diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 00000000..e5b6d8d6 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 00000000..91b6a951 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/package.json b/package.json index 5a05622c..b84064ec 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sdk-monorepo", "displayName": "Puzzle SDK", - "version": "0.3.1", + "version": "0.4.0", "description": "Your portal to privacy", "type": "module", "workspaces": [ @@ -13,7 +13,9 @@ "pretty": "pnpm exec prettier . --write" }, "dependencies": { - "@puzzlehq/types": "1.0.11" + "@changesets/cli": "^2.27.1", + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6" }, "devDependencies": { "@types/chrome": "^0.0.228", @@ -42,15 +44,5 @@ "bugs": { "url": "https://github.com/puzzlehq/puzzle-sdk/issues" }, - "homepage": "https://github.com/puzzlehq/puzzle-sdk#readme", - "pnpm": { - "overrides": { - "@walletconnect/core": "^2.11.2", - "@walletconnect/sign-client": "^2.11.2" - }, - "patchedDependencies": { - "@walletconnect/modal-ui@2.6.2": "patches/@walletconnect__modal-ui@2.6.2.patch", - "@walletconnect/modal-core@2.6.2": "patches/@walletconnect__modal-core@2.6.2.patch" - } - } + "homepage": "https://github.com/puzzlehq/puzzle-sdk#readme" } diff --git a/packages/core/dist/index-0kpjH3lP.js b/packages/core/dist/index-0kpjH3lP.js deleted file mode 100644 index 51671476..00000000 --- a/packages/core/dist/index-0kpjH3lP.js +++ /dev/null @@ -1,17516 +0,0 @@ -const t = Symbol(); -const s = Object.getPrototypeOf, c$2 = /* @__PURE__ */ new WeakMap(), l$2 = (e) => e && (c$2.has(e) ? c$2.get(e) : s(e) === Object.prototype || s(e) === Array.prototype), y$4 = (e) => l$2(e) && e[t] || null, h$4 = (e, t2 = true) => { - c$2.set(e, t2); -}; -var define_import_meta_env_default = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false }; -const isObject = (x2) => typeof x2 === "object" && x2 !== null; -const proxyStateMap = /* @__PURE__ */ new WeakMap(); -const refSet = /* @__PURE__ */ new WeakSet(); -const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x2) => isObject(x2) && !refSet.has(x2) && (Array.isArray(x2) || !(Symbol.iterator in x2)) && !(x2 instanceof WeakMap) && !(x2 instanceof WeakSet) && !(x2 instanceof Error) && !(x2 instanceof Number) && !(x2 instanceof Date) && !(x2 instanceof String) && !(x2 instanceof RegExp) && !(x2 instanceof ArrayBuffer), defaultHandlePromise = (promise) => { - switch (promise.status) { - case "fulfilled": - return promise.value; - case "rejected": - throw promise.reason; - default: - throw promise; - } -}, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version2, handlePromise = defaultHandlePromise) => { - const cache = snapCache.get(target); - if ((cache == null ? void 0 : cache[0]) === version2) { - return cache[1]; - } - const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); - h$4(snap, true); - snapCache.set(target, [version2, snap]); - Reflect.ownKeys(target).forEach((key) => { - if (Object.getOwnPropertyDescriptor(snap, key)) { - return; - } - const value = Reflect.get(target, key); - const desc = { - value, - enumerable: true, - // This is intentional to avoid copying with proxy-compare. - // It's still non-writable, so it avoids assigning a value. - configurable: true - }; - if (refSet.has(value)) { - h$4(value, false); - } else if (value instanceof Promise) { - delete desc.value; - desc.get = () => handlePromise(value); - } else if (proxyStateMap.has(value)) { - const [target2, ensureVersion] = proxyStateMap.get( - value - ); - desc.value = createSnapshot( - target2, - ensureVersion(), - handlePromise - ); - } - Object.defineProperty(snap, key, desc); - }); - return Object.preventExtensions(snap); -}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { - if (!isObject(initialObject)) { - throw new Error("object required"); - } - const found = proxyCache.get(initialObject); - if (found) { - return found; - } - let version2 = versionHolder[0]; - const listeners2 = /* @__PURE__ */ new Set(); - const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => { - if (version2 !== nextVersion) { - version2 = nextVersion; - listeners2.forEach((listener) => listener(op, nextVersion)); - } - }; - let checkVersion = versionHolder[1]; - const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => { - if (checkVersion !== nextCheckVersion && !listeners2.size) { - checkVersion = nextCheckVersion; - propProxyStates.forEach(([propProxyState]) => { - const propVersion = propProxyState[1](nextCheckVersion); - if (propVersion > version2) { - version2 = propVersion; - } - }); - } - return version2; - }; - const createPropListener = (prop) => (op, nextVersion) => { - const newOp = [...op]; - newOp[1] = [prop, ...newOp[1]]; - notifyUpdate(newOp, nextVersion); - }; - const propProxyStates = /* @__PURE__ */ new Map(); - const addPropListener = (prop, propProxyState) => { - if ((define_import_meta_env_default ? "production" : void 0) !== "production" && propProxyStates.has(prop)) { - throw new Error("prop listener already exists"); - } - if (listeners2.size) { - const remove = propProxyState[3](createPropListener(prop)); - propProxyStates.set(prop, [propProxyState, remove]); - } else { - propProxyStates.set(prop, [propProxyState]); - } - }; - const removePropListener = (prop) => { - var _a; - const entry = propProxyStates.get(prop); - if (entry) { - propProxyStates.delete(prop); - (_a = entry[1]) == null ? void 0 : _a.call(entry); - } - }; - const addListener2 = (listener) => { - listeners2.add(listener); - if (listeners2.size === 1) { - propProxyStates.forEach(([propProxyState, prevRemove], prop) => { - if ((define_import_meta_env_default ? "production" : void 0) !== "production" && prevRemove) { - throw new Error("remove already exists"); - } - const remove = propProxyState[3](createPropListener(prop)); - propProxyStates.set(prop, [propProxyState, remove]); - }); - } - const removeListener2 = () => { - listeners2.delete(listener); - if (listeners2.size === 0) { - propProxyStates.forEach(([propProxyState, remove], prop) => { - if (remove) { - remove(); - propProxyStates.set(prop, [propProxyState]); - } - }); - } - }; - return removeListener2; - }; - const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); - const handler = { - deleteProperty(target, prop) { - const prevValue = Reflect.get(target, prop); - removePropListener(prop); - const deleted = Reflect.deleteProperty(target, prop); - if (deleted) { - notifyUpdate(["delete", [prop], prevValue]); - } - return deleted; - }, - set(target, prop, value, receiver) { - const hasPrevValue = Reflect.has(target, prop); - const prevValue = Reflect.get(target, prop, receiver); - if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { - return true; - } - removePropListener(prop); - if (isObject(value)) { - value = y$4(value) || value; - } - let nextValue = value; - if (value instanceof Promise) { - value.then((v3) => { - value.status = "fulfilled"; - value.value = v3; - notifyUpdate(["resolve", [prop], v3]); - }).catch((e) => { - value.status = "rejected"; - value.reason = e; - notifyUpdate(["reject", [prop], e]); - }); - } else { - if (!proxyStateMap.has(value) && canProxy(value)) { - nextValue = proxyFunction(value); - } - const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); - if (childProxyState) { - addPropListener(prop, childProxyState); - } - } - Reflect.set(target, prop, nextValue, receiver); - notifyUpdate(["set", [prop], value, prevValue]); - return true; - } - }; - const proxyObject = newProxy(baseObject, handler); - proxyCache.set(initialObject, proxyObject); - const proxyState = [ - baseObject, - ensureVersion, - createSnapshot, - addListener2 - ]; - proxyStateMap.set(proxyObject, proxyState); - Reflect.ownKeys(initialObject).forEach((key) => { - const desc = Object.getOwnPropertyDescriptor( - initialObject, - key - ); - if ("value" in desc) { - proxyObject[key] = initialObject[key]; - delete desc.value; - delete desc.writable; - } - Object.defineProperty(baseObject, key, desc); - }); - return proxyObject; -}) => [ - // public functions - proxyFunction, - // shared state - proxyStateMap, - refSet, - // internal things - objectIs, - newProxy, - canProxy, - defaultHandlePromise, - snapCache, - createSnapshot, - proxyCache, - versionHolder -]; -const [defaultProxyFunction] = buildProxyFunction(); -function proxy(initialObject = {}) { - return defaultProxyFunction(initialObject); -} -function subscribe(proxyObject, callback, notifyInSync) { - const proxyState = proxyStateMap.get(proxyObject); - if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !proxyState) { - console.warn("Please use proxy object"); - } - let promise; - const ops = []; - const addListener2 = proxyState[3]; - let isListenerActive = false; - const listener = (op) => { - ops.push(op); - if (notifyInSync) { - callback(ops.splice(0)); - return; - } - if (!promise) { - promise = Promise.resolve().then(() => { - promise = void 0; - if (isListenerActive) { - callback(ops.splice(0)); - } - }); - } - }; - const removeListener2 = addListener2(listener); - isListenerActive = true; - return () => { - isListenerActive = false; - removeListener2(); - }; -} -function snapshot(proxyObject, handlePromise) { - const proxyState = proxyStateMap.get(proxyObject); - if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !proxyState) { - console.warn("Please use proxy object"); - } - const [target, ensureVersion, createSnapshot] = proxyState; - return createSnapshot(target, ensureVersion(), handlePromise); -} -const o$1 = proxy({ - history: ["ConnectWallet"], - view: "ConnectWallet", - data: void 0 -}), T$1 = { - state: o$1, - subscribe(e) { - return subscribe(o$1, () => e(o$1)); - }, - push(e, t2) { - e !== o$1.view && (o$1.view = e, t2 && (o$1.data = t2), o$1.history.push(e)); - }, - reset(e) { - o$1.view = e, o$1.history = [e]; - }, - replace(e) { - o$1.history.length > 1 && (o$1.history[o$1.history.length - 1] = e, o$1.view = e); - }, - goBack() { - if (o$1.history.length > 1) { - o$1.history.pop(); - const [e] = o$1.history.slice(-1); - o$1.view = e; - } - }, - setData(e) { - o$1.data = e; - } -}, a$3 = { - WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", - WCM_VERSION: "WCM_VERSION", - RECOMMENDED_WALLET_AMOUNT: 9, - isMobile() { - return typeof window < "u" ? Boolean( - window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test( - navigator.userAgent - ) - ) : false; - }, - isAndroid() { - return a$3.isMobile() && navigator.userAgent.toLowerCase().includes("android"); - }, - isIos() { - const e = navigator.userAgent.toLowerCase(); - return a$3.isMobile() && (e.includes("iphone") || e.includes("ipad")); - }, - isHttpUrl(e) { - return e.startsWith("http://") || e.startsWith("https://"); - }, - isArray(e) { - return Array.isArray(e) && e.length > 0; - }, - formatNativeUrl(e, t2, s2) { - if (a$3.isHttpUrl(e)) - return this.formatUniversalUrl(e, t2, s2); - let n3 = e; - n3.includes("://") || (n3 = e.replaceAll("/", "").replaceAll(":", ""), n3 = `${n3}://`), n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - formatUniversalUrl(e, t2, s2) { - if (!a$3.isHttpUrl(e)) - return this.formatNativeUrl(e, t2, s2); - let n3 = e; - n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - async wait(e) { - return new Promise((t2) => { - setTimeout(t2, e); - }); - }, - openHref(e, t2) { - window.open(e, t2, "noreferrer noopener"); - }, - setWalletConnectDeepLink(e, t2) { - try { - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: e, name: t2 }) - ); - } catch { - console.info("Unable to set WalletConnect deep link"); - } - }, - setWalletConnectAndroidDeepLink(e) { - try { - const [t2] = e.split("?"); - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: t2, name: "Android" }) - ); - } catch { - console.info("Unable to set WalletConnect android deep link"); - } - }, - removeWalletConnectDeepLink() { - try { - localStorage.removeItem(a$3.WALLETCONNECT_DEEPLINK_CHOICE); - } catch { - console.info("Unable to remove WalletConnect deep link"); - } - }, - setModalVersionInStorage() { - try { - typeof localStorage < "u" && localStorage.setItem(a$3.WCM_VERSION, "2.6.2"); - } catch { - console.info("Unable to set Web3Modal version in storage"); - } - }, - getWalletRouterData() { - var e; - const t2 = (e = T$1.state.data) == null ? void 0 : e.Wallet; - if (!t2) - throw new Error('Missing "Wallet" view data'); - return t2; - } -}, _$3 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), r$1 = proxy({ - enabled: _$3, - userSessionId: "", - events: [], - connectedWalletId: void 0 -}), R$4 = { - state: r$1, - subscribe(e) { - return subscribe(r$1.events, () => e(snapshot(r$1.events[r$1.events.length - 1]))); - }, - initialize() { - r$1.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (r$1.userSessionId = crypto.randomUUID()); - }, - setConnectedWalletId(e) { - r$1.connectedWalletId = e; - }, - click(e) { - if (r$1.enabled) { - const t2 = { - type: "CLICK", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - }, - track(e) { - if (r$1.enabled) { - const t2 = { - type: "TRACK", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - }, - view(e) { - if (r$1.enabled) { - const t2 = { - type: "VIEW", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - } -}, c$1 = proxy({ - chains: void 0, - walletConnectUri: void 0, - isAuth: false, - isCustomDesktop: false, - isCustomMobile: false, - isDataLoaded: false, - isUiLoaded: false -}), p$3 = { - state: c$1, - subscribe(e) { - return subscribe(c$1, () => e(c$1)); - }, - setChains(e) { - c$1.chains = e; - }, - setWalletConnectUri(e) { - c$1.walletConnectUri = e; - }, - setIsCustomDesktop(e) { - c$1.isCustomDesktop = e; - }, - setIsCustomMobile(e) { - c$1.isCustomMobile = e; - }, - setIsDataLoaded(e) { - c$1.isDataLoaded = e; - }, - setIsUiLoaded(e) { - c$1.isUiLoaded = e; - }, - setIsAuth(e) { - c$1.isAuth = e; - } -}, W$2 = proxy({ - projectId: "", - mobileWallets: void 0, - desktopWallets: void 0, - walletImages: void 0, - chains: void 0, - enableAuthMode: false, - enableExplorer: true, - explorerExcludedWalletIds: void 0, - explorerRecommendedWalletIds: void 0, - termsOfServiceUrl: void 0, - privacyPolicyUrl: void 0 -}), y$3 = { - state: W$2, - subscribe(e) { - return subscribe(W$2, () => e(W$2)); - }, - setConfig(e) { - var t2, s2; - R$4.initialize(), p$3.setChains(e.chains), p$3.setIsAuth(Boolean(e.enableAuthMode)), p$3.setIsCustomMobile( - Boolean((t2 = e.mobileWallets) == null ? void 0 : t2.length) - ), p$3.setIsCustomDesktop( - Boolean((s2 = e.desktopWallets) == null ? void 0 : s2.length) - ), a$3.setModalVersionInStorage(), Object.assign(W$2, e); - } -}; -var V$2 = Object.defineProperty, D$4 = Object.getOwnPropertySymbols, H$2 = Object.prototype.hasOwnProperty, B$2 = Object.prototype.propertyIsEnumerable, M$1 = (e, t2, s2) => t2 in e ? V$2(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, K$1 = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - H$2.call(t2, s2) && M$1(e, s2, t2[s2]); - if (D$4) - for (var s2 of D$4(t2)) - B$2.call(t2, s2) && M$1(e, s2, t2[s2]); - return e; -}; -const L$2 = "https://explorer-api.walletconnect.com", E$2 = "wcm", O$3 = "js-2.6.2"; -async function w$5(e, t2) { - const s2 = K$1({ sdkType: E$2, sdkVersion: O$3 }, t2), n3 = new URL(e, L$2); - return n3.searchParams.append("projectId", y$3.state.projectId), Object.entries(s2).forEach(([i2, l2]) => { - l2 && n3.searchParams.append(i2, String(l2)); - }), (await fetch(n3)).json(); -} -const m$2 = { - async getDesktopListings(e) { - return w$5("/w3m/v1/getDesktopListings", e); - }, - async getMobileListings(e) { - return w$5("/w3m/v1/getMobileListings", e); - }, - async getInjectedListings(e) { - return w$5("/w3m/v1/getInjectedListings", e); - }, - async getAllListings(e) { - return w$5("/w3m/v1/getAllListings", e); - }, - getWalletImageUrl(e) { - return `${L$2}/w3m/v1/getWalletImage/${e}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; - }, - getAssetImageUrl(e) { - return `${L$2}/w3m/v1/getAssetImage/${e}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; - } -}; -var z$3 = Object.defineProperty, j$3 = Object.getOwnPropertySymbols, J$2 = Object.prototype.hasOwnProperty, q$2 = Object.prototype.propertyIsEnumerable, k$2 = (e, t2, s2) => t2 in e ? z$3(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, F$3 = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - J$2.call(t2, s2) && k$2(e, s2, t2[s2]); - if (j$3) - for (var s2 of j$3(t2)) - q$2.call(t2, s2) && k$2(e, s2, t2[s2]); - return e; -}; -const N$3 = a$3.isMobile(), d$2 = proxy({ - wallets: { listings: [], total: 0, page: 1 }, - search: { listings: [], total: 0, page: 1 }, - recomendedWallets: [] -}), te$2 = { - state: d$2, - async getRecomendedWallets() { - const { explorerRecommendedWalletIds: e, explorerExcludedWalletIds: t2 } = y$3.state; - if (e === "NONE" || t2 === "ALL" && !e) - return d$2.recomendedWallets; - if (a$3.isArray(e)) { - const s2 = { recommendedIds: e.join(",") }, { listings: n3 } = await m$2.getAllListings(s2), i2 = Object.values(n3); - i2.sort && i2.sort((l2, v3) => { - const b3 = e.indexOf(l2.id), f2 = e.indexOf(v3.id); - return b3 - f2; - }), d$2.recomendedWallets = i2; - } else { - const { chains: s2, isAuth: n3 } = p$3.state, i2 = s2 == null ? void 0 : s2.join(","), l2 = a$3.isArray(t2), v3 = { - page: 1, - sdks: n3 ? "auth_v1" : void 0, - entries: a$3.RECOMMENDED_WALLET_AMOUNT, - chains: i2, - version: 2, - excludedIds: l2 ? t2.join(",") : void 0 - }, { listings: b3 } = N$3 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); - d$2.recomendedWallets = Object.values(b3); - } - return d$2.recomendedWallets; - }, - async getWallets(e) { - const t2 = F$3({}, e), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n3 } = y$3.state, { recomendedWallets: i2 } = d$2; - if (n3 === "ALL") - return d$2.wallets; - i2.length ? t2.excludedIds = i2.map((x2) => x2.id).join(",") : a$3.isArray(s2) && (t2.excludedIds = s2.join(",")), a$3.isArray(n3) && (t2.excludedIds = [t2.excludedIds, n3].filter(Boolean).join(",")), p$3.state.isAuth && (t2.sdks = "auth_v1"); - const { page: l2, search: v3 } = e, { listings: b3, total: f2 } = N$3 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; - return d$2[U2] = { listings: [...d$2[U2].listings, ...A2], total: f2, page: l2 ?? 1 }, { listings: A2, total: f2 }; - }, - getWalletImageUrl(e) { - return m$2.getWalletImageUrl(e); - }, - getAssetImageUrl(e) { - return m$2.getAssetImageUrl(e); - }, - resetSearch() { - d$2.search = { listings: [], total: 0, page: 1 }; - } -}, I$1 = proxy({ open: false }), se = { - state: I$1, - subscribe(e) { - return subscribe(I$1, () => e(I$1)); - }, - async open(e) { - return new Promise((t2) => { - const { isUiLoaded: s2, isDataLoaded: n3 } = p$3.state; - if (a$3.removeWalletConnectDeepLink(), p$3.setWalletConnectUri(e == null ? void 0 : e.uri), p$3.setChains(e == null ? void 0 : e.chains), T$1.reset("ConnectWallet"), s2 && n3) - I$1.open = true, t2(); - else { - const i2 = setInterval(() => { - const l2 = p$3.state; - l2.isUiLoaded && l2.isDataLoaded && (clearInterval(i2), I$1.open = true, t2()); - }, 200); - } - }); - }, - close() { - I$1.open = false; - } -}; -var G$2 = Object.defineProperty, $$2 = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$2 = Object.prototype.propertyIsEnumerable, S$2 = (e, t2, s2) => t2 in e ? G$2(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, Y = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - Q$3.call(t2, s2) && S$2(e, s2, t2[s2]); - if ($$2) - for (var s2 of $$2(t2)) - X$2.call(t2, s2) && S$2(e, s2, t2[s2]); - return e; -}; -function Z$2() { - return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; -} -const C = proxy({ themeMode: Z$2() ? "dark" : "light" }), ne = { - state: C, - subscribe(e) { - return subscribe(C, () => e(C)); - }, - setThemeConfig(e) { - const { themeMode: t2, themeVariables: s2 } = e; - t2 && (C.themeMode = t2), s2 && (C.themeVariables = Y({}, s2)); - } -}, g$5 = proxy({ open: false, message: "", variant: "success" }), oe$1 = { - state: g$5, - subscribe(e) { - return subscribe(g$5, () => e(g$5)); - }, - openToast(e, t2) { - g$5.open = true, g$5.message = e, g$5.variant = t2; - }, - closeToast() { - g$5.open = false; - } -}; -let d$1 = class d { - constructor(e) { - this.openModal = se.open, this.closeModal = se.close, this.subscribeModal = se.subscribe, this.setTheme = ne.setThemeConfig, ne.setThemeConfig(e), y$3.setConfig(e), this.initUi(); - } - async initUi() { - if (typeof window < "u") { - await import("./index-B2etef5O.js"); - const e = document.createElement("wcm-modal"); - document.body.insertAdjacentElement("beforeend", e), p$3.setIsUiLoaded(true); - } - } -}; -var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; -function getDefaultExportFromCjs(x2) { - return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; -} -function getAugmentedNamespace(n3) { - if (n3.__esModule) - return n3; - var f2 = n3.default; - if (typeof f2 == "function") { - var a3 = function a4() { - if (this instanceof a4) { - return Reflect.construct(f2, arguments, this.constructor); - } - return f2.apply(this, arguments); - }; - a3.prototype = f2.prototype; - } else - a3 = {}; - Object.defineProperty(a3, "__esModule", { value: true }); - Object.keys(n3).forEach(function(k2) { - var d3 = Object.getOwnPropertyDescriptor(n3, k2); - Object.defineProperty(a3, k2, d3.get ? d3 : { - enumerable: true, - get: function() { - return n3[k2]; - } - }); - }); - return a3; -} -var events = { exports: {} }; -var R$3 = typeof Reflect === "object" ? Reflect : null; -var ReflectApply = R$3 && typeof R$3.apply === "function" ? R$3.apply : function ReflectApply2(target, receiver, args) { - return Function.prototype.apply.call(target, receiver, args); -}; -var ReflectOwnKeys; -if (R$3 && typeof R$3.ownKeys === "function") { - ReflectOwnKeys = R$3.ownKeys; -} else if (Object.getOwnPropertySymbols) { - ReflectOwnKeys = function ReflectOwnKeys2(target) { - return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); - }; -} else { - ReflectOwnKeys = function ReflectOwnKeys2(target) { - return Object.getOwnPropertyNames(target); - }; -} -function ProcessEmitWarning(warning) { - if (console && console.warn) - console.warn(warning); -} -var NumberIsNaN = Number.isNaN || function NumberIsNaN2(value) { - return value !== value; -}; -function EventEmitter() { - EventEmitter.init.call(this); -} -events.exports = EventEmitter; -events.exports.once = once2; -EventEmitter.EventEmitter = EventEmitter; -EventEmitter.prototype._events = void 0; -EventEmitter.prototype._eventsCount = 0; -EventEmitter.prototype._maxListeners = void 0; -var defaultMaxListeners = 10; -function checkListener(listener) { - if (typeof listener !== "function") { - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); - } -} -Object.defineProperty(EventEmitter, "defaultMaxListeners", { - enumerable: true, - get: function() { - return defaultMaxListeners; - }, - set: function(arg) { - if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) { - throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + "."); - } - defaultMaxListeners = arg; - } -}); -EventEmitter.init = function() { - if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) { - this._events = /* @__PURE__ */ Object.create(null); - this._eventsCount = 0; - } - this._maxListeners = this._maxListeners || void 0; -}; -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n3) { - if (typeof n3 !== "number" || n3 < 0 || NumberIsNaN(n3)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n3 + "."); - } - this._maxListeners = n3; - return this; -}; -function _getMaxListeners(that) { - if (that._maxListeners === void 0) - return EventEmitter.defaultMaxListeners; - return that._maxListeners; -} -EventEmitter.prototype.getMaxListeners = function getMaxListeners() { - return _getMaxListeners(this); -}; -EventEmitter.prototype.emit = function emit(type2) { - var args = []; - for (var i2 = 1; i2 < arguments.length; i2++) - args.push(arguments[i2]); - var doError = type2 === "error"; - var events2 = this._events; - if (events2 !== void 0) - doError = doError && events2.error === void 0; - else if (!doError) - return false; - if (doError) { - var er2; - if (args.length > 0) - er2 = args[0]; - if (er2 instanceof Error) { - throw er2; - } - var err = new Error("Unhandled error." + (er2 ? " (" + er2.message + ")" : "")); - err.context = er2; - throw err; - } - var handler = events2[type2]; - if (handler === void 0) - return false; - if (typeof handler === "function") { - ReflectApply(handler, this, args); - } else { - var len = handler.length; - var listeners2 = arrayClone(handler, len); - for (var i2 = 0; i2 < len; ++i2) - ReflectApply(listeners2[i2], this, args); - } - return true; -}; -function _addListener(target, type2, listener, prepend) { - var m2; - var events2; - var existing; - checkListener(listener); - events2 = target._events; - if (events2 === void 0) { - events2 = target._events = /* @__PURE__ */ Object.create(null); - target._eventsCount = 0; - } else { - if (events2.newListener !== void 0) { - target.emit( - "newListener", - type2, - listener.listener ? listener.listener : listener - ); - events2 = target._events; - } - existing = events2[type2]; - } - if (existing === void 0) { - existing = events2[type2] = listener; - ++target._eventsCount; - } else { - if (typeof existing === "function") { - existing = events2[type2] = prepend ? [listener, existing] : [existing, listener]; - } else if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } - m2 = _getMaxListeners(target); - if (m2 > 0 && existing.length > m2 && !existing.warned) { - existing.warned = true; - var w3 = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type2) + " listeners added. Use emitter.setMaxListeners() to increase limit"); - w3.name = "MaxListenersExceededWarning"; - w3.emitter = target; - w3.type = type2; - w3.count = existing.length; - ProcessEmitWarning(w3); - } - } - return target; -} -EventEmitter.prototype.addListener = function addListener(type2, listener) { - return _addListener(this, type2, listener, false); -}; -EventEmitter.prototype.on = EventEmitter.prototype.addListener; -EventEmitter.prototype.prependListener = function prependListener(type2, listener) { - return _addListener(this, type2, listener, true); -}; -function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - if (arguments.length === 0) - return this.listener.call(this.target); - return this.listener.apply(this.target, arguments); - } -} -function _onceWrap(target, type2, listener) { - var state = { fired: false, wrapFn: void 0, target, type: type2, listener }; - var wrapped = onceWrapper.bind(state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; -} -EventEmitter.prototype.once = function once(type2, listener) { - checkListener(listener); - this.on(type2, _onceWrap(this, type2, listener)); - return this; -}; -EventEmitter.prototype.prependOnceListener = function prependOnceListener(type2, listener) { - checkListener(listener); - this.prependListener(type2, _onceWrap(this, type2, listener)); - return this; -}; -EventEmitter.prototype.removeListener = function removeListener(type2, listener) { - var list, events2, position, i2, originalListener; - checkListener(listener); - events2 = this._events; - if (events2 === void 0) - return this; - list = events2[type2]; - if (list === void 0) - return this; - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) - this._events = /* @__PURE__ */ Object.create(null); - else { - delete events2[type2]; - if (events2.removeListener) - this.emit("removeListener", type2, list.listener || listener); - } - } else if (typeof list !== "function") { - position = -1; - for (i2 = list.length - 1; i2 >= 0; i2--) { - if (list[i2] === listener || list[i2].listener === listener) { - originalListener = list[i2].listener; - position = i2; - break; - } - } - if (position < 0) - return this; - if (position === 0) - list.shift(); - else { - spliceOne(list, position); - } - if (list.length === 1) - events2[type2] = list[0]; - if (events2.removeListener !== void 0) - this.emit("removeListener", type2, originalListener || listener); - } - return this; -}; -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; -EventEmitter.prototype.removeAllListeners = function removeAllListeners(type2) { - var listeners2, events2, i2; - events2 = this._events; - if (events2 === void 0) - return this; - if (events2.removeListener === void 0) { - if (arguments.length === 0) { - this._events = /* @__PURE__ */ Object.create(null); - this._eventsCount = 0; - } else if (events2[type2] !== void 0) { - if (--this._eventsCount === 0) - this._events = /* @__PURE__ */ Object.create(null); - else - delete events2[type2]; - } - return this; - } - if (arguments.length === 0) { - var keys2 = Object.keys(events2); - var key; - for (i2 = 0; i2 < keys2.length; ++i2) { - key = keys2[i2]; - if (key === "removeListener") - continue; - this.removeAllListeners(key); - } - this.removeAllListeners("removeListener"); - this._events = /* @__PURE__ */ Object.create(null); - this._eventsCount = 0; - return this; - } - listeners2 = events2[type2]; - if (typeof listeners2 === "function") { - this.removeListener(type2, listeners2); - } else if (listeners2 !== void 0) { - for (i2 = listeners2.length - 1; i2 >= 0; i2--) { - this.removeListener(type2, listeners2[i2]); - } - } - return this; -}; -function _listeners(target, type2, unwrap) { - var events2 = target._events; - if (events2 === void 0) - return []; - var evlistener = events2[type2]; - if (evlistener === void 0) - return []; - if (typeof evlistener === "function") - return unwrap ? [evlistener.listener || evlistener] : [evlistener]; - return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); -} -EventEmitter.prototype.listeners = function listeners(type2) { - return _listeners(this, type2, true); -}; -EventEmitter.prototype.rawListeners = function rawListeners(type2) { - return _listeners(this, type2, false); -}; -EventEmitter.listenerCount = function(emitter2, type2) { - if (typeof emitter2.listenerCount === "function") { - return emitter2.listenerCount(type2); - } else { - return listenerCount.call(emitter2, type2); - } -}; -EventEmitter.prototype.listenerCount = listenerCount; -function listenerCount(type2) { - var events2 = this._events; - if (events2 !== void 0) { - var evlistener = events2[type2]; - if (typeof evlistener === "function") { - return 1; - } else if (evlistener !== void 0) { - return evlistener.length; - } - } - return 0; -} -EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; -}; -function arrayClone(arr, n3) { - var copy = new Array(n3); - for (var i2 = 0; i2 < n3; ++i2) - copy[i2] = arr[i2]; - return copy; -} -function spliceOne(list, index) { - for (; index + 1 < list.length; index++) - list[index] = list[index + 1]; - list.pop(); -} -function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i2 = 0; i2 < ret.length; ++i2) { - ret[i2] = arr[i2].listener || arr[i2]; - } - return ret; -} -function once2(emitter2, name2) { - return new Promise(function(resolve, reject) { - function errorListener(err) { - emitter2.removeListener(name2, resolver); - reject(err); - } - function resolver() { - if (typeof emitter2.removeListener === "function") { - emitter2.removeListener("error", errorListener); - } - resolve([].slice.call(arguments)); - } - eventTargetAgnosticAddListener(emitter2, name2, resolver, { once: true }); - if (name2 !== "error") { - addErrorHandlerIfEventEmitter(emitter2, errorListener, { once: true }); - } - }); -} -function addErrorHandlerIfEventEmitter(emitter2, handler, flags) { - if (typeof emitter2.on === "function") { - eventTargetAgnosticAddListener(emitter2, "error", handler, flags); - } -} -function eventTargetAgnosticAddListener(emitter2, name2, listener, flags) { - if (typeof emitter2.on === "function") { - if (flags.once) { - emitter2.once(name2, listener); - } else { - emitter2.on(name2, listener); - } - } else if (typeof emitter2.addEventListener === "function") { - emitter2.addEventListener(name2, function wrapListener(arg) { - if (flags.once) { - emitter2.removeEventListener(name2, wrapListener); - } - listener(arg); - }); - } else { - throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter2); - } -} -var eventsExports = events.exports; -const EventEmitter$1 = /* @__PURE__ */ getDefaultExportFromCjs(eventsExports); -const suspectProtoRx = /"(?:_|\\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*:/; -const suspectConstructorRx = /"(?: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*:/; -const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/; -function jsonParseTransform(key, value) { - if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) { - warnKeyDropped(key); - return; - } - return value; -} -function warnKeyDropped(key) { - console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`); -} -function destr(value, options = {}) { - if (typeof value !== "string") { - return value; - } - const _value = value.trim(); - if ( - // eslint-disable-next-line unicorn/prefer-at - value[0] === '"' && value.endsWith('"') && !value.includes("\\") - ) { - return _value.slice(1, -1); - } - if (_value.length <= 9) { - const _lval = _value.toLowerCase(); - if (_lval === "true") { - return true; - } - if (_lval === "false") { - return false; - } - if (_lval === "undefined") { - return void 0; - } - if (_lval === "null") { - return null; - } - if (_lval === "nan") { - return Number.NaN; - } - if (_lval === "infinity") { - return Number.POSITIVE_INFINITY; - } - if (_lval === "-infinity") { - return Number.NEGATIVE_INFINITY; - } - } - if (!JsonSigRx.test(value)) { - if (options.strict) { - throw new SyntaxError("[destr] Invalid JSON"); - } - return value; - } - try { - if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) { - if (options.strict) { - throw new Error("[destr] Possible prototype pollution"); - } - return JSON.parse(value, jsonParseTransform); - } - return JSON.parse(value); - } catch (error) { - if (options.strict) { - throw error; - } - return value; - } -} -function wrapToPromise(value) { - if (!value || typeof value.then !== "function") { - return Promise.resolve(value); - } - return value; -} -function asyncCall(function_, ...arguments_) { - try { - return wrapToPromise(function_(...arguments_)); - } catch (error) { - return Promise.reject(error); - } -} -function isPrimitive(value) { - const type2 = typeof value; - return value === null || type2 !== "object" && type2 !== "function"; -} -function isPureObject(value) { - const proto = Object.getPrototypeOf(value); - return !proto || proto.isPrototypeOf(Object); -} -function stringify(value) { - if (isPrimitive(value)) { - return String(value); - } - if (isPureObject(value) || Array.isArray(value)) { - return JSON.stringify(value); - } - if (typeof value.toJSON === "function") { - return stringify(value.toJSON()); - } - throw new Error("[unstorage] Cannot stringify value!"); -} -function checkBufferSupport() { - if (typeof Buffer === void 0) { - throw new TypeError("[unstorage] Buffer is not supported!"); - } -} -const BASE64_PREFIX = "base64:"; -function serializeRaw(value) { - if (typeof value === "string") { - return value; - } - checkBufferSupport(); - const base642 = Buffer.from(value).toString("base64"); - return BASE64_PREFIX + base642; -} -function deserializeRaw(value) { - if (typeof value !== "string") { - return value; - } - if (!value.startsWith(BASE64_PREFIX)) { - return value; - } - checkBufferSupport(); - return Buffer.from(value.slice(BASE64_PREFIX.length), "base64"); -} -function normalizeKey(key) { - if (!key) { - return ""; - } - return key.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, ""); -} -function joinKeys(...keys2) { - return normalizeKey(keys2.join(":")); -} -function normalizeBaseKey(base3) { - base3 = normalizeKey(base3); - return base3 ? base3 + ":" : ""; -} -function defineDriver(factory) { - return factory; -} -const DRIVER_NAME = "memory"; -const memory = defineDriver(() => { - const data = /* @__PURE__ */ new Map(); - return { - name: DRIVER_NAME, - options: {}, - hasItem(key) { - return data.has(key); - }, - getItem(key) { - return data.get(key) ?? null; - }, - getItemRaw(key) { - return data.get(key) ?? null; - }, - setItem(key, value) { - data.set(key, value); - }, - setItemRaw(key, value) { - data.set(key, value); - }, - removeItem(key) { - data.delete(key); - }, - getKeys() { - return Array.from(data.keys()); - }, - clear() { - data.clear(); - }, - dispose() { - data.clear(); - } - }; -}); -function createStorage(options = {}) { - const context = { - mounts: { "": options.driver || memory() }, - mountpoints: [""], - watching: false, - watchListeners: [], - unwatch: {} - }; - const getMount = (key) => { - for (const base3 of context.mountpoints) { - if (key.startsWith(base3)) { - return { - base: base3, - relativeKey: key.slice(base3.length), - driver: context.mounts[base3] - }; - } - } - return { - base: "", - relativeKey: key, - driver: context.mounts[""] - }; - }; - const getMounts = (base3, includeParent) => { - return context.mountpoints.filter( - (mountpoint) => mountpoint.startsWith(base3) || includeParent && base3.startsWith(mountpoint) - ).map((mountpoint) => ({ - relativeBase: base3.length > mountpoint.length ? base3.slice(mountpoint.length) : void 0, - mountpoint, - driver: context.mounts[mountpoint] - })); - }; - const onChange = (event, key) => { - if (!context.watching) { - return; - } - key = normalizeKey(key); - for (const listener of context.watchListeners) { - listener(event, key); - } - }; - const startWatch = async () => { - if (context.watching) { - return; - } - context.watching = true; - for (const mountpoint in context.mounts) { - context.unwatch[mountpoint] = await watch$2( - context.mounts[mountpoint], - onChange, - mountpoint - ); - } - }; - const stopWatch = async () => { - if (!context.watching) { - return; - } - for (const mountpoint in context.unwatch) { - await context.unwatch[mountpoint](); - } - context.unwatch = {}; - context.watching = false; - }; - const runBatch = (items, commonOptions, cb) => { - const batches = /* @__PURE__ */ new Map(); - const getBatch = (mount) => { - let batch = batches.get(mount.base); - if (!batch) { - batch = { - driver: mount.driver, - base: mount.base, - items: [] - }; - batches.set(mount.base, batch); - } - return batch; - }; - for (const item of items) { - const isStringItem = typeof item === "string"; - const key = normalizeKey(isStringItem ? item : item.key); - const value = isStringItem ? void 0 : item.value; - const options2 = isStringItem || !item.options ? commonOptions : { ...commonOptions, ...item.options }; - const mount = getMount(key); - getBatch(mount).items.push({ - key, - value, - relativeKey: mount.relativeKey, - options: options2 - }); - } - return Promise.all([...batches.values()].map((batch) => cb(batch))).then( - (r2) => r2.flat() - ); - }; - const storage = { - // Item - hasItem(key, opts = {}) { - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - return asyncCall(driver.hasItem, relativeKey, opts); - }, - getItem(key, opts = {}) { - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - return asyncCall(driver.getItem, relativeKey, opts).then( - (value) => destr(value) - ); - }, - getItems(items, commonOptions) { - return runBatch(items, commonOptions, (batch) => { - if (batch.driver.getItems) { - return asyncCall( - batch.driver.getItems, - batch.items.map((item) => ({ - key: item.relativeKey, - options: item.options - })), - commonOptions - ).then( - (r2) => r2.map((item) => ({ - key: joinKeys(batch.base, item.key), - value: destr(item.value) - })) - ); - } - return Promise.all( - batch.items.map((item) => { - return asyncCall( - batch.driver.getItem, - item.relativeKey, - item.options - ).then((value) => ({ - key: item.key, - value: destr(value) - })); - }) - ); - }); - }, - getItemRaw(key, opts = {}) { - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - if (driver.getItemRaw) { - return asyncCall(driver.getItemRaw, relativeKey, opts); - } - return asyncCall(driver.getItem, relativeKey, opts).then( - (value) => deserializeRaw(value) - ); - }, - async setItem(key, value, opts = {}) { - if (value === void 0) { - return storage.removeItem(key); - } - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - if (!driver.setItem) { - return; - } - await asyncCall(driver.setItem, relativeKey, stringify(value), opts); - if (!driver.watch) { - onChange("update", key); - } - }, - async setItems(items, commonOptions) { - await runBatch(items, commonOptions, async (batch) => { - if (batch.driver.setItems) { - await asyncCall( - batch.driver.setItems, - batch.items.map((item) => ({ - key: item.relativeKey, - value: stringify(item.value), - options: item.options - })), - commonOptions - ); - } - if (!batch.driver.setItem) { - return; - } - await Promise.all( - batch.items.map((item) => { - return asyncCall( - batch.driver.setItem, - item.relativeKey, - stringify(item.value), - item.options - ); - }) - ); - }); - }, - async setItemRaw(key, value, opts = {}) { - if (value === void 0) { - return storage.removeItem(key, opts); - } - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - if (driver.setItemRaw) { - await asyncCall(driver.setItemRaw, relativeKey, value, opts); - } else if (driver.setItem) { - await asyncCall(driver.setItem, relativeKey, serializeRaw(value), opts); - } else { - return; - } - if (!driver.watch) { - onChange("update", key); - } - }, - async removeItem(key, opts = {}) { - if (typeof opts === "boolean") { - opts = { removeMeta: opts }; - } - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - if (!driver.removeItem) { - return; - } - await asyncCall(driver.removeItem, relativeKey, opts); - if (opts.removeMeta || opts.removeMata) { - await asyncCall(driver.removeItem, relativeKey + "$", opts); - } - if (!driver.watch) { - onChange("remove", key); - } - }, - // Meta - async getMeta(key, opts = {}) { - if (typeof opts === "boolean") { - opts = { nativeOnly: opts }; - } - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - const meta = /* @__PURE__ */ Object.create(null); - if (driver.getMeta) { - Object.assign(meta, await asyncCall(driver.getMeta, relativeKey, opts)); - } - if (!opts.nativeOnly) { - const value = await asyncCall( - driver.getItem, - relativeKey + "$", - opts - ).then((value_) => destr(value_)); - if (value && typeof value === "object") { - if (typeof value.atime === "string") { - value.atime = new Date(value.atime); - } - if (typeof value.mtime === "string") { - value.mtime = new Date(value.mtime); - } - Object.assign(meta, value); - } - } - return meta; - }, - setMeta(key, value, opts = {}) { - return this.setItem(key + "$", value, opts); - }, - removeMeta(key, opts = {}) { - return this.removeItem(key + "$", opts); - }, - // Keys - async getKeys(base3, opts = {}) { - base3 = normalizeBaseKey(base3); - const mounts = getMounts(base3, true); - let maskedMounts = []; - const allKeys = []; - for (const mount of mounts) { - const rawKeys = await asyncCall( - mount.driver.getKeys, - mount.relativeBase, - opts - ); - const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p3) => key.startsWith(p3))); - allKeys.push(...keys2); - maskedMounts = [ - mount.mountpoint, - ...maskedMounts.filter((p3) => !p3.startsWith(mount.mountpoint)) - ]; - } - return base3 ? allKeys.filter((key) => key.startsWith(base3) && !key.endsWith("$")) : allKeys.filter((key) => !key.endsWith("$")); - }, - // Utils - async clear(base3, opts = {}) { - base3 = normalizeBaseKey(base3); - await Promise.all( - getMounts(base3, false).map(async (m2) => { - if (m2.driver.clear) { - return asyncCall(m2.driver.clear, m2.relativeBase, opts); - } - if (m2.driver.removeItem) { - const keys2 = await m2.driver.getKeys(m2.relativeBase || "", opts); - return Promise.all( - keys2.map((key) => m2.driver.removeItem(key, opts)) - ); - } - }) - ); - }, - async dispose() { - await Promise.all( - Object.values(context.mounts).map((driver) => dispose(driver)) - ); - }, - async watch(callback) { - await startWatch(); - context.watchListeners.push(callback); - return async () => { - context.watchListeners = context.watchListeners.filter( - (listener) => listener !== callback - ); - if (context.watchListeners.length === 0) { - await stopWatch(); - } - }; - }, - async unwatch() { - context.watchListeners = []; - await stopWatch(); - }, - // Mount - mount(base3, driver) { - base3 = normalizeBaseKey(base3); - if (base3 && context.mounts[base3]) { - throw new Error(`already mounted at ${base3}`); - } - if (base3) { - context.mountpoints.push(base3); - context.mountpoints.sort((a3, b3) => b3.length - a3.length); - } - context.mounts[base3] = driver; - if (context.watching) { - Promise.resolve(watch$2(driver, onChange, base3)).then((unwatcher) => { - context.unwatch[base3] = unwatcher; - }).catch(console.error); - } - return storage; - }, - async unmount(base3, _dispose = true) { - base3 = normalizeBaseKey(base3); - if (!base3 || !context.mounts[base3]) { - return; - } - if (context.watching && base3 in context.unwatch) { - context.unwatch[base3](); - delete context.unwatch[base3]; - } - if (_dispose) { - await dispose(context.mounts[base3]); - } - context.mountpoints = context.mountpoints.filter((key) => key !== base3); - delete context.mounts[base3]; - }, - getMount(key = "") { - key = normalizeKey(key) + ":"; - const m2 = getMount(key); - return { - driver: m2.driver, - base: m2.base - }; - }, - getMounts(base3 = "", opts = {}) { - base3 = normalizeKey(base3); - const mounts = getMounts(base3, opts.parents); - return mounts.map((m2) => ({ - driver: m2.driver, - base: m2.mountpoint - })); - } - }; - return storage; -} -function watch$2(driver, onChange, base3) { - return driver.watch ? driver.watch((event, key) => onChange(event, base3 + key)) : () => { - }; -} -async function dispose(driver) { - if (typeof driver.dispose === "function") { - await asyncCall(driver.dispose); - } -} -function promisifyRequest(request) { - return new Promise((resolve, reject) => { - request.oncomplete = request.onsuccess = () => resolve(request.result); - request.onabort = request.onerror = () => reject(request.error); - }); -} -function createStore(dbName, storeName) { - const request = indexedDB.open(dbName); - request.onupgradeneeded = () => request.result.createObjectStore(storeName); - const dbp = promisifyRequest(request); - return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName))); -} -let defaultGetStoreFunc; -function defaultGetStore() { - if (!defaultGetStoreFunc) { - defaultGetStoreFunc = createStore("keyval-store", "keyval"); - } - return defaultGetStoreFunc; -} -function get(key, customStore = defaultGetStore()) { - return customStore("readonly", (store) => promisifyRequest(store.get(key))); -} -function set(key, value, customStore = defaultGetStore()) { - return customStore("readwrite", (store) => { - store.put(value, key); - return promisifyRequest(store.transaction); - }); -} -function del(key, customStore = defaultGetStore()) { - return customStore("readwrite", (store) => { - store.delete(key); - return promisifyRequest(store.transaction); - }); -} -function clear(customStore = defaultGetStore()) { - return customStore("readwrite", (store) => { - store.clear(); - return promisifyRequest(store.transaction); - }); -} -function eachCursor(store, callback) { - store.openCursor().onsuccess = function() { - if (!this.result) - return; - callback(this.result); - this.result.continue(); - }; - return promisifyRequest(store.transaction); -} -function keys(customStore = defaultGetStore()) { - return customStore("readonly", (store) => { - if (store.getAllKeys) { - return promisifyRequest(store.getAllKeys()); - } - const items = []; - return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items); - }); -} -const JSONStringify = (data) => JSON.stringify(data, (_3, value) => typeof value === "bigint" ? value.toString() + "n" : value); -const JSONParse = (json) => { - const numbersBiggerThanMaxInt = /([\[:])?(\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; - const serializedData = json.replace(numbersBiggerThanMaxInt, '$1"$2n"$3'); - return JSON.parse(serializedData, (_3, value) => { - const isCustomFormatBigInt = typeof value === "string" && value.match(/^\d+n$/); - if (isCustomFormatBigInt) - return BigInt(value.substring(0, value.length - 1)); - return value; - }); -}; -function safeJsonParse(value) { - if (typeof value !== "string") { - throw new Error(`Cannot safe json parse value of type ${typeof value}`); - } - try { - return JSONParse(value); - } catch (_a) { - return value; - } -} -function safeJsonStringify(value) { - return typeof value === "string" ? value : JSONStringify(value) || ""; -} -const x$1 = "idb-keyval"; -var z$2 = (i2 = {}) => { - const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e = (s2) => t2 + s2; - let n3; - return i2.dbName && i2.storeName && (n3 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { - return !(typeof await get(e(s2), n3) > "u"); - }, async getItem(s2) { - return await get(e(s2), n3) ?? null; - }, setItem(s2, a3) { - return set(e(s2), a3, n3); - }, removeItem(s2) { - return del(e(s2), n3); - }, getKeys() { - return keys(n3); - }, clear() { - return clear(n3); - } }; -}; -const D$3 = "WALLET_CONNECT_V2_INDEXED_DB", E$1 = "keyvaluestorage"; -let _$2 = class _ { - constructor() { - this.indexedDb = createStorage({ driver: z$2({ dbName: D$3, storeName: E$1 }) }); - } - async getKeys() { - return this.indexedDb.getKeys(); - } - async getEntries() { - return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((t2) => [t2.key, t2.value]); - } - async getItem(t2) { - const e = await this.indexedDb.getItem(t2); - if (e !== null) - return e; - } - async setItem(t2, e) { - await this.indexedDb.setItem(t2, safeJsonStringify(e)); - } - async removeItem(t2) { - await this.indexedDb.removeItem(t2); - } -}; -var l$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c = { exports: {} }; -(function() { - let i2; - function t2() { - } - i2 = t2, i2.prototype.getItem = function(e) { - return this.hasOwnProperty(e) ? String(this[e]) : null; - }, i2.prototype.setItem = function(e, n3) { - this[e] = String(n3); - }, i2.prototype.removeItem = function(e) { - delete this[e]; - }, i2.prototype.clear = function() { - const e = this; - Object.keys(e).forEach(function(n3) { - e[n3] = void 0, delete e[n3]; - }); - }, i2.prototype.key = function(e) { - return e = e || 0, Object.keys(this)[e]; - }, i2.prototype.__defineGetter__("length", function() { - return Object.keys(this).length; - }), typeof l$1 < "u" && l$1.localStorage ? c.exports = l$1.localStorage : typeof window < "u" && window.localStorage ? c.exports = window.localStorage : c.exports = new t2(); -})(); -function k$1(i2) { - var t2; - return [i2[0], safeJsonParse((t2 = i2[1]) != null ? t2 : "")]; -} -class K { - constructor() { - this.localStorage = c.exports; - } - async getKeys() { - return Object.keys(this.localStorage); - } - async getEntries() { - return Object.entries(this.localStorage).map(k$1); - } - async getItem(t2) { - const e = this.localStorage.getItem(t2); - if (e !== null) - return safeJsonParse(e); - } - async setItem(t2, e) { - this.localStorage.setItem(t2, safeJsonStringify(e)); - } - async removeItem(t2) { - this.localStorage.removeItem(t2); - } -} -const N$2 = "wc_storage_version", y$2 = 1, O$2 = async (i2, t2, e) => { - const n3 = N$2, s2 = await t2.getItem(n3); - if (s2 && s2 >= y$2) { - e(t2); - return; - } - const a3 = await i2.getKeys(); - if (!a3.length) { - e(t2); - return; - } - const m2 = []; - for (; a3.length; ) { - const r2 = a3.shift(); - if (!r2) - continue; - const o2 = r2.toLowerCase(); - if (o2.includes("wc@") || o2.includes("walletconnect") || o2.includes("wc_") || o2.includes("wallet_connect")) { - const f2 = await i2.getItem(r2); - await t2.setItem(r2, f2), m2.push(r2); - } - } - await t2.setItem(n3, y$2), e(t2), j$2(i2, m2); -}, j$2 = async (i2, t2) => { - t2.length && t2.forEach(async (e) => { - await i2.removeItem(e); - }); -}; -let h$3 = class h { - constructor() { - this.initialized = false, this.setInitialized = (e) => { - this.storage = e, this.initialized = true; - }; - const t2 = new K(); - this.storage = t2; - try { - const e = new _$2(); - O$2(t2, e, this.setInitialized); - } catch { - this.initialized = true; - } - } - async getKeys() { - return await this.initialize(), this.storage.getKeys(); - } - async getEntries() { - return await this.initialize(), this.storage.getEntries(); - } - async getItem(t2) { - return await this.initialize(), this.storage.getItem(t2); - } - async setItem(t2, e) { - return await this.initialize(), this.storage.setItem(t2, e); - } - async removeItem(t2) { - return await this.initialize(), this.storage.removeItem(t2); - } - async initialize() { - this.initialized || await new Promise((t2) => { - const e = setInterval(() => { - this.initialized && (clearInterval(e), t2()); - }, 20); - }); - } -}; -var cjs$5 = {}; -/*! ***************************************************************************** -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. -***************************************************************************** */ -var extendStatics = function(d3, b3) { - extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { - d4.__proto__ = b4; - } || function(d4, b4) { - for (var p3 in b4) - if (b4.hasOwnProperty(p3)) - d4[p3] = b4[p3]; - }; - return extendStatics(d3, b3); -}; -function __extends(d3, b3) { - extendStatics(d3, b3); - function __() { - this.constructor = d3; - } - d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); -} -var __assign = function() { - __assign = Object.assign || function __assign2(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { - s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; - } - return t2; - }; - return __assign.apply(this, arguments); -}; -function __rest(s2, e) { - var t2 = {}; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3) && e.indexOf(p3) < 0) - t2[p3] = s2[p3]; - if (s2 != null && typeof Object.getOwnPropertySymbols === "function") - for (var i2 = 0, p3 = Object.getOwnPropertySymbols(s2); i2 < p3.length; i2++) { - if (e.indexOf(p3[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p3[i2])) - t2[p3[i2]] = s2[p3[i2]]; - } - return t2; -} -function __decorate(decorators, target, key, desc) { - var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r2 = Reflect.decorate(decorators, target, key, desc); - else - for (var i2 = decorators.length - 1; i2 >= 0; i2--) - if (d3 = decorators[i2]) - r2 = (c2 < 3 ? d3(r2) : c2 > 3 ? d3(target, key, r2) : d3(target, key)) || r2; - return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2; -} -function __param(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; -} -function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") - return Reflect.metadata(metadataKey, metadataValue); -} -function __awaiter(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve) { - resolve(value); - }); - } - return new (P2 || (P2 = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} -function __generator(thisArg, body) { - var _3 = { label: 0, sent: function() { - if (t2[0] & 1) - throw t2[1]; - return t2[1]; - }, trys: [], ops: [] }, f2, y3, t2, g3; - return g3 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() { - return this; - }), g3; - function verb(n3) { - return function(v3) { - return step([n3, v3]); - }; - } - function step(op) { - if (f2) - throw new TypeError("Generator is already executing."); - while (_3) - try { - if (f2 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) - return t2; - if (y3 = 0, t2) - op = [op[0] & 2, t2.value]; - switch (op[0]) { - case 0: - case 1: - t2 = op; - break; - case 4: - _3.label++; - return { value: op[1], done: false }; - case 5: - _3.label++; - y3 = op[1]; - op = [0]; - continue; - case 7: - op = _3.ops.pop(); - _3.trys.pop(); - continue; - default: - if (!(t2 = _3.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _3 = 0; - continue; - } - if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) { - _3.label = op[1]; - break; - } - if (op[0] === 6 && _3.label < t2[1]) { - _3.label = t2[1]; - t2 = op; - break; - } - if (t2 && _3.label < t2[2]) { - _3.label = t2[2]; - _3.ops.push(op); - break; - } - if (t2[2]) - _3.ops.pop(); - _3.trys.pop(); - continue; - } - op = body.call(thisArg, _3); - } catch (e) { - op = [6, e]; - y3 = 0; - } finally { - f2 = t2 = 0; - } - if (op[0] & 5) - throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } -} -function __createBinding(o2, m2, k2, k22) { - if (k22 === void 0) - k22 = k2; - o2[k22] = m2[k2]; -} -function __exportStar(m2, exports2) { - for (var p3 in m2) - if (p3 !== "default" && !exports2.hasOwnProperty(p3)) - exports2[p3] = m2[p3]; -} -function __values(o2) { - var s2 = typeof Symbol === "function" && Symbol.iterator, m2 = s2 && o2[s2], i2 = 0; - if (m2) - return m2.call(o2); - if (o2 && typeof o2.length === "number") - return { - next: function() { - if (o2 && i2 >= o2.length) - o2 = void 0; - return { value: o2 && o2[i2++], done: !o2 }; - } - }; - throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined."); -} -function __read(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) - return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; - try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); - } catch (error) { - e = { error }; - } finally { - try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); - } finally { - if (e) - throw e.error; - } - } - return ar2; -} -function __spread() { - for (var ar2 = [], i2 = 0; i2 < arguments.length; i2++) - ar2 = ar2.concat(__read(arguments[i2])); - return ar2; -} -function __spreadArrays() { - for (var s2 = 0, i2 = 0, il = arguments.length; i2 < il; i2++) - s2 += arguments[i2].length; - for (var r2 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) - for (var a3 = arguments[i2], j2 = 0, jl = a3.length; j2 < jl; j2++, k2++) - r2[k2] = a3[j2]; - return r2; -} -function __await(v3) { - return this instanceof __await ? (this.v = v3, this) : new __await(v3); -} -function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var g3 = generator.apply(thisArg, _arguments || []), i2, q2 = []; - return i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { - return this; - }, i2; - function verb(n3) { - if (g3[n3]) - i2[n3] = function(v3) { - return new Promise(function(a3, b3) { - q2.push([n3, v3, a3, b3]) > 1 || resume(n3, v3); - }); - }; - } - function resume(n3, v3) { - try { - step(g3[n3](v3)); - } catch (e) { - settle(q2[0][3], e); - } - } - function step(r2) { - r2.value instanceof __await ? Promise.resolve(r2.value.v).then(fulfill, reject) : settle(q2[0][2], r2); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f2, v3) { - if (f2(v3), q2.shift(), q2.length) - resume(q2[0][0], q2[0][1]); - } -} -function __asyncDelegator(o2) { - var i2, p3; - return i2 = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i2[Symbol.iterator] = function() { - return this; - }, i2; - function verb(n3, f2) { - i2[n3] = o2[n3] ? function(v3) { - return (p3 = !p3) ? { value: __await(o2[n3](v3)), done: n3 === "return" } : f2 ? f2(v3) : v3; - } : f2; - } -} -function __asyncValues(o2) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var m2 = o2[Symbol.asyncIterator], i2; - return m2 ? m2.call(o2) : (o2 = typeof __values === "function" ? __values(o2) : o2[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { - return this; - }, i2); - function verb(n3) { - i2[n3] = o2[n3] && function(v3) { - return new Promise(function(resolve, reject) { - v3 = o2[n3](v3), settle(resolve, reject, v3.done, v3.value); - }); - }; - } - function settle(resolve, reject, d3, v3) { - Promise.resolve(v3).then(function(v4) { - resolve({ value: v4, done: d3 }); - }, reject); - } -} -function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { - Object.defineProperty(cooked, "raw", { value: raw }); - } else { - cooked.raw = raw; - } - return cooked; -} -function __importStar(mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) { - for (var k2 in mod) - if (Object.hasOwnProperty.call(mod, k2)) - result[k2] = mod[k2]; - } - result.default = mod; - return result; -} -function __importDefault(mod) { - return mod && mod.__esModule ? mod : { default: mod }; -} -function __classPrivateFieldGet(receiver, privateMap) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to get private field on non-instance"); - } - return privateMap.get(receiver); -} -function __classPrivateFieldSet(receiver, privateMap, value) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to set private field on non-instance"); - } - privateMap.set(receiver, value); - return value; -} -const tslib_es6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - get __assign() { - return __assign; - }, - __asyncDelegator, - __asyncGenerator, - __asyncValues, - __await, - __awaiter, - __classPrivateFieldGet, - __classPrivateFieldSet, - __createBinding, - __decorate, - __exportStar, - __extends, - __generator, - __importDefault, - __importStar, - __makeTemplateObject, - __metadata, - __param, - __read, - __rest, - __spread, - __spreadArrays, - __values -}, Symbol.toStringTag, { value: "Module" })); -const require$$0$2 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6); -var heartbeat$2 = {}; -var cjs$4 = {}; -var utils$1 = {}; -var delay = {}; -var hasRequiredDelay; -function requireDelay() { - if (hasRequiredDelay) - return delay; - hasRequiredDelay = 1; - Object.defineProperty(delay, "__esModule", { value: true }); - delay.delay = void 0; - function delay$1(timeout) { - return new Promise((resolve) => { - setTimeout(() => { - resolve(true); - }, timeout); - }); - } - delay.delay = delay$1; - return delay; -} -var convert = {}; -var constants$2 = {}; -var misc = {}; -var hasRequiredMisc; -function requireMisc() { - if (hasRequiredMisc) - return misc; - hasRequiredMisc = 1; - Object.defineProperty(misc, "__esModule", { value: true }); - misc.ONE_THOUSAND = misc.ONE_HUNDRED = void 0; - misc.ONE_HUNDRED = 100; - misc.ONE_THOUSAND = 1e3; - return misc; -} -var time = {}; -var hasRequiredTime; -function requireTime() { - if (hasRequiredTime) - return time; - hasRequiredTime = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.ONE_YEAR = exports2.FOUR_WEEKS = exports2.THREE_WEEKS = exports2.TWO_WEEKS = exports2.ONE_WEEK = exports2.THIRTY_DAYS = exports2.SEVEN_DAYS = exports2.FIVE_DAYS = exports2.THREE_DAYS = exports2.ONE_DAY = exports2.TWENTY_FOUR_HOURS = exports2.TWELVE_HOURS = exports2.SIX_HOURS = exports2.THREE_HOURS = exports2.ONE_HOUR = exports2.SIXTY_MINUTES = exports2.THIRTY_MINUTES = exports2.TEN_MINUTES = exports2.FIVE_MINUTES = exports2.ONE_MINUTE = exports2.SIXTY_SECONDS = exports2.THIRTY_SECONDS = exports2.TEN_SECONDS = exports2.FIVE_SECONDS = exports2.ONE_SECOND = void 0; - exports2.ONE_SECOND = 1; - exports2.FIVE_SECONDS = 5; - exports2.TEN_SECONDS = 10; - exports2.THIRTY_SECONDS = 30; - exports2.SIXTY_SECONDS = 60; - exports2.ONE_MINUTE = exports2.SIXTY_SECONDS; - exports2.FIVE_MINUTES = exports2.ONE_MINUTE * 5; - exports2.TEN_MINUTES = exports2.ONE_MINUTE * 10; - exports2.THIRTY_MINUTES = exports2.ONE_MINUTE * 30; - exports2.SIXTY_MINUTES = exports2.ONE_MINUTE * 60; - exports2.ONE_HOUR = exports2.SIXTY_MINUTES; - exports2.THREE_HOURS = exports2.ONE_HOUR * 3; - exports2.SIX_HOURS = exports2.ONE_HOUR * 6; - exports2.TWELVE_HOURS = exports2.ONE_HOUR * 12; - exports2.TWENTY_FOUR_HOURS = exports2.ONE_HOUR * 24; - exports2.ONE_DAY = exports2.TWENTY_FOUR_HOURS; - exports2.THREE_DAYS = exports2.ONE_DAY * 3; - exports2.FIVE_DAYS = exports2.ONE_DAY * 5; - exports2.SEVEN_DAYS = exports2.ONE_DAY * 7; - exports2.THIRTY_DAYS = exports2.ONE_DAY * 30; - exports2.ONE_WEEK = exports2.SEVEN_DAYS; - exports2.TWO_WEEKS = exports2.ONE_WEEK * 2; - exports2.THREE_WEEKS = exports2.ONE_WEEK * 3; - exports2.FOUR_WEEKS = exports2.ONE_WEEK * 4; - exports2.ONE_YEAR = exports2.ONE_DAY * 365; - })(time); - return time; -} -var hasRequiredConstants$2; -function requireConstants$2() { - if (hasRequiredConstants$2) - return constants$2; - hasRequiredConstants$2 = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireMisc(), exports2); - tslib_1.__exportStar(requireTime(), exports2); - })(constants$2); - return constants$2; -} -var hasRequiredConvert; -function requireConvert() { - if (hasRequiredConvert) - return convert; - hasRequiredConvert = 1; - Object.defineProperty(convert, "__esModule", { value: true }); - convert.fromMiliseconds = convert.toMiliseconds = void 0; - const constants_1 = requireConstants$2(); - function toMiliseconds(seconds) { - return seconds * constants_1.ONE_THOUSAND; - } - convert.toMiliseconds = toMiliseconds; - function fromMiliseconds(miliseconds) { - return Math.floor(miliseconds / constants_1.ONE_THOUSAND); - } - convert.fromMiliseconds = fromMiliseconds; - return convert; -} -var hasRequiredUtils$1; -function requireUtils$1() { - if (hasRequiredUtils$1) - return utils$1; - hasRequiredUtils$1 = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireDelay(), exports2); - tslib_1.__exportStar(requireConvert(), exports2); - })(utils$1); - return utils$1; -} -var watch$1 = {}; -var hasRequiredWatch$1; -function requireWatch$1() { - if (hasRequiredWatch$1) - return watch$1; - hasRequiredWatch$1 = 1; - Object.defineProperty(watch$1, "__esModule", { value: true }); - watch$1.Watch = void 0; - class Watch { - constructor() { - this.timestamps = /* @__PURE__ */ new Map(); - } - start(label) { - if (this.timestamps.has(label)) { - throw new Error(`Watch already started for label: ${label}`); - } - this.timestamps.set(label, { started: Date.now() }); - } - stop(label) { - const timestamp = this.get(label); - if (typeof timestamp.elapsed !== "undefined") { - throw new Error(`Watch already stopped for label: ${label}`); - } - const elapsed = Date.now() - timestamp.started; - this.timestamps.set(label, { started: timestamp.started, elapsed }); - } - get(label) { - const timestamp = this.timestamps.get(label); - if (typeof timestamp === "undefined") { - throw new Error(`No timestamp found for label: ${label}`); - } - return timestamp; - } - elapsed(label) { - const timestamp = this.get(label); - const elapsed = timestamp.elapsed || Date.now() - timestamp.started; - return elapsed; - } - } - watch$1.Watch = Watch; - watch$1.default = Watch; - return watch$1; -} -var types$2 = {}; -var watch = {}; -var hasRequiredWatch; -function requireWatch() { - if (hasRequiredWatch) - return watch; - hasRequiredWatch = 1; - Object.defineProperty(watch, "__esModule", { value: true }); - watch.IWatch = void 0; - class IWatch { - } - watch.IWatch = IWatch; - return watch; -} -var hasRequiredTypes$1; -function requireTypes$1() { - if (hasRequiredTypes$1) - return types$2; - hasRequiredTypes$1 = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireWatch(), exports2); - })(types$2); - return types$2; -} -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireUtils$1(), exports2); - tslib_1.__exportStar(requireWatch$1(), exports2); - tslib_1.__exportStar(requireTypes$1(), exports2); - tslib_1.__exportStar(requireConstants$2(), exports2); -})(cjs$4); -var types$1 = {}; -var heartbeat$1 = {}; -let IEvents$1 = class IEvents { -}; -const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - IEvents: IEvents$1 -}, Symbol.toStringTag, { value: "Module" })); -const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(esm); -var hasRequiredHeartbeat$2; -function requireHeartbeat$2() { - if (hasRequiredHeartbeat$2) - return heartbeat$1; - hasRequiredHeartbeat$2 = 1; - Object.defineProperty(heartbeat$1, "__esModule", { value: true }); - heartbeat$1.IHeartBeat = void 0; - const events_1 = require$$0$1; - class IHeartBeat extends events_1.IEvents { - constructor(opts) { - super(); - } - } - heartbeat$1.IHeartBeat = IHeartBeat; - return heartbeat$1; -} -var hasRequiredTypes; -function requireTypes() { - if (hasRequiredTypes) - return types$1; - hasRequiredTypes = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireHeartbeat$2(), exports2); - })(types$1); - return types$1; -} -var constants$1 = {}; -var heartbeat = {}; -var hasRequiredHeartbeat$1; -function requireHeartbeat$1() { - if (hasRequiredHeartbeat$1) - return heartbeat; - hasRequiredHeartbeat$1 = 1; - Object.defineProperty(heartbeat, "__esModule", { value: true }); - heartbeat.HEARTBEAT_EVENTS = heartbeat.HEARTBEAT_INTERVAL = void 0; - const time_1 = cjs$4; - heartbeat.HEARTBEAT_INTERVAL = time_1.FIVE_SECONDS; - heartbeat.HEARTBEAT_EVENTS = { - pulse: "heartbeat_pulse" - }; - return heartbeat; -} -var hasRequiredConstants$1; -function requireConstants$1() { - if (hasRequiredConstants$1) - return constants$1; - hasRequiredConstants$1 = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireHeartbeat$1(), exports2); - })(constants$1); - return constants$1; -} -var hasRequiredHeartbeat; -function requireHeartbeat() { - if (hasRequiredHeartbeat) - return heartbeat$2; - hasRequiredHeartbeat = 1; - Object.defineProperty(heartbeat$2, "__esModule", { value: true }); - heartbeat$2.HeartBeat = void 0; - const tslib_1 = require$$0$2; - const events_1 = eventsExports; - const time_1 = cjs$4; - const types_1 = requireTypes(); - const constants_1 = requireConstants$1(); - class HeartBeat extends types_1.IHeartBeat { - constructor(opts) { - super(opts); - this.events = new events_1.EventEmitter(); - this.interval = constants_1.HEARTBEAT_INTERVAL; - this.interval = (opts === null || opts === void 0 ? void 0 : opts.interval) || constants_1.HEARTBEAT_INTERVAL; - } - static init(opts) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const heartbeat2 = new HeartBeat(opts); - yield heartbeat2.init(); - return heartbeat2; - }); - } - init() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield this.initialize(); - }); - } - stop() { - clearInterval(this.intervalRef); - } - on(event, listener) { - this.events.on(event, listener); - } - once(event, listener) { - this.events.once(event, listener); - } - off(event, listener) { - this.events.off(event, listener); - } - removeListener(event, listener) { - this.events.removeListener(event, listener); - } - initialize() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - this.intervalRef = setInterval(() => this.pulse(), time_1.toMiliseconds(this.interval)); - }); - } - pulse() { - this.events.emit(constants_1.HEARTBEAT_EVENTS.pulse); - } - } - heartbeat$2.HeartBeat = HeartBeat; - return heartbeat$2; -} -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireHeartbeat(), exports2); - tslib_1.__exportStar(requireTypes(), exports2); - tslib_1.__exportStar(requireConstants$1(), exports2); -})(cjs$5); -var cjs$3 = {}; -var quickFormatUnescaped; -var hasRequiredQuickFormatUnescaped; -function requireQuickFormatUnescaped() { - if (hasRequiredQuickFormatUnescaped) - return quickFormatUnescaped; - hasRequiredQuickFormatUnescaped = 1; - function tryStringify(o2) { - try { - return JSON.stringify(o2); - } catch (e) { - return '"[Circular]"'; - } - } - quickFormatUnescaped = format; - function format(f2, args, opts) { - var ss2 = opts && opts.stringify || tryStringify; - var offset = 1; - if (typeof f2 === "object" && f2 !== null) { - var len = args.length + offset; - if (len === 1) - return f2; - var objects = new Array(len); - objects[0] = ss2(f2); - for (var index = 1; index < len; index++) { - objects[index] = ss2(args[index]); - } - return objects.join(" "); - } - if (typeof f2 !== "string") { - return f2; - } - var argLen = args.length; - if (argLen === 0) - return f2; - var str = ""; - var a3 = 1 - offset; - var lastPos = -1; - var flen = f2 && f2.length || 0; - for (var i2 = 0; i2 < flen; ) { - if (f2.charCodeAt(i2) === 37 && i2 + 1 < flen) { - lastPos = lastPos > -1 ? lastPos : 0; - switch (f2.charCodeAt(i2 + 1)) { - case 100: - case 102: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Number(args[a3]); - lastPos = i2 + 2; - i2++; - break; - case 105: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Math.floor(Number(args[a3])); - lastPos = i2 + 2; - i2++; - break; - case 79: - case 111: - case 106: - if (a3 >= argLen) - break; - if (args[a3] === void 0) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - var type2 = typeof args[a3]; - if (type2 === "string") { - str += "'" + args[a3] + "'"; - lastPos = i2 + 2; - i2++; - break; - } - if (type2 === "function") { - str += args[a3].name || ""; - lastPos = i2 + 2; - i2++; - break; - } - str += ss2(args[a3]); - lastPos = i2 + 2; - i2++; - break; - case 115: - if (a3 >= argLen) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += String(args[a3]); - lastPos = i2 + 2; - i2++; - break; - case 37: - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += "%"; - lastPos = i2 + 2; - i2++; - a3--; - break; - } - ++a3; - } - ++i2; - } - if (lastPos === -1) - return f2; - else if (lastPos < flen) { - str += f2.slice(lastPos); - } - return str; - } - return quickFormatUnescaped; -} -var browser$4; -var hasRequiredBrowser; -function requireBrowser() { - if (hasRequiredBrowser) - return browser$4; - hasRequiredBrowser = 1; - const format = requireQuickFormatUnescaped(); - browser$4 = pino; - const _console = pfGlobalThisOrFallback().console || {}; - const stdSerializers = { - mapHttpRequest: mock, - mapHttpResponse: mock, - wrapRequestSerializer: passthrough, - wrapResponseSerializer: passthrough, - wrapErrorSerializer: passthrough, - req: mock, - res: mock, - err: asErrValue - }; - function shouldSerialize(serialize, serializers) { - if (Array.isArray(serialize)) { - const hasToFilter = serialize.filter(function(k2) { - return k2 !== "!stdSerializers.err"; - }); - return hasToFilter; - } else if (serialize === true) { - return Object.keys(serializers); - } - return false; - } - function pino(opts) { - opts = opts || {}; - opts.browser = opts.browser || {}; - const transmit2 = opts.browser.transmit; - if (transmit2 && typeof transmit2.send !== "function") { - throw Error("pino: transmit option must have a send function"); - } - const proto = opts.browser.write || _console; - if (opts.browser.write) - opts.browser.asObject = true; - const serializers = opts.serializers || {}; - const serialize = shouldSerialize(opts.browser.serialize, serializers); - let stdErrSerialize = opts.browser.serialize; - if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) - stdErrSerialize = false; - const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; - if (typeof proto === "function") { - proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; - } - if (opts.enabled === false) - opts.level = "silent"; - const level = opts.level || "info"; - const logger = Object.create(proto); - if (!logger.log) - logger.log = noop; - Object.defineProperty(logger, "levelVal", { - get: getLevelVal - }); - Object.defineProperty(logger, "level", { - get: getLevel, - set: setLevel - }); - const setOpts = { - transmit: transmit2, - serialize, - asObject: opts.browser.asObject, - levels, - timestamp: getTimeFunction(opts) - }; - logger.levels = pino.levels; - logger.level = level; - logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop; - logger.serializers = serializers; - logger._serialize = serialize; - logger._stdErrSerialize = stdErrSerialize; - logger.child = child; - if (transmit2) - logger._logEvent = createLogEventShape(); - function getLevelVal() { - return this.level === "silent" ? Infinity : this.levels.values[this.level]; - } - function getLevel() { - return this._level; - } - function setLevel(level2) { - if (level2 !== "silent" && !this.levels.values[level2]) { - throw Error("unknown level " + level2); - } - this._level = level2; - set2(setOpts, logger, "error", "log"); - set2(setOpts, logger, "fatal", "error"); - set2(setOpts, logger, "warn", "error"); - set2(setOpts, logger, "info", "log"); - set2(setOpts, logger, "debug", "log"); - set2(setOpts, logger, "trace", "log"); - } - function child(bindings, childOptions) { - if (!bindings) { - throw new Error("missing bindings for child Pino"); - } - childOptions = childOptions || {}; - if (serialize && bindings.serializers) { - childOptions.serializers = bindings.serializers; - } - const childOptionsSerializers = childOptions.serializers; - if (serialize && childOptionsSerializers) { - var childSerializers = Object.assign({}, serializers, childOptionsSerializers); - var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; - delete bindings.serializers; - applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); - } - function Child(parent) { - this._childLevel = (parent._childLevel | 0) + 1; - this.error = bind(parent, bindings, "error"); - this.fatal = bind(parent, bindings, "fatal"); - this.warn = bind(parent, bindings, "warn"); - this.info = bind(parent, bindings, "info"); - this.debug = bind(parent, bindings, "debug"); - this.trace = bind(parent, bindings, "trace"); - if (childSerializers) { - this.serializers = childSerializers; - this._serialize = childSerialize; - } - if (transmit2) { - this._logEvent = createLogEventShape( - [].concat(parent._logEvent.bindings, bindings) - ); - } - } - Child.prototype = this; - return new Child(this); - } - return logger; - } - pino.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" - } - }; - pino.stdSerializers = stdSerializers; - pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); - function set2(opts, logger, level, fallback) { - const proto = Object.getPrototypeOf(logger); - logger[level] = logger.levelVal > logger.levels.values[level] ? noop : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop; - wrap(opts, logger, level); - } - function wrap(opts, logger, level) { - if (!opts.transmit && logger[level] === noop) - return; - logger[level] = /* @__PURE__ */ function(write) { - return function LOG() { - const ts2 = opts.timestamp(); - const args = new Array(arguments.length); - const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; - for (var i2 = 0; i2 < args.length; i2++) - args[i2] = arguments[i2]; - if (opts.serialize && !opts.asObject) { - applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); - } - if (opts.asObject) - write.call(proto, asObject(this, level, args, ts2)); - else - write.apply(proto, args); - if (opts.transmit) { - const transmitLevel = opts.transmit.level || logger.level; - const transmitValue = pino.levels.values[transmitLevel]; - const methodValue = pino.levels.values[level]; - if (methodValue < transmitValue) - return; - transmit(this, { - ts: ts2, - methodLevel: level, - methodValue, - transmitLevel, - transmitValue: pino.levels.values[opts.transmit.level || logger.level], - send: opts.transmit.send, - val: logger.levelVal - }, args); - } - }; - }(logger[level]); - } - function asObject(logger, level, args, ts2) { - if (logger._serialize) - applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); - const argsCloned = args.slice(); - let msg = argsCloned[0]; - const o2 = {}; - if (ts2) { - o2.time = ts2; - } - o2.level = pino.levels.values[level]; - let lvl = (logger._childLevel | 0) + 1; - if (lvl < 1) - lvl = 1; - if (msg !== null && typeof msg === "object") { - while (lvl-- && typeof argsCloned[0] === "object") { - Object.assign(o2, argsCloned.shift()); - } - msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; - } else if (typeof msg === "string") - msg = format(argsCloned.shift(), argsCloned); - if (msg !== void 0) - o2.msg = msg; - return o2; - } - function applySerializers(args, serialize, serializers, stdErrSerialize) { - for (const i2 in args) { - if (stdErrSerialize && args[i2] instanceof Error) { - args[i2] = pino.stdSerializers.err(args[i2]); - } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { - for (const k2 in args[i2]) { - if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { - args[i2][k2] = serializers[k2](args[i2][k2]); - } - } - } - } - } - function bind(parent, bindings, level) { - return function() { - const args = new Array(1 + arguments.length); - args[0] = bindings; - for (var i2 = 1; i2 < args.length; i2++) { - args[i2] = arguments[i2 - 1]; - } - return parent[level].apply(this, args); - }; - } - function transmit(logger, opts, args) { - const send = opts.send; - const ts2 = opts.ts; - const methodLevel = opts.methodLevel; - const methodValue = opts.methodValue; - const val = opts.val; - const bindings = logger._logEvent.bindings; - applySerializers( - args, - logger._serialize || Object.keys(logger.serializers), - logger.serializers, - logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize - ); - logger._logEvent.ts = ts2; - logger._logEvent.messages = args.filter(function(arg) { - return bindings.indexOf(arg) === -1; - }); - logger._logEvent.level.label = methodLevel; - logger._logEvent.level.value = methodValue; - send(methodLevel, logger._logEvent, val); - logger._logEvent = createLogEventShape(bindings); - } - function createLogEventShape(bindings) { - return { - ts: 0, - messages: [], - bindings: bindings || [], - level: { label: "", value: 0 } - }; - } - function asErrValue(err) { - const obj = { - type: err.constructor.name, - msg: err.message, - stack: err.stack - }; - for (const key in err) { - if (obj[key] === void 0) { - obj[key] = err[key]; - } - } - return obj; - } - function getTimeFunction(opts) { - if (typeof opts.timestamp === "function") { - return opts.timestamp; - } - if (opts.timestamp === false) { - return nullTime; - } - return epochTime; - } - function mock() { - return {}; - } - function passthrough(a3) { - return a3; - } - function noop() { - } - function nullTime() { - return false; - } - function epochTime() { - return Date.now(); - } - function unixTime() { - return Math.round(Date.now() / 1e3); - } - function isoTime() { - return new Date(Date.now()).toISOString(); - } - function pfGlobalThisOrFallback() { - function defd(o2) { - return typeof o2 !== "undefined" && o2; - } - try { - if (typeof globalThis !== "undefined") - return globalThis; - Object.defineProperty(Object.prototype, "globalThis", { - get: function() { - delete Object.prototype.globalThis; - return this.globalThis = this; - }, - configurable: true - }); - return globalThis; - } catch (e) { - return defd(self) || defd(window) || defd(this) || {}; - } - } - return browser$4; -} -var constants = {}; -var hasRequiredConstants; -function requireConstants() { - if (hasRequiredConstants) - return constants; - hasRequiredConstants = 1; - Object.defineProperty(constants, "__esModule", { value: true }); - constants.PINO_CUSTOM_CONTEXT_KEY = constants.PINO_LOGGER_DEFAULTS = void 0; - constants.PINO_LOGGER_DEFAULTS = { - level: "info" - }; - constants.PINO_CUSTOM_CONTEXT_KEY = "custom_context"; - return constants; -} -var utils = {}; -var hasRequiredUtils; -function requireUtils() { - if (hasRequiredUtils) - return utils; - hasRequiredUtils = 1; - Object.defineProperty(utils, "__esModule", { value: true }); - utils.generateChildLogger = utils.formatChildLoggerContext = utils.getLoggerContext = utils.setBrowserLoggerContext = utils.getBrowserLoggerContext = utils.getDefaultLoggerOptions = void 0; - const constants_1 = requireConstants(); - function getDefaultLoggerOptions(opts) { - return Object.assign(Object.assign({}, opts), { level: (opts === null || opts === void 0 ? void 0 : opts.level) || constants_1.PINO_LOGGER_DEFAULTS.level }); - } - utils.getDefaultLoggerOptions = getDefaultLoggerOptions; - function getBrowserLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - return logger[customContextKey] || ""; - } - utils.getBrowserLoggerContext = getBrowserLoggerContext; - function setBrowserLoggerContext(logger, context, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - logger[customContextKey] = context; - return logger; - } - utils.setBrowserLoggerContext = setBrowserLoggerContext; - function getLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - let context = ""; - if (typeof logger.bindings === "undefined") { - context = getBrowserLoggerContext(logger, customContextKey); - } else { - context = logger.bindings().context || ""; - } - return context; - } - utils.getLoggerContext = getLoggerContext; - function formatChildLoggerContext(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const parentContext = getLoggerContext(logger, customContextKey); - const context = parentContext.trim() ? `${parentContext}/${childContext}` : childContext; - return context; - } - utils.formatChildLoggerContext = formatChildLoggerContext; - function generateChildLogger(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const context = formatChildLoggerContext(logger, childContext, customContextKey); - const child = logger.child({ context }); - return setBrowserLoggerContext(child, context, customContextKey); - } - utils.generateChildLogger = generateChildLogger; - return utils; -} -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.pino = void 0; - const tslib_1 = require$$0$2; - const pino_1 = tslib_1.__importDefault(requireBrowser()); - Object.defineProperty(exports2, "pino", { enumerable: true, get: function() { - return pino_1.default; - } }); - tslib_1.__exportStar(requireConstants(), exports2); - tslib_1.__exportStar(requireUtils(), exports2); -})(cjs$3); -let n$1 = class n extends IEvents$1 { - constructor(s2) { - super(), this.opts = s2, this.protocol = "wc", this.version = 2; - } -}; -let h$2 = class h2 extends IEvents$1 { - constructor(s2, t2) { - super(), this.core = s2, this.logger = t2, this.records = /* @__PURE__ */ new Map(); - } -}; -let a$2 = class a { - constructor(s2, t2) { - this.logger = s2, this.core = t2; - } -}; -let u$1 = class u extends IEvents$1 { - constructor(s2, t2) { - super(), this.relayer = s2, this.logger = t2; - } -}; -let g$4 = class g extends IEvents$1 { - constructor(s2) { - super(); - } -}; -let p$2 = class p { - constructor(s2, t2, o2, M2) { - this.core = s2, this.logger = t2, this.name = o2; - } -}; -class d2 extends IEvents$1 { - constructor(s2, t2) { - super(), this.relayer = s2, this.logger = t2; - } -} -class E extends IEvents$1 { - constructor(s2, t2) { - super(), this.core = s2, this.logger = t2; - } -} -let y$1 = class y { - constructor(s2, t2) { - this.projectId = s2, this.logger = t2; - } -}; -let v$1 = class v { - constructor(s2, t2) { - this.projectId = s2, this.logger = t2; - } -}; -let b$1 = class b { - constructor(s2) { - this.opts = s2, this.protocol = "wc", this.version = 2; - } -}; -let w$4 = class w { - constructor(s2) { - this.client = s2; - } -}; -var ed25519 = {}; -var random = {}; -var system = {}; -var browser$3 = {}; -Object.defineProperty(browser$3, "__esModule", { value: true }); -browser$3.BrowserRandomSource = void 0; -const QUOTA = 65536; -class BrowserRandomSource { - constructor() { - this.isAvailable = false; - this.isInstantiated = false; - const browserCrypto = typeof self !== "undefined" ? self.crypto || self.msCrypto : null; - if (browserCrypto && browserCrypto.getRandomValues !== void 0) { - this._crypto = browserCrypto; - this.isAvailable = true; - this.isInstantiated = true; - } - } - randomBytes(length) { - if (!this.isAvailable || !this._crypto) { - throw new Error("Browser random byte generator is not available."); - } - const out = new Uint8Array(length); - for (let i2 = 0; i2 < out.length; i2 += QUOTA) { - this._crypto.getRandomValues(out.subarray(i2, i2 + Math.min(out.length - i2, QUOTA))); - } - return out; - } -} -browser$3.BrowserRandomSource = BrowserRandomSource; -function commonjsRequire(path) { - throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); -} -var node = {}; -var wipe$1 = {}; -Object.defineProperty(wipe$1, "__esModule", { value: true }); -function wipe(array) { - for (var i2 = 0; i2 < array.length; i2++) { - array[i2] = 0; - } - return array; -} -wipe$1.wipe = wipe; -const __viteBrowserExternal = {}; -const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: __viteBrowserExternal -}, Symbol.toStringTag, { value: "Module" })); -const require$$1 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1); -Object.defineProperty(node, "__esModule", { value: true }); -node.NodeRandomSource = void 0; -const wipe_1$3 = wipe$1; -class NodeRandomSource { - constructor() { - this.isAvailable = false; - this.isInstantiated = false; - if (typeof commonjsRequire !== "undefined") { - const nodeCrypto = require$$1; - if (nodeCrypto && nodeCrypto.randomBytes) { - this._crypto = nodeCrypto; - this.isAvailable = true; - this.isInstantiated = true; - } - } - } - randomBytes(length) { - if (!this.isAvailable || !this._crypto) { - throw new Error("Node.js random byte generator is not available."); - } - let buffer = this._crypto.randomBytes(length); - if (buffer.length !== length) { - throw new Error("NodeRandomSource: got fewer bytes than requested"); - } - const out = new Uint8Array(length); - for (let i2 = 0; i2 < out.length; i2++) { - out[i2] = buffer[i2]; - } - (0, wipe_1$3.wipe)(buffer); - return out; - } -} -node.NodeRandomSource = NodeRandomSource; -Object.defineProperty(system, "__esModule", { value: true }); -system.SystemRandomSource = void 0; -const browser_1 = browser$3; -const node_1 = node; -class SystemRandomSource { - constructor() { - this.isAvailable = false; - this.name = ""; - this._source = new browser_1.BrowserRandomSource(); - if (this._source.isAvailable) { - this.isAvailable = true; - this.name = "Browser"; - return; - } - this._source = new node_1.NodeRandomSource(); - if (this._source.isAvailable) { - this.isAvailable = true; - this.name = "Node"; - return; - } - } - randomBytes(length) { - if (!this.isAvailable) { - throw new Error("System random byte generator is not available."); - } - return this._source.randomBytes(length); - } -} -system.SystemRandomSource = SystemRandomSource; -var binary = {}; -var int = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - function imulShim(a3, b3) { - var ah = a3 >>> 16 & 65535, al = a3 & 65535; - var bh = b3 >>> 16 & 65535, bl = b3 & 65535; - return al * bl + (ah * bl + al * bh << 16 >>> 0) | 0; - } - exports2.mul = Math.imul || imulShim; - function add(a3, b3) { - return a3 + b3 | 0; - } - exports2.add = add; - function sub(a3, b3) { - return a3 - b3 | 0; - } - exports2.sub = sub; - function rotl(x2, n3) { - return x2 << n3 | x2 >>> 32 - n3; - } - exports2.rotl = rotl; - function rotr(x2, n3) { - return x2 << 32 - n3 | x2 >>> n3; - } - exports2.rotr = rotr; - function isIntegerShim(n3) { - return typeof n3 === "number" && isFinite(n3) && Math.floor(n3) === n3; - } - exports2.isInteger = Number.isInteger || isIntegerShim; - exports2.MAX_SAFE_INTEGER = 9007199254740991; - exports2.isSafeInteger = function(n3) { - return exports2.isInteger(n3) && (n3 >= -exports2.MAX_SAFE_INTEGER && n3 <= exports2.MAX_SAFE_INTEGER); - }; -})(int); -Object.defineProperty(binary, "__esModule", { value: true }); -var int_1 = int; -function readInt16BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 0] << 8 | array[offset + 1]) << 16 >> 16; -} -binary.readInt16BE = readInt16BE; -function readUint16BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 0] << 8 | array[offset + 1]) >>> 0; -} -binary.readUint16BE = readUint16BE; -function readInt16LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 1] << 8 | array[offset]) << 16 >> 16; -} -binary.readInt16LE = readInt16LE; -function readUint16LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 1] << 8 | array[offset]) >>> 0; -} -binary.readUint16LE = readUint16LE; -function writeUint16BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(2); - } - if (offset === void 0) { - offset = 0; - } - out[offset + 0] = value >>> 8; - out[offset + 1] = value >>> 0; - return out; -} -binary.writeUint16BE = writeUint16BE; -binary.writeInt16BE = writeUint16BE; -function writeUint16LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(2); - } - if (offset === void 0) { - offset = 0; - } - out[offset + 0] = value >>> 0; - out[offset + 1] = value >>> 8; - return out; -} -binary.writeUint16LE = writeUint16LE; -binary.writeInt16LE = writeUint16LE; -function readInt32BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3]; -} -binary.readInt32BE = readInt32BE; -function readUint32BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3]) >>> 0; -} -binary.readUint32BE = readUint32BE; -function readInt32LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return array[offset + 3] << 24 | array[offset + 2] << 16 | array[offset + 1] << 8 | array[offset]; -} -binary.readInt32LE = readInt32LE; -function readUint32LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 3] << 24 | array[offset + 2] << 16 | array[offset + 1] << 8 | array[offset]) >>> 0; -} -binary.readUint32LE = readUint32LE; -function writeUint32BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(4); - } - if (offset === void 0) { - offset = 0; - } - out[offset + 0] = value >>> 24; - out[offset + 1] = value >>> 16; - out[offset + 2] = value >>> 8; - out[offset + 3] = value >>> 0; - return out; -} -binary.writeUint32BE = writeUint32BE; -binary.writeInt32BE = writeUint32BE; -function writeUint32LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(4); - } - if (offset === void 0) { - offset = 0; - } - out[offset + 0] = value >>> 0; - out[offset + 1] = value >>> 8; - out[offset + 2] = value >>> 16; - out[offset + 3] = value >>> 24; - return out; -} -binary.writeUint32LE = writeUint32LE; -binary.writeInt32LE = writeUint32LE; -function readInt64BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var hi = readInt32BE(array, offset); - var lo = readInt32BE(array, offset + 4); - return hi * 4294967296 + lo - (lo >> 31) * 4294967296; -} -binary.readInt64BE = readInt64BE; -function readUint64BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var hi = readUint32BE(array, offset); - var lo = readUint32BE(array, offset + 4); - return hi * 4294967296 + lo; -} -binary.readUint64BE = readUint64BE; -function readInt64LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var lo = readInt32LE(array, offset); - var hi = readInt32LE(array, offset + 4); - return hi * 4294967296 + lo - (lo >> 31) * 4294967296; -} -binary.readInt64LE = readInt64LE; -function readUint64LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var lo = readUint32LE(array, offset); - var hi = readUint32LE(array, offset + 4); - return hi * 4294967296 + lo; -} -binary.readUint64LE = readUint64LE; -function writeUint64BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(8); - } - if (offset === void 0) { - offset = 0; - } - writeUint32BE(value / 4294967296 >>> 0, out, offset); - writeUint32BE(value >>> 0, out, offset + 4); - return out; -} -binary.writeUint64BE = writeUint64BE; -binary.writeInt64BE = writeUint64BE; -function writeUint64LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(8); - } - if (offset === void 0) { - offset = 0; - } - writeUint32LE(value >>> 0, out, offset); - writeUint32LE(value / 4294967296 >>> 0, out, offset + 4); - return out; -} -binary.writeUint64LE = writeUint64LE; -binary.writeInt64LE = writeUint64LE; -function readUintBE(bitLength, array, offset) { - if (offset === void 0) { - offset = 0; - } - if (bitLength % 8 !== 0) { - throw new Error("readUintBE supports only bitLengths divisible by 8"); - } - if (bitLength / 8 > array.length - offset) { - throw new Error("readUintBE: array is too short for the given bitLength"); - } - var result = 0; - var mul = 1; - for (var i2 = bitLength / 8 + offset - 1; i2 >= offset; i2--) { - result += array[i2] * mul; - mul *= 256; - } - return result; -} -binary.readUintBE = readUintBE; -function readUintLE(bitLength, array, offset) { - if (offset === void 0) { - offset = 0; - } - if (bitLength % 8 !== 0) { - throw new Error("readUintLE supports only bitLengths divisible by 8"); - } - if (bitLength / 8 > array.length - offset) { - throw new Error("readUintLE: array is too short for the given bitLength"); - } - var result = 0; - var mul = 1; - for (var i2 = offset; i2 < offset + bitLength / 8; i2++) { - result += array[i2] * mul; - mul *= 256; - } - return result; -} -binary.readUintLE = readUintLE; -function writeUintBE(bitLength, value, out, offset) { - if (out === void 0) { - out = new Uint8Array(bitLength / 8); - } - if (offset === void 0) { - offset = 0; - } - if (bitLength % 8 !== 0) { - throw new Error("writeUintBE supports only bitLengths divisible by 8"); - } - if (!int_1.isSafeInteger(value)) { - throw new Error("writeUintBE value must be an integer"); - } - var div = 1; - for (var i2 = bitLength / 8 + offset - 1; i2 >= offset; i2--) { - out[i2] = value / div & 255; - div *= 256; - } - return out; -} -binary.writeUintBE = writeUintBE; -function writeUintLE(bitLength, value, out, offset) { - if (out === void 0) { - out = new Uint8Array(bitLength / 8); - } - if (offset === void 0) { - offset = 0; - } - if (bitLength % 8 !== 0) { - throw new Error("writeUintLE supports only bitLengths divisible by 8"); - } - if (!int_1.isSafeInteger(value)) { - throw new Error("writeUintLE value must be an integer"); - } - var div = 1; - for (var i2 = offset; i2 < offset + bitLength / 8; i2++) { - out[i2] = value / div & 255; - div *= 256; - } - return out; -} -binary.writeUintLE = writeUintLE; -function readFloat32BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var view = new DataView(array.buffer, array.byteOffset, array.byteLength); - return view.getFloat32(offset); -} -binary.readFloat32BE = readFloat32BE; -function readFloat32LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var view = new DataView(array.buffer, array.byteOffset, array.byteLength); - return view.getFloat32(offset, true); -} -binary.readFloat32LE = readFloat32LE; -function readFloat64BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var view = new DataView(array.buffer, array.byteOffset, array.byteLength); - return view.getFloat64(offset); -} -binary.readFloat64BE = readFloat64BE; -function readFloat64LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var view = new DataView(array.buffer, array.byteOffset, array.byteLength); - return view.getFloat64(offset, true); -} -binary.readFloat64LE = readFloat64LE; -function writeFloat32BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(4); - } - if (offset === void 0) { - offset = 0; - } - var view = new DataView(out.buffer, out.byteOffset, out.byteLength); - view.setFloat32(offset, value); - return out; -} -binary.writeFloat32BE = writeFloat32BE; -function writeFloat32LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(4); - } - if (offset === void 0) { - offset = 0; - } - var view = new DataView(out.buffer, out.byteOffset, out.byteLength); - view.setFloat32(offset, value, true); - return out; -} -binary.writeFloat32LE = writeFloat32LE; -function writeFloat64BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(8); - } - if (offset === void 0) { - offset = 0; - } - var view = new DataView(out.buffer, out.byteOffset, out.byteLength); - view.setFloat64(offset, value); - return out; -} -binary.writeFloat64BE = writeFloat64BE; -function writeFloat64LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(8); - } - if (offset === void 0) { - offset = 0; - } - var view = new DataView(out.buffer, out.byteOffset, out.byteLength); - view.setFloat64(offset, value, true); - return out; -} -binary.writeFloat64LE = writeFloat64LE; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.randomStringForEntropy = exports2.randomString = exports2.randomUint32 = exports2.randomBytes = exports2.defaultRandomSource = void 0; - const system_1 = system; - const binary_12 = binary; - const wipe_12 = wipe$1; - exports2.defaultRandomSource = new system_1.SystemRandomSource(); - function randomBytes(length, prng = exports2.defaultRandomSource) { - return prng.randomBytes(length); - } - exports2.randomBytes = randomBytes; - function randomUint32(prng = exports2.defaultRandomSource) { - const buf = randomBytes(4, prng); - const result = (0, binary_12.readUint32LE)(buf); - (0, wipe_12.wipe)(buf); - return result; - } - exports2.randomUint32 = randomUint32; - const ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - function randomString(length, charset = ALPHANUMERIC, prng = exports2.defaultRandomSource) { - if (charset.length < 2) { - throw new Error("randomString charset is too short"); - } - if (charset.length > 256) { - throw new Error("randomString charset is too long"); - } - let out = ""; - const charsLen = charset.length; - const maxByte = 256 - 256 % charsLen; - while (length > 0) { - const buf = randomBytes(Math.ceil(length * 256 / maxByte), prng); - for (let i2 = 0; i2 < buf.length && length > 0; i2++) { - const randomByte = buf[i2]; - if (randomByte < maxByte) { - out += charset.charAt(randomByte % charsLen); - length--; - } - } - (0, wipe_12.wipe)(buf); - } - return out; - } - exports2.randomString = randomString; - function randomStringForEntropy(bits, charset = ALPHANUMERIC, prng = exports2.defaultRandomSource) { - const length = Math.ceil(bits / (Math.log(charset.length) / Math.LN2)); - return randomString(length, charset, prng); - } - exports2.randomStringForEntropy = randomStringForEntropy; -})(random); -var sha512 = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var binary_12 = binary; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 64; - exports2.BLOCK_SIZE = 128; - var SHA512 = ( - /** @class */ - function() { - function SHA5122() { - this.digestLength = exports2.DIGEST_LENGTH; - this.blockSize = exports2.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 = false; - this.reset(); - } - SHA5122.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; - }; - SHA5122.prototype.reset = function() { - this._initState(); - this._bufferLength = 0; - this._bytesHashed = 0; - this._finished = false; - return this; - }; - SHA5122.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._tempHi); - wipe_12.wipe(this._tempLo); - this.reset(); - }; - SHA5122.prototype.update = function(data, dataLength) { - if (dataLength === void 0) { - dataLength = data.length; - } - if (this._finished) { - throw new Error("SHA512: can't update because hash was finished."); - } - var dataPos = 0; - this._bytesHashed += dataLength; - if (this._bufferLength > 0) { - while (this._bufferLength < exports2.BLOCK_SIZE && dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - if (this._bufferLength === this.blockSize) { - hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, this.blockSize); - this._bufferLength = 0; - } - } - if (dataLength >= this.blockSize) { - dataPos = hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, data, dataPos, dataLength); - dataLength %= this.blockSize; - } - while (dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - return this; - }; - SHA5122.prototype.finish = function(out) { - if (!this._finished) { - var bytesHashed = this._bytesHashed; - var left = this._bufferLength; - var bitLenHi = bytesHashed / 536870912 | 0; - var bitLenLo = bytesHashed << 3; - var padLength = bytesHashed % 128 < 112 ? 128 : 256; - this._buffer[left] = 128; - for (var i2 = left + 1; i2 < padLength - 8; i2++) { - this._buffer[i2] = 0; - } - binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); - binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); - hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, padLength); - this._finished = true; - } - for (var i2 = 0; i2 < this.digestLength / 8; i2++) { - binary_12.writeUint32BE(this._stateHi[i2], out, i2 * 8); - binary_12.writeUint32BE(this._stateLo[i2], out, i2 * 8 + 4); - } - return this; - }; - SHA5122.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - SHA5122.prototype.saveState = function() { - if (this._finished) { - throw new Error("SHA256: cannot save finished state"); - } - return { - stateHi: new Int32Array(this._stateHi), - stateLo: new Int32Array(this._stateLo), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed - }; - }; - SHA5122.prototype.restoreState = function(savedState) { - this._stateHi.set(savedState.stateHi); - this._stateLo.set(savedState.stateLo); - this._bufferLength = savedState.bufferLength; - if (savedState.buffer) { - this._buffer.set(savedState.buffer); - } - this._bytesHashed = savedState.bytesHashed; - this._finished = false; - return this; - }; - SHA5122.prototype.cleanSavedState = function(savedState) { - wipe_12.wipe(savedState.stateHi); - wipe_12.wipe(savedState.stateLo); - if (savedState.buffer) { - wipe_12.wipe(savedState.buffer); - } - savedState.bufferLength = 0; - savedState.bytesHashed = 0; - }; - return SHA5122; - }() - ); - exports2.SHA512 = SHA512; - var K2 = 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 hashBlocks(wh, wl, hh, hl, m2, pos, len) { - var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; - var h4, l2; - var th, tl; - var a3, b3, c2, d3; - while (len >= 128) { - for (var i2 = 0; i2 < 16; i2++) { - var j2 = 8 * i2 + pos; - wh[i2] = binary_12.readUint32BE(m2, j2); - wl[i2] = binary_12.readUint32BE(m2, j2 + 4); - } - for (var i2 = 0; i2 < 80; i2++) { - var bh0 = ah0; - var bh1 = ah1; - var bh2 = ah2; - var bh3 = ah3; - var bh4 = ah4; - var bh5 = ah5; - var bh6 = ah6; - var bh7 = ah7; - var bl0 = al0; - var bl1 = al1; - var bl2 = al2; - var bl3 = al3; - var bl4 = al4; - var bl5 = al5; - var bl6 = al6; - var bl7 = al7; - h4 = ah7; - l2 = al7; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32)); - l2 = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32)); - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = ah4 & ah5 ^ ~ah4 & ah6; - l2 = al4 & al5 ^ ~al4 & al6; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = K2[i2 * 2]; - l2 = K2[i2 * 2 + 1]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = wh[i2 % 16]; - l2 = wl[i2 % 16]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - th = c2 & 65535 | d3 << 16; - tl = a3 & 65535 | b3 << 16; - h4 = th; - l2 = tl; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32)); - l2 = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32)); - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2; - l2 = al0 & al1 ^ al0 & al2 ^ al1 & al2; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh7 = c2 & 65535 | d3 << 16; - bl7 = a3 & 65535 | b3 << 16; - h4 = bh3; - l2 = bl3; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = th; - l2 = tl; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh3 = c2 & 65535 | d3 << 16; - bl3 = a3 & 65535 | b3 << 16; - ah1 = bh0; - ah2 = bh1; - ah3 = bh2; - ah4 = bh3; - ah5 = bh4; - ah6 = bh5; - ah7 = bh6; - ah0 = bh7; - al1 = bl0; - al2 = bl1; - al3 = bl2; - al4 = bl3; - al5 = bl4; - al6 = bl5; - al7 = bl6; - al0 = bl7; - if (i2 % 16 === 15) { - for (var j2 = 0; j2 < 16; j2++) { - h4 = wh[j2]; - l2 = wl[j2]; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = wh[(j2 + 9) % 16]; - l2 = wl[(j2 + 9) % 16]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 1) % 16]; - tl = wl[(j2 + 1) % 16]; - h4 = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7; - l2 = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7); - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 14) % 16]; - tl = wl[(j2 + 14) % 16]; - h4 = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6; - l2 = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6); - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - wh[j2] = c2 & 65535 | d3 << 16; - wl[j2] = a3 & 65535 | b3 << 16; - } - } - } - h4 = ah0; - l2 = al0; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[0]; - l2 = hl[0]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[0] = ah0 = c2 & 65535 | d3 << 16; - hl[0] = al0 = a3 & 65535 | b3 << 16; - h4 = ah1; - l2 = al1; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[1]; - l2 = hl[1]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[1] = ah1 = c2 & 65535 | d3 << 16; - hl[1] = al1 = a3 & 65535 | b3 << 16; - h4 = ah2; - l2 = al2; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[2]; - l2 = hl[2]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[2] = ah2 = c2 & 65535 | d3 << 16; - hl[2] = al2 = a3 & 65535 | b3 << 16; - h4 = ah3; - l2 = al3; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[3]; - l2 = hl[3]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[3] = ah3 = c2 & 65535 | d3 << 16; - hl[3] = al3 = a3 & 65535 | b3 << 16; - h4 = ah4; - l2 = al4; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[4]; - l2 = hl[4]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[4] = ah4 = c2 & 65535 | d3 << 16; - hl[4] = al4 = a3 & 65535 | b3 << 16; - h4 = ah5; - l2 = al5; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[5]; - l2 = hl[5]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[5] = ah5 = c2 & 65535 | d3 << 16; - hl[5] = al5 = a3 & 65535 | b3 << 16; - h4 = ah6; - l2 = al6; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[6]; - l2 = hl[6]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[6] = ah6 = c2 & 65535 | d3 << 16; - hl[6] = al6 = a3 & 65535 | b3 << 16; - h4 = ah7; - l2 = al7; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[7]; - l2 = hl[7]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[7] = ah7 = c2 & 65535 | d3 << 16; - hl[7] = al7 = a3 & 65535 | b3 << 16; - pos += 128; - len -= 128; - } - return pos; - } - function hash2(data) { - var h4 = new SHA512(); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; - } - exports2.hash = hash2; -})(sha512); -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.convertSecretKeyToX25519 = exports2.convertPublicKeyToX25519 = exports2.verify = exports2.sign = exports2.extractPublicKeyFromSecretKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.SEED_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = exports2.SIGNATURE_LENGTH = void 0; - const random_1 = random; - const sha512_1 = sha512; - const wipe_12 = wipe$1; - exports2.SIGNATURE_LENGTH = 64; - exports2.PUBLIC_KEY_LENGTH = 32; - exports2.SECRET_KEY_LENGTH = 64; - exports2.SEED_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); - if (init) { - for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; - } - } - return r2; - } - const _9 = new Uint8Array(32); - _9[0] = 9; - const gf0 = gf(); - const gf1 = gf([1]); - const D2 = gf([ - 30883, - 4953, - 19914, - 30187, - 55467, - 16705, - 2637, - 112, - 59544, - 30585, - 16505, - 36039, - 65139, - 11119, - 27886, - 20995 - ]); - const D22 = gf([ - 61785, - 9906, - 39828, - 60374, - 45398, - 33411, - 5274, - 224, - 53552, - 61171, - 33010, - 6542, - 64743, - 22239, - 55772, - 9222 - ]); - const X2 = gf([ - 54554, - 36645, - 11616, - 51542, - 42930, - 38181, - 51040, - 26924, - 56412, - 64982, - 57905, - 49316, - 21502, - 52590, - 14035, - 8553 - ]); - const Y2 = gf([ - 26200, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214 - ]); - const I2 = gf([ - 41136, - 18958, - 6951, - 50414, - 58488, - 44335, - 6150, - 12099, - 55207, - 15867, - 153, - 11085, - 57099, - 20417, - 9344, - 11139 - ]); - function set25519(r2, a3) { - for (let i2 = 0; i2 < 16; i2++) { - r2[i2] = a3[i2] | 0; - } - } - function car25519(o2) { - let c2 = 1; - for (let i2 = 0; i2 < 16; i2++) { - let v3 = o2[i2] + c2 + 65535; - c2 = Math.floor(v3 / 65536); - o2[i2] = v3 - c2 * 65536; - } - o2[0] += c2 - 1 + 37 * (c2 - 1); - } - function sel25519(p3, q2, b3) { - const c2 = ~(b3 - 1); - for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; - q2[i2] ^= t2; - } - } - function pack25519(o2, n3) { - const m2 = gf(); - const t2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; - } - car25519(t2); - car25519(t2); - car25519(t2); - for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; - for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; - } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); - } - for (let i2 = 0; i2 < 16; i2++) { - o2[2 * i2] = t2[i2] & 255; - o2[2 * i2 + 1] = t2[i2] >> 8; - } - } - function verify32(x2, y3) { - let d3 = 0; - for (let i2 = 0; i2 < 32; i2++) { - d3 |= x2[i2] ^ y3[i2]; - } - return (1 & d3 - 1 >>> 8) - 1; - } - function neq25519(a3, b3) { - const c2 = new Uint8Array(32); - const d3 = new Uint8Array(32); - pack25519(c2, a3); - pack25519(d3, b3); - return verify32(c2, d3); - } - function par25519(a3) { - const d3 = new Uint8Array(32); - pack25519(d3, a3); - return d3[0] & 1; - } - function unpack25519(o2, n3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); - } - o2[15] &= 32767; - } - function add(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] + b3[i2]; - } - } - function sub(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] - b3[i2]; - } - } - function mul(o2, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; - v3 = a3[0]; - t0 += v3 * b0; - t1 += v3 * b1; - t2 += v3 * b22; - t3 += v3 * b32; - t4 += v3 * b4; - t5 += v3 * b5; - t6 += v3 * b6; - t7 += v3 * b7; - t8 += v3 * b8; - t9 += v3 * b9; - t10 += v3 * b10; - t11 += v3 * b11; - t12 += v3 * b12; - t13 += v3 * b13; - t14 += v3 * b14; - t15 += v3 * b15; - v3 = a3[1]; - t1 += v3 * b0; - t2 += v3 * b1; - t3 += v3 * b22; - t4 += v3 * b32; - t5 += v3 * b4; - t6 += v3 * b5; - t7 += v3 * b6; - t8 += v3 * b7; - t9 += v3 * b8; - t10 += v3 * b9; - t11 += v3 * b10; - t12 += v3 * b11; - t13 += v3 * b12; - t14 += v3 * b13; - t15 += v3 * b14; - t16 += v3 * b15; - v3 = a3[2]; - t2 += v3 * b0; - t3 += v3 * b1; - t4 += v3 * b22; - t5 += v3 * b32; - t6 += v3 * b4; - t7 += v3 * b5; - t8 += v3 * b6; - t9 += v3 * b7; - t10 += v3 * b8; - t11 += v3 * b9; - t12 += v3 * b10; - t13 += v3 * b11; - t14 += v3 * b12; - t15 += v3 * b13; - t16 += v3 * b14; - t17 += v3 * b15; - v3 = a3[3]; - t3 += v3 * b0; - t4 += v3 * b1; - t5 += v3 * b22; - t6 += v3 * b32; - t7 += v3 * b4; - t8 += v3 * b5; - t9 += v3 * b6; - t10 += v3 * b7; - t11 += v3 * b8; - t12 += v3 * b9; - t13 += v3 * b10; - t14 += v3 * b11; - t15 += v3 * b12; - t16 += v3 * b13; - t17 += v3 * b14; - t18 += v3 * b15; - v3 = a3[4]; - t4 += v3 * b0; - t5 += v3 * b1; - t6 += v3 * b22; - t7 += v3 * b32; - t8 += v3 * b4; - t9 += v3 * b5; - t10 += v3 * b6; - t11 += v3 * b7; - t12 += v3 * b8; - t13 += v3 * b9; - t14 += v3 * b10; - t15 += v3 * b11; - t16 += v3 * b12; - t17 += v3 * b13; - t18 += v3 * b14; - t19 += v3 * b15; - v3 = a3[5]; - t5 += v3 * b0; - t6 += v3 * b1; - t7 += v3 * b22; - t8 += v3 * b32; - t9 += v3 * b4; - t10 += v3 * b5; - t11 += v3 * b6; - t12 += v3 * b7; - t13 += v3 * b8; - t14 += v3 * b9; - t15 += v3 * b10; - t16 += v3 * b11; - t17 += v3 * b12; - t18 += v3 * b13; - t19 += v3 * b14; - t20 += v3 * b15; - v3 = a3[6]; - t6 += v3 * b0; - t7 += v3 * b1; - t8 += v3 * b22; - t9 += v3 * b32; - t10 += v3 * b4; - t11 += v3 * b5; - t12 += v3 * b6; - t13 += v3 * b7; - t14 += v3 * b8; - t15 += v3 * b9; - t16 += v3 * b10; - t17 += v3 * b11; - t18 += v3 * b12; - t19 += v3 * b13; - t20 += v3 * b14; - t21 += v3 * b15; - v3 = a3[7]; - t7 += v3 * b0; - t8 += v3 * b1; - t9 += v3 * b22; - t10 += v3 * b32; - t11 += v3 * b4; - t12 += v3 * b5; - t13 += v3 * b6; - t14 += v3 * b7; - t15 += v3 * b8; - t16 += v3 * b9; - t17 += v3 * b10; - t18 += v3 * b11; - t19 += v3 * b12; - t20 += v3 * b13; - t21 += v3 * b14; - t22 += v3 * b15; - v3 = a3[8]; - t8 += v3 * b0; - t9 += v3 * b1; - t10 += v3 * b22; - t11 += v3 * b32; - t12 += v3 * b4; - t13 += v3 * b5; - t14 += v3 * b6; - t15 += v3 * b7; - t16 += v3 * b8; - t17 += v3 * b9; - t18 += v3 * b10; - t19 += v3 * b11; - t20 += v3 * b12; - t21 += v3 * b13; - t22 += v3 * b14; - t23 += v3 * b15; - v3 = a3[9]; - t9 += v3 * b0; - t10 += v3 * b1; - t11 += v3 * b22; - t12 += v3 * b32; - t13 += v3 * b4; - t14 += v3 * b5; - t15 += v3 * b6; - t16 += v3 * b7; - t17 += v3 * b8; - t18 += v3 * b9; - t19 += v3 * b10; - t20 += v3 * b11; - t21 += v3 * b12; - t22 += v3 * b13; - t23 += v3 * b14; - t24 += v3 * b15; - v3 = a3[10]; - t10 += v3 * b0; - t11 += v3 * b1; - t12 += v3 * b22; - t13 += v3 * b32; - t14 += v3 * b4; - t15 += v3 * b5; - t16 += v3 * b6; - t17 += v3 * b7; - t18 += v3 * b8; - t19 += v3 * b9; - t20 += v3 * b10; - t21 += v3 * b11; - t22 += v3 * b12; - t23 += v3 * b13; - t24 += v3 * b14; - t25 += v3 * b15; - v3 = a3[11]; - t11 += v3 * b0; - t12 += v3 * b1; - t13 += v3 * b22; - t14 += v3 * b32; - t15 += v3 * b4; - t16 += v3 * b5; - t17 += v3 * b6; - t18 += v3 * b7; - t19 += v3 * b8; - t20 += v3 * b9; - t21 += v3 * b10; - t22 += v3 * b11; - t23 += v3 * b12; - t24 += v3 * b13; - t25 += v3 * b14; - t26 += v3 * b15; - v3 = a3[12]; - t12 += v3 * b0; - t13 += v3 * b1; - t14 += v3 * b22; - t15 += v3 * b32; - t16 += v3 * b4; - t17 += v3 * b5; - t18 += v3 * b6; - t19 += v3 * b7; - t20 += v3 * b8; - t21 += v3 * b9; - t22 += v3 * b10; - t23 += v3 * b11; - t24 += v3 * b12; - t25 += v3 * b13; - t26 += v3 * b14; - t27 += v3 * b15; - v3 = a3[13]; - t13 += v3 * b0; - t14 += v3 * b1; - t15 += v3 * b22; - t16 += v3 * b32; - t17 += v3 * b4; - t18 += v3 * b5; - t19 += v3 * b6; - t20 += v3 * b7; - t21 += v3 * b8; - t22 += v3 * b9; - t23 += v3 * b10; - t24 += v3 * b11; - t25 += v3 * b12; - t26 += v3 * b13; - t27 += v3 * b14; - t28 += v3 * b15; - v3 = a3[14]; - t14 += v3 * b0; - t15 += v3 * b1; - t16 += v3 * b22; - t17 += v3 * b32; - t18 += v3 * b4; - t19 += v3 * b5; - t20 += v3 * b6; - t21 += v3 * b7; - t22 += v3 * b8; - t23 += v3 * b9; - t24 += v3 * b10; - t25 += v3 * b11; - t26 += v3 * b12; - t27 += v3 * b13; - t28 += v3 * b14; - t29 += v3 * b15; - v3 = a3[15]; - t15 += v3 * b0; - t16 += v3 * b1; - t17 += v3 * b22; - t18 += v3 * b32; - t19 += v3 * b4; - t20 += v3 * b5; - t21 += v3 * b6; - t22 += v3 * b7; - t23 += v3 * b8; - t24 += v3 * b9; - t25 += v3 * b10; - t26 += v3 * b11; - t27 += v3 * b12; - t28 += v3 * b13; - t29 += v3 * b14; - t30 += v3 * b15; - t0 += 38 * t16; - t1 += 38 * t17; - t2 += 38 * t18; - t3 += 38 * t19; - t4 += 38 * t20; - t5 += 38 * t21; - t6 += 38 * t22; - t7 += 38 * t23; - t8 += 38 * t24; - t9 += 38 * t25; - t10 += 38 * t26; - t11 += 38 * t27; - t12 += 38 * t28; - t13 += 38 * t29; - t14 += 38 * t30; - c2 = 1; - v3 = t0 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t0 = v3 - c2 * 65536; - v3 = t1 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t1 = v3 - c2 * 65536; - v3 = t2 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t2 = v3 - c2 * 65536; - v3 = t3 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t3 = v3 - c2 * 65536; - v3 = t4 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t4 = v3 - c2 * 65536; - v3 = t5 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t5 = v3 - c2 * 65536; - v3 = t6 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t6 = v3 - c2 * 65536; - v3 = t7 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t7 = v3 - c2 * 65536; - v3 = t8 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t8 = v3 - c2 * 65536; - v3 = t9 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t9 = v3 - c2 * 65536; - v3 = t10 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t10 = v3 - c2 * 65536; - v3 = t11 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t11 = v3 - c2 * 65536; - v3 = t12 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t12 = v3 - c2 * 65536; - v3 = t13 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t13 = v3 - c2 * 65536; - v3 = t14 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t14 = v3 - c2 * 65536; - v3 = t15 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t15 = v3 - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - c2 = 1; - v3 = t0 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t0 = v3 - c2 * 65536; - v3 = t1 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t1 = v3 - c2 * 65536; - v3 = t2 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t2 = v3 - c2 * 65536; - v3 = t3 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t3 = v3 - c2 * 65536; - v3 = t4 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t4 = v3 - c2 * 65536; - v3 = t5 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t5 = v3 - c2 * 65536; - v3 = t6 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t6 = v3 - c2 * 65536; - v3 = t7 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t7 = v3 - c2 * 65536; - v3 = t8 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t8 = v3 - c2 * 65536; - v3 = t9 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t9 = v3 - c2 * 65536; - v3 = t10 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t10 = v3 - c2 * 65536; - v3 = t11 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t11 = v3 - c2 * 65536; - v3 = t12 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t12 = v3 - c2 * 65536; - v3 = t13 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t13 = v3 - c2 * 65536; - v3 = t14 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t14 = v3 - c2 * 65536; - v3 = t15 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t15 = v3 - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - o2[0] = t0; - o2[1] = t1; - o2[2] = t2; - o2[3] = t3; - o2[4] = t4; - o2[5] = t5; - o2[6] = t6; - o2[7] = t7; - o2[8] = t8; - o2[9] = t9; - o2[10] = t10; - o2[11] = t11; - o2[12] = t12; - o2[13] = t13; - o2[14] = t14; - o2[15] = t15; - } - function square(o2, a3) { - mul(o2, a3, a3); - } - function inv25519(o2, i2) { - const c2 = gf(); - let a3; - for (a3 = 0; a3 < 16; a3++) { - c2[a3] = i2[a3]; - } - for (a3 = 253; a3 >= 0; a3--) { - square(c2, c2); - if (a3 !== 2 && a3 !== 4) { - mul(c2, c2, i2); - } - } - for (a3 = 0; a3 < 16; a3++) { - o2[a3] = c2[a3]; - } - } - function pow2523(o2, i2) { - const c2 = gf(); - let a3; - for (a3 = 0; a3 < 16; a3++) { - c2[a3] = i2[a3]; - } - for (a3 = 250; a3 >= 0; a3--) { - square(c2, c2); - if (a3 !== 1) { - mul(c2, c2, i2); - } - } - for (a3 = 0; a3 < 16; a3++) { - o2[a3] = c2[a3]; - } - } - function edadd(p3, q2) { - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e = gf(), f2 = gf(), g3 = gf(), h4 = gf(), t2 = gf(); - sub(a3, p3[1], p3[0]); - sub(t2, q2[1], q2[0]); - mul(a3, a3, t2); - add(b3, p3[0], p3[1]); - add(t2, q2[0], q2[1]); - mul(b3, b3, t2); - mul(c2, p3[3], q2[3]); - mul(c2, c2, D22); - mul(d3, p3[2], q2[2]); - add(d3, d3, d3); - sub(e, b3, a3); - sub(f2, d3, c2); - add(g3, d3, c2); - add(h4, b3, a3); - mul(p3[0], e, f2); - mul(p3[1], h4, g3); - mul(p3[2], g3, f2); - mul(p3[3], e, h4); - } - function cswap(p3, q2, b3) { - for (let i2 = 0; i2 < 4; i2++) { - sel25519(p3[i2], q2[i2], b3); - } - } - function pack(r2, p3) { - const tx = gf(), ty = gf(), zi = gf(); - inv25519(zi, p3[2]); - mul(tx, p3[0], zi); - mul(ty, p3[1], zi); - pack25519(r2, ty); - r2[31] ^= par25519(tx) << 7; - } - function scalarmult(p3, q2, s2) { - set25519(p3[0], gf0); - set25519(p3[1], gf1); - set25519(p3[2], gf1); - set25519(p3[3], gf0); - for (let i2 = 255; i2 >= 0; --i2) { - const b3 = s2[i2 / 8 | 0] >> (i2 & 7) & 1; - cswap(p3, q2, b3); - edadd(q2, p3); - edadd(p3, p3); - cswap(p3, q2, b3); - } - } - function scalarbase(p3, s2) { - const q2 = [gf(), gf(), gf(), gf()]; - set25519(q2[0], X2); - set25519(q2[1], Y2); - set25519(q2[2], gf1); - mul(q2[3], X2, Y2); - scalarmult(p3, q2, s2); - } - function generateKeyPairFromSeed(seed) { - if (seed.length !== exports2.SEED_LENGTH) { - throw new Error(`ed25519: seed must be ${exports2.SEED_LENGTH} bytes`); - } - const d3 = (0, sha512_1.hash)(seed); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const publicKey = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - scalarbase(p3, d3); - pack(publicKey, p3); - const secretKey = new Uint8Array(64); - secretKey.set(seed); - secretKey.set(publicKey, 32); - return { - publicKey, - secretKey - }; - } - exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; - function generateKeyPair2(prng) { - const seed = (0, random_1.randomBytes)(32, prng); - const result = generateKeyPairFromSeed(seed); - (0, wipe_12.wipe)(seed); - return result; - } - exports2.generateKeyPair = generateKeyPair2; - function extractPublicKeyFromSecretKey(secretKey) { - if (secretKey.length !== exports2.SECRET_KEY_LENGTH) { - throw new Error(`ed25519: secret key must be ${exports2.SECRET_KEY_LENGTH} bytes`); - } - return new Uint8Array(secretKey.subarray(32)); - } - exports2.extractPublicKeyFromSecretKey = extractPublicKeyFromSecretKey; - const L2 = 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 modL(r2, x2) { - let carry; - let i2; - let j2; - let k2; - for (i2 = 63; i2 >= 32; --i2) { - carry = 0; - for (j2 = i2 - 32, k2 = i2 - 12; j2 < k2; ++j2) { - x2[j2] += carry - 16 * x2[i2] * L2[j2 - (i2 - 32)]; - carry = Math.floor((x2[j2] + 128) / 256); - x2[j2] -= carry * 256; - } - x2[j2] += carry; - x2[i2] = 0; - } - carry = 0; - for (j2 = 0; j2 < 32; j2++) { - x2[j2] += carry - (x2[31] >> 4) * L2[j2]; - carry = x2[j2] >> 8; - x2[j2] &= 255; - } - for (j2 = 0; j2 < 32; j2++) { - x2[j2] -= carry * L2[j2]; - } - for (i2 = 0; i2 < 32; i2++) { - x2[i2 + 1] += x2[i2] >> 8; - r2[i2] = x2[i2] & 255; - } - } - function reduce(r2) { - const x2 = new Float64Array(64); - for (let i2 = 0; i2 < 64; i2++) { - x2[i2] = r2[i2]; - } - for (let i2 = 0; i2 < 64; i2++) { - r2[i2] = 0; - } - modL(r2, x2); - } - function sign(secretKey, message) { - const x2 = new Float64Array(64); - const p3 = [gf(), gf(), gf(), gf()]; - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const signature = new Uint8Array(64); - signature.set(d3.subarray(32), 32); - const hs2 = new sha512_1.SHA512(); - hs2.update(signature.subarray(32)); - hs2.update(message); - const r2 = hs2.digest(); - hs2.clean(); - reduce(r2); - scalarbase(p3, r2); - pack(signature, p3); - hs2.reset(); - hs2.update(signature.subarray(0, 32)); - hs2.update(secretKey.subarray(32)); - hs2.update(message); - const h4 = hs2.digest(); - reduce(h4); - for (let i2 = 0; i2 < 32; i2++) { - x2[i2] = r2[i2]; - } - for (let i2 = 0; i2 < 32; i2++) { - for (let j2 = 0; j2 < 32; j2++) { - x2[i2 + j2] += h4[i2] * d3[j2]; - } - } - modL(signature.subarray(32), x2); - return signature; - } - exports2.sign = sign; - function unpackneg(r2, p3) { - const t2 = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf(); - set25519(r2[2], gf1); - unpack25519(r2[1], p3); - square(num, r2[1]); - mul(den, num, D2); - sub(num, num, r2[2]); - add(den, r2[2], den); - square(den2, den); - square(den4, den2); - mul(den6, den4, den2); - mul(t2, den6, num); - mul(t2, t2, den); - pow2523(t2, t2); - mul(t2, t2, num); - mul(t2, t2, den); - mul(t2, t2, den); - mul(r2[0], t2, den); - square(chk, r2[0]); - mul(chk, chk, den); - if (neq25519(chk, num)) { - mul(r2[0], r2[0], I2); - } - square(chk, r2[0]); - mul(chk, chk, den); - if (neq25519(chk, num)) { - return -1; - } - if (par25519(r2[0]) === p3[31] >> 7) { - sub(r2[0], gf0, r2[0]); - } - mul(r2[3], r2[0], r2[1]); - return 0; - } - function verify(publicKey, message, signature) { - const t2 = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - const q2 = [gf(), gf(), gf(), gf()]; - if (signature.length !== exports2.SIGNATURE_LENGTH) { - throw new Error(`ed25519: signature must be ${exports2.SIGNATURE_LENGTH} bytes`); - } - if (unpackneg(q2, publicKey)) { - return false; - } - const hs2 = new sha512_1.SHA512(); - hs2.update(signature.subarray(0, 32)); - hs2.update(publicKey); - hs2.update(message); - const h4 = hs2.digest(); - reduce(h4); - scalarmult(p3, q2, h4); - scalarbase(q2, signature.subarray(32)); - edadd(p3, q2); - pack(t2, p3); - if (verify32(signature, t2)) { - return false; - } - return true; - } - exports2.verify = verify; - function convertPublicKeyToX25519(publicKey) { - let q2 = [gf(), gf(), gf(), gf()]; - if (unpackneg(q2, publicKey)) { - throw new Error("Ed25519: invalid public key"); - } - let a3 = gf(); - let b3 = gf(); - let y3 = q2[1]; - add(a3, gf1, y3); - sub(b3, gf1, y3); - inv25519(b3, b3); - mul(a3, a3, b3); - let z3 = new Uint8Array(32); - pack25519(z3, a3); - return z3; - } - exports2.convertPublicKeyToX25519 = convertPublicKeyToX25519; - function convertSecretKeyToX25519(secretKey) { - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const o2 = new Uint8Array(d3.subarray(0, 32)); - (0, wipe_12.wipe)(d3); - return o2; - } - exports2.convertSecretKeyToX25519 = convertSecretKeyToX25519; -})(ed25519); -const JWT_IRIDIUM_ALG = "EdDSA"; -const JWT_IRIDIUM_TYP = "JWT"; -const JWT_DELIMITER = "."; -const JWT_ENCODING = "base64url"; -const JSON_ENCODING = "utf8"; -const DATA_ENCODING = "utf8"; -const DID_DELIMITER = ":"; -const DID_PREFIX = "did"; -const DID_METHOD = "key"; -const MULTICODEC_ED25519_ENCODING = "base58btc"; -const MULTICODEC_ED25519_BASE = "z"; -const MULTICODEC_ED25519_HEADER = "K36"; -const KEY_PAIR_SEED_LENGTH = 32; -function asUint8Array(buf) { - if (globalThis.Buffer != null) { - return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength); - } - return buf; -} -function allocUnsafe(size = 0) { - if (globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null) { - return asUint8Array(globalThis.Buffer.allocUnsafe(size)); - } - return new Uint8Array(size); -} -function concat(arrays, length) { - if (!length) { - length = arrays.reduce((acc, curr) => acc + curr.length, 0); - } - const output = allocUnsafe(length); - let offset = 0; - for (const arr of arrays) { - output.set(arr, offset); - offset += arr.length; - } - return asUint8Array(output); -} -function base(ALPHABET, name2) { - if (ALPHABET.length >= 255) { - throw new TypeError("Alphabet too long"); - } - var BASE_MAP = new Uint8Array(256); - for (var j2 = 0; j2 < BASE_MAP.length; j2++) { - BASE_MAP[j2] = 255; - } - for (var i2 = 0; i2 < ALPHABET.length; i2++) { - var x2 = ALPHABET.charAt(i2); - var xc = x2.charCodeAt(0); - if (BASE_MAP[xc] !== 255) { - throw new TypeError(x2 + " is ambiguous"); - } - BASE_MAP[xc] = i2; - } - var BASE = ALPHABET.length; - var LEADER = ALPHABET.charAt(0); - var FACTOR = Math.log(BASE) / Math.log(256); - var iFACTOR = Math.log(256) / Math.log(BASE); - function encode2(source) { - if (source instanceof Uint8Array) - ; - else if (ArrayBuffer.isView(source)) { - source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength); - } else if (Array.isArray(source)) { - source = Uint8Array.from(source); - } - if (!(source instanceof Uint8Array)) { - throw new TypeError("Expected Uint8Array"); - } - if (source.length === 0) { - return ""; - } - var zeroes = 0; - var length = 0; - var pbegin = 0; - var pend = source.length; - while (pbegin !== pend && source[pbegin] === 0) { - pbegin++; - zeroes++; - } - var size = (pend - pbegin) * iFACTOR + 1 >>> 0; - var b58 = new Uint8Array(size); - while (pbegin !== pend) { - var carry = source[pbegin]; - var i3 = 0; - for (var it1 = size - 1; (carry !== 0 || i3 < length) && it1 !== -1; it1--, i3++) { - carry += 256 * b58[it1] >>> 0; - b58[it1] = carry % BASE >>> 0; - carry = carry / BASE >>> 0; - } - if (carry !== 0) { - throw new Error("Non-zero carry"); - } - length = i3; - pbegin++; - } - var it2 = size - length; - while (it2 !== size && b58[it2] === 0) { - it2++; - } - var str = LEADER.repeat(zeroes); - for (; it2 < size; ++it2) { - str += ALPHABET.charAt(b58[it2]); - } - return str; - } - function decodeUnsafe(source) { - if (typeof source !== "string") { - throw new TypeError("Expected String"); - } - if (source.length === 0) { - return new Uint8Array(); - } - var psz = 0; - if (source[psz] === " ") { - return; - } - var zeroes = 0; - var length = 0; - while (source[psz] === LEADER) { - zeroes++; - psz++; - } - var size = (source.length - psz) * FACTOR + 1 >>> 0; - var b256 = new Uint8Array(size); - while (source[psz]) { - var carry = BASE_MAP[source.charCodeAt(psz)]; - if (carry === 255) { - return; - } - var i3 = 0; - for (var it3 = size - 1; (carry !== 0 || i3 < length) && it3 !== -1; it3--, i3++) { - carry += BASE * b256[it3] >>> 0; - b256[it3] = carry % 256 >>> 0; - carry = carry / 256 >>> 0; - } - if (carry !== 0) { - throw new Error("Non-zero carry"); - } - length = i3; - psz++; - } - if (source[psz] === " ") { - return; - } - var it4 = size - length; - while (it4 !== size && b256[it4] === 0) { - it4++; - } - var vch = new Uint8Array(zeroes + (size - it4)); - var j3 = zeroes; - while (it4 !== size) { - vch[j3++] = b256[it4++]; - } - return vch; - } - function decode2(string2) { - var buffer = decodeUnsafe(string2); - if (buffer) { - return buffer; - } - throw new Error(`Non-${name2} character`); - } - return { - encode: encode2, - decodeUnsafe, - decode: decode2 - }; -} -var src = base; -var _brrp__multiformats_scope_baseX = src; -const coerce$1 = (o2) => { - if (o2 instanceof Uint8Array && o2.constructor.name === "Uint8Array") - return o2; - if (o2 instanceof ArrayBuffer) - return new Uint8Array(o2); - if (ArrayBuffer.isView(o2)) { - return new Uint8Array(o2.buffer, o2.byteOffset, o2.byteLength); - } - throw new Error("Unknown type, must be binary type"); -}; -const fromString$1 = (str) => new TextEncoder().encode(str); -const toString$1 = (b3) => new TextDecoder().decode(b3); -class Encoder { - constructor(name2, prefix, baseEncode) { - this.name = name2; - this.prefix = prefix; - this.baseEncode = baseEncode; - } - encode(bytes) { - if (bytes instanceof Uint8Array) { - return `${this.prefix}${this.baseEncode(bytes)}`; - } else { - throw Error("Unknown type, must be binary type"); - } - } -} -class Decoder { - constructor(name2, prefix, baseDecode) { - this.name = name2; - this.prefix = prefix; - if (prefix.codePointAt(0) === void 0) { - throw new Error("Invalid prefix character"); - } - this.prefixCodePoint = prefix.codePointAt(0); - this.baseDecode = baseDecode; - } - decode(text) { - if (typeof text === "string") { - if (text.codePointAt(0) !== this.prefixCodePoint) { - throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); - } - return this.baseDecode(text.slice(this.prefix.length)); - } else { - throw Error("Can only multibase decode strings"); - } - } - or(decoder) { - return or$2(this, decoder); - } -} -class ComposedDecoder { - constructor(decoders) { - this.decoders = decoders; - } - or(decoder) { - return or$2(this, decoder); - } - decode(input) { - const prefix = input[0]; - const decoder = this.decoders[prefix]; - if (decoder) { - return decoder.decode(input); - } else { - throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); - } - } -} -const or$2 = (left, right) => new ComposedDecoder({ - ...left.decoders || { [left.prefix]: left }, - ...right.decoders || { [right.prefix]: right } -}); -class Codec { - constructor(name2, prefix, baseEncode, baseDecode) { - this.name = name2; - this.prefix = prefix; - this.baseEncode = baseEncode; - this.baseDecode = baseDecode; - this.encoder = new Encoder(name2, prefix, baseEncode); - this.decoder = new Decoder(name2, prefix, baseDecode); - } - encode(input) { - return this.encoder.encode(input); - } - decode(input) { - return this.decoder.decode(input); - } -} -const from = ({ name: name2, prefix, encode: encode2, decode: decode2 }) => new Codec(name2, prefix, encode2, decode2); -const baseX = ({ prefix, name: name2, alphabet: alphabet2 }) => { - const { encode: encode2, decode: decode2 } = _brrp__multiformats_scope_baseX(alphabet2, name2); - return from({ - prefix, - name: name2, - encode: encode2, - decode: (text) => coerce$1(decode2(text)) - }); -}; -const decode$2 = (string2, alphabet2, bitsPerChar, name2) => { - const codes = {}; - for (let i2 = 0; i2 < alphabet2.length; ++i2) { - codes[alphabet2[i2]] = i2; - } - let end = string2.length; - while (string2[end - 1] === "=") { - --end; - } - const out = new Uint8Array(end * bitsPerChar / 8 | 0); - let bits = 0; - let buffer = 0; - let written = 0; - for (let i2 = 0; i2 < end; ++i2) { - const value = codes[string2[i2]]; - if (value === void 0) { - throw new SyntaxError(`Non-${name2} character`); - } - buffer = buffer << bitsPerChar | value; - bits += bitsPerChar; - if (bits >= 8) { - bits -= 8; - out[written++] = 255 & buffer >> bits; - } - } - if (bits >= bitsPerChar || 255 & buffer << 8 - bits) { - throw new SyntaxError("Unexpected end of data"); - } - return out; -}; -const encode$1 = (data, alphabet2, bitsPerChar) => { - const pad = alphabet2[alphabet2.length - 1] === "="; - const mask = (1 << bitsPerChar) - 1; - let out = ""; - let bits = 0; - let buffer = 0; - for (let i2 = 0; i2 < data.length; ++i2) { - buffer = buffer << 8 | data[i2]; - bits += 8; - while (bits > bitsPerChar) { - bits -= bitsPerChar; - out += alphabet2[mask & buffer >> bits]; - } - } - if (bits) { - out += alphabet2[mask & buffer << bitsPerChar - bits]; - } - if (pad) { - while (out.length * bitsPerChar & 7) { - out += "="; - } - } - return out; -}; -const rfc4648 = ({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) => { - return from({ - prefix, - name: name2, - encode(input) { - return encode$1(input, alphabet2, bitsPerChar); - }, - decode(input) { - return decode$2(input, alphabet2, bitsPerChar, name2); - } - }); -}; -const identity = from({ - prefix: "\0", - name: "identity", - encode: (buf) => toString$1(buf), - decode: (str) => fromString$1(str) -}); -const identityBase = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - identity -}, Symbol.toStringTag, { value: "Module" })); -const base2 = rfc4648({ - prefix: "0", - name: "base2", - alphabet: "01", - bitsPerChar: 1 -}); -const base2$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base2 -}, Symbol.toStringTag, { value: "Module" })); -const base8 = rfc4648({ - prefix: "7", - name: "base8", - alphabet: "01234567", - bitsPerChar: 3 -}); -const base8$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base8 -}, Symbol.toStringTag, { value: "Module" })); -const base10 = baseX({ - prefix: "9", - name: "base10", - alphabet: "0123456789" -}); -const base10$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base10 -}, Symbol.toStringTag, { value: "Module" })); -const base16 = rfc4648({ - prefix: "f", - name: "base16", - alphabet: "0123456789abcdef", - bitsPerChar: 4 -}); -const base16upper = rfc4648({ - prefix: "F", - name: "base16upper", - alphabet: "0123456789ABCDEF", - bitsPerChar: 4 -}); -const base16$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base16, - base16upper -}, Symbol.toStringTag, { value: "Module" })); -const base32 = rfc4648({ - prefix: "b", - name: "base32", - alphabet: "abcdefghijklmnopqrstuvwxyz234567", - bitsPerChar: 5 -}); -const base32upper = rfc4648({ - prefix: "B", - name: "base32upper", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", - bitsPerChar: 5 -}); -const base32pad = rfc4648({ - prefix: "c", - name: "base32pad", - alphabet: "abcdefghijklmnopqrstuvwxyz234567=", - bitsPerChar: 5 -}); -const base32padupper = rfc4648({ - prefix: "C", - name: "base32padupper", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", - bitsPerChar: 5 -}); -const base32hex = rfc4648({ - prefix: "v", - name: "base32hex", - alphabet: "0123456789abcdefghijklmnopqrstuv", - bitsPerChar: 5 -}); -const base32hexupper = rfc4648({ - prefix: "V", - name: "base32hexupper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", - bitsPerChar: 5 -}); -const base32hexpad = rfc4648({ - prefix: "t", - name: "base32hexpad", - alphabet: "0123456789abcdefghijklmnopqrstuv=", - bitsPerChar: 5 -}); -const base32hexpadupper = rfc4648({ - prefix: "T", - name: "base32hexpadupper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", - bitsPerChar: 5 -}); -const base32z = rfc4648({ - prefix: "h", - name: "base32z", - alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", - bitsPerChar: 5 -}); -const base32$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base32, - base32hex, - base32hexpad, - base32hexpadupper, - base32hexupper, - base32pad, - base32padupper, - base32upper, - base32z -}, Symbol.toStringTag, { value: "Module" })); -const base36 = baseX({ - prefix: "k", - name: "base36", - alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" -}); -const base36upper = baseX({ - prefix: "K", - name: "base36upper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" -}); -const base36$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base36, - base36upper -}, Symbol.toStringTag, { value: "Module" })); -const base58btc = baseX({ - name: "base58btc", - prefix: "z", - alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" -}); -const base58flickr = baseX({ - name: "base58flickr", - prefix: "Z", - alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" -}); -const base58 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base58btc, - base58flickr -}, Symbol.toStringTag, { value: "Module" })); -const base64 = rfc4648({ - prefix: "m", - name: "base64", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", - bitsPerChar: 6 -}); -const base64pad = rfc4648({ - prefix: "M", - name: "base64pad", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - bitsPerChar: 6 -}); -const base64url = rfc4648({ - prefix: "u", - name: "base64url", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", - bitsPerChar: 6 -}); -const base64urlpad = rfc4648({ - prefix: "U", - name: "base64urlpad", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", - bitsPerChar: 6 -}); -const base64$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base64, - base64pad, - base64url, - base64urlpad -}, Symbol.toStringTag, { value: "Module" })); -const alphabet = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"); -const alphabetBytesToChars = alphabet.reduce((p3, c2, i2) => { - p3[i2] = c2; - return p3; -}, []); -const alphabetCharsToBytes = alphabet.reduce((p3, c2, i2) => { - p3[c2.codePointAt(0)] = i2; - return p3; -}, []); -function encode(data) { - return data.reduce((p3, c2) => { - p3 += alphabetBytesToChars[c2]; - return p3; - }, ""); -} -function decode$1(str) { - const byts = []; - for (const char of str) { - const byt = alphabetCharsToBytes[char.codePointAt(0)]; - if (byt === void 0) { - throw new Error(`Non-base256emoji character: ${char}`); - } - byts.push(byt); - } - return new Uint8Array(byts); -} -const base256emoji = from({ - prefix: "🚀", - name: "base256emoji", - encode, - decode: decode$1 -}); -const base256emoji$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base256emoji -}, Symbol.toStringTag, { value: "Module" })); -new TextEncoder(); -new TextDecoder(); -const bases = { - ...identityBase, - ...base2$1, - ...base8$1, - ...base10$1, - ...base16$1, - ...base32$1, - ...base36$1, - ...base58, - ...base64$1, - ...base256emoji$1 -}; -function createCodec(name2, prefix, encode2, decode2) { - return { - name: name2, - prefix, - encoder: { - name: name2, - prefix, - encode: encode2 - }, - decoder: { decode: decode2 } - }; -} -const string = createCodec("utf8", "u", (buf) => { - const decoder = new TextDecoder("utf8"); - return "u" + decoder.decode(buf); -}, (str) => { - const encoder = new TextEncoder(); - return encoder.encode(str.substring(1)); -}); -const ascii = createCodec("ascii", "a", (buf) => { - let string2 = "a"; - for (let i2 = 0; i2 < buf.length; i2++) { - string2 += String.fromCharCode(buf[i2]); - } - return string2; -}, (str) => { - str = str.substring(1); - const buf = allocUnsafe(str.length); - for (let i2 = 0; i2 < str.length; i2++) { - buf[i2] = str.charCodeAt(i2); - } - return buf; -}); -const BASES = { - utf8: string, - "utf-8": string, - hex: bases.base16, - latin1: ascii, - ascii, - binary: ascii, - ...bases -}; -function toString(array, encoding = "utf8") { - const base3 = BASES[encoding]; - if (!base3) { - throw new Error(`Unsupported encoding "${encoding}"`); - } - if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { - return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString("utf8"); - } - return base3.encoder.encode(array).substring(1); -} -function fromString(string2, encoding = "utf8") { - const base3 = BASES[encoding]; - if (!base3) { - throw new Error(`Unsupported encoding "${encoding}"`); - } - if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { - return asUint8Array(globalThis.Buffer.from(string2, "utf-8")); - } - return base3.decoder.decode(`${base3.prefix}${string2}`); -} -function encodeJSON(val) { - return toString(fromString(safeJsonStringify(val), JSON_ENCODING), JWT_ENCODING); -} -function encodeIss(publicKey) { - const header = fromString(MULTICODEC_ED25519_HEADER, MULTICODEC_ED25519_ENCODING); - const multicodec = MULTICODEC_ED25519_BASE + toString(concat([header, publicKey]), MULTICODEC_ED25519_ENCODING); - return [DID_PREFIX, DID_METHOD, multicodec].join(DID_DELIMITER); -} -function encodeSig(bytes) { - return toString(bytes, JWT_ENCODING); -} -function encodeData(params) { - return fromString([encodeJSON(params.header), encodeJSON(params.payload)].join(JWT_DELIMITER), DATA_ENCODING); -} -function encodeJWT(params) { - return [ - encodeJSON(params.header), - encodeJSON(params.payload), - encodeSig(params.signature) - ].join(JWT_DELIMITER); -} -function generateKeyPair(seed = random.randomBytes(KEY_PAIR_SEED_LENGTH)) { - return ed25519.generateKeyPairFromSeed(seed); -} -async function signJWT(sub, aud, ttl, keyPair, iat = cjs$4.fromMiliseconds(Date.now())) { - const header = { alg: JWT_IRIDIUM_ALG, typ: JWT_IRIDIUM_TYP }; - const iss = encodeIss(keyPair.publicKey); - const exp = iat + ttl; - const payload = { iss, sub, aud, iat, exp }; - const data = encodeData({ header, payload }); - const signature = ed25519.sign(keyPair.secretKey, data); - return encodeJWT({ header, payload, signature }); -} -var chacha20poly1305 = {}; -var chacha = {}; -Object.defineProperty(chacha, "__esModule", { value: true }); -var binary_1 = binary; -var wipe_1$2 = wipe$1; -var ROUNDS = 20; -function core(out, input, key) { - var j0 = 1634760805; - var j1 = 857760878; - var j2 = 2036477234; - var j3 = 1797285236; - var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; - var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; - var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; - var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; - var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; - var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; - var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; - var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; - var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; - var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; - var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; - var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; - var x0 = j0; - var x1 = j1; - var x2 = j2; - var x3 = j3; - var x4 = j4; - var x5 = j5; - var x6 = j6; - var x7 = j7; - var x8 = j8; - var x9 = j9; - var x10 = j10; - var x11 = j11; - var x12 = j12; - var x13 = j13; - var x14 = j14; - var x15 = j15; - for (var i2 = 0; i2 < ROUNDS; i2 += 2) { - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 16 | x12 << 16; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 12 | x4 << 12; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 16 | x13 << 16; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 12 | x5 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 16 | x14 << 16; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 12 | x6 << 12; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 16 | x15 << 16; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 12 | x7 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 8 | x14 << 8; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 7 | x6 << 7; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 8 | x15 << 8; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 7 | x7 << 7; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 8 | x13 << 8; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 7 | x5 << 7; - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 8 | x12 << 8; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 7 | x4 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 16 | x15 << 16; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 12 | x5 << 12; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 16 | x12 << 16; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 12 | x6 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 16 | x13 << 16; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 12 | x7 << 12; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 16 | x14 << 16; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 12 | x4 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 8 | x13 << 8; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 7 | x7 << 7; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 8 | x14 << 8; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 7 | x4 << 7; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 8 | x12 << 8; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 7 | x6 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 8 | x15 << 8; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 7 | x5 << 7; - } - binary_1.writeUint32LE(x0 + j0 | 0, out, 0); - binary_1.writeUint32LE(x1 + j1 | 0, out, 4); - binary_1.writeUint32LE(x2 + j2 | 0, out, 8); - binary_1.writeUint32LE(x3 + j3 | 0, out, 12); - binary_1.writeUint32LE(x4 + j4 | 0, out, 16); - binary_1.writeUint32LE(x5 + j5 | 0, out, 20); - binary_1.writeUint32LE(x6 + j6 | 0, out, 24); - binary_1.writeUint32LE(x7 + j7 | 0, out, 28); - binary_1.writeUint32LE(x8 + j8 | 0, out, 32); - binary_1.writeUint32LE(x9 + j9 | 0, out, 36); - binary_1.writeUint32LE(x10 + j10 | 0, out, 40); - binary_1.writeUint32LE(x11 + j11 | 0, out, 44); - binary_1.writeUint32LE(x12 + j12 | 0, out, 48); - binary_1.writeUint32LE(x13 + j13 | 0, out, 52); - binary_1.writeUint32LE(x14 + j14 | 0, out, 56); - binary_1.writeUint32LE(x15 + j15 | 0, out, 60); -} -function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - if (key.length !== 32) { - throw new Error("ChaCha: key size must be 32 bytes"); - } - if (dst.length < src2.length) { - throw new Error("ChaCha: destination is shorter than source"); - } - var nc; - var counterLength; - if (nonceInplaceCounterLength === 0) { - if (nonce.length !== 8 && nonce.length !== 12) { - throw new Error("ChaCha nonce must be 8 or 12 bytes"); - } - nc = new Uint8Array(16); - counterLength = nc.length - nonce.length; - nc.set(nonce, counterLength); - } else { - if (nonce.length !== 16) { - throw new Error("ChaCha nonce with counter must be 16 bytes"); - } - nc = nonce; - counterLength = nonceInplaceCounterLength; - } - var block = new Uint8Array(64); - for (var i2 = 0; i2 < src2.length; i2 += 64) { - core(block, nc, key); - for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { - dst[j2] = src2[j2] ^ block[j2 - i2]; - } - incrementCounter(nc, 0, counterLength); - } - wipe_1$2.wipe(block); - if (nonceInplaceCounterLength === 0) { - wipe_1$2.wipe(nc); - } - return dst; -} -chacha.streamXOR = streamXOR; -function stream(key, nonce, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - wipe_1$2.wipe(dst); - return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); -} -chacha.stream = stream; -function incrementCounter(counter, pos, len) { - var carry = 1; - while (len--) { - carry = carry + (counter[pos] & 255) | 0; - counter[pos] = carry & 255; - carry >>>= 8; - pos++; - } - if (carry > 0) { - throw new Error("ChaCha: counter overflow"); - } -} -var poly1305 = {}; -var constantTime = {}; -Object.defineProperty(constantTime, "__esModule", { value: true }); -function select(subject, resultIfOne, resultIfZero) { - return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; -} -constantTime.select = select; -function lessOrEqual(a3, b3) { - return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; -} -constantTime.lessOrEqual = lessOrEqual; -function compare(a3, b3) { - if (a3.length !== b3.length) { - return 0; - } - var result = 0; - for (var i2 = 0; i2 < a3.length; i2++) { - result |= a3[i2] ^ b3[i2]; - } - return 1 & result - 1 >>> 8; -} -constantTime.compare = compare; -function equal(a3, b3) { - if (a3.length === 0 || b3.length === 0) { - return false; - } - return compare(a3, b3) !== 0; -} -constantTime.equal = equal; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var constant_time_12 = constantTime; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 16; - var Poly1305 = ( - /** @class */ - function() { - function Poly13052(key) { - this.digestLength = exports2.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 = false; - var t0 = key[0] | key[1] << 8; - this._r[0] = t0 & 8191; - var t1 = key[2] | key[3] << 8; - this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; - var t2 = key[4] | key[5] << 8; - this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; - var t3 = key[6] | key[7] << 8; - this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; - var t4 = key[8] | key[9] << 8; - this._r[4] = (t3 >>> 4 | t4 << 12) & 255; - this._r[5] = t4 >>> 1 & 8190; - var t5 = key[10] | key[11] << 8; - this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; - var t6 = key[12] | key[13] << 8; - this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; - var t7 = key[14] | key[15] << 8; - this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; - this._r[9] = t7 >>> 5 & 127; - this._pad[0] = key[16] | key[17] << 8; - this._pad[1] = key[18] | key[19] << 8; - this._pad[2] = key[20] | key[21] << 8; - this._pad[3] = key[22] | key[23] << 8; - this._pad[4] = key[24] | key[25] << 8; - this._pad[5] = key[26] | key[27] << 8; - this._pad[6] = key[28] | key[29] << 8; - this._pad[7] = key[30] | key[31] << 8; - } - Poly13052.prototype._blocks = function(m2, mpos, bytes) { - var hibit = this._fin ? 0 : 1 << 11; - var h0 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; - var r0 = this._r[0], r1 = this._r[1], r2 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; - while (bytes >= 16) { - var t0 = m2[mpos + 0] | m2[mpos + 1] << 8; - h0 += t0 & 8191; - var t1 = m2[mpos + 2] | m2[mpos + 3] << 8; - h1 += (t0 >>> 13 | t1 << 3) & 8191; - var t2 = m2[mpos + 4] | m2[mpos + 5] << 8; - h22 += (t1 >>> 10 | t2 << 6) & 8191; - var t3 = m2[mpos + 6] | m2[mpos + 7] << 8; - h32 += (t2 >>> 7 | t3 << 9) & 8191; - var t4 = m2[mpos + 8] | m2[mpos + 9] << 8; - h4 += (t3 >>> 4 | t4 << 12) & 8191; - h5 += t4 >>> 1 & 8191; - var t5 = m2[mpos + 10] | m2[mpos + 11] << 8; - h6 += (t4 >>> 14 | t5 << 2) & 8191; - var t6 = m2[mpos + 12] | m2[mpos + 13] << 8; - h7 += (t5 >>> 11 | t6 << 5) & 8191; - var t7 = m2[mpos + 14] | m2[mpos + 15] << 8; - h8 += (t6 >>> 8 | t7 << 8) & 8191; - h9 += t7 >>> 5 | hibit; - var c2 = 0; - var d0 = c2; - d0 += h0 * r0; - d0 += h1 * (5 * r9); - d0 += h22 * (5 * r8); - d0 += h32 * (5 * r7); - d0 += h4 * (5 * r6); - c2 = d0 >>> 13; - d0 &= 8191; - d0 += h5 * (5 * r5); - d0 += h6 * (5 * r4); - d0 += h7 * (5 * r3); - d0 += h8 * (5 * r2); - d0 += h9 * (5 * r1); - c2 += d0 >>> 13; - d0 &= 8191; - var d1 = c2; - d1 += h0 * r1; - d1 += h1 * r0; - d1 += h22 * (5 * r9); - d1 += h32 * (5 * r8); - d1 += h4 * (5 * r7); - c2 = d1 >>> 13; - d1 &= 8191; - d1 += h5 * (5 * r6); - d1 += h6 * (5 * r5); - d1 += h7 * (5 * r4); - d1 += h8 * (5 * r3); - d1 += h9 * (5 * r2); - c2 += d1 >>> 13; - d1 &= 8191; - var d22 = c2; - d22 += h0 * r2; - d22 += h1 * r1; - d22 += h22 * r0; - d22 += h32 * (5 * r9); - d22 += h4 * (5 * r8); - c2 = d22 >>> 13; - d22 &= 8191; - d22 += h5 * (5 * r7); - d22 += h6 * (5 * r6); - d22 += h7 * (5 * r5); - d22 += h8 * (5 * r4); - d22 += h9 * (5 * r3); - c2 += d22 >>> 13; - d22 &= 8191; - var d3 = c2; - d3 += h0 * r3; - d3 += h1 * r2; - d3 += h22 * r1; - d3 += h32 * r0; - d3 += h4 * (5 * r9); - c2 = d3 >>> 13; - d3 &= 8191; - d3 += h5 * (5 * r8); - d3 += h6 * (5 * r7); - d3 += h7 * (5 * r6); - d3 += h8 * (5 * r5); - d3 += h9 * (5 * r4); - c2 += d3 >>> 13; - d3 &= 8191; - var d4 = c2; - d4 += h0 * r4; - d4 += h1 * r3; - d4 += h22 * r2; - d4 += h32 * r1; - d4 += h4 * r0; - c2 = d4 >>> 13; - d4 &= 8191; - d4 += h5 * (5 * r9); - d4 += h6 * (5 * r8); - d4 += h7 * (5 * r7); - d4 += h8 * (5 * r6); - d4 += h9 * (5 * r5); - c2 += d4 >>> 13; - d4 &= 8191; - var d5 = c2; - d5 += h0 * r5; - d5 += h1 * r4; - d5 += h22 * r3; - d5 += h32 * r2; - d5 += h4 * r1; - c2 = d5 >>> 13; - d5 &= 8191; - d5 += h5 * r0; - d5 += h6 * (5 * r9); - d5 += h7 * (5 * r8); - d5 += h8 * (5 * r7); - d5 += h9 * (5 * r6); - c2 += d5 >>> 13; - d5 &= 8191; - var d6 = c2; - d6 += h0 * r6; - d6 += h1 * r5; - d6 += h22 * r4; - d6 += h32 * r3; - d6 += h4 * r2; - c2 = d6 >>> 13; - d6 &= 8191; - d6 += h5 * r1; - d6 += h6 * r0; - d6 += h7 * (5 * r9); - d6 += h8 * (5 * r8); - d6 += h9 * (5 * r7); - c2 += d6 >>> 13; - d6 &= 8191; - var d7 = c2; - d7 += h0 * r7; - d7 += h1 * r6; - d7 += h22 * r5; - d7 += h32 * r4; - d7 += h4 * r3; - c2 = d7 >>> 13; - d7 &= 8191; - d7 += h5 * r2; - d7 += h6 * r1; - d7 += h7 * r0; - d7 += h8 * (5 * r9); - d7 += h9 * (5 * r8); - c2 += d7 >>> 13; - d7 &= 8191; - var d8 = c2; - d8 += h0 * r8; - d8 += h1 * r7; - d8 += h22 * r6; - d8 += h32 * r5; - d8 += h4 * r4; - c2 = d8 >>> 13; - d8 &= 8191; - d8 += h5 * r3; - d8 += h6 * r2; - d8 += h7 * r1; - d8 += h8 * r0; - d8 += h9 * (5 * r9); - c2 += d8 >>> 13; - d8 &= 8191; - var d9 = c2; - d9 += h0 * r9; - d9 += h1 * r8; - d9 += h22 * r7; - d9 += h32 * r6; - d9 += h4 * r5; - c2 = d9 >>> 13; - d9 &= 8191; - d9 += h5 * r4; - d9 += h6 * r3; - d9 += h7 * r2; - d9 += h8 * r1; - d9 += h9 * r0; - c2 += d9 >>> 13; - d9 &= 8191; - c2 = (c2 << 2) + c2 | 0; - c2 = c2 + d0 | 0; - d0 = c2 & 8191; - c2 = c2 >>> 13; - d1 += c2; - h0 = d0; - h1 = d1; - h22 = d22; - h32 = d3; - h4 = d4; - h5 = d5; - h6 = d6; - h7 = d7; - h8 = d8; - h9 = d9; - mpos += 16; - bytes -= 16; - } - this._h[0] = h0; - this._h[1] = h1; - this._h[2] = h22; - this._h[3] = h32; - this._h[4] = h4; - this._h[5] = h5; - this._h[6] = h6; - this._h[7] = h7; - this._h[8] = h8; - this._h[9] = h9; - }; - Poly13052.prototype.finish = function(mac, macpos) { - if (macpos === void 0) { - macpos = 0; - } - var g3 = new Uint16Array(10); - var c2; - var mask; - var f2; - var i2; - if (this._leftover) { - i2 = this._leftover; - this._buffer[i2++] = 1; - for (; i2 < 16; i2++) { - this._buffer[i2] = 0; - } - this._fin = 1; - this._blocks(this._buffer, 0, 16); - } - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - for (i2 = 2; i2 < 10; i2++) { - this._h[i2] += c2; - c2 = this._h[i2] >>> 13; - this._h[i2] &= 8191; - } - this._h[0] += c2 * 5; - c2 = this._h[0] >>> 13; - this._h[0] &= 8191; - this._h[1] += c2; - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - this._h[2] += c2; - g3[0] = this._h[0] + 5; - c2 = g3[0] >>> 13; - g3[0] &= 8191; - for (i2 = 1; i2 < 10; i2++) { - g3[i2] = this._h[i2] + c2; - c2 = g3[i2] >>> 13; - g3[i2] &= 8191; - } - g3[9] -= 1 << 13; - mask = (c2 ^ 1) - 1; - for (i2 = 0; i2 < 10; i2++) { - g3[i2] &= mask; - } - mask = ~mask; - for (i2 = 0; i2 < 10; i2++) { - this._h[i2] = this._h[i2] & mask | g3[i2]; - } - 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; - f2 = this._h[0] + this._pad[0]; - this._h[0] = f2 & 65535; - for (i2 = 1; i2 < 8; i2++) { - f2 = (this._h[i2] + this._pad[i2] | 0) + (f2 >>> 16) | 0; - this._h[i2] = f2 & 65535; - } - mac[macpos + 0] = this._h[0] >>> 0; - mac[macpos + 1] = this._h[0] >>> 8; - mac[macpos + 2] = this._h[1] >>> 0; - mac[macpos + 3] = this._h[1] >>> 8; - mac[macpos + 4] = this._h[2] >>> 0; - mac[macpos + 5] = this._h[2] >>> 8; - mac[macpos + 6] = this._h[3] >>> 0; - mac[macpos + 7] = this._h[3] >>> 8; - mac[macpos + 8] = this._h[4] >>> 0; - mac[macpos + 9] = this._h[4] >>> 8; - mac[macpos + 10] = this._h[5] >>> 0; - mac[macpos + 11] = this._h[5] >>> 8; - mac[macpos + 12] = this._h[6] >>> 0; - mac[macpos + 13] = this._h[6] >>> 8; - mac[macpos + 14] = this._h[7] >>> 0; - mac[macpos + 15] = this._h[7] >>> 8; - this._finished = true; - return this; - }; - Poly13052.prototype.update = function(m2) { - var mpos = 0; - var bytes = m2.length; - var want; - if (this._leftover) { - want = 16 - this._leftover; - if (want > bytes) { - want = bytes; - } - for (var i2 = 0; i2 < want; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; - } - bytes -= want; - mpos += want; - this._leftover += want; - if (this._leftover < 16) { - return this; - } - this._blocks(this._buffer, 0, 16); - this._leftover = 0; - } - if (bytes >= 16) { - want = bytes - bytes % 16; - this._blocks(m2, mpos, want); - mpos += want; - bytes -= want; - } - if (bytes) { - for (var i2 = 0; i2 < bytes; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; - } - this._leftover += bytes; - } - return this; - }; - Poly13052.prototype.digest = function() { - if (this._finished) { - throw new Error("Poly1305 was finished"); - } - var mac = new Uint8Array(16); - this.finish(mac); - return mac; - }; - Poly13052.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._r); - wipe_12.wipe(this._h); - wipe_12.wipe(this._pad); - this._leftover = 0; - this._fin = 0; - this._finished = true; - return this; - }; - return Poly13052; - }() - ); - exports2.Poly1305 = Poly1305; - function oneTimeAuth(key, data) { - var h4 = new Poly1305(key); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; - } - exports2.oneTimeAuth = oneTimeAuth; - function equal2(a3, b3) { - if (a3.length !== exports2.DIGEST_LENGTH || b3.length !== exports2.DIGEST_LENGTH) { - return false; - } - return constant_time_12.equal(a3, b3); - } - exports2.equal = equal2; -})(poly1305); -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var chacha_1 = chacha; - var poly1305_1 = poly1305; - var wipe_12 = wipe$1; - var binary_12 = binary; - var constant_time_12 = constantTime; - exports2.KEY_LENGTH = 32; - exports2.NONCE_LENGTH = 12; - exports2.TAG_LENGTH = 16; - var ZEROS = new Uint8Array(16); - var ChaCha20Poly1305 = ( - /** @class */ - function() { - function ChaCha20Poly13052(key) { - this.nonceLength = exports2.NONCE_LENGTH; - this.tagLength = exports2.TAG_LENGTH; - if (key.length !== exports2.KEY_LENGTH) { - throw new Error("ChaCha20Poly1305 needs 32-byte key"); - } - this._key = new Uint8Array(key); - } - ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var resultLength = plaintext.length + this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); - } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, plaintext, result, 4); - this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - if (sealed.length < this.tagLength) { - return null; - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var calculatedTag = new Uint8Array(this.tagLength); - this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); - if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { - return null; - } - var resultLength = sealed.length - this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); - } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.clean = function() { - wipe_12.wipe(this._key); - return this; - }; - ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { - var h4 = new poly1305_1.Poly1305(authKey); - if (associatedData) { - h4.update(associatedData); - if (associatedData.length % 16 > 0) { - h4.update(ZEROS.subarray(associatedData.length % 16)); - } - } - h4.update(ciphertext); - if (ciphertext.length % 16 > 0) { - h4.update(ZEROS.subarray(ciphertext.length % 16)); - } - var length = new Uint8Array(8); - if (associatedData) { - binary_12.writeUint64LE(associatedData.length, length); - } - h4.update(length); - binary_12.writeUint64LE(ciphertext.length, length); - h4.update(length); - var tag = h4.digest(); - for (var i2 = 0; i2 < tag.length; i2++) { - tagOut[i2] = tag[i2]; - } - h4.clean(); - wipe_12.wipe(tag); - wipe_12.wipe(length); - }; - return ChaCha20Poly13052; - }() - ); - exports2.ChaCha20Poly1305 = ChaCha20Poly1305; -})(chacha20poly1305); -var hkdf = {}; -var hmac$1 = {}; -var hash = {}; -Object.defineProperty(hash, "__esModule", { value: true }); -function isSerializableHash(h4) { - return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; -} -hash.isSerializableHash = isSerializableHash; -Object.defineProperty(hmac$1, "__esModule", { value: true }); -var hash_1 = hash; -var constant_time_1 = constantTime; -var wipe_1$1 = wipe$1; -var HMAC = ( - /** @class */ - function() { - function HMAC2(hash2, key) { - this._finished = false; - this._inner = new hash2(); - this._outer = new hash2(); - this.blockSize = this._outer.blockSize; - this.digestLength = this._outer.digestLength; - var pad = new Uint8Array(this.blockSize); - if (key.length > this.blockSize) { - this._inner.update(key).finish(pad).clean(); - } else { - pad.set(key); - } - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54; - } - this._inner.update(pad); - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54 ^ 92; - } - this._outer.update(pad); - if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { - this._innerKeyedState = this._inner.saveState(); - this._outerKeyedState = this._outer.saveState(); - } - wipe_1$1.wipe(pad); - } - HMAC2.prototype.reset = function() { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); - } - this._inner.restoreState(this._innerKeyedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.clean = function() { - if (hash_1.isSerializableHash(this._inner)) { - this._inner.cleanSavedState(this._innerKeyedState); - } - if (hash_1.isSerializableHash(this._outer)) { - this._outer.cleanSavedState(this._outerKeyedState); - } - this._inner.clean(); - this._outer.clean(); - }; - HMAC2.prototype.update = function(data) { - this._inner.update(data); - return this; - }; - HMAC2.prototype.finish = function(out) { - if (this._finished) { - this._outer.finish(out); - return this; - } - this._inner.finish(out); - this._outer.update(out.subarray(0, this.digestLength)).finish(out); - this._finished = true; - return this; - }; - HMAC2.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - HMAC2.prototype.saveState = function() { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't saveState() because hash doesn't implement it"); - } - return this._inner.saveState(); - }; - HMAC2.prototype.restoreState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't restoreState() because hash doesn't implement it"); - } - this._inner.restoreState(savedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.cleanSavedState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); - } - this._inner.cleanSavedState(savedState); - }; - return HMAC2; - }() -); -hmac$1.HMAC = HMAC; -function hmac(hash2, key, data) { - var h4 = new HMAC(hash2, key); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; -} -hmac$1.hmac = hmac; -hmac$1.equal = constant_time_1.equal; -Object.defineProperty(hkdf, "__esModule", { value: true }); -var hmac_1 = hmac$1; -var wipe_1 = wipe$1; -var HKDF = ( - /** @class */ - function() { - function HKDF2(hash2, key, salt, info) { - if (salt === void 0) { - salt = new Uint8Array(0); - } - this._counter = new Uint8Array(1); - this._hash = hash2; - this._info = info; - var okm = hmac_1.hmac(this._hash, salt, key); - this._hmac = new hmac_1.HMAC(hash2, okm); - this._buffer = new Uint8Array(this._hmac.digestLength); - this._bufpos = this._buffer.length; - } - HKDF2.prototype._fillBuffer = function() { - this._counter[0]++; - var ctr = this._counter[0]; - if (ctr === 0) { - throw new Error("hkdf: cannot expand more"); - } - this._hmac.reset(); - if (ctr > 1) { - this._hmac.update(this._buffer); - } - if (this._info) { - this._hmac.update(this._info); - } - this._hmac.update(this._counter); - this._hmac.finish(this._buffer); - this._bufpos = 0; - }; - HKDF2.prototype.expand = function(length) { - var out = new Uint8Array(length); - for (var i2 = 0; i2 < out.length; i2++) { - if (this._bufpos === this._buffer.length) { - this._fillBuffer(); - } - out[i2] = this._buffer[this._bufpos++]; - } - return out; - }; - HKDF2.prototype.clean = function() { - this._hmac.clean(); - wipe_1.wipe(this._buffer); - wipe_1.wipe(this._counter); - this._bufpos = 0; - }; - return HKDF2; - }() -); -var HKDF_1 = hkdf.HKDF = HKDF; -var sha256 = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var binary_12 = binary; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 32; - exports2.BLOCK_SIZE = 64; - var SHA256 = ( - /** @class */ - function() { - function SHA2562() { - this.digestLength = exports2.DIGEST_LENGTH; - this.blockSize = exports2.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 = false; - this.reset(); - } - SHA2562.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; - }; - SHA2562.prototype.reset = function() { - this._initState(); - this._bufferLength = 0; - this._bytesHashed = 0; - this._finished = false; - return this; - }; - SHA2562.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._temp); - this.reset(); - }; - SHA2562.prototype.update = function(data, dataLength) { - if (dataLength === void 0) { - dataLength = data.length; - } - if (this._finished) { - throw new Error("SHA256: can't update because hash was finished."); - } - var dataPos = 0; - this._bytesHashed += dataLength; - if (this._bufferLength > 0) { - while (this._bufferLength < this.blockSize && dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - if (this._bufferLength === this.blockSize) { - hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); - this._bufferLength = 0; - } - } - if (dataLength >= this.blockSize) { - dataPos = hashBlocks(this._temp, this._state, data, dataPos, dataLength); - dataLength %= this.blockSize; - } - while (dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - return this; - }; - SHA2562.prototype.finish = function(out) { - if (!this._finished) { - var bytesHashed = this._bytesHashed; - var left = this._bufferLength; - var bitLenHi = bytesHashed / 536870912 | 0; - var bitLenLo = bytesHashed << 3; - var padLength = bytesHashed % 64 < 56 ? 64 : 128; - this._buffer[left] = 128; - for (var i2 = left + 1; i2 < padLength - 8; i2++) { - this._buffer[i2] = 0; - } - binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); - binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); - hashBlocks(this._temp, this._state, this._buffer, 0, padLength); - this._finished = true; - } - for (var i2 = 0; i2 < this.digestLength / 4; i2++) { - binary_12.writeUint32BE(this._state[i2], out, i2 * 4); - } - return this; - }; - SHA2562.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - SHA2562.prototype.saveState = function() { - if (this._finished) { - throw new Error("SHA256: cannot save finished state"); - } - return { - state: new Int32Array(this._state), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed - }; - }; - SHA2562.prototype.restoreState = function(savedState) { - this._state.set(savedState.state); - this._bufferLength = savedState.bufferLength; - if (savedState.buffer) { - this._buffer.set(savedState.buffer); - } - this._bytesHashed = savedState.bytesHashed; - this._finished = false; - return this; - }; - SHA2562.prototype.cleanSavedState = function(savedState) { - wipe_12.wipe(savedState.state); - if (savedState.buffer) { - wipe_12.wipe(savedState.buffer); - } - savedState.bufferLength = 0; - savedState.bytesHashed = 0; - }; - return SHA2562; - }() - ); - exports2.SHA256 = SHA256; - var K2 = 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 hashBlocks(w3, v3, p3, pos, len) { - while (len >= 64) { - var a3 = v3[0]; - var b3 = v3[1]; - var c2 = v3[2]; - var d3 = v3[3]; - var e = v3[4]; - var f2 = v3[5]; - var g3 = v3[6]; - var h4 = v3[7]; - for (var i2 = 0; i2 < 16; i2++) { - var j2 = pos + i2 * 4; - w3[i2] = binary_12.readUint32BE(p3, j2); - } - for (var i2 = 16; i2 < 64; i2++) { - var u3 = w3[i2 - 2]; - var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; - u3 = w3[i2 - 15]; - var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; - w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); - } - for (var i2 = 0; i2 < 64; i2++) { - var t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f2 ^ ~e & g3) | 0) + (h4 + (K2[i2] + w3[i2] | 0) | 0) | 0; - var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; - h4 = g3; - g3 = f2; - f2 = e; - e = d3 + t1 | 0; - d3 = c2; - c2 = b3; - b3 = a3; - a3 = t1 + t2 | 0; - } - v3[0] += a3; - v3[1] += b3; - v3[2] += c2; - v3[3] += d3; - v3[4] += e; - v3[5] += f2; - v3[6] += g3; - v3[7] += h4; - pos += 64; - len -= 64; - } - return pos; - } - function hash2(data) { - var h4 = new SHA256(); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; - } - exports2.hash = hash2; -})(sha256); -var x25519 = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.sharedKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.scalarMultBase = exports2.scalarMult = exports2.SHARED_KEY_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = void 0; - const random_1 = random; - const wipe_12 = wipe$1; - exports2.PUBLIC_KEY_LENGTH = 32; - exports2.SECRET_KEY_LENGTH = 32; - exports2.SHARED_KEY_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); - if (init) { - for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; - } - } - return r2; - } - const _9 = new Uint8Array(32); - _9[0] = 9; - const _121665 = gf([56129, 1]); - function car25519(o2) { - let c2 = 1; - for (let i2 = 0; i2 < 16; i2++) { - let v3 = o2[i2] + c2 + 65535; - c2 = Math.floor(v3 / 65536); - o2[i2] = v3 - c2 * 65536; - } - o2[0] += c2 - 1 + 37 * (c2 - 1); - } - function sel25519(p3, q2, b3) { - const c2 = ~(b3 - 1); - for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; - q2[i2] ^= t2; - } - } - function pack25519(o2, n3) { - const m2 = gf(); - const t2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; - } - car25519(t2); - car25519(t2); - car25519(t2); - for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; - for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; - } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); - } - for (let i2 = 0; i2 < 16; i2++) { - o2[2 * i2] = t2[i2] & 255; - o2[2 * i2 + 1] = t2[i2] >> 8; - } - } - function unpack25519(o2, n3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); - } - o2[15] &= 32767; - } - function add(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] + b3[i2]; - } - } - function sub(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] - b3[i2]; - } - } - function mul(o2, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; - v3 = a3[0]; - t0 += v3 * b0; - t1 += v3 * b1; - t2 += v3 * b22; - t3 += v3 * b32; - t4 += v3 * b4; - t5 += v3 * b5; - t6 += v3 * b6; - t7 += v3 * b7; - t8 += v3 * b8; - t9 += v3 * b9; - t10 += v3 * b10; - t11 += v3 * b11; - t12 += v3 * b12; - t13 += v3 * b13; - t14 += v3 * b14; - t15 += v3 * b15; - v3 = a3[1]; - t1 += v3 * b0; - t2 += v3 * b1; - t3 += v3 * b22; - t4 += v3 * b32; - t5 += v3 * b4; - t6 += v3 * b5; - t7 += v3 * b6; - t8 += v3 * b7; - t9 += v3 * b8; - t10 += v3 * b9; - t11 += v3 * b10; - t12 += v3 * b11; - t13 += v3 * b12; - t14 += v3 * b13; - t15 += v3 * b14; - t16 += v3 * b15; - v3 = a3[2]; - t2 += v3 * b0; - t3 += v3 * b1; - t4 += v3 * b22; - t5 += v3 * b32; - t6 += v3 * b4; - t7 += v3 * b5; - t8 += v3 * b6; - t9 += v3 * b7; - t10 += v3 * b8; - t11 += v3 * b9; - t12 += v3 * b10; - t13 += v3 * b11; - t14 += v3 * b12; - t15 += v3 * b13; - t16 += v3 * b14; - t17 += v3 * b15; - v3 = a3[3]; - t3 += v3 * b0; - t4 += v3 * b1; - t5 += v3 * b22; - t6 += v3 * b32; - t7 += v3 * b4; - t8 += v3 * b5; - t9 += v3 * b6; - t10 += v3 * b7; - t11 += v3 * b8; - t12 += v3 * b9; - t13 += v3 * b10; - t14 += v3 * b11; - t15 += v3 * b12; - t16 += v3 * b13; - t17 += v3 * b14; - t18 += v3 * b15; - v3 = a3[4]; - t4 += v3 * b0; - t5 += v3 * b1; - t6 += v3 * b22; - t7 += v3 * b32; - t8 += v3 * b4; - t9 += v3 * b5; - t10 += v3 * b6; - t11 += v3 * b7; - t12 += v3 * b8; - t13 += v3 * b9; - t14 += v3 * b10; - t15 += v3 * b11; - t16 += v3 * b12; - t17 += v3 * b13; - t18 += v3 * b14; - t19 += v3 * b15; - v3 = a3[5]; - t5 += v3 * b0; - t6 += v3 * b1; - t7 += v3 * b22; - t8 += v3 * b32; - t9 += v3 * b4; - t10 += v3 * b5; - t11 += v3 * b6; - t12 += v3 * b7; - t13 += v3 * b8; - t14 += v3 * b9; - t15 += v3 * b10; - t16 += v3 * b11; - t17 += v3 * b12; - t18 += v3 * b13; - t19 += v3 * b14; - t20 += v3 * b15; - v3 = a3[6]; - t6 += v3 * b0; - t7 += v3 * b1; - t8 += v3 * b22; - t9 += v3 * b32; - t10 += v3 * b4; - t11 += v3 * b5; - t12 += v3 * b6; - t13 += v3 * b7; - t14 += v3 * b8; - t15 += v3 * b9; - t16 += v3 * b10; - t17 += v3 * b11; - t18 += v3 * b12; - t19 += v3 * b13; - t20 += v3 * b14; - t21 += v3 * b15; - v3 = a3[7]; - t7 += v3 * b0; - t8 += v3 * b1; - t9 += v3 * b22; - t10 += v3 * b32; - t11 += v3 * b4; - t12 += v3 * b5; - t13 += v3 * b6; - t14 += v3 * b7; - t15 += v3 * b8; - t16 += v3 * b9; - t17 += v3 * b10; - t18 += v3 * b11; - t19 += v3 * b12; - t20 += v3 * b13; - t21 += v3 * b14; - t22 += v3 * b15; - v3 = a3[8]; - t8 += v3 * b0; - t9 += v3 * b1; - t10 += v3 * b22; - t11 += v3 * b32; - t12 += v3 * b4; - t13 += v3 * b5; - t14 += v3 * b6; - t15 += v3 * b7; - t16 += v3 * b8; - t17 += v3 * b9; - t18 += v3 * b10; - t19 += v3 * b11; - t20 += v3 * b12; - t21 += v3 * b13; - t22 += v3 * b14; - t23 += v3 * b15; - v3 = a3[9]; - t9 += v3 * b0; - t10 += v3 * b1; - t11 += v3 * b22; - t12 += v3 * b32; - t13 += v3 * b4; - t14 += v3 * b5; - t15 += v3 * b6; - t16 += v3 * b7; - t17 += v3 * b8; - t18 += v3 * b9; - t19 += v3 * b10; - t20 += v3 * b11; - t21 += v3 * b12; - t22 += v3 * b13; - t23 += v3 * b14; - t24 += v3 * b15; - v3 = a3[10]; - t10 += v3 * b0; - t11 += v3 * b1; - t12 += v3 * b22; - t13 += v3 * b32; - t14 += v3 * b4; - t15 += v3 * b5; - t16 += v3 * b6; - t17 += v3 * b7; - t18 += v3 * b8; - t19 += v3 * b9; - t20 += v3 * b10; - t21 += v3 * b11; - t22 += v3 * b12; - t23 += v3 * b13; - t24 += v3 * b14; - t25 += v3 * b15; - v3 = a3[11]; - t11 += v3 * b0; - t12 += v3 * b1; - t13 += v3 * b22; - t14 += v3 * b32; - t15 += v3 * b4; - t16 += v3 * b5; - t17 += v3 * b6; - t18 += v3 * b7; - t19 += v3 * b8; - t20 += v3 * b9; - t21 += v3 * b10; - t22 += v3 * b11; - t23 += v3 * b12; - t24 += v3 * b13; - t25 += v3 * b14; - t26 += v3 * b15; - v3 = a3[12]; - t12 += v3 * b0; - t13 += v3 * b1; - t14 += v3 * b22; - t15 += v3 * b32; - t16 += v3 * b4; - t17 += v3 * b5; - t18 += v3 * b6; - t19 += v3 * b7; - t20 += v3 * b8; - t21 += v3 * b9; - t22 += v3 * b10; - t23 += v3 * b11; - t24 += v3 * b12; - t25 += v3 * b13; - t26 += v3 * b14; - t27 += v3 * b15; - v3 = a3[13]; - t13 += v3 * b0; - t14 += v3 * b1; - t15 += v3 * b22; - t16 += v3 * b32; - t17 += v3 * b4; - t18 += v3 * b5; - t19 += v3 * b6; - t20 += v3 * b7; - t21 += v3 * b8; - t22 += v3 * b9; - t23 += v3 * b10; - t24 += v3 * b11; - t25 += v3 * b12; - t26 += v3 * b13; - t27 += v3 * b14; - t28 += v3 * b15; - v3 = a3[14]; - t14 += v3 * b0; - t15 += v3 * b1; - t16 += v3 * b22; - t17 += v3 * b32; - t18 += v3 * b4; - t19 += v3 * b5; - t20 += v3 * b6; - t21 += v3 * b7; - t22 += v3 * b8; - t23 += v3 * b9; - t24 += v3 * b10; - t25 += v3 * b11; - t26 += v3 * b12; - t27 += v3 * b13; - t28 += v3 * b14; - t29 += v3 * b15; - v3 = a3[15]; - t15 += v3 * b0; - t16 += v3 * b1; - t17 += v3 * b22; - t18 += v3 * b32; - t19 += v3 * b4; - t20 += v3 * b5; - t21 += v3 * b6; - t22 += v3 * b7; - t23 += v3 * b8; - t24 += v3 * b9; - t25 += v3 * b10; - t26 += v3 * b11; - t27 += v3 * b12; - t28 += v3 * b13; - t29 += v3 * b14; - t30 += v3 * b15; - t0 += 38 * t16; - t1 += 38 * t17; - t2 += 38 * t18; - t3 += 38 * t19; - t4 += 38 * t20; - t5 += 38 * t21; - t6 += 38 * t22; - t7 += 38 * t23; - t8 += 38 * t24; - t9 += 38 * t25; - t10 += 38 * t26; - t11 += 38 * t27; - t12 += 38 * t28; - t13 += 38 * t29; - t14 += 38 * t30; - c2 = 1; - v3 = t0 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t0 = v3 - c2 * 65536; - v3 = t1 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t1 = v3 - c2 * 65536; - v3 = t2 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t2 = v3 - c2 * 65536; - v3 = t3 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t3 = v3 - c2 * 65536; - v3 = t4 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t4 = v3 - c2 * 65536; - v3 = t5 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t5 = v3 - c2 * 65536; - v3 = t6 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t6 = v3 - c2 * 65536; - v3 = t7 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t7 = v3 - c2 * 65536; - v3 = t8 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t8 = v3 - c2 * 65536; - v3 = t9 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t9 = v3 - c2 * 65536; - v3 = t10 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t10 = v3 - c2 * 65536; - v3 = t11 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t11 = v3 - c2 * 65536; - v3 = t12 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t12 = v3 - c2 * 65536; - v3 = t13 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t13 = v3 - c2 * 65536; - v3 = t14 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t14 = v3 - c2 * 65536; - v3 = t15 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t15 = v3 - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - c2 = 1; - v3 = t0 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t0 = v3 - c2 * 65536; - v3 = t1 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t1 = v3 - c2 * 65536; - v3 = t2 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t2 = v3 - c2 * 65536; - v3 = t3 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t3 = v3 - c2 * 65536; - v3 = t4 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t4 = v3 - c2 * 65536; - v3 = t5 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t5 = v3 - c2 * 65536; - v3 = t6 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t6 = v3 - c2 * 65536; - v3 = t7 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t7 = v3 - c2 * 65536; - v3 = t8 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t8 = v3 - c2 * 65536; - v3 = t9 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t9 = v3 - c2 * 65536; - v3 = t10 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t10 = v3 - c2 * 65536; - v3 = t11 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t11 = v3 - c2 * 65536; - v3 = t12 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t12 = v3 - c2 * 65536; - v3 = t13 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t13 = v3 - c2 * 65536; - v3 = t14 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t14 = v3 - c2 * 65536; - v3 = t15 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t15 = v3 - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - o2[0] = t0; - o2[1] = t1; - o2[2] = t2; - o2[3] = t3; - o2[4] = t4; - o2[5] = t5; - o2[6] = t6; - o2[7] = t7; - o2[8] = t8; - o2[9] = t9; - o2[10] = t10; - o2[11] = t11; - o2[12] = t12; - o2[13] = t13; - o2[14] = t14; - o2[15] = t15; - } - function square(o2, a3) { - mul(o2, a3, a3); - } - function inv25519(o2, inp) { - const c2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - c2[i2] = inp[i2]; - } - for (let i2 = 253; i2 >= 0; i2--) { - square(c2, c2); - if (i2 !== 2 && i2 !== 4) { - mul(c2, c2, inp); - } - } - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = c2[i2]; - } - } - function scalarMult(n3, p3) { - const z3 = new Uint8Array(32); - const x2 = new Float64Array(80); - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e = gf(), f2 = gf(); - for (let i2 = 0; i2 < 31; i2++) { - z3[i2] = n3[i2]; - } - z3[31] = n3[31] & 127 | 64; - z3[0] &= 248; - unpack25519(x2, p3); - for (let i2 = 0; i2 < 16; i2++) { - b3[i2] = x2[i2]; - } - a3[0] = d3[0] = 1; - for (let i2 = 254; i2 >= 0; --i2) { - const r2 = z3[i2 >>> 3] >>> (i2 & 7) & 1; - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); - add(e, a3, c2); - sub(a3, a3, c2); - add(c2, b3, d3); - sub(b3, b3, d3); - square(d3, e); - square(f2, a3); - mul(a3, c2, a3); - mul(c2, b3, e); - add(e, a3, c2); - sub(a3, a3, c2); - square(b3, a3); - sub(c2, d3, f2); - mul(a3, c2, _121665); - add(a3, a3, d3); - mul(c2, c2, a3); - mul(a3, d3, f2); - mul(d3, b3, x2); - square(b3, e); - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); - } - for (let i2 = 0; i2 < 16; i2++) { - x2[i2 + 16] = a3[i2]; - x2[i2 + 32] = c2[i2]; - x2[i2 + 48] = b3[i2]; - x2[i2 + 64] = d3[i2]; - } - const x32 = x2.subarray(32); - const x16 = x2.subarray(16); - inv25519(x32, x32); - mul(x16, x16, x32); - const q2 = new Uint8Array(32); - pack25519(q2, x16); - return q2; - } - exports2.scalarMult = scalarMult; - function scalarMultBase(n3) { - return scalarMult(n3, _9); - } - exports2.scalarMultBase = scalarMultBase; - function generateKeyPairFromSeed(seed) { - if (seed.length !== exports2.SECRET_KEY_LENGTH) { - throw new Error(`x25519: seed must be ${exports2.SECRET_KEY_LENGTH} bytes`); - } - const secretKey = new Uint8Array(seed); - const publicKey = scalarMultBase(secretKey); - return { - publicKey, - secretKey - }; - } - exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; - function generateKeyPair2(prng) { - const seed = (0, random_1.randomBytes)(32, prng); - const result = generateKeyPairFromSeed(seed); - (0, wipe_12.wipe)(seed); - return result; - } - exports2.generateKeyPair = generateKeyPair2; - function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { - if (mySecretKey.length !== exports2.PUBLIC_KEY_LENGTH) { - throw new Error("X25519: incorrect secret key length"); - } - if (theirPublicKey.length !== exports2.PUBLIC_KEY_LENGTH) { - throw new Error("X25519: incorrect public key length"); - } - const result = scalarMult(mySecretKey, theirPublicKey); - if (rejectZero) { - let zeros = 0; - for (let i2 = 0; i2 < result.length; i2++) { - zeros |= result[i2]; - } - if (zeros === 0) { - throw new Error("X25519: invalid shared key"); - } - } - return result; - } - exports2.sharedKey = sharedKey; -})(x25519); -var __spreadArray = function(to, from2, pack) { - if (pack || arguments.length === 2) - for (var i2 = 0, l2 = from2.length, ar2; i2 < l2; i2++) { - if (ar2 || !(i2 in from2)) { - if (!ar2) - ar2 = Array.prototype.slice.call(from2, 0, i2); - ar2[i2] = from2[i2]; - } - } - return to.concat(ar2 || Array.prototype.slice.call(from2)); -}; -var BrowserInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BrowserInfo2(name2, version2, os2) { - this.name = name2; - this.version = version2; - this.os = os2; - this.type = "browser"; - } - return BrowserInfo2; - }() -); -var NodeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function NodeInfo2(version2) { - this.version = version2; - this.type = "node"; - this.name = "node"; - this.os = process.platform; - } - return NodeInfo2; - }() -); -var SearchBotDeviceInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function SearchBotDeviceInfo2(name2, version2, os2, bot) { - this.name = name2; - this.version = version2; - this.os = os2; - this.bot = bot; - this.type = "bot-device"; - } - return SearchBotDeviceInfo2; - }() -); -var BotInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BotInfo2() { - this.type = "bot"; - this.bot = true; - this.name = "bot"; - this.version = null; - this.os = null; - } - return BotInfo2; - }() -); -var ReactNativeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function ReactNativeInfo2() { - this.type = "react-native"; - this.name = "react-native"; - this.version = null; - this.os = null; - } - return ReactNativeInfo2; - }() -); -var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; -var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; -var REQUIRED_VERSION_PARTS = 3; -var userAgentRules = [ - ["aol", /AOLShield\/([0-9\._]+)/], - ["edge", /Edge\/([0-9\._]+)/], - ["edge-ios", /EdgiOS\/([0-9\._]+)/], - ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], - ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], - ["samsung", /SamsungBrowser\/([0-9\.]+)/], - ["silk", /\bSilk\/([0-9._-]+)\b/], - ["miui", /MiuiBrowser\/([0-9\.]+)$/], - ["beaker", /BeakerBrowser\/([0-9\.]+)/], - ["edge-chromium", /EdgA?\/([0-9\.]+)/], - [ - "chromium-webview", - /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ - ], - ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], - ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], - ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], - ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], - ["fxios", /FxiOS\/([0-9\.]+)/], - ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], - ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], - ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], - ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], - ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], - ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], - ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], - ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], - ["ie", /MSIE\s(7\.0)/], - ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], - ["android", /Android\s([0-9\.]+)/], - ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], - ["safari", /Version\/([0-9\._]+).*Safari/], - ["facebook", /FB[AS]V\/([0-9\.]+)/], - ["instagram", /Instagram\s([0-9\.]+)/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], - ["curl", /^curl\/([0-9\.]+)$/], - ["searchbot", SEARCHBOX_UA_REGEX] -]; -var operatingSystemRules = [ - ["iOS", /iP(hone|od|ad)/], - ["Android OS", /Android/], - ["BlackBerry OS", /BlackBerry|BB10/], - ["Windows Mobile", /IEMobile/], - ["Amazon OS", /Kindle/], - ["Windows 3.11", /Win16/], - ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], - ["Windows 98", /(Windows 98)|(Win98)/], - ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], - ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], - ["Windows Server 2003", /(Windows NT 5.2)/], - ["Windows Vista", /(Windows NT 6.0)/], - ["Windows 7", /(Windows NT 6.1)/], - ["Windows 8", /(Windows NT 6.2)/], - ["Windows 8.1", /(Windows NT 6.3)/], - ["Windows 10", /(Windows NT 10.0)/], - ["Windows ME", /Windows ME/], - ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], - ["Open BSD", /OpenBSD/], - ["Sun OS", /SunOS/], - ["Chrome OS", /CrOS/], - ["Linux", /(Linux)|(X11)/], - ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], - ["QNX", /QNX/], - ["BeOS", /BeOS/], - ["OS/2", /OS\/2/] -]; -function detect(userAgent) { - if (!!userAgent) { - return parseUserAgent(userAgent); - } - if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { - return new ReactNativeInfo(); - } - if (typeof navigator !== "undefined") { - return parseUserAgent(navigator.userAgent); - } - return getNodeVersion(); -} -function matchUserAgent(ua) { - return ua !== "" && userAgentRules.reduce(function(matched, _a) { - var browser2 = _a[0], regex = _a[1]; - if (matched) { - return matched; - } - var uaMatch = regex.exec(ua); - return !!uaMatch && [browser2, uaMatch]; - }, false); -} -function parseUserAgent(ua) { - var matchedRule = matchUserAgent(ua); - if (!matchedRule) { - return null; - } - var name2 = matchedRule[0], match = matchedRule[1]; - if (name2 === "searchbot") { - return new BotInfo(); - } - var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); - if (versionParts) { - if (versionParts.length < REQUIRED_VERSION_PARTS) { - versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); - } - } else { - versionParts = []; - } - var version2 = versionParts.join("."); - var os2 = detectOS(ua); - var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua); - if (searchBotMatch && searchBotMatch[1]) { - return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); - } - return new BrowserInfo(name2, version2, os2); -} -function detectOS(ua) { - for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { - var _a = operatingSystemRules[ii], os2 = _a[0], regex = _a[1]; - var match = regex.exec(ua); - if (match) { - return os2; - } - } - return null; -} -function getNodeVersion() { - var isNode = typeof process !== "undefined" && process.version; - return isNode ? new NodeInfo(process.version.slice(1)) : null; -} -function createVersionParts(count) { - var output = []; - for (var ii = 0; ii < count; ii++) { - output.push("0"); - } - return output; -} -var cjs$2 = {}; -Object.defineProperty(cjs$2, "__esModule", { value: true }); -cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; -function getFromWindow(name2) { - let res = void 0; - if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { - res = window[name2]; - } - return res; -} -cjs$2.getFromWindow = getFromWindow; -function getFromWindowOrThrow(name2) { - const res = getFromWindow(name2); - if (!res) { - throw new Error(`${name2} is not defined in Window`); - } - return res; -} -cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; -function getDocumentOrThrow() { - return getFromWindowOrThrow("document"); -} -cjs$2.getDocumentOrThrow = getDocumentOrThrow; -function getDocument() { - return getFromWindow("document"); -} -var getDocument_1 = cjs$2.getDocument = getDocument; -function getNavigatorOrThrow() { - return getFromWindowOrThrow("navigator"); -} -cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; -function getNavigator() { - return getFromWindow("navigator"); -} -var getNavigator_1 = cjs$2.getNavigator = getNavigator; -function getLocationOrThrow() { - return getFromWindowOrThrow("location"); -} -cjs$2.getLocationOrThrow = getLocationOrThrow; -function getLocation() { - return getFromWindow("location"); -} -var getLocation_1 = cjs$2.getLocation = getLocation; -function getCryptoOrThrow() { - return getFromWindowOrThrow("crypto"); -} -cjs$2.getCryptoOrThrow = getCryptoOrThrow; -function getCrypto() { - return getFromWindow("crypto"); -} -cjs$2.getCrypto = getCrypto; -function getLocalStorageOrThrow() { - return getFromWindowOrThrow("localStorage"); -} -cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; -function getLocalStorage() { - return getFromWindow("localStorage"); -} -cjs$2.getLocalStorage = getLocalStorage; -var cjs$1 = {}; -Object.defineProperty(cjs$1, "__esModule", { value: true }); -var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; -const window_getters_1 = cjs$2; -function getWindowMetadata() { - let doc; - let loc; - try { - doc = window_getters_1.getDocumentOrThrow(); - loc = window_getters_1.getLocationOrThrow(); - } catch (e) { - return null; - } - function getIcons() { - const links = doc.getElementsByTagName("link"); - const icons2 = []; - for (let i2 = 0; i2 < links.length; i2++) { - const link = links[i2]; - const rel = link.getAttribute("rel"); - if (rel) { - if (rel.toLowerCase().indexOf("icon") > -1) { - const href = link.getAttribute("href"); - if (href) { - if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { - let absoluteHref = loc.protocol + "//" + loc.host; - if (href.indexOf("/") === 0) { - absoluteHref += href; - } else { - const path = loc.pathname.split("/"); - path.pop(); - const finalPath = path.join("/"); - absoluteHref += finalPath + "/" + href; - } - icons2.push(absoluteHref); - } else if (href.indexOf("//") === 0) { - const absoluteUrl = loc.protocol + href; - icons2.push(absoluteUrl); - } else { - icons2.push(href); - } - } - } - } - } - return icons2; - } - function getWindowMetadataOfAny(...args) { - const metaTags = doc.getElementsByTagName("meta"); - for (let i2 = 0; i2 < metaTags.length; i2++) { - const tag = metaTags[i2]; - const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { - if (attr) { - return args.includes(attr); - } - return false; - }); - if (attributes.length && attributes) { - const content = tag.getAttribute("content"); - if (content) { - return content; - } - } - } - return ""; - } - function getName() { - let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); - if (!name3) { - name3 = doc.title; - } - return name3; - } - function getDescription() { - const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); - return description3; - } - const name2 = getName(); - const description2 = getDescription(); - const url = loc.origin; - const icons = getIcons(); - const meta = { - description: description2, - url, - icons, - name: name2 - }; - return meta; -} -getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; -var queryString = {}; -var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); -var token = "%[a-f0-9]{2}"; -var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); -var multiMatcher = new RegExp("(" + token + ")+", "gi"); -function decodeComponents(components, split) { - try { - return [decodeURIComponent(components.join(""))]; - } catch (err) { - } - if (components.length === 1) { - return components; - } - split = split || 1; - var left = components.slice(0, split); - var right = components.slice(split); - return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); -} -function decode(input) { - try { - return decodeURIComponent(input); - } catch (err) { - var tokens = input.match(singleMatcher) || []; - for (var i2 = 1; i2 < tokens.length; i2++) { - input = decodeComponents(tokens, i2).join(""); - tokens = input.match(singleMatcher) || []; - } - return input; - } -} -function customDecodeURIComponent(input) { - var replaceMap = { - "%FE%FF": "��", - "%FF%FE": "��" - }; - var match = multiMatcher.exec(input); - while (match) { - try { - replaceMap[match[0]] = decodeURIComponent(match[0]); - } catch (err) { - var result = decode(match[0]); - if (result !== match[0]) { - replaceMap[match[0]] = result; - } - } - match = multiMatcher.exec(input); - } - replaceMap["%C2"] = "�"; - var entries = Object.keys(replaceMap); - for (var i2 = 0; i2 < entries.length; i2++) { - var key = entries[i2]; - input = input.replace(new RegExp(key, "g"), replaceMap[key]); - } - return input; -} -var decodeUriComponent = function(encodedURI) { - if (typeof encodedURI !== "string") { - throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); - } - try { - encodedURI = encodedURI.replace(/\+/g, " "); - return decodeURIComponent(encodedURI); - } catch (err) { - return customDecodeURIComponent(encodedURI); - } -}; -var splitOnFirst = (string2, separator) => { - if (!(typeof string2 === "string" && typeof separator === "string")) { - throw new TypeError("Expected the arguments to be of type `string`"); - } - if (separator === "") { - return [string2]; - } - const separatorIndex = string2.indexOf(separator); - if (separatorIndex === -1) { - return [string2]; - } - return [ - string2.slice(0, separatorIndex), - string2.slice(separatorIndex + separator.length) - ]; -}; -var filterObj = function(obj, predicate) { - var ret = {}; - var keys2 = Object.keys(obj); - var isArr = Array.isArray(predicate); - for (var i2 = 0; i2 < keys2.length; i2++) { - var key = keys2[i2]; - var val = obj[key]; - if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { - ret[key] = val; - } - } - return ret; -}; -(function(exports2) { - const strictUriEncode$1 = strictUriEncode; - const decodeComponent = decodeUriComponent; - const splitOnFirst$1 = splitOnFirst; - const filterObject = filterObj; - const isNullOrUndefined = (value) => value === null || value === void 0; - const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); - function encoderForArrayFormat(options) { - switch (options.arrayFormat) { - case "index": - return (key) => (result, value) => { - const index = result.length; - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[", index, "]"].join("")]; - } - return [ - ...result, - [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") - ]; - }; - case "bracket": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[]"].join("")]; - } - return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; - }; - case "colon-list-separator": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), ":list="].join("")]; - } - return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; - }; - case "comma": - case "separator": - case "bracket-separator": { - const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - value = value === null ? "" : value; - if (result.length === 0) { - return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; - } - return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; - }; - } - default: - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, encode2(key, options)]; - } - return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; - }; - } - } - function parserForArrayFormat(options) { - let result; - switch (options.arrayFormat) { - case "index": - return (key, value, accumulator) => { - result = /\[(\d*)\]$/.exec(key); - key = key.replace(/\[\d*\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = {}; - } - accumulator[key][result[1]] = value; - }; - case "bracket": - return (key, value, accumulator) => { - result = /(\[\])$/.exec(key); - key = key.replace(/\[\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "colon-list-separator": - return (key, value, accumulator) => { - result = /(:list)$/.exec(key); - key = key.replace(/:list$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "comma": - case "separator": - return (key, value, accumulator) => { - const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator); - const isEncodedArray = typeof value === "string" && !isArray && decode2(value, options).includes(options.arrayFormatSeparator); - value = isEncodedArray ? decode2(value, options) : value; - const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); - accumulator[key] = newValue; - }; - case "bracket-separator": - return (key, value, accumulator) => { - const isArray = /(\[\])$/.test(key); - key = key.replace(/\[\]$/, ""); - if (!isArray) { - accumulator[key] = value ? decode2(value, options) : value; - return; - } - const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); - if (accumulator[key] === void 0) { - accumulator[key] = arrayValue; - return; - } - accumulator[key] = [].concat(accumulator[key], arrayValue); - }; - default: - return (key, value, accumulator) => { - if (accumulator[key] === void 0) { - accumulator[key] = value; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - } - } - function validateArrayFormatSeparator(value) { - if (typeof value !== "string" || value.length !== 1) { - throw new TypeError("arrayFormatSeparator must be single character string"); - } - } - function encode2(value, options) { - if (options.encode) { - return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); - } - return value; - } - function decode2(value, options) { - if (options.decode) { - return decodeComponent(value); - } - return value; - } - function keysSorter(input) { - if (Array.isArray(input)) { - return input.sort(); - } - if (typeof input === "object") { - return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); - } - return input; - } - function removeHash(input) { - const hashStart = input.indexOf("#"); - if (hashStart !== -1) { - input = input.slice(0, hashStart); - } - return input; - } - function getHash(url) { - let hash2 = ""; - const hashStart = url.indexOf("#"); - if (hashStart !== -1) { - hash2 = url.slice(hashStart); - } - return hash2; - } - function extract(input) { - input = removeHash(input); - const queryStart = input.indexOf("?"); - if (queryStart === -1) { - return ""; - } - return input.slice(queryStart + 1); - } - function parseValue(value, options) { - if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { - value = Number(value); - } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { - value = value.toLowerCase() === "true"; - } - return value; - } - function parse(query, options) { - options = Object.assign({ - decode: true, - sort: true, - arrayFormat: "none", - arrayFormatSeparator: ",", - parseNumbers: false, - parseBooleans: false - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const formatter = parserForArrayFormat(options); - const ret = /* @__PURE__ */ Object.create(null); - if (typeof query !== "string") { - return ret; - } - query = query.trim().replace(/^[?#&]/, ""); - if (!query) { - return ret; - } - for (const param of query.split("&")) { - if (param === "") { - continue; - } - let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); - value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); - formatter(decode2(key, options), value, ret); - } - for (const key of Object.keys(ret)) { - const value = ret[key]; - if (typeof value === "object" && value !== null) { - for (const k2 of Object.keys(value)) { - value[k2] = parseValue(value[k2], options); - } - } else { - ret[key] = parseValue(value, options); - } - } - if (options.sort === false) { - return ret; - } - return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { - const value = ret[key]; - if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { - result[key] = keysSorter(value); - } else { - result[key] = value; - } - return result; - }, /* @__PURE__ */ Object.create(null)); - } - exports2.extract = extract; - exports2.parse = parse; - exports2.stringify = (object, options) => { - if (!object) { - return ""; - } - options = Object.assign({ - encode: true, - strict: true, - arrayFormat: "none", - arrayFormatSeparator: "," - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; - const formatter = encoderForArrayFormat(options); - const objectCopy = {}; - for (const key of Object.keys(object)) { - if (!shouldFilter(key)) { - objectCopy[key] = object[key]; - } - } - const keys2 = Object.keys(objectCopy); - if (options.sort !== false) { - keys2.sort(options.sort); - } - return keys2.map((key) => { - const value = object[key]; - if (value === void 0) { - return ""; - } - if (value === null) { - return encode2(key, options); - } - if (Array.isArray(value)) { - if (value.length === 0 && options.arrayFormat === "bracket-separator") { - return encode2(key, options) + "[]"; - } - return value.reduce(formatter(key), []).join("&"); - } - return encode2(key, options) + "=" + encode2(value, options); - }).filter((x2) => x2.length > 0).join("&"); - }; - exports2.parseUrl = (url, options) => { - options = Object.assign({ - decode: true - }, options); - const [url_, hash2] = splitOnFirst$1(url, "#"); - return Object.assign( - { - url: url_.split("?")[0] || "", - query: parse(extract(url), options) - }, - options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} - ); - }; - exports2.stringifyUrl = (object, options) => { - options = Object.assign({ - encode: true, - strict: true, - [encodeFragmentIdentifier]: true - }, options); - const url = removeHash(object.url).split("?")[0] || ""; - const queryFromUrl = exports2.extract(object.url); - const parsedQueryFromUrl = exports2.parse(queryFromUrl, { sort: false }); - const query = Object.assign(parsedQueryFromUrl, object.query); - let queryString2 = exports2.stringify(query, options); - if (queryString2) { - queryString2 = `?${queryString2}`; - } - let hash2 = getHash(object.url); - if (object.fragmentIdentifier) { - hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; - } - return `${url}${queryString2}${hash2}`; - }; - exports2.pick = (input, filter, options) => { - options = Object.assign({ - parseFragmentIdentifier: true, - [encodeFragmentIdentifier]: false - }, options); - const { url, query, fragmentIdentifier } = exports2.parseUrl(input, options); - return exports2.stringifyUrl({ - url, - query: filterObject(query, filter), - fragmentIdentifier - }, options); - }; - exports2.exclude = (input, filter, options) => { - const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); - return exports2.pick(input, exclusionFilter, options); - }; -})(queryString); -const RELAY_JSONRPC = { - waku: { - publish: "waku_publish", - batchPublish: "waku_batchPublish", - subscribe: "waku_subscribe", - batchSubscribe: "waku_batchSubscribe", - subscription: "waku_subscription", - unsubscribe: "waku_unsubscribe", - batchUnsubscribe: "waku_batchUnsubscribe" - }, - irn: { - publish: "irn_publish", - batchPublish: "irn_batchPublish", - subscribe: "irn_subscribe", - batchSubscribe: "irn_batchSubscribe", - subscription: "irn_subscription", - unsubscribe: "irn_unsubscribe", - batchUnsubscribe: "irn_batchUnsubscribe" - }, - iridium: { - publish: "iridium_publish", - batchPublish: "iridium_batchPublish", - subscribe: "iridium_subscribe", - batchSubscribe: "iridium_batchSubscribe", - subscription: "iridium_subscription", - unsubscribe: "iridium_unsubscribe", - batchUnsubscribe: "iridium_batchUnsubscribe" - } -}; -function L$1(e, n3) { - return e.includes(":") ? [e] : n3.chains || []; -} -const J$1 = "base10", p$1 = "base16", F$2 = "base64pad", H$1 = "utf8", Q$2 = 0, _$1 = 1, Dn = 0, Te = 1, Z$1 = 12, X$1 = 32; -function kn() { - const e = x25519.generateKeyPair(); - return { privateKey: toString(e.secretKey, p$1), publicKey: toString(e.publicKey, p$1) }; -} -function Vn() { - const e = random.randomBytes(X$1); - return toString(e, p$1); -} -function Mn(e, n3) { - const t2 = x25519.sharedKey(fromString(e, p$1), fromString(n3, p$1), true), r2 = new HKDF_1(sha256.SHA256, t2).expand(X$1); - return toString(r2, p$1); -} -function Kn(e) { - const n3 = sha256.hash(fromString(e, p$1)); - return toString(n3, p$1); -} -function Ln(e) { - const n3 = sha256.hash(fromString(e, H$1)); - return toString(n3, p$1); -} -function Pe(e) { - return fromString(`${e}`, J$1); -} -function j$1(e) { - return Number(toString(e, J$1)); -} -function xn(e) { - const n3 = Pe(typeof e.type < "u" ? e.type : Q$2); - if (j$1(n3) === _$1 && typeof e.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - const t2 = typeof e.senderPublicKey < "u" ? fromString(e.senderPublicKey, p$1) : void 0, r2 = typeof e.iv < "u" ? fromString(e.iv, p$1) : random.randomBytes(Z$1), o2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e.symKey, p$1)).seal(r2, fromString(e.message, H$1)); - return Re({ type: n3, sealed: o2, iv: r2, senderPublicKey: t2 }); -} -function Fn(e) { - const n3 = new chacha20poly1305.ChaCha20Poly1305(fromString(e.symKey, p$1)), { sealed: t2, iv: r2 } = ee$1(e.encoded), o2 = n3.open(r2, t2); - if (o2 === null) - throw new Error("Failed to decrypt"); - return toString(o2, H$1); -} -function Re(e) { - if (j$1(e.type) === _$1) { - if (typeof e.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - return toString(concat([e.type, e.senderPublicKey, e.iv, e.sealed]), F$2); - } - return toString(concat([e.type, e.iv, e.sealed]), F$2); -} -function ee$1(e) { - const n3 = fromString(e, F$2), t2 = n3.slice(Dn, Te), r2 = Te; - if (j$1(t2) === _$1) { - const d3 = r2 + X$1, l2 = d3 + Z$1, c2 = n3.slice(r2, d3), u3 = n3.slice(d3, l2), a3 = n3.slice(l2); - return { type: t2, sealed: a3, iv: u3, senderPublicKey: c2 }; - } - const o2 = r2 + Z$1, s2 = n3.slice(r2, o2), i2 = n3.slice(o2); - return { type: t2, sealed: i2, iv: s2 }; -} -function Hn(e, n3) { - const t2 = ee$1(e); - return Ae({ type: j$1(t2.type), senderPublicKey: typeof t2.senderPublicKey < "u" ? toString(t2.senderPublicKey, p$1) : void 0, receiverPublicKey: n3 == null ? void 0 : n3.receiverPublicKey }); -} -function Ae(e) { - const n3 = (e == null ? void 0 : e.type) || Q$2; - if (n3 === _$1) { - if (typeof (e == null ? void 0 : e.senderPublicKey) > "u") - throw new Error("missing sender public key"); - if (typeof (e == null ? void 0 : e.receiverPublicKey) > "u") - throw new Error("missing receiver public key"); - } - return { type: n3, senderPublicKey: e == null ? void 0 : e.senderPublicKey, receiverPublicKey: e == null ? void 0 : e.receiverPublicKey }; -} -function qn(e) { - return e.type === _$1 && typeof e.senderPublicKey == "string" && typeof e.receiverPublicKey == "string"; -} -var Bn = Object.defineProperty, Ue$1 = Object.getOwnPropertySymbols, Gn = Object.prototype.hasOwnProperty, Wn = Object.prototype.propertyIsEnumerable, _e = (e, n3, t2) => n3 in e ? Bn(e, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[n3] = t2, $e$1 = (e, n3) => { - for (var t2 in n3 || (n3 = {})) - Gn.call(n3, t2) && _e(e, t2, n3[t2]); - if (Ue$1) - for (var t2 of Ue$1(n3)) - Wn.call(n3, t2) && _e(e, t2, n3[t2]); - return e; -}; -const Ce = "ReactNative", m$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, De$1 = "js"; -function te$1() { - return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; -} -function $$1() { - return !getDocument_1() && !!getNavigator_1() && navigator.product === Ce; -} -function D$2() { - return !te$1() && !!getNavigator_1() && !!getDocument_1(); -} -function R$2() { - return $$1() ? m$1.reactNative : te$1() ? m$1.node : D$2() ? m$1.browser : m$1.unknown; -} -function Jn() { - var e; - try { - return $$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e = global.Application) == null ? void 0 : e.applicationId : void 0; - } catch { - return; - } -} -function ke$1(e, n3) { - let t2 = queryString.parse(e); - return t2 = $e$1($e$1({}, t2), n3), e = queryString.stringify(t2), e; -} -function Qn() { - return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; -} -function Ve$1() { - if (R$2() === m$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { - const { OS: t2, Version: r2 } = global.Platform; - return [t2, r2].join("-"); - } - const e = detect(); - if (e === null) - return "unknown"; - const n3 = e.os ? e.os.replace(" ", "").toLowerCase() : "unknown"; - return e.type === "browser" ? [n3, e.name, e.version].join("-") : [n3, e.version].join("-"); -} -function Me$1() { - var e; - const n3 = R$2(); - return n3 === m$1.browser ? [n3, ((e = getLocation_1()) == null ? void 0 : e.host) || "unknown"].join(":") : n3; -} -function Ke$1(e, n3, t2) { - const r2 = Ve$1(), o2 = Me$1(); - return [[e, n3].join("-"), [De$1, t2].join("-"), r2, o2].join("/"); -} -function Xn({ protocol: e, version: n3, relayUrl: t2, sdkVersion: r2, auth: o2, projectId: s2, useOnCloseEvent: i2, bundleId: d3 }) { - const l2 = t2.split("?"), c2 = Ke$1(e, n3, r2), u3 = { auth: o2, ua: c2, projectId: s2, useOnCloseEvent: i2 || void 0, origin: d3 || void 0 }, a3 = ke$1(l2[1] || "", u3); - return l2[0] + "?" + a3; -} -function O$1(e, n3) { - return e.filter((t2) => n3.includes(t2)).length === e.length; -} -function rt$1(e) { - return Object.fromEntries(e.entries()); -} -function ot$1(e) { - return new Map(Object.entries(e)); -} -function at$1(e = cjs$4.FIVE_MINUTES, n3) { - const t2 = cjs$4.toMiliseconds(e || cjs$4.FIVE_MINUTES); - let r2, o2, s2; - return { resolve: (i2) => { - s2 && r2 && (clearTimeout(s2), r2(i2)); - }, reject: (i2) => { - s2 && o2 && (clearTimeout(s2), o2(i2)); - }, done: () => new Promise((i2, d3) => { - s2 = setTimeout(() => { - d3(new Error(n3)); - }, t2), r2 = i2, o2 = d3; - }) }; -} -function ut$1(e, n3, t2) { - return new Promise(async (r2, o2) => { - const s2 = setTimeout(() => o2(new Error(t2)), n3); - try { - const i2 = await e; - r2(i2); - } catch (i2) { - o2(i2); - } - clearTimeout(s2); - }); -} -function re(e, n3) { - if (typeof n3 == "string" && n3.startsWith(`${e}:`)) - return n3; - if (e.toLowerCase() === "topic") { - if (typeof n3 != "string") - throw new Error('Value must be "string" for expirer target type: topic'); - return `topic:${n3}`; - } else if (e.toLowerCase() === "id") { - if (typeof n3 != "number") - throw new Error('Value must be "number" for expirer target type: id'); - return `id:${n3}`; - } - throw new Error(`Unknown expirer target type: ${e}`); -} -function lt$1(e) { - return re("topic", e); -} -function dt$1(e) { - return re("id", e); -} -function ft$1(e) { - const [n3, t2] = e.split(":"), r2 = { id: void 0, topic: void 0 }; - if (n3 === "topic" && typeof t2 == "string") - r2.topic = t2; - else if (n3 === "id" && Number.isInteger(Number(t2))) - r2.id = Number(t2); - else - throw new Error(`Invalid target, expected id:number or topic:string, got ${n3}:${t2}`); - return r2; -} -function pt$1(e, n3) { - return cjs$4.fromMiliseconds((n3 || Date.now()) + cjs$4.toMiliseconds(e)); -} -function mt$1(e) { - return Date.now() >= cjs$4.toMiliseconds(e); -} -function yt$1(e, n3) { - return `${e}${n3 ? `:${n3}` : ""}`; -} -async function gt$1({ id: e, topic: n3, wcDeepLink: t2 }) { - try { - if (!t2) - return; - const r2 = typeof t2 == "string" ? JSON.parse(t2) : t2; - let o2 = r2 == null ? void 0 : r2.href; - if (typeof o2 != "string") - return; - o2.endsWith("/") && (o2 = o2.slice(0, -1)); - const s2 = `${o2}/wc?requestId=${e}&sessionTopic=${n3}`, i2 = R$2(); - i2 === m$1.browser ? s2.startsWith("https://") ? window.open(s2, "_blank", "noreferrer noopener") : window.open(s2, "_self", "noreferrer noopener") : i2 === m$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(s2); - } catch (r2) { - console.error(r2); - } -} -async function ht$1(e, n3) { - try { - return await e.getItem(n3) || (D$2() ? localStorage.getItem(n3) : void 0); - } catch (t2) { - console.error(t2); - } -} -const He$1 = "irn"; -function vt$1(e) { - return (e == null ? void 0 : e.relay) || { protocol: He$1 }; -} -function Et$1(e) { - const n3 = RELAY_JSONRPC[e]; - if (typeof n3 > "u") - throw new Error(`Relay Protocol not supported: ${e}`); - return n3; -} -var bt$1 = Object.defineProperty, Nt$1 = Object.defineProperties, Ot$1 = Object.getOwnPropertyDescriptors, qe$1 = Object.getOwnPropertySymbols, St$1 = Object.prototype.hasOwnProperty, wt$1 = Object.prototype.propertyIsEnumerable, Be$1 = (e, n3, t2) => n3 in e ? bt$1(e, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[n3] = t2, It$1 = (e, n3) => { - for (var t2 in n3 || (n3 = {})) - St$1.call(n3, t2) && Be$1(e, t2, n3[t2]); - if (qe$1) - for (var t2 of qe$1(n3)) - wt$1.call(n3, t2) && Be$1(e, t2, n3[t2]); - return e; -}, Tt$1 = (e, n3) => Nt$1(e, Ot$1(n3)); -function Ge$1(e, n3 = "-") { - const t2 = {}, r2 = "relay" + n3; - return Object.keys(e).forEach((o2) => { - if (o2.startsWith(r2)) { - const s2 = o2.replace(r2, ""), i2 = e[o2]; - t2[s2] = i2; - } - }), t2; -} -function Pt$1(e) { - e = e.includes("wc://") ? e.replace("wc://", "") : e, e = e.includes("wc:") ? e.replace("wc:", "") : e; - const n3 = e.indexOf(":"), t2 = e.indexOf("?") !== -1 ? e.indexOf("?") : void 0, r2 = e.substring(0, n3), o2 = e.substring(n3 + 1, t2).split("@"), s2 = typeof t2 < "u" ? e.substring(t2) : "", i2 = queryString.parse(s2); - return { protocol: r2, topic: We$1(o2[0]), version: parseInt(o2[1], 10), symKey: i2.symKey, relay: Ge$1(i2), expiryTimestamp: i2.expiryTimestamp ? parseInt(i2.expiryTimestamp, 10) : void 0 }; -} -function We$1(e) { - return e.startsWith("//") ? e.substring(2) : e; -} -function ze(e, n3 = "-") { - const t2 = "relay", r2 = {}; - return Object.keys(e).forEach((o2) => { - const s2 = t2 + n3 + o2; - e[o2] && (r2[s2] = e[o2]); - }), r2; -} -function Rt$1(e) { - return `${e.protocol}:${e.topic}@${e.version}?` + queryString.stringify(Tt$1(It$1({ symKey: e.symKey }, ze(e.relay)), { expiryTimestamp: e.expiryTimestamp })); -} -function A$1(e) { - const n3 = []; - return e.forEach((t2) => { - const [r2, o2] = t2.split(":"); - n3.push(`${r2}:${o2}`); - }), n3; -} -function Qe$1(e) { - const n3 = []; - return Object.values(e).forEach((t2) => { - n3.push(...A$1(t2.accounts)); - }), n3; -} -function Ze$1(e, n3) { - const t2 = []; - return Object.values(e).forEach((r2) => { - A$1(r2.accounts).includes(n3) && t2.push(...r2.methods); - }), t2; -} -function Xe$1(e, n3) { - const t2 = []; - return Object.values(e).forEach((r2) => { - A$1(r2.accounts).includes(n3) && t2.push(...r2.events); - }), t2; -} -const nn = { 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 } }, tn = { 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 N$1(e, n3) { - const { message: t2, code: r2 } = tn[e]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; -} -function U$2(e, n3) { - const { message: t2, code: r2 } = nn[e]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; -} -function k(e, n3) { - return Array.isArray(e) ? typeof n3 < "u" && e.length ? e.every(n3) : true : false; -} -function B$1(e) { - return Object.getPrototypeOf(e) === Object.prototype && Object.keys(e).length; -} -function w$3(e) { - return typeof e > "u"; -} -function g$3(e, n3) { - return n3 && w$3(e) ? true : typeof e == "string" && !!e.trim().length; -} -function G$1(e, n3) { - return n3 && w$3(e) ? true : typeof e == "number" && !isNaN(e); -} -function Mt$1(e, n3) { - const { requiredNamespaces: t2 } = n3, r2 = Object.keys(e.namespaces), o2 = Object.keys(t2); - let s2 = true; - return O$1(o2, r2) ? (r2.forEach((i2) => { - const { accounts: d3, methods: l2, events: c2 } = e.namespaces[i2], u3 = A$1(d3), a3 = t2[i2]; - (!O$1(L$1(i2, a3), u3) || !O$1(a3.methods, l2) || !O$1(a3.events, c2)) && (s2 = false); - }), s2) : false; -} -function V$1(e) { - return g$3(e, false) && e.includes(":") ? e.split(":").length === 2 : false; -} -function rn(e) { - if (g$3(e, false) && e.includes(":")) { - const n3 = e.split(":"); - if (n3.length === 3) { - const t2 = n3[0] + ":" + n3[1]; - return !!n3[2] && V$1(t2); - } - } - return false; -} -function Kt$1(e) { - if (g$3(e, false)) - try { - return typeof new URL(e) < "u"; - } catch { - return false; - } - return false; -} -function Lt$1(e) { - var n3; - return (n3 = e == null ? void 0 : e.proposer) == null ? void 0 : n3.publicKey; -} -function xt$1(e) { - return e == null ? void 0 : e.topic; -} -function Ft$1(e, n3) { - let t2 = null; - return g$3(e == null ? void 0 : e.publicKey, false) || (t2 = N$1("MISSING_OR_INVALID", `${n3} controller public key should be a string`)), t2; -} -function ie(e) { - let n3 = true; - return k(e) ? e.length && (n3 = e.every((t2) => g$3(t2, false))) : n3 = false, n3; -} -function on(e, n3, t2) { - let r2 = null; - return k(n3) && n3.length ? n3.forEach((o2) => { - r2 || V$1(o2) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, chain ${o2} should be a string and conform to "namespace:chainId" format`)); - }) : V$1(e) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, 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"] }`)), r2; -} -function sn(e, n3, t2) { - let r2 = null; - return Object.entries(e).forEach(([o2, s2]) => { - if (r2) - return; - const i2 = on(o2, L$1(o2, s2), `${n3} ${t2}`); - i2 && (r2 = i2); - }), r2; -} -function cn(e, n3) { - let t2 = null; - return k(e) ? e.forEach((r2) => { - t2 || rn(r2) || (t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, account ${r2} should be a string and conform to "namespace:chainId:address" format`)); - }) : t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), t2; -} -function an(e, n3) { - let t2 = null; - return Object.values(e).forEach((r2) => { - if (t2) - return; - const o2 = cn(r2 == null ? void 0 : r2.accounts, `${n3} namespace`); - o2 && (t2 = o2); - }), t2; -} -function un(e, n3) { - let t2 = null; - return ie(e == null ? void 0 : e.methods) ? ie(e == null ? void 0 : e.events) || (t2 = U$2("UNSUPPORTED_EVENTS", `${n3}, events should be an array of strings or empty array for no events`)) : t2 = U$2("UNSUPPORTED_METHODS", `${n3}, methods should be an array of strings or empty array for no methods`), t2; -} -function ce$2(e, n3) { - let t2 = null; - return Object.values(e).forEach((r2) => { - if (t2) - return; - const o2 = un(r2, `${n3}, namespace`); - o2 && (t2 = o2); - }), t2; -} -function Ht$1(e, n3, t2) { - let r2 = null; - if (e && B$1(e)) { - const o2 = ce$2(e, n3); - o2 && (r2 = o2); - const s2 = sn(e, n3, t2); - s2 && (r2 = s2); - } else - r2 = N$1("MISSING_OR_INVALID", `${n3}, ${t2} should be an object with data`); - return r2; -} -function ln(e, n3) { - let t2 = null; - if (e && B$1(e)) { - const r2 = ce$2(e, n3); - r2 && (t2 = r2); - const o2 = an(e, n3); - o2 && (t2 = o2); - } else - t2 = N$1("MISSING_OR_INVALID", `${n3}, namespaces should be an object with data`); - return t2; -} -function dn(e) { - return g$3(e.protocol, true); -} -function qt$1(e, n3) { - let t2 = false; - return n3 && !e ? t2 = true : e && k(e) && e.length && e.forEach((r2) => { - t2 = dn(r2); - }), t2; -} -function Bt$1(e) { - return typeof e == "number"; -} -function Gt$1(e) { - return typeof e < "u" && typeof e !== null; -} -function Wt(e) { - return !(!e || typeof e != "object" || !e.code || !G$1(e.code, false) || !e.message || !g$3(e.message, false)); -} -function zt$1(e) { - return !(w$3(e) || !g$3(e.method, false)); -} -function Yt$1(e) { - return !(w$3(e) || w$3(e.result) && w$3(e.error) || !G$1(e.id, false) || !g$3(e.jsonrpc, false)); -} -function Jt$1(e) { - return !(w$3(e) || !g$3(e.name, false)); -} -function Qt(e, n3) { - return !(!V$1(n3) || !Qe$1(e).includes(n3)); -} -function Zt(e, n3, t2) { - return g$3(t2, false) ? Ze$1(e, n3).includes(t2) : false; -} -function Xt(e, n3, t2) { - return g$3(t2, false) ? Xe$1(e, n3).includes(t2) : false; -} -function fn(e, n3, t2) { - let r2 = null; - const o2 = er$1(e), s2 = nr$1(n3), i2 = Object.keys(o2), d3 = Object.keys(s2), l2 = pn(Object.keys(e)), c2 = pn(Object.keys(n3)), u3 = l2.filter((a3) => !c2.includes(a3)); - return u3.length && (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces keys don't satisfy requiredNamespaces. - Required: ${u3.toString()} - Received: ${Object.keys(n3).toString()}`)), O$1(i2, d3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces chains don't satisfy required namespaces. - Required: ${i2.toString()} - Approved: ${d3.toString()}`)), Object.keys(n3).forEach((a3) => { - if (!a3.includes(":") || r2) - return; - const b3 = A$1(n3[a3].accounts); - b3.includes(a3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces accounts don't satisfy namespace accounts for ${a3} - Required: ${a3} - Approved: ${b3.toString()}`)); - }), i2.forEach((a3) => { - r2 || (O$1(o2[a3].methods, s2[a3].methods) ? O$1(o2[a3].events, s2[a3].events) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces events don't satisfy namespace events for ${a3}`)) : r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces methods don't satisfy namespace methods for ${a3}`)); - }), r2; -} -function er$1(e) { - const n3 = {}; - return Object.keys(e).forEach((t2) => { - var r2; - t2.includes(":") ? n3[t2] = e[t2] : (r2 = e[t2].chains) == null || r2.forEach((o2) => { - n3[o2] = { methods: e[t2].methods, events: e[t2].events }; - }); - }), n3; -} -function pn(e) { - return [...new Set(e.map((n3) => n3.includes(":") ? n3.split(":")[0] : n3))]; -} -function nr$1(e) { - const n3 = {}; - return Object.keys(e).forEach((t2) => { - if (t2.includes(":")) - n3[t2] = e[t2]; - else { - const r2 = A$1(e[t2].accounts); - r2 == null ? void 0 : r2.forEach((o2) => { - n3[o2] = { accounts: e[t2].accounts.filter((s2) => s2.includes(`${o2}:`)), methods: e[t2].methods, events: e[t2].events }; - }); - } - }), n3; -} -function tr$1(e, n3) { - return G$1(e, false) && e <= n3.max && e >= n3.min; -} -function rr$1() { - const e = R$2(); - return new Promise((n3) => { - switch (e) { - case m$1.browser: - n3(mn()); - break; - case m$1.reactNative: - n3(yn()); - break; - case m$1.node: - n3(gn()); - break; - default: - n3(true); - } - }); -} -function mn() { - return D$2() && (navigator == null ? void 0 : navigator.onLine); -} -async function yn() { - if ($$1() && typeof global < "u" && global != null && global.NetInfo) { - const e = await (global == null ? void 0 : global.NetInfo.fetch()); - return e == null ? void 0 : e.isConnected; - } - return true; -} -function gn() { - return true; -} -function or$1(e) { - switch (R$2()) { - case m$1.browser: - hn(e); - break; - case m$1.reactNative: - vn(e); - break; - } -} -function hn(e) { - !$$1() && D$2() && (window.addEventListener("online", () => e(true)), window.addEventListener("offline", () => e(false))); -} -function vn(e) { - $$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((n3) => e(n3 == null ? void 0 : n3.isConnected))); -} -const ae$1 = {}; -let sr$1 = class sr { - static get(n3) { - return ae$1[n3]; - } - static set(n3, t2) { - ae$1[n3] = t2; - } - static delete(n3) { - delete ae$1[n3]; - } -}; -const PARSE_ERROR = "PARSE_ERROR"; -const INVALID_REQUEST = "INVALID_REQUEST"; -const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; -const INVALID_PARAMS = "INVALID_PARAMS"; -const INTERNAL_ERROR = "INTERNAL_ERROR"; -const SERVER_ERROR = "SERVER_ERROR"; -const RESERVED_ERROR_CODES = [-32700, -32600, -32601, -32602, -32603]; -const STANDARD_ERROR_MAP = { - [PARSE_ERROR]: { code: -32700, message: "Parse error" }, - [INVALID_REQUEST]: { code: -32600, message: "Invalid Request" }, - [METHOD_NOT_FOUND]: { code: -32601, message: "Method not found" }, - [INVALID_PARAMS]: { code: -32602, message: "Invalid params" }, - [INTERNAL_ERROR]: { code: -32603, message: "Internal error" }, - [SERVER_ERROR]: { code: -32e3, message: "Server error" } -}; -const DEFAULT_ERROR = SERVER_ERROR; -function isReservedErrorCode(code) { - return RESERVED_ERROR_CODES.includes(code); -} -function getError(type2) { - if (!Object.keys(STANDARD_ERROR_MAP).includes(type2)) { - return STANDARD_ERROR_MAP[DEFAULT_ERROR]; - } - return STANDARD_ERROR_MAP[type2]; -} -function getErrorByCode(code) { - const match = Object.values(STANDARD_ERROR_MAP).find((e) => e.code === code); - if (!match) { - return STANDARD_ERROR_MAP[DEFAULT_ERROR]; - } - return match; -} -function parseConnectionError(e, url, type2) { - return e.message.includes("getaddrinfo ENOTFOUND") || e.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${type2} RPC url at ${url}`) : e; -} -var cjs = {}; -var crypto$1 = {}; -var hasRequiredCrypto; -function requireCrypto() { - if (hasRequiredCrypto) - return crypto$1; - hasRequiredCrypto = 1; - Object.defineProperty(crypto$1, "__esModule", { value: true }); - crypto$1.isBrowserCryptoAvailable = crypto$1.getSubtleCrypto = crypto$1.getBrowerCrypto = void 0; - function getBrowerCrypto() { - return (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.crypto) || (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.msCrypto) || {}; - } - crypto$1.getBrowerCrypto = getBrowerCrypto; - function getSubtleCrypto() { - const browserCrypto = getBrowerCrypto(); - return browserCrypto.subtle || browserCrypto.webkitSubtle; - } - crypto$1.getSubtleCrypto = getSubtleCrypto; - function isBrowserCryptoAvailable() { - return !!getBrowerCrypto() && !!getSubtleCrypto(); - } - crypto$1.isBrowserCryptoAvailable = isBrowserCryptoAvailable; - return crypto$1; -} -var env = {}; -var hasRequiredEnv; -function requireEnv() { - if (hasRequiredEnv) - return env; - hasRequiredEnv = 1; - Object.defineProperty(env, "__esModule", { value: true }); - env.isBrowser = env.isNode = env.isReactNative = void 0; - function isReactNative() { - return typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative"; - } - env.isReactNative = isReactNative; - function isNode() { - return typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined"; - } - env.isNode = isNode; - function isBrowser() { - return !isReactNative() && !isNode(); - } - env.isBrowser = isBrowser; - return env; -} -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireCrypto(), exports2); - tslib_1.__exportStar(requireEnv(), exports2); -})(cjs); -function payloadId(entropy = 3) { - const date = Date.now() * Math.pow(10, entropy); - const extra = Math.floor(Math.random() * Math.pow(10, entropy)); - return date + extra; -} -function getBigIntRpcId(entropy = 6) { - return BigInt(payloadId(entropy)); -} -function formatJsonRpcRequest(method, params, id) { - return { - id: id || payloadId(), - jsonrpc: "2.0", - method, - params - }; -} -function formatJsonRpcResult(id, result) { - return { - id, - jsonrpc: "2.0", - result - }; -} -function formatJsonRpcError(id, error, data) { - return { - id, - jsonrpc: "2.0", - error: formatErrorMessage(error, data) - }; -} -function formatErrorMessage(error, data) { - if (typeof error === "undefined") { - return getError(INTERNAL_ERROR); - } - if (typeof error === "string") { - error = Object.assign(Object.assign({}, getError(SERVER_ERROR)), { message: error }); - } - if (typeof data !== "undefined") { - error.data = data; - } - if (isReservedErrorCode(error.code)) { - error = getErrorByCode(error.code); - } - return error; -} -class IEvents2 { -} -class IBaseJsonRpcProvider extends IEvents2 { - constructor() { - super(); - } -} -class IJsonRpcProvider extends IBaseJsonRpcProvider { - constructor(connection2) { - super(); - } -} -const WS_REGEX = "^wss?:"; -function getUrlProtocol(url) { - const matches = url.match(new RegExp(/^\w+:/, "gi")); - if (!matches || !matches.length) - return; - return matches[0]; -} -function matchRegexProtocol(url, regex) { - const protocol = getUrlProtocol(url); - if (typeof protocol === "undefined") - return false; - return new RegExp(regex).test(protocol); -} -function isWsUrl(url) { - return matchRegexProtocol(url, WS_REGEX); -} -function isLocalhostUrl(url) { - return new RegExp("wss?://localhost(:d{2,5})?").test(url); -} -function isJsonRpcPayload(payload) { - return typeof payload === "object" && "id" in payload && "jsonrpc" in payload && payload.jsonrpc === "2.0"; -} -function isJsonRpcRequest(payload) { - return isJsonRpcPayload(payload) && "method" in payload; -} -function isJsonRpcResponse(payload) { - return isJsonRpcPayload(payload) && (isJsonRpcResult(payload) || isJsonRpcError(payload)); -} -function isJsonRpcResult(payload) { - return "result" in payload; -} -function isJsonRpcError(payload) { - return "error" in payload; -} -class JsonRpcProvider extends IJsonRpcProvider { - constructor(connection2) { - super(connection2); - this.events = new eventsExports.EventEmitter(); - this.hasRegisteredEventListeners = false; - this.connection = this.setConnection(connection2); - if (this.connection.connected) { - this.registerEventListeners(); - } - } - async connect(connection2 = this.connection) { - await this.open(connection2); - } - async disconnect() { - await this.close(); - } - on(event, listener) { - this.events.on(event, listener); - } - once(event, listener) { - this.events.once(event, listener); - } - off(event, listener) { - this.events.off(event, listener); - } - removeListener(event, listener) { - this.events.removeListener(event, listener); - } - async request(request, context) { - return this.requestStrict(formatJsonRpcRequest(request.method, request.params || [], request.id || getBigIntRpcId().toString()), context); - } - async requestStrict(request, context) { - return new Promise(async (resolve, reject) => { - if (!this.connection.connected) { - try { - await this.open(); - } catch (e) { - reject(e); - } - } - this.events.on(`${request.id}`, (response) => { - if (isJsonRpcError(response)) { - reject(response.error); - } else { - resolve(response.result); - } - }); - try { - await this.connection.send(request, context); - } catch (e) { - reject(e); - } - }); - } - setConnection(connection2 = this.connection) { - return connection2; - } - onPayload(payload) { - this.events.emit("payload", payload); - if (isJsonRpcResponse(payload)) { - this.events.emit(`${payload.id}`, payload); - } else { - this.events.emit("message", { - type: payload.method, - data: payload.params - }); - } - } - onClose(event) { - if (event && event.code === 3e3) { - this.events.emit("error", new Error(`WebSocket connection closed abnormally with code: ${event.code} ${event.reason ? `(${event.reason})` : ""}`)); - } - this.events.emit("disconnect"); - } - async open(connection2 = this.connection) { - if (this.connection === connection2 && this.connection.connected) - return; - if (this.connection.connected) - this.close(); - if (typeof connection2 === "string") { - await this.connection.open(connection2); - connection2 = this.connection; - } - this.connection = this.setConnection(connection2); - await this.connection.open(); - this.registerEventListeners(); - this.events.emit("connect"); - } - async close() { - await this.connection.close(); - } - registerEventListeners() { - if (this.hasRegisteredEventListeners) - return; - this.connection.on("payload", (payload) => this.onPayload(payload)); - this.connection.on("close", (event) => this.onClose(event)); - this.connection.on("error", (error) => this.events.emit("error", error)); - this.connection.on("register_error", (error) => this.onClose()); - this.hasRegisteredEventListeners = true; - } -} -const w$2 = () => 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 : (() => {try { return require("ws") } catch (e) { } })(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a$1 = (c2) => c2.split("?")[0], h$1 = 10, S$1 = w$2(); -class f { - constructor(e) { - if (this.url = e, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(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, t2) { - this.events.on(e, t2); - } - once(e, t2) { - this.events.once(e, t2); - } - off(e, t2) { - this.events.off(e, t2); - } - removeListener(e, t2) { - this.events.removeListener(e, t2); - } - async open(e = this.url) { - await this.register(e); - } - async close() { - return new Promise((e, t2) => { - if (typeof this.socket > "u") { - t2(new Error("Connection already closed")); - return; - } - this.socket.onclose = (n3) => { - this.onClose(n3), e(); - }, this.socket.close(); - }); - } - async send(e) { - typeof this.socket > "u" && (this.socket = await this.register()); - try { - this.socket.send(safeJsonStringify(e)); - } catch (t2) { - this.onError(e.id, t2); - } - } - register(e = this.url) { - if (!isWsUrl(e)) - throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`); - if (this.registering) { - const t2 = this.events.getMaxListeners(); - return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n3, o2) => { - this.events.once("register_error", (s2) => { - this.resetMaxListeners(), o2(s2); - }), this.events.once("open", () => { - if (this.resetMaxListeners(), typeof this.socket > "u") - return o2(new Error("WebSocket connection is missing or invalid")); - n3(this.socket); - }); - }); - } - return this.url = e, this.registering = true, new Promise((t2, n3) => { - const o2 = new URLSearchParams(e).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e) }, i2 = new S$1(e, [], s2); - b2() ? i2.onerror = (r2) => { - const l2 = r2; - n3(this.emitError(l2.error)); - } : i2.on("error", (r2) => { - n3(this.emitError(r2)); - }), i2.onopen = () => { - this.onOpen(i2), t2(i2); - }; - }); - } - onOpen(e) { - e.onmessage = (t2) => this.onPayload(t2), e.onclose = (t2) => this.onClose(t2), this.socket = e, this.registering = false, this.events.emit("open"); - } - onClose(e) { - this.socket = void 0, this.registering = false, this.events.emit("close", e); - } - onPayload(e) { - if (typeof e.data > "u") - return; - const t2 = typeof e.data == "string" ? safeJsonParse(e.data) : e.data; - this.events.emit("payload", t2); - } - onError(e, t2) { - const n3 = this.parseError(t2), o2 = n3.message || n3.toString(), s2 = formatJsonRpcError(e, o2); - this.events.emit("payload", s2); - } - parseError(e, t2 = this.url) { - return parseConnectionError(e, a$1(t2), "WS"); - } - resetMaxListeners() { - this.events.getMaxListeners() > h$1 && this.events.setMaxListeners(h$1); - } - emitError(e) { - const t2 = this.parseError(new Error((e == null ? void 0 : e.message) || `WebSocket connection failed for host: ${a$1(this.url)}`)); - return this.events.emit("register_error", t2), t2; - } -} -var lodash_isequal = { exports: {} }; -lodash_isequal.exports; -(function(module2, exports2) { - var LARGE_ARRAY_SIZE = 200; - var HASH_UNDEFINED = "__lodash_hash_undefined__"; - var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; - var MAX_SAFE_INTEGER = 9007199254740991; - var argsTag = "[object Arguments]", arrayTag = "[object Array]", asyncTag = "[object AsyncFunction]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", nullTag = "[object Null]", objectTag = "[object Object]", promiseTag = "[object Promise]", proxyTag = "[object Proxy]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", undefinedTag = "[object Undefined]", weakMapTag = "[object WeakMap]"; - var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; - var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - var reIsHostCtor = /^\[object .+?Constructor\]$/; - var reIsUint = /^(?:0|[1-9]\d*)$/; - var typedArrayTags = {}; - typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; - typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; - var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; - var freeSelf = typeof self == "object" && self && self.Object === Object && self; - var root = freeGlobal || freeSelf || Function("return this")(); - var freeExports = exports2 && !exports2.nodeType && exports2; - var freeModule = freeExports && true && module2 && !module2.nodeType && module2; - var moduleExports = freeModule && freeModule.exports === freeExports; - var freeProcess = moduleExports && freeGlobal.process; - var nodeUtil = function() { - try { - return freeProcess && freeProcess.binding && freeProcess.binding("util"); - } catch (e) { - } - }(); - var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - function arrayFilter(array, predicate) { - var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result[resIndex++] = value; - } - } - return result; - } - function arrayPush(array, values) { - var index = -1, length = values.length, offset = array.length; - while (++index < length) { - array[offset + index] = values[index]; - } - return array; - } - function arraySome(array, predicate) { - var index = -1, length = array == null ? 0 : array.length; - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; - } - function baseTimes(n3, iteratee) { - var index = -1, result = Array(n3); - while (++index < n3) { - result[index] = iteratee(index); - } - return result; - } - function baseUnary(func) { - return function(value) { - return func(value); - }; - } - function cacheHas(cache, key) { - return cache.has(key); - } - function getValue(object, key) { - return object == null ? void 0 : object[key]; - } - function mapToArray(map) { - var index = -1, result = Array(map.size); - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; - } - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - function setToArray(set2) { - var index = -1, result = Array(set2.size); - set2.forEach(function(value) { - result[++index] = value; - }); - return result; - } - var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype; - var coreJsData = root["__core-js_shared__"]; - var funcToString = funcProto.toString; - var hasOwnProperty = objectProto.hasOwnProperty; - var maskSrcKey = function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); - return uid ? "Symbol(src)_1." + uid : ""; - }(); - var nativeObjectToString = objectProto.toString; - var reIsNative = RegExp( - "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" - ); - var Buffer2 = moduleExports ? root.Buffer : void 0, Symbol2 = root.Symbol, Uint8Array2 = root.Uint8Array, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0; - var nativeGetSymbols = Object.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0, nativeKeys = overArg(Object.keys, Object); - var DataView2 = getNative(root, "DataView"), Map2 = getNative(root, "Map"), Promise2 = getNative(root, "Promise"), Set2 = getNative(root, "Set"), WeakMap2 = getNative(root, "WeakMap"), nativeCreate = getNative(Object, "create"); - var dataViewCtorString = toSource(DataView2), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2); - var symbolProto = Symbol2 ? Symbol2.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0; - function Hash(entries) { - var index = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; - this.size = 0; - } - function hashDelete(key) { - var result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; - return result; - } - function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? void 0 : result; - } - return hasOwnProperty.call(data, key) ? data[key] : void 0; - } - function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key); - } - function hashSet(key, value) { - var data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value; - return this; - } - Hash.prototype.clear = hashClear; - Hash.prototype["delete"] = hashDelete; - Hash.prototype.get = hashGet; - Hash.prototype.has = hashHas; - Hash.prototype.set = hashSet; - function ListCache(entries) { - var index = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - function listCacheClear() { - this.__data__ = []; - this.size = 0; - } - function listCacheDelete(key) { - var data = this.__data__, index = assocIndexOf(data, key); - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - --this.size; - return true; - } - function listCacheGet(key) { - var data = this.__data__, index = assocIndexOf(data, key); - return index < 0 ? void 0 : data[index][1]; - } - function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; - } - function listCacheSet(key, value) { - var data = this.__data__, index = assocIndexOf(data, key); - if (index < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; - } - ListCache.prototype.clear = listCacheClear; - ListCache.prototype["delete"] = listCacheDelete; - ListCache.prototype.get = listCacheGet; - ListCache.prototype.has = listCacheHas; - ListCache.prototype.set = listCacheSet; - function MapCache(entries) { - var index = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - function mapCacheClear() { - this.size = 0; - this.__data__ = { - "hash": new Hash(), - "map": new (Map2 || ListCache)(), - "string": new Hash() - }; - } - function mapCacheDelete(key) { - var result = getMapData(this, key)["delete"](key); - this.size -= result ? 1 : 0; - return result; - } - function mapCacheGet(key) { - return getMapData(this, key).get(key); - } - function mapCacheHas(key) { - return getMapData(this, key).has(key); - } - function mapCacheSet(key, value) { - var data = getMapData(this, key), size = data.size; - data.set(key, value); - this.size += data.size == size ? 0 : 1; - return this; - } - MapCache.prototype.clear = mapCacheClear; - MapCache.prototype["delete"] = mapCacheDelete; - MapCache.prototype.get = mapCacheGet; - MapCache.prototype.has = mapCacheHas; - MapCache.prototype.set = mapCacheSet; - function SetCache(values) { - var index = -1, length = values == null ? 0 : values.length; - this.__data__ = new MapCache(); - while (++index < length) { - this.add(values[index]); - } - } - function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; - } - function setCacheHas(value) { - return this.__data__.has(value); - } - SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; - SetCache.prototype.has = setCacheHas; - function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; - } - function stackClear() { - this.__data__ = new ListCache(); - this.size = 0; - } - function stackDelete(key) { - var data = this.__data__, result = data["delete"](key); - this.size = data.size; - return result; - } - function stackGet(key) { - return this.__data__.get(key); - } - function stackHas(key) { - return this.__data__.has(key); - } - function stackSet(key, value) { - var data = this.__data__; - if (data instanceof ListCache) { - var pairs = data.__data__; - if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); - } - data.set(key, value); - this.size = data.size; - return this; - } - Stack.prototype.clear = stackClear; - Stack.prototype["delete"] = stackDelete; - Stack.prototype.get = stackGet; - Stack.prototype.has = stackHas; - Stack.prototype.set = stackSet; - function arrayLikeKeys(value, inherited) { - var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. - (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. - isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. - isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. - isIndex(key, length)))) { - result.push(key); - } - } - return result; - } - function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; - } - function baseGetAllKeys(object, keysFunc, symbolsFunc) { - var result = keysFunc(object); - return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); - } - function baseGetTag(value) { - if (value == null) { - return value === void 0 ? undefinedTag : nullTag; - } - return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); - } - function baseIsArguments(value) { - return isObjectLike(value) && baseGetTag(value) == argsTag; - } - function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); - } - function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { - var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other); - objTag = objTag == argsTag ? objectTag : objTag; - othTag = othTag == argsTag ? objectTag : othTag; - var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; - if (isSameTag && isBuffer(object)) { - if (!isBuffer(other)) { - return false; - } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack || (stack = new Stack()); - return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__"); - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; - stack || (stack = new Stack()); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack()); - return equalObjects(object, other, bitmask, customizer, equalFunc, stack); - } - function baseIsNative(value) { - if (!isObject2(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); - } - function baseIsTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; - } - function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != "constructor") { - result.push(key); - } - } - return result; - } - function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : void 0; - stack.set(array, other); - stack.set(other, array); - while (++index < arrLength) { - var arrValue = array[index], othValue = other[index]; - if (customizer) { - var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== void 0) { - if (compared) { - continue; - } - result = false; - break; - } - if (seen) { - if (!arraySome(other, function(othValue2, othIndex) { - if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - result = false; - break; - } - } - stack["delete"](array); - stack["delete"](other); - return result; - } - function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { - case dataViewTag: - if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { - return false; - } - object = object.buffer; - other = other.buffer; - case arrayBufferTag: - if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) { - return false; - } - return true; - case boolTag: - case dateTag: - case numberTag: - return eq(+object, +other); - case errorTag: - return object.name == other.name && object.message == other.message; - case regexpTag: - case stringTag: - return object == other + ""; - case mapTag: - var convert2 = mapToArray; - case setTag: - var isPartial = bitmask & COMPARE_PARTIAL_FLAG; - convert2 || (convert2 = setToArray); - if (object.size != other.size && !isPartial) { - return false; - } - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG; - stack.set(object, other); - var result = equalArrays(convert2(object), convert2(other), bitmask, customizer, equalFunc, stack); - stack["delete"](object); - return result; - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; - } - function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - var result = true; - stack.set(object, other); - stack.set(other, object); - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], othValue = other[key]; - if (customizer) { - var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); - } - if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { - result = false; - break; - } - skipCtor || (skipCtor = key == "constructor"); - } - if (result && !skipCtor) { - var objCtor = object.constructor, othCtor = other.constructor; - if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { - result = false; - } - } - stack["delete"](object); - stack["delete"](other); - return result; - } - function getAllKeys(object) { - return baseGetAllKeys(object, keys2, getSymbols); - } - function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; - } - function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : void 0; - } - function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; - try { - value[symToStringTag] = void 0; - var unmasked = true; - } catch (e) { - } - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; - } - var getSymbols = !nativeGetSymbols ? stubArray : function(object) { - if (object == null) { - return []; - } - object = Object(object); - return arrayFilter(nativeGetSymbols(object), function(symbol) { - return propertyIsEnumerable.call(object, symbol); - }); - }; - var getTag = baseGetTag; - if (DataView2 && getTag(new DataView2(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) { - getTag = function(value) { - var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : ""; - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: - return dataViewTag; - case mapCtorString: - return mapTag; - case promiseCtorString: - return promiseTag; - case setCtorString: - return setTag; - case weakMapCtorString: - return weakMapTag; - } - } - return result; - }; - } - function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); - } - function isKeyable(value) { - var type2 = typeof value; - return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null; - } - function isMasked(func) { - return !!maskSrcKey && maskSrcKey in func; - } - function isPrototype(value) { - var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto; - return value === proto; - } - function objectToString(value) { - return nativeObjectToString.call(value); - } - function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) { - } - try { - return func + ""; - } catch (e) { - } - } - return ""; - } - function eq(value, other) { - return value === other || value !== value && other !== other; - } - var isArguments = baseIsArguments(/* @__PURE__ */ function() { - return arguments; - }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); - }; - var isArray = Array.isArray; - function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); - } - var isBuffer = nativeIsBuffer || stubFalse; - function isEqual(value, other) { - return baseIsEqual(value, other); - } - function isFunction(value) { - if (!isObject2(value)) { - return false; - } - var tag = baseGetTag(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; - } - function isLength(value) { - return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - function isObject2(value) { - var type2 = typeof value; - return value != null && (type2 == "object" || type2 == "function"); - } - function isObjectLike(value) { - return value != null && typeof value == "object"; - } - var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - function keys2(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); - } - function stubArray() { - return []; - } - function stubFalse() { - return false; - } - module2.exports = isEqual; -})(lodash_isequal, lodash_isequal.exports); -var lodash_isequalExports = lodash_isequal.exports; -const Gi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); -function unfetch_module(e, n3) { - return n3 = n3 || {}, new Promise(function(t2, r2) { - var s2 = new XMLHttpRequest(), o2 = [], u3 = [], i2 = {}, a3 = function() { - return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() { - return Promise.resolve(s2.responseText); - }, json: function() { - return Promise.resolve(s2.responseText).then(JSON.parse); - }, blob: function() { - return Promise.resolve(new Blob([s2.response])); - }, clone: a3, headers: { keys: function() { - return o2; - }, entries: function() { - return u3; - }, get: function(e2) { - return i2[e2.toLowerCase()]; - }, has: function(e2) { - return e2.toLowerCase() in i2; - } } }; - }; - for (var l2 in s2.open(n3.method || "get", e, true), s2.onload = function() { - s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e2, n4, t3) { - o2.push(n4 = n4.toLowerCase()), u3.push([n4, t3]), i2[n4] = i2[n4] ? i2[n4] + "," + t3 : t3; - }), t2(a3()); - }, s2.onerror = r2, s2.withCredentials = "include" == n3.credentials, n3.headers) - s2.setRequestHeader(l2, n3.headers[l2]); - s2.send(n3.body || null); - }); -} -const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: unfetch_module -}, Symbol.toStringTag, { value: "Module" })); -const require$$0 = /* @__PURE__ */ getAugmentedNamespace(unfetch_module$1); -var browser$2 = fetch || (self.fetch = require$$0.default || require$$0); -const Yi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); -function Hi(n3, e) { - if (n3.length >= 255) - throw new TypeError("Alphabet too long"); - for (var t2 = new Uint8Array(256), i2 = 0; i2 < t2.length; i2++) - t2[i2] = 255; - for (var s2 = 0; s2 < n3.length; s2++) { - var r2 = n3.charAt(s2), o2 = r2.charCodeAt(0); - if (t2[o2] !== 255) - throw new TypeError(r2 + " is ambiguous"); - t2[o2] = s2; - } - var a3 = n3.length, h4 = n3.charAt(0), l2 = Math.log(a3) / Math.log(256), d3 = Math.log(256) / Math.log(a3); - function p3(u3) { - if (u3 instanceof Uint8Array || (ArrayBuffer.isView(u3) ? u3 = new Uint8Array(u3.buffer, u3.byteOffset, u3.byteLength) : Array.isArray(u3) && (u3 = Uint8Array.from(u3))), !(u3 instanceof Uint8Array)) - throw new TypeError("Expected Uint8Array"); - if (u3.length === 0) - return ""; - for (var m2 = 0, z3 = 0, I2 = 0, _3 = u3.length; I2 !== _3 && u3[I2] === 0; ) - I2++, m2++; - for (var T2 = (_3 - I2) * d3 + 1 >>> 0, f2 = new Uint8Array(T2); I2 !== _3; ) { - for (var S2 = u3[I2], A2 = 0, C2 = T2 - 1; (S2 !== 0 || A2 < z3) && C2 !== -1; C2--, A2++) - S2 += 256 * f2[C2] >>> 0, f2[C2] = S2 % a3 >>> 0, S2 = S2 / a3 >>> 0; - if (S2 !== 0) - throw new Error("Non-zero carry"); - z3 = A2, I2++; - } - for (var x2 = T2 - z3; x2 !== T2 && f2[x2] === 0; ) - x2++; - for (var j2 = h4.repeat(m2); x2 < T2; ++x2) - j2 += n3.charAt(f2[x2]); - return j2; - } - function y3(u3) { - if (typeof u3 != "string") - throw new TypeError("Expected String"); - if (u3.length === 0) - return new Uint8Array(); - var m2 = 0; - if (u3[m2] !== " ") { - for (var z3 = 0, I2 = 0; u3[m2] === h4; ) - z3++, m2++; - for (var _3 = (u3.length - m2) * l2 + 1 >>> 0, T2 = new Uint8Array(_3); u3[m2]; ) { - var f2 = t2[u3.charCodeAt(m2)]; - if (f2 === 255) - return; - for (var S2 = 0, A2 = _3 - 1; (f2 !== 0 || S2 < I2) && A2 !== -1; A2--, S2++) - f2 += a3 * T2[A2] >>> 0, T2[A2] = f2 % 256 >>> 0, f2 = f2 / 256 >>> 0; - if (f2 !== 0) - throw new Error("Non-zero carry"); - I2 = S2, m2++; - } - if (u3[m2] !== " ") { - for (var C2 = _3 - I2; C2 !== _3 && T2[C2] === 0; ) - C2++; - for (var x2 = new Uint8Array(z3 + (_3 - C2)), j2 = z3; C2 !== _3; ) - x2[j2++] = T2[C2++]; - return x2; - } - } - } - function M2(u3) { - var m2 = y3(u3); - if (m2) - return m2; - throw new Error(`Non-${e} character`); - } - return { encode: p3, decodeUnsafe: y3, decode: M2 }; -} -var Ji = Hi, Xi = Ji; -const Ne = (n3) => { - if (n3 instanceof Uint8Array && n3.constructor.name === "Uint8Array") - return n3; - if (n3 instanceof ArrayBuffer) - return new Uint8Array(n3); - if (ArrayBuffer.isView(n3)) - return new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength); - throw new Error("Unknown type, must be binary type"); -}, Wi = (n3) => new TextEncoder().encode(n3), Qi = (n3) => new TextDecoder().decode(n3); -class Zi { - constructor(e, t2, i2) { - this.name = e, this.prefix = t2, this.baseEncode = i2; - } - encode(e) { - if (e instanceof Uint8Array) - return `${this.prefix}${this.baseEncode(e)}`; - throw Error("Unknown type, must be binary type"); - } -} -class es { - constructor(e, t2, i2) { - if (this.name = e, this.prefix = t2, t2.codePointAt(0) === void 0) - throw new Error("Invalid prefix character"); - this.prefixCodePoint = t2.codePointAt(0), this.baseDecode = i2; - } - 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 Ue(this, e); - } -} -class ts { - constructor(e) { - this.decoders = e; - } - or(e) { - return Ue(this, e); - } - decode(e) { - const t2 = e[0], i2 = this.decoders[t2]; - if (i2) - return i2.decode(e); - throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); - } -} -const Ue = (n3, e) => new ts({ ...n3.decoders || { [n3.prefix]: n3 }, ...e.decoders || { [e.prefix]: e } }); -class is { - constructor(e, t2, i2, s2) { - this.name = e, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new Zi(e, t2, i2), this.decoder = new es(e, t2, s2); - } - encode(e) { - return this.encoder.encode(e); - } - decode(e) { - return this.decoder.decode(e); - } -} -const W$1 = ({ name: n3, prefix: e, encode: t2, decode: i2 }) => new is(n3, e, t2, i2), B = ({ prefix: n3, name: e, alphabet: t2 }) => { - const { encode: i2, decode: s2 } = Xi(t2, e); - return W$1({ prefix: n3, name: e, encode: i2, decode: (r2) => Ne(s2(r2)) }); -}, ss = (n3, e, t2, i2) => { - const s2 = {}; - for (let d3 = 0; d3 < e.length; ++d3) - s2[e[d3]] = d3; - let r2 = n3.length; - for (; n3[r2 - 1] === "="; ) - --r2; - const o2 = new Uint8Array(r2 * t2 / 8 | 0); - let a3 = 0, h4 = 0, l2 = 0; - for (let d3 = 0; d3 < r2; ++d3) { - const p3 = s2[n3[d3]]; - if (p3 === void 0) - throw new SyntaxError(`Non-${i2} character`); - h4 = h4 << t2 | p3, a3 += t2, a3 >= 8 && (a3 -= 8, o2[l2++] = 255 & h4 >> a3); - } - if (a3 >= t2 || 255 & h4 << 8 - a3) - throw new SyntaxError("Unexpected end of data"); - return o2; -}, rs = (n3, e, t2) => { - const i2 = e[e.length - 1] === "=", s2 = (1 << t2) - 1; - let r2 = "", o2 = 0, a3 = 0; - for (let h4 = 0; h4 < n3.length; ++h4) - for (a3 = a3 << 8 | n3[h4], o2 += 8; o2 > t2; ) - o2 -= t2, r2 += e[s2 & a3 >> o2]; - if (o2 && (r2 += e[s2 & a3 << t2 - o2]), i2) - for (; r2.length * t2 & 7; ) - r2 += "="; - return r2; -}, g$2 = ({ name: n3, prefix: e, bitsPerChar: t2, alphabet: i2 }) => W$1({ prefix: e, name: n3, encode(s2) { - return rs(s2, i2, t2); -}, decode(s2) { - return ss(s2, i2, t2, n3); -} }), ns = W$1({ prefix: "\0", name: "identity", encode: (n3) => Qi(n3), decode: (n3) => Wi(n3) }); -var os = Object.freeze({ __proto__: null, identity: ns }); -const as$1 = g$2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); -var hs$1 = Object.freeze({ __proto__: null, base2: as$1 }); -const cs$1 = g$2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); -var us$1 = Object.freeze({ __proto__: null, base8: cs$1 }); -const ls$1 = B({ prefix: "9", name: "base10", alphabet: "0123456789" }); -var ds$1 = Object.freeze({ __proto__: null, base10: ls$1 }); -const gs$1 = g$2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), ps$1 = g$2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); -var Ds = Object.freeze({ __proto__: null, base16: gs$1, base16upper: ps$1 }); -const ys = g$2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), ms$1 = g$2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), bs = g$2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), fs = g$2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), Es = g$2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), ws = g$2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), vs = g$2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Is = g$2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), Cs = g$2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); -var Rs = Object.freeze({ __proto__: null, base32: ys, base32upper: ms$1, base32pad: bs, base32padupper: fs, base32hex: Es, base32hexupper: ws, base32hexpad: vs, base32hexpadupper: Is, base32z: Cs }); -const _s = B({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ts = B({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); -var Ss = Object.freeze({ __proto__: null, base36: _s, base36upper: Ts }); -const Ps = B({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), xs = B({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); -var Os = Object.freeze({ __proto__: null, base58btc: Ps, base58flickr: xs }); -const As = g$2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), zs = g$2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ns = g$2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us = g$2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); -var Ls = Object.freeze({ __proto__: null, base64: As, base64pad: zs, base64url: Ns, base64urlpad: Us }); -const Le = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), $s = Le.reduce((n3, e, t2) => (n3[t2] = e, n3), []), Fs = Le.reduce((n3, e, t2) => (n3[e.codePointAt(0)] = t2, n3), []); -function Ms(n3) { - return n3.reduce((e, t2) => (e += $s[t2], e), ""); -} -function ks(n3) { - const e = []; - for (const t2 of n3) { - const i2 = Fs[t2.codePointAt(0)]; - if (i2 === void 0) - throw new Error(`Non-base256emoji character: ${t2}`); - e.push(i2); - } - return new Uint8Array(e); -} -const Ks = W$1({ prefix: "🚀", name: "base256emoji", encode: Ms, decode: ks }); -var Bs = Object.freeze({ __proto__: null, base256emoji: Ks }), Vs = Fe, $e = 128, qs = 127, js = ~qs, Gs = Math.pow(2, 31); -function Fe(n3, e, t2) { - e = e || [], t2 = t2 || 0; - for (var i2 = t2; n3 >= Gs; ) - e[t2++] = n3 & 255 | $e, n3 /= 128; - for (; n3 & js; ) - e[t2++] = n3 & 255 | $e, n3 >>>= 7; - return e[t2] = n3 | 0, Fe.bytes = t2 - i2 + 1, e; -} -var Ys = he$1, Hs = 128, Me = 127; -function he$1(n3, i2) { - var t2 = 0, i2 = i2 || 0, s2 = 0, r2 = i2, o2, a3 = n3.length; - do { - if (r2 >= a3) - throw he$1.bytes = 0, new RangeError("Could not decode varint"); - o2 = n3[r2++], t2 += s2 < 28 ? (o2 & Me) << s2 : (o2 & Me) * Math.pow(2, s2), s2 += 7; - } while (o2 >= Hs); - return he$1.bytes = r2 - i2, t2; -} -var Js = Math.pow(2, 7), Xs = Math.pow(2, 14), Ws = Math.pow(2, 21), Qs = Math.pow(2, 28), Zs = Math.pow(2, 35), er = Math.pow(2, 42), tr = Math.pow(2, 49), ir = Math.pow(2, 56), sr2 = Math.pow(2, 63), rr = function(n3) { - return n3 < Js ? 1 : n3 < Xs ? 2 : n3 < Ws ? 3 : n3 < Qs ? 4 : n3 < Zs ? 5 : n3 < er ? 6 : n3 < tr ? 7 : n3 < ir ? 8 : n3 < sr2 ? 9 : 10; -}, nr = { encode: Vs, decode: Ys, encodingLength: rr }, ke = nr; -const Ke = (n3, e, t2 = 0) => (ke.encode(n3, e, t2), e), Be = (n3) => ke.encodingLength(n3), ce$1 = (n3, e) => { - const t2 = e.byteLength, i2 = Be(n3), s2 = i2 + Be(t2), r2 = new Uint8Array(s2 + t2); - return Ke(n3, r2, 0), Ke(t2, r2, i2), r2.set(e, s2), new or(n3, t2, e, r2); -}; -class or { - constructor(e, t2, i2, s2) { - this.code = e, this.size = t2, this.digest = i2, this.bytes = s2; - } -} -const Ve = ({ name: n3, code: e, encode: t2 }) => new ar(n3, e, t2); -class ar { - constructor(e, t2, i2) { - this.name = e, this.code = t2, this.encode = i2; - } - digest(e) { - if (e instanceof Uint8Array) { - const t2 = this.encode(e); - return t2 instanceof Uint8Array ? ce$1(this.code, t2) : t2.then((i2) => ce$1(this.code, i2)); - } else - throw Error("Unknown type, must be binary type"); - } -} -const qe = (n3) => async (e) => new Uint8Array(await crypto.subtle.digest(n3, e)), hr = Ve({ name: "sha2-256", code: 18, encode: qe("SHA-256") }), cr = Ve({ name: "sha2-512", code: 19, encode: qe("SHA-512") }); -var ur = Object.freeze({ __proto__: null, sha256: hr, sha512: cr }); -const je = 0, lr = "identity", Ge = Ne, dr = (n3) => ce$1(je, Ge(n3)), gr = { code: je, name: lr, encode: Ge, digest: dr }; -var pr = Object.freeze({ __proto__: null, identity: gr }); -new TextEncoder(), new TextDecoder(); -const Ye = { ...os, ...hs$1, ...us$1, ...ds$1, ...Ds, ...Rs, ...Ss, ...Os, ...Ls, ...Bs }; -({ ...ur, ...pr }); -function He(n3) { - return globalThis.Buffer != null ? new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength) : n3; -} -function Dr(n3 = 0) { - return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? He(globalThis.Buffer.allocUnsafe(n3)) : new Uint8Array(n3); -} -function Je(n3, e, t2, i2) { - return { name: n3, prefix: e, encoder: { name: n3, prefix: e, encode: t2 }, decoder: { decode: i2 } }; -} -const Xe = Je("utf8", "u", (n3) => "u" + new TextDecoder("utf8").decode(n3), (n3) => new TextEncoder().encode(n3.substring(1))), ue$1 = Je("ascii", "a", (n3) => { - let e = "a"; - for (let t2 = 0; t2 < n3.length; t2++) - e += String.fromCharCode(n3[t2]); - return e; -}, (n3) => { - n3 = n3.substring(1); - const e = Dr(n3.length); - for (let t2 = 0; t2 < n3.length; t2++) - e[t2] = n3.charCodeAt(t2); - return e; -}), yr = { utf8: Xe, "utf-8": Xe, hex: Ye.base16, latin1: ue$1, ascii: ue$1, binary: ue$1, ...Ye }; -function mr(n3, e = "utf8") { - const t2 = yr[e]; - if (!t2) - throw new Error(`Unsupported encoding "${e}"`); - return (e === "utf8" || e === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? He(globalThis.Buffer.from(n3, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n3}`); -} -const le$1 = "wc", We = 2, Q$1 = "core", O = `${le$1}@2:${Q$1}:`, Qe = { name: Q$1, logger: "error" }, Ze = { database: ":memory:" }, et = "crypto", de$1 = "client_ed25519_seed", tt = cjs$4.ONE_DAY, it = "keychain", st = "0.3", rt = "messages", nt = "0.3", ot = cjs$4.SIX_HOURS, at = "publisher", ht = "irn", ct = "error", ge$1 = "wss://relay.walletconnect.com", pe$1 = "wss://relay.walletconnect.org", ut = "relayer", D$1 = { 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" }, lt = "_subscription", P$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, dt = cjs$4.ONE_SECOND, gt = "2.11.2", pt = 1e4, Dt = "0.3", yt = "WALLETCONNECT_CLIENT_ID", w$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, mt = "subscription", bt = "0.3", ft = cjs$4.FIVE_SECONDS * 1e3, Et = "pairing", wt = "0.3", $ = { wc_pairingDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 } } }, V = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, R$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, vt = "history", It = "0.3", Ct = "expirer", v2 = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Rt = "0.3", Z = "verify-api", F$1 = "https://verify.walletconnect.com", ee = "https://verify.walletconnect.org", _t = [F$1, ee], Tt = "echo", St = "https://echo.walletconnect.com"; -class Pt { - constructor(e, t2) { - this.core = e, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = it, this.version = st, this.initialized = false, this.storagePrefix = O, this.init = async () => { - if (!this.initialized) { - const i2 = await this.getKeyChain(); - typeof i2 < "u" && (this.keychain = i2), this.initialized = true; - } - }, this.has = (i2) => (this.isInitialized(), this.keychain.has(i2)), this.set = async (i2, s2) => { - this.isInitialized(), this.keychain.set(i2, s2), await this.persist(); - }, this.get = (i2) => { - this.isInitialized(); - const s2 = this.keychain.get(i2); - if (typeof s2 > "u") { - const { message: r2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${i2}`); - throw new Error(r2); - } - return s2; - }, this.del = async (i2) => { - this.isInitialized(), this.keychain.delete(i2), await this.persist(); - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - get storageKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; - } - async setKeyChain(e) { - await this.core.storage.setItem(this.storageKey, rt$1(e)); - } - async getKeyChain() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? ot$1(e) : void 0; - } - async persist() { - await this.setKeyChain(this.keychain); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class xt { - constructor(e, t2, i2) { - this.core = e, this.logger = t2, this.name = et, this.initialized = false, this.init = async () => { - this.initialized || (await this.keychain.init(), this.initialized = true); - }, this.hasKeys = (s2) => (this.isInitialized(), this.keychain.has(s2)), this.getClientId = async () => { - this.isInitialized(); - const s2 = await this.getClientSeed(), r2 = generateKeyPair(s2); - return encodeIss(r2.publicKey); - }, this.generateKeyPair = () => { - this.isInitialized(); - const s2 = kn(); - return this.setPrivateKey(s2.publicKey, s2.privateKey); - }, this.signJWT = async (s2) => { - this.isInitialized(); - const r2 = await this.getClientSeed(), o2 = generateKeyPair(r2), a3 = Vn(), h4 = tt; - return await signJWT(a3, s2, h4, o2); - }, this.generateSharedKey = (s2, r2, o2) => { - this.isInitialized(); - const a3 = this.getPrivateKey(s2), h4 = Mn(a3, r2); - return this.setSymKey(h4, o2); - }, this.setSymKey = async (s2, r2) => { - this.isInitialized(); - const o2 = r2 || Kn(s2); - return await this.keychain.set(o2, s2), o2; - }, this.deleteKeyPair = async (s2) => { - this.isInitialized(), await this.keychain.del(s2); - }, this.deleteSymKey = async (s2) => { - this.isInitialized(), await this.keychain.del(s2); - }, this.encode = async (s2, r2, o2) => { - this.isInitialized(); - const a3 = Ae(o2), h4 = safeJsonStringify(r2); - if (qn(a3)) { - const y3 = a3.senderPublicKey, M2 = a3.receiverPublicKey; - s2 = await this.generateSharedKey(y3, M2); - } - const l2 = this.getSymKey(s2), { type: d3, senderPublicKey: p3 } = a3; - return xn({ type: d3, symKey: l2, message: h4, senderPublicKey: p3 }); - }, this.decode = async (s2, r2, o2) => { - this.isInitialized(); - const a3 = Hn(r2, o2); - if (qn(a3)) { - const h4 = a3.receiverPublicKey, l2 = a3.senderPublicKey; - s2 = await this.generateSharedKey(h4, l2); - } - try { - const h4 = this.getSymKey(s2), l2 = Fn({ symKey: h4, encoded: r2 }); - return safeJsonParse(l2); - } catch (h4) { - this.logger.error(`Failed to decode message from topic: '${s2}', clientId: '${await this.getClientId()}'`), this.logger.error(h4); - } - }, this.getPayloadType = (s2) => { - const r2 = ee$1(s2); - return j$1(r2.type); - }, this.getPayloadSenderPublicKey = (s2) => { - const r2 = ee$1(s2); - return r2.senderPublicKey ? toString(r2.senderPublicKey, p$1) : void 0; - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.keychain = i2 || new Pt(this.core, this.logger); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - async setPrivateKey(e, t2) { - return await this.keychain.set(e, t2), e; - } - getPrivateKey(e) { - return this.keychain.get(e); - } - async getClientSeed() { - let e = ""; - try { - e = this.keychain.get(de$1); - } catch { - e = Vn(), await this.keychain.set(de$1, e); - } - return mr(e, "base16"); - } - getSymKey(e) { - return this.keychain.get(e); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class Ot extends a$2 { - constructor(e, t2) { - super(e, t2), this.logger = e, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = rt, this.version = nt, this.initialized = false, this.storagePrefix = O, this.init = async () => { - if (!this.initialized) { - this.logger.trace("Initialized"); - try { - const i2 = await this.getRelayerMessages(); - typeof i2 < "u" && (this.messages = i2), this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", size: this.messages.size }); - } catch (i2) { - this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(i2); - } finally { - this.initialized = true; - } - } - }, this.set = async (i2, s2) => { - this.isInitialized(); - const r2 = Ln(s2); - let o2 = this.messages.get(i2); - return typeof o2 > "u" && (o2 = {}), typeof o2[r2] < "u" || (o2[r2] = s2, this.messages.set(i2, o2), await this.persist()), r2; - }, this.get = (i2) => { - this.isInitialized(); - let s2 = this.messages.get(i2); - return typeof s2 > "u" && (s2 = {}), s2; - }, this.has = (i2, s2) => { - this.isInitialized(); - const r2 = this.get(i2), o2 = Ln(s2); - return typeof r2[o2] < "u"; - }, this.del = async (i2) => { - this.isInitialized(), this.messages.delete(i2), await this.persist(); - }, this.logger = cjs$3.generateChildLogger(e, this.name), this.core = t2; - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - get storageKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; - } - async setRelayerMessages(e) { - await this.core.storage.setItem(this.storageKey, rt$1(e)); - } - async getRelayerMessages() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? ot$1(e) : void 0; - } - async persist() { - await this.setRelayerMessages(this.messages); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class vr extends u$1 { - constructor(e, t2) { - super(e, t2), this.relayer = e, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = at, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$4.toMiliseconds(cjs$4.TEN_SECONDS * 2), this.needsTransportRestart = false, this.publish = async (i2, s2, r2) => { - var o2; - this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); - try { - const a3 = (r2 == null ? void 0 : r2.ttl) || ot, h4 = vt$1(r2), l2 = (r2 == null ? void 0 : r2.prompt) || false, d3 = (r2 == null ? void 0 : r2.tag) || 0, p3 = (r2 == null ? void 0 : r2.id) || getBigIntRpcId().toString(), y3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d3, id: p3 } }, M2 = setTimeout(() => this.queue.set(p3, y3), this.publishTimeout); - try { - await await ut$1(this.rpcPublish(i2, s2, a3, h4, l2, d3, p3), this.publishTimeout, `Failed to publish payload, please try again. id:${p3} tag:${d3}`), this.removeRequestFromQueue(p3), this.relayer.events.emit(D$1.publish, y3); - } catch (u3) { - if (this.logger.debug("Publishing Payload stalled"), this.needsTransportRestart = true, (o2 = r2 == null ? void 0 : r2.internal) != null && o2.throwOnFailedPublish) - throw this.removeRequestFromQueue(p3), u3; - return; - } finally { - clearTimeout(M2); - } - this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); - } catch (a3) { - throw this.logger.debug("Failed to Publish Payload"), this.logger.error(a3), a3; - } - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.relayer = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.registerEventListeners(); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - rpcPublish(e, t2, i2, s2, r2, o2, a3) { - var h4, l2, d3, p3; - const y3 = { method: Et$1(s2.protocol).publish, params: { topic: e, message: t2, ttl: i2, prompt: r2, tag: o2 }, id: a3 }; - return w$3((h4 = y3.params) == null ? void 0 : h4.prompt) && ((l2 = y3.params) == null || delete l2.prompt), w$3((d3 = y3.params) == null ? void 0 : d3.tag) && ((p3 = y3.params) == null || delete p3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: y3 }), this.relayer.request(y3); - } - removeRequestFromQueue(e) { - this.queue.delete(e); - } - checkQueue() { - this.queue.forEach(async (e) => { - const { topic: t2, message: i2, opts: s2 } = e; - await this.publish(t2, i2, s2); - }); - } - registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { - if (this.needsTransportRestart) { - this.needsTransportRestart = false, this.relayer.events.emit(D$1.connection_stalled); - return; - } - this.checkQueue(); - }), this.relayer.on(D$1.message_ack, (e) => { - this.removeRequestFromQueue(e.id.toString()); - }); - } -} -class Ir { - constructor() { - this.map = /* @__PURE__ */ new Map(), this.set = (e, t2) => { - const i2 = this.get(e); - this.exists(e, t2) || this.map.set(e, [...i2, t2]); - }, this.get = (e) => this.map.get(e) || [], this.exists = (e, t2) => this.get(e).includes(t2), this.delete = (e, t2) => { - if (typeof t2 > "u") { - this.map.delete(e); - return; - } - if (!this.map.has(e)) - return; - const i2 = this.get(e); - if (!this.exists(e, t2)) - return; - const s2 = i2.filter((r2) => r2 !== t2); - if (!s2.length) { - this.map.delete(e); - return; - } - this.map.set(e, s2); - }, this.clear = () => { - this.map.clear(); - }; - } - get topics() { - return Array.from(this.map.keys()); - } -} -var Cr = Object.defineProperty, Rr = Object.defineProperties, _r = Object.getOwnPropertyDescriptors, At = Object.getOwnPropertySymbols, Tr = Object.prototype.hasOwnProperty, Sr = Object.prototype.propertyIsEnumerable, zt = (n3, e, t2) => e in n3 ? Cr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, q$1 = (n3, e) => { - for (var t2 in e || (e = {})) - Tr.call(e, t2) && zt(n3, t2, e[t2]); - if (At) - for (var t2 of At(e)) - Sr.call(e, t2) && zt(n3, t2, e[t2]); - return n3; -}, De = (n3, e) => Rr(n3, _r(e)); -class Nt extends d2 { - constructor(e, t2) { - super(e, t2), this.relayer = e, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Ir(), this.events = new eventsExports.EventEmitter(), this.name = mt, this.version = bt, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = O, this.subscribeTimeout = 1e4, this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), this.clientId = await this.relayer.core.crypto.getClientId()); - }, this.subscribe = async (i2, s2) => { - await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }); - try { - const r2 = vt$1(s2), o2 = { topic: i2, relay: r2 }; - this.pending.set(i2, o2); - const a3 = await this.rpcSubscribe(i2, r2); - return this.onSubscribe(a3, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }), a3; - } catch (r2) { - throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r2), r2; - } - }, this.unsubscribe = async (i2, s2) => { - await this.restartToComplete(), this.isInitialized(), typeof (s2 == null ? void 0 : s2.id) < "u" ? await this.unsubscribeById(i2, s2.id, s2) : await this.unsubscribeByTopic(i2, s2); - }, this.isSubscribed = async (i2) => { - if (this.topics.includes(i2)) - return true; - const s2 = `${this.pendingSubscriptionWatchLabel}_${i2}`; - return await new Promise((r2, o2) => { - const a3 = new cjs$4.Watch(); - a3.start(s2); - const h4 = setInterval(() => { - !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r2(true)), a3.elapsed(s2) >= ft && (clearInterval(h4), a3.stop(s2), o2(new Error("Subscription resolution timeout"))); - }, this.pollingInterval); - }).catch(() => false); - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.restart = async () => { - this.restartInProgress = true, await this.restore(), await this.reset(), this.restartInProgress = false; - }, this.relayer = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.clientId = ""; - } - get context() { - return cjs$3.getLoggerContext(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, t2) { - let i2 = false; - try { - i2 = this.getSubscription(e).topic === t2; - } catch { - } - return i2; - } - onEnable() { - this.cached = [], this.initialized = true; - } - onDisable() { - this.cached = this.values, this.subscriptions.clear(), this.topicMap.clear(); - } - async unsubscribeByTopic(e, t2) { - const i2 = this.topicMap.get(e); - await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e, s2, t2))); - } - async unsubscribeById(e, t2, i2) { - this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: t2, opts: i2 } }); - try { - const s2 = vt$1(i2); - await this.rpcUnsubscribe(e, t2, s2); - const r2 = U$2("USER_DISCONNECTED", `${this.name}, ${e}`); - await this.onUnsubscribe(e, t2, r2), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: t2, opts: i2 } }); - } catch (s2) { - throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s2), s2; - } - } - async rpcSubscribe(e, t2) { - const i2 = { method: Et$1(t2.protocol).subscribe, params: { topic: e } }; - this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); - try { - await await ut$1(this.relayer.request(i2), this.subscribeTimeout); - } catch { - this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(D$1.connection_stalled); - } - return Ln(e + this.clientId); - } - async rpcBatchSubscribe(e) { - if (!e.length) - return; - const t2 = e[0].relay, i2 = { method: Et$1(t2.protocol).batchSubscribe, params: { topics: e.map((s2) => s2.topic) } }; - this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); - try { - return await await ut$1(this.relayer.request(i2), this.subscribeTimeout); - } catch { - this.logger.debug("Outgoing Relay Payload stalled"), this.relayer.events.emit(D$1.connection_stalled); - } - } - rpcUnsubscribe(e, t2, i2) { - const s2 = { method: Et$1(i2.protocol).unsubscribe, params: { topic: e, id: t2 } }; - return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s2 }), this.relayer.request(s2); - } - onSubscribe(e, t2) { - this.setSubscription(e, De(q$1({}, t2), { id: e })), this.pending.delete(t2.topic); - } - onBatchSubscribe(e) { - e.length && e.forEach((t2) => { - this.setSubscription(t2.id, q$1({}, t2)), this.pending.delete(t2.topic); - }); - } - async onUnsubscribe(e, t2, i2) { - this.events.removeAllListeners(t2), this.hasSubscription(t2, e) && this.deleteSubscription(t2, i2), 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, t2) { - this.subscriptions.has(e) || (this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e, subscription: t2 }), this.addSubscription(e, t2)); - } - addSubscription(e, t2) { - this.subscriptions.set(e, q$1({}, t2)), this.topicMap.set(t2.topic, e), this.events.emit(w$1.created, t2); - } - getSubscription(e) { - this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e }); - const t2 = this.subscriptions.get(e); - if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw new Error(i2); - } - return t2; - } - deleteSubscription(e, t2) { - this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e, reason: t2 }); - const i2 = this.getSubscription(e); - this.subscriptions.delete(e), this.topicMap.delete(i2.topic, e), this.events.emit(w$1.deleted, De(q$1({}, i2), { reason: t2 })); - } - async persist() { - await this.setRelayerSubscriptions(this.values), this.events.emit(w$1.sync); - } - async reset() { - if (this.cached.length) { - const e = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); - for (let t2 = 0; t2 < e; t2++) { - const i2 = this.cached.splice(0, this.batchSubscribeTopicsLimit); - await this.batchSubscribe(i2); - } - } - this.events.emit(w$1.resubscribed); - } - async restore() { - try { - const e = await this.getRelayerSubscriptions(); - if (typeof e > "u" || !e.length) - return; - if (this.subscriptions.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); - } - 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; - const t2 = await this.rpcBatchSubscribe(e); - k(t2) && this.onBatchSubscribe(t2.map((i2, s2) => De(q$1({}, e[s2]), { id: i2 }))); - } - async onConnect() { - this.restartInProgress || (await this.restart(), this.onEnable()); - } - onDisconnect() { - this.onDisable(); - } - async checkPending() { - if (!this.initialized || this.relayer.transportExplicitlyClosed) - return; - const e = []; - this.pending.forEach((t2) => { - e.push(t2); - }), await this.batchSubscribe(e); - } - registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, async () => { - await this.checkPending(); - }), this.relayer.on(D$1.connect, async () => { - await this.onConnect(); - }), this.relayer.on(D$1.disconnect, () => { - this.onDisconnect(); - }), this.events.on(w$1.created, async (e) => { - const t2 = w$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), await this.persist(); - }), this.events.on(w$1.deleted, async (e) => { - const t2 = w$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), await this.persist(); - }); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - async restartToComplete() { - this.restartInProgress && await new Promise((e) => { - const t2 = setInterval(() => { - this.restartInProgress || (clearInterval(t2), e()); - }, this.pollingInterval); - }); - } -} -var Pr = Object.defineProperty, Ut = Object.getOwnPropertySymbols, xr = Object.prototype.hasOwnProperty, Or = Object.prototype.propertyIsEnumerable, Lt = (n3, e, t2) => e in n3 ? Pr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, Ar = (n3, e) => { - for (var t2 in e || (e = {})) - xr.call(e, t2) && Lt(n3, t2, e[t2]); - if (Ut) - for (var t2 of Ut(e)) - Or.call(e, t2) && Lt(n3, t2, e[t2]); - return n3; -}; -class $t extends g$4 { - constructor(e) { - super(e), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = ut, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.request = async (t2) => { - this.logger.debug("Publishing Request Payload"); - const i2 = t2.id; - try { - await this.toEstablishConnection(); - const s2 = this.provider.request(t2); - return this.requestsInFlight.set(i2, { promise: s2, request: t2 }), await s2; - } catch (s2) { - throw this.logger.debug("Failed to Publish Request"), this.logger.error(s2), s2; - } finally { - this.requestsInFlight.delete(i2); - } - }, this.onPayloadHandler = (t2) => { - this.onProviderPayload(t2); - }, this.onConnectHandler = () => { - this.events.emit(D$1.connect); - }, this.onDisconnectHandler = () => { - this.onProviderDisconnect(); - }, this.onProviderErrorHandler = (t2) => { - this.logger.error(t2), this.events.emit(D$1.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); - }, this.registerProviderListeners = () => { - this.provider.on(P$1.payload, this.onPayloadHandler), this.provider.on(P$1.connect, this.onConnectHandler), this.provider.on(P$1.disconnect, this.onDisconnectHandler), this.provider.on(P$1.error, this.onProviderErrorHandler); - }, this.core = e.core, this.logger = typeof e.logger < "u" && typeof e.logger != "string" ? cjs$3.generateChildLogger(e.logger, this.name) : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: e.logger || ct })), this.messages = new Ot(this.logger, e.core), this.subscriber = new Nt(this, this.logger), this.publisher = new vr(this, this.logger), this.relayUrl = (e == null ? void 0 : e.relayUrl) || ge$1, this.projectId = e.projectId, this.bundleId = Jn(), this.provider = {}; - } - async init() { - this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); - try { - await this.transportOpen(); - } catch { - this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$1}...`), await this.restartTransport(pe$1); - } - this.initialized = true, setTimeout(async () => { - this.subscriber.topics.length === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); - }, pt); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - get connected() { - return this.provider.connection.connected; - } - get connecting() { - return this.provider.connection.connecting; - } - async publish(e, t2, i2) { - this.isInitialized(), await this.publisher.publish(e, t2, i2), await this.recordMessageEvent({ topic: e, message: t2, publishedAt: Date.now() }); - } - async subscribe(e, t2) { - var i2; - this.isInitialized(); - let s2 = ((i2 = this.subscriber.topicMap.get(e)) == null ? void 0 : i2[0]) || ""; - if (s2) - return s2; - let r2; - const o2 = (a3) => { - a3.topic === e && (this.subscriber.off(w$1.created, o2), r2()); - }; - return await Promise.all([new Promise((a3) => { - r2 = a3, this.subscriber.on(w$1.created, o2); - }), new Promise(async (a3) => { - s2 = await this.subscriber.subscribe(e, t2), a3(); - })]), s2; - } - async unsubscribe(e, t2) { - this.isInitialized(), await this.subscriber.unsubscribe(e, t2); - } - on(e, t2) { - this.events.on(e, t2); - } - once(e, t2) { - this.events.once(e, t2); - } - off(e, t2) { - this.events.off(e, t2); - } - removeListener(e, t2) { - this.events.removeListener(e, t2); - } - async transportClose() { - this.requestsInFlight.size > 0 && (this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."), this.requestsInFlight.forEach(async (e) => { - await e.promise; - })), this.transportExplicitlyClosed = true, this.hasExperiencedNetworkDisruption && this.connected ? await ut$1(this.provider.disconnect(), 1e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.connected && await this.provider.disconnect(); - } - async transportOpen(e) { - if (this.transportExplicitlyClosed = false, await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress) { - e && e !== this.relayUrl && (this.relayUrl = e, await this.transportClose(), await this.createProvider()), this.connectionAttemptInProgress = true; - try { - await Promise.all([new Promise((t2) => { - if (!this.initialized) - return t2(); - this.subscriber.once(w$1.resubscribed, () => { - t2(); - }); - }), new Promise(async (t2, i2) => { - try { - await ut$1(this.provider.connect(), 1e4, `Socket stalled when trying to connect to ${this.relayUrl}`); - } catch (s2) { - i2(s2); - return; - } - t2(); - })]); - } catch (t2) { - this.logger.error(t2); - const i2 = t2; - if (!this.isConnectionStalled(i2.message)) - throw t2; - this.provider.events.emit(P$1.disconnect); - } finally { - this.connectionAttemptInProgress = false, this.hasExperiencedNetworkDisruption = false; - } - } - } - async restartTransport(e) { - await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress && (this.relayUrl = e || this.relayUrl, await this.transportClose(), await this.createProvider(), await this.transportOpen()); - } - async confirmOnlineStateOrThrow() { - if (!await rr$1()) - throw new Error("No internet connection detected. Please restart your network and try again."); - } - isConnectionStalled(e) { - return this.staleConnectionErrors.some((t2) => e.includes(t2)); - } - async createProvider() { - this.provider.connection && this.unregisterProviderListeners(); - const e = await this.core.crypto.signJWT(this.relayUrl); - this.provider = new JsonRpcProvider(new f(Xn({ sdkVersion: gt, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); - } - async recordMessageEvent(e) { - const { topic: t2, message: i2 } = e; - await this.messages.set(t2, i2); - } - async shouldIgnoreMessageEvent(e) { - const { topic: t2, message: i2 } = e; - if (!i2 || i2.length === 0) - return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; - if (!await this.subscriber.isSubscribed(t2)) - return this.logger.debug(`Ignoring message for non-subscribed topic ${t2}`), true; - const s2 = this.messages.has(t2, i2); - return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; - } - async onProviderPayload(e) { - if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e }), isJsonRpcRequest(e)) { - if (!e.method.endsWith(lt)) - return; - const t2 = e.params, { topic: i2, message: s2, publishedAt: r2 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r2 }; - this.logger.debug("Emitting Relayer Payload"), this.logger.trace(Ar({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e), await this.onMessageEvent(o2); - } else - isJsonRpcResponse(e) && this.events.emit(D$1.message_ack, e); - } - async onMessageEvent(e) { - await this.shouldIgnoreMessageEvent(e) || (this.events.emit(D$1.message, e), await this.recordMessageEvent(e)); - } - async acknowledgePayload(e) { - const t2 = formatJsonRpcResult(e.id, true); - await this.provider.connection.send(t2); - } - unregisterProviderListeners() { - this.provider.off(P$1.payload, this.onPayloadHandler), this.provider.off(P$1.connect, this.onConnectHandler), this.provider.off(P$1.disconnect, this.onDisconnectHandler), this.provider.off(P$1.error, this.onProviderErrorHandler); - } - async registerEventListeners() { - this.events.on(D$1.connection_stalled, () => { - this.restartTransport().catch((t2) => this.logger.error(t2)); - }); - let e = await rr$1(); - or$1(async (t2) => { - this.initialized && e !== t2 && (e = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportClose().catch((i2) => this.logger.error(i2)))); - }); - } - onProviderDisconnect() { - this.events.emit(D$1.disconnect), this.attemptToReconnect(); - } - attemptToReconnect() { - this.transportExplicitlyClosed || (this.logger.info("attemptToReconnect called. Connecting..."), setTimeout(async () => { - await this.restartTransport().catch((e) => this.logger.error(e)); - }, cjs$4.toMiliseconds(dt))); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - async toEstablishConnection() { - if (await this.confirmOnlineStateOrThrow(), !this.connected) { - if (this.connectionAttemptInProgress) - return await new Promise((e) => { - const t2 = setInterval(() => { - this.connected && (clearInterval(t2), e()); - }, this.connectionStatusPollingInterval); - }); - await this.restartTransport(); - } - } -} -var zr = Object.defineProperty, Ft = Object.getOwnPropertySymbols, Nr = Object.prototype.hasOwnProperty, Ur = Object.prototype.propertyIsEnumerable, Mt = (n3, e, t2) => e in n3 ? zr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, kt = (n3, e) => { - for (var t2 in e || (e = {})) - Nr.call(e, t2) && Mt(n3, t2, e[t2]); - if (Ft) - for (var t2 of Ft(e)) - Ur.call(e, t2) && Mt(n3, t2, e[t2]); - return n3; -}; -class Kt extends p$2 { - constructor(e, t2, i2, s2 = O, r2 = void 0) { - super(e, t2, i2, s2), this.core = e, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = Dt, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o2) => { - this.getKey && o2 !== null && !w$3(o2) ? this.map.set(this.getKey(o2), o2) : Lt$1(o2) ? this.map.set(o2.id, o2) : xt$1(o2) && this.map.set(o2.topic, o2); - }), this.cached = [], this.initialized = true); - }, this.set = async (o2, a3) => { - this.isInitialized(), this.map.has(o2) ? await this.update(o2, a3) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o2, value: a3 }), this.map.set(o2, a3), await this.persist()); - }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a3) => Object.keys(o2).every((h4) => Gi(a3[h4], o2[h4]))) : this.values), this.update = async (o2, a3) => { - this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o2, update: a3 }); - const h4 = kt(kt({}, this.getData(o2)), a3); - this.map.set(o2, h4), await this.persist(); - }, this.delete = async (o2, a3) => { - this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a3 }), this.map.delete(o2), await this.persist()); - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.storagePrefix = s2, this.getKey = r2; - } - get context() { - return cjs$3.getLoggerContext(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()); - } - async setDataStore(e) { - await this.core.storage.setItem(this.storageKey, e); - } - async getDataStore() { - return await this.core.storage.getItem(this.storageKey); - } - getData(e) { - const t2 = this.map.get(e); - if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw this.logger.error(i2), new Error(i2); - } - return t2; - } - async persist() { - await this.setDataStore(this.values); - } - async restore() { - try { - const e = await this.getDataStore(); - if (typeof e > "u" || !e.length) - return; - if (this.map.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); - } - 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) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class Bt { - constructor(e, t2) { - this.core = e, this.logger = t2, this.name = Et, this.version = wt, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = O, this.ignoredPayloadTypes = [_$1], this.registeredMethods = [], this.init = async () => { - this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); - }, this.register = ({ methods: i2 }) => { - this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; - }, this.create = async () => { - this.isInitialized(); - const i2 = Vn(), s2 = await this.core.crypto.setSymKey(i2), r2 = pt$1(cjs$4.FIVE_MINUTES), o2 = { protocol: ht }, a3 = { topic: s2, expiry: r2, relay: o2, active: false }, h4 = Rt$1({ protocol: this.core.protocol, version: this.core.version, topic: s2, symKey: i2, relay: o2, expiryTimestamp: r2 }); - return await this.pairings.set(s2, a3), await this.core.relayer.subscribe(s2), this.core.expirer.set(s2, r2), { topic: s2, uri: h4 }; - }, this.pair = async (i2) => { - this.isInitialized(), this.isValidPair(i2); - const { topic: s2, symKey: r2, relay: o2, expiryTimestamp: a3 } = Pt$1(i2.uri); - let h4; - if (this.pairings.keys.includes(s2) && (h4 = this.pairings.get(s2), h4.active)) - throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); - const l2 = a3 || pt$1(cjs$4.FIVE_MINUTES), d3 = { topic: s2, relay: o2, expiry: l2, active: false }; - return await this.pairings.set(s2, d3), this.core.expirer.set(s2, l2), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V.create, d3), this.core.crypto.keychain.has(s2) || (await this.core.crypto.setSymKey(r2, s2), await this.core.relayer.subscribe(s2, { relay: o2 })), d3; - }, this.activate = async ({ topic: i2 }) => { - this.isInitialized(); - const s2 = pt$1(cjs$4.THIRTY_DAYS); - await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); - }, this.ping = async (i2) => { - this.isInitialized(), await this.isValidPing(i2); - const { topic: s2 } = i2; - if (this.pairings.keys.includes(s2)) { - const r2 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a3, reject: h4 } = at$1(); - this.events.once(yt$1("pairing_ping", r2), ({ error: l2 }) => { - l2 ? h4(l2) : a3(); - }), await o2(); - } - }, this.updateExpiry = async ({ topic: i2, expiry: s2 }) => { - this.isInitialized(), await this.pairings.update(i2, { expiry: s2 }); - }, this.updateMetadata = async ({ topic: i2, metadata: s2 }) => { - this.isInitialized(), await this.pairings.update(i2, { peerMetadata: s2 }); - }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { - this.isInitialized(), await this.isValidDisconnect(i2); - const { topic: s2 } = i2; - this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", U$2("USER_DISCONNECTED")), await this.deletePairing(s2)); - }, this.sendRequest = async (i2, s2, r2) => { - const o2 = formatJsonRpcRequest(s2, r2), a3 = await this.core.crypto.encode(i2, o2), h4 = $[s2].req; - return this.core.history.set(i2, o2), this.core.relayer.publish(i2, a3, h4), o2.id; - }, this.sendResult = async (i2, s2, r2) => { - const o2 = formatJsonRpcResult(i2, r2), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = $[h4.request.method].res; - await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); - }, this.sendError = async (i2, s2, r2) => { - const o2 = formatJsonRpcError(i2, r2), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = $[h4.request.method] ? $[h4.request.method].res : $.unregistered_method.res; - await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); - }, this.deletePairing = async (i2, s2) => { - await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, U$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); - }, this.cleanup = async () => { - const i2 = this.pairings.getAll().filter((s2) => mt$1(s2.expiry)); - await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); - }, this.onRelayEventRequest = (i2) => { - const { topic: s2, payload: r2 } = i2; - switch (r2.method) { - case "wc_pairingPing": - return this.onPairingPingRequest(s2, r2); - case "wc_pairingDelete": - return this.onPairingDeleteRequest(s2, r2); - default: - return this.onUnknownRpcMethodRequest(s2, r2); - } - }, this.onRelayEventResponse = async (i2) => { - const { topic: s2, payload: r2 } = i2, o2 = (await this.core.history.get(s2, r2.id)).request.method; - switch (o2) { - case "wc_pairingPing": - return this.onPairingPingResponse(s2, r2); - default: - return this.onUnknownRpcMethodResponse(o2); - } - }, this.onPairingPingRequest = async (i2, s2) => { - const { id: r2 } = s2; - try { - this.isValidPing({ topic: i2 }), await this.sendResult(r2, i2, true), this.events.emit(V.ping, { id: r2, topic: i2 }); - } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); - } - }, this.onPairingPingResponse = (i2, s2) => { - const { id: r2 } = s2; - setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("pairing_ping", r2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("pairing_ping", r2), { error: s2.error }); - }, 500); - }, this.onPairingDeleteRequest = async (i2, s2) => { - const { id: r2 } = s2; - try { - this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V.delete, { id: r2, topic: i2 }); - } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); - } - }, this.onUnknownRpcMethodRequest = async (i2, s2) => { - const { id: r2, method: o2 } = s2; - try { - if (this.registeredMethods.includes(o2)) - return; - const a3 = U$2("WC_METHOD_UNSUPPORTED", o2); - await this.sendError(r2, i2, a3), this.logger.error(a3); - } catch (a3) { - await this.sendError(r2, i2, a3), this.logger.error(a3); - } - }, this.onUnknownRpcMethodResponse = (i2) => { - this.registeredMethods.includes(i2) || this.logger.error(U$2("WC_METHOD_UNSUPPORTED", i2)); - }, this.isValidPair = (i2) => { - var s2; - if (!Gt$1(i2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `pair() params: ${i2}`); - throw new Error(o2); - } - if (!Kt$1(i2.uri)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); - throw new Error(o2); - } - const r2 = Pt$1(i2.uri); - if (!((s2 = r2 == null ? void 0 : r2.relay) != null && s2.protocol)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", "pair() uri#relay-protocol"); - throw new Error(o2); - } - if (!(r2 != null && r2.symKey)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", "pair() uri#symKey"); - throw new Error(o2); - } - if (r2 != null && r2.expiryTimestamp && cjs$4.toMiliseconds(r2 == null ? void 0 : r2.expiryTimestamp) < Date.now()) { - const { message: o2 } = N$1("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); - throw new Error(o2); - } - }, this.isValidPing = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `ping() params: ${i2}`); - throw new Error(r2); - } - const { topic: s2 } = i2; - await this.isValidPairingTopic(s2); - }, this.isValidDisconnect = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${i2}`); - throw new Error(r2); - } - const { topic: s2 } = i2; - await this.isValidPairingTopic(s2); - }, this.isValidPairingTopic = async (i2) => { - if (!g$3(i2, false)) { - const { message: s2 } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); - throw new Error(s2); - } - if (!this.pairings.keys.includes(i2)) { - const { message: s2 } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); - throw new Error(s2); - } - if (mt$1(this.pairings.get(i2).expiry)) { - await this.deletePairing(i2); - const { message: s2 } = N$1("EXPIRED", `pairing topic: ${i2}`); - throw new Error(s2); - } - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.pairings = new Kt(this.core, this.logger, this.name, this.storagePrefix); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - registerRelayerEvents() { - this.core.relayer.on(D$1.message, async (e) => { - const { topic: t2, message: i2 } = e; - if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) - return; - const s2 = await this.core.crypto.decode(t2, i2); - try { - isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); - } catch (r2) { - this.logger.error(r2); - } - }); - } - registerExpirerEvents() { - this.core.expirer.on(v2.expired, async (e) => { - const { topic: t2 } = ft$1(e.target); - t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V.expire, { topic: t2 })); - }); - } -} -class Vt extends h$2 { - constructor(e, t2) { - super(e, t2), this.core = e, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = vt, this.version = It, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.set = (i2, s2, r2) => { - if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r2 }), this.records.has(s2.id)) - return; - const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r2, expiry: pt$1(cjs$4.THIRTY_DAYS) }; - this.records.set(o2.id, o2), this.events.emit(R$1.created, o2); - }, this.resolve = async (i2) => { - if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) - return; - const s2 = await this.getRecord(i2.id); - typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.events.emit(R$1.updated, s2)); - }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { - this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r2) => { - if (r2.topic === i2) { - if (typeof s2 < "u" && r2.id !== s2) - return; - this.records.delete(r2.id), this.events.emit(R$1.deleted, r2); - } - }); - }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); - } - get context() { - return cjs$3.getLoggerContext(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() { - const e = []; - return this.values.forEach((t2) => { - if (typeof t2.response < "u") - return; - const i2 = { topic: t2.topic, request: formatJsonRpcRequest(t2.request.method, t2.request.params, t2.id), chainId: t2.chainId }; - return e.push(i2); - }), 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(); - const t2 = this.records.get(e); - if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw new Error(i2); - } - return t2; - } - async persist() { - await this.setJsonRpcRecords(this.values), this.events.emit(R$1.sync); - } - async restore() { - try { - const e = await this.getJsonRpcRecords(); - if (typeof e > "u" || !e.length) - return; - if (this.records.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); - } - 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(R$1.created, (e) => { - const t2 = R$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.events.on(R$1.updated, (e) => { - const t2 = R$1.updated; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.events.on(R$1.deleted, (e) => { - const t2 = R$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { - this.cleanup(); - }); - } - cleanup() { - try { - this.records.forEach((e) => { - cjs$4.toMiliseconds(e.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${e.id}`), this.delete(e.topic, e.id)); - }); - } catch (e) { - this.logger.warn(e); - } - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class qt extends E { - constructor(e, t2) { - super(e, t2), this.core = e, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = Rt, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.has = (i2) => { - try { - const s2 = this.formatTarget(i2); - return typeof this.getExpiration(s2) < "u"; - } catch { - return false; - } - }, this.set = (i2, s2) => { - this.isInitialized(); - const r2 = this.formatTarget(i2), o2 = { target: r2, expiry: s2 }; - this.expirations.set(r2, o2), this.checkExpiry(r2, o2), this.events.emit(v2.created, { target: r2, expiration: o2 }); - }, this.get = (i2) => { - this.isInitialized(); - const s2 = this.formatTarget(i2); - return this.getExpiration(s2); - }, this.del = (i2) => { - if (this.isInitialized(), this.has(i2)) { - const s2 = this.formatTarget(i2), r2 = this.getExpiration(s2); - this.expirations.delete(s2), this.events.emit(v2.deleted, { target: s2, expiration: r2 }); - } - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); - } - get context() { - return cjs$3.getLoggerContext(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 lt$1(e); - if (typeof e == "number") - return dt$1(e); - const { message: t2 } = N$1("UNKNOWN_TYPE", `Target type: ${typeof e}`); - throw new Error(t2); - } - 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(v2.sync); - } - async restore() { - try { - const e = await this.getExpirations(); - if (typeof e > "u" || !e.length) - return; - if (this.expirations.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); - } - 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) { - const t2 = this.expirations.get(e); - if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw this.logger.error(i2), new Error(i2); - } - return t2; - } - checkExpiry(e, t2) { - const { expiry: i2 } = t2; - cjs$4.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e, t2); - } - expire(e, t2) { - this.expirations.delete(e), this.events.emit(v2.expired, { target: e, expiration: t2 }); - } - checkExpirations() { - this.core.relayer.connected && this.expirations.forEach((e, t2) => this.checkExpiry(t2, e)); - } - registerEventListeners() { - this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(v2.created, (e) => { - const t2 = v2.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }), this.events.on(v2.expired, (e) => { - const t2 = v2.expired; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }), this.events.on(v2.deleted, (e) => { - const t2 = v2.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class jt extends y$1 { - constructor(e, t2) { - super(e, t2), this.projectId = e, this.logger = t2, this.name = Z, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { - if (this.verifyDisabled || $$1() || !D$2()) - return; - const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; - try { - await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2); - } - if (!this.initialized) { - this.removeIframe(), this.verifyUrl = ee; - try { - await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2), this.verifyDisabled = true; - } - } - }, this.register = async (i2) => { - this.initialized ? this.sendPost(i2.attestationId) : (this.addToQueue(i2.attestationId), await this.init()); - }, this.resolve = async (i2) => { - if (this.isDevEnv) - return ""; - const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - let r2; - try { - r2 = await this.fetchAttestation(i2.attestationId, s2); - } catch (o2) { - this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r2 = await this.fetchAttestation(i2.attestationId, ee); - } - return r2; - }, this.fetchAttestation = async (i2, s2) => { - this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); - const r2 = this.startAbortTimer(cjs$4.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); - return clearTimeout(r2), o2.status === 200 ? await o2.json() : void 0; - }, this.addToQueue = (i2) => { - this.queue.push(i2); - }, this.processQueue = () => { - this.queue.length !== 0 && (this.queue.forEach((i2) => this.sendPost(i2)), this.queue = []); - }, this.sendPost = (i2) => { - var s2; - try { - if (!this.iframe) - return; - (s2 = this.iframe.contentWindow) == null || s2.postMessage(i2, "*"), this.logger.info(`postMessage sent: ${i2} ${this.verifyUrl}`); - } catch { - } - }, this.createIframe = async () => { - let i2; - const s2 = (r2) => { - r2.data === "verify_ready" && (this.initialized = true, this.processQueue(), window.removeEventListener("message", s2), i2()); - }; - await Promise.race([new Promise((r2) => { - if (document.getElementById(Z)) - return r2(); - window.addEventListener("message", s2); - const o2 = document.createElement("iframe"); - o2.id = Z, o2.src = `${this.verifyUrl}/${this.projectId}`, o2.style.display = "none", document.body.append(o2), this.iframe = o2, i2 = r2; - }), new Promise((r2, o2) => setTimeout(() => { - window.removeEventListener("message", s2), o2("verify iframe load timeout"); - }, cjs$4.toMiliseconds(cjs$4.FIVE_SECONDS)))]); - }, this.removeIframe = () => { - this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); - }, this.getVerifyUrl = (i2) => { - let s2 = i2 || F$1; - return _t.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${F$1}`), s2 = F$1), s2; - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.verifyUrl = F$1, this.abortController = new AbortController(), this.isDevEnv = te$1() && process.env.IS_VITEST; - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - startAbortTimer(e) { - return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$4.toMiliseconds(e)); - } -} -class Gt extends v$1 { - constructor(e, t2) { - super(e, t2), this.projectId = e, this.logger = t2, this.context = Tt, this.registerDeviceToken = async (i2) => { - const { clientId: s2, token: r2, notificationType: o2, enableEncrypted: a3 = false } = i2, h4 = `${St}/${this.projectId}/clients`; - await Yi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r2, always_raw: a3 }) }); - }, this.logger = cjs$3.generateChildLogger(t2, this.context); - } -} -var Lr = Object.defineProperty, Yt = Object.getOwnPropertySymbols, $r = Object.prototype.hasOwnProperty, Fr = Object.prototype.propertyIsEnumerable, Ht = (n3, e, t2) => e in n3 ? Lr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, Jt = (n3, e) => { - for (var t2 in e || (e = {})) - $r.call(e, t2) && Ht(n3, t2, e[t2]); - if (Yt) - for (var t2 of Yt(e)) - Fr.call(e, t2) && Ht(n3, t2, e[t2]); - return n3; -}; -class te extends n$1 { - constructor(e) { - super(e), this.protocol = le$1, this.version = We, this.name = Q$1, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (i2, s2) => this.events.on(i2, s2), this.once = (i2, s2) => this.events.once(i2, s2), this.off = (i2, s2) => this.events.off(i2, s2), this.removeListener = (i2, s2) => this.events.removeListener(i2, s2), this.projectId = e == null ? void 0 : e.projectId, this.relayUrl = (e == null ? void 0 : e.relayUrl) || ge$1, this.customStoragePrefix = e != null && e.customStoragePrefix ? `:${e.customStoragePrefix}` : ""; - const t2 = typeof (e == null ? void 0 : e.logger) < "u" && typeof (e == null ? void 0 : e.logger) != "string" ? e.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (e == null ? void 0 : e.logger) || Qe.logger })); - this.logger = cjs$3.generateChildLogger(t2, this.name), this.heartbeat = new cjs$5.HeartBeat(), this.crypto = new xt(this, this.logger, e == null ? void 0 : e.keychain), this.history = new Vt(this, this.logger), this.expirer = new qt(this, this.logger), this.storage = e != null && e.storage ? e.storage : new h$3(Jt(Jt({}, Ze), e == null ? void 0 : e.storageOptions)), this.relayer = new $t({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new Bt(this, this.logger), this.verify = new jt(this.projectId || "", this.logger), this.echoClient = new Gt(this.projectId || "", this.logger); - } - static async init(e) { - const t2 = new te(e); - await t2.initialize(); - const i2 = await t2.crypto.getClientId(); - return await t2.storage.setItem(yt, i2), t2; - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - async start() { - this.initialized || await this.initialize(); - } - 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.initialized = true, 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; - } - } -} -const Mr = te; -const J = "wc", F = 2, X = "client", G = `${J}@${F}:${X}:`, M = { name: X, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, H = "WALLETCONNECT_DEEPLINK_CHOICE", oe = "proposal", ae = "Proposal expired", ce = "session", L = cjs$4.SEVEN_DAYS, le = "engine", R = { wc_sessionPropose: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1114 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1115 } } }, U$1 = { min: cjs$4.FIVE_MINUTES, max: cjs$4.SEVEN_DAYS }, I = { idle: "IDLE", active: "ACTIVE" }, pe = "request", he = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"]; -var as = Object.defineProperty, cs = Object.defineProperties, ls = Object.getOwnPropertyDescriptors, de = Object.getOwnPropertySymbols, ps = Object.prototype.hasOwnProperty, hs = Object.prototype.propertyIsEnumerable, ue = (w3, r2, e) => r2 in w3 ? as(w3, r2, { enumerable: true, configurable: true, writable: true, value: e }) : w3[r2] = e, g$1 = (w3, r2) => { - for (var e in r2 || (r2 = {})) - ps.call(r2, e) && ue(w3, e, r2[e]); - if (de) - for (var e of de(r2)) - hs.call(r2, e) && ue(w3, e, r2[e]); - return w3; -}, D = (w3, r2) => cs(w3, ls(r2)); -class ds extends w$4 { - constructor(r2) { - super(r2), this.name = le, this.events = new EventEmitter$1(), this.initialized = false, this.ignoredPayloadTypes = [_$1], this.requestQueue = { state: I.idle, queue: [] }, this.sessionRequestQueue = { state: I.idle, queue: [] }, this.requestQueueDelay = cjs$4.ONE_SECOND, this.init = async () => { - this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(R) }), this.initialized = true, setTimeout(() => { - this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay))); - }, this.connect = async (e) => { - await this.isInitialized(); - const s2 = D(g$1({}, e), { requiredNamespaces: e.requiredNamespaces || {}, optionalNamespaces: e.optionalNamespaces || {} }); - await this.isValidConnect(s2); - const { pairingTopic: t2, requiredNamespaces: i2, optionalNamespaces: n3, sessionProperties: o2, relays: a3 } = s2; - let c2 = t2, p3, d3 = false; - if (c2 && (d3 = this.client.core.pairing.pairings.get(c2).active), !c2 || !d3) { - const { topic: T2, uri: _3 } = await this.client.core.pairing.create(); - c2 = T2, p3 = _3; - } - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = R.wc_sessionPropose.req.ttl || cjs$4.FIVE_MINUTES, m2 = pt$1(N2), f2 = g$1({ requiredNamespaces: i2, optionalNamespaces: n3, relays: a3 ?? [{ protocol: ht }], proposer: { publicKey: h4, metadata: this.client.metadata }, expiryTimestamp: m2 }, o2 && { sessionProperties: o2 }), { reject: k2, resolve: O2, done: we } = at$1(N2, ae); - if (this.events.once(yt$1("session_connect"), async ({ error: T2, session: _3 }) => { - if (T2) - k2(T2); - else if (_3) { - _3.self.publicKey = h4; - const B2 = D(g$1({}, _3), { requiredNamespaces: f2.requiredNamespaces, optionalNamespaces: f2.optionalNamespaces }); - await this.client.session.set(_3.topic, B2), await this.setExpiry(_3.topic, _3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: _3.peer.metadata }), O2(B2); - } - }), !c2) { - const { message: T2 } = N$1("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); - throw new Error(T2); - } - const W2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: f2, throwOnFailedPublish: true }); - return await this.setProposal(W2, g$1({ id: W2 }, f2)), { uri: p3, approval: we }; - }, this.pair = async (e) => (await this.isInitialized(), await this.client.core.pairing.pair(e)), this.approve = async (e) => { - await this.isInitialized(), await this.isValidApprove(e); - const { id: s2, relayProtocol: t2, namespaces: i2, sessionProperties: n3 } = e, o2 = this.client.proposal.get(s2); - let { pairingTopic: a3, proposer: c2, requiredNamespaces: p3, optionalNamespaces: d3 } = o2; - a3 = a3 || ""; - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = c2.publicKey, m2 = await this.client.core.crypto.generateSharedKey(h4, N2); - a3 && s2 && (await this.client.core.pairing.updateMetadata({ topic: a3, metadata: c2.metadata }), await this.sendResult({ id: s2, topic: a3, result: { relay: { protocol: t2 ?? "irn" }, responderPublicKey: h4 } }), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: a3 })); - const f2 = g$1({ relay: { protocol: t2 ?? "irn" }, namespaces: i2, pairingTopic: a3, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: pt$1(L) }, n3 && { sessionProperties: n3 }); - await this.client.core.relayer.subscribe(m2); - const k2 = D(g$1({}, f2), { topic: m2, requiredNamespaces: p3, optionalNamespaces: d3, pairingTopic: a3, acknowledged: false, self: f2.controller, peer: { publicKey: c2.publicKey, metadata: c2.metadata }, controller: h4 }); - await this.client.session.set(m2, k2); - try { - await this.sendRequest({ topic: m2, method: "wc_sessionSettle", params: f2, throwOnFailedPublish: true }); - } catch (O2) { - throw this.client.logger.error(O2), this.client.session.delete(m2, U$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(m2), O2; - } - return await this.setExpiry(m2, pt$1(L)), { topic: m2, acknowledged: () => new Promise((O2) => setTimeout(() => O2(this.client.session.get(m2)), 500)) }; - }, this.reject = async (e) => { - await this.isInitialized(), await this.isValidReject(e); - const { id: s2, reason: t2 } = e, { pairingTopic: i2 } = this.client.proposal.get(s2); - i2 && (await this.sendError(s2, i2, t2), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED"))); - }, this.update = async (e) => { - await this.isInitialized(), await this.isValidUpdate(e); - const { topic: s2, namespaces: t2 } = e, i2 = await this.sendRequest({ topic: s2, method: "wc_sessionUpdate", params: { namespaces: t2 } }), { done: n3, resolve: o2, reject: a3 } = at$1(); - return this.events.once(yt$1("session_update", i2), ({ error: c2 }) => { - c2 ? a3(c2) : o2(); - }), await this.client.session.update(s2, { namespaces: t2 }), { acknowledged: n3 }; - }, this.extend = async (e) => { - await this.isInitialized(), await this.isValidExtend(e); - const { topic: s2 } = e, t2 = await this.sendRequest({ topic: s2, method: "wc_sessionExtend", params: {} }), { done: i2, resolve: n3, reject: o2 } = at$1(); - return this.events.once(yt$1("session_extend", t2), ({ error: a3 }) => { - a3 ? o2(a3) : n3(); - }), await this.setExpiry(s2, pt$1(L)), { acknowledged: i2 }; - }, this.request = async (e) => { - await this.isInitialized(), await this.isValidRequest(e); - const { chainId: s2, request: t2, topic: i2, expiry: n3 = R.wc_sessionRequest.req.ttl } = e, o2 = payloadId(), { done: a3, resolve: c2, reject: p3 } = at$1(n3, "Request expired. Please try again."); - return this.events.once(yt$1("session_request", o2), ({ error: d3, result: h4 }) => { - d3 ? p3(d3) : c2(h4); - }), await Promise.all([new Promise(async (d3) => { - await this.sendRequest({ clientRpcId: o2, topic: i2, method: "wc_sessionRequest", params: { request: D(g$1({}, t2), { expiryTimestamp: pt$1(n3) }), chainId: s2 }, expiry: n3, throwOnFailedPublish: true }).catch((h4) => p3(h4)), this.client.events.emit("session_request_sent", { topic: i2, request: t2, chainId: s2, id: o2 }), d3(); - }), new Promise(async (d3) => { - const h4 = await ht$1(this.client.core.storage, H); - gt$1({ id: o2, topic: i2, wcDeepLink: h4 }), d3(); - }), a3()]).then((d3) => d3[2]); - }, this.respond = async (e) => { - await this.isInitialized(), await this.isValidRespond(e); - const { topic: s2, response: t2 } = e, { id: i2 } = t2; - isJsonRpcResult(t2) ? await this.sendResult({ id: i2, topic: s2, result: t2.result, throwOnFailedPublish: true }) : isJsonRpcError(t2) && await this.sendError(i2, s2, t2.error), this.cleanupAfterResponse(e); - }, this.ping = async (e) => { - await this.isInitialized(), await this.isValidPing(e); - const { topic: s2 } = e; - if (this.client.session.keys.includes(s2)) { - const t2 = await this.sendRequest({ topic: s2, method: "wc_sessionPing", params: {} }), { done: i2, resolve: n3, reject: o2 } = at$1(); - this.events.once(yt$1("session_ping", t2), ({ error: a3 }) => { - a3 ? o2(a3) : n3(); - }), await i2(); - } else - this.client.core.pairing.pairings.keys.includes(s2) && await this.client.core.pairing.ping({ topic: s2 }); - }, this.emit = async (e) => { - await this.isInitialized(), await this.isValidEmit(e); - const { topic: s2, event: t2, chainId: i2 } = e; - await this.sendRequest({ topic: s2, method: "wc_sessionEvent", params: { event: t2, chainId: i2 } }); - }, this.disconnect = async (e) => { - await this.isInitialized(), await this.isValidDisconnect(e); - const { topic: s2 } = e; - if (this.client.session.keys.includes(s2)) - await this.sendRequest({ topic: s2, method: "wc_sessionDelete", params: U$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: s2, emitEvent: false }); - else if (this.client.core.pairing.pairings.keys.includes(s2)) - await this.client.core.pairing.disconnect({ topic: s2 }); - else { - const { message: t2 } = N$1("MISMATCHED_TOPIC", `Session or pairing topic not found: ${s2}`); - throw new Error(t2); - } - }, this.find = (e) => (this.isInitialized(), this.client.session.getAll().filter((s2) => Mt$1(s2, e))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.cleanupDuplicatePairings = async (e) => { - if (e.pairingTopic) - try { - const s2 = this.client.core.pairing.pairings.get(e.pairingTopic), t2 = this.client.core.pairing.pairings.getAll().filter((i2) => { - var n3, o2; - return ((n3 = i2.peerMetadata) == null ? void 0 : n3.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === e.peer.metadata.url && i2.topic && i2.topic !== s2.topic; - }); - if (t2.length === 0) - return; - this.client.logger.info(`Cleaning up ${t2.length} duplicate pairing(s)`), await Promise.all(t2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.deleteSession = async (e) => { - const { topic: s2, expirerHasDeleted: t2 = false, emitEvent: i2 = true, id: n3 = 0 } = e, { self: o2 } = this.client.session.get(s2); - await this.client.core.relayer.unsubscribe(s2), await this.client.session.delete(s2, U$2("USER_DISCONNECTED")), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(s2) && await this.client.core.crypto.deleteSymKey(s2), t2 || this.client.core.expirer.del(s2), this.client.core.storage.removeItem(H).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { - a3.topic === s2 && this.deletePendingSessionRequest(a3.id, U$2("USER_DISCONNECTED")); - }), i2 && this.client.events.emit("session_delete", { id: n3, topic: s2 }); - }, this.deleteProposal = async (e, s2) => { - await Promise.all([this.client.proposal.delete(e, U$2("USER_DISCONNECTED")), s2 ? Promise.resolve() : this.client.core.expirer.del(e)]); - }, this.deletePendingSessionRequest = async (e, s2, t2 = false) => { - await Promise.all([this.client.pendingRequest.delete(e, s2), t2 ? Promise.resolve() : this.client.core.expirer.del(e)]), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== e), t2 && (this.sessionRequestQueue.state = I.idle, this.client.events.emit("session_request_expire", { id: e })); - }, this.setExpiry = async (e, s2) => { - this.client.session.keys.includes(e) && await this.client.session.update(e, { expiry: s2 }), this.client.core.expirer.set(e, s2); - }, this.setProposal = async (e, s2) => { - await this.client.proposal.set(e, s2), this.client.core.expirer.set(e, pt$1(R.wc_sessionPropose.req.ttl)); - }, this.setPendingSessionRequest = async (e) => { - const { id: s2, topic: t2, params: i2, verifyContext: n3 } = e, o2 = i2.request.expiryTimestamp || pt$1(R.wc_sessionRequest.req.ttl); - await this.client.pendingRequest.set(s2, { id: s2, topic: t2, params: i2, verifyContext: n3 }), o2 && this.client.core.expirer.set(s2, o2); - }, this.sendRequest = async (e) => { - const { topic: s2, method: t2, params: i2, expiry: n3, relayRpcId: o2, clientRpcId: a3, throwOnFailedPublish: c2 } = e, p3 = formatJsonRpcRequest(t2, i2, a3); - if (D$2() && he.includes(t2)) { - const N2 = Ln(JSON.stringify(p3)); - this.client.core.verify.register({ attestationId: N2 }); - } - const d3 = await this.client.core.crypto.encode(s2, p3), h4 = R[t2].req; - return n3 && (h4.ttl = n3), o2 && (h4.id = o2), this.client.core.history.set(s2, p3), c2 ? (h4.internal = D(g$1({}, h4.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, d3, h4)) : this.client.core.relayer.publish(s2, d3, h4).catch((N2) => this.client.logger.error(N2)), p3.id; - }, this.sendResult = async (e) => { - const { id: s2, topic: t2, result: i2, throwOnFailedPublish: n3 } = e, o2 = formatJsonRpcResult(s2, i2), a3 = await this.client.core.crypto.encode(t2, o2), c2 = await this.client.core.history.get(t2, s2), p3 = R[c2.request.method].res; - n3 ? (p3.internal = D(g$1({}, p3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(t2, a3, p3)) : this.client.core.relayer.publish(t2, a3, p3).catch((d3) => this.client.logger.error(d3)), await this.client.core.history.resolve(o2); - }, this.sendError = async (e, s2, t2) => { - const i2 = formatJsonRpcError(e, t2), n3 = await this.client.core.crypto.encode(s2, i2), o2 = await this.client.core.history.get(s2, e), a3 = R[o2.request.method].res; - this.client.core.relayer.publish(s2, n3, a3), await this.client.core.history.resolve(i2); - }, this.cleanup = async () => { - const e = [], s2 = []; - this.client.session.getAll().forEach((t2) => { - let i2 = false; - mt$1(t2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(t2.topic) || (i2 = true), i2 && e.push(t2.topic); - }), this.client.proposal.getAll().forEach((t2) => { - mt$1(t2.expiryTimestamp) && s2.push(t2.id); - }), await Promise.all([...e.map((t2) => this.deleteSession({ topic: t2 })), ...s2.map((t2) => this.deleteProposal(t2))]); - }, this.onRelayEventRequest = async (e) => { - this.requestQueue.queue.push(e), await this.processRequestsQueue(); - }, this.processRequestsQueue = async () => { - if (this.requestQueue.state === I.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 = I.active; - const e = this.requestQueue.queue.shift(); - if (e) - try { - this.processRequest(e), await new Promise((s2) => setTimeout(s2, 300)); - } catch (s2) { - this.client.logger.warn(s2); - } - } - this.requestQueue.state = I.idle; - }, this.processRequest = (e) => { - const { topic: s2, payload: t2 } = e, i2 = t2.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeRequest(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleRequest(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateRequest(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendRequest(s2, t2); - case "wc_sessionPing": - return this.onSessionPingRequest(s2, t2); - case "wc_sessionDelete": - return this.onSessionDeleteRequest(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequest(s2, t2); - case "wc_sessionEvent": - return this.onSessionEventRequest(s2, t2); - default: - return this.client.logger.info(`Unsupported request method ${i2}`); - } - }, this.onRelayEventResponse = async (e) => { - const { topic: s2, payload: t2 } = e, i2 = (await this.client.core.history.get(s2, t2.id)).request.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeResponse(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleResponse(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateResponse(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendResponse(s2, t2); - case "wc_sessionPing": - return this.onSessionPingResponse(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequestResponse(s2, t2); - default: - return this.client.logger.info(`Unsupported response method ${i2}`); - } - }, this.onRelayEventUnknownPayload = (e) => { - const { topic: s2 } = e, { message: t2 } = N$1("MISSING_OR_INVALID", `Decoded payload on topic ${s2} is not identifiable as a JSON-RPC request or a response.`); - throw new Error(t2); - }, this.onSessionProposeRequest = async (e, s2) => { - const { params: t2, id: i2 } = s2; - try { - this.isValidConnect(g$1({}, s2.params)); - const n3 = t2.expiryTimestamp || pt$1(R.wc_sessionPropose.req.ttl), o2 = g$1({ id: i2, pairingTopic: e, expiryTimestamp: n3 }, t2); - await this.setProposal(i2, o2); - const a3 = Ln(JSON.stringify(s2)), c2 = await this.getVerifyContext(a3, o2.proposer.metadata); - this.client.events.emit("session_proposal", { id: i2, params: o2, verifyContext: c2 }); - } catch (n3) { - await this.sendError(i2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionProposeResponse = async (e, s2) => { - const { id: t2 } = s2; - if (isJsonRpcResult(s2)) { - const { result: i2 } = s2; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); - const n3 = this.client.proposal.get(t2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: n3 }); - const o2 = n3.proposer.publicKey; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o2 }); - const a3 = i2.responderPublicKey; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a3 }); - const c2 = await this.client.core.crypto.generateSharedKey(o2, a3); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); - const p3 = await this.client.core.relayer.subscribe(c2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: p3 }), await this.client.core.pairing.activate({ topic: e }); - } else - isJsonRpcError(s2) && (await this.client.proposal.delete(t2, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_connect"), { error: s2.error })); - }, this.onSessionSettleRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; - try { - this.isValidSessionSettleRequest(i2); - const { relay: n3, controller: o2, expiry: a3, namespaces: c2, sessionProperties: p3, pairingTopic: d3 } = s2.params, h4 = g$1({ topic: e, relay: n3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: d3, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, p3 && { sessionProperties: p3 }); - await this.sendResult({ id: s2.id, topic: e, result: true }), this.events.emit(yt$1("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionSettleResponse = async (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? (await this.client.session.update(e, { acknowledged: true }), this.events.emit(yt$1("session_approve", t2), {})) : isJsonRpcError(s2) && (await this.client.session.delete(e, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_approve", t2), { error: s2.error })); - }, this.onSessionUpdateRequest = async (e, s2) => { - const { params: t2, id: i2 } = s2; - try { - const n3 = `${e}_session_update`, o2 = sr$1.get(n3); - if (o2 && this.isRequestOutOfSync(o2, i2)) { - this.client.logger.info(`Discarding out of sync request - ${i2}`); - return; - } - this.isValidUpdate(g$1({ topic: e }, t2)), await this.client.session.update(e, { namespaces: t2.namespaces }), await this.sendResult({ id: i2, topic: e, result: true }), this.client.events.emit("session_update", { id: i2, topic: e, params: t2 }), sr$1.set(n3, i2); - } catch (n3) { - await this.sendError(i2, e, n3), this.client.logger.error(n3); - } - }, this.isRequestOutOfSync = (e, s2) => parseInt(s2.toString().slice(0, -3)) <= parseInt(e.toString().slice(0, -3)), this.onSessionUpdateResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_update", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_update", t2), { error: s2.error }); - }, this.onSessionExtendRequest = async (e, s2) => { - const { id: t2 } = s2; - try { - this.isValidExtend({ topic: e }), await this.setExpiry(e, pt$1(L)), await this.sendResult({ id: t2, topic: e, result: true }), this.client.events.emit("session_extend", { id: t2, topic: e }); - } catch (i2) { - await this.sendError(t2, e, i2), this.client.logger.error(i2); - } - }, this.onSessionExtendResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_extend", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_extend", t2), { error: s2.error }); - }, this.onSessionPingRequest = async (e, s2) => { - const { id: t2 } = s2; - try { - this.isValidPing({ topic: e }), await this.sendResult({ id: t2, topic: e, result: true }), this.client.events.emit("session_ping", { id: t2, topic: e }); - } catch (i2) { - await this.sendError(t2, e, i2), this.client.logger.error(i2); - } - }, this.onSessionPingResponse = (e, s2) => { - const { id: t2 } = s2; - setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_ping", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_ping", t2), { error: s2.error }); - }, 500); - }, this.onSessionDeleteRequest = async (e, s2) => { - const { id: t2 } = s2; - try { - this.isValidDisconnect({ topic: e, reason: s2.params }), await Promise.all([new Promise((i2) => { - this.client.core.relayer.once(D$1.publish, async () => { - i2(await this.deleteSession({ topic: e, id: t2 })); - }); - }), this.sendResult({ id: t2, topic: e, result: true }), this.cleanupPendingSentRequestsForTopic({ topic: e, error: U$2("USER_DISCONNECTED") })]); - } catch (i2) { - this.client.logger.error(i2); - } - }, this.onSessionRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; - try { - this.isValidRequest(g$1({ topic: e }, i2)); - const n3 = Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, t2))), o2 = this.client.session.get(e), a3 = await this.getVerifyContext(n3, o2.peer.metadata), c2 = { id: t2, topic: e, params: i2, verifyContext: a3 }; - await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionRequestResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_request", t2), { result: s2.result }) : isJsonRpcError(s2) && this.events.emit(yt$1("session_request", t2), { error: s2.error }); - }, this.onSessionEventRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; - try { - const n3 = `${e}_session_event_${i2.event.name}`, o2 = sr$1.get(n3); - if (o2 && this.isRequestOutOfSync(o2, t2)) { - this.client.logger.info(`Discarding out of sync request - ${t2}`); - return; - } - this.isValidEmit(g$1({ topic: e }, i2)), this.client.events.emit("session_event", { id: t2, topic: e, params: i2 }), sr$1.set(n3, t2); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.addSessionRequestToSessionRequestQueue = (e) => { - this.sessionRequestQueue.queue.push(e); - }, this.cleanupAfterResponse = (e) => { - this.deletePendingSessionRequest(e.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { - this.sessionRequestQueue.state = I.idle, this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay)); - }, this.cleanupPendingSentRequestsForTopic = ({ topic: e, error: s2 }) => { - const t2 = this.client.core.history.pending; - t2.length > 0 && t2.filter((i2) => i2.topic === e && i2.request.method === "wc_sessionRequest").forEach((i2) => { - this.events.emit(yt$1("session_request", i2.request.id), { error: s2 }); - }); - }, this.processSessionRequestQueue = () => { - if (this.sessionRequestQueue.state === I.active) { - this.client.logger.info("session request queue is already active."); - return; - } - const e = this.sessionRequestQueue.queue[0]; - if (!e) { - this.client.logger.info("session request queue is empty."); - return; - } - try { - this.sessionRequestQueue.state = I.active, this.client.events.emit("session_request", e); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.onPairingCreated = (e) => { - if (e.active) - return; - const s2 = this.client.proposal.getAll().find((t2) => t2.pairingTopic === e.topic); - s2 && this.onSessionProposeRequest(e.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: s2.requiredNamespaces, optionalNamespaces: s2.optionalNamespaces, relays: s2.relays, proposer: s2.proposer, sessionProperties: s2.sessionProperties }, s2.id)); - }, this.isValidConnect = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(e)}`); - throw new Error(a3); - } - const { pairingTopic: s2, requiredNamespaces: t2, optionalNamespaces: i2, sessionProperties: n3, relays: o2 } = e; - if (w$3(s2) || await this.isValidPairingTopic(s2), !qt$1(o2, true)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() relays: ${o2}`); - throw new Error(a3); - } - !w$3(t2) && B$1(t2) !== 0 && this.validateNamespaces(t2, "requiredNamespaces"), !w$3(i2) && B$1(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.validateNamespaces = (e, s2) => { - const t2 = Ht$1(e, "connect()", s2); - if (t2) - throw new Error(t2.message); - }, this.isValidApprove = async (e) => { - if (!Gt$1(e)) - throw new Error(N$1("MISSING_OR_INVALID", `approve() params: ${e}`).message); - const { id: s2, namespaces: t2, relayProtocol: i2, sessionProperties: n3 } = e; - await this.isValidProposalId(s2); - const o2 = this.client.proposal.get(s2), a3 = ln(t2, "approve()"); - if (a3) - throw new Error(a3.message); - const c2 = fn(o2.requiredNamespaces, t2, "approve()"); - if (c2) - throw new Error(c2.message); - if (!g$3(i2, true)) { - const { message: p3 } = N$1("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); - throw new Error(p3); - } - w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.isValidReject = async (e) => { - if (!Gt$1(e)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() params: ${e}`); - throw new Error(i2); - } - const { id: s2, reason: t2 } = e; - if (await this.isValidProposalId(s2), !Wt(t2)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(t2)}`); - throw new Error(i2); - } - }, this.isValidSessionSettleRequest = (e) => { - if (!Gt$1(e)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${e}`); - throw new Error(c2); - } - const { relay: s2, controller: t2, namespaces: i2, expiry: n3 } = e; - if (!dn(s2)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); - throw new Error(c2); - } - const o2 = Ft$1(t2, "onSessionSettleRequest()"); - if (o2) - throw new Error(o2.message); - const a3 = ln(i2, "onSessionSettleRequest()"); - if (a3) - throw new Error(a3.message); - if (mt$1(n3)) { - const { message: c2 } = N$1("EXPIRED", "onSessionSettleRequest()"); - throw new Error(c2); - } - }, this.isValidUpdate = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `update() params: ${e}`); - throw new Error(a3); - } - const { topic: s2, namespaces: t2 } = e; - await this.isValidSessionTopic(s2); - const i2 = this.client.session.get(s2), n3 = ln(t2, "update()"); - if (n3) - throw new Error(n3.message); - const o2 = fn(i2.requiredNamespaces, t2, "update()"); - if (o2) - throw new Error(o2.message); - }, this.isValidExtend = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `extend() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionTopic(s2); - }, this.isValidRequest = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() params: ${e}`); - throw new Error(a3); - } - const { topic: s2, request: t2, chainId: i2, expiry: n3 } = e; - await this.isValidSessionTopic(s2); - const { namespaces: o2 } = this.client.session.get(s2); - if (!Qt(o2, i2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() chainId: ${i2}`); - throw new Error(a3); - } - if (!zt$1(t2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() ${JSON.stringify(t2)}`); - throw new Error(a3); - } - if (!Zt(o2, i2, t2.method)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() method: ${t2.method}`); - throw new Error(a3); - } - if (n3 && !tr$1(n3, U$1)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() expiry: ${n3}. Expiry must be a number (in seconds) between ${U$1.min} and ${U$1.max}`); - throw new Error(a3); - } - }, this.isValidRespond = async (e) => { - var s2; - if (!Gt$1(e)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() params: ${e}`); - throw new Error(n3); - } - const { topic: t2, response: i2 } = e; - try { - await this.isValidSessionTopic(t2); - } catch (n3) { - throw (s2 = e == null ? void 0 : e.response) != null && s2.id && this.cleanupAfterResponse(e), n3; - } - if (!Yt$1(i2)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); - throw new Error(n3); - } - }, this.isValidPing = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `ping() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionOrPairingTopic(s2); - }, this.isValidEmit = async (e) => { - if (!Gt$1(e)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() params: ${e}`); - throw new Error(o2); - } - const { topic: s2, event: t2, chainId: i2 } = e; - await this.isValidSessionTopic(s2); - const { namespaces: n3 } = this.client.session.get(s2); - if (!Qt(n3, i2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() chainId: ${i2}`); - throw new Error(o2); - } - if (!Jt$1(t2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); - throw new Error(o2); - } - if (!Xt(n3, i2, t2.name)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); - throw new Error(o2); - } - }, this.isValidDisconnect = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionOrPairingTopic(s2); - }, this.getVerifyContext = async (e, s2) => { - const t2 = { verified: { verifyUrl: s2.verifyUrl || F$1, validation: "UNKNOWN", origin: s2.url || "" } }; - try { - const i2 = await this.client.core.verify.resolve({ attestationId: e, verifyUrl: s2.verifyUrl }); - i2 && (t2.verified.origin = i2.origin, t2.verified.isScam = i2.isScam, t2.verified.validation = i2.origin === new URL(s2.url).origin ? "VALID" : "INVALID"); - } catch (i2) { - this.client.logger.info(i2); - } - return this.client.logger.info(`Verify context: ${JSON.stringify(t2)}`), t2; - }, this.validateSessionProps = (e, s2) => { - Object.values(e).forEach((t2) => { - if (!g$3(t2, false)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `${s2} must be in Record format. Received: ${JSON.stringify(t2)}`); - throw new Error(i2); - } - }); - }; - } - async isInitialized() { - if (!this.initialized) { - const { message: r2 } = N$1("NOT_INITIALIZED", this.name); - throw new Error(r2); - } - await this.client.core.relayer.confirmOnlineStateOrThrow(); - } - registerRelayerEvents() { - this.client.core.relayer.on(D$1.message, async (r2) => { - const { topic: e, message: s2 } = r2; - if (this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s2))) - return; - const t2 = await this.client.core.crypto.decode(e, s2); - try { - isJsonRpcRequest(t2) ? (this.client.core.history.set(e, t2), this.onRelayEventRequest({ topic: e, payload: t2 })) : isJsonRpcResponse(t2) ? (await this.client.core.history.resolve(t2), await this.onRelayEventResponse({ topic: e, payload: t2 }), this.client.core.history.delete(e, t2.id)) : this.onRelayEventUnknownPayload({ topic: e, payload: t2 }); - } catch (i2) { - this.client.logger.error(i2); - } - }); - } - registerExpirerEvents() { - this.client.core.expirer.on(v2.expired, async (r2) => { - const { topic: e, id: s2 } = ft$1(r2.target); - if (s2 && this.client.pendingRequest.keys.includes(s2)) - return await this.deletePendingSessionRequest(s2, N$1("EXPIRED"), true); - e ? this.client.session.keys.includes(e) && (await this.deleteSession({ topic: e, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: e })) : s2 && (await this.deleteProposal(s2, true), this.client.events.emit("proposal_expire", { id: s2 })); - }); - } - registerPairingEvents() { - this.client.core.pairing.events.on(V.create, (r2) => this.onPairingCreated(r2)); - } - isValidPairingTopic(r2) { - if (!g$3(r2, false)) { - const { message: e } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${r2}`); - throw new Error(e); - } - if (!this.client.core.pairing.pairings.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${r2}`); - throw new Error(e); - } - if (mt$1(this.client.core.pairing.pairings.get(r2).expiry)) { - const { message: e } = N$1("EXPIRED", `pairing topic: ${r2}`); - throw new Error(e); - } - } - async isValidSessionTopic(r2) { - if (!g$3(r2, false)) { - const { message: e } = N$1("MISSING_OR_INVALID", `session topic should be a string: ${r2}`); - throw new Error(e); - } - if (!this.client.session.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `session topic doesn't exist: ${r2}`); - throw new Error(e); - } - if (mt$1(this.client.session.get(r2).expiry)) { - await this.deleteSession({ topic: r2 }); - const { message: e } = N$1("EXPIRED", `session topic: ${r2}`); - throw new Error(e); - } - if (!this.client.core.crypto.keychain.has(r2)) { - const { message: e } = N$1("MISSING_OR_INVALID", `session topic does not exist in keychain: ${r2}`); - throw await this.deleteSession({ topic: r2 }), new Error(e); - } - } - async isValidSessionOrPairingTopic(r2) { - if (this.client.session.keys.includes(r2)) - await this.isValidSessionTopic(r2); - else if (this.client.core.pairing.pairings.keys.includes(r2)) - this.isValidPairingTopic(r2); - else if (g$3(r2, false)) { - const { message: e } = N$1("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${r2}`); - throw new Error(e); - } else { - const { message: e } = N$1("MISSING_OR_INVALID", `session or pairing topic should be a string: ${r2}`); - throw new Error(e); - } - } - async isValidProposalId(r2) { - if (!Bt$1(r2)) { - const { message: e } = N$1("MISSING_OR_INVALID", `proposal id should be a number: ${r2}`); - throw new Error(e); - } - if (!this.client.proposal.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `proposal id doesn't exist: ${r2}`); - throw new Error(e); - } - if (mt$1(this.client.proposal.get(r2).expiryTimestamp)) { - await this.deleteProposal(r2); - const { message: e } = N$1("EXPIRED", `proposal id: ${r2}`); - throw new Error(e); - } - } -} -class us extends Kt { - constructor(r2, e) { - super(r2, e, oe, G), this.core = r2, this.logger = e; - } -} -class ge extends Kt { - constructor(r2, e) { - super(r2, e, ce, G), this.core = r2, this.logger = e; - } -} -class gs extends Kt { - constructor(r2, e) { - super(r2, e, pe, G, (s2) => s2.id), this.core = r2, this.logger = e; - } -} -class Q extends b$1 { - constructor(r2) { - super(r2), this.protocol = J, this.version = F, this.name = M.name, this.events = new eventsExports.EventEmitter(), this.on = (s2, t2) => this.events.on(s2, t2), this.once = (s2, t2) => this.events.once(s2, t2), this.off = (s2, t2) => this.events.off(s2, t2), this.removeListener = (s2, t2) => this.events.removeListener(s2, t2), this.removeAllListeners = (s2) => this.events.removeAllListeners(s2), this.connect = async (s2) => { - try { - return await this.engine.connect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.pair = async (s2) => { - try { - return await this.engine.pair(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.approve = async (s2) => { - try { - return await this.engine.approve(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.reject = async (s2) => { - try { - return await this.engine.reject(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.update = async (s2) => { - try { - return await this.engine.update(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.extend = async (s2) => { - try { - return await this.engine.extend(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.request = async (s2) => { - try { - return await this.engine.request(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.respond = async (s2) => { - try { - return await this.engine.respond(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.ping = async (s2) => { - try { - return await this.engine.ping(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.emit = async (s2) => { - try { - return await this.engine.emit(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.disconnect = async (s2) => { - try { - return await this.engine.disconnect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.find = (s2) => { - try { - return this.engine.find(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.getPendingSessionRequests = () => { - try { - return this.engine.getPendingSessionRequests(); - } catch (s2) { - throw this.logger.error(s2.message), s2; - } - }, this.name = (r2 == null ? void 0 : r2.name) || M.name, this.metadata = (r2 == null ? void 0 : r2.metadata) || Qn(); - const e = typeof (r2 == null ? void 0 : r2.logger) < "u" && typeof (r2 == null ? void 0 : r2.logger) != "string" ? r2.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (r2 == null ? void 0 : r2.logger) || M.logger })); - this.core = (r2 == null ? void 0 : r2.core) || new Mr(r2), this.logger = cjs$3.generateChildLogger(e, this.name), this.session = new ge(this.core, this.logger), this.proposal = new us(this.core, this.logger), this.pendingRequest = new gs(this.core, this.logger), this.engine = new ds(this); - } - static async init(r2) { - const e = new Q(r2); - return await e.initialize(), e; - } - get context() { - return cjs$3.getLoggerContext(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.engine.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); - } catch (r2) { - throw this.logger.info("SignClient Initialization Failure"), this.logger.error(r2.message), r2; - } - } -} -var P = Object.defineProperty, x = Object.defineProperties, N = Object.getOwnPropertyDescriptors, j = Object.getOwnPropertySymbols, U = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable, W = (e, t2, s2) => t2 in e ? P(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, q = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - U.call(t2, s2) && W(e, s2, t2[s2]); - if (j) - for (var s2 of j(t2)) - T.call(t2, s2) && W(e, s2, t2[s2]); - return e; -}, A = (e, t2) => x(e, N(t2)), S = (e, t2, s2) => { - if (!t2.has(e)) - throw TypeError("Cannot " + s2); -}, a2 = (e, t2, s2) => (S(e, t2, "read from private field"), s2 ? s2.call(e) : t2.get(e)), l = (e, t2, s2) => { - if (t2.has(e)) - throw TypeError("Cannot add the same private member more than once"); - t2 instanceof WeakSet ? t2.add(e) : t2.set(e, s2); -}, y2 = (e, t2, s2, d3) => (S(e, t2, "write to private field"), d3 ? d3.call(e, s2) : t2.set(e, s2), s2), o = (e, t2, s2) => (S(e, t2, "access private method"), s2), h3, p2, w2, i, u2, _2, n2, r, m, g2; -let z$1 = class z { - constructor(t2) { - l(this, u2), l(this, n2), l(this, m), l(this, h3, void 0), l(this, p2, void 0), l(this, w2, void 0), l(this, i, void 0), y2(this, h3, t2), y2(this, p2, o(this, u2, _2).call(this)), o(this, n2, r).call(this); - } - async connect(t2) { - const { requiredNamespaces: s2, optionalNamespaces: d3 } = t2; - return new Promise(async (C2, b3) => { - await o(this, n2, r).call(this); - const E2 = a2(this, p2).subscribeModal((c2) => { - c2.open || (E2(), b3(new Error("Modal closed"))); - }), { uri: O2, approval: I2 } = await a2(this, i).connect(t2); - if (O2) { - const c2 = /* @__PURE__ */ new Set(); - s2 && Object.values(s2).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), d3 && Object.values(d3).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), await a2(this, p2).openModal({ uri: O2, chains: Array.from(c2) }); - } - try { - const c2 = await I2(); - C2(c2); - } catch (c2) { - b3(c2); - } finally { - E2(), a2(this, p2).closeModal(); - } - }); - } - async disconnect(t2) { - await o(this, n2, r).call(this), await a2(this, i).disconnect(t2); - } - async request(t2) { - return await o(this, n2, r).call(this), await a2(this, i).request(t2); - } - async getSessions() { - return await o(this, n2, r).call(this), a2(this, i).session.getAll(); - } - async getSession() { - return await o(this, n2, r).call(this), a2(this, i).session.getAll().at(-1); - } - async onSessionEvent(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_event", t2); - } - async offSessionEvent(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_event", t2); - } - async onSessionUpdate(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_update", t2); - } - async offSessionUpdate(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_update", t2); - } - async onSessionDelete(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_delete", t2); - } - async offSessionDelete(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_delete", t2); - } - async onSessionExpire(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_expire", t2); - } - async offSessionExpire(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_expire", t2); - } -}; -h3 = /* @__PURE__ */ new WeakMap(), p2 = /* @__PURE__ */ new WeakMap(), w2 = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), u2 = /* @__PURE__ */ new WeakSet(), _2 = function() { - const { modalOptions: e, projectId: t2 } = a2(this, h3); - return new d$1(A(q({}, e), { projectId: t2 })); -}, n2 = /* @__PURE__ */ new WeakSet(), r = async function() { - return a2(this, i) ? true : (!a2(this, w2) && typeof window < "u" && y2(this, w2, o(this, m, g2).call(this)), a2(this, w2)); -}, m = /* @__PURE__ */ new WeakSet(), g2 = async function() { - y2(this, i, await Q.init({ metadata: a2(this, h3).metadata, projectId: a2(this, h3).projectId, relayUrl: a2(this, h3).relayUrl })); - const e = await a2(this, i).core.crypto.getClientId(); - try { - localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e); - } catch { - console.info("Unable to set client id"); - } -}; -const wc_aleo_methods = [ - "decrypt", - "disconnect", - "getSelectedAccount", - "getBalance", - "getRecords", - "requestCreateEvent", - "getEvent", - "getEvents", - "createSharedState", - "importSharedState", - "requestSignature" -]; -const wc_aleo_chains = ["aleo:1"]; -const wc_events = [ - "chainChanged", - "accountSelected", - "selectedAccountSynced", - "sharedAccountSynced" -]; -const projectId = "f0aaeffe71b636da453fce042d79d723"; -function isAndroid() { - if (!navigator) { - return false; - } - return /Android/i.test(navigator.userAgent); -} -const web3modal_puzzle_props_android = { - projectId, - chains: ["aleo:3"], - enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png" - } -}; -const web3modal_puzzle_props_default = { - projectId, - chains: wc_aleo_chains, - enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } - } - ], - desktopWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "", - universal: "https://walletconnect.puzzle.online/" - } - }, - { - id: "avail", - name: "Avail Wallet", - links: { - native: "avail://", - universal: "https://avail.global" - } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png", - avail: "https://i.imgur.com/GxNn8BO.png" - } -}; -const web3modal_puzzle_props = isAndroid() ? web3modal_puzzle_props_android : web3modal_puzzle_props_default; -const signClient_puzzleProps = { - requiredNamespaces: { - aleo: { - methods: wc_aleo_methods, - chains: web3modal_puzzle_props.chains, - events: wc_events - } - } -}; -const name = "@puzzlehq/sdk-core"; -const displayName = "Puzzle SDK"; -const version = "0.3.1"; -const description = "Your portal to privacy"; -const main = "./dist/puzzle.cjs.js"; -const module = "./dist/puzzle.es.js"; -const browser$1 = "./dist/puzzle.umd.js"; -const types = "./dist/types/src/index.d.ts"; -const exports = { - ".": { - "import": "./dist/puzzle.es.js", - require: "./dist/puzzle.cjs.js", - browser: "./dist/puzzle.umd.js", - types: "./dist/types/src/index.d.ts" - } -}; -const type = "module"; -const scripts = { - "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", - "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, - build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", - "type-check": "tsc --noEmit" -}; -const repository = { - type: "git", - url: "git+https://github.com/puzzlehq/puzzle-sdk.git" -}; -const dependencies = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", - "@walletconnect/types": "^2.11.2", - "@walletconnect/utils": "^2.11.2", - debug: "^4.3.4", - events: "^3.3.0", - ws: "^8.16.0" -}; -const peerDependencies = { - buffer: "^6.0.3" -}; -const keywords = [ - "puzzle", - "cryptocurrency wallet", - "privacy", - "aleo", - "web3", - "crypto", - "typescript" -]; -const author = "Puzzle"; -const license = "ISC"; -const bugs = { - url: "https://github.com/puzzlehq/puzzle-sdk/issues" -}; -const homepage = "https://github.com/puzzlehq/puzzle-sdk#readme"; -const pkg = { - name, - displayName, - version, - description, - main, - module, - browser: browser$1, - types, - "private": false, - exports, - type, - scripts, - repository, - dependencies, - peerDependencies, - keywords, - author, - license, - bugs, - homepage -}; -const emitter = new EventEmitter$1(); -let connection = void 0; -async function configureConnection(options) { - let disconnectSessions = false; - const thisVersion = pkg.version; - const prevVersion = localStorage.getItem("puzzle_sdk_version"); - if (thisVersion !== prevVersion) { - console.log( - `${pkg.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" - ); - localStorage.setItem("puzzle_sdk_version", thisVersion); - disconnectSessions = true; - } - connection = new z$1({ - projectId: options.projectId ?? projectId, - metadata: { - name: options.dAppName, - description: options.dAppDescription, - url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", - icons: [options.dAppIconURL] - }, - modalOptions: { ...web3modal_puzzle_props } - }); - if (disconnectSessions) { - localStorage.removeItem("puzzle-hasInjectedConnection"); - try { - disconnectOnVersionChange(connection, options.onDisconnect); - } catch (e) { - console.error(e); - } - } - connection.onSessionDelete(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - connection.onSessionExpire(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - if (typeof window !== "undefined") { - window.puzzleSdkConnection = connection; - } - return connection; -} -async function disconnectOnVersionChange(connection2, onDisconnect) { - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (session) { - console.log("Disconnecting session", session); - onDisconnect && onDisconnect(); - connection2.disconnect({ - topic: session.topic, - reason: U$2("USER_DISCONNECTED") - }); - } -} -async function getWalletConnectModalSignClient() { - return new Promise((resolve) => { - if (connection) { - resolve(connection); - } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { - resolve(window.puzzleSdkConnection); - } else { - const interval = setInterval(() => { - if (connection) { - clearInterval(interval); - resolve(connection); - } - }, 200); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - }); -} -const checkForDesktopConnection = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - try { - const res = await window.aleo.puzzleWalletClient.isConnected.query( - { sessionTopic } - ); - if (res) { - localStorage.setItem("puzzle-hasInjectedConnection", "true"); - return true; - } else { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - } catch (e) { - console.warn(e); - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } -}; -const hasInjectedConnection = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - return false; - } - const puzzleHasDesktopConnection = localStorage.getItem( - "puzzle-hasInjectedConnection" - ); - return puzzleHasDesktopConnection === "true"; -}; -const getAccount = async () => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await connection2.getSession(); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getSelectedAccount" - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getSelectedAccount.query(query); - return response; - } catch (e) { - console.error("getAccount error", e); - return { error: e.message }; - } - } - try { - const response = await connection2.request(query); - return response; - } catch (e) { - console.error("getAccount error", e); - const error = e.message; - return { error }; - } -}; -const getBalance = async ({ - address -}) => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await connection2.getSession(); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getBalance", - params: { - assetId: void 0, - address - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getBalance.query(query); - return response; - } catch (e) { - const error = e.message; - console.error("getBalance error", e); - return { error }; - } - } - try { - const response = await connection2.request(query); - return response; - } catch (e) { - const error = e.message; - console.error("getBalance error", e); - return { error }; - } -}; -const connect = async () => { - const connection2 = await getWalletConnectModalSignClient(); - if (!connection2) { - throw new Error("call setConnection() first!"); - } - const existingSession = await connection2.getSession(); - if (existingSession) { - console.log("Already connected!", existingSession); - return existingSession; - } - try { - const newSession = await connection2.connect({ - requiredNamespaces: { - aleo: { - methods: wc_aleo_methods, - chains: wc_aleo_chains, - events: wc_events - } - } - }); - emitter.emit("session_change"); - if (newSession) { - await checkForDesktopConnection(newSession.topic); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - return newSession; - } catch (e) { - console.error("connect error", e); - } -}; -const requestCreateEvent = async (requestData) => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { - if (typeof input === "string") { - return input; - } - return input.plaintext; - }); - try { - const response = await connection2.request({ - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "requestCreateEvent", - params: { - ...requestData, - inputs - } - } - }); - return response; - } catch (e) { - console.error("createEvent error", e); - const error = e.message; - return { error }; - } -}; -const createSharedState = async () => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "createSharedState", - params: {} - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.createSharedState.mutate( - query - ); - return response; - } catch (e) { - console.error("createSharedState error", e); - const error = e.message; - return { error }; - } - } - try { - const response = await connection2.request(query); - return response; - } catch (e) { - console.error("createSharedState error", e); - const error = e.message; - return { error }; - } -}; -const decrypt = async (ciphertexts) => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "decrypt", - params: { - ciphertexts - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.decrypt.query(query); - return response; - } catch (e) { - const error = e.message; - console.error("decrypt error", e); - return { error }; - } - } - try { - const response = await connection2.request(query); - return response; - } catch (e) { - console.error("decrypt error", e); - return { error: e.message }; - } -}; -const disconnect = async () => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - try { - try { - await connection2.disconnect({ - reason: U$2("USER_DISCONNECTED"), - topic: session.topic - }); - localStorage.removeItem("puzzle-hasInjectedConnection"); - emitter.emit("session_change"); - } catch (e) { - console.warn(e); - } - return {}; - } catch (e) { - console.error("error disconnecting", e); - const error = e.message; - return { error }; - } -}; -const getEvent = async ({ - id, - address -}) => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { event: void 0, error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getEvent", - params: { - id, - address - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getEvent.query(query); - return response; - } catch (e) { - console.error("getEvent error", e); - const error = e.message; - return { error }; - } - } - const fetchEvent = async () => { - const response = await connection2.request(query); - return response; - }; - try { - const response = await fetchEvent(); - return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; - return { error }; - } -}; -const getEvents = async (filter) => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { events: void 0, error: "no session or connection" }; - } - if ((filter == null ? void 0 : filter.programId) === "") { - filter.programId = void 0; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getEvents", - params: { - filter, - page: 0 - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getEvents.query(query); - return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; - return { error }; - } - } - const fetchPage = async (page = 0) => { - const response = await connection2.request(query); - return response; - }; - try { - const response = await fetchPage(); - return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; - return { error }; - } -}; -const importSharedState = async (seed) => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "importSharedState", - params: { - seed - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.importSharedState.mutate(query); - return response; - } catch (e) { - console.error("importSharedState error", e); - const error = e.message; - return { error }; - } - } - try { - const response = await connection2.request(query); - return response; - } catch (e) { - console.error("importSharedState error", e); - const error = e.message; - return { error }; - } -}; -const getRecords = async ({ - address, - filter, - page = 0 -}) => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getRecords", - params: { - address, - filter, - page - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getRecords.query(query); - return response; - } catch (e) { - console.error("getRecords error", e); - const error = e.message; - return { error }; - } - } - const fetchPage = async (page2 = 0) => { - const response = await connection2.request(query); - return response; - }; - try { - const response = await fetchPage(); - return response; - } catch (e) { - console.error("getRecords error", e); - const error = e.message; - return { error }; - } -}; -var util; -(function(util2) { - util2.assertEqual = (val) => val; - function assertIs(_arg) { - } - util2.assertIs = assertIs; - function assertNever(_x) { - throw new Error(); - } - util2.assertNever = assertNever; - util2.arrayToEnum = (items) => { - const obj = {}; - for (const item of items) { - obj[item] = item; - } - return obj; - }; - util2.getValidEnumValues = (obj) => { - const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number"); - const filtered = {}; - for (const k2 of validKeys) { - filtered[k2] = obj[k2]; - } - return util2.objectValues(filtered); - }; - util2.objectValues = (obj) => { - return util2.objectKeys(obj).map(function(e) { - return obj[e]; - }); - }; - util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { - const keys2 = []; - for (const key in object) { - if (Object.prototype.hasOwnProperty.call(object, key)) { - keys2.push(key); - } - } - return keys2; - }; - util2.find = (arr, checker) => { - for (const item of arr) { - if (checker(item)) - return item; - } - return void 0; - }; - util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val; - function joinValues(array, separator = " | ") { - return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator); - } - util2.joinValues = joinValues; - util2.jsonStringifyReplacer = (_3, value) => { - if (typeof value === "bigint") { - return value.toString(); - } - return value; - }; -})(util || (util = {})); -var objectUtil; -(function(objectUtil2) { - objectUtil2.mergeShapes = (first, second) => { - return { - ...first, - ...second - // second overwrites first - }; - }; -})(objectUtil || (objectUtil = {})); -const ZodParsedType = util.arrayToEnum([ - "string", - "nan", - "number", - "integer", - "float", - "boolean", - "date", - "bigint", - "symbol", - "function", - "undefined", - "null", - "array", - "object", - "unknown", - "promise", - "void", - "never", - "map", - "set" -]); -const getParsedType = (data) => { - const t2 = typeof data; - switch (t2) { - case "undefined": - return ZodParsedType.undefined; - case "string": - return ZodParsedType.string; - case "number": - return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number; - case "boolean": - return ZodParsedType.boolean; - case "function": - return ZodParsedType.function; - case "bigint": - return ZodParsedType.bigint; - case "symbol": - return ZodParsedType.symbol; - case "object": - if (Array.isArray(data)) { - return ZodParsedType.array; - } - if (data === null) { - return ZodParsedType.null; - } - if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { - return ZodParsedType.promise; - } - if (typeof Map !== "undefined" && data instanceof Map) { - return ZodParsedType.map; - } - if (typeof Set !== "undefined" && data instanceof Set) { - return ZodParsedType.set; - } - if (typeof Date !== "undefined" && data instanceof Date) { - return ZodParsedType.date; - } - return ZodParsedType.object; - default: - return ZodParsedType.unknown; - } -}; -const ZodIssueCode = util.arrayToEnum([ - "invalid_type", - "invalid_literal", - "custom", - "invalid_union", - "invalid_union_discriminator", - "invalid_enum_value", - "unrecognized_keys", - "invalid_arguments", - "invalid_return_type", - "invalid_date", - "invalid_string", - "too_small", - "too_big", - "invalid_intersection_types", - "not_multiple_of", - "not_finite" -]); -const quotelessJson = (obj) => { - const json = JSON.stringify(obj, null, 2); - return json.replace(/"([^"]+)":/g, "$1:"); -}; -class ZodError extends Error { - constructor(issues) { - super(); - this.issues = []; - this.addIssue = (sub) => { - this.issues = [...this.issues, sub]; - }; - this.addIssues = (subs = []) => { - this.issues = [...this.issues, ...subs]; - }; - const actualProto = new.target.prototype; - if (Object.setPrototypeOf) { - Object.setPrototypeOf(this, actualProto); - } else { - this.__proto__ = actualProto; - } - this.name = "ZodError"; - this.issues = issues; - } - get errors() { - return this.issues; - } - format(_mapper) { - const mapper = _mapper || function(issue) { - return issue.message; - }; - const fieldErrors = { _errors: [] }; - const processError = (error) => { - for (const issue of error.issues) { - if (issue.code === "invalid_union") { - issue.unionErrors.map(processError); - } else if (issue.code === "invalid_return_type") { - processError(issue.returnTypeError); - } else if (issue.code === "invalid_arguments") { - processError(issue.argumentsError); - } else if (issue.path.length === 0) { - fieldErrors._errors.push(mapper(issue)); - } else { - let curr = fieldErrors; - let i2 = 0; - while (i2 < issue.path.length) { - const el = issue.path[i2]; - const terminal = i2 === issue.path.length - 1; - if (!terminal) { - curr[el] = curr[el] || { _errors: [] }; - } else { - curr[el] = curr[el] || { _errors: [] }; - curr[el]._errors.push(mapper(issue)); - } - curr = curr[el]; - i2++; - } - } - } - }; - processError(this); - return fieldErrors; - } - toString() { - return this.message; - } - get message() { - return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2); - } - get isEmpty() { - return this.issues.length === 0; - } - flatten(mapper = (issue) => issue.message) { - const fieldErrors = {}; - const formErrors = []; - for (const sub of this.issues) { - if (sub.path.length > 0) { - fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; - fieldErrors[sub.path[0]].push(mapper(sub)); - } else { - formErrors.push(mapper(sub)); - } - } - return { formErrors, fieldErrors }; - } - get formErrors() { - return this.flatten(); - } -} -ZodError.create = (issues) => { - const error = new ZodError(issues); - return error; -}; -const errorMap = (issue, _ctx) => { - let message; - switch (issue.code) { - case ZodIssueCode.invalid_type: - if (issue.received === ZodParsedType.undefined) { - message = "Required"; - } else { - message = `Expected ${issue.expected}, received ${issue.received}`; - } - break; - case ZodIssueCode.invalid_literal: - message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`; - break; - case ZodIssueCode.unrecognized_keys: - message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`; - break; - case ZodIssueCode.invalid_union: - message = `Invalid input`; - break; - case ZodIssueCode.invalid_union_discriminator: - message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`; - break; - case ZodIssueCode.invalid_enum_value: - message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`; - break; - case ZodIssueCode.invalid_arguments: - message = `Invalid function arguments`; - break; - case ZodIssueCode.invalid_return_type: - message = `Invalid function return type`; - break; - case ZodIssueCode.invalid_date: - message = `Invalid date`; - break; - case ZodIssueCode.invalid_string: - if (typeof issue.validation === "object") { - if ("includes" in issue.validation) { - message = `Invalid input: must include "${issue.validation.includes}"`; - if (typeof issue.validation.position === "number") { - message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; - } - } else if ("startsWith" in issue.validation) { - message = `Invalid input: must start with "${issue.validation.startsWith}"`; - } else if ("endsWith" in issue.validation) { - message = `Invalid input: must end with "${issue.validation.endsWith}"`; - } else { - util.assertNever(issue.validation); - } - } else if (issue.validation !== "regex") { - message = `Invalid ${issue.validation}`; - } else { - message = "Invalid"; - } - break; - case ZodIssueCode.too_small: - if (issue.type === "array") - message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`; - else if (issue.type === "string") - message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`; - else if (issue.type === "number") - message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`; - else if (issue.type === "date") - message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`; - else - message = "Invalid input"; - break; - case ZodIssueCode.too_big: - if (issue.type === "array") - message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`; - else if (issue.type === "string") - message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`; - else if (issue.type === "number") - message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; - else if (issue.type === "bigint") - message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; - else if (issue.type === "date") - message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`; - else - message = "Invalid input"; - break; - case ZodIssueCode.custom: - message = `Invalid input`; - break; - case ZodIssueCode.invalid_intersection_types: - message = `Intersection results could not be merged`; - break; - case ZodIssueCode.not_multiple_of: - message = `Number must be a multiple of ${issue.multipleOf}`; - break; - case ZodIssueCode.not_finite: - message = "Number must be finite"; - break; - default: - message = _ctx.defaultError; - util.assertNever(issue); - } - return { message }; -}; -let overrideErrorMap = errorMap; -function setErrorMap(map) { - overrideErrorMap = map; -} -function getErrorMap() { - return overrideErrorMap; -} -const makeIssue = (params) => { - const { data, path, errorMaps, issueData } = params; - const fullPath = [...path, ...issueData.path || []]; - const fullIssue = { - ...issueData, - path: fullPath - }; - let errorMessage = ""; - const maps = errorMaps.filter((m2) => !!m2).slice().reverse(); - for (const map of maps) { - errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; - } - return { - ...issueData, - path: fullPath, - message: issueData.message || errorMessage - }; -}; -const EMPTY_PATH = []; -function addIssueToContext(ctx, issueData) { - const issue = makeIssue({ - issueData, - data: ctx.data, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap(), - errorMap - // then global default map - ].filter((x2) => !!x2) - }); - ctx.common.issues.push(issue); -} -class ParseStatus { - constructor() { - this.value = "valid"; - } - dirty() { - if (this.value === "valid") - this.value = "dirty"; - } - abort() { - if (this.value !== "aborted") - this.value = "aborted"; - } - static mergeArray(status, results) { - const arrayValue = []; - for (const s2 of results) { - if (s2.status === "aborted") - return INVALID; - if (s2.status === "dirty") - status.dirty(); - arrayValue.push(s2.value); - } - return { status: status.value, value: arrayValue }; - } - static async mergeObjectAsync(status, pairs) { - const syncPairs = []; - for (const pair of pairs) { - syncPairs.push({ - key: await pair.key, - value: await pair.value - }); - } - return ParseStatus.mergeObjectSync(status, syncPairs); - } - static mergeObjectSync(status, pairs) { - const finalObject = {}; - for (const pair of pairs) { - const { key, value } = pair; - if (key.status === "aborted") - return INVALID; - if (value.status === "aborted") - return INVALID; - if (key.status === "dirty") - status.dirty(); - if (value.status === "dirty") - status.dirty(); - if (typeof value.value !== "undefined" || pair.alwaysSet) { - finalObject[key.value] = value.value; - } - } - return { status: status.value, value: finalObject }; - } -} -const INVALID = Object.freeze({ - status: "aborted" -}); -const DIRTY = (value) => ({ status: "dirty", value }); -const OK = (value) => ({ status: "valid", value }); -const isAborted = (x2) => x2.status === "aborted"; -const isDirty = (x2) => x2.status === "dirty"; -const isValid = (x2) => x2.status === "valid"; -const isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise; -var errorUtil; -(function(errorUtil2) { - errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {}; - errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; -})(errorUtil || (errorUtil = {})); -class ParseInputLazyPath { - constructor(parent, value, path, key) { - this._cachedPath = []; - this.parent = parent; - this.data = value; - this._path = path; - this._key = key; - } - get path() { - if (!this._cachedPath.length) { - if (this._key instanceof Array) { - this._cachedPath.push(...this._path, ...this._key); - } else { - this._cachedPath.push(...this._path, this._key); - } - } - return this._cachedPath; - } -} -const handleResult = (ctx, result) => { - if (isValid(result)) { - return { success: true, data: result.value }; - } else { - if (!ctx.common.issues.length) { - throw new Error("Validation failed but no issues detected."); - } - return { - success: false, - get error() { - if (this._error) - return this._error; - const error = new ZodError(ctx.common.issues); - this._error = error; - return this._error; - } - }; - } -}; -function processCreateParams(params) { - if (!params) - return {}; - const { errorMap: errorMap2, invalid_type_error, required_error, description: description2 } = params; - if (errorMap2 && (invalid_type_error || required_error)) { - throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); - } - if (errorMap2) - return { errorMap: errorMap2, description: description2 }; - const customMap = (iss, ctx) => { - if (iss.code !== "invalid_type") - return { message: ctx.defaultError }; - if (typeof ctx.data === "undefined") { - return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError }; - } - return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError }; - }; - return { errorMap: customMap, description: description2 }; -} -class ZodType { - constructor(def) { - this.spa = this.safeParseAsync; - this._def = def; - this.parse = this.parse.bind(this); - this.safeParse = this.safeParse.bind(this); - this.parseAsync = this.parseAsync.bind(this); - this.safeParseAsync = this.safeParseAsync.bind(this); - this.spa = this.spa.bind(this); - this.refine = this.refine.bind(this); - this.refinement = this.refinement.bind(this); - this.superRefine = this.superRefine.bind(this); - this.optional = this.optional.bind(this); - this.nullable = this.nullable.bind(this); - this.nullish = this.nullish.bind(this); - this.array = this.array.bind(this); - this.promise = this.promise.bind(this); - this.or = this.or.bind(this); - this.and = this.and.bind(this); - this.transform = this.transform.bind(this); - this.brand = this.brand.bind(this); - this.default = this.default.bind(this); - this.catch = this.catch.bind(this); - this.describe = this.describe.bind(this); - this.pipe = this.pipe.bind(this); - this.isNullable = this.isNullable.bind(this); - this.isOptional = this.isOptional.bind(this); - } - get description() { - return this._def.description; - } - _getType(input) { - return getParsedType(input.data); - } - _getOrReturnCtx(input, ctx) { - return ctx || { - common: input.parent.common, - data: input.data, - parsedType: getParsedType(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - }; - } - _processInputParams(input) { - return { - status: new ParseStatus(), - ctx: { - common: input.parent.common, - data: input.data, - parsedType: getParsedType(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - } - }; - } - _parseSync(input) { - const result = this._parse(input); - if (isAsync(result)) { - throw new Error("Synchronous parse encountered promise."); - } - return result; - } - _parseAsync(input) { - const result = this._parse(input); - return Promise.resolve(result); - } - parse(data, params) { - const result = this.safeParse(data, params); - if (result.success) - return result.data; - throw result.error; - } - safeParse(data, params) { - var _a; - const ctx = { - common: { - issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, - contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap - }, - path: (params === null || params === void 0 ? void 0 : params.path) || [], - schemaErrorMap: this._def.errorMap, - parent: null, - data, - parsedType: getParsedType(data) - }; - const result = this._parseSync({ data, path: ctx.path, parent: ctx }); - return handleResult(ctx, result); - } - async parseAsync(data, params) { - const result = await this.safeParseAsync(data, params); - if (result.success) - return result.data; - throw result.error; - } - async safeParseAsync(data, params) { - const ctx = { - common: { - issues: [], - contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap, - async: true - }, - path: (params === null || params === void 0 ? void 0 : params.path) || [], - schemaErrorMap: this._def.errorMap, - parent: null, - data, - parsedType: getParsedType(data) - }; - const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }); - const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); - return handleResult(ctx, result); - } - refine(check, message) { - const getIssueProperties = (val) => { - if (typeof message === "string" || typeof message === "undefined") { - return { message }; - } else if (typeof message === "function") { - return message(val); - } else { - return message; - } - }; - return this._refinement((val, ctx) => { - const result = check(val); - const setError = () => ctx.addIssue({ - code: ZodIssueCode.custom, - ...getIssueProperties(val) - }); - if (typeof Promise !== "undefined" && result instanceof Promise) { - return result.then((data) => { - if (!data) { - setError(); - return false; - } else { - return true; - } - }); - } - if (!result) { - setError(); - return false; - } else { - return true; - } - }); - } - refinement(check, refinementData) { - return this._refinement((val, ctx) => { - if (!check(val)) { - ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData); - return false; - } else { - return true; - } - }); - } - _refinement(refinement) { - return new ZodEffects({ - schema: this, - typeName: ZodFirstPartyTypeKind.ZodEffects, - effect: { type: "refinement", refinement } - }); - } - superRefine(refinement) { - return this._refinement(refinement); - } - optional() { - return ZodOptional.create(this, this._def); - } - nullable() { - return ZodNullable.create(this, this._def); - } - nullish() { - return this.nullable().optional(); - } - array() { - return ZodArray.create(this, this._def); - } - promise() { - return ZodPromise.create(this, this._def); - } - or(option) { - return ZodUnion.create([this, option], this._def); - } - and(incoming) { - return ZodIntersection.create(this, incoming, this._def); - } - transform(transform) { - return new ZodEffects({ - ...processCreateParams(this._def), - schema: this, - typeName: ZodFirstPartyTypeKind.ZodEffects, - effect: { type: "transform", transform } - }); - } - default(def) { - const defaultValueFunc = typeof def === "function" ? def : () => def; - return new ZodDefault({ - ...processCreateParams(this._def), - innerType: this, - defaultValue: defaultValueFunc, - typeName: ZodFirstPartyTypeKind.ZodDefault - }); - } - brand() { - return new ZodBranded({ - typeName: ZodFirstPartyTypeKind.ZodBranded, - type: this, - ...processCreateParams(this._def) - }); - } - catch(def) { - const catchValueFunc = typeof def === "function" ? def : () => def; - return new ZodCatch({ - ...processCreateParams(this._def), - innerType: this, - catchValue: catchValueFunc, - typeName: ZodFirstPartyTypeKind.ZodCatch - }); - } - describe(description2) { - const This = this.constructor; - return new This({ - ...this._def, - description: description2 - }); - } - pipe(target) { - return ZodPipeline.create(this, target); - } - isOptional() { - return this.safeParse(void 0).success; - } - isNullable() { - return this.safeParse(null).success; - } -} -const cuidRegex = /^c[^\s-]{8,}$/i; -const cuid2Regex = /^[a-z][a-z0-9]*$/; -const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/; -const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; -const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/; -const emojiRegex = new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u"); -const ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; -const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/; -const datetimeRegex = (args) => { - if (args.precision) { - if (args.offset) { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); - } else { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`); - } - } else if (args.precision === 0) { - if (args.offset) { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); - } else { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`); - } - } else { - if (args.offset) { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`); - } else { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`); - } - } -}; -function isValidIP(ip, version2) { - if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) { - return true; - } - if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) { - return true; - } - return false; -} -class ZodString extends ZodType { - constructor() { - super(...arguments); - this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), { - validation, - code: ZodIssueCode.invalid_string, - ...errorUtil.errToObj(message) - }); - this.nonempty = (message) => this.min(1, errorUtil.errToObj(message)); - this.trim = () => new ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "trim" }] - }); - this.toLowerCase = () => new ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "toLowerCase" }] - }); - this.toUpperCase = () => new ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "toUpperCase" }] - }); - } - _parse(input) { - if (this._def.coerce) { - input.data = String(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.string) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext( - ctx2, - { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.string, - received: ctx2.parsedType - } - // - ); - return INVALID; - } - const status = new ParseStatus(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.length < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: check.value, - type: "string", - inclusive: true, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.length > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: check.value, - type: "string", - inclusive: true, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "length") { - const tooBig = input.data.length > check.value; - const tooSmall = input.data.length < check.value; - if (tooBig || tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - if (tooBig) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: check.value, - type: "string", - inclusive: true, - exact: true, - message: check.message - }); - } else if (tooSmall) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: check.value, - type: "string", - inclusive: true, - exact: true, - message: check.message - }); - } - status.dirty(); - } - } else if (check.kind === "email") { - if (!emailRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "email", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "emoji") { - if (!emojiRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "emoji", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "uuid") { - if (!uuidRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "uuid", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "cuid") { - if (!cuidRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "cuid", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "cuid2") { - if (!cuid2Regex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "cuid2", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "ulid") { - if (!ulidRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "ulid", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "url") { - try { - new URL(input.data); - } catch (_a) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "url", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "regex") { - check.regex.lastIndex = 0; - const testResult = check.regex.test(input.data); - if (!testResult) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "regex", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "trim") { - input.data = input.data.trim(); - } else if (check.kind === "includes") { - if (!input.data.includes(check.value, check.position)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_string, - validation: { includes: check.value, position: check.position }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "toLowerCase") { - input.data = input.data.toLowerCase(); - } else if (check.kind === "toUpperCase") { - input.data = input.data.toUpperCase(); - } else if (check.kind === "startsWith") { - if (!input.data.startsWith(check.value)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_string, - validation: { startsWith: check.value }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "endsWith") { - if (!input.data.endsWith(check.value)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_string, - validation: { endsWith: check.value }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "datetime") { - const regex = datetimeRegex(check); - if (!regex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_string, - validation: "datetime", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "ip") { - if (!isValidIP(input.data, check.version)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "ip", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else { - util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - _addCheck(check) { - return new ZodString({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - email(message) { - return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) }); - } - url(message) { - return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) }); - } - emoji(message) { - return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) }); - } - uuid(message) { - return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) }); - } - cuid(message) { - return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) }); - } - cuid2(message) { - return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) }); - } - ulid(message) { - return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) }); - } - ip(options) { - return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); - } - datetime(options) { - var _a; - if (typeof options === "string") { - return this._addCheck({ - kind: "datetime", - precision: null, - offset: false, - message: options - }); - } - return this._addCheck({ - kind: "datetime", - precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, - ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) - }); - } - regex(regex, message) { - return this._addCheck({ - kind: "regex", - regex, - ...errorUtil.errToObj(message) - }); - } - includes(value, options) { - return this._addCheck({ - kind: "includes", - value, - position: options === null || options === void 0 ? void 0 : options.position, - ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) - }); - } - startsWith(value, message) { - return this._addCheck({ - kind: "startsWith", - value, - ...errorUtil.errToObj(message) - }); - } - endsWith(value, message) { - return this._addCheck({ - kind: "endsWith", - value, - ...errorUtil.errToObj(message) - }); - } - min(minLength, message) { - return this._addCheck({ - kind: "min", - value: minLength, - ...errorUtil.errToObj(message) - }); - } - max(maxLength, message) { - return this._addCheck({ - kind: "max", - value: maxLength, - ...errorUtil.errToObj(message) - }); - } - length(len, message) { - return this._addCheck({ - kind: "length", - value: len, - ...errorUtil.errToObj(message) - }); - } - get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); - } - get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); - } - get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); - } - get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); - } - get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); - } - get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); - } - get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); - } - get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); - } - get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); - } - get minLength() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxLength() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } -} -ZodString.create = (params) => { - var _a; - return new ZodString({ - checks: [], - typeName: ZodFirstPartyTypeKind.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, - ...processCreateParams(params) - }); -}; -function floatSafeRemainder(val, step) { - const valDecCount = (val.toString().split(".")[1] || "").length; - const stepDecCount = (step.toString().split(".")[1] || "").length; - const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; - const valInt = parseInt(val.toFixed(decCount).replace(".", "")); - const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); - return valInt % stepInt / Math.pow(10, decCount); -} -class ZodNumber extends ZodType { - constructor() { - super(...arguments); - this.min = this.gte; - this.max = this.lte; - this.step = this.multipleOf; - } - _parse(input) { - if (this._def.coerce) { - input.data = Number(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.number) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.number, - received: ctx2.parsedType - }); - return INVALID; - } - let ctx = void 0; - const status = new ParseStatus(); - for (const check of this._def.checks) { - if (check.kind === "int") { - if (!util.isInteger(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: "integer", - received: "float", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: check.value, - type: "number", - inclusive: check.inclusive, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: check.value, - type: "number", - inclusive: check.inclusive, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "multipleOf") { - if (floatSafeRemainder(input.data, check.value) !== 0) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.not_multiple_of, - multipleOf: check.value, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "finite") { - if (!Number.isFinite(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.not_finite, - message: check.message - }); - status.dirty(); - } - } else { - util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil.toString(message)); - } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil.toString(message)); - } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil.toString(message)); - } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil.toString(message)); - } - setLimit(kind, value, inclusive, message) { - return new ZodNumber({ - ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil.toString(message) - } - ] - }); - } - _addCheck(check) { - return new ZodNumber({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - int(message) { - return this._addCheck({ - kind: "int", - message: errorUtil.toString(message) - }); - } - positive(message) { - return this._addCheck({ - kind: "min", - value: 0, - inclusive: false, - message: errorUtil.toString(message) - }); - } - negative(message) { - return this._addCheck({ - kind: "max", - value: 0, - inclusive: false, - message: errorUtil.toString(message) - }); - } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: 0, - inclusive: true, - message: errorUtil.toString(message) - }); - } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: 0, - inclusive: true, - message: errorUtil.toString(message) - }); - } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil.toString(message) - }); - } - finite(message) { - return this._addCheck({ - kind: "finite", - message: errorUtil.toString(message) - }); - } - safe(message) { - return this._addCheck({ - kind: "min", - inclusive: true, - value: Number.MIN_SAFE_INTEGER, - message: errorUtil.toString(message) - })._addCheck({ - kind: "max", - inclusive: true, - value: Number.MAX_SAFE_INTEGER, - message: errorUtil.toString(message) - }); - } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } - get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); - } - get isFinite() { - let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { - return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return Number.isFinite(min) && Number.isFinite(max); - } -} -ZodNumber.create = (params) => { - return new ZodNumber({ - checks: [], - typeName: ZodFirstPartyTypeKind.ZodNumber, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - ...processCreateParams(params) - }); -}; -class ZodBigInt extends ZodType { - constructor() { - super(...arguments); - this.min = this.gte; - this.max = this.lte; - } - _parse(input) { - if (this._def.coerce) { - input.data = BigInt(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.bigint) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.bigint, - received: ctx2.parsedType - }); - return INVALID; - } - let ctx = void 0; - const status = new ParseStatus(); - for (const check of this._def.checks) { - if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - type: "bigint", - minimum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - type: "bigint", - maximum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "multipleOf") { - if (input.data % check.value !== BigInt(0)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.not_multiple_of, - multipleOf: check.value, - message: check.message - }); - status.dirty(); - } - } else { - util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil.toString(message)); - } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil.toString(message)); - } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil.toString(message)); - } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil.toString(message)); - } - setLimit(kind, value, inclusive, message) { - return new ZodBigInt({ - ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil.toString(message) - } - ] - }); - } - _addCheck(check) { - return new ZodBigInt({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - positive(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: false, - message: errorUtil.toString(message) - }); - } - negative(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: false, - message: errorUtil.toString(message) - }); - } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: true, - message: errorUtil.toString(message) - }); - } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: true, - message: errorUtil.toString(message) - }); - } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil.toString(message) - }); - } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } -} -ZodBigInt.create = (params) => { - var _a; - return new ZodBigInt({ - checks: [], - typeName: ZodFirstPartyTypeKind.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, - ...processCreateParams(params) - }); -}; -class ZodBoolean extends ZodType { - _parse(input) { - if (this._def.coerce) { - input.data = Boolean(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.boolean) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.boolean, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodBoolean.create = (params) => { - return new ZodBoolean({ - typeName: ZodFirstPartyTypeKind.ZodBoolean, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - ...processCreateParams(params) - }); -}; -class ZodDate extends ZodType { - _parse(input) { - if (this._def.coerce) { - input.data = new Date(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.date) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.date, - received: ctx2.parsedType - }); - return INVALID; - } - if (isNaN(input.data.getTime())) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_date - }); - return INVALID; - } - const status = new ParseStatus(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.getTime() < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - message: check.message, - inclusive: true, - exact: false, - minimum: check.value, - type: "date" - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.getTime() > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - message: check.message, - inclusive: true, - exact: false, - maximum: check.value, - type: "date" - }); - status.dirty(); - } - } else { - util.assertNever(check); - } - } - return { - status: status.value, - value: new Date(input.data.getTime()) - }; - } - _addCheck(check) { - return new ZodDate({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - min(minDate, message) { - return this._addCheck({ - kind: "min", - value: minDate.getTime(), - message: errorUtil.toString(message) - }); - } - max(maxDate, message) { - return this._addCheck({ - kind: "max", - value: maxDate.getTime(), - message: errorUtil.toString(message) - }); - } - get minDate() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min != null ? new Date(min) : null; - } - get maxDate() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max != null ? new Date(max) : null; - } -} -ZodDate.create = (params) => { - return new ZodDate({ - checks: [], - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - typeName: ZodFirstPartyTypeKind.ZodDate, - ...processCreateParams(params) - }); -}; -class ZodSymbol extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.symbol) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.symbol, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodSymbol.create = (params) => { - return new ZodSymbol({ - typeName: ZodFirstPartyTypeKind.ZodSymbol, - ...processCreateParams(params) - }); -}; -class ZodUndefined extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.undefined) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.undefined, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodUndefined.create = (params) => { - return new ZodUndefined({ - typeName: ZodFirstPartyTypeKind.ZodUndefined, - ...processCreateParams(params) - }); -}; -class ZodNull extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.null) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.null, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodNull.create = (params) => { - return new ZodNull({ - typeName: ZodFirstPartyTypeKind.ZodNull, - ...processCreateParams(params) - }); -}; -class ZodAny extends ZodType { - constructor() { - super(...arguments); - this._any = true; - } - _parse(input) { - return OK(input.data); - } -} -ZodAny.create = (params) => { - return new ZodAny({ - typeName: ZodFirstPartyTypeKind.ZodAny, - ...processCreateParams(params) - }); -}; -class ZodUnknown extends ZodType { - constructor() { - super(...arguments); - this._unknown = true; - } - _parse(input) { - return OK(input.data); - } -} -ZodUnknown.create = (params) => { - return new ZodUnknown({ - typeName: ZodFirstPartyTypeKind.ZodUnknown, - ...processCreateParams(params) - }); -}; -class ZodNever extends ZodType { - _parse(input) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.never, - received: ctx.parsedType - }); - return INVALID; - } -} -ZodNever.create = (params) => { - return new ZodNever({ - typeName: ZodFirstPartyTypeKind.ZodNever, - ...processCreateParams(params) - }); -}; -class ZodVoid extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.undefined) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.void, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodVoid.create = (params) => { - return new ZodVoid({ - typeName: ZodFirstPartyTypeKind.ZodVoid, - ...processCreateParams(params) - }); -}; -class ZodArray extends ZodType { - _parse(input) { - const { ctx, status } = this._processInputParams(input); - const def = this._def; - if (ctx.parsedType !== ZodParsedType.array) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.array, - received: ctx.parsedType - }); - return INVALID; - } - if (def.exactLength !== null) { - const tooBig = ctx.data.length > def.exactLength.value; - const tooSmall = ctx.data.length < def.exactLength.value; - if (tooBig || tooSmall) { - addIssueToContext(ctx, { - code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, - minimum: tooSmall ? def.exactLength.value : void 0, - maximum: tooBig ? def.exactLength.value : void 0, - type: "array", - inclusive: true, - exact: true, - message: def.exactLength.message - }); - status.dirty(); - } - } - if (def.minLength !== null) { - if (ctx.data.length < def.minLength.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: def.minLength.value, - type: "array", - inclusive: true, - exact: false, - message: def.minLength.message - }); - status.dirty(); - } - } - if (def.maxLength !== null) { - if (ctx.data.length > def.maxLength.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: def.maxLength.value, - type: "array", - inclusive: true, - exact: false, - message: def.maxLength.message - }); - status.dirty(); - } - } - if (ctx.common.async) { - return Promise.all([...ctx.data].map((item, i2) => { - return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); - })).then((result2) => { - return ParseStatus.mergeArray(status, result2); - }); - } - const result = [...ctx.data].map((item, i2) => { - return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); - }); - return ParseStatus.mergeArray(status, result); - } - get element() { - return this._def.type; - } - min(minLength, message) { - return new ZodArray({ - ...this._def, - minLength: { value: minLength, message: errorUtil.toString(message) } - }); - } - max(maxLength, message) { - return new ZodArray({ - ...this._def, - maxLength: { value: maxLength, message: errorUtil.toString(message) } - }); - } - length(len, message) { - return new ZodArray({ - ...this._def, - exactLength: { value: len, message: errorUtil.toString(message) } - }); - } - nonempty(message) { - return this.min(1, message); - } -} -ZodArray.create = (schema, params) => { - return new ZodArray({ - type: schema, - minLength: null, - maxLength: null, - exactLength: null, - typeName: ZodFirstPartyTypeKind.ZodArray, - ...processCreateParams(params) - }); -}; -function deepPartialify(schema) { - if (schema instanceof ZodObject) { - const newShape = {}; - for (const key in schema.shape) { - const fieldSchema = schema.shape[key]; - newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); - } - return new ZodObject({ - ...schema._def, - shape: () => newShape - }); - } else if (schema instanceof ZodArray) { - return new ZodArray({ - ...schema._def, - type: deepPartialify(schema.element) - }); - } else if (schema instanceof ZodOptional) { - return ZodOptional.create(deepPartialify(schema.unwrap())); - } else if (schema instanceof ZodNullable) { - return ZodNullable.create(deepPartialify(schema.unwrap())); - } else if (schema instanceof ZodTuple) { - return ZodTuple.create(schema.items.map((item) => deepPartialify(item))); - } else { - return schema; - } -} -class ZodObject extends ZodType { - constructor() { - super(...arguments); - this._cached = null; - this.nonstrict = this.passthrough; - this.augment = this.extend; - } - _getCached() { - if (this._cached !== null) - return this._cached; - const shape = this._def.shape(); - const keys2 = util.objectKeys(shape); - return this._cached = { shape, keys: keys2 }; - } - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.object) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, - received: ctx2.parsedType - }); - return INVALID; - } - const { status, ctx } = this._processInputParams(input); - const { shape, keys: shapeKeys } = this._getCached(); - const extraKeys = []; - if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { - for (const key in ctx.data) { - if (!shapeKeys.includes(key)) { - extraKeys.push(key); - } - } - } - const pairs = []; - for (const key of shapeKeys) { - const keyValidator = shape[key]; - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), - alwaysSet: key in ctx.data - }); - } - if (this._def.catchall instanceof ZodNever) { - const unknownKeys = this._def.unknownKeys; - if (unknownKeys === "passthrough") { - for (const key of extraKeys) { - pairs.push({ - key: { status: "valid", value: key }, - value: { status: "valid", value: ctx.data[key] } - }); - } - } else if (unknownKeys === "strict") { - if (extraKeys.length > 0) { - addIssueToContext(ctx, { - code: ZodIssueCode.unrecognized_keys, - keys: extraKeys - }); - status.dirty(); - } - } else if (unknownKeys === "strip") - ; - else { - throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); - } - } else { - const catchall = this._def.catchall; - for (const key of extraKeys) { - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: catchall._parse( - new ParseInputLazyPath(ctx, value, ctx.path, key) - //, ctx.child(key), value, getParsedType(value) - ), - alwaysSet: key in ctx.data - }); - } - } - if (ctx.common.async) { - return Promise.resolve().then(async () => { - const syncPairs = []; - for (const pair of pairs) { - const key = await pair.key; - syncPairs.push({ - key, - value: await pair.value, - alwaysSet: pair.alwaysSet - }); - } - return syncPairs; - }).then((syncPairs) => { - return ParseStatus.mergeObjectSync(status, syncPairs); - }); - } else { - return ParseStatus.mergeObjectSync(status, pairs); - } - } - get shape() { - return this._def.shape(); - } - strict(message) { - errorUtil.errToObj; - return new ZodObject({ - ...this._def, - unknownKeys: "strict", - ...message !== void 0 ? { - errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; - if (issue.code === "unrecognized_keys") - return { - message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError - }; - return { - message: defaultError - }; - } - } : {} - }); - } - strip() { - return new ZodObject({ - ...this._def, - unknownKeys: "strip" - }); - } - passthrough() { - return new ZodObject({ - ...this._def, - unknownKeys: "passthrough" - }); - } - // const AugmentFactory = - // (def: Def) => - // ( - // augmentation: Augmentation - // ): ZodObject< - // extendShape, Augmentation>, - // Def["unknownKeys"], - // Def["catchall"] - // > => { - // return new ZodObject({ - // ...def, - // shape: () => ({ - // ...def.shape(), - // ...augmentation, - // }), - // }) as any; - // }; - extend(augmentation) { - return new ZodObject({ - ...this._def, - shape: () => ({ - ...this._def.shape(), - ...augmentation - }) - }); - } - /** - * Prior to zod@1.0.12 there was a bug in the - * inferred type of merged objects. Please - * upgrade if you are experiencing issues. - */ - merge(merging) { - const merged = new ZodObject({ - unknownKeys: merging._def.unknownKeys, - catchall: merging._def.catchall, - shape: () => ({ - ...this._def.shape(), - ...merging._def.shape() - }), - typeName: ZodFirstPartyTypeKind.ZodObject - }); - return merged; - } - // merge< - // Incoming extends AnyZodObject, - // Augmentation extends Incoming["shape"], - // NewOutput extends { - // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation - // ? Augmentation[k]["_output"] - // : k extends keyof Output - // ? Output[k] - // : never; - // }, - // NewInput extends { - // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation - // ? Augmentation[k]["_input"] - // : k extends keyof Input - // ? Input[k] - // : never; - // } - // >( - // merging: Incoming - // ): ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"], - // NewOutput, - // NewInput - // > { - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - setKey(key, schema) { - return this.augment({ [key]: schema }); - } - // merge( - // merging: Incoming - // ): //ZodObject = (merging) => { - // ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"] - // > { - // // const mergedShape = objectUtil.mergeShapes( - // // this._def.shape(), - // // merging._def.shape() - // // ); - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - catchall(index) { - return new ZodObject({ - ...this._def, - catchall: index - }); - } - pick(mask) { - const shape = {}; - util.objectKeys(mask).forEach((key) => { - if (mask[key] && this.shape[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ - ...this._def, - shape: () => shape - }); - } - omit(mask) { - const shape = {}; - util.objectKeys(this.shape).forEach((key) => { - if (!mask[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ - ...this._def, - shape: () => shape - }); - } - /** - * @deprecated - */ - deepPartial() { - return deepPartialify(this); - } - partial(mask) { - const newShape = {}; - util.objectKeys(this.shape).forEach((key) => { - const fieldSchema = this.shape[key]; - if (mask && !mask[key]) { - newShape[key] = fieldSchema; - } else { - newShape[key] = fieldSchema.optional(); - } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape - }); - } - required(mask) { - const newShape = {}; - util.objectKeys(this.shape).forEach((key) => { - if (mask && !mask[key]) { - newShape[key] = this.shape[key]; - } else { - const fieldSchema = this.shape[key]; - let newField = fieldSchema; - while (newField instanceof ZodOptional) { - newField = newField._def.innerType; - } - newShape[key] = newField; - } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape - }); - } - keyof() { - return createZodEnum(util.objectKeys(this.shape)); - } -} -ZodObject.create = (shape, params) => { - return new ZodObject({ - shape: () => shape, - unknownKeys: "strip", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, - ...processCreateParams(params) - }); -}; -ZodObject.strictCreate = (shape, params) => { - return new ZodObject({ - shape: () => shape, - unknownKeys: "strict", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, - ...processCreateParams(params) - }); -}; -ZodObject.lazycreate = (shape, params) => { - return new ZodObject({ - shape, - unknownKeys: "strip", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, - ...processCreateParams(params) - }); -}; -class ZodUnion extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - const options = this._def.options; - function handleResults(results) { - for (const result of results) { - if (result.result.status === "valid") { - return result.result; - } - } - for (const result of results) { - if (result.result.status === "dirty") { - ctx.common.issues.push(...result.ctx.common.issues); - return result.result; - } - } - const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues)); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union, - unionErrors - }); - return INVALID; - } - if (ctx.common.async) { - return Promise.all(options.map(async (option) => { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - return { - result: await option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }), - ctx: childCtx - }; - })).then(handleResults); - } else { - let dirty = void 0; - const issues = []; - for (const option of options) { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - const result = option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }); - if (result.status === "valid") { - return result; - } else if (result.status === "dirty" && !dirty) { - dirty = { result, ctx: childCtx }; - } - if (childCtx.common.issues.length) { - issues.push(childCtx.common.issues); - } - } - if (dirty) { - ctx.common.issues.push(...dirty.ctx.common.issues); - return dirty.result; - } - const unionErrors = issues.map((issues2) => new ZodError(issues2)); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union, - unionErrors - }); - return INVALID; - } - } - get options() { - return this._def.options; - } -} -ZodUnion.create = (types2, params) => { - return new ZodUnion({ - options: types2, - typeName: ZodFirstPartyTypeKind.ZodUnion, - ...processCreateParams(params) - }); -}; -const getDiscriminator = (type2) => { - if (type2 instanceof ZodLazy) { - return getDiscriminator(type2.schema); - } else if (type2 instanceof ZodEffects) { - return getDiscriminator(type2.innerType()); - } else if (type2 instanceof ZodLiteral) { - return [type2.value]; - } else if (type2 instanceof ZodEnum) { - return type2.options; - } else if (type2 instanceof ZodNativeEnum) { - return Object.keys(type2.enum); - } else if (type2 instanceof ZodDefault) { - return getDiscriminator(type2._def.innerType); - } else if (type2 instanceof ZodUndefined) { - return [void 0]; - } else if (type2 instanceof ZodNull) { - return [null]; - } else { - return null; - } -}; -class ZodDiscriminatedUnion extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.object) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, - received: ctx.parsedType - }); - return INVALID; - } - const discriminator = this.discriminator; - const discriminatorValue = ctx.data[discriminator]; - const option = this.optionsMap.get(discriminatorValue); - if (!option) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union_discriminator, - options: Array.from(this.optionsMap.keys()), - path: [discriminator] - }); - return INVALID; - } - if (ctx.common.async) { - return option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } else { - return option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } - } - get discriminator() { - return this._def.discriminator; - } - get options() { - return this._def.options; - } - get optionsMap() { - return this._def.optionsMap; - } - /** - * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. - * However, it only allows a union of objects, all of which need to share a discriminator property. This property must - * have a different value for each object in the union. - * @param discriminator the name of the discriminator property - * @param types an array of object schemas - * @param params - */ - static create(discriminator, options, params) { - const optionsMap = /* @__PURE__ */ new Map(); - for (const type2 of options) { - const discriminatorValues = getDiscriminator(type2.shape[discriminator]); - if (!discriminatorValues) { - throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); - } - for (const value of discriminatorValues) { - if (optionsMap.has(value)) { - throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); - } - optionsMap.set(value, type2); - } - } - return new ZodDiscriminatedUnion({ - typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, - discriminator, - options, - optionsMap, - ...processCreateParams(params) - }); - } -} -function mergeValues(a3, b3) { - const aType = getParsedType(a3); - const bType = getParsedType(b3); - if (a3 === b3) { - return { valid: true, data: a3 }; - } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) { - const bKeys = util.objectKeys(b3); - const sharedKeys = util.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1); - const newObj = { ...a3, ...b3 }; - for (const key of sharedKeys) { - const sharedValue = mergeValues(a3[key], b3[key]); - if (!sharedValue.valid) { - return { valid: false }; - } - newObj[key] = sharedValue.data; - } - return { valid: true, data: newObj }; - } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { - if (a3.length !== b3.length) { - return { valid: false }; - } - const newArray = []; - for (let index = 0; index < a3.length; index++) { - const itemA = a3[index]; - const itemB = b3[index]; - const sharedValue = mergeValues(itemA, itemB); - if (!sharedValue.valid) { - return { valid: false }; - } - newArray.push(sharedValue.data); - } - return { valid: true, data: newArray }; - } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a3 === +b3) { - return { valid: true, data: a3 }; - } else { - return { valid: false }; - } -} -class ZodIntersection extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const handleParsed = (parsedLeft, parsedRight) => { - if (isAborted(parsedLeft) || isAborted(parsedRight)) { - return INVALID; - } - const merged = mergeValues(parsedLeft.value, parsedRight.value); - if (!merged.valid) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_intersection_types - }); - return INVALID; - } - if (isDirty(parsedLeft) || isDirty(parsedRight)) { - status.dirty(); - } - return { status: status.value, value: merged.data }; - }; - if (ctx.common.async) { - return Promise.all([ - this._def.left._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), - this._def.right._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }) - ]).then(([left, right]) => handleParsed(left, right)); - } else { - return handleParsed(this._def.left._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), this._def.right._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - })); - } - } -} -ZodIntersection.create = (left, right, params) => { - return new ZodIntersection({ - left, - right, - typeName: ZodFirstPartyTypeKind.ZodIntersection, - ...processCreateParams(params) - }); -}; -class ZodTuple extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.array) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.array, - received: ctx.parsedType - }); - return INVALID; - } - if (ctx.data.length < this._def.items.length) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - return INVALID; - } - const rest = this._def.rest; - if (!rest && ctx.data.length > this._def.items.length) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - status.dirty(); - } - const items = [...ctx.data].map((item, itemIndex) => { - const schema = this._def.items[itemIndex] || this._def.rest; - if (!schema) - return null; - return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)); - }).filter((x2) => !!x2); - if (ctx.common.async) { - return Promise.all(items).then((results) => { - return ParseStatus.mergeArray(status, results); - }); - } else { - return ParseStatus.mergeArray(status, items); - } - } - get items() { - return this._def.items; - } - rest(rest) { - return new ZodTuple({ - ...this._def, - rest - }); - } -} -ZodTuple.create = (schemas, params) => { - if (!Array.isArray(schemas)) { - throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); - } - return new ZodTuple({ - items: schemas, - typeName: ZodFirstPartyTypeKind.ZodTuple, - rest: null, - ...processCreateParams(params) - }); -}; -class ZodRecord extends ZodType { - get keySchema() { - return this._def.keyType; - } - get valueSchema() { - return this._def.valueType; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.object) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, - received: ctx.parsedType - }); - return INVALID; - } - const pairs = []; - const keyType = this._def.keyType; - const valueType = this._def.valueType; - for (const key in ctx.data) { - pairs.push({ - key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), - value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) - }); - } - if (ctx.common.async) { - return ParseStatus.mergeObjectAsync(status, pairs); - } else { - return ParseStatus.mergeObjectSync(status, pairs); - } - } - get element() { - return this._def.valueType; - } - static create(first, second, third) { - if (second instanceof ZodType) { - return new ZodRecord({ - keyType: first, - valueType: second, - typeName: ZodFirstPartyTypeKind.ZodRecord, - ...processCreateParams(third) - }); - } - return new ZodRecord({ - keyType: ZodString.create(), - valueType: first, - typeName: ZodFirstPartyTypeKind.ZodRecord, - ...processCreateParams(second) - }); - } -} -class ZodMap extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.map) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.map, - received: ctx.parsedType - }); - return INVALID; - } - const keyType = this._def.keyType; - const valueType = this._def.valueType; - const pairs = [...ctx.data.entries()].map(([key, value], index) => { - return { - key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])), - value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"])) - }; - }); - if (ctx.common.async) { - const finalMap = /* @__PURE__ */ new Map(); - return Promise.resolve().then(async () => { - for (const pair of pairs) { - const key = await pair.key; - const value = await pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - }); - } else { - const finalMap = /* @__PURE__ */ new Map(); - for (const pair of pairs) { - const key = pair.key; - const value = pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - } - } -} -ZodMap.create = (keyType, valueType, params) => { - return new ZodMap({ - valueType, - keyType, - typeName: ZodFirstPartyTypeKind.ZodMap, - ...processCreateParams(params) - }); -}; -class ZodSet extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.set) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.set, - received: ctx.parsedType - }); - return INVALID; - } - const def = this._def; - if (def.minSize !== null) { - if (ctx.data.size < def.minSize.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: def.minSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.minSize.message - }); - status.dirty(); - } - } - if (def.maxSize !== null) { - if (ctx.data.size > def.maxSize.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: def.maxSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.maxSize.message - }); - status.dirty(); - } - } - const valueType = this._def.valueType; - function finalizeSet(elements2) { - const parsedSet = /* @__PURE__ */ new Set(); - for (const element of elements2) { - if (element.status === "aborted") - return INVALID; - if (element.status === "dirty") - status.dirty(); - parsedSet.add(element.value); - } - return { status: status.value, value: parsedSet }; - } - const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2))); - if (ctx.common.async) { - return Promise.all(elements).then((elements2) => finalizeSet(elements2)); - } else { - return finalizeSet(elements); - } - } - min(minSize, message) { - return new ZodSet({ - ...this._def, - minSize: { value: minSize, message: errorUtil.toString(message) } - }); - } - max(maxSize, message) { - return new ZodSet({ - ...this._def, - maxSize: { value: maxSize, message: errorUtil.toString(message) } - }); - } - size(size, message) { - return this.min(size, message).max(size, message); - } - nonempty(message) { - return this.min(1, message); - } -} -ZodSet.create = (valueType, params) => { - return new ZodSet({ - valueType, - minSize: null, - maxSize: null, - typeName: ZodFirstPartyTypeKind.ZodSet, - ...processCreateParams(params) - }); -}; -class ZodFunction extends ZodType { - constructor() { - super(...arguments); - this.validate = this.implement; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.function) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.function, - received: ctx.parsedType - }); - return INVALID; - } - function makeArgsIssue(args, error) { - return makeIssue({ - data: args, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap(), - errorMap - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode.invalid_arguments, - argumentsError: error - } - }); - } - function makeReturnsIssue(returns, error) { - return makeIssue({ - data: returns, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap(), - errorMap - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode.invalid_return_type, - returnTypeError: error - } - }); - } - const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; - if (this._def.returns instanceof ZodPromise) { - return OK(async (...args) => { - const error = new ZodError([]); - const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => { - error.addIssue(makeArgsIssue(args, e)); - throw error; - }); - const result = await fn2(...parsedArgs); - const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => { - error.addIssue(makeReturnsIssue(result, e)); - throw error; - }); - return parsedReturns; - }); - } else { - return OK((...args) => { - const parsedArgs = this._def.args.safeParse(args, params); - if (!parsedArgs.success) { - throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); - } - const result = fn2(...parsedArgs.data); - const parsedReturns = this._def.returns.safeParse(result, params); - if (!parsedReturns.success) { - throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); - } - return parsedReturns.data; - }); - } - } - parameters() { - return this._def.args; - } - returnType() { - return this._def.returns; - } - args(...items) { - return new ZodFunction({ - ...this._def, - args: ZodTuple.create(items).rest(ZodUnknown.create()) - }); - } - returns(returnType) { - return new ZodFunction({ - ...this._def, - returns: returnType - }); - } - implement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - strictImplement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - static create(args, returns, params) { - return new ZodFunction({ - args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()), - returns: returns || ZodUnknown.create(), - typeName: ZodFirstPartyTypeKind.ZodFunction, - ...processCreateParams(params) - }); - } -} -class ZodLazy extends ZodType { - get schema() { - return this._def.getter(); - } - _parse(input) { - const { ctx } = this._processInputParams(input); - const lazySchema = this._def.getter(); - return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); - } -} -ZodLazy.create = (getter, params) => { - return new ZodLazy({ - getter, - typeName: ZodFirstPartyTypeKind.ZodLazy, - ...processCreateParams(params) - }); -}; -class ZodLiteral extends ZodType { - _parse(input) { - if (input.data !== this._def.value) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_literal, - expected: this._def.value - }); - return INVALID; - } - return { status: "valid", value: input.data }; - } - get value() { - return this._def.value; - } -} -ZodLiteral.create = (value, params) => { - return new ZodLiteral({ - value, - typeName: ZodFirstPartyTypeKind.ZodLiteral, - ...processCreateParams(params) - }); -}; -function createZodEnum(values, params) { - return new ZodEnum({ - values, - typeName: ZodFirstPartyTypeKind.ZodEnum, - ...processCreateParams(params) - }); -} -class ZodEnum extends ZodType { - _parse(input) { - if (typeof input.data !== "string") { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext(ctx, { - expected: util.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode.invalid_type - }); - return INVALID; - } - if (this._def.values.indexOf(input.data) === -1) { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_enum_value, - options: expectedValues - }); - return INVALID; - } - return OK(input.data); - } - get options() { - return this._def.values; - } - get enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - get Values() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - get Enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - extract(values) { - return ZodEnum.create(values); - } - exclude(values) { - return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); - } -} -ZodEnum.create = createZodEnum; -class ZodNativeEnum extends ZodType { - _parse(input) { - const nativeEnumValues = util.getValidEnumValues(this._def.values); - const ctx = this._getOrReturnCtx(input); - if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { - const expectedValues = util.objectValues(nativeEnumValues); - addIssueToContext(ctx, { - expected: util.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode.invalid_type - }); - return INVALID; - } - if (nativeEnumValues.indexOf(input.data) === -1) { - const expectedValues = util.objectValues(nativeEnumValues); - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_enum_value, - options: expectedValues - }); - return INVALID; - } - return OK(input.data); - } - get enum() { - return this._def.values; - } -} -ZodNativeEnum.create = (values, params) => { - return new ZodNativeEnum({ - values, - typeName: ZodFirstPartyTypeKind.ZodNativeEnum, - ...processCreateParams(params) - }); -}; -class ZodPromise extends ZodType { - unwrap() { - return this._def.type; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.promise, - received: ctx.parsedType - }); - return INVALID; - } - const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); - return OK(promisified.then((data) => { - return this._def.type.parseAsync(data, { - path: ctx.path, - errorMap: ctx.common.contextualErrorMap - }); - })); - } -} -ZodPromise.create = (schema, params) => { - return new ZodPromise({ - type: schema, - typeName: ZodFirstPartyTypeKind.ZodPromise, - ...processCreateParams(params) - }); -}; -class ZodEffects extends ZodType { - innerType() { - return this._def.schema; - } - sourceType() { - return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const effect = this._def.effect || null; - if (effect.type === "preprocess") { - const processed = effect.transform(ctx.data); - if (ctx.common.async) { - return Promise.resolve(processed).then((processed2) => { - return this._def.schema._parseAsync({ - data: processed2, - path: ctx.path, - parent: ctx - }); - }); - } else { - return this._def.schema._parseSync({ - data: processed, - path: ctx.path, - parent: ctx - }); - } - } - const checkCtx = { - addIssue: (arg) => { - addIssueToContext(ctx, arg); - if (arg.fatal) { - status.abort(); - } else { - status.dirty(); - } - }, - get path() { - return ctx.path; - } - }; - checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); - if (effect.type === "refinement") { - const executeRefinement = (acc) => { - const result = effect.refinement(acc, checkCtx); - if (ctx.common.async) { - return Promise.resolve(result); - } - if (result instanceof Promise) { - throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); - } - return acc; - }; - if (ctx.common.async === false) { - const inner = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inner.status === "aborted") - return INVALID; - if (inner.status === "dirty") - status.dirty(); - executeRefinement(inner.value); - return { status: status.value, value: inner.value }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { - if (inner.status === "aborted") - return INVALID; - if (inner.status === "dirty") - status.dirty(); - return executeRefinement(inner.value).then(() => { - return { status: status.value, value: inner.value }; - }); - }); - } - } - if (effect.type === "transform") { - if (ctx.common.async === false) { - const base3 = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (!isValid(base3)) - return base3; - const result = effect.transform(base3.value, checkCtx); - if (result instanceof Promise) { - throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); - } - return { status: status.value, value: result }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { - if (!isValid(base3)) - return base3; - return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); - }); - } - } - util.assertNever(effect); - } -} -ZodEffects.create = (schema, effect, params) => { - return new ZodEffects({ - schema, - typeName: ZodFirstPartyTypeKind.ZodEffects, - effect, - ...processCreateParams(params) - }); -}; -ZodEffects.createWithPreprocess = (preprocess, schema, params) => { - return new ZodEffects({ - schema, - effect: { type: "preprocess", transform: preprocess }, - typeName: ZodFirstPartyTypeKind.ZodEffects, - ...processCreateParams(params) - }); -}; -class ZodOptional extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType.undefined) { - return OK(void 0); - } - return this._def.innerType._parse(input); - } - unwrap() { - return this._def.innerType; - } -} -ZodOptional.create = (type2, params) => { - return new ZodOptional({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodOptional, - ...processCreateParams(params) - }); -}; -class ZodNullable extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType.null) { - return OK(null); - } - return this._def.innerType._parse(input); - } - unwrap() { - return this._def.innerType; - } -} -ZodNullable.create = (type2, params) => { - return new ZodNullable({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodNullable, - ...processCreateParams(params) - }); -}; -class ZodDefault extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - let data = ctx.data; - if (ctx.parsedType === ZodParsedType.undefined) { - data = this._def.defaultValue(); - } - return this._def.innerType._parse({ - data, - path: ctx.path, - parent: ctx - }); - } - removeDefault() { - return this._def.innerType; - } -} -ZodDefault.create = (type2, params) => { - return new ZodDefault({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodDefault, - defaultValue: typeof params.default === "function" ? params.default : () => params.default, - ...processCreateParams(params) - }); -}; -class ZodCatch extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - const newCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - } - }; - const result = this._def.innerType._parse({ - data: newCtx.data, - path: newCtx.path, - parent: { - ...newCtx - } - }); - if (isAsync(result)) { - return result.then((result2) => { - return { - status: "valid", - value: result2.status === "valid" ? result2.value : this._def.catchValue({ - get error() { - return new ZodError(newCtx.common.issues); - } - }) - }; - }); - } else { - return { - status: "valid", - value: result.status === "valid" ? result.value : this._def.catchValue({ - get error() { - return new ZodError(newCtx.common.issues); - } - }) - }; - } - } - removeCatch() { - return this._def.innerType; - } -} -ZodCatch.create = (type2, params) => { - return new ZodCatch({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodCatch, - catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, - ...processCreateParams(params) - }); -}; -class ZodNaN extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.nan) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.nan, - received: ctx.parsedType - }); - return INVALID; - } - return { status: "valid", value: input.data }; - } -} -ZodNaN.create = (params) => { - return new ZodNaN({ - typeName: ZodFirstPartyTypeKind.ZodNaN, - ...processCreateParams(params) - }); -}; -const BRAND = Symbol("zod_brand"); -class ZodBranded extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - const data = ctx.data; - return this._def.type._parse({ - data, - path: ctx.path, - parent: ctx - }); - } - unwrap() { - return this._def.type; - } -} -class ZodPipeline extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.common.async) { - const handleAsync = async () => { - const inResult = await this._def.in._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID; - if (inResult.status === "dirty") { - status.dirty(); - return DIRTY(inResult.value); - } else { - return this._def.out._parseAsync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - }; - return handleAsync(); - } else { - const inResult = this._def.in._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID; - if (inResult.status === "dirty") { - status.dirty(); - return { - status: "dirty", - value: inResult.value - }; - } else { - return this._def.out._parseSync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - } - } - static create(a3, b3) { - return new ZodPipeline({ - in: a3, - out: b3, - typeName: ZodFirstPartyTypeKind.ZodPipeline - }); - } -} -const custom = (check, params = {}, fatal) => { - if (check) - return ZodAny.create().superRefine((data, ctx) => { - var _a, _b; - if (!check(data)) { - const p3 = typeof params === "function" ? params(data) : params; - const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p3 === "string" ? { message: p3 } : p3; - ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); - } - }); - return ZodAny.create(); -}; -const late = { - object: ZodObject.lazycreate -}; -var ZodFirstPartyTypeKind; -(function(ZodFirstPartyTypeKind2) { - ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; - ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; - ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; - ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; - ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; - ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; - ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; - ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; - ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; - ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; - ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; - ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; - ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; - ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; - ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; - ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; - ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; - ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; - ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; - ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; - ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; - ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; - ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; - ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; - ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; - ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; - ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; - ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; - ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; - ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; - ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; - ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; - ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; - ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; - ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; -})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); -const instanceOfType = (cls, params = { - message: `Input not instance of ${cls.name}` -}) => custom((data) => data instanceof cls, params); -const stringType = ZodString.create; -const numberType = ZodNumber.create; -const nanType = ZodNaN.create; -const bigIntType = ZodBigInt.create; -const booleanType = ZodBoolean.create; -const dateType = ZodDate.create; -const symbolType = ZodSymbol.create; -const undefinedType = ZodUndefined.create; -const nullType = ZodNull.create; -const anyType = ZodAny.create; -const unknownType = ZodUnknown.create; -const neverType = ZodNever.create; -const voidType = ZodVoid.create; -const arrayType = ZodArray.create; -const objectType = ZodObject.create; -const strictObjectType = ZodObject.strictCreate; -const unionType = ZodUnion.create; -const discriminatedUnionType = ZodDiscriminatedUnion.create; -const intersectionType = ZodIntersection.create; -const tupleType = ZodTuple.create; -const recordType = ZodRecord.create; -const mapType = ZodMap.create; -const setType = ZodSet.create; -const functionType = ZodFunction.create; -const lazyType = ZodLazy.create; -const literalType = ZodLiteral.create; -const enumType = ZodEnum.create; -const nativeEnumType = ZodNativeEnum.create; -const promiseType = ZodPromise.create; -const effectsType = ZodEffects.create; -const optionalType = ZodOptional.create; -const nullableType = ZodNullable.create; -const preprocessType = ZodEffects.createWithPreprocess; -const pipelineType = ZodPipeline.create; -const ostring = () => stringType().optional(); -const onumber = () => numberType().optional(); -const oboolean = () => booleanType().optional(); -const coerce = { - string: (arg) => ZodString.create({ ...arg, coerce: true }), - number: (arg) => ZodNumber.create({ ...arg, coerce: true }), - boolean: (arg) => ZodBoolean.create({ - ...arg, - coerce: true - }), - bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }), - date: (arg) => ZodDate.create({ ...arg, coerce: true }) -}; -const NEVER = INVALID; -var z2 = /* @__PURE__ */ Object.freeze({ - __proto__: null, - defaultErrorMap: errorMap, - setErrorMap, - getErrorMap, - makeIssue, - EMPTY_PATH, - addIssueToContext, - ParseStatus, - INVALID, - DIRTY, - OK, - isAborted, - isDirty, - isValid, - isAsync, - get util() { - return util; - }, - get objectUtil() { - return objectUtil; - }, - ZodParsedType, - getParsedType, - ZodType, - ZodString, - ZodNumber, - ZodBigInt, - ZodBoolean, - ZodDate, - ZodSymbol, - ZodUndefined, - ZodNull, - ZodAny, - ZodUnknown, - ZodNever, - ZodVoid, - ZodArray, - ZodObject, - ZodUnion, - ZodDiscriminatedUnion, - ZodIntersection, - ZodTuple, - ZodRecord, - ZodMap, - ZodSet, - ZodFunction, - ZodLazy, - ZodLiteral, - ZodEnum, - ZodNativeEnum, - ZodPromise, - ZodEffects, - ZodTransformer: ZodEffects, - ZodOptional, - ZodNullable, - ZodDefault, - ZodCatch, - ZodNaN, - BRAND, - ZodBranded, - ZodPipeline, - custom, - Schema: ZodType, - ZodSchema: ZodType, - late, - get ZodFirstPartyTypeKind() { - return ZodFirstPartyTypeKind; - }, - coerce, - any: anyType, - array: arrayType, - bigint: bigIntType, - boolean: booleanType, - date: dateType, - discriminatedUnion: discriminatedUnionType, - effect: effectsType, - "enum": enumType, - "function": functionType, - "instanceof": instanceOfType, - intersection: intersectionType, - lazy: lazyType, - literal: literalType, - map: mapType, - nan: nanType, - nativeEnum: nativeEnumType, - never: neverType, - "null": nullType, - nullable: nullableType, - number: numberType, - object: objectType, - oboolean, - onumber, - optional: optionalType, - ostring, - pipeline: pipelineType, - preprocess: preprocessType, - promise: promiseType, - record: recordType, - set: setType, - strictObject: strictObjectType, - string: stringType, - symbol: symbolType, - transformer: effectsType, - tuple: tupleType, - "undefined": undefinedType, - union: unionType, - unknown: unknownType, - "void": voidType, - NEVER, - ZodIssueCode, - quotelessJson, - ZodError -}); -const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; -const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; -const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; -const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; -const aleoFieldRegex = /^\d+field$/; -const aleoU32 = /^\d+u32$/; -const aleoU64 = /^\d+u64$/; -const zodAddress = z2.string().regex(aleoAddressRegex); -const zodViewKey = z2.string().regex(aleoViewKeyRegex); -const zodPrivateKey = z2.string().regex(aleoPrivateKeyRegex); -const zodTransactionId = z2.string().regex(aleoTransactionIdRegex); -const zodField = z2.string().regex(aleoFieldRegex); -const zodU32 = z2.string().regex(aleoU32); -const zodU64 = z2.string().regex(aleoU64); -var InputOutputType; -(function(InputOutputType2) { - InputOutputType2["Record"] = "record"; - InputOutputType2["OutputRecord"] = "outputRecord"; - InputOutputType2["Public"] = "public"; - InputOutputType2["Private"] = "private"; - InputOutputType2["Constant"] = "constant"; - InputOutputType2["Future"] = "future"; - InputOutputType2["ExternalRecord"] = "external_record"; -})(InputOutputType || (InputOutputType = {})); -var EventType; -(function(EventType2) { - EventType2["Deploy"] = "Deploy"; - EventType2["Execute"] = "Execute"; - EventType2["Send"] = "Send"; - EventType2["Receive"] = "Receive"; - EventType2["Join"] = "Join"; - EventType2["Split"] = "Split"; - EventType2["Shield"] = "Shield"; - EventType2["Unshield"] = "Unshield"; -})(EventType || (EventType = {})); -var EventStatus; -(function(EventStatus2) { - EventStatus2["Creating"] = "Creating"; - EventStatus2["Pending"] = "Pending"; - EventStatus2["Settled"] = "Settled"; - EventStatus2["Failed"] = "Failed"; -})(EventStatus || (EventStatus = {})); -var Visibility; -(function(Visibility2) { - Visibility2["Private"] = "Private"; - Visibility2["Public"] = "Public"; -})(Visibility || (Visibility = {})); -var Network; -(function(Network2) { - Network2["AleoTestnet"] = "AleoTestnet"; - Network2["AleoMainnet"] = "AleoMainnet"; -})(Network || (Network = {})); -var AssetType; -(function(AssetType2) { - AssetType2[AssetType2["ALEO"] = 0] = "ALEO"; -})(AssetType || (AssetType = {})); -const zodEventType = z2.nativeEnum(EventType); -const zodEventStatus = z2.nativeEnum(EventStatus); -const zodNetwork = z2.nativeEnum(Network); -const zodVisibility = z2.nativeEnum(Visibility); -const requestSignature = async ({ - message, - address -}) => { - const connection2 = await getWalletConnectModalSignClient(); - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (!session || !connection2) { - return { error: "no session or connection" }; - } - try { - const response = await connection2.request({ - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "requestSignature", - params: { - message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 - } - } - }); - return response; - } catch (e) { - console.error("signature error", e); - const error = e.message; - return { error }; - } -}; -const PAGE_SIZE = 20; -var browser = { exports: {} }; -var ms; -var hasRequiredMs; -function requireMs() { - if (hasRequiredMs) - return ms; - hasRequiredMs = 1; - var s2 = 1e3; - var m2 = s2 * 60; - var h4 = m2 * 60; - var d3 = h4 * 24; - var w3 = d3 * 7; - var y3 = d3 * 365.25; - ms = function(val, options) { - options = options || {}; - var type2 = typeof val; - if (type2 === "string" && val.length > 0) { - return parse(val); - } else if (type2 === "number" && isFinite(val)) { - return options.long ? fmtLong(val) : fmtShort(val); - } - throw new Error( - "val is not a non-empty string or a valid number. val=" + JSON.stringify(val) - ); - }; - function parse(str) { - str = String(str); - if (str.length > 100) { - return; - } - var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( - str - ); - if (!match) { - return; - } - var n3 = parseFloat(match[1]); - var type2 = (match[2] || "ms").toLowerCase(); - switch (type2) { - case "years": - case "year": - case "yrs": - case "yr": - case "y": - return n3 * y3; - case "weeks": - case "week": - case "w": - return n3 * w3; - case "days": - case "day": - case "d": - return n3 * d3; - case "hours": - case "hour": - case "hrs": - case "hr": - case "h": - return n3 * h4; - case "minutes": - case "minute": - case "mins": - case "min": - case "m": - return n3 * m2; - case "seconds": - case "second": - case "secs": - case "sec": - case "s": - return n3 * s2; - case "milliseconds": - case "millisecond": - case "msecs": - case "msec": - case "ms": - return n3; - default: - return void 0; - } - } - function fmtShort(ms2) { - var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return Math.round(ms2 / d3) + "d"; - } - if (msAbs >= h4) { - return Math.round(ms2 / h4) + "h"; - } - if (msAbs >= m2) { - return Math.round(ms2 / m2) + "m"; - } - if (msAbs >= s2) { - return Math.round(ms2 / s2) + "s"; - } - return ms2 + "ms"; - } - function fmtLong(ms2) { - var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return plural(ms2, msAbs, d3, "day"); - } - if (msAbs >= h4) { - return plural(ms2, msAbs, h4, "hour"); - } - if (msAbs >= m2) { - return plural(ms2, msAbs, m2, "minute"); - } - if (msAbs >= s2) { - return plural(ms2, msAbs, s2, "second"); - } - return ms2 + " ms"; - } - function plural(ms2, msAbs, n3, name2) { - var isPlural = msAbs >= n3 * 1.5; - return Math.round(ms2 / n3) + " " + name2 + (isPlural ? "s" : ""); - } - return ms; -} -function setup(env2) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce2; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = requireMs(); - createDebug.destroy = destroy; - Object.keys(env2).forEach((key) => { - createDebug[key] = env2[key]; - }); - createDebug.names = []; - createDebug.skips = []; - createDebug.formatters = {}; - function selectColor(namespace) { - let hash2 = 0; - for (let i2 = 0; i2 < namespace.length; i2++) { - hash2 = (hash2 << 5) - hash2 + namespace.charCodeAt(i2); - hash2 |= 0; - } - return createDebug.colors[Math.abs(hash2) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; - function debug2(...args) { - if (!debug2.enabled) { - return; - } - const self2 = debug2; - const curr = Number(/* @__PURE__ */ new Date()); - const ms2 = curr - (prevTime || curr); - self2.diff = ms2; - self2.prev = prevTime; - self2.curr = curr; - prevTime = curr; - args[0] = createDebug.coerce(args[0]); - if (typeof args[0] !== "string") { - args.unshift("%O"); - } - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - if (match === "%%") { - return "%"; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === "function") { - const val = args[index]; - match = formatter.call(self2, val); - args.splice(index, 1); - index--; - } - return match; - }); - createDebug.formatArgs.call(self2, args); - const logFn = self2.log || createDebug.log; - logFn.apply(self2, args); - } - debug2.namespace = namespace; - debug2.useColors = createDebug.useColors(); - debug2.color = createDebug.selectColor(namespace); - debug2.extend = extend; - debug2.destroy = createDebug.destroy; - Object.defineProperty(debug2, "enabled", { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } - return enabledCache; - }, - set: (v3) => { - enableOverride = v3; - } - }); - if (typeof createDebug.init === "function") { - createDebug.init(debug2); - } - return debug2; - } - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; - createDebug.names = []; - createDebug.skips = []; - let i2; - const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); - const len = split.length; - for (i2 = 0; i2 < len; i2++) { - if (!split[i2]) { - continue; - } - namespaces = split[i2].replace(/\*/g, ".*?"); - if (namespaces[0] === "-") { - createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")); - } else { - createDebug.names.push(new RegExp("^" + namespaces + "$")); - } - } - } - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace) - ].join(","); - createDebug.enable(""); - return namespaces; - } - function enabled(name2) { - if (name2[name2.length - 1] === "*") { - return true; - } - let i2; - let len; - for (i2 = 0, len = createDebug.skips.length; i2 < len; i2++) { - if (createDebug.skips[i2].test(name2)) { - return false; - } - } - for (i2 = 0, len = createDebug.names.length; i2 < len; i2++) { - if (createDebug.names[i2].test(name2)) { - return true; - } - } - return false; - } - function toNamespace(regexp) { - return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*"); - } - function coerce2(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; - } - function destroy() { - console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); - } - createDebug.enable(createDebug.load()); - return createDebug; -} -var common = setup; -(function(module2, exports2) { - exports2.formatArgs = formatArgs; - exports2.save = save; - exports2.load = load; - exports2.useColors = useColors; - exports2.storage = localstorage(); - exports2.destroy = /* @__PURE__ */ (() => { - let warned = false; - return () => { - if (!warned) { - warned = true; - console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); - } - }; - })(); - exports2.colors = [ - "#0000CC", - "#0000FF", - "#0033CC", - "#0033FF", - "#0066CC", - "#0066FF", - "#0099CC", - "#0099FF", - "#00CC00", - "#00CC33", - "#00CC66", - "#00CC99", - "#00CCCC", - "#00CCFF", - "#3300CC", - "#3300FF", - "#3333CC", - "#3333FF", - "#3366CC", - "#3366FF", - "#3399CC", - "#3399FF", - "#33CC00", - "#33CC33", - "#33CC66", - "#33CC99", - "#33CCCC", - "#33CCFF", - "#6600CC", - "#6600FF", - "#6633CC", - "#6633FF", - "#66CC00", - "#66CC33", - "#9900CC", - "#9900FF", - "#9933CC", - "#9933FF", - "#99CC00", - "#99CC33", - "#CC0000", - "#CC0033", - "#CC0066", - "#CC0099", - "#CC00CC", - "#CC00FF", - "#CC3300", - "#CC3333", - "#CC3366", - "#CC3399", - "#CC33CC", - "#CC33FF", - "#CC6600", - "#CC6633", - "#CC9900", - "#CC9933", - "#CCCC00", - "#CCCC33", - "#FF0000", - "#FF0033", - "#FF0066", - "#FF0099", - "#FF00CC", - "#FF00FF", - "#FF3300", - "#FF3333", - "#FF3366", - "#FF3399", - "#FF33CC", - "#FF33FF", - "#FF6600", - "#FF6633", - "#FF9900", - "#FF9933", - "#FFCC00", - "#FFCC33" - ]; - function useColors() { - if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) { - return true; - } - if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } - return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 - typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker - typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); - } - function formatArgs(args) { - args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff); - if (!this.useColors) { - return; - } - const c2 = "color: " + this.color; - args.splice(1, 0, c2, "color: inherit"); - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, (match) => { - if (match === "%%") { - return; - } - index++; - if (match === "%c") { - lastC = index; - } - }); - args.splice(lastC, 0, c2); - } - exports2.log = console.debug || console.log || (() => { - }); - function save(namespaces) { - try { - if (namespaces) { - exports2.storage.setItem("debug", namespaces); - } else { - exports2.storage.removeItem("debug"); - } - } catch (error) { - } - } - function load() { - let r2; - try { - r2 = exports2.storage.getItem("debug"); - } catch (error) { - } - if (!r2 && typeof process !== "undefined" && "env" in process) { - r2 = process.env.DEBUG; - } - return r2; - } - function localstorage() { - try { - return localStorage; - } catch (error) { - } - } - module2.exports = common(exports2); - const { formatters } = module2.exports; - formatters.j = function(v3) { - try { - return JSON.stringify(v3); - } catch (error) { - return "[UnexpectedJSONParseError]: " + error.message; - } - }; -})(browser, browser.exports); -var browserExports = browser.exports; -const debug = /* @__PURE__ */ getDefaultExportFromCjs(browserExports); -const log_sdk = debug("wallet:sdk"); -log_sdk.enabled = true; -export { - log_sdk as $, - AssetType as A, - getAccount as B, - getBalance as C, - connect as D, - EventStatus as E, - requestCreateEvent as F, - createSharedState as G, - decrypt as H, - disconnect as I, - getEvent as J, - getEvents as K, - importSharedState as L, - getRecords as M, - Network as N, - requestSignature as O, - PAGE_SIZE as P, - wc_aleo_methods as Q, - R$4 as R, - wc_aleo_chains as S, - T$1 as T, - wc_events as U, - Visibility as V, - projectId as W, - web3modal_puzzle_props_android as X, - web3modal_puzzle_props_default as Y, - web3modal_puzzle_props as Z, - signClient_puzzleProps as _, - a$3 as a, - checkForDesktopConnection as a0, - hasInjectedConnection as a1, - emitter as a2, - connection as a3, - configureConnection as a4, - getWalletConnectModalSignClient as a5, - EventType as b, - aleoAddressRegex as c, - aleoFieldRegex as d, - aleoPrivateKeyRegex as e, - aleoTransactionIdRegex as f, - aleoU32 as g, - aleoU64 as h, - aleoViewKeyRegex as i, - zodEventStatus as j, - zodEventType as k, - zodField as l, - zodNetwork as m, - ne as n, - oe$1 as o, - p$3 as p, - zodPrivateKey as q, - zodTransactionId as r, - se as s, - te$2 as t, - zodU32 as u, - zodU64 as v, - zodViewKey as w, - zodVisibility as x, - y$3 as y, - zodAddress as z -}; diff --git a/packages/core/dist/index-CB32TCFB.js b/packages/core/dist/index-CB32TCFB.js new file mode 100644 index 00000000..0d9d4737 --- /dev/null +++ b/packages/core/dist/index-CB32TCFB.js @@ -0,0 +1,24691 @@ +const t = Symbol(); +const s$1 = Object.getPrototypeOf, c$4 = /* @__PURE__ */ new WeakMap(), l$2 = (e2) => e2 && (c$4.has(e2) ? c$4.get(e2) : s$1(e2) === Object.prototype || s$1(e2) === Array.prototype), y$5 = (e2) => l$2(e2) && e2[t] || null, h$3 = (e2, t2 = true) => { + c$4.set(e2, t2); +}; +var define_import_meta_env_default = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false }; +const isObject = (x2) => typeof x2 === "object" && x2 !== null; +const proxyStateMap = /* @__PURE__ */ new WeakMap(); +const refSet = /* @__PURE__ */ new WeakSet(); +const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x2) => isObject(x2) && !refSet.has(x2) && (Array.isArray(x2) || !(Symbol.iterator in x2)) && !(x2 instanceof WeakMap) && !(x2 instanceof WeakSet) && !(x2 instanceof Error) && !(x2 instanceof Number) && !(x2 instanceof Date) && !(x2 instanceof String) && !(x2 instanceof RegExp) && !(x2 instanceof ArrayBuffer), defaultHandlePromise = (promise) => { + switch (promise.status) { + case "fulfilled": + return promise.value; + case "rejected": + throw promise.reason; + default: + throw promise; + } +}, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version2, handlePromise = defaultHandlePromise) => { + const cache = snapCache.get(target); + if ((cache == null ? void 0 : cache[0]) === version2) { + return cache[1]; + } + const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); + h$3(snap, true); + snapCache.set(target, [version2, snap]); + Reflect.ownKeys(target).forEach((key) => { + if (Object.getOwnPropertyDescriptor(snap, key)) { + return; + } + const value = Reflect.get(target, key); + const desc = { + value, + enumerable: true, + // This is intentional to avoid copying with proxy-compare. + // It's still non-writable, so it avoids assigning a value. + configurable: true + }; + if (refSet.has(value)) { + h$3(value, false); + } else if (value instanceof Promise) { + delete desc.value; + desc.get = () => handlePromise(value); + } else if (proxyStateMap.has(value)) { + const [target2, ensureVersion] = proxyStateMap.get( + value + ); + desc.value = createSnapshot( + target2, + ensureVersion(), + handlePromise + ); + } + Object.defineProperty(snap, key, desc); + }); + return Object.preventExtensions(snap); +}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { + if (!isObject(initialObject)) { + throw new Error("object required"); + } + const found = proxyCache.get(initialObject); + if (found) { + return found; + } + let version2 = versionHolder[0]; + const listeners2 = /* @__PURE__ */ new Set(); + const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => { + if (version2 !== nextVersion) { + version2 = nextVersion; + listeners2.forEach((listener) => listener(op, nextVersion)); + } + }; + let checkVersion = versionHolder[1]; + const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => { + if (checkVersion !== nextCheckVersion && !listeners2.size) { + checkVersion = nextCheckVersion; + propProxyStates.forEach(([propProxyState]) => { + const propVersion = propProxyState[1](nextCheckVersion); + if (propVersion > version2) { + version2 = propVersion; + } + }); + } + return version2; + }; + const createPropListener = (prop) => (op, nextVersion) => { + const newOp = [...op]; + newOp[1] = [prop, ...newOp[1]]; + notifyUpdate(newOp, nextVersion); + }; + const propProxyStates = /* @__PURE__ */ new Map(); + const addPropListener = (prop, propProxyState) => { + if ((define_import_meta_env_default ? "production" : void 0) !== "production" && propProxyStates.has(prop)) { + throw new Error("prop listener already exists"); + } + if (listeners2.size) { + const remove = propProxyState[3](createPropListener(prop)); + propProxyStates.set(prop, [propProxyState, remove]); + } else { + propProxyStates.set(prop, [propProxyState]); + } + }; + const removePropListener = (prop) => { + var _a2; + const entry = propProxyStates.get(prop); + if (entry) { + propProxyStates.delete(prop); + (_a2 = entry[1]) == null ? void 0 : _a2.call(entry); + } + }; + const addListener2 = (listener) => { + listeners2.add(listener); + if (listeners2.size === 1) { + propProxyStates.forEach(([propProxyState, prevRemove], prop) => { + if ((define_import_meta_env_default ? "production" : void 0) !== "production" && prevRemove) { + throw new Error("remove already exists"); + } + const remove = propProxyState[3](createPropListener(prop)); + propProxyStates.set(prop, [propProxyState, remove]); + }); + } + const removeListener2 = () => { + listeners2.delete(listener); + if (listeners2.size === 0) { + propProxyStates.forEach(([propProxyState, remove], prop) => { + if (remove) { + remove(); + propProxyStates.set(prop, [propProxyState]); + } + }); + } + }; + return removeListener2; + }; + const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); + const handler = { + deleteProperty(target, prop) { + const prevValue = Reflect.get(target, prop); + removePropListener(prop); + const deleted = Reflect.deleteProperty(target, prop); + if (deleted) { + notifyUpdate(["delete", [prop], prevValue]); + } + return deleted; + }, + set(target, prop, value, receiver) { + const hasPrevValue = Reflect.has(target, prop); + const prevValue = Reflect.get(target, prop, receiver); + if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { + return true; + } + removePropListener(prop); + if (isObject(value)) { + value = y$5(value) || value; + } + let nextValue = value; + if (value instanceof Promise) { + value.then((v3) => { + value.status = "fulfilled"; + value.value = v3; + notifyUpdate(["resolve", [prop], v3]); + }).catch((e2) => { + value.status = "rejected"; + value.reason = e2; + notifyUpdate(["reject", [prop], e2]); + }); + } else { + if (!proxyStateMap.has(value) && canProxy(value)) { + nextValue = proxyFunction(value); + } + const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); + if (childProxyState) { + addPropListener(prop, childProxyState); + } + } + Reflect.set(target, prop, nextValue, receiver); + notifyUpdate(["set", [prop], value, prevValue]); + return true; + } + }; + const proxyObject = newProxy(baseObject, handler); + proxyCache.set(initialObject, proxyObject); + const proxyState = [ + baseObject, + ensureVersion, + createSnapshot, + addListener2 + ]; + proxyStateMap.set(proxyObject, proxyState); + Reflect.ownKeys(initialObject).forEach((key) => { + const desc = Object.getOwnPropertyDescriptor( + initialObject, + key + ); + if ("value" in desc) { + proxyObject[key] = initialObject[key]; + delete desc.value; + delete desc.writable; + } + Object.defineProperty(baseObject, key, desc); + }); + return proxyObject; +}) => [ + // public functions + proxyFunction, + // shared state + proxyStateMap, + refSet, + // internal things + objectIs, + newProxy, + canProxy, + defaultHandlePromise, + snapCache, + createSnapshot, + proxyCache, + versionHolder +]; +const [defaultProxyFunction] = buildProxyFunction(); +function proxy(initialObject = {}) { + return defaultProxyFunction(initialObject); +} +function subscribe(proxyObject, callback, notifyInSync) { + const proxyState = proxyStateMap.get(proxyObject); + if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !proxyState) { + console.warn("Please use proxy object"); + } + let promise; + const ops = []; + const addListener2 = proxyState[3]; + let isListenerActive = false; + const listener = (op) => { + ops.push(op); + if (!promise) { + promise = Promise.resolve().then(() => { + promise = void 0; + if (isListenerActive) { + callback(ops.splice(0)); + } + }); + } + }; + const removeListener2 = addListener2(listener); + isListenerActive = true; + return () => { + isListenerActive = false; + removeListener2(); + }; +} +function snapshot(proxyObject, handlePromise) { + const proxyState = proxyStateMap.get(proxyObject); + if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !proxyState) { + console.warn("Please use proxy object"); + } + const [target, ensureVersion, createSnapshot] = proxyState; + return createSnapshot(target, ensureVersion(), handlePromise); +} +const o$1 = proxy({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), T$2 = { state: o$1, subscribe(e2) { + return subscribe(o$1, () => e2(o$1)); +}, push(e2, t2) { + e2 !== o$1.view && (o$1.view = e2, t2 && (o$1.data = t2), o$1.history.push(e2)); +}, reset(e2) { + o$1.view = e2, o$1.history = [e2]; +}, replace(e2) { + o$1.history.length > 1 && (o$1.history[o$1.history.length - 1] = e2, o$1.view = e2); +}, goBack() { + if (o$1.history.length > 1) { + o$1.history.pop(); + const [e2] = o$1.history.slice(-1); + o$1.view = e2; + } +}, setData(e2) { + o$1.data = e2; +} }, i$1 = { WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", WCM_VERSION: "WCM_VERSION", RECOMMENDED_WALLET_AMOUNT: 9, isMobile() { + return typeof window < "u" ? Boolean(window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : false; +}, isAndroid() { + return i$1.isMobile() && navigator.userAgent.toLowerCase().includes("android"); +}, isIos() { + const e2 = navigator.userAgent.toLowerCase(); + return i$1.isMobile() && (e2.includes("iphone") || e2.includes("ipad")); +}, isHttpUrl(e2) { + return e2.startsWith("http://") || e2.startsWith("https://"); +}, isArray(e2) { + return Array.isArray(e2) && e2.length > 0; +}, formatNativeUrl(e2, t2, s2) { + if (i$1.isHttpUrl(e2)) + return this.formatUniversalUrl(e2, t2, s2); + let n4 = e2; + n4.includes("://") || (n4 = e2.replaceAll("/", "").replaceAll(":", ""), n4 = `${n4}://`), n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s2); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; +}, formatUniversalUrl(e2, t2, s2) { + if (!i$1.isHttpUrl(e2)) + return this.formatNativeUrl(e2, t2, s2); + let n4 = e2; + n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s2); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; +}, async wait(e2) { + return new Promise((t2) => { + setTimeout(t2, e2); + }); +}, openHref(e2, t2) { + window.open(e2, t2, "noreferrer noopener"); +}, setWalletConnectDeepLink(e2, t2) { + try { + localStorage.setItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: e2, name: t2 })); + } catch { + console.info("Unable to set WalletConnect deep link"); + } +}, setWalletConnectAndroidDeepLink(e2) { + try { + const [t2] = e2.split("?"); + localStorage.setItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: t2, name: "Android" })); + } catch { + console.info("Unable to set WalletConnect android deep link"); + } +}, removeWalletConnectDeepLink() { + try { + localStorage.removeItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE); + } catch { + console.info("Unable to remove WalletConnect deep link"); + } +}, setModalVersionInStorage() { + try { + typeof localStorage < "u" && localStorage.setItem(i$1.WCM_VERSION, "0.0.6"); + } catch { + console.info("Unable to set Web3Modal version in storage"); + } +}, getWalletRouterData() { + var e2; + const t2 = (e2 = T$2.state.data) == null ? void 0 : e2.Wallet; + if (!t2) + throw new Error('Missing "Wallet" view data'); + return t2; +} }, _$2 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), a$2 = proxy({ enabled: _$2, userSessionId: "", events: [], connectedWalletId: void 0 }), R$1 = { state: a$2, subscribe(e2) { + return subscribe(a$2.events, () => e2(snapshot(a$2.events[a$2.events.length - 1]))); +}, initialize() { + a$2.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (a$2.userSessionId = crypto.randomUUID()); +}, setConnectedWalletId(e2) { + a$2.connectedWalletId = e2; +}, click(e2) { + if (a$2.enabled) { + const t2 = { type: "CLICK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +}, track(e2) { + if (a$2.enabled) { + const t2 = { type: "TRACK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +}, view(e2) { + if (a$2.enabled) { + const t2 = { type: "VIEW", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +} }, c$3 = proxy({ chains: void 0, walletConnectUri: void 0, isAuth: false, isCustomDesktop: false, isCustomMobile: false, isDataLoaded: false, isUiLoaded: false }), p$2 = { state: c$3, subscribe(e2) { + return subscribe(c$3, () => e2(c$3)); +}, setChains(e2) { + c$3.chains = e2; +}, setWalletConnectUri(e2) { + c$3.walletConnectUri = e2; +}, setIsCustomDesktop(e2) { + c$3.isCustomDesktop = e2; +}, setIsCustomMobile(e2) { + c$3.isCustomMobile = e2; +}, setIsDataLoaded(e2) { + c$3.isDataLoaded = e2; +}, setIsUiLoaded(e2) { + c$3.isUiLoaded = e2; +}, setIsAuth(e2) { + c$3.isAuth = e2; +} }, W = proxy({ projectId: "", mobileWallets: void 0, desktopWallets: void 0, walletImages: void 0, chains: void 0, enableAuthMode: false, enableExplorer: true, explorerExcludedWalletIds: void 0, explorerRecommendedWalletIds: void 0, termsOfServiceUrl: void 0, privacyPolicyUrl: void 0 }), y$4 = { state: W, subscribe(e2) { + return subscribe(W, () => e2(W)); +}, setConfig(e2) { + var t2, s2; + R$1.initialize(), p$2.setChains(e2.chains), p$2.setIsAuth(Boolean(e2.enableAuthMode)), p$2.setIsCustomMobile(Boolean((t2 = e2.mobileWallets) == null ? void 0 : t2.length)), p$2.setIsCustomDesktop(Boolean((s2 = e2.desktopWallets) == null ? void 0 : s2.length)), i$1.setModalVersionInStorage(), Object.assign(W, e2); +} }; +var V$3 = Object.defineProperty, D$2 = Object.getOwnPropertySymbols, H = Object.prototype.hasOwnProperty, B$1 = Object.prototype.propertyIsEnumerable, M$1 = (e2, t2, s2) => t2 in e2 ? V$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, K$4 = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + H.call(t2, s2) && M$1(e2, s2, t2[s2]); + if (D$2) + for (var s2 of D$2(t2)) + B$1.call(t2, s2) && M$1(e2, s2, t2[s2]); + return e2; +}; +const L$5 = "https://explorer-api.walletconnect.com", E$3 = "wcm", O$3 = "js-0.0.6"; +async function w$4(e2, t2) { + const s2 = K$4({ sdkType: E$3, sdkVersion: O$3 }, t2), n4 = new URL(e2, L$5); + return n4.searchParams.append("projectId", y$4.state.projectId), Object.entries(s2).forEach(([r3, l2]) => { + l2 && n4.searchParams.append(r3, String(l2)); + }), (await fetch(n4)).json(); +} +const m$2 = { async getDesktopListings(e2) { + return w$4("/w3m/v1/getDesktopListings", e2); +}, async getMobileListings(e2) { + return w$4("/w3m/v1/getMobileListings", e2); +}, async getInjectedListings(e2) { + return w$4("/w3m/v1/getInjectedListings", e2); +}, async getAllListings(e2) { + return w$4("/w3m/v1/getAllListings", e2); +}, getWalletImageUrl(e2) { + return `${L$5}/w3m/v1/getWalletImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; +}, getAssetImageUrl(e2) { + return `${L$5}/w3m/v1/getAssetImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; +} }; +var z$4 = Object.defineProperty, j$4 = Object.getOwnPropertySymbols, J$1 = Object.prototype.hasOwnProperty, q$3 = Object.prototype.propertyIsEnumerable, k$4 = (e2, t2, s2) => t2 in e2 ? z$4(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, F$2 = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + J$1.call(t2, s2) && k$4(e2, s2, t2[s2]); + if (j$4) + for (var s2 of j$4(t2)) + q$3.call(t2, s2) && k$4(e2, s2, t2[s2]); + return e2; +}; +const N$2 = i$1.isMobile(), d$4 = proxy({ wallets: { listings: [], total: 0, page: 1 }, search: { listings: [], total: 0, page: 1 }, recomendedWallets: [] }), te$1 = { state: d$4, async getRecomendedWallets() { + const { explorerRecommendedWalletIds: e2, explorerExcludedWalletIds: t2 } = y$4.state; + if (e2 === "NONE" || t2 === "ALL" && !e2) + return d$4.recomendedWallets; + if (i$1.isArray(e2)) { + const s2 = { recommendedIds: e2.join(",") }, { listings: n4 } = await m$2.getAllListings(s2), r3 = Object.values(n4); + n4 && r3.sort && r3.sort((l2, v3) => { + const b3 = e2.indexOf(l2.id), f3 = e2.indexOf(v3.id); + return b3 - f3; + }), d$4.recomendedWallets = r3; + } else { + const { chains: s2, isAuth: n4 } = p$2.state, r3 = s2 == null ? void 0 : s2.join(","), l2 = i$1.isArray(t2), v3 = { page: 1, sdks: n4 ? "auth_v1" : void 0, entries: i$1.RECOMMENDED_WALLET_AMOUNT, chains: r3, version: 2, excludedIds: l2 ? t2.join(",") : void 0 }, { listings: b3 } = N$2 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); + d$4.recomendedWallets = Object.values(b3); + } + return d$4.recomendedWallets; +}, async getWallets(e2) { + const t2 = F$2({}, e2), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n4 } = y$4.state, { recomendedWallets: r3 } = d$4; + if (n4 === "ALL") + return d$4.wallets; + r3.length ? t2.excludedIds = r3.map((x2) => x2.id).join(",") : i$1.isArray(s2) && (t2.excludedIds = s2.join(",")), i$1.isArray(n4) && (t2.excludedIds = [t2.excludedIds, n4].filter(Boolean).join(",")), p$2.state.isAuth && (t2.sdks = "auth_v1"); + const { page: l2, search: v3 } = e2, { listings: b3, total: f3 } = N$2 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; + return d$4[U2] = { listings: [...d$4[U2].listings, ...A2], total: f3, page: l2 ?? 1 }, { listings: A2, total: f3 }; +}, getWalletImageUrl(e2) { + return m$2.getWalletImageUrl(e2); +}, getAssetImageUrl(e2) { + return m$2.getAssetImageUrl(e2); +}, resetSearch() { + d$4.search = { listings: [], total: 0, page: 1 }; +} }, I$3 = proxy({ open: false }), se$3 = { state: I$3, subscribe(e2) { + return subscribe(I$3, () => e2(I$3)); +}, async open(e2) { + return new Promise((t2) => { + const { isUiLoaded: s2, isDataLoaded: n4 } = p$2.state; + if (i$1.removeWalletConnectDeepLink(), p$2.setWalletConnectUri(e2 == null ? void 0 : e2.uri), p$2.setChains(e2 == null ? void 0 : e2.chains), T$2.reset("ConnectWallet"), s2 && n4) + I$3.open = true, t2(); + else { + const r3 = setInterval(() => { + const l2 = p$2.state; + l2.isUiLoaded && l2.isDataLoaded && (clearInterval(r3), I$3.open = true, t2()); + }, 200); + } + }); +}, close() { + I$3.open = false; +} }; +var G$1 = Object.defineProperty, $ = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$1 = Object.prototype.propertyIsEnumerable, S$4 = (e2, t2, s2) => t2 in e2 ? G$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, Y = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + Q$3.call(t2, s2) && S$4(e2, s2, t2[s2]); + if ($) + for (var s2 of $(t2)) + X$1.call(t2, s2) && S$4(e2, s2, t2[s2]); + return e2; +}; +function Z$1() { + return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; +} +const C$3 = proxy({ themeMode: Z$1() ? "dark" : "light" }), ne$3 = { state: C$3, subscribe(e2) { + return subscribe(C$3, () => e2(C$3)); +}, setThemeConfig(e2) { + const { themeMode: t2, themeVariables: s2 } = e2; + t2 && (C$3.themeMode = t2), s2 && (C$3.themeVariables = Y({}, s2)); +} }, g$3 = proxy({ open: false, message: "", variant: "success" }), oe$2 = { state: g$3, subscribe(e2) { + return subscribe(g$3, () => e2(g$3)); +}, openToast(e2, t2) { + g$3.open = true, g$3.message = e2, g$3.variant = t2; +}, closeToast() { + g$3.open = false; +} }; +let d$3 = class d { + constructor(e2) { + this.openModal = se$3.open, this.closeModal = se$3.close, this.subscribeModal = se$3.subscribe, this.setTheme = ne$3.setThemeConfig, ne$3.setThemeConfig(e2), y$4.setConfig(e2), this.initUi(); + } + async initUi() { + if (typeof window < "u") { + await import("./index-f3LbIFb5.js"); + const e2 = document.createElement("wcm-modal"); + document.body.insertAdjacentElement("beforeend", e2), p$2.setIsUiLoaded(true); + } + } +}; +var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; +function getDefaultExportFromCjs(x2) { + return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; +} +function getAugmentedNamespace(n4) { + if (n4.__esModule) + return n4; + var f3 = n4.default; + if (typeof f3 == "function") { + var a3 = function a4() { + if (this instanceof a4) { + return Reflect.construct(f3, arguments, this.constructor); + } + return f3.apply(this, arguments); + }; + a3.prototype = f3.prototype; + } else + a3 = {}; + Object.defineProperty(a3, "__esModule", { value: true }); + Object.keys(n4).forEach(function(k2) { + var d5 = Object.getOwnPropertyDescriptor(n4, k2); + Object.defineProperty(a3, k2, d5.get ? d5 : { + enumerable: true, + get: function() { + return n4[k2]; + } + }); + }); + return a3; +} +var events = { exports: {} }; +var R = typeof Reflect === "object" ? Reflect : null; +var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); +}; +var ReflectOwnKeys; +if (R && typeof R.ownKeys === "function") { + ReflectOwnKeys = R.ownKeys; +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys2(target) { + return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys2(target) { + return Object.getOwnPropertyNames(target); + }; +} +function ProcessEmitWarning(warning) { + if (console && console.warn) + console.warn(warning); +} +var NumberIsNaN = Number.isNaN || function NumberIsNaN2(value) { + return value !== value; +}; +function EventEmitter() { + EventEmitter.init.call(this); +} +events.exports = EventEmitter; +events.exports.once = once2; +EventEmitter.EventEmitter = EventEmitter; +EventEmitter.prototype._events = void 0; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = void 0; +var defaultMaxListeners = 10; +function checkListener(listener) { + if (typeof listener !== "function") { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } +} +Object.defineProperty(EventEmitter, "defaultMaxListeners", { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + "."); + } + defaultMaxListeners = arg; + } +}); +EventEmitter.init = function() { + if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) { + this._events = /* @__PURE__ */ Object.create(null); + this._eventsCount = 0; + } + this._maxListeners = this._maxListeners || void 0; +}; +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n4) { + if (typeof n4 !== "number" || n4 < 0 || NumberIsNaN(n4)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n4 + "."); + } + this._maxListeners = n4; + return this; +}; +function _getMaxListeners(that) { + if (that._maxListeners === void 0) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return _getMaxListeners(this); +}; +EventEmitter.prototype.emit = function emit(type2) { + var args = []; + for (var i2 = 1; i2 < arguments.length; i2++) + args.push(arguments[i2]); + var doError = type2 === "error"; + var events2 = this._events; + if (events2 !== void 0) + doError = doError && events2.error === void 0; + else if (!doError) + return false; + if (doError) { + var er2; + if (args.length > 0) + er2 = args[0]; + if (er2 instanceof Error) { + throw er2; + } + var err = new Error("Unhandled error." + (er2 ? " (" + er2.message + ")" : "")); + err.context = er2; + throw err; + } + var handler = events2[type2]; + if (handler === void 0) + return false; + if (typeof handler === "function") { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners2 = arrayClone(handler, len); + for (var i2 = 0; i2 < len; ++i2) + ReflectApply(listeners2[i2], this, args); + } + return true; +}; +function _addListener(target, type2, listener, prepend) { + var m3; + var events2; + var existing; + checkListener(listener); + events2 = target._events; + if (events2 === void 0) { + events2 = target._events = /* @__PURE__ */ Object.create(null); + target._eventsCount = 0; + } else { + if (events2.newListener !== void 0) { + target.emit( + "newListener", + type2, + listener.listener ? listener.listener : listener + ); + events2 = target._events; + } + existing = events2[type2]; + } + if (existing === void 0) { + existing = events2[type2] = listener; + ++target._eventsCount; + } else { + if (typeof existing === "function") { + existing = events2[type2] = prepend ? [listener, existing] : [existing, listener]; + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + m3 = _getMaxListeners(target); + if (m3 > 0 && existing.length > m3 && !existing.warned) { + existing.warned = true; + var w3 = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type2) + " listeners added. Use emitter.setMaxListeners() to increase limit"); + w3.name = "MaxListenersExceededWarning"; + w3.emitter = target; + w3.type = type2; + w3.count = existing.length; + ProcessEmitWarning(w3); + } + } + return target; +} +EventEmitter.prototype.addListener = function addListener(type2, listener) { + return _addListener(this, type2, listener, false); +}; +EventEmitter.prototype.on = EventEmitter.prototype.addListener; +EventEmitter.prototype.prependListener = function prependListener(type2, listener) { + return _addListener(this, type2, listener, true); +}; +function onceWrapper() { + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + if (arguments.length === 0) + return this.listener.call(this.target); + return this.listener.apply(this.target, arguments); + } +} +function _onceWrap(target, type2, listener) { + var state = { fired: false, wrapFn: void 0, target, type: type2, listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} +EventEmitter.prototype.once = function once(type2, listener) { + checkListener(listener); + this.on(type2, _onceWrap(this, type2, listener)); + return this; +}; +EventEmitter.prototype.prependOnceListener = function prependOnceListener(type2, listener) { + checkListener(listener); + this.prependListener(type2, _onceWrap(this, type2, listener)); + return this; +}; +EventEmitter.prototype.removeListener = function removeListener(type2, listener) { + var list, events2, position, i2, originalListener; + checkListener(listener); + events2 = this._events; + if (events2 === void 0) + return this; + list = events2[type2]; + if (list === void 0) + return this; + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = /* @__PURE__ */ Object.create(null); + else { + delete events2[type2]; + if (events2.removeListener) + this.emit("removeListener", type2, list.listener || listener); + } + } else if (typeof list !== "function") { + position = -1; + for (i2 = list.length - 1; i2 >= 0; i2--) { + if (list[i2] === listener || list[i2].listener === listener) { + originalListener = list[i2].listener; + position = i2; + break; + } + } + if (position < 0) + return this; + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + if (list.length === 1) + events2[type2] = list[0]; + if (events2.removeListener !== void 0) + this.emit("removeListener", type2, originalListener || listener); + } + return this; +}; +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; +EventEmitter.prototype.removeAllListeners = function removeAllListeners(type2) { + var listeners2, events2, i2; + events2 = this._events; + if (events2 === void 0) + return this; + if (events2.removeListener === void 0) { + if (arguments.length === 0) { + this._events = /* @__PURE__ */ Object.create(null); + this._eventsCount = 0; + } else if (events2[type2] !== void 0) { + if (--this._eventsCount === 0) + this._events = /* @__PURE__ */ Object.create(null); + else + delete events2[type2]; + } + return this; + } + if (arguments.length === 0) { + var keys2 = Object.keys(events2); + var key; + for (i2 = 0; i2 < keys2.length; ++i2) { + key = keys2[i2]; + if (key === "removeListener") + continue; + this.removeAllListeners(key); + } + this.removeAllListeners("removeListener"); + this._events = /* @__PURE__ */ Object.create(null); + this._eventsCount = 0; + return this; + } + listeners2 = events2[type2]; + if (typeof listeners2 === "function") { + this.removeListener(type2, listeners2); + } else if (listeners2 !== void 0) { + for (i2 = listeners2.length - 1; i2 >= 0; i2--) { + this.removeListener(type2, listeners2[i2]); + } + } + return this; +}; +function _listeners(target, type2, unwrap) { + var events2 = target._events; + if (events2 === void 0) + return []; + var evlistener = events2[type2]; + if (evlistener === void 0) + return []; + if (typeof evlistener === "function") + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); +} +EventEmitter.prototype.listeners = function listeners(type2) { + return _listeners(this, type2, true); +}; +EventEmitter.prototype.rawListeners = function rawListeners(type2) { + return _listeners(this, type2, false); +}; +EventEmitter.listenerCount = function(emitter2, type2) { + if (typeof emitter2.listenerCount === "function") { + return emitter2.listenerCount(type2); + } else { + return listenerCount.call(emitter2, type2); + } +}; +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type2) { + var events2 = this._events; + if (events2 !== void 0) { + var evlistener = events2[type2]; + if (typeof evlistener === "function") { + return 1; + } else if (evlistener !== void 0) { + return evlistener.length; + } + } + return 0; +} +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; +function arrayClone(arr, n4) { + var copy = new Array(n4); + for (var i2 = 0; i2 < n4; ++i2) + copy[i2] = arr[i2]; + return copy; +} +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i2 = 0; i2 < ret.length; ++i2) { + ret[i2] = arr[i2].listener || arr[i2]; + } + return ret; +} +function once2(emitter2, name2) { + return new Promise(function(resolve, reject) { + function errorListener(err) { + emitter2.removeListener(name2, resolver); + reject(err); + } + function resolver() { + if (typeof emitter2.removeListener === "function") { + emitter2.removeListener("error", errorListener); + } + resolve([].slice.call(arguments)); + } + eventTargetAgnosticAddListener(emitter2, name2, resolver, { once: true }); + if (name2 !== "error") { + addErrorHandlerIfEventEmitter(emitter2, errorListener, { once: true }); + } + }); +} +function addErrorHandlerIfEventEmitter(emitter2, handler, flags) { + if (typeof emitter2.on === "function") { + eventTargetAgnosticAddListener(emitter2, "error", handler, flags); + } +} +function eventTargetAgnosticAddListener(emitter2, name2, listener, flags) { + if (typeof emitter2.on === "function") { + if (flags.once) { + emitter2.once(name2, listener); + } else { + emitter2.on(name2, listener); + } + } else if (typeof emitter2.addEventListener === "function") { + emitter2.addEventListener(name2, function wrapListener(arg) { + if (flags.once) { + emitter2.removeEventListener(name2, wrapListener); + } + listener(arg); + }); + } else { + throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter2); + } +} +var eventsExports = events.exports; +const EventEmitter$1 = /* @__PURE__ */ getDefaultExportFromCjs(eventsExports); +const suspectProtoRx = /"(?:_|\\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*:/; +const suspectConstructorRx = /"(?: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*:/; +const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/; +function jsonParseTransform(key, value) { + if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) { + warnKeyDropped(key); + return; + } + return value; +} +function warnKeyDropped(key) { + console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`); +} +function destr(value, options = {}) { + if (typeof value !== "string") { + return value; + } + const _value = value.trim(); + if ( + // eslint-disable-next-line unicorn/prefer-at + value[0] === '"' && value.endsWith('"') && !value.includes("\\") + ) { + return _value.slice(1, -1); + } + if (_value.length <= 9) { + const _lval = _value.toLowerCase(); + if (_lval === "true") { + return true; + } + if (_lval === "false") { + return false; + } + if (_lval === "undefined") { + return void 0; + } + if (_lval === "null") { + return null; + } + if (_lval === "nan") { + return Number.NaN; + } + if (_lval === "infinity") { + return Number.POSITIVE_INFINITY; + } + if (_lval === "-infinity") { + return Number.NEGATIVE_INFINITY; + } + } + if (!JsonSigRx.test(value)) { + if (options.strict) { + throw new SyntaxError("[destr] Invalid JSON"); + } + return value; + } + try { + if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) { + if (options.strict) { + throw new Error("[destr] Possible prototype pollution"); + } + return JSON.parse(value, jsonParseTransform); + } + return JSON.parse(value); + } catch (error) { + if (options.strict) { + throw error; + } + return value; + } +} +function wrapToPromise(value) { + if (!value || typeof value.then !== "function") { + return Promise.resolve(value); + } + return value; +} +function asyncCall(function_, ...arguments_) { + try { + return wrapToPromise(function_(...arguments_)); + } catch (error) { + return Promise.reject(error); + } +} +function isPrimitive(value) { + const type2 = typeof value; + return value === null || type2 !== "object" && type2 !== "function"; +} +function isPureObject(value) { + const proto = Object.getPrototypeOf(value); + return !proto || proto.isPrototypeOf(Object); +} +function stringify(value) { + if (isPrimitive(value)) { + return String(value); + } + if (isPureObject(value) || Array.isArray(value)) { + return JSON.stringify(value); + } + if (typeof value.toJSON === "function") { + return stringify(value.toJSON()); + } + throw new Error("[unstorage] Cannot stringify value!"); +} +function checkBufferSupport() { + if (typeof Buffer === void 0) { + throw new TypeError("[unstorage] Buffer is not supported!"); + } +} +const BASE64_PREFIX = "base64:"; +function serializeRaw(value) { + if (typeof value === "string") { + return value; + } + checkBufferSupport(); + const base642 = Buffer.from(value).toString("base64"); + return BASE64_PREFIX + base642; +} +function deserializeRaw(value) { + if (typeof value !== "string") { + return value; + } + if (!value.startsWith(BASE64_PREFIX)) { + return value; + } + checkBufferSupport(); + return Buffer.from(value.slice(BASE64_PREFIX.length), "base64"); +} +function normalizeKey(key) { + if (!key) { + return ""; + } + return key.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, ""); +} +function joinKeys(...keys2) { + return normalizeKey(keys2.join(":")); +} +function normalizeBaseKey(base3) { + base3 = normalizeKey(base3); + return base3 ? base3 + ":" : ""; +} +function defineDriver(factory) { + return factory; +} +const DRIVER_NAME = "memory"; +const memory = defineDriver(() => { + const data = /* @__PURE__ */ new Map(); + return { + name: DRIVER_NAME, + options: {}, + hasItem(key) { + return data.has(key); + }, + getItem(key) { + return data.get(key) ?? null; + }, + getItemRaw(key) { + return data.get(key) ?? null; + }, + setItem(key, value) { + data.set(key, value); + }, + setItemRaw(key, value) { + data.set(key, value); + }, + removeItem(key) { + data.delete(key); + }, + getKeys() { + return Array.from(data.keys()); + }, + clear() { + data.clear(); + }, + dispose() { + data.clear(); + } + }; +}); +function createStorage(options = {}) { + const context = { + mounts: { "": options.driver || memory() }, + mountpoints: [""], + watching: false, + watchListeners: [], + unwatch: {} + }; + const getMount = (key) => { + for (const base3 of context.mountpoints) { + if (key.startsWith(base3)) { + return { + base: base3, + relativeKey: key.slice(base3.length), + driver: context.mounts[base3] + }; + } + } + return { + base: "", + relativeKey: key, + driver: context.mounts[""] + }; + }; + const getMounts = (base3, includeParent) => { + return context.mountpoints.filter( + (mountpoint) => mountpoint.startsWith(base3) || includeParent && base3.startsWith(mountpoint) + ).map((mountpoint) => ({ + relativeBase: base3.length > mountpoint.length ? base3.slice(mountpoint.length) : void 0, + mountpoint, + driver: context.mounts[mountpoint] + })); + }; + const onChange = (event, key) => { + if (!context.watching) { + return; + } + key = normalizeKey(key); + for (const listener of context.watchListeners) { + listener(event, key); + } + }; + const startWatch = async () => { + if (context.watching) { + return; + } + context.watching = true; + for (const mountpoint in context.mounts) { + context.unwatch[mountpoint] = await watch$2( + context.mounts[mountpoint], + onChange, + mountpoint + ); + } + }; + const stopWatch = async () => { + if (!context.watching) { + return; + } + for (const mountpoint in context.unwatch) { + await context.unwatch[mountpoint](); + } + context.unwatch = {}; + context.watching = false; + }; + const runBatch = (items, commonOptions, cb) => { + const batches = /* @__PURE__ */ new Map(); + const getBatch = (mount) => { + let batch = batches.get(mount.base); + if (!batch) { + batch = { + driver: mount.driver, + base: mount.base, + items: [] + }; + batches.set(mount.base, batch); + } + return batch; + }; + for (const item of items) { + const isStringItem = typeof item === "string"; + const key = normalizeKey(isStringItem ? item : item.key); + const value = isStringItem ? void 0 : item.value; + const options2 = isStringItem || !item.options ? commonOptions : { ...commonOptions, ...item.options }; + const mount = getMount(key); + getBatch(mount).items.push({ + key, + value, + relativeKey: mount.relativeKey, + options: options2 + }); + } + return Promise.all([...batches.values()].map((batch) => cb(batch))).then( + (r3) => r3.flat() + ); + }; + const storage = { + // Item + hasItem(key, opts = {}) { + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + return asyncCall(driver.hasItem, relativeKey, opts); + }, + getItem(key, opts = {}) { + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + return asyncCall(driver.getItem, relativeKey, opts).then( + (value) => destr(value) + ); + }, + getItems(items, commonOptions) { + return runBatch(items, commonOptions, (batch) => { + if (batch.driver.getItems) { + return asyncCall( + batch.driver.getItems, + batch.items.map((item) => ({ + key: item.relativeKey, + options: item.options + })), + commonOptions + ).then( + (r3) => r3.map((item) => ({ + key: joinKeys(batch.base, item.key), + value: destr(item.value) + })) + ); + } + return Promise.all( + batch.items.map((item) => { + return asyncCall( + batch.driver.getItem, + item.relativeKey, + item.options + ).then((value) => ({ + key: item.key, + value: destr(value) + })); + }) + ); + }); + }, + getItemRaw(key, opts = {}) { + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + if (driver.getItemRaw) { + return asyncCall(driver.getItemRaw, relativeKey, opts); + } + return asyncCall(driver.getItem, relativeKey, opts).then( + (value) => deserializeRaw(value) + ); + }, + async setItem(key, value, opts = {}) { + if (value === void 0) { + return storage.removeItem(key); + } + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + if (!driver.setItem) { + return; + } + await asyncCall(driver.setItem, relativeKey, stringify(value), opts); + if (!driver.watch) { + onChange("update", key); + } + }, + async setItems(items, commonOptions) { + await runBatch(items, commonOptions, async (batch) => { + if (batch.driver.setItems) { + return asyncCall( + batch.driver.setItems, + batch.items.map((item) => ({ + key: item.relativeKey, + value: stringify(item.value), + options: item.options + })), + commonOptions + ); + } + if (!batch.driver.setItem) { + return; + } + await Promise.all( + batch.items.map((item) => { + return asyncCall( + batch.driver.setItem, + item.relativeKey, + stringify(item.value), + item.options + ); + }) + ); + }); + }, + async setItemRaw(key, value, opts = {}) { + if (value === void 0) { + return storage.removeItem(key, opts); + } + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + if (driver.setItemRaw) { + await asyncCall(driver.setItemRaw, relativeKey, value, opts); + } else if (driver.setItem) { + await asyncCall(driver.setItem, relativeKey, serializeRaw(value), opts); + } else { + return; + } + if (!driver.watch) { + onChange("update", key); + } + }, + async removeItem(key, opts = {}) { + if (typeof opts === "boolean") { + opts = { removeMeta: opts }; + } + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + if (!driver.removeItem) { + return; + } + await asyncCall(driver.removeItem, relativeKey, opts); + if (opts.removeMeta || opts.removeMata) { + await asyncCall(driver.removeItem, relativeKey + "$", opts); + } + if (!driver.watch) { + onChange("remove", key); + } + }, + // Meta + async getMeta(key, opts = {}) { + if (typeof opts === "boolean") { + opts = { nativeOnly: opts }; + } + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + const meta = /* @__PURE__ */ Object.create(null); + if (driver.getMeta) { + Object.assign(meta, await asyncCall(driver.getMeta, relativeKey, opts)); + } + if (!opts.nativeOnly) { + const value = await asyncCall( + driver.getItem, + relativeKey + "$", + opts + ).then((value_) => destr(value_)); + if (value && typeof value === "object") { + if (typeof value.atime === "string") { + value.atime = new Date(value.atime); + } + if (typeof value.mtime === "string") { + value.mtime = new Date(value.mtime); + } + Object.assign(meta, value); + } + } + return meta; + }, + setMeta(key, value, opts = {}) { + return this.setItem(key + "$", value, opts); + }, + removeMeta(key, opts = {}) { + return this.removeItem(key + "$", opts); + }, + // Keys + async getKeys(base3, opts = {}) { + base3 = normalizeBaseKey(base3); + const mounts = getMounts(base3, true); + let maskedMounts = []; + const allKeys = []; + for (const mount of mounts) { + const rawKeys = await asyncCall( + mount.driver.getKeys, + mount.relativeBase, + opts + ); + const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p2) => key.startsWith(p2))); + allKeys.push(...keys2); + maskedMounts = [ + mount.mountpoint, + ...maskedMounts.filter((p2) => !p2.startsWith(mount.mountpoint)) + ]; + } + return base3 ? allKeys.filter((key) => key.startsWith(base3) && !key.endsWith("$")) : allKeys.filter((key) => !key.endsWith("$")); + }, + // Utils + async clear(base3, opts = {}) { + base3 = normalizeBaseKey(base3); + await Promise.all( + getMounts(base3, false).map(async (m3) => { + if (m3.driver.clear) { + return asyncCall(m3.driver.clear, m3.relativeBase, opts); + } + if (m3.driver.removeItem) { + const keys2 = await m3.driver.getKeys(m3.relativeBase || "", opts); + return Promise.all( + keys2.map((key) => m3.driver.removeItem(key, opts)) + ); + } + }) + ); + }, + async dispose() { + await Promise.all( + Object.values(context.mounts).map((driver) => dispose(driver)) + ); + }, + async watch(callback) { + await startWatch(); + context.watchListeners.push(callback); + return async () => { + context.watchListeners = context.watchListeners.filter( + (listener) => listener !== callback + ); + if (context.watchListeners.length === 0) { + await stopWatch(); + } + }; + }, + async unwatch() { + context.watchListeners = []; + await stopWatch(); + }, + // Mount + mount(base3, driver) { + base3 = normalizeBaseKey(base3); + if (base3 && context.mounts[base3]) { + throw new Error(`already mounted at ${base3}`); + } + if (base3) { + context.mountpoints.push(base3); + context.mountpoints.sort((a3, b3) => b3.length - a3.length); + } + context.mounts[base3] = driver; + if (context.watching) { + Promise.resolve(watch$2(driver, onChange, base3)).then((unwatcher) => { + context.unwatch[base3] = unwatcher; + }).catch(console.error); + } + return storage; + }, + async unmount(base3, _dispose = true) { + base3 = normalizeBaseKey(base3); + if (!base3 || !context.mounts[base3]) { + return; + } + if (context.watching && base3 in context.unwatch) { + context.unwatch[base3](); + delete context.unwatch[base3]; + } + if (_dispose) { + await dispose(context.mounts[base3]); + } + context.mountpoints = context.mountpoints.filter((key) => key !== base3); + delete context.mounts[base3]; + }, + getMount(key = "") { + key = normalizeKey(key) + ":"; + const m3 = getMount(key); + return { + driver: m3.driver, + base: m3.base + }; + }, + getMounts(base3 = "", opts = {}) { + base3 = normalizeKey(base3); + const mounts = getMounts(base3, opts.parents); + return mounts.map((m3) => ({ + driver: m3.driver, + base: m3.mountpoint + })); + } + }; + return storage; +} +function watch$2(driver, onChange, base3) { + return driver.watch ? driver.watch((event, key) => onChange(event, base3 + key)) : () => { + }; +} +async function dispose(driver) { + if (typeof driver.dispose === "function") { + await asyncCall(driver.dispose); + } +} +function promisifyRequest(request) { + return new Promise((resolve, reject) => { + request.oncomplete = request.onsuccess = () => resolve(request.result); + request.onabort = request.onerror = () => reject(request.error); + }); +} +function createStore(dbName, storeName) { + const request = indexedDB.open(dbName); + request.onupgradeneeded = () => request.result.createObjectStore(storeName); + const dbp = promisifyRequest(request); + return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName))); +} +let defaultGetStoreFunc; +function defaultGetStore() { + if (!defaultGetStoreFunc) { + defaultGetStoreFunc = createStore("keyval-store", "keyval"); + } + return defaultGetStoreFunc; +} +function get(key, customStore = defaultGetStore()) { + return customStore("readonly", (store) => promisifyRequest(store.get(key))); +} +function set$1(key, value, customStore = defaultGetStore()) { + return customStore("readwrite", (store) => { + store.put(value, key); + return promisifyRequest(store.transaction); + }); +} +function del(key, customStore = defaultGetStore()) { + return customStore("readwrite", (store) => { + store.delete(key); + return promisifyRequest(store.transaction); + }); +} +function clear(customStore = defaultGetStore()) { + return customStore("readwrite", (store) => { + store.clear(); + return promisifyRequest(store.transaction); + }); +} +function eachCursor(store, callback) { + store.openCursor().onsuccess = function() { + if (!this.result) + return; + callback(this.result); + this.result.continue(); + }; + return promisifyRequest(store.transaction); +} +function keys(customStore = defaultGetStore()) { + return customStore("readonly", (store) => { + if (store.getAllKeys) { + return promisifyRequest(store.getAllKeys()); + } + const items = []; + return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items); + }); +} +const JSONStringify = (data) => JSON.stringify(data, (_3, value) => typeof value === "bigint" ? value.toString() + "n" : value); +const JSONParse = (json) => { + const numbersBiggerThanMaxInt = /([\[:])?(\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; + const serializedData = json.replace(numbersBiggerThanMaxInt, '$1"$2n"$3'); + return JSON.parse(serializedData, (_3, value) => { + const isCustomFormatBigInt = typeof value === "string" && value.match(/^\d+n$/); + if (isCustomFormatBigInt) + return BigInt(value.substring(0, value.length - 1)); + return value; + }); +}; +function safeJsonParse(value) { + if (typeof value !== "string") { + throw new Error(`Cannot safe json parse value of type ${typeof value}`); + } + try { + return JSONParse(value); + } catch (_a2) { + return value; + } +} +function safeJsonStringify(value) { + return typeof value === "string" ? value : JSONStringify(value) || ""; +} +const x$1 = "idb-keyval"; +var z$3 = (i2 = {}) => { + const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e2 = (s2) => t2 + s2; + let n4; + return i2.dbName && i2.storeName && (n4 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { + return !(typeof await get(e2(s2), n4) > "u"); + }, async getItem(s2) { + return await get(e2(s2), n4) ?? null; + }, setItem(s2, a3) { + return set$1(e2(s2), a3, n4); + }, removeItem(s2) { + return del(e2(s2), n4); + }, getKeys() { + return keys(n4); + }, clear() { + return clear(n4); + } }; +}; +const D$1 = "WALLET_CONNECT_V2_INDEXED_DB", E$2 = "keyvaluestorage"; +let _$1 = class _ { + constructor() { + this.indexedDb = createStorage({ driver: z$3({ dbName: D$1, storeName: E$2 }) }); + } + async getKeys() { + return this.indexedDb.getKeys(); + } + async getEntries() { + return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((t2) => [t2.key, t2.value]); + } + async getItem(t2) { + const e2 = await this.indexedDb.getItem(t2); + if (e2 !== null) + return e2; + } + async setItem(t2, e2) { + await this.indexedDb.setItem(t2, safeJsonStringify(e2)); + } + async removeItem(t2) { + await this.indexedDb.removeItem(t2); + } +}; +var l$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c$2 = { exports: {} }; +(function() { + let i2; + function t2() { + } + i2 = t2, i2.prototype.getItem = function(e2) { + return this.hasOwnProperty(e2) ? String(this[e2]) : null; + }, i2.prototype.setItem = function(e2, n4) { + this[e2] = String(n4); + }, i2.prototype.removeItem = function(e2) { + delete this[e2]; + }, i2.prototype.clear = function() { + const e2 = this; + Object.keys(e2).forEach(function(n4) { + e2[n4] = void 0, delete e2[n4]; + }); + }, i2.prototype.key = function(e2) { + return e2 = e2 || 0, Object.keys(this)[e2]; + }, i2.prototype.__defineGetter__("length", function() { + return Object.keys(this).length; + }), typeof l$1 < "u" && l$1.localStorage ? c$2.exports = l$1.localStorage : typeof window < "u" && window.localStorage ? c$2.exports = window.localStorage : c$2.exports = new t2(); +})(); +function k$3(i2) { + var t2; + return [i2[0], safeJsonParse((t2 = i2[1]) != null ? t2 : "")]; +} +let K$3 = class K { + constructor() { + this.localStorage = c$2.exports; + } + async getKeys() { + return Object.keys(this.localStorage); + } + async getEntries() { + return Object.entries(this.localStorage).map(k$3); + } + async getItem(t2) { + const e2 = this.localStorage.getItem(t2); + if (e2 !== null) + return safeJsonParse(e2); + } + async setItem(t2, e2) { + this.localStorage.setItem(t2, safeJsonStringify(e2)); + } + async removeItem(t2) { + this.localStorage.removeItem(t2); + } +}; +const N$1 = "wc_storage_version", y$3 = 1, O$2 = async (i2, t2, e2) => { + const n4 = N$1, s2 = await t2.getItem(n4); + if (s2 && s2 >= y$3) { + e2(t2); + return; + } + const a3 = await i2.getKeys(); + if (!a3.length) { + e2(t2); + return; + } + const m3 = []; + for (; a3.length; ) { + const r3 = a3.shift(); + if (!r3) + continue; + const o2 = r3.toLowerCase(); + if (o2.includes("wc@") || o2.includes("walletconnect") || o2.includes("wc_") || o2.includes("wallet_connect")) { + const f3 = await i2.getItem(r3); + await t2.setItem(r3, f3), m3.push(r3); + } + } + await t2.setItem(n4, y$3), e2(t2), j$3(i2, m3); +}, j$3 = async (i2, t2) => { + t2.length && t2.forEach(async (e2) => { + await i2.removeItem(e2); + }); +}; +let h$2 = class h { + constructor() { + this.initialized = false, this.setInitialized = (e2) => { + this.storage = e2, this.initialized = true; + }; + const t2 = new K$3(); + this.storage = t2; + try { + const e2 = new _$1(); + O$2(t2, e2, this.setInitialized); + } catch { + this.initialized = true; + } + } + async getKeys() { + return await this.initialize(), this.storage.getKeys(); + } + async getEntries() { + return await this.initialize(), this.storage.getEntries(); + } + async getItem(t2) { + return await this.initialize(), this.storage.getItem(t2); + } + async setItem(t2, e2) { + return await this.initialize(), this.storage.setItem(t2, e2); + } + async removeItem(t2) { + return await this.initialize(), this.storage.removeItem(t2); + } + async initialize() { + this.initialized || await new Promise((t2) => { + const e2 = setInterval(() => { + this.initialized && (clearInterval(e2), t2()); + }, 20); + }); + } +}; +var cjs$4 = {}; +/*! ***************************************************************************** +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. +***************************************************************************** */ +var extendStatics = function(d5, b3) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d6, b4) { + d6.__proto__ = b4; + } || function(d6, b4) { + for (var p2 in b4) + if (b4.hasOwnProperty(p2)) + d6[p2] = b4[p2]; + }; + return extendStatics(d5, b3); +}; +function __extends(d5, b3) { + extendStatics(d5, b3); + function __() { + this.constructor = d5; + } + d5.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); +} +var __assign = function() { + __assign = Object.assign || function __assign2(t2) { + for (var s2, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { + s2 = arguments[i2]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2)) + t2[p2] = s2[p2]; + } + return t2; + }; + return __assign.apply(this, arguments); +}; +function __rest(s2, e2) { + var t2 = {}; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0) + t2[p2] = s2[p2]; + if (s2 != null && typeof Object.getOwnPropertySymbols === "function") + for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++) { + if (e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i2])) + t2[p2[i2]] = s2[p2[i2]]; + } + return t2; +} +function __decorate(decorators, target, key, desc) { + var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d5; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") + r3 = Reflect.decorate(decorators, target, key, desc); + else + for (var i2 = decorators.length - 1; i2 >= 0; i2--) + if (d5 = decorators[i2]) + r3 = (c2 < 3 ? d5(r3) : c2 > 3 ? d5(target, key, r3) : d5(target, key)) || r3; + return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3; +} +function __param(paramIndex, decorator) { + return function(target, key) { + decorator(target, key, paramIndex); + }; +} +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") + return Reflect.metadata(metadataKey, metadataValue); +} +function __awaiter(thisArg, _arguments, P2, generator) { + function adopt(value) { + return value instanceof P2 ? value : new P2(function(resolve) { + resolve(value); + }); + } + return new (P2 || (P2 = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e2) { + reject(e2); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e2) { + reject(e2); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} +function __generator(thisArg, body) { + var _3 = { label: 0, sent: function() { + if (t2[0] & 1) + throw t2[1]; + return t2[1]; + }, trys: [], ops: [] }, f3, y3, t2, g3; + return g3 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() { + return this; + }), g3; + function verb(n4) { + return function(v3) { + return step([n4, v3]); + }; + } + function step(op) { + if (f3) + throw new TypeError("Generator is already executing."); + while (_3) + try { + if (f3 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) + return t2; + if (y3 = 0, t2) + op = [op[0] & 2, t2.value]; + switch (op[0]) { + case 0: + case 1: + t2 = op; + break; + case 4: + _3.label++; + return { value: op[1], done: false }; + case 5: + _3.label++; + y3 = op[1]; + op = [0]; + continue; + case 7: + op = _3.ops.pop(); + _3.trys.pop(); + continue; + default: + if (!(t2 = _3.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) { + _3 = 0; + continue; + } + if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) { + _3.label = op[1]; + break; + } + if (op[0] === 6 && _3.label < t2[1]) { + _3.label = t2[1]; + t2 = op; + break; + } + if (t2 && _3.label < t2[2]) { + _3.label = t2[2]; + _3.ops.push(op); + break; + } + if (t2[2]) + _3.ops.pop(); + _3.trys.pop(); + continue; + } + op = body.call(thisArg, _3); + } catch (e2) { + op = [6, e2]; + y3 = 0; + } finally { + f3 = t2 = 0; + } + if (op[0] & 5) + throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } +} +function __createBinding(o2, m3, k2, k22) { + if (k22 === void 0) + k22 = k2; + o2[k22] = m3[k2]; +} +function __exportStar(m3, exports2) { + for (var p2 in m3) + if (p2 !== "default" && !exports2.hasOwnProperty(p2)) + exports2[p2] = m3[p2]; +} +function __values(o2) { + var s2 = typeof Symbol === "function" && Symbol.iterator, m3 = s2 && o2[s2], i2 = 0; + if (m3) + return m3.call(o2); + if (o2 && typeof o2.length === "number") + return { + next: function() { + if (o2 && i2 >= o2.length) + o2 = void 0; + return { value: o2 && o2[i2++], done: !o2 }; + } + }; + throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined."); +} +function __read(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) + return o2; + var i2 = m3.call(o2), r3, ar3 = [], e2; + try { + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); + } catch (error) { + e2 = { error }; + } finally { + try { + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); + } finally { + if (e2) + throw e2.error; + } + } + return ar3; +} +function __spread() { + for (var ar3 = [], i2 = 0; i2 < arguments.length; i2++) + ar3 = ar3.concat(__read(arguments[i2])); + return ar3; +} +function __spreadArrays() { + for (var s2 = 0, i2 = 0, il = arguments.length; i2 < il; i2++) + s2 += arguments[i2].length; + for (var r3 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) + for (var a3 = arguments[i2], j2 = 0, jl = a3.length; j2 < jl; j2++, k2++) + r3[k2] = a3[j2]; + return r3; +} +function __await(v3) { + return this instanceof __await ? (this.v = v3, this) : new __await(v3); +} +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) + throw new TypeError("Symbol.asyncIterator is not defined."); + var g3 = generator.apply(thisArg, _arguments || []), i2, q2 = []; + return i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { + return this; + }, i2; + function verb(n4) { + if (g3[n4]) + i2[n4] = function(v3) { + return new Promise(function(a3, b3) { + q2.push([n4, v3, a3, b3]) > 1 || resume(n4, v3); + }); + }; + } + function resume(n4, v3) { + try { + step(g3[n4](v3)); + } catch (e2) { + settle(q2[0][3], e2); + } + } + function step(r3) { + r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q2[0][2], r3); + } + function fulfill(value) { + resume("next", value); + } + function reject(value) { + resume("throw", value); + } + function settle(f3, v3) { + if (f3(v3), q2.shift(), q2.length) + resume(q2[0][0], q2[0][1]); + } +} +function __asyncDelegator(o2) { + var i2, p2; + return i2 = {}, verb("next"), verb("throw", function(e2) { + throw e2; + }), verb("return"), i2[Symbol.iterator] = function() { + return this; + }, i2; + function verb(n4, f3) { + i2[n4] = o2[n4] ? function(v3) { + return (p2 = !p2) ? { value: __await(o2[n4](v3)), done: n4 === "return" } : f3 ? f3(v3) : v3; + } : f3; + } +} +function __asyncValues(o2) { + if (!Symbol.asyncIterator) + throw new TypeError("Symbol.asyncIterator is not defined."); + var m3 = o2[Symbol.asyncIterator], i2; + return m3 ? m3.call(o2) : (o2 = typeof __values === "function" ? __values(o2) : o2[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { + return this; + }, i2); + function verb(n4) { + i2[n4] = o2[n4] && function(v3) { + return new Promise(function(resolve, reject) { + v3 = o2[n4](v3), settle(resolve, reject, v3.done, v3.value); + }); + }; + } + function settle(resolve, reject, d5, v3) { + Promise.resolve(v3).then(function(v4) { + resolve({ value: v4, done: d5 }); + }, reject); + } +} +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { + Object.defineProperty(cooked, "raw", { value: raw }); + } else { + cooked.raw = raw; + } + return cooked; +} +function __importStar(mod) { + if (mod && mod.__esModule) + return mod; + var result = {}; + if (mod != null) { + for (var k2 in mod) + if (Object.hasOwnProperty.call(mod, k2)) + result[k2] = mod[k2]; + } + result.default = mod; + return result; +} +function __importDefault(mod) { + return mod && mod.__esModule ? mod : { default: mod }; +} +function __classPrivateFieldGet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + return privateMap.get(receiver); +} +function __classPrivateFieldSet(receiver, privateMap, value) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + privateMap.set(receiver, value); + return value; +} +const tslib_es6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + get __assign() { + return __assign; + }, + __asyncDelegator, + __asyncGenerator, + __asyncValues, + __await, + __awaiter, + __classPrivateFieldGet, + __classPrivateFieldSet, + __createBinding, + __decorate, + __exportStar, + __extends, + __generator, + __importDefault, + __importStar, + __makeTemplateObject, + __metadata, + __param, + __read, + __rest, + __spread, + __spreadArrays, + __values +}, Symbol.toStringTag, { value: "Module" })); +const require$$0$2 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6); +var heartbeat$2 = {}; +var cjs$3 = {}; +var utils = {}; +var delay = {}; +var hasRequiredDelay; +function requireDelay() { + if (hasRequiredDelay) + return delay; + hasRequiredDelay = 1; + Object.defineProperty(delay, "__esModule", { value: true }); + delay.delay = void 0; + function delay$1(timeout) { + return new Promise((resolve) => { + setTimeout(() => { + resolve(true); + }, timeout); + }); + } + delay.delay = delay$1; + return delay; +} +var convert = {}; +var constants$1 = {}; +var misc = {}; +var hasRequiredMisc; +function requireMisc() { + if (hasRequiredMisc) + return misc; + hasRequiredMisc = 1; + Object.defineProperty(misc, "__esModule", { value: true }); + misc.ONE_THOUSAND = misc.ONE_HUNDRED = void 0; + misc.ONE_HUNDRED = 100; + misc.ONE_THOUSAND = 1e3; + return misc; +} +var time = {}; +var hasRequiredTime; +function requireTime() { + if (hasRequiredTime) + return time; + hasRequiredTime = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.ONE_YEAR = exports2.FOUR_WEEKS = exports2.THREE_WEEKS = exports2.TWO_WEEKS = exports2.ONE_WEEK = exports2.THIRTY_DAYS = exports2.SEVEN_DAYS = exports2.FIVE_DAYS = exports2.THREE_DAYS = exports2.ONE_DAY = exports2.TWENTY_FOUR_HOURS = exports2.TWELVE_HOURS = exports2.SIX_HOURS = exports2.THREE_HOURS = exports2.ONE_HOUR = exports2.SIXTY_MINUTES = exports2.THIRTY_MINUTES = exports2.TEN_MINUTES = exports2.FIVE_MINUTES = exports2.ONE_MINUTE = exports2.SIXTY_SECONDS = exports2.THIRTY_SECONDS = exports2.TEN_SECONDS = exports2.FIVE_SECONDS = exports2.ONE_SECOND = void 0; + exports2.ONE_SECOND = 1; + exports2.FIVE_SECONDS = 5; + exports2.TEN_SECONDS = 10; + exports2.THIRTY_SECONDS = 30; + exports2.SIXTY_SECONDS = 60; + exports2.ONE_MINUTE = exports2.SIXTY_SECONDS; + exports2.FIVE_MINUTES = exports2.ONE_MINUTE * 5; + exports2.TEN_MINUTES = exports2.ONE_MINUTE * 10; + exports2.THIRTY_MINUTES = exports2.ONE_MINUTE * 30; + exports2.SIXTY_MINUTES = exports2.ONE_MINUTE * 60; + exports2.ONE_HOUR = exports2.SIXTY_MINUTES; + exports2.THREE_HOURS = exports2.ONE_HOUR * 3; + exports2.SIX_HOURS = exports2.ONE_HOUR * 6; + exports2.TWELVE_HOURS = exports2.ONE_HOUR * 12; + exports2.TWENTY_FOUR_HOURS = exports2.ONE_HOUR * 24; + exports2.ONE_DAY = exports2.TWENTY_FOUR_HOURS; + exports2.THREE_DAYS = exports2.ONE_DAY * 3; + exports2.FIVE_DAYS = exports2.ONE_DAY * 5; + exports2.SEVEN_DAYS = exports2.ONE_DAY * 7; + exports2.THIRTY_DAYS = exports2.ONE_DAY * 30; + exports2.ONE_WEEK = exports2.SEVEN_DAYS; + exports2.TWO_WEEKS = exports2.ONE_WEEK * 2; + exports2.THREE_WEEKS = exports2.ONE_WEEK * 3; + exports2.FOUR_WEEKS = exports2.ONE_WEEK * 4; + exports2.ONE_YEAR = exports2.ONE_DAY * 365; + })(time); + return time; +} +var hasRequiredConstants$1; +function requireConstants$1() { + if (hasRequiredConstants$1) + return constants$1; + hasRequiredConstants$1 = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireMisc(), exports2); + tslib_1.__exportStar(requireTime(), exports2); + })(constants$1); + return constants$1; +} +var hasRequiredConvert; +function requireConvert() { + if (hasRequiredConvert) + return convert; + hasRequiredConvert = 1; + Object.defineProperty(convert, "__esModule", { value: true }); + convert.fromMiliseconds = convert.toMiliseconds = void 0; + const constants_1 = requireConstants$1(); + function toMiliseconds(seconds) { + return seconds * constants_1.ONE_THOUSAND; + } + convert.toMiliseconds = toMiliseconds; + function fromMiliseconds(miliseconds) { + return Math.floor(miliseconds / constants_1.ONE_THOUSAND); + } + convert.fromMiliseconds = fromMiliseconds; + return convert; +} +var hasRequiredUtils; +function requireUtils() { + if (hasRequiredUtils) + return utils; + hasRequiredUtils = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireDelay(), exports2); + tslib_1.__exportStar(requireConvert(), exports2); + })(utils); + return utils; +} +var watch$1 = {}; +var hasRequiredWatch$1; +function requireWatch$1() { + if (hasRequiredWatch$1) + return watch$1; + hasRequiredWatch$1 = 1; + Object.defineProperty(watch$1, "__esModule", { value: true }); + watch$1.Watch = void 0; + class Watch { + constructor() { + this.timestamps = /* @__PURE__ */ new Map(); + } + start(label) { + if (this.timestamps.has(label)) { + throw new Error(`Watch already started for label: ${label}`); + } + this.timestamps.set(label, { started: Date.now() }); + } + stop(label) { + const timestamp = this.get(label); + if (typeof timestamp.elapsed !== "undefined") { + throw new Error(`Watch already stopped for label: ${label}`); + } + const elapsed = Date.now() - timestamp.started; + this.timestamps.set(label, { started: timestamp.started, elapsed }); + } + get(label) { + const timestamp = this.timestamps.get(label); + if (typeof timestamp === "undefined") { + throw new Error(`No timestamp found for label: ${label}`); + } + return timestamp; + } + elapsed(label) { + const timestamp = this.get(label); + const elapsed = timestamp.elapsed || Date.now() - timestamp.started; + return elapsed; + } + } + watch$1.Watch = Watch; + watch$1.default = Watch; + return watch$1; +} +var types$2 = {}; +var watch = {}; +var hasRequiredWatch; +function requireWatch() { + if (hasRequiredWatch) + return watch; + hasRequiredWatch = 1; + Object.defineProperty(watch, "__esModule", { value: true }); + watch.IWatch = void 0; + class IWatch { + } + watch.IWatch = IWatch; + return watch; +} +var hasRequiredTypes$1; +function requireTypes$1() { + if (hasRequiredTypes$1) + return types$2; + hasRequiredTypes$1 = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireWatch(), exports2); + })(types$2); + return types$2; +} +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireUtils(), exports2); + tslib_1.__exportStar(requireWatch$1(), exports2); + tslib_1.__exportStar(requireTypes$1(), exports2); + tslib_1.__exportStar(requireConstants$1(), exports2); +})(cjs$3); +var types$1 = {}; +var heartbeat$1 = {}; +class IEvents { +} +const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + IEvents +}, Symbol.toStringTag, { value: "Module" })); +const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(esm); +var hasRequiredHeartbeat$2; +function requireHeartbeat$2() { + if (hasRequiredHeartbeat$2) + return heartbeat$1; + hasRequiredHeartbeat$2 = 1; + Object.defineProperty(heartbeat$1, "__esModule", { value: true }); + heartbeat$1.IHeartBeat = void 0; + const events_1 = require$$0$1; + class IHeartBeat extends events_1.IEvents { + constructor(opts) { + super(); + } + } + heartbeat$1.IHeartBeat = IHeartBeat; + return heartbeat$1; +} +var hasRequiredTypes; +function requireTypes() { + if (hasRequiredTypes) + return types$1; + hasRequiredTypes = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireHeartbeat$2(), exports2); + })(types$1); + return types$1; +} +var constants = {}; +var heartbeat = {}; +var hasRequiredHeartbeat$1; +function requireHeartbeat$1() { + if (hasRequiredHeartbeat$1) + return heartbeat; + hasRequiredHeartbeat$1 = 1; + Object.defineProperty(heartbeat, "__esModule", { value: true }); + heartbeat.HEARTBEAT_EVENTS = heartbeat.HEARTBEAT_INTERVAL = void 0; + const time_1 = cjs$3; + heartbeat.HEARTBEAT_INTERVAL = time_1.FIVE_SECONDS; + heartbeat.HEARTBEAT_EVENTS = { + pulse: "heartbeat_pulse" + }; + return heartbeat; +} +var hasRequiredConstants; +function requireConstants() { + if (hasRequiredConstants) + return constants; + hasRequiredConstants = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireHeartbeat$1(), exports2); + })(constants); + return constants; +} +var hasRequiredHeartbeat; +function requireHeartbeat() { + if (hasRequiredHeartbeat) + return heartbeat$2; + hasRequiredHeartbeat = 1; + Object.defineProperty(heartbeat$2, "__esModule", { value: true }); + heartbeat$2.HeartBeat = void 0; + const tslib_1 = require$$0$2; + const events_1 = eventsExports; + const time_1 = cjs$3; + const types_1 = requireTypes(); + const constants_1 = requireConstants(); + class HeartBeat extends types_1.IHeartBeat { + constructor(opts) { + super(opts); + this.events = new events_1.EventEmitter(); + this.interval = constants_1.HEARTBEAT_INTERVAL; + this.interval = (opts === null || opts === void 0 ? void 0 : opts.interval) || constants_1.HEARTBEAT_INTERVAL; + } + static init(opts) { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + const heartbeat2 = new HeartBeat(opts); + yield heartbeat2.init(); + return heartbeat2; + }); + } + init() { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + yield this.initialize(); + }); + } + stop() { + clearInterval(this.intervalRef); + } + on(event, listener) { + this.events.on(event, listener); + } + once(event, listener) { + this.events.once(event, listener); + } + off(event, listener) { + this.events.off(event, listener); + } + removeListener(event, listener) { + this.events.removeListener(event, listener); + } + initialize() { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + this.intervalRef = setInterval(() => this.pulse(), time_1.toMiliseconds(this.interval)); + }); + } + pulse() { + this.events.emit(constants_1.HEARTBEAT_EVENTS.pulse); + } + } + heartbeat$2.HeartBeat = HeartBeat; + return heartbeat$2; +} +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireHeartbeat(), exports2); + tslib_1.__exportStar(requireTypes(), exports2); + tslib_1.__exportStar(requireConstants(), exports2); +})(cjs$4); +function tryStringify(o2) { + try { + return JSON.stringify(o2); + } catch (e2) { + return '"[Circular]"'; + } +} +var quickFormatUnescaped = format$1; +function format$1(f3, args, opts) { + var ss4 = opts && opts.stringify || tryStringify; + var offset = 1; + if (typeof f3 === "object" && f3 !== null) { + var len = args.length + offset; + if (len === 1) + return f3; + var objects = new Array(len); + objects[0] = ss4(f3); + for (var index = 1; index < len; index++) { + objects[index] = ss4(args[index]); + } + return objects.join(" "); + } + if (typeof f3 !== "string") { + return f3; + } + var argLen = args.length; + if (argLen === 0) + return f3; + var str = ""; + var a3 = 1 - offset; + var lastPos = -1; + var flen = f3 && f3.length || 0; + for (var i2 = 0; i2 < flen; ) { + if (f3.charCodeAt(i2) === 37 && i2 + 1 < flen) { + lastPos = lastPos > -1 ? lastPos : 0; + switch (f3.charCodeAt(i2 + 1)) { + case 100: + case 102: + if (a3 >= argLen) + break; + if (args[a3] == null) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Number(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 105: + if (a3 >= argLen) + break; + if (args[a3] == null) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Math.floor(Number(args[a3])); + lastPos = i2 + 2; + i2++; + break; + case 79: + case 111: + case 106: + if (a3 >= argLen) + break; + if (args[a3] === void 0) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + var type2 = typeof args[a3]; + if (type2 === "string") { + str += "'" + args[a3] + "'"; + lastPos = i2 + 2; + i2++; + break; + } + if (type2 === "function") { + str += args[a3].name || ""; + lastPos = i2 + 2; + i2++; + break; + } + str += ss4(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 115: + if (a3 >= argLen) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += String(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 37: + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += "%"; + lastPos = i2 + 2; + i2++; + a3--; + break; + } + ++a3; + } + ++i2; + } + if (lastPos === -1) + return f3; + else if (lastPos < flen) { + str += f3.slice(lastPos); + } + return str; +} +const format = quickFormatUnescaped; +var browser$4 = pino; +const _console = pfGlobalThisOrFallback().console || {}; +const stdSerializers = { + mapHttpRequest: mock, + mapHttpResponse: mock, + wrapRequestSerializer: passthrough, + wrapResponseSerializer: passthrough, + wrapErrorSerializer: passthrough, + req: mock, + res: mock, + err: asErrValue +}; +function shouldSerialize(serialize, serializers) { + if (Array.isArray(serialize)) { + const hasToFilter = serialize.filter(function(k2) { + return k2 !== "!stdSerializers.err"; + }); + return hasToFilter; + } else if (serialize === true) { + return Object.keys(serializers); + } + return false; +} +function pino(opts) { + opts = opts || {}; + opts.browser = opts.browser || {}; + const transmit2 = opts.browser.transmit; + if (transmit2 && typeof transmit2.send !== "function") { + throw Error("pino: transmit option must have a send function"); + } + const proto = opts.browser.write || _console; + if (opts.browser.write) + opts.browser.asObject = true; + const serializers = opts.serializers || {}; + const serialize = shouldSerialize(opts.browser.serialize, serializers); + let stdErrSerialize = opts.browser.serialize; + if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) + stdErrSerialize = false; + const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; + if (typeof proto === "function") { + proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; + } + if (opts.enabled === false) + opts.level = "silent"; + const level = opts.level || "info"; + const logger = Object.create(proto); + if (!logger.log) + logger.log = noop; + Object.defineProperty(logger, "levelVal", { + get: getLevelVal + }); + Object.defineProperty(logger, "level", { + get: getLevel, + set: setLevel + }); + const setOpts = { + transmit: transmit2, + serialize, + asObject: opts.browser.asObject, + levels, + timestamp: getTimeFunction(opts) + }; + logger.levels = pino.levels; + logger.level = level; + logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop; + logger.serializers = serializers; + logger._serialize = serialize; + logger._stdErrSerialize = stdErrSerialize; + logger.child = child; + if (transmit2) + logger._logEvent = createLogEventShape(); + function getLevelVal() { + return this.level === "silent" ? Infinity : this.levels.values[this.level]; + } + function getLevel() { + return this._level; + } + function setLevel(level2) { + if (level2 !== "silent" && !this.levels.values[level2]) { + throw Error("unknown level " + level2); + } + this._level = level2; + set(setOpts, logger, "error", "log"); + set(setOpts, logger, "fatal", "error"); + set(setOpts, logger, "warn", "error"); + set(setOpts, logger, "info", "log"); + set(setOpts, logger, "debug", "log"); + set(setOpts, logger, "trace", "log"); + } + function child(bindings, childOptions) { + if (!bindings) { + throw new Error("missing bindings for child Pino"); + } + childOptions = childOptions || {}; + if (serialize && bindings.serializers) { + childOptions.serializers = bindings.serializers; + } + const childOptionsSerializers = childOptions.serializers; + if (serialize && childOptionsSerializers) { + var childSerializers = Object.assign({}, serializers, childOptionsSerializers); + var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; + delete bindings.serializers; + applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); + } + function Child(parent) { + this._childLevel = (parent._childLevel | 0) + 1; + this.error = bind(parent, bindings, "error"); + this.fatal = bind(parent, bindings, "fatal"); + this.warn = bind(parent, bindings, "warn"); + this.info = bind(parent, bindings, "info"); + this.debug = bind(parent, bindings, "debug"); + this.trace = bind(parent, bindings, "trace"); + if (childSerializers) { + this.serializers = childSerializers; + this._serialize = childSerialize; + } + if (transmit2) { + this._logEvent = createLogEventShape( + [].concat(parent._logEvent.bindings, bindings) + ); + } + } + Child.prototype = this; + return new Child(this); + } + return logger; +} +pino.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" + } +}; +pino.stdSerializers = stdSerializers; +pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); +function set(opts, logger, level, fallback) { + const proto = Object.getPrototypeOf(logger); + logger[level] = logger.levelVal > logger.levels.values[level] ? noop : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop; + wrap(opts, logger, level); +} +function wrap(opts, logger, level) { + if (!opts.transmit && logger[level] === noop) + return; + logger[level] = /* @__PURE__ */ function(write) { + return function LOG() { + const ts3 = opts.timestamp(); + const args = new Array(arguments.length); + const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; + for (var i2 = 0; i2 < args.length; i2++) + args[i2] = arguments[i2]; + if (opts.serialize && !opts.asObject) { + applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); + } + if (opts.asObject) + write.call(proto, asObject(this, level, args, ts3)); + else + write.apply(proto, args); + if (opts.transmit) { + const transmitLevel = opts.transmit.level || logger.level; + const transmitValue = pino.levels.values[transmitLevel]; + const methodValue = pino.levels.values[level]; + if (methodValue < transmitValue) + return; + transmit(this, { + ts: ts3, + methodLevel: level, + methodValue, + transmitLevel, + transmitValue: pino.levels.values[opts.transmit.level || logger.level], + send: opts.transmit.send, + val: logger.levelVal + }, args); + } + }; + }(logger[level]); +} +function asObject(logger, level, args, ts3) { + if (logger._serialize) + applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); + const argsCloned = args.slice(); + let msg = argsCloned[0]; + const o2 = {}; + if (ts3) { + o2.time = ts3; + } + o2.level = pino.levels.values[level]; + let lvl = (logger._childLevel | 0) + 1; + if (lvl < 1) + lvl = 1; + if (msg !== null && typeof msg === "object") { + while (lvl-- && typeof argsCloned[0] === "object") { + Object.assign(o2, argsCloned.shift()); + } + msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; + } else if (typeof msg === "string") + msg = format(argsCloned.shift(), argsCloned); + if (msg !== void 0) + o2.msg = msg; + return o2; +} +function applySerializers(args, serialize, serializers, stdErrSerialize) { + for (const i2 in args) { + if (stdErrSerialize && args[i2] instanceof Error) { + args[i2] = pino.stdSerializers.err(args[i2]); + } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { + for (const k2 in args[i2]) { + if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { + args[i2][k2] = serializers[k2](args[i2][k2]); + } + } + } + } +} +function bind(parent, bindings, level) { + return function() { + const args = new Array(1 + arguments.length); + args[0] = bindings; + for (var i2 = 1; i2 < args.length; i2++) { + args[i2] = arguments[i2 - 1]; + } + return parent[level].apply(this, args); + }; +} +function transmit(logger, opts, args) { + const send = opts.send; + const ts3 = opts.ts; + const methodLevel = opts.methodLevel; + const methodValue = opts.methodValue; + const val = opts.val; + const bindings = logger._logEvent.bindings; + applySerializers( + args, + logger._serialize || Object.keys(logger.serializers), + logger.serializers, + logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize + ); + logger._logEvent.ts = ts3; + logger._logEvent.messages = args.filter(function(arg) { + return bindings.indexOf(arg) === -1; + }); + logger._logEvent.level.label = methodLevel; + logger._logEvent.level.value = methodValue; + send(methodLevel, logger._logEvent, val); + logger._logEvent = createLogEventShape(bindings); +} +function createLogEventShape(bindings) { + return { + ts: 0, + messages: [], + bindings: bindings || [], + level: { label: "", value: 0 } + }; +} +function asErrValue(err) { + const obj = { + type: err.constructor.name, + msg: err.message, + stack: err.stack + }; + for (const key in err) { + if (obj[key] === void 0) { + obj[key] = err[key]; + } + } + return obj; +} +function getTimeFunction(opts) { + if (typeof opts.timestamp === "function") { + return opts.timestamp; + } + if (opts.timestamp === false) { + return nullTime; + } + return epochTime; +} +function mock() { + return {}; +} +function passthrough(a3) { + return a3; +} +function noop() { +} +function nullTime() { + return false; +} +function epochTime() { + return Date.now(); +} +function unixTime() { + return Math.round(Date.now() / 1e3); +} +function isoTime() { + return new Date(Date.now()).toISOString(); +} +function pfGlobalThisOrFallback() { + function defd(o2) { + return typeof o2 !== "undefined" && o2; + } + try { + if (typeof globalThis !== "undefined") + return globalThis; + Object.defineProperty(Object.prototype, "globalThis", { + get: function() { + delete Object.prototype.globalThis; + return this.globalThis = this; + }, + configurable: true + }); + return globalThis; + } catch (e2) { + return defd(self) || defd(window) || defd(this) || {}; + } +} +const nt$1 = /* @__PURE__ */ getDefaultExportFromCjs(browser$4); +const c$1 = { level: "info" }, n$3 = "custom_context", l = 1e3 * 1024; +let O$1 = class O { + constructor(e2) { + this.nodeValue = e2, this.sizeInBytes = new TextEncoder().encode(this.nodeValue).length, this.next = null; + } + get value() { + return this.nodeValue; + } + get size() { + return this.sizeInBytes; + } +}; +let d$2 = class d2 { + constructor(e2) { + this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e2, this.sizeInBytes = 0; + } + append(e2) { + const t2 = new O$1(e2); + if (t2.size > this.maxSizeInBytes) + throw new Error(`[LinkedList] Value too big to insert into list: ${e2} with size ${t2.size}`); + for (; this.size + t2.size > this.maxSizeInBytes; ) + this.shift(); + this.head ? (this.tail && (this.tail.next = t2), this.tail = t2) : (this.head = t2, this.tail = t2), this.lengthInNodes++, this.sizeInBytes += t2.size; + } + shift() { + if (!this.head) + return; + const e2 = this.head; + this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e2.size; + } + toArray() { + const e2 = []; + let t2 = this.head; + for (; t2 !== null; ) + e2.push(t2.value), t2 = t2.next; + return e2; + } + get length() { + return this.lengthInNodes; + } + get size() { + return this.sizeInBytes; + } + toOrderedArray() { + return Array.from(this); + } + [Symbol.iterator]() { + let e2 = this.head; + return { next: () => { + if (!e2) + return { done: true, value: null }; + const t2 = e2.value; + return e2 = e2.next, { done: false, value: t2 }; + } }; + } +}; +let L$4 = class L { + constructor(e2, t2 = l) { + this.level = e2 ?? "error", this.levelValue = browser$4.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = t2, this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); + } + forwardToConsole(e2, t2) { + t2 === browser$4.levels.values.error ? console.error(e2) : t2 === browser$4.levels.values.warn ? console.warn(e2) : t2 === browser$4.levels.values.debug ? console.debug(e2) : t2 === browser$4.levels.values.trace ? console.trace(e2) : console.log(e2); + } + appendToLogs(e2) { + this.logs.append(safeJsonStringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: e2 })); + const t2 = typeof e2 == "string" ? JSON.parse(e2).level : e2.level; + t2 >= this.levelValue && this.forwardToConsole(e2, t2); + } + getLogs() { + return this.logs; + } + clearLogs() { + this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); + } + getLogArray() { + return Array.from(this.logs); + } + logsToBlob(e2) { + const t2 = this.getLogArray(); + return t2.push(safeJsonStringify({ extraMetadata: e2 })), new Blob(t2, { type: "application/json" }); + } +}; +let m$1 = class m { + constructor(e2, t2 = l) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } + downloadLogsBlobInBrowser(e2) { + const t2 = URL.createObjectURL(this.logsToBlob(e2)), o2 = document.createElement("a"); + o2.href = t2, o2.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(o2), o2.click(), document.body.removeChild(o2), URL.revokeObjectURL(t2); + } +}; +class B { + constructor(e2, t2 = l) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } +} +var x = Object.defineProperty, S$3 = Object.defineProperties, _2 = Object.getOwnPropertyDescriptors, p$1 = Object.getOwnPropertySymbols, T$1 = Object.prototype.hasOwnProperty, z$2 = Object.prototype.propertyIsEnumerable, f$3 = (r3, e2, t2) => e2 in r3 ? x(r3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : r3[e2] = t2, i = (r3, e2) => { + for (var t2 in e2 || (e2 = {})) + T$1.call(e2, t2) && f$3(r3, t2, e2[t2]); + if (p$1) + for (var t2 of p$1(e2)) + z$2.call(e2, t2) && f$3(r3, t2, e2[t2]); + return r3; +}, g$2 = (r3, e2) => S$3(r3, _2(e2)); +function k$2(r3) { + return g$2(i({}, r3), { level: (r3 == null ? void 0 : r3.level) || c$1.level }); +} +function v$2(r3, e2 = n$3) { + return r3[e2] || ""; +} +function b$2(r3, e2, t2 = n$3) { + return r3[t2] = e2, r3; +} +function y$2(r3, e2 = n$3) { + let t2 = ""; + return typeof r3.bindings > "u" ? t2 = v$2(r3, e2) : t2 = r3.bindings().context || "", t2; +} +function w$3(r3, e2, t2 = n$3) { + const o2 = y$2(r3, t2); + return o2.trim() ? `${o2}/${e2}` : e2; +} +function E$1(r3, e2, t2 = n$3) { + const o2 = w$3(r3, e2, t2), a3 = r3.child({ context: o2 }); + return b$2(a3, o2, t2); +} +function C$2(r3) { + var e2, t2; + const o2 = new m$1((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i({}, r3.opts), { level: "trace", browser: g$2(i({}, (t2 = r3.opts) == null ? void 0 : t2.browser), { write: (a3) => o2.write(a3) }) })), chunkLoggerController: o2 }; +} +function I$2(r3) { + var e2; + const t2 = new B((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i({}, r3.opts), { level: "trace" }), t2), chunkLoggerController: t2 }; +} +function A$2(r3) { + return typeof r3.loggerOverride < "u" && typeof r3.loggerOverride != "string" ? { logger: r3.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? C$2(r3) : I$2(r3); +} +let n$2 = class n extends IEvents { + constructor(s2) { + super(), this.opts = s2, this.protocol = "wc", this.version = 2; + } +}; +let h$1 = class h2 extends IEvents { + constructor(s2, t2) { + super(), this.core = s2, this.logger = t2, this.records = /* @__PURE__ */ new Map(); + } +}; +let a$1 = class a { + constructor(s2, t2) { + this.logger = s2, this.core = t2; + } +}; +let u$1 = class u extends IEvents { + constructor(s2, t2) { + super(), this.relayer = s2, this.logger = t2; + } +}; +let g$1 = class g extends IEvents { + constructor(s2) { + super(); + } +}; +class p { + constructor(s2, t2, o2, M2) { + this.core = s2, this.logger = t2, this.name = o2; + } +} +let d$1 = class d3 extends IEvents { + constructor(s2, t2) { + super(), this.relayer = s2, this.logger = t2; + } +}; +class E extends IEvents { + constructor(s2, t2) { + super(), this.core = s2, this.logger = t2; + } +} +let y$1 = class y { + constructor(s2, t2) { + this.projectId = s2, this.logger = t2; + } +}; +let v$1 = class v { + constructor(s2, t2) { + this.projectId = s2, this.logger = t2; + } +}; +let b$1 = class b { + constructor(s2) { + this.opts = s2, this.protocol = "wc", this.version = 2; + } +}; +let w$2 = class w { + constructor(s2) { + this.client = s2; + } +}; +var ed25519 = {}; +var random = {}; +var system = {}; +var browser$3 = {}; +Object.defineProperty(browser$3, "__esModule", { value: true }); +browser$3.BrowserRandomSource = void 0; +const QUOTA = 65536; +class BrowserRandomSource { + constructor() { + this.isAvailable = false; + this.isInstantiated = false; + const browserCrypto = typeof self !== "undefined" ? self.crypto || self.msCrypto : null; + if (browserCrypto && browserCrypto.getRandomValues !== void 0) { + this._crypto = browserCrypto; + this.isAvailable = true; + this.isInstantiated = true; + } + } + randomBytes(length) { + if (!this.isAvailable || !this._crypto) { + throw new Error("Browser random byte generator is not available."); + } + const out = new Uint8Array(length); + for (let i2 = 0; i2 < out.length; i2 += QUOTA) { + this._crypto.getRandomValues(out.subarray(i2, i2 + Math.min(out.length - i2, QUOTA))); + } + return out; + } +} +browser$3.BrowserRandomSource = BrowserRandomSource; +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} +var node = {}; +var wipe$1 = {}; +Object.defineProperty(wipe$1, "__esModule", { value: true }); +function wipe(array) { + for (var i2 = 0; i2 < array.length; i2++) { + array[i2] = 0; + } + return array; +} +wipe$1.wipe = wipe; +const __viteBrowserExternal = {}; +const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + default: __viteBrowserExternal +}, Symbol.toStringTag, { value: "Module" })); +const require$$1 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1); +Object.defineProperty(node, "__esModule", { value: true }); +node.NodeRandomSource = void 0; +const wipe_1$3 = wipe$1; +class NodeRandomSource { + constructor() { + this.isAvailable = false; + this.isInstantiated = false; + if (typeof commonjsRequire !== "undefined") { + const nodeCrypto = require$$1; + if (nodeCrypto && nodeCrypto.randomBytes) { + this._crypto = nodeCrypto; + this.isAvailable = true; + this.isInstantiated = true; + } + } + } + randomBytes(length) { + if (!this.isAvailable || !this._crypto) { + throw new Error("Node.js random byte generator is not available."); + } + let buffer = this._crypto.randomBytes(length); + if (buffer.length !== length) { + throw new Error("NodeRandomSource: got fewer bytes than requested"); + } + const out = new Uint8Array(length); + for (let i2 = 0; i2 < out.length; i2++) { + out[i2] = buffer[i2]; + } + (0, wipe_1$3.wipe)(buffer); + return out; + } +} +node.NodeRandomSource = NodeRandomSource; +Object.defineProperty(system, "__esModule", { value: true }); +system.SystemRandomSource = void 0; +const browser_1 = browser$3; +const node_1 = node; +class SystemRandomSource { + constructor() { + this.isAvailable = false; + this.name = ""; + this._source = new browser_1.BrowserRandomSource(); + if (this._source.isAvailable) { + this.isAvailable = true; + this.name = "Browser"; + return; + } + this._source = new node_1.NodeRandomSource(); + if (this._source.isAvailable) { + this.isAvailable = true; + this.name = "Node"; + return; + } + } + randomBytes(length) { + if (!this.isAvailable) { + throw new Error("System random byte generator is not available."); + } + return this._source.randomBytes(length); + } +} +system.SystemRandomSource = SystemRandomSource; +var binary = {}; +var int = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + function imulShim(a3, b3) { + var ah2 = a3 >>> 16 & 65535, al = a3 & 65535; + var bh = b3 >>> 16 & 65535, bl = b3 & 65535; + return al * bl + (ah2 * bl + al * bh << 16 >>> 0) | 0; + } + exports2.mul = Math.imul || imulShim; + function add(a3, b3) { + return a3 + b3 | 0; + } + exports2.add = add; + function sub(a3, b3) { + return a3 - b3 | 0; + } + exports2.sub = sub; + function rotl(x2, n4) { + return x2 << n4 | x2 >>> 32 - n4; + } + exports2.rotl = rotl; + function rotr(x2, n4) { + return x2 << 32 - n4 | x2 >>> n4; + } + exports2.rotr = rotr; + function isIntegerShim(n4) { + return typeof n4 === "number" && isFinite(n4) && Math.floor(n4) === n4; + } + exports2.isInteger = Number.isInteger || isIntegerShim; + exports2.MAX_SAFE_INTEGER = 9007199254740991; + exports2.isSafeInteger = function(n4) { + return exports2.isInteger(n4) && (n4 >= -exports2.MAX_SAFE_INTEGER && n4 <= exports2.MAX_SAFE_INTEGER); + }; +})(int); +Object.defineProperty(binary, "__esModule", { value: true }); +var int_1 = int; +function readInt16BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 0] << 8 | array[offset + 1]) << 16 >> 16; +} +binary.readInt16BE = readInt16BE; +function readUint16BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 0] << 8 | array[offset + 1]) >>> 0; +} +binary.readUint16BE = readUint16BE; +function readInt16LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 1] << 8 | array[offset]) << 16 >> 16; +} +binary.readInt16LE = readInt16LE; +function readUint16LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 1] << 8 | array[offset]) >>> 0; +} +binary.readUint16LE = readUint16LE; +function writeUint16BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(2); + } + if (offset === void 0) { + offset = 0; + } + out[offset + 0] = value >>> 8; + out[offset + 1] = value >>> 0; + return out; +} +binary.writeUint16BE = writeUint16BE; +binary.writeInt16BE = writeUint16BE; +function writeUint16LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(2); + } + if (offset === void 0) { + offset = 0; + } + out[offset + 0] = value >>> 0; + out[offset + 1] = value >>> 8; + return out; +} +binary.writeUint16LE = writeUint16LE; +binary.writeInt16LE = writeUint16LE; +function readInt32BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3]; +} +binary.readInt32BE = readInt32BE; +function readUint32BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3]) >>> 0; +} +binary.readUint32BE = readUint32BE; +function readInt32LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return array[offset + 3] << 24 | array[offset + 2] << 16 | array[offset + 1] << 8 | array[offset]; +} +binary.readInt32LE = readInt32LE; +function readUint32LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 3] << 24 | array[offset + 2] << 16 | array[offset + 1] << 8 | array[offset]) >>> 0; +} +binary.readUint32LE = readUint32LE; +function writeUint32BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(4); + } + if (offset === void 0) { + offset = 0; + } + out[offset + 0] = value >>> 24; + out[offset + 1] = value >>> 16; + out[offset + 2] = value >>> 8; + out[offset + 3] = value >>> 0; + return out; +} +binary.writeUint32BE = writeUint32BE; +binary.writeInt32BE = writeUint32BE; +function writeUint32LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(4); + } + if (offset === void 0) { + offset = 0; + } + out[offset + 0] = value >>> 0; + out[offset + 1] = value >>> 8; + out[offset + 2] = value >>> 16; + out[offset + 3] = value >>> 24; + return out; +} +binary.writeUint32LE = writeUint32LE; +binary.writeInt32LE = writeUint32LE; +function readInt64BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var hi = readInt32BE(array, offset); + var lo2 = readInt32BE(array, offset + 4); + return hi * 4294967296 + lo2 - (lo2 >> 31) * 4294967296; +} +binary.readInt64BE = readInt64BE; +function readUint64BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var hi = readUint32BE(array, offset); + var lo2 = readUint32BE(array, offset + 4); + return hi * 4294967296 + lo2; +} +binary.readUint64BE = readUint64BE; +function readInt64LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var lo2 = readInt32LE(array, offset); + var hi = readInt32LE(array, offset + 4); + return hi * 4294967296 + lo2 - (lo2 >> 31) * 4294967296; +} +binary.readInt64LE = readInt64LE; +function readUint64LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var lo2 = readUint32LE(array, offset); + var hi = readUint32LE(array, offset + 4); + return hi * 4294967296 + lo2; +} +binary.readUint64LE = readUint64LE; +function writeUint64BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(8); + } + if (offset === void 0) { + offset = 0; + } + writeUint32BE(value / 4294967296 >>> 0, out, offset); + writeUint32BE(value >>> 0, out, offset + 4); + return out; +} +binary.writeUint64BE = writeUint64BE; +binary.writeInt64BE = writeUint64BE; +function writeUint64LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(8); + } + if (offset === void 0) { + offset = 0; + } + writeUint32LE(value >>> 0, out, offset); + writeUint32LE(value / 4294967296 >>> 0, out, offset + 4); + return out; +} +binary.writeUint64LE = writeUint64LE; +binary.writeInt64LE = writeUint64LE; +function readUintBE(bitLength, array, offset) { + if (offset === void 0) { + offset = 0; + } + if (bitLength % 8 !== 0) { + throw new Error("readUintBE supports only bitLengths divisible by 8"); + } + if (bitLength / 8 > array.length - offset) { + throw new Error("readUintBE: array is too short for the given bitLength"); + } + var result = 0; + var mul = 1; + for (var i2 = bitLength / 8 + offset - 1; i2 >= offset; i2--) { + result += array[i2] * mul; + mul *= 256; + } + return result; +} +binary.readUintBE = readUintBE; +function readUintLE(bitLength, array, offset) { + if (offset === void 0) { + offset = 0; + } + if (bitLength % 8 !== 0) { + throw new Error("readUintLE supports only bitLengths divisible by 8"); + } + if (bitLength / 8 > array.length - offset) { + throw new Error("readUintLE: array is too short for the given bitLength"); + } + var result = 0; + var mul = 1; + for (var i2 = offset; i2 < offset + bitLength / 8; i2++) { + result += array[i2] * mul; + mul *= 256; + } + return result; +} +binary.readUintLE = readUintLE; +function writeUintBE(bitLength, value, out, offset) { + if (out === void 0) { + out = new Uint8Array(bitLength / 8); + } + if (offset === void 0) { + offset = 0; + } + if (bitLength % 8 !== 0) { + throw new Error("writeUintBE supports only bitLengths divisible by 8"); + } + if (!int_1.isSafeInteger(value)) { + throw new Error("writeUintBE value must be an integer"); + } + var div = 1; + for (var i2 = bitLength / 8 + offset - 1; i2 >= offset; i2--) { + out[i2] = value / div & 255; + div *= 256; + } + return out; +} +binary.writeUintBE = writeUintBE; +function writeUintLE(bitLength, value, out, offset) { + if (out === void 0) { + out = new Uint8Array(bitLength / 8); + } + if (offset === void 0) { + offset = 0; + } + if (bitLength % 8 !== 0) { + throw new Error("writeUintLE supports only bitLengths divisible by 8"); + } + if (!int_1.isSafeInteger(value)) { + throw new Error("writeUintLE value must be an integer"); + } + var div = 1; + for (var i2 = offset; i2 < offset + bitLength / 8; i2++) { + out[i2] = value / div & 255; + div *= 256; + } + return out; +} +binary.writeUintLE = writeUintLE; +function readFloat32BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var view = new DataView(array.buffer, array.byteOffset, array.byteLength); + return view.getFloat32(offset); +} +binary.readFloat32BE = readFloat32BE; +function readFloat32LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var view = new DataView(array.buffer, array.byteOffset, array.byteLength); + return view.getFloat32(offset, true); +} +binary.readFloat32LE = readFloat32LE; +function readFloat64BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var view = new DataView(array.buffer, array.byteOffset, array.byteLength); + return view.getFloat64(offset); +} +binary.readFloat64BE = readFloat64BE; +function readFloat64LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var view = new DataView(array.buffer, array.byteOffset, array.byteLength); + return view.getFloat64(offset, true); +} +binary.readFloat64LE = readFloat64LE; +function writeFloat32BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(4); + } + if (offset === void 0) { + offset = 0; + } + var view = new DataView(out.buffer, out.byteOffset, out.byteLength); + view.setFloat32(offset, value); + return out; +} +binary.writeFloat32BE = writeFloat32BE; +function writeFloat32LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(4); + } + if (offset === void 0) { + offset = 0; + } + var view = new DataView(out.buffer, out.byteOffset, out.byteLength); + view.setFloat32(offset, value, true); + return out; +} +binary.writeFloat32LE = writeFloat32LE; +function writeFloat64BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(8); + } + if (offset === void 0) { + offset = 0; + } + var view = new DataView(out.buffer, out.byteOffset, out.byteLength); + view.setFloat64(offset, value); + return out; +} +binary.writeFloat64BE = writeFloat64BE; +function writeFloat64LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(8); + } + if (offset === void 0) { + offset = 0; + } + var view = new DataView(out.buffer, out.byteOffset, out.byteLength); + view.setFloat64(offset, value, true); + return out; +} +binary.writeFloat64LE = writeFloat64LE; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.randomStringForEntropy = exports2.randomString = exports2.randomUint32 = exports2.randomBytes = exports2.defaultRandomSource = void 0; + const system_1 = system; + const binary_12 = binary; + const wipe_12 = wipe$1; + exports2.defaultRandomSource = new system_1.SystemRandomSource(); + function randomBytes(length, prng = exports2.defaultRandomSource) { + return prng.randomBytes(length); + } + exports2.randomBytes = randomBytes; + function randomUint32(prng = exports2.defaultRandomSource) { + const buf = randomBytes(4, prng); + const result = (0, binary_12.readUint32LE)(buf); + (0, wipe_12.wipe)(buf); + return result; + } + exports2.randomUint32 = randomUint32; + const ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + function randomString(length, charset = ALPHANUMERIC, prng = exports2.defaultRandomSource) { + if (charset.length < 2) { + throw new Error("randomString charset is too short"); + } + if (charset.length > 256) { + throw new Error("randomString charset is too long"); + } + let out = ""; + const charsLen = charset.length; + const maxByte = 256 - 256 % charsLen; + while (length > 0) { + const buf = randomBytes(Math.ceil(length * 256 / maxByte), prng); + for (let i2 = 0; i2 < buf.length && length > 0; i2++) { + const randomByte = buf[i2]; + if (randomByte < maxByte) { + out += charset.charAt(randomByte % charsLen); + length--; + } + } + (0, wipe_12.wipe)(buf); + } + return out; + } + exports2.randomString = randomString; + function randomStringForEntropy(bits, charset = ALPHANUMERIC, prng = exports2.defaultRandomSource) { + const length = Math.ceil(bits / (Math.log(charset.length) / Math.LN2)); + return randomString(length, charset, prng); + } + exports2.randomStringForEntropy = randomStringForEntropy; +})(random); +var sha512 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var binary_12 = binary; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 64; + exports2.BLOCK_SIZE = 128; + var SHA512 = ( + /** @class */ + function() { + function SHA5122() { + this.digestLength = exports2.DIGEST_LENGTH; + this.blockSize = exports2.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 = false; + this.reset(); + } + SHA5122.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; + }; + SHA5122.prototype.reset = function() { + this._initState(); + this._bufferLength = 0; + this._bytesHashed = 0; + this._finished = false; + return this; + }; + SHA5122.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._tempHi); + wipe_12.wipe(this._tempLo); + this.reset(); + }; + SHA5122.prototype.update = function(data, dataLength) { + if (dataLength === void 0) { + dataLength = data.length; + } + if (this._finished) { + throw new Error("SHA512: can't update because hash was finished."); + } + var dataPos = 0; + this._bytesHashed += dataLength; + if (this._bufferLength > 0) { + while (this._bufferLength < exports2.BLOCK_SIZE && dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + if (this._bufferLength === this.blockSize) { + hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, this.blockSize); + this._bufferLength = 0; + } + } + if (dataLength >= this.blockSize) { + dataPos = hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, data, dataPos, dataLength); + dataLength %= this.blockSize; + } + while (dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + return this; + }; + SHA5122.prototype.finish = function(out) { + if (!this._finished) { + var bytesHashed = this._bytesHashed; + var left = this._bufferLength; + var bitLenHi = bytesHashed / 536870912 | 0; + var bitLenLo = bytesHashed << 3; + var padLength = bytesHashed % 128 < 112 ? 128 : 256; + this._buffer[left] = 128; + for (var i2 = left + 1; i2 < padLength - 8; i2++) { + this._buffer[i2] = 0; + } + binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); + binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); + hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, padLength); + this._finished = true; + } + for (var i2 = 0; i2 < this.digestLength / 8; i2++) { + binary_12.writeUint32BE(this._stateHi[i2], out, i2 * 8); + binary_12.writeUint32BE(this._stateLo[i2], out, i2 * 8 + 4); + } + return this; + }; + SHA5122.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + SHA5122.prototype.saveState = function() { + if (this._finished) { + throw new Error("SHA256: cannot save finished state"); + } + return { + stateHi: new Int32Array(this._stateHi), + stateLo: new Int32Array(this._stateLo), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }; + SHA5122.prototype.restoreState = function(savedState) { + this._stateHi.set(savedState.stateHi); + this._stateLo.set(savedState.stateLo); + this._bufferLength = savedState.bufferLength; + if (savedState.buffer) { + this._buffer.set(savedState.buffer); + } + this._bytesHashed = savedState.bytesHashed; + this._finished = false; + return this; + }; + SHA5122.prototype.cleanSavedState = function(savedState) { + wipe_12.wipe(savedState.stateHi); + wipe_12.wipe(savedState.stateLo); + if (savedState.buffer) { + wipe_12.wipe(savedState.buffer); + } + savedState.bufferLength = 0; + savedState.bytesHashed = 0; + }; + return SHA5122; + }() + ); + exports2.SHA512 = SHA512; + var K3 = 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 hashBlocks(wh, wl, hh2, hl, m3, pos, len) { + var ah0 = hh2[0], ah1 = hh2[1], ah2 = hh2[2], ah3 = hh2[3], ah4 = hh2[4], ah5 = hh2[5], ah6 = hh2[6], ah7 = hh2[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; + var h4, l2; + var th2, tl; + var a3, b3, c2, d5; + while (len >= 128) { + for (var i2 = 0; i2 < 16; i2++) { + var j2 = 8 * i2 + pos; + wh[i2] = binary_12.readUint32BE(m3, j2); + wl[i2] = binary_12.readUint32BE(m3, j2 + 4); + } + for (var i2 = 0; i2 < 80; i2++) { + var bh0 = ah0; + var bh1 = ah1; + var bh2 = ah2; + var bh3 = ah3; + var bh4 = ah4; + var bh5 = ah5; + var bh6 = ah6; + var bh7 = ah7; + var bl0 = al0; + var bl1 = al1; + var bl2 = al2; + var bl3 = al3; + var bl4 = al4; + var bl5 = al5; + var bl6 = al6; + var bl7 = al7; + h4 = ah7; + l2 = al7; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32)); + l2 = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32)); + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + h4 = ah4 & ah5 ^ ~ah4 & ah6; + l2 = al4 & al5 ^ ~al4 & al6; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + h4 = K3[i2 * 2]; + l2 = K3[i2 * 2 + 1]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + h4 = wh[i2 % 16]; + l2 = wl[i2 % 16]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + th2 = c2 & 65535 | d5 << 16; + tl = a3 & 65535 | b3 << 16; + h4 = th2; + l2 = tl; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32)); + l2 = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32)); + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + h4 = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2; + l2 = al0 & al1 ^ al0 & al2 ^ al1 & al2; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + bh7 = c2 & 65535 | d5 << 16; + bl7 = a3 & 65535 | b3 << 16; + h4 = bh3; + l2 = bl3; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = th2; + l2 = tl; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + bh3 = c2 & 65535 | d5 << 16; + bl3 = a3 & 65535 | b3 << 16; + ah1 = bh0; + ah2 = bh1; + ah3 = bh2; + ah4 = bh3; + ah5 = bh4; + ah6 = bh5; + ah7 = bh6; + ah0 = bh7; + al1 = bl0; + al2 = bl1; + al3 = bl2; + al4 = bl3; + al5 = bl4; + al6 = bl5; + al7 = bl6; + al0 = bl7; + if (i2 % 16 === 15) { + for (var j2 = 0; j2 < 16; j2++) { + h4 = wh[j2]; + l2 = wl[j2]; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = wh[(j2 + 9) % 16]; + l2 = wl[(j2 + 9) % 16]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + th2 = wh[(j2 + 1) % 16]; + tl = wl[(j2 + 1) % 16]; + h4 = (th2 >>> 1 | tl << 32 - 1) ^ (th2 >>> 8 | tl << 32 - 8) ^ th2 >>> 7; + l2 = (tl >>> 1 | th2 << 32 - 1) ^ (tl >>> 8 | th2 << 32 - 8) ^ (tl >>> 7 | th2 << 32 - 7); + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + th2 = wh[(j2 + 14) % 16]; + tl = wl[(j2 + 14) % 16]; + h4 = (th2 >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th2 << 32 - (61 - 32)) ^ th2 >>> 6; + l2 = (tl >>> 19 | th2 << 32 - 19) ^ (th2 >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th2 << 32 - 6); + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + wh[j2] = c2 & 65535 | d5 << 16; + wl[j2] = a3 & 65535 | b3 << 16; + } + } + } + h4 = ah0; + l2 = al0; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[0]; + l2 = hl[0]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[0] = ah0 = c2 & 65535 | d5 << 16; + hl[0] = al0 = a3 & 65535 | b3 << 16; + h4 = ah1; + l2 = al1; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[1]; + l2 = hl[1]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[1] = ah1 = c2 & 65535 | d5 << 16; + hl[1] = al1 = a3 & 65535 | b3 << 16; + h4 = ah2; + l2 = al2; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[2]; + l2 = hl[2]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[2] = ah2 = c2 & 65535 | d5 << 16; + hl[2] = al2 = a3 & 65535 | b3 << 16; + h4 = ah3; + l2 = al3; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[3]; + l2 = hl[3]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[3] = ah3 = c2 & 65535 | d5 << 16; + hl[3] = al3 = a3 & 65535 | b3 << 16; + h4 = ah4; + l2 = al4; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[4]; + l2 = hl[4]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[4] = ah4 = c2 & 65535 | d5 << 16; + hl[4] = al4 = a3 & 65535 | b3 << 16; + h4 = ah5; + l2 = al5; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[5]; + l2 = hl[5]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[5] = ah5 = c2 & 65535 | d5 << 16; + hl[5] = al5 = a3 & 65535 | b3 << 16; + h4 = ah6; + l2 = al6; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[6]; + l2 = hl[6]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[6] = ah6 = c2 & 65535 | d5 << 16; + hl[6] = al6 = a3 & 65535 | b3 << 16; + h4 = ah7; + l2 = al7; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[7]; + l2 = hl[7]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[7] = ah7 = c2 & 65535 | d5 << 16; + hl[7] = al7 = a3 & 65535 | b3 << 16; + pos += 128; + len -= 128; + } + return pos; + } + function hash2(data) { + var h4 = new SHA512(); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.hash = hash2; +})(sha512); +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.convertSecretKeyToX25519 = exports2.convertPublicKeyToX25519 = exports2.verify = exports2.sign = exports2.extractPublicKeyFromSecretKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.SEED_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = exports2.SIGNATURE_LENGTH = void 0; + const random_1 = random; + const sha512_1 = sha512; + const wipe_12 = wipe$1; + exports2.SIGNATURE_LENGTH = 64; + exports2.PUBLIC_KEY_LENGTH = 32; + exports2.SECRET_KEY_LENGTH = 64; + exports2.SEED_LENGTH = 32; + function gf2(init) { + const r3 = new Float64Array(16); + if (init) { + for (let i2 = 0; i2 < init.length; i2++) { + r3[i2] = init[i2]; + } + } + return r3; + } + const _9 = new Uint8Array(32); + _9[0] = 9; + const gf0 = gf2(); + const gf1 = gf2([1]); + const D2 = gf2([ + 30883, + 4953, + 19914, + 30187, + 55467, + 16705, + 2637, + 112, + 59544, + 30585, + 16505, + 36039, + 65139, + 11119, + 27886, + 20995 + ]); + const D22 = gf2([ + 61785, + 9906, + 39828, + 60374, + 45398, + 33411, + 5274, + 224, + 53552, + 61171, + 33010, + 6542, + 64743, + 22239, + 55772, + 9222 + ]); + const X2 = gf2([ + 54554, + 36645, + 11616, + 51542, + 42930, + 38181, + 51040, + 26924, + 56412, + 64982, + 57905, + 49316, + 21502, + 52590, + 14035, + 8553 + ]); + const Y2 = gf2([ + 26200, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214 + ]); + const I2 = gf2([ + 41136, + 18958, + 6951, + 50414, + 58488, + 44335, + 6150, + 12099, + 55207, + 15867, + 153, + 11085, + 57099, + 20417, + 9344, + 11139 + ]); + function set25519(r3, a3) { + for (let i2 = 0; i2 < 16; i2++) { + r3[i2] = a3[i2] | 0; + } + } + function car25519(o2) { + let c2 = 1; + for (let i2 = 0; i2 < 16; i2++) { + let v3 = o2[i2] + c2 + 65535; + c2 = Math.floor(v3 / 65536); + o2[i2] = v3 - c2 * 65536; + } + o2[0] += c2 - 1 + 37 * (c2 - 1); + } + function sel25519(p2, q2, b3) { + const c2 = ~(b3 - 1); + for (let i2 = 0; i2 < 16; i2++) { + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; + q2[i2] ^= t2; + } + } + function pack25519(o2, n4) { + const m3 = gf2(); + const t2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + t2[i2] = n4[i2]; + } + car25519(t2); + car25519(t2); + car25519(t2); + for (let j2 = 0; j2 < 2; j2++) { + m3[0] = t2[0] - 65517; + for (let i2 = 1; i2 < 15; i2++) { + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; + } + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); + } + for (let i2 = 0; i2 < 16; i2++) { + o2[2 * i2] = t2[i2] & 255; + o2[2 * i2 + 1] = t2[i2] >> 8; + } + } + function verify32(x2, y3) { + let d5 = 0; + for (let i2 = 0; i2 < 32; i2++) { + d5 |= x2[i2] ^ y3[i2]; + } + return (1 & d5 - 1 >>> 8) - 1; + } + function neq25519(a3, b3) { + const c2 = new Uint8Array(32); + const d5 = new Uint8Array(32); + pack25519(c2, a3); + pack25519(d5, b3); + return verify32(c2, d5); + } + function par25519(a3) { + const d5 = new Uint8Array(32); + pack25519(d5, a3); + return d5[0] & 1; + } + function unpack25519(o2, n4) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); + } + o2[15] &= 32767; + } + function add(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] + b3[i2]; + } + } + function sub(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] - b3[i2]; + } + } + function mul(o2, a3, b3) { + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + v3 = a3[0]; + t0 += v3 * b02; + t1 += v3 * b1; + t2 += v3 * b22; + t3 += v3 * b32; + t4 += v3 * b4; + t5 += v3 * b5; + t6 += v3 * b6; + t7 += v3 * b7; + t8 += v3 * b8; + t9 += v3 * b9; + t10 += v3 * b10; + t11 += v3 * b11; + t12 += v3 * b12; + t13 += v3 * b13; + t14 += v3 * b14; + t15 += v3 * b15; + v3 = a3[1]; + t1 += v3 * b02; + t2 += v3 * b1; + t3 += v3 * b22; + t4 += v3 * b32; + t5 += v3 * b4; + t6 += v3 * b5; + t7 += v3 * b6; + t8 += v3 * b7; + t9 += v3 * b8; + t10 += v3 * b9; + t11 += v3 * b10; + t12 += v3 * b11; + t13 += v3 * b12; + t14 += v3 * b13; + t15 += v3 * b14; + t16 += v3 * b15; + v3 = a3[2]; + t2 += v3 * b02; + t3 += v3 * b1; + t4 += v3 * b22; + t5 += v3 * b32; + t6 += v3 * b4; + t7 += v3 * b5; + t8 += v3 * b6; + t9 += v3 * b7; + t10 += v3 * b8; + t11 += v3 * b9; + t12 += v3 * b10; + t13 += v3 * b11; + t14 += v3 * b12; + t15 += v3 * b13; + t16 += v3 * b14; + t17 += v3 * b15; + v3 = a3[3]; + t3 += v3 * b02; + t4 += v3 * b1; + t5 += v3 * b22; + t6 += v3 * b32; + t7 += v3 * b4; + t8 += v3 * b5; + t9 += v3 * b6; + t10 += v3 * b7; + t11 += v3 * b8; + t12 += v3 * b9; + t13 += v3 * b10; + t14 += v3 * b11; + t15 += v3 * b12; + t16 += v3 * b13; + t17 += v3 * b14; + t18 += v3 * b15; + v3 = a3[4]; + t4 += v3 * b02; + t5 += v3 * b1; + t6 += v3 * b22; + t7 += v3 * b32; + t8 += v3 * b4; + t9 += v3 * b5; + t10 += v3 * b6; + t11 += v3 * b7; + t12 += v3 * b8; + t13 += v3 * b9; + t14 += v3 * b10; + t15 += v3 * b11; + t16 += v3 * b12; + t17 += v3 * b13; + t18 += v3 * b14; + t19 += v3 * b15; + v3 = a3[5]; + t5 += v3 * b02; + t6 += v3 * b1; + t7 += v3 * b22; + t8 += v3 * b32; + t9 += v3 * b4; + t10 += v3 * b5; + t11 += v3 * b6; + t12 += v3 * b7; + t13 += v3 * b8; + t14 += v3 * b9; + t15 += v3 * b10; + t16 += v3 * b11; + t17 += v3 * b12; + t18 += v3 * b13; + t19 += v3 * b14; + t20 += v3 * b15; + v3 = a3[6]; + t6 += v3 * b02; + t7 += v3 * b1; + t8 += v3 * b22; + t9 += v3 * b32; + t10 += v3 * b4; + t11 += v3 * b5; + t12 += v3 * b6; + t13 += v3 * b7; + t14 += v3 * b8; + t15 += v3 * b9; + t16 += v3 * b10; + t17 += v3 * b11; + t18 += v3 * b12; + t19 += v3 * b13; + t20 += v3 * b14; + t21 += v3 * b15; + v3 = a3[7]; + t7 += v3 * b02; + t8 += v3 * b1; + t9 += v3 * b22; + t10 += v3 * b32; + t11 += v3 * b4; + t12 += v3 * b5; + t13 += v3 * b6; + t14 += v3 * b7; + t15 += v3 * b8; + t16 += v3 * b9; + t17 += v3 * b10; + t18 += v3 * b11; + t19 += v3 * b12; + t20 += v3 * b13; + t21 += v3 * b14; + t22 += v3 * b15; + v3 = a3[8]; + t8 += v3 * b02; + t9 += v3 * b1; + t10 += v3 * b22; + t11 += v3 * b32; + t12 += v3 * b4; + t13 += v3 * b5; + t14 += v3 * b6; + t15 += v3 * b7; + t16 += v3 * b8; + t17 += v3 * b9; + t18 += v3 * b10; + t19 += v3 * b11; + t20 += v3 * b12; + t21 += v3 * b13; + t22 += v3 * b14; + t23 += v3 * b15; + v3 = a3[9]; + t9 += v3 * b02; + t10 += v3 * b1; + t11 += v3 * b22; + t12 += v3 * b32; + t13 += v3 * b4; + t14 += v3 * b5; + t15 += v3 * b6; + t16 += v3 * b7; + t17 += v3 * b8; + t18 += v3 * b9; + t19 += v3 * b10; + t20 += v3 * b11; + t21 += v3 * b12; + t22 += v3 * b13; + t23 += v3 * b14; + t24 += v3 * b15; + v3 = a3[10]; + t10 += v3 * b02; + t11 += v3 * b1; + t12 += v3 * b22; + t13 += v3 * b32; + t14 += v3 * b4; + t15 += v3 * b5; + t16 += v3 * b6; + t17 += v3 * b7; + t18 += v3 * b8; + t19 += v3 * b9; + t20 += v3 * b10; + t21 += v3 * b11; + t22 += v3 * b12; + t23 += v3 * b13; + t24 += v3 * b14; + t25 += v3 * b15; + v3 = a3[11]; + t11 += v3 * b02; + t12 += v3 * b1; + t13 += v3 * b22; + t14 += v3 * b32; + t15 += v3 * b4; + t16 += v3 * b5; + t17 += v3 * b6; + t18 += v3 * b7; + t19 += v3 * b8; + t20 += v3 * b9; + t21 += v3 * b10; + t22 += v3 * b11; + t23 += v3 * b12; + t24 += v3 * b13; + t25 += v3 * b14; + t26 += v3 * b15; + v3 = a3[12]; + t12 += v3 * b02; + t13 += v3 * b1; + t14 += v3 * b22; + t15 += v3 * b32; + t16 += v3 * b4; + t17 += v3 * b5; + t18 += v3 * b6; + t19 += v3 * b7; + t20 += v3 * b8; + t21 += v3 * b9; + t22 += v3 * b10; + t23 += v3 * b11; + t24 += v3 * b12; + t25 += v3 * b13; + t26 += v3 * b14; + t27 += v3 * b15; + v3 = a3[13]; + t13 += v3 * b02; + t14 += v3 * b1; + t15 += v3 * b22; + t16 += v3 * b32; + t17 += v3 * b4; + t18 += v3 * b5; + t19 += v3 * b6; + t20 += v3 * b7; + t21 += v3 * b8; + t22 += v3 * b9; + t23 += v3 * b10; + t24 += v3 * b11; + t25 += v3 * b12; + t26 += v3 * b13; + t27 += v3 * b14; + t28 += v3 * b15; + v3 = a3[14]; + t14 += v3 * b02; + t15 += v3 * b1; + t16 += v3 * b22; + t17 += v3 * b32; + t18 += v3 * b4; + t19 += v3 * b5; + t20 += v3 * b6; + t21 += v3 * b7; + t22 += v3 * b8; + t23 += v3 * b9; + t24 += v3 * b10; + t25 += v3 * b11; + t26 += v3 * b12; + t27 += v3 * b13; + t28 += v3 * b14; + t29 += v3 * b15; + v3 = a3[15]; + t15 += v3 * b02; + t16 += v3 * b1; + t17 += v3 * b22; + t18 += v3 * b32; + t19 += v3 * b4; + t20 += v3 * b5; + t21 += v3 * b6; + t22 += v3 * b7; + t23 += v3 * b8; + t24 += v3 * b9; + t25 += v3 * b10; + t26 += v3 * b11; + t27 += v3 * b12; + t28 += v3 * b13; + t29 += v3 * b14; + t30 += v3 * b15; + t0 += 38 * t16; + t1 += 38 * t17; + t2 += 38 * t18; + t3 += 38 * t19; + t4 += 38 * t20; + t5 += 38 * t21; + t6 += 38 * t22; + t7 += 38 * t23; + t8 += 38 * t24; + t9 += 38 * t25; + t10 += 38 * t26; + t11 += 38 * t27; + t12 += 38 * t28; + t13 += 38 * t29; + t14 += 38 * t30; + c2 = 1; + v3 = t0 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t0 = v3 - c2 * 65536; + v3 = t1 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t1 = v3 - c2 * 65536; + v3 = t2 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t2 = v3 - c2 * 65536; + v3 = t3 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t3 = v3 - c2 * 65536; + v3 = t4 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t4 = v3 - c2 * 65536; + v3 = t5 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t5 = v3 - c2 * 65536; + v3 = t6 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t6 = v3 - c2 * 65536; + v3 = t7 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t7 = v3 - c2 * 65536; + v3 = t8 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t8 = v3 - c2 * 65536; + v3 = t9 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t9 = v3 - c2 * 65536; + v3 = t10 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t10 = v3 - c2 * 65536; + v3 = t11 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t11 = v3 - c2 * 65536; + v3 = t12 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t12 = v3 - c2 * 65536; + v3 = t13 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t13 = v3 - c2 * 65536; + v3 = t14 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t14 = v3 - c2 * 65536; + v3 = t15 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t15 = v3 - c2 * 65536; + t0 += c2 - 1 + 37 * (c2 - 1); + c2 = 1; + v3 = t0 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t0 = v3 - c2 * 65536; + v3 = t1 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t1 = v3 - c2 * 65536; + v3 = t2 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t2 = v3 - c2 * 65536; + v3 = t3 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t3 = v3 - c2 * 65536; + v3 = t4 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t4 = v3 - c2 * 65536; + v3 = t5 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t5 = v3 - c2 * 65536; + v3 = t6 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t6 = v3 - c2 * 65536; + v3 = t7 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t7 = v3 - c2 * 65536; + v3 = t8 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t8 = v3 - c2 * 65536; + v3 = t9 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t9 = v3 - c2 * 65536; + v3 = t10 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t10 = v3 - c2 * 65536; + v3 = t11 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t11 = v3 - c2 * 65536; + v3 = t12 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t12 = v3 - c2 * 65536; + v3 = t13 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t13 = v3 - c2 * 65536; + v3 = t14 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t14 = v3 - c2 * 65536; + v3 = t15 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t15 = v3 - c2 * 65536; + t0 += c2 - 1 + 37 * (c2 - 1); + o2[0] = t0; + o2[1] = t1; + o2[2] = t2; + o2[3] = t3; + o2[4] = t4; + o2[5] = t5; + o2[6] = t6; + o2[7] = t7; + o2[8] = t8; + o2[9] = t9; + o2[10] = t10; + o2[11] = t11; + o2[12] = t12; + o2[13] = t13; + o2[14] = t14; + o2[15] = t15; + } + function square(o2, a3) { + mul(o2, a3, a3); + } + function inv25519(o2, i2) { + const c2 = gf2(); + let a3; + for (a3 = 0; a3 < 16; a3++) { + c2[a3] = i2[a3]; + } + for (a3 = 253; a3 >= 0; a3--) { + square(c2, c2); + if (a3 !== 2 && a3 !== 4) { + mul(c2, c2, i2); + } + } + for (a3 = 0; a3 < 16; a3++) { + o2[a3] = c2[a3]; + } + } + function pow2523(o2, i2) { + const c2 = gf2(); + let a3; + for (a3 = 0; a3 < 16; a3++) { + c2[a3] = i2[a3]; + } + for (a3 = 250; a3 >= 0; a3--) { + square(c2, c2); + if (a3 !== 1) { + mul(c2, c2, i2); + } + } + for (a3 = 0; a3 < 16; a3++) { + o2[a3] = c2[a3]; + } + } + function edadd(p2, q2) { + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(), g3 = gf2(), h4 = gf2(), t2 = gf2(); + sub(a3, p2[1], p2[0]); + sub(t2, q2[1], q2[0]); + mul(a3, a3, t2); + add(b3, p2[0], p2[1]); + add(t2, q2[0], q2[1]); + mul(b3, b3, t2); + mul(c2, p2[3], q2[3]); + mul(c2, c2, D22); + mul(d5, p2[2], q2[2]); + add(d5, d5, d5); + sub(e2, b3, a3); + sub(f3, d5, c2); + add(g3, d5, c2); + add(h4, b3, a3); + mul(p2[0], e2, f3); + mul(p2[1], h4, g3); + mul(p2[2], g3, f3); + mul(p2[3], e2, h4); + } + function cswap(p2, q2, b3) { + for (let i2 = 0; i2 < 4; i2++) { + sel25519(p2[i2], q2[i2], b3); + } + } + function pack(r3, p2) { + const tx = gf2(), ty = gf2(), zi2 = gf2(); + inv25519(zi2, p2[2]); + mul(tx, p2[0], zi2); + mul(ty, p2[1], zi2); + pack25519(r3, ty); + r3[31] ^= par25519(tx) << 7; + } + function scalarmult(p2, q2, s2) { + set25519(p2[0], gf0); + set25519(p2[1], gf1); + set25519(p2[2], gf1); + set25519(p2[3], gf0); + for (let i2 = 255; i2 >= 0; --i2) { + const b3 = s2[i2 / 8 | 0] >> (i2 & 7) & 1; + cswap(p2, q2, b3); + edadd(q2, p2); + edadd(p2, p2); + cswap(p2, q2, b3); + } + } + function scalarbase(p2, s2) { + const q2 = [gf2(), gf2(), gf2(), gf2()]; + set25519(q2[0], X2); + set25519(q2[1], Y2); + set25519(q2[2], gf1); + mul(q2[3], X2, Y2); + scalarmult(p2, q2, s2); + } + function generateKeyPairFromSeed(seed) { + if (seed.length !== exports2.SEED_LENGTH) { + throw new Error(`ed25519: seed must be ${exports2.SEED_LENGTH} bytes`); + } + const d5 = (0, sha512_1.hash)(seed); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const publicKey = new Uint8Array(32); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + scalarbase(p2, d5); + pack(publicKey, p2); + const secretKey = new Uint8Array(64); + secretKey.set(seed); + secretKey.set(publicKey, 32); + return { + publicKey, + secretKey + }; + } + exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; + function generateKeyPair2(prng) { + const seed = (0, random_1.randomBytes)(32, prng); + const result = generateKeyPairFromSeed(seed); + (0, wipe_12.wipe)(seed); + return result; + } + exports2.generateKeyPair = generateKeyPair2; + function extractPublicKeyFromSecretKey(secretKey) { + if (secretKey.length !== exports2.SECRET_KEY_LENGTH) { + throw new Error(`ed25519: secret key must be ${exports2.SECRET_KEY_LENGTH} bytes`); + } + return new Uint8Array(secretKey.subarray(32)); + } + exports2.extractPublicKeyFromSecretKey = extractPublicKeyFromSecretKey; + const L4 = 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 modL(r3, x2) { + let carry; + let i2; + let j2; + let k2; + for (i2 = 63; i2 >= 32; --i2) { + carry = 0; + for (j2 = i2 - 32, k2 = i2 - 12; j2 < k2; ++j2) { + x2[j2] += carry - 16 * x2[i2] * L4[j2 - (i2 - 32)]; + carry = Math.floor((x2[j2] + 128) / 256); + x2[j2] -= carry * 256; + } + x2[j2] += carry; + x2[i2] = 0; + } + carry = 0; + for (j2 = 0; j2 < 32; j2++) { + x2[j2] += carry - (x2[31] >> 4) * L4[j2]; + carry = x2[j2] >> 8; + x2[j2] &= 255; + } + for (j2 = 0; j2 < 32; j2++) { + x2[j2] -= carry * L4[j2]; + } + for (i2 = 0; i2 < 32; i2++) { + x2[i2 + 1] += x2[i2] >> 8; + r3[i2] = x2[i2] & 255; + } + } + function reduce(r3) { + const x2 = new Float64Array(64); + for (let i2 = 0; i2 < 64; i2++) { + x2[i2] = r3[i2]; + } + for (let i2 = 0; i2 < 64; i2++) { + r3[i2] = 0; + } + modL(r3, x2); + } + function sign(secretKey, message) { + const x2 = new Float64Array(64); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const signature = new Uint8Array(64); + signature.set(d5.subarray(32), 32); + const hs2 = new sha512_1.SHA512(); + hs2.update(signature.subarray(32)); + hs2.update(message); + const r3 = hs2.digest(); + hs2.clean(); + reduce(r3); + scalarbase(p2, r3); + pack(signature, p2); + hs2.reset(); + hs2.update(signature.subarray(0, 32)); + hs2.update(secretKey.subarray(32)); + hs2.update(message); + const h4 = hs2.digest(); + reduce(h4); + for (let i2 = 0; i2 < 32; i2++) { + x2[i2] = r3[i2]; + } + for (let i2 = 0; i2 < 32; i2++) { + for (let j2 = 0; j2 < 32; j2++) { + x2[i2 + j2] += h4[i2] * d5[j2]; + } + } + modL(signature.subarray(32), x2); + return signature; + } + exports2.sign = sign; + function unpackneg(r3, p2) { + const t2 = gf2(), chk = gf2(), num = gf2(), den = gf2(), den2 = gf2(), den4 = gf2(), den6 = gf2(); + set25519(r3[2], gf1); + unpack25519(r3[1], p2); + square(num, r3[1]); + mul(den, num, D2); + sub(num, num, r3[2]); + add(den, r3[2], den); + square(den2, den); + square(den4, den2); + mul(den6, den4, den2); + mul(t2, den6, num); + mul(t2, t2, den); + pow2523(t2, t2); + mul(t2, t2, num); + mul(t2, t2, den); + mul(t2, t2, den); + mul(r3[0], t2, den); + square(chk, r3[0]); + mul(chk, chk, den); + if (neq25519(chk, num)) { + mul(r3[0], r3[0], I2); + } + square(chk, r3[0]); + mul(chk, chk, den); + if (neq25519(chk, num)) { + return -1; + } + if (par25519(r3[0]) === p2[31] >> 7) { + sub(r3[0], gf0, r3[0]); + } + mul(r3[3], r3[0], r3[1]); + return 0; + } + function verify(publicKey, message, signature) { + const t2 = new Uint8Array(32); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const q2 = [gf2(), gf2(), gf2(), gf2()]; + if (signature.length !== exports2.SIGNATURE_LENGTH) { + throw new Error(`ed25519: signature must be ${exports2.SIGNATURE_LENGTH} bytes`); + } + if (unpackneg(q2, publicKey)) { + return false; + } + const hs2 = new sha512_1.SHA512(); + hs2.update(signature.subarray(0, 32)); + hs2.update(publicKey); + hs2.update(message); + const h4 = hs2.digest(); + reduce(h4); + scalarmult(p2, q2, h4); + scalarbase(q2, signature.subarray(32)); + edadd(p2, q2); + pack(t2, p2); + if (verify32(signature, t2)) { + return false; + } + return true; + } + exports2.verify = verify; + function convertPublicKeyToX25519(publicKey) { + let q2 = [gf2(), gf2(), gf2(), gf2()]; + if (unpackneg(q2, publicKey)) { + throw new Error("Ed25519: invalid public key"); + } + let a3 = gf2(); + let b3 = gf2(); + let y3 = q2[1]; + add(a3, gf1, y3); + sub(b3, gf1, y3); + inv25519(b3, b3); + mul(a3, a3, b3); + let z2 = new Uint8Array(32); + pack25519(z2, a3); + return z2; + } + exports2.convertPublicKeyToX25519 = convertPublicKeyToX25519; + function convertSecretKeyToX25519(secretKey) { + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const o2 = new Uint8Array(d5.subarray(0, 32)); + (0, wipe_12.wipe)(d5); + return o2; + } + exports2.convertSecretKeyToX25519 = convertSecretKeyToX25519; +})(ed25519); +const JWT_IRIDIUM_ALG = "EdDSA"; +const JWT_IRIDIUM_TYP = "JWT"; +const JWT_DELIMITER = "."; +const JWT_ENCODING = "base64url"; +const JSON_ENCODING = "utf8"; +const DATA_ENCODING = "utf8"; +const DID_DELIMITER = ":"; +const DID_PREFIX = "did"; +const DID_METHOD = "key"; +const MULTICODEC_ED25519_ENCODING = "base58btc"; +const MULTICODEC_ED25519_BASE = "z"; +const MULTICODEC_ED25519_HEADER = "K36"; +const KEY_PAIR_SEED_LENGTH = 32; +function asUint8Array(buf) { + if (globalThis.Buffer != null) { + return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength); + } + return buf; +} +function allocUnsafe(size = 0) { + if (globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null) { + return asUint8Array(globalThis.Buffer.allocUnsafe(size)); + } + return new Uint8Array(size); +} +function concat(arrays, length) { + if (!length) { + length = arrays.reduce((acc, curr) => acc + curr.length, 0); + } + const output = allocUnsafe(length); + let offset = 0; + for (const arr of arrays) { + output.set(arr, offset); + offset += arr.length; + } + return asUint8Array(output); +} +function base(ALPHABET, name2) { + if (ALPHABET.length >= 255) { + throw new TypeError("Alphabet too long"); + } + var BASE_MAP = new Uint8Array(256); + for (var j2 = 0; j2 < BASE_MAP.length; j2++) { + BASE_MAP[j2] = 255; + } + for (var i2 = 0; i2 < ALPHABET.length; i2++) { + var x2 = ALPHABET.charAt(i2); + var xc = x2.charCodeAt(0); + if (BASE_MAP[xc] !== 255) { + throw new TypeError(x2 + " is ambiguous"); + } + BASE_MAP[xc] = i2; + } + var BASE = ALPHABET.length; + var LEADER = ALPHABET.charAt(0); + var FACTOR = Math.log(BASE) / Math.log(256); + var iFACTOR = Math.log(256) / Math.log(BASE); + function encode2(source) { + if (source instanceof Uint8Array) + ; + else if (ArrayBuffer.isView(source)) { + source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength); + } else if (Array.isArray(source)) { + source = Uint8Array.from(source); + } + if (!(source instanceof Uint8Array)) { + throw new TypeError("Expected Uint8Array"); + } + if (source.length === 0) { + return ""; + } + var zeroes = 0; + var length = 0; + var pbegin = 0; + var pend = source.length; + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++; + zeroes++; + } + var size = (pend - pbegin) * iFACTOR + 1 >>> 0; + var b58 = new Uint8Array(size); + while (pbegin !== pend) { + var carry = source[pbegin]; + var i3 = 0; + for (var it1 = size - 1; (carry !== 0 || i3 < length) && it1 !== -1; it1--, i3++) { + carry += 256 * b58[it1] >>> 0; + b58[it1] = carry % BASE >>> 0; + carry = carry / BASE >>> 0; + } + if (carry !== 0) { + throw new Error("Non-zero carry"); + } + length = i3; + pbegin++; + } + var it2 = size - length; + while (it2 !== size && b58[it2] === 0) { + it2++; + } + var str = LEADER.repeat(zeroes); + for (; it2 < size; ++it2) { + str += ALPHABET.charAt(b58[it2]); + } + return str; + } + function decodeUnsafe(source) { + if (typeof source !== "string") { + throw new TypeError("Expected String"); + } + if (source.length === 0) { + return new Uint8Array(); + } + var psz = 0; + if (source[psz] === " ") { + return; + } + var zeroes = 0; + var length = 0; + while (source[psz] === LEADER) { + zeroes++; + psz++; + } + var size = (source.length - psz) * FACTOR + 1 >>> 0; + var b256 = new Uint8Array(size); + while (source[psz]) { + var carry = BASE_MAP[source.charCodeAt(psz)]; + if (carry === 255) { + return; + } + var i3 = 0; + for (var it3 = size - 1; (carry !== 0 || i3 < length) && it3 !== -1; it3--, i3++) { + carry += BASE * b256[it3] >>> 0; + b256[it3] = carry % 256 >>> 0; + carry = carry / 256 >>> 0; + } + if (carry !== 0) { + throw new Error("Non-zero carry"); + } + length = i3; + psz++; + } + if (source[psz] === " ") { + return; + } + var it4 = size - length; + while (it4 !== size && b256[it4] === 0) { + it4++; + } + var vch = new Uint8Array(zeroes + (size - it4)); + var j3 = zeroes; + while (it4 !== size) { + vch[j3++] = b256[it4++]; + } + return vch; + } + function decode2(string2) { + var buffer = decodeUnsafe(string2); + if (buffer) { + return buffer; + } + throw new Error(`Non-${name2} character`); + } + return { + encode: encode2, + decodeUnsafe, + decode: decode2 + }; +} +var src = base; +var _brrp__multiformats_scope_baseX = src; +const coerce$1 = (o2) => { + if (o2 instanceof Uint8Array && o2.constructor.name === "Uint8Array") + return o2; + if (o2 instanceof ArrayBuffer) + return new Uint8Array(o2); + if (ArrayBuffer.isView(o2)) { + return new Uint8Array(o2.buffer, o2.byteOffset, o2.byteLength); + } + throw new Error("Unknown type, must be binary type"); +}; +const fromString$1 = (str) => new TextEncoder().encode(str); +const toString$1 = (b3) => new TextDecoder().decode(b3); +class Encoder { + constructor(name2, prefix, baseEncode) { + this.name = name2; + this.prefix = prefix; + this.baseEncode = baseEncode; + } + encode(bytes) { + if (bytes instanceof Uint8Array) { + return `${this.prefix}${this.baseEncode(bytes)}`; + } else { + throw Error("Unknown type, must be binary type"); + } + } +} +class Decoder { + constructor(name2, prefix, baseDecode) { + this.name = name2; + this.prefix = prefix; + if (prefix.codePointAt(0) === void 0) { + throw new Error("Invalid prefix character"); + } + this.prefixCodePoint = prefix.codePointAt(0); + this.baseDecode = baseDecode; + } + decode(text) { + if (typeof text === "string") { + if (text.codePointAt(0) !== this.prefixCodePoint) { + throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); + } + return this.baseDecode(text.slice(this.prefix.length)); + } else { + throw Error("Can only multibase decode strings"); + } + } + or(decoder) { + return or$3(this, decoder); + } +} +class ComposedDecoder { + constructor(decoders) { + this.decoders = decoders; + } + or(decoder) { + return or$3(this, decoder); + } + decode(input) { + const prefix = input[0]; + const decoder = this.decoders[prefix]; + if (decoder) { + return decoder.decode(input); + } else { + throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + } + } +} +const or$3 = (left, right) => new ComposedDecoder({ + ...left.decoders || { [left.prefix]: left }, + ...right.decoders || { [right.prefix]: right } +}); +class Codec { + constructor(name2, prefix, baseEncode, baseDecode) { + this.name = name2; + this.prefix = prefix; + this.baseEncode = baseEncode; + this.baseDecode = baseDecode; + this.encoder = new Encoder(name2, prefix, baseEncode); + this.decoder = new Decoder(name2, prefix, baseDecode); + } + encode(input) { + return this.encoder.encode(input); + } + decode(input) { + return this.decoder.decode(input); + } +} +const from = ({ name: name2, prefix, encode: encode2, decode: decode2 }) => new Codec(name2, prefix, encode2, decode2); +const baseX = ({ prefix, name: name2, alphabet: alphabet2 }) => { + const { encode: encode2, decode: decode2 } = _brrp__multiformats_scope_baseX(alphabet2, name2); + return from({ + prefix, + name: name2, + encode: encode2, + decode: (text) => coerce$1(decode2(text)) + }); +}; +const decode$2 = (string2, alphabet2, bitsPerChar, name2) => { + const codes = {}; + for (let i2 = 0; i2 < alphabet2.length; ++i2) { + codes[alphabet2[i2]] = i2; + } + let end = string2.length; + while (string2[end - 1] === "=") { + --end; + } + const out = new Uint8Array(end * bitsPerChar / 8 | 0); + let bits = 0; + let buffer = 0; + let written = 0; + for (let i2 = 0; i2 < end; ++i2) { + const value = codes[string2[i2]]; + if (value === void 0) { + throw new SyntaxError(`Non-${name2} character`); + } + buffer = buffer << bitsPerChar | value; + bits += bitsPerChar; + if (bits >= 8) { + bits -= 8; + out[written++] = 255 & buffer >> bits; + } + } + if (bits >= bitsPerChar || 255 & buffer << 8 - bits) { + throw new SyntaxError("Unexpected end of data"); + } + return out; +}; +const encode$1 = (data, alphabet2, bitsPerChar) => { + const pad = alphabet2[alphabet2.length - 1] === "="; + const mask = (1 << bitsPerChar) - 1; + let out = ""; + let bits = 0; + let buffer = 0; + for (let i2 = 0; i2 < data.length; ++i2) { + buffer = buffer << 8 | data[i2]; + bits += 8; + while (bits > bitsPerChar) { + bits -= bitsPerChar; + out += alphabet2[mask & buffer >> bits]; + } + } + if (bits) { + out += alphabet2[mask & buffer << bitsPerChar - bits]; + } + if (pad) { + while (out.length * bitsPerChar & 7) { + out += "="; + } + } + return out; +}; +const rfc4648 = ({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) => { + return from({ + prefix, + name: name2, + encode(input) { + return encode$1(input, alphabet2, bitsPerChar); + }, + decode(input) { + return decode$2(input, alphabet2, bitsPerChar, name2); + } + }); +}; +const identity = from({ + prefix: "\0", + name: "identity", + encode: (buf) => toString$1(buf), + decode: (str) => fromString$1(str) +}); +const identityBase = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + identity +}, Symbol.toStringTag, { value: "Module" })); +const base2 = rfc4648({ + prefix: "0", + name: "base2", + alphabet: "01", + bitsPerChar: 1 +}); +const base2$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base2 +}, Symbol.toStringTag, { value: "Module" })); +const base8 = rfc4648({ + prefix: "7", + name: "base8", + alphabet: "01234567", + bitsPerChar: 3 +}); +const base8$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base8 +}, Symbol.toStringTag, { value: "Module" })); +const base10 = baseX({ + prefix: "9", + name: "base10", + alphabet: "0123456789" +}); +const base10$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base10 +}, Symbol.toStringTag, { value: "Module" })); +const base16 = rfc4648({ + prefix: "f", + name: "base16", + alphabet: "0123456789abcdef", + bitsPerChar: 4 +}); +const base16upper = rfc4648({ + prefix: "F", + name: "base16upper", + alphabet: "0123456789ABCDEF", + bitsPerChar: 4 +}); +const base16$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base16, + base16upper +}, Symbol.toStringTag, { value: "Module" })); +const base32 = rfc4648({ + prefix: "b", + name: "base32", + alphabet: "abcdefghijklmnopqrstuvwxyz234567", + bitsPerChar: 5 +}); +const base32upper = rfc4648({ + prefix: "B", + name: "base32upper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", + bitsPerChar: 5 +}); +const base32pad = rfc4648({ + prefix: "c", + name: "base32pad", + alphabet: "abcdefghijklmnopqrstuvwxyz234567=", + bitsPerChar: 5 +}); +const base32padupper = rfc4648({ + prefix: "C", + name: "base32padupper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", + bitsPerChar: 5 +}); +const base32hex = rfc4648({ + prefix: "v", + name: "base32hex", + alphabet: "0123456789abcdefghijklmnopqrstuv", + bitsPerChar: 5 +}); +const base32hexupper = rfc4648({ + prefix: "V", + name: "base32hexupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", + bitsPerChar: 5 +}); +const base32hexpad = rfc4648({ + prefix: "t", + name: "base32hexpad", + alphabet: "0123456789abcdefghijklmnopqrstuv=", + bitsPerChar: 5 +}); +const base32hexpadupper = rfc4648({ + prefix: "T", + name: "base32hexpadupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", + bitsPerChar: 5 +}); +const base32z = rfc4648({ + prefix: "h", + name: "base32z", + alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", + bitsPerChar: 5 +}); +const base32$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base32, + base32hex, + base32hexpad, + base32hexpadupper, + base32hexupper, + base32pad, + base32padupper, + base32upper, + base32z +}, Symbol.toStringTag, { value: "Module" })); +const base36 = baseX({ + prefix: "k", + name: "base36", + alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" +}); +const base36upper = baseX({ + prefix: "K", + name: "base36upper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" +}); +const base36$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base36, + base36upper +}, Symbol.toStringTag, { value: "Module" })); +const base58btc = baseX({ + name: "base58btc", + prefix: "z", + alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" +}); +const base58flickr = baseX({ + name: "base58flickr", + prefix: "Z", + alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" +}); +const base58 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base58btc, + base58flickr +}, Symbol.toStringTag, { value: "Module" })); +const base64 = rfc4648({ + prefix: "m", + name: "base64", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + bitsPerChar: 6 +}); +const base64pad = rfc4648({ + prefix: "M", + name: "base64pad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + bitsPerChar: 6 +}); +const base64url = rfc4648({ + prefix: "u", + name: "base64url", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", + bitsPerChar: 6 +}); +const base64urlpad = rfc4648({ + prefix: "U", + name: "base64urlpad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", + bitsPerChar: 6 +}); +const base64$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base64, + base64pad, + base64url, + base64urlpad +}, Symbol.toStringTag, { value: "Module" })); +const alphabet = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"); +const alphabetBytesToChars = alphabet.reduce((p2, c2, i2) => { + p2[i2] = c2; + return p2; +}, []); +const alphabetCharsToBytes = alphabet.reduce((p2, c2, i2) => { + p2[c2.codePointAt(0)] = i2; + return p2; +}, []); +function encode(data) { + return data.reduce((p2, c2) => { + p2 += alphabetBytesToChars[c2]; + return p2; + }, ""); +} +function decode$1(str) { + const byts = []; + for (const char of str) { + const byt = alphabetCharsToBytes[char.codePointAt(0)]; + if (byt === void 0) { + throw new Error(`Non-base256emoji character: ${char}`); + } + byts.push(byt); + } + return new Uint8Array(byts); +} +const base256emoji = from({ + prefix: "🚀", + name: "base256emoji", + encode, + decode: decode$1 +}); +const base256emoji$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base256emoji +}, Symbol.toStringTag, { value: "Module" })); +new TextEncoder(); +new TextDecoder(); +const bases = { + ...identityBase, + ...base2$1, + ...base8$1, + ...base10$1, + ...base16$1, + ...base32$1, + ...base36$1, + ...base58, + ...base64$1, + ...base256emoji$1 +}; +function createCodec(name2, prefix, encode2, decode2) { + return { + name: name2, + prefix, + encoder: { + name: name2, + prefix, + encode: encode2 + }, + decoder: { decode: decode2 } + }; +} +const string = createCodec("utf8", "u", (buf) => { + const decoder = new TextDecoder("utf8"); + return "u" + decoder.decode(buf); +}, (str) => { + const encoder = new TextEncoder(); + return encoder.encode(str.substring(1)); +}); +const ascii = createCodec("ascii", "a", (buf) => { + let string2 = "a"; + for (let i2 = 0; i2 < buf.length; i2++) { + string2 += String.fromCharCode(buf[i2]); + } + return string2; +}, (str) => { + str = str.substring(1); + const buf = allocUnsafe(str.length); + for (let i2 = 0; i2 < str.length; i2++) { + buf[i2] = str.charCodeAt(i2); + } + return buf; +}); +const BASES = { + utf8: string, + "utf-8": string, + hex: bases.base16, + latin1: ascii, + ascii, + binary: ascii, + ...bases +}; +function toString(array, encoding = "utf8") { + const base3 = BASES[encoding]; + if (!base3) { + throw new Error(`Unsupported encoding "${encoding}"`); + } + if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { + return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString("utf8"); + } + return base3.encoder.encode(array).substring(1); +} +function fromString(string2, encoding = "utf8") { + const base3 = BASES[encoding]; + if (!base3) { + throw new Error(`Unsupported encoding "${encoding}"`); + } + if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { + return asUint8Array(globalThis.Buffer.from(string2, "utf-8")); + } + return base3.decoder.decode(`${base3.prefix}${string2}`); +} +function encodeJSON(val) { + return toString(fromString(safeJsonStringify(val), JSON_ENCODING), JWT_ENCODING); +} +function encodeIss(publicKey) { + const header = fromString(MULTICODEC_ED25519_HEADER, MULTICODEC_ED25519_ENCODING); + const multicodec = MULTICODEC_ED25519_BASE + toString(concat([header, publicKey]), MULTICODEC_ED25519_ENCODING); + return [DID_PREFIX, DID_METHOD, multicodec].join(DID_DELIMITER); +} +function encodeSig(bytes) { + return toString(bytes, JWT_ENCODING); +} +function encodeData(params) { + return fromString([encodeJSON(params.header), encodeJSON(params.payload)].join(JWT_DELIMITER), DATA_ENCODING); +} +function encodeJWT(params) { + return [ + encodeJSON(params.header), + encodeJSON(params.payload), + encodeSig(params.signature) + ].join(JWT_DELIMITER); +} +function generateKeyPair(seed = random.randomBytes(KEY_PAIR_SEED_LENGTH)) { + return ed25519.generateKeyPairFromSeed(seed); +} +async function signJWT(sub, aud, ttl, keyPair, iat = cjs$3.fromMiliseconds(Date.now())) { + const header = { alg: JWT_IRIDIUM_ALG, typ: JWT_IRIDIUM_TYP }; + const iss = encodeIss(keyPair.publicKey); + const exp = iat + ttl; + const payload = { iss, sub, aud, iat, exp }; + const data = encodeData({ header, payload }); + const signature = ed25519.sign(keyPair.secretKey, data); + return encodeJWT({ header, payload, signature }); +} +var __spreadArray = function(to2, from2, pack) { + if (pack || arguments.length === 2) + for (var i2 = 0, l2 = from2.length, ar3; i2 < l2; i2++) { + if (ar3 || !(i2 in from2)) { + if (!ar3) + ar3 = Array.prototype.slice.call(from2, 0, i2); + ar3[i2] = from2[i2]; + } + } + return to2.concat(ar3 || Array.prototype.slice.call(from2)); +}; +var BrowserInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BrowserInfo2(name2, version2, os2) { + this.name = name2; + this.version = version2; + this.os = os2; + this.type = "browser"; + } + return BrowserInfo2; + }() +); +var NodeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function NodeInfo2(version2) { + this.version = version2; + this.type = "node"; + this.name = "node"; + this.os = process.platform; + } + return NodeInfo2; + }() +); +var SearchBotDeviceInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function SearchBotDeviceInfo2(name2, version2, os2, bot) { + this.name = name2; + this.version = version2; + this.os = os2; + this.bot = bot; + this.type = "bot-device"; + } + return SearchBotDeviceInfo2; + }() +); +var BotInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BotInfo2() { + this.type = "bot"; + this.bot = true; + this.name = "bot"; + this.version = null; + this.os = null; + } + return BotInfo2; + }() +); +var ReactNativeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function ReactNativeInfo2() { + this.type = "react-native"; + this.name = "react-native"; + this.version = null; + this.os = null; + } + return ReactNativeInfo2; + }() +); +var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; +var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; +var REQUIRED_VERSION_PARTS = 3; +var userAgentRules = [ + ["aol", /AOLShield\/([0-9\._]+)/], + ["edge", /Edge\/([0-9\._]+)/], + ["edge-ios", /EdgiOS\/([0-9\._]+)/], + ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], + ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], + ["samsung", /SamsungBrowser\/([0-9\.]+)/], + ["silk", /\bSilk\/([0-9._-]+)\b/], + ["miui", /MiuiBrowser\/([0-9\.]+)$/], + ["beaker", /BeakerBrowser\/([0-9\.]+)/], + ["edge-chromium", /EdgA?\/([0-9\.]+)/], + [ + "chromium-webview", + /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ + ], + ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], + ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], + ["fxios", /FxiOS\/([0-9\.]+)/], + ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], + ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], + ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], + ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], + ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], + ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], + ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ["ie", /MSIE\s(7\.0)/], + ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], + ["android", /Android\s([0-9\.]+)/], + ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ["safari", /Version\/([0-9\._]+).*Safari/], + ["facebook", /FB[AS]V\/([0-9\.]+)/], + ["instagram", /Instagram\s([0-9\.]+)/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ["curl", /^curl\/([0-9\.]+)$/], + ["searchbot", SEARCHBOX_UA_REGEX] +]; +var operatingSystemRules = [ + ["iOS", /iP(hone|od|ad)/], + ["Android OS", /Android/], + ["BlackBerry OS", /BlackBerry|BB10/], + ["Windows Mobile", /IEMobile/], + ["Amazon OS", /Kindle/], + ["Windows 3.11", /Win16/], + ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], + ["Windows 98", /(Windows 98)|(Win98)/], + ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], + ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], + ["Windows Server 2003", /(Windows NT 5.2)/], + ["Windows Vista", /(Windows NT 6.0)/], + ["Windows 7", /(Windows NT 6.1)/], + ["Windows 8", /(Windows NT 6.2)/], + ["Windows 8.1", /(Windows NT 6.3)/], + ["Windows 10", /(Windows NT 10.0)/], + ["Windows ME", /Windows ME/], + ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], + ["Open BSD", /OpenBSD/], + ["Sun OS", /SunOS/], + ["Chrome OS", /CrOS/], + ["Linux", /(Linux)|(X11)/], + ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], + ["QNX", /QNX/], + ["BeOS", /BeOS/], + ["OS/2", /OS\/2/] +]; +function detect(userAgent) { + if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { + return new ReactNativeInfo(); + } + if (typeof navigator !== "undefined") { + return parseUserAgent(navigator.userAgent); + } + return getNodeVersion(); +} +function matchUserAgent(ua2) { + return ua2 !== "" && userAgentRules.reduce(function(matched, _a2) { + var browser2 = _a2[0], regex = _a2[1]; + if (matched) { + return matched; + } + var uaMatch = regex.exec(ua2); + return !!uaMatch && [browser2, uaMatch]; + }, false); +} +function parseUserAgent(ua2) { + var matchedRule = matchUserAgent(ua2); + if (!matchedRule) { + return null; + } + var name2 = matchedRule[0], match = matchedRule[1]; + if (name2 === "searchbot") { + return new BotInfo(); + } + var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); + if (versionParts) { + if (versionParts.length < REQUIRED_VERSION_PARTS) { + versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); + } + } else { + versionParts = []; + } + var version2 = versionParts.join("."); + var os2 = detectOS(ua2); + var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua2); + if (searchBotMatch && searchBotMatch[1]) { + return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); + } + return new BrowserInfo(name2, version2, os2); +} +function detectOS(ua2) { + for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { + var _a2 = operatingSystemRules[ii], os2 = _a2[0], regex = _a2[1]; + var match = regex.exec(ua2); + if (match) { + return os2; + } + } + return null; +} +function getNodeVersion() { + var isNode = typeof process !== "undefined" && process.version; + return isNode ? new NodeInfo(process.version.slice(1)) : null; +} +function createVersionParts(count) { + var output = []; + for (var ii = 0; ii < count; ii++) { + output.push("0"); + } + return output; +} +var cjs$2 = {}; +Object.defineProperty(cjs$2, "__esModule", { value: true }); +cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; +function getFromWindow(name2) { + let res = void 0; + if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { + res = window[name2]; + } + return res; +} +cjs$2.getFromWindow = getFromWindow; +function getFromWindowOrThrow(name2) { + const res = getFromWindow(name2); + if (!res) { + throw new Error(`${name2} is not defined in Window`); + } + return res; +} +cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; +function getDocumentOrThrow() { + return getFromWindowOrThrow("document"); +} +cjs$2.getDocumentOrThrow = getDocumentOrThrow; +function getDocument() { + return getFromWindow("document"); +} +var getDocument_1 = cjs$2.getDocument = getDocument; +function getNavigatorOrThrow() { + return getFromWindowOrThrow("navigator"); +} +cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; +function getNavigator() { + return getFromWindow("navigator"); +} +var getNavigator_1 = cjs$2.getNavigator = getNavigator; +function getLocationOrThrow() { + return getFromWindowOrThrow("location"); +} +cjs$2.getLocationOrThrow = getLocationOrThrow; +function getLocation() { + return getFromWindow("location"); +} +var getLocation_1 = cjs$2.getLocation = getLocation; +function getCryptoOrThrow() { + return getFromWindowOrThrow("crypto"); +} +cjs$2.getCryptoOrThrow = getCryptoOrThrow; +function getCrypto() { + return getFromWindow("crypto"); +} +cjs$2.getCrypto = getCrypto; +function getLocalStorageOrThrow() { + return getFromWindowOrThrow("localStorage"); +} +cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; +function getLocalStorage() { + return getFromWindow("localStorage"); +} +cjs$2.getLocalStorage = getLocalStorage; +var cjs$1 = {}; +Object.defineProperty(cjs$1, "__esModule", { value: true }); +var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; +const window_getters_1 = cjs$2; +function getWindowMetadata() { + let doc; + let loc; + try { + doc = window_getters_1.getDocumentOrThrow(); + loc = window_getters_1.getLocationOrThrow(); + } catch (e2) { + return null; + } + function getIcons() { + const links = doc.getElementsByTagName("link"); + const icons2 = []; + for (let i2 = 0; i2 < links.length; i2++) { + const link = links[i2]; + const rel = link.getAttribute("rel"); + if (rel) { + if (rel.toLowerCase().indexOf("icon") > -1) { + const href = link.getAttribute("href"); + if (href) { + if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { + let absoluteHref = loc.protocol + "//" + loc.host; + if (href.indexOf("/") === 0) { + absoluteHref += href; + } else { + const path = loc.pathname.split("/"); + path.pop(); + const finalPath = path.join("/"); + absoluteHref += finalPath + "/" + href; + } + icons2.push(absoluteHref); + } else if (href.indexOf("//") === 0) { + const absoluteUrl = loc.protocol + href; + icons2.push(absoluteUrl); + } else { + icons2.push(href); + } + } + } + } + } + return icons2; + } + function getWindowMetadataOfAny(...args) { + const metaTags = doc.getElementsByTagName("meta"); + for (let i2 = 0; i2 < metaTags.length; i2++) { + const tag = metaTags[i2]; + const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { + if (attr) { + return args.includes(attr); + } + return false; + }); + if (attributes.length && attributes) { + const content = tag.getAttribute("content"); + if (content) { + return content; + } + } + } + return ""; + } + function getName() { + let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); + if (!name3) { + name3 = doc.title; + } + return name3; + } + function getDescription() { + const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); + return description3; + } + const name2 = getName(); + const description2 = getDescription(); + const url = loc.origin; + const icons = getIcons(); + const meta = { + description: description2, + url, + icons, + name: name2 + }; + return meta; +} +getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; +var queryString = {}; +var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); +var token = "%[a-f0-9]{2}"; +var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); +var multiMatcher = new RegExp("(" + token + ")+", "gi"); +function decodeComponents(components, split) { + try { + return [decodeURIComponent(components.join(""))]; + } catch (err) { + } + if (components.length === 1) { + return components; + } + split = split || 1; + var left = components.slice(0, split); + var right = components.slice(split); + return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); +} +function decode(input) { + try { + return decodeURIComponent(input); + } catch (err) { + var tokens = input.match(singleMatcher) || []; + for (var i2 = 1; i2 < tokens.length; i2++) { + input = decodeComponents(tokens, i2).join(""); + tokens = input.match(singleMatcher) || []; + } + return input; + } +} +function customDecodeURIComponent(input) { + var replaceMap = { + "%FE%FF": "��", + "%FF%FE": "��" + }; + var match = multiMatcher.exec(input); + while (match) { + try { + replaceMap[match[0]] = decodeURIComponent(match[0]); + } catch (err) { + var result = decode(match[0]); + if (result !== match[0]) { + replaceMap[match[0]] = result; + } + } + match = multiMatcher.exec(input); + } + replaceMap["%C2"] = "�"; + var entries = Object.keys(replaceMap); + for (var i2 = 0; i2 < entries.length; i2++) { + var key = entries[i2]; + input = input.replace(new RegExp(key, "g"), replaceMap[key]); + } + return input; +} +var decodeUriComponent = function(encodedURI) { + if (typeof encodedURI !== "string") { + throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + } + try { + encodedURI = encodedURI.replace(/\+/g, " "); + return decodeURIComponent(encodedURI); + } catch (err) { + return customDecodeURIComponent(encodedURI); + } +}; +var splitOnFirst = (string2, separator) => { + if (!(typeof string2 === "string" && typeof separator === "string")) { + throw new TypeError("Expected the arguments to be of type `string`"); + } + if (separator === "") { + return [string2]; + } + const separatorIndex = string2.indexOf(separator); + if (separatorIndex === -1) { + return [string2]; + } + return [ + string2.slice(0, separatorIndex), + string2.slice(separatorIndex + separator.length) + ]; +}; +var filterObj = function(obj, predicate) { + var ret = {}; + var keys2 = Object.keys(obj); + var isArr = Array.isArray(predicate); + for (var i2 = 0; i2 < keys2.length; i2++) { + var key = keys2[i2]; + var val = obj[key]; + if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { + ret[key] = val; + } + } + return ret; +}; +(function(exports2) { + const strictUriEncode$1 = strictUriEncode; + const decodeComponent = decodeUriComponent; + const splitOnFirst$1 = splitOnFirst; + const filterObject = filterObj; + const isNullOrUndefined = (value) => value === null || value === void 0; + const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); + function encoderForArrayFormat(options) { + switch (options.arrayFormat) { + case "index": + return (key) => (result, value) => { + const index = result.length; + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), "[", index, "]"].join("")]; + } + return [ + ...result, + [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") + ]; + }; + case "bracket": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), "[]"].join("")]; + } + return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; + }; + case "colon-list-separator": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), ":list="].join("")]; + } + return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; + }; + case "comma": + case "separator": + case "bracket-separator": { + const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + value = value === null ? "" : value; + if (result.length === 0) { + return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; + } + return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; + }; + } + default: + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, encode2(key, options)]; + } + return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; + }; + } + } + function parserForArrayFormat(options) { + let result; + switch (options.arrayFormat) { + case "index": + return (key, value, accumulator) => { + result = /\[(\d*)\]$/.exec(key); + key = key.replace(/\[\d*\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = {}; + } + accumulator[key][result[1]] = value; + }; + case "bracket": + return (key, value, accumulator) => { + result = /(\[\])$/.exec(key); + key = key.replace(/\[\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "colon-list-separator": + return (key, value, accumulator) => { + result = /(:list)$/.exec(key); + key = key.replace(/:list$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "comma": + case "separator": + return (key, value, accumulator) => { + const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator); + const isEncodedArray = typeof value === "string" && !isArray && decode2(value, options).includes(options.arrayFormatSeparator); + value = isEncodedArray ? decode2(value, options) : value; + const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); + accumulator[key] = newValue; + }; + case "bracket-separator": + return (key, value, accumulator) => { + const isArray = /(\[\])$/.test(key); + key = key.replace(/\[\]$/, ""); + if (!isArray) { + accumulator[key] = value ? decode2(value, options) : value; + return; + } + const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); + if (accumulator[key] === void 0) { + accumulator[key] = arrayValue; + return; + } + accumulator[key] = [].concat(accumulator[key], arrayValue); + }; + default: + return (key, value, accumulator) => { + if (accumulator[key] === void 0) { + accumulator[key] = value; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + } + } + function validateArrayFormatSeparator(value) { + if (typeof value !== "string" || value.length !== 1) { + throw new TypeError("arrayFormatSeparator must be single character string"); + } + } + function encode2(value, options) { + if (options.encode) { + return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); + } + return value; + } + function decode2(value, options) { + if (options.decode) { + return decodeComponent(value); + } + return value; + } + function keysSorter(input) { + if (Array.isArray(input)) { + return input.sort(); + } + if (typeof input === "object") { + return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); + } + return input; + } + function removeHash(input) { + const hashStart = input.indexOf("#"); + if (hashStart !== -1) { + input = input.slice(0, hashStart); + } + return input; + } + function getHash(url) { + let hash2 = ""; + const hashStart = url.indexOf("#"); + if (hashStart !== -1) { + hash2 = url.slice(hashStart); + } + return hash2; + } + function extract(input) { + input = removeHash(input); + const queryStart = input.indexOf("?"); + if (queryStart === -1) { + return ""; + } + return input.slice(queryStart + 1); + } + function parseValue(value, options) { + if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { + value = Number(value); + } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { + value = value.toLowerCase() === "true"; + } + return value; + } + function parse(query, options) { + options = Object.assign({ + decode: true, + sort: true, + arrayFormat: "none", + arrayFormatSeparator: ",", + parseNumbers: false, + parseBooleans: false + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const formatter = parserForArrayFormat(options); + const ret = /* @__PURE__ */ Object.create(null); + if (typeof query !== "string") { + return ret; + } + query = query.trim().replace(/^[?#&]/, ""); + if (!query) { + return ret; + } + for (const param of query.split("&")) { + if (param === "") { + continue; + } + let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); + value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); + formatter(decode2(key, options), value, ret); + } + for (const key of Object.keys(ret)) { + const value = ret[key]; + if (typeof value === "object" && value !== null) { + for (const k2 of Object.keys(value)) { + value[k2] = parseValue(value[k2], options); + } + } else { + ret[key] = parseValue(value, options); + } + } + if (options.sort === false) { + return ret; + } + return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { + const value = ret[key]; + if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { + result[key] = keysSorter(value); + } else { + result[key] = value; + } + return result; + }, /* @__PURE__ */ Object.create(null)); + } + exports2.extract = extract; + exports2.parse = parse; + exports2.stringify = (object, options) => { + if (!object) { + return ""; + } + options = Object.assign({ + encode: true, + strict: true, + arrayFormat: "none", + arrayFormatSeparator: "," + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; + const formatter = encoderForArrayFormat(options); + const objectCopy = {}; + for (const key of Object.keys(object)) { + if (!shouldFilter(key)) { + objectCopy[key] = object[key]; + } + } + const keys2 = Object.keys(objectCopy); + if (options.sort !== false) { + keys2.sort(options.sort); + } + return keys2.map((key) => { + const value = object[key]; + if (value === void 0) { + return ""; + } + if (value === null) { + return encode2(key, options); + } + if (Array.isArray(value)) { + if (value.length === 0 && options.arrayFormat === "bracket-separator") { + return encode2(key, options) + "[]"; + } + return value.reduce(formatter(key), []).join("&"); + } + return encode2(key, options) + "=" + encode2(value, options); + }).filter((x2) => x2.length > 0).join("&"); + }; + exports2.parseUrl = (url, options) => { + options = Object.assign({ + decode: true + }, options); + const [url_, hash2] = splitOnFirst$1(url, "#"); + return Object.assign( + { + url: url_.split("?")[0] || "", + query: parse(extract(url), options) + }, + options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} + ); + }; + exports2.stringifyUrl = (object, options) => { + options = Object.assign({ + encode: true, + strict: true, + [encodeFragmentIdentifier]: true + }, options); + const url = removeHash(object.url).split("?")[0] || ""; + const queryFromUrl = exports2.extract(object.url); + const parsedQueryFromUrl = exports2.parse(queryFromUrl, { sort: false }); + const query = Object.assign(parsedQueryFromUrl, object.query); + let queryString2 = exports2.stringify(query, options); + if (queryString2) { + queryString2 = `?${queryString2}`; + } + let hash2 = getHash(object.url); + if (object.fragmentIdentifier) { + hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + } + return `${url}${queryString2}${hash2}`; + }; + exports2.pick = (input, filter, options) => { + options = Object.assign({ + parseFragmentIdentifier: true, + [encodeFragmentIdentifier]: false + }, options); + const { url, query, fragmentIdentifier } = exports2.parseUrl(input, options); + return exports2.stringifyUrl({ + url, + query: filterObject(query, filter), + fragmentIdentifier + }, options); + }; + exports2.exclude = (input, filter, options) => { + const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); + return exports2.pick(input, exclusionFilter, options); + }; +})(queryString); +var chacha20poly1305 = {}; +var chacha = {}; +Object.defineProperty(chacha, "__esModule", { value: true }); +var binary_1 = binary; +var wipe_1$2 = wipe$1; +var ROUNDS = 20; +function core(out, input, key) { + var j02 = 1634760805; + var j1 = 857760878; + var j2 = 2036477234; + var j3 = 1797285236; + var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; + var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; + var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; + var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; + var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; + var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; + var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; + var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; + var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; + var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; + var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; + var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; + var x02 = j02; + var x1 = j1; + var x2 = j2; + var x3 = j3; + var x4 = j4; + var x5 = j5; + var x6 = j6; + var x7 = j7; + var x8 = j8; + var x9 = j9; + var x10 = j10; + var x11 = j11; + var x12 = j12; + var x13 = j13; + var x14 = j14; + var x15 = j15; + for (var i2 = 0; i2 < ROUNDS; i2 += 2) { + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 16 | x12 << 16; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 12 | x4 << 12; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 16 | x13 << 16; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 12 | x5 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 16 | x14 << 16; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 12 | x6 << 12; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 16 | x15 << 16; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 12 | x7 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 8 | x14 << 8; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 7 | x6 << 7; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 8 | x15 << 8; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 7 | x7 << 7; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 8 | x13 << 8; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 7 | x5 << 7; + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 8 | x12 << 8; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 7 | x4 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 16 | x15 << 16; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 12 | x5 << 12; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 16 | x12 << 16; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 12 | x6 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 16 | x13 << 16; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 12 | x7 << 12; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 16 | x14 << 16; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 12 | x4 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 8 | x13 << 8; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 7 | x7 << 7; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 8 | x14 << 8; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 7 | x4 << 7; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 8 | x12 << 8; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 7 | x6 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 8 | x15 << 8; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 7 | x5 << 7; + } + binary_1.writeUint32LE(x02 + j02 | 0, out, 0); + binary_1.writeUint32LE(x1 + j1 | 0, out, 4); + binary_1.writeUint32LE(x2 + j2 | 0, out, 8); + binary_1.writeUint32LE(x3 + j3 | 0, out, 12); + binary_1.writeUint32LE(x4 + j4 | 0, out, 16); + binary_1.writeUint32LE(x5 + j5 | 0, out, 20); + binary_1.writeUint32LE(x6 + j6 | 0, out, 24); + binary_1.writeUint32LE(x7 + j7 | 0, out, 28); + binary_1.writeUint32LE(x8 + j8 | 0, out, 32); + binary_1.writeUint32LE(x9 + j9 | 0, out, 36); + binary_1.writeUint32LE(x10 + j10 | 0, out, 40); + binary_1.writeUint32LE(x11 + j11 | 0, out, 44); + binary_1.writeUint32LE(x12 + j12 | 0, out, 48); + binary_1.writeUint32LE(x13 + j13 | 0, out, 52); + binary_1.writeUint32LE(x14 + j14 | 0, out, 56); + binary_1.writeUint32LE(x15 + j15 | 0, out, 60); +} +function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + if (key.length !== 32) { + throw new Error("ChaCha: key size must be 32 bytes"); + } + if (dst.length < src2.length) { + throw new Error("ChaCha: destination is shorter than source"); + } + var nc; + var counterLength; + if (nonceInplaceCounterLength === 0) { + if (nonce.length !== 8 && nonce.length !== 12) { + throw new Error("ChaCha nonce must be 8 or 12 bytes"); + } + nc = new Uint8Array(16); + counterLength = nc.length - nonce.length; + nc.set(nonce, counterLength); + } else { + if (nonce.length !== 16) { + throw new Error("ChaCha nonce with counter must be 16 bytes"); + } + nc = nonce; + counterLength = nonceInplaceCounterLength; + } + var block = new Uint8Array(64); + for (var i2 = 0; i2 < src2.length; i2 += 64) { + core(block, nc, key); + for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { + dst[j2] = src2[j2] ^ block[j2 - i2]; + } + incrementCounter(nc, 0, counterLength); + } + wipe_1$2.wipe(block); + if (nonceInplaceCounterLength === 0) { + wipe_1$2.wipe(nc); + } + return dst; +} +chacha.streamXOR = streamXOR; +function stream(key, nonce, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + wipe_1$2.wipe(dst); + return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); +} +chacha.stream = stream; +function incrementCounter(counter, pos, len) { + var carry = 1; + while (len--) { + carry = carry + (counter[pos] & 255) | 0; + counter[pos] = carry & 255; + carry >>>= 8; + pos++; + } + if (carry > 0) { + throw new Error("ChaCha: counter overflow"); + } +} +var poly1305 = {}; +var constantTime = {}; +Object.defineProperty(constantTime, "__esModule", { value: true }); +function select(subject, resultIfOne, resultIfZero) { + return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; +} +constantTime.select = select; +function lessOrEqual(a3, b3) { + return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; +} +constantTime.lessOrEqual = lessOrEqual; +function compare(a3, b3) { + if (a3.length !== b3.length) { + return 0; + } + var result = 0; + for (var i2 = 0; i2 < a3.length; i2++) { + result |= a3[i2] ^ b3[i2]; + } + return 1 & result - 1 >>> 8; +} +constantTime.compare = compare; +function equal(a3, b3) { + if (a3.length === 0 || b3.length === 0) { + return false; + } + return compare(a3, b3) !== 0; +} +constantTime.equal = equal; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var constant_time_12 = constantTime; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 16; + var Poly1305 = ( + /** @class */ + function() { + function Poly13052(key) { + this.digestLength = exports2.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 = false; + var t0 = key[0] | key[1] << 8; + this._r[0] = t0 & 8191; + var t1 = key[2] | key[3] << 8; + this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; + var t2 = key[4] | key[5] << 8; + this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; + var t3 = key[6] | key[7] << 8; + this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; + var t4 = key[8] | key[9] << 8; + this._r[4] = (t3 >>> 4 | t4 << 12) & 255; + this._r[5] = t4 >>> 1 & 8190; + var t5 = key[10] | key[11] << 8; + this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; + var t6 = key[12] | key[13] << 8; + this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; + var t7 = key[14] | key[15] << 8; + this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; + this._r[9] = t7 >>> 5 & 127; + this._pad[0] = key[16] | key[17] << 8; + this._pad[1] = key[18] | key[19] << 8; + this._pad[2] = key[20] | key[21] << 8; + this._pad[3] = key[22] | key[23] << 8; + this._pad[4] = key[24] | key[25] << 8; + this._pad[5] = key[26] | key[27] << 8; + this._pad[6] = key[28] | key[29] << 8; + this._pad[7] = key[30] | key[31] << 8; + } + Poly13052.prototype._blocks = function(m3, mpos, bytes) { + var hibit = this._fin ? 0 : 1 << 11; + var h02 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; + var r0 = this._r[0], r1 = this._r[1], r22 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; + while (bytes >= 16) { + var t0 = m3[mpos + 0] | m3[mpos + 1] << 8; + h02 += t0 & 8191; + var t1 = m3[mpos + 2] | m3[mpos + 3] << 8; + h1 += (t0 >>> 13 | t1 << 3) & 8191; + var t2 = m3[mpos + 4] | m3[mpos + 5] << 8; + h22 += (t1 >>> 10 | t2 << 6) & 8191; + var t3 = m3[mpos + 6] | m3[mpos + 7] << 8; + h32 += (t2 >>> 7 | t3 << 9) & 8191; + var t4 = m3[mpos + 8] | m3[mpos + 9] << 8; + h4 += (t3 >>> 4 | t4 << 12) & 8191; + h5 += t4 >>> 1 & 8191; + var t5 = m3[mpos + 10] | m3[mpos + 11] << 8; + h6 += (t4 >>> 14 | t5 << 2) & 8191; + var t6 = m3[mpos + 12] | m3[mpos + 13] << 8; + h7 += (t5 >>> 11 | t6 << 5) & 8191; + var t7 = m3[mpos + 14] | m3[mpos + 15] << 8; + h8 += (t6 >>> 8 | t7 << 8) & 8191; + h9 += t7 >>> 5 | hibit; + var c2 = 0; + var d02 = c2; + d02 += h02 * r0; + d02 += h1 * (5 * r9); + d02 += h22 * (5 * r8); + d02 += h32 * (5 * r7); + d02 += h4 * (5 * r6); + c2 = d02 >>> 13; + d02 &= 8191; + d02 += h5 * (5 * r5); + d02 += h6 * (5 * r4); + d02 += h7 * (5 * r3); + d02 += h8 * (5 * r22); + d02 += h9 * (5 * r1); + c2 += d02 >>> 13; + d02 &= 8191; + var d1 = c2; + d1 += h02 * r1; + d1 += h1 * r0; + d1 += h22 * (5 * r9); + d1 += h32 * (5 * r8); + d1 += h4 * (5 * r7); + c2 = d1 >>> 13; + d1 &= 8191; + d1 += h5 * (5 * r6); + d1 += h6 * (5 * r5); + d1 += h7 * (5 * r4); + d1 += h8 * (5 * r3); + d1 += h9 * (5 * r22); + c2 += d1 >>> 13; + d1 &= 8191; + var d22 = c2; + d22 += h02 * r22; + d22 += h1 * r1; + d22 += h22 * r0; + d22 += h32 * (5 * r9); + d22 += h4 * (5 * r8); + c2 = d22 >>> 13; + d22 &= 8191; + d22 += h5 * (5 * r7); + d22 += h6 * (5 * r6); + d22 += h7 * (5 * r5); + d22 += h8 * (5 * r4); + d22 += h9 * (5 * r3); + c2 += d22 >>> 13; + d22 &= 8191; + var d32 = c2; + d32 += h02 * r3; + d32 += h1 * r22; + d32 += h22 * r1; + d32 += h32 * r0; + d32 += h4 * (5 * r9); + c2 = d32 >>> 13; + d32 &= 8191; + d32 += h5 * (5 * r8); + d32 += h6 * (5 * r7); + d32 += h7 * (5 * r6); + d32 += h8 * (5 * r5); + d32 += h9 * (5 * r4); + c2 += d32 >>> 13; + d32 &= 8191; + var d42 = c2; + d42 += h02 * r4; + d42 += h1 * r3; + d42 += h22 * r22; + d42 += h32 * r1; + d42 += h4 * r0; + c2 = d42 >>> 13; + d42 &= 8191; + d42 += h5 * (5 * r9); + d42 += h6 * (5 * r8); + d42 += h7 * (5 * r7); + d42 += h8 * (5 * r6); + d42 += h9 * (5 * r5); + c2 += d42 >>> 13; + d42 &= 8191; + var d5 = c2; + d5 += h02 * r5; + d5 += h1 * r4; + d5 += h22 * r3; + d5 += h32 * r22; + d5 += h4 * r1; + c2 = d5 >>> 13; + d5 &= 8191; + d5 += h5 * r0; + d5 += h6 * (5 * r9); + d5 += h7 * (5 * r8); + d5 += h8 * (5 * r7); + d5 += h9 * (5 * r6); + c2 += d5 >>> 13; + d5 &= 8191; + var d6 = c2; + d6 += h02 * r6; + d6 += h1 * r5; + d6 += h22 * r4; + d6 += h32 * r3; + d6 += h4 * r22; + c2 = d6 >>> 13; + d6 &= 8191; + d6 += h5 * r1; + d6 += h6 * r0; + d6 += h7 * (5 * r9); + d6 += h8 * (5 * r8); + d6 += h9 * (5 * r7); + c2 += d6 >>> 13; + d6 &= 8191; + var d7 = c2; + d7 += h02 * r7; + d7 += h1 * r6; + d7 += h22 * r5; + d7 += h32 * r4; + d7 += h4 * r3; + c2 = d7 >>> 13; + d7 &= 8191; + d7 += h5 * r22; + d7 += h6 * r1; + d7 += h7 * r0; + d7 += h8 * (5 * r9); + d7 += h9 * (5 * r8); + c2 += d7 >>> 13; + d7 &= 8191; + var d8 = c2; + d8 += h02 * r8; + d8 += h1 * r7; + d8 += h22 * r6; + d8 += h32 * r5; + d8 += h4 * r4; + c2 = d8 >>> 13; + d8 &= 8191; + d8 += h5 * r3; + d8 += h6 * r22; + d8 += h7 * r1; + d8 += h8 * r0; + d8 += h9 * (5 * r9); + c2 += d8 >>> 13; + d8 &= 8191; + var d9 = c2; + d9 += h02 * r9; + d9 += h1 * r8; + d9 += h22 * r7; + d9 += h32 * r6; + d9 += h4 * r5; + c2 = d9 >>> 13; + d9 &= 8191; + d9 += h5 * r4; + d9 += h6 * r3; + d9 += h7 * r22; + d9 += h8 * r1; + d9 += h9 * r0; + c2 += d9 >>> 13; + d9 &= 8191; + c2 = (c2 << 2) + c2 | 0; + c2 = c2 + d02 | 0; + d02 = c2 & 8191; + c2 = c2 >>> 13; + d1 += c2; + h02 = d02; + h1 = d1; + h22 = d22; + h32 = d32; + h4 = d42; + h5 = d5; + h6 = d6; + h7 = d7; + h8 = d8; + h9 = d9; + mpos += 16; + bytes -= 16; + } + this._h[0] = h02; + this._h[1] = h1; + this._h[2] = h22; + this._h[3] = h32; + this._h[4] = h4; + this._h[5] = h5; + this._h[6] = h6; + this._h[7] = h7; + this._h[8] = h8; + this._h[9] = h9; + }; + Poly13052.prototype.finish = function(mac, macpos) { + if (macpos === void 0) { + macpos = 0; + } + var g3 = new Uint16Array(10); + var c2; + var mask; + var f3; + var i2; + if (this._leftover) { + i2 = this._leftover; + this._buffer[i2++] = 1; + for (; i2 < 16; i2++) { + this._buffer[i2] = 0; + } + this._fin = 1; + this._blocks(this._buffer, 0, 16); + } + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + for (i2 = 2; i2 < 10; i2++) { + this._h[i2] += c2; + c2 = this._h[i2] >>> 13; + this._h[i2] &= 8191; + } + this._h[0] += c2 * 5; + c2 = this._h[0] >>> 13; + this._h[0] &= 8191; + this._h[1] += c2; + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + this._h[2] += c2; + g3[0] = this._h[0] + 5; + c2 = g3[0] >>> 13; + g3[0] &= 8191; + for (i2 = 1; i2 < 10; i2++) { + g3[i2] = this._h[i2] + c2; + c2 = g3[i2] >>> 13; + g3[i2] &= 8191; + } + g3[9] -= 1 << 13; + mask = (c2 ^ 1) - 1; + for (i2 = 0; i2 < 10; i2++) { + g3[i2] &= mask; + } + mask = ~mask; + for (i2 = 0; i2 < 10; i2++) { + this._h[i2] = this._h[i2] & mask | g3[i2]; + } + 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; + f3 = this._h[0] + this._pad[0]; + this._h[0] = f3 & 65535; + for (i2 = 1; i2 < 8; i2++) { + f3 = (this._h[i2] + this._pad[i2] | 0) + (f3 >>> 16) | 0; + this._h[i2] = f3 & 65535; + } + mac[macpos + 0] = this._h[0] >>> 0; + mac[macpos + 1] = this._h[0] >>> 8; + mac[macpos + 2] = this._h[1] >>> 0; + mac[macpos + 3] = this._h[1] >>> 8; + mac[macpos + 4] = this._h[2] >>> 0; + mac[macpos + 5] = this._h[2] >>> 8; + mac[macpos + 6] = this._h[3] >>> 0; + mac[macpos + 7] = this._h[3] >>> 8; + mac[macpos + 8] = this._h[4] >>> 0; + mac[macpos + 9] = this._h[4] >>> 8; + mac[macpos + 10] = this._h[5] >>> 0; + mac[macpos + 11] = this._h[5] >>> 8; + mac[macpos + 12] = this._h[6] >>> 0; + mac[macpos + 13] = this._h[6] >>> 8; + mac[macpos + 14] = this._h[7] >>> 0; + mac[macpos + 15] = this._h[7] >>> 8; + this._finished = true; + return this; + }; + Poly13052.prototype.update = function(m3) { + var mpos = 0; + var bytes = m3.length; + var want; + if (this._leftover) { + want = 16 - this._leftover; + if (want > bytes) { + want = bytes; + } + for (var i2 = 0; i2 < want; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + bytes -= want; + mpos += want; + this._leftover += want; + if (this._leftover < 16) { + return this; + } + this._blocks(this._buffer, 0, 16); + this._leftover = 0; + } + if (bytes >= 16) { + want = bytes - bytes % 16; + this._blocks(m3, mpos, want); + mpos += want; + bytes -= want; + } + if (bytes) { + for (var i2 = 0; i2 < bytes; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + this._leftover += bytes; + } + return this; + }; + Poly13052.prototype.digest = function() { + if (this._finished) { + throw new Error("Poly1305 was finished"); + } + var mac = new Uint8Array(16); + this.finish(mac); + return mac; + }; + Poly13052.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._r); + wipe_12.wipe(this._h); + wipe_12.wipe(this._pad); + this._leftover = 0; + this._fin = 0; + this._finished = true; + return this; + }; + return Poly13052; + }() + ); + exports2.Poly1305 = Poly1305; + function oneTimeAuth(key, data) { + var h4 = new Poly1305(key); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.oneTimeAuth = oneTimeAuth; + function equal2(a3, b3) { + if (a3.length !== exports2.DIGEST_LENGTH || b3.length !== exports2.DIGEST_LENGTH) { + return false; + } + return constant_time_12.equal(a3, b3); + } + exports2.equal = equal2; +})(poly1305); +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var chacha_1 = chacha; + var poly1305_1 = poly1305; + var wipe_12 = wipe$1; + var binary_12 = binary; + var constant_time_12 = constantTime; + exports2.KEY_LENGTH = 32; + exports2.NONCE_LENGTH = 12; + exports2.TAG_LENGTH = 16; + var ZEROS = new Uint8Array(16); + var ChaCha20Poly1305 = ( + /** @class */ + function() { + function ChaCha20Poly13052(key) { + this.nonceLength = exports2.NONCE_LENGTH; + this.tagLength = exports2.TAG_LENGTH; + if (key.length !== exports2.KEY_LENGTH) { + throw new Error("ChaCha20Poly1305 needs 32-byte key"); + } + this._key = new Uint8Array(key); + } + ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var resultLength = plaintext.length + this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, plaintext, result, 4); + this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + if (sealed.length < this.tagLength) { + return null; + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var calculatedTag = new Uint8Array(this.tagLength); + this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); + if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { + return null; + } + var resultLength = sealed.length - this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.clean = function() { + wipe_12.wipe(this._key); + return this; + }; + ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { + var h4 = new poly1305_1.Poly1305(authKey); + if (associatedData) { + h4.update(associatedData); + if (associatedData.length % 16 > 0) { + h4.update(ZEROS.subarray(associatedData.length % 16)); + } + } + h4.update(ciphertext); + if (ciphertext.length % 16 > 0) { + h4.update(ZEROS.subarray(ciphertext.length % 16)); + } + var length = new Uint8Array(8); + if (associatedData) { + binary_12.writeUint64LE(associatedData.length, length); + } + h4.update(length); + binary_12.writeUint64LE(ciphertext.length, length); + h4.update(length); + var tag = h4.digest(); + for (var i2 = 0; i2 < tag.length; i2++) { + tagOut[i2] = tag[i2]; + } + h4.clean(); + wipe_12.wipe(tag); + wipe_12.wipe(length); + }; + return ChaCha20Poly13052; + }() + ); + exports2.ChaCha20Poly1305 = ChaCha20Poly1305; +})(chacha20poly1305); +var hkdf = {}; +var hmac$1 = {}; +var hash = {}; +Object.defineProperty(hash, "__esModule", { value: true }); +function isSerializableHash(h4) { + return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; +} +hash.isSerializableHash = isSerializableHash; +Object.defineProperty(hmac$1, "__esModule", { value: true }); +var hash_1 = hash; +var constant_time_1 = constantTime; +var wipe_1$1 = wipe$1; +var HMAC = ( + /** @class */ + function() { + function HMAC2(hash2, key) { + this._finished = false; + this._inner = new hash2(); + this._outer = new hash2(); + this.blockSize = this._outer.blockSize; + this.digestLength = this._outer.digestLength; + var pad = new Uint8Array(this.blockSize); + if (key.length > this.blockSize) { + this._inner.update(key).finish(pad).clean(); + } else { + pad.set(key); + } + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54; + } + this._inner.update(pad); + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54 ^ 92; + } + this._outer.update(pad); + if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { + this._innerKeyedState = this._inner.saveState(); + this._outerKeyedState = this._outer.saveState(); + } + wipe_1$1.wipe(pad); + } + HMAC2.prototype.reset = function() { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); + } + this._inner.restoreState(this._innerKeyedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.clean = function() { + if (hash_1.isSerializableHash(this._inner)) { + this._inner.cleanSavedState(this._innerKeyedState); + } + if (hash_1.isSerializableHash(this._outer)) { + this._outer.cleanSavedState(this._outerKeyedState); + } + this._inner.clean(); + this._outer.clean(); + }; + HMAC2.prototype.update = function(data) { + this._inner.update(data); + return this; + }; + HMAC2.prototype.finish = function(out) { + if (this._finished) { + this._outer.finish(out); + return this; + } + this._inner.finish(out); + this._outer.update(out.subarray(0, this.digestLength)).finish(out); + this._finished = true; + return this; + }; + HMAC2.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + HMAC2.prototype.saveState = function() { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't saveState() because hash doesn't implement it"); + } + return this._inner.saveState(); + }; + HMAC2.prototype.restoreState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't restoreState() because hash doesn't implement it"); + } + this._inner.restoreState(savedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.cleanSavedState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); + } + this._inner.cleanSavedState(savedState); + }; + return HMAC2; + }() +); +hmac$1.HMAC = HMAC; +function hmac(hash2, key, data) { + var h4 = new HMAC(hash2, key); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; +} +hmac$1.hmac = hmac; +hmac$1.equal = constant_time_1.equal; +Object.defineProperty(hkdf, "__esModule", { value: true }); +var hmac_1 = hmac$1; +var wipe_1 = wipe$1; +var HKDF = ( + /** @class */ + function() { + function HKDF2(hash2, key, salt, info) { + if (salt === void 0) { + salt = new Uint8Array(0); + } + this._counter = new Uint8Array(1); + this._hash = hash2; + this._info = info; + var okm = hmac_1.hmac(this._hash, salt, key); + this._hmac = new hmac_1.HMAC(hash2, okm); + this._buffer = new Uint8Array(this._hmac.digestLength); + this._bufpos = this._buffer.length; + } + HKDF2.prototype._fillBuffer = function() { + this._counter[0]++; + var ctr = this._counter[0]; + if (ctr === 0) { + throw new Error("hkdf: cannot expand more"); + } + this._hmac.reset(); + if (ctr > 1) { + this._hmac.update(this._buffer); + } + if (this._info) { + this._hmac.update(this._info); + } + this._hmac.update(this._counter); + this._hmac.finish(this._buffer); + this._bufpos = 0; + }; + HKDF2.prototype.expand = function(length) { + var out = new Uint8Array(length); + for (var i2 = 0; i2 < out.length; i2++) { + if (this._bufpos === this._buffer.length) { + this._fillBuffer(); + } + out[i2] = this._buffer[this._bufpos++]; + } + return out; + }; + HKDF2.prototype.clean = function() { + this._hmac.clean(); + wipe_1.wipe(this._buffer); + wipe_1.wipe(this._counter); + this._bufpos = 0; + }; + return HKDF2; + }() +); +var HKDF_1 = hkdf.HKDF = HKDF; +var sha256 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var binary_12 = binary; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 32; + exports2.BLOCK_SIZE = 64; + var SHA256 = ( + /** @class */ + function() { + function SHA2562() { + this.digestLength = exports2.DIGEST_LENGTH; + this.blockSize = exports2.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 = false; + this.reset(); + } + SHA2562.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; + }; + SHA2562.prototype.reset = function() { + this._initState(); + this._bufferLength = 0; + this._bytesHashed = 0; + this._finished = false; + return this; + }; + SHA2562.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._temp); + this.reset(); + }; + SHA2562.prototype.update = function(data, dataLength) { + if (dataLength === void 0) { + dataLength = data.length; + } + if (this._finished) { + throw new Error("SHA256: can't update because hash was finished."); + } + var dataPos = 0; + this._bytesHashed += dataLength; + if (this._bufferLength > 0) { + while (this._bufferLength < this.blockSize && dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + if (this._bufferLength === this.blockSize) { + hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); + this._bufferLength = 0; + } + } + if (dataLength >= this.blockSize) { + dataPos = hashBlocks(this._temp, this._state, data, dataPos, dataLength); + dataLength %= this.blockSize; + } + while (dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + return this; + }; + SHA2562.prototype.finish = function(out) { + if (!this._finished) { + var bytesHashed = this._bytesHashed; + var left = this._bufferLength; + var bitLenHi = bytesHashed / 536870912 | 0; + var bitLenLo = bytesHashed << 3; + var padLength = bytesHashed % 64 < 56 ? 64 : 128; + this._buffer[left] = 128; + for (var i2 = left + 1; i2 < padLength - 8; i2++) { + this._buffer[i2] = 0; + } + binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); + binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); + hashBlocks(this._temp, this._state, this._buffer, 0, padLength); + this._finished = true; + } + for (var i2 = 0; i2 < this.digestLength / 4; i2++) { + binary_12.writeUint32BE(this._state[i2], out, i2 * 4); + } + return this; + }; + SHA2562.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + SHA2562.prototype.saveState = function() { + if (this._finished) { + throw new Error("SHA256: cannot save finished state"); + } + return { + state: new Int32Array(this._state), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }; + SHA2562.prototype.restoreState = function(savedState) { + this._state.set(savedState.state); + this._bufferLength = savedState.bufferLength; + if (savedState.buffer) { + this._buffer.set(savedState.buffer); + } + this._bytesHashed = savedState.bytesHashed; + this._finished = false; + return this; + }; + SHA2562.prototype.cleanSavedState = function(savedState) { + wipe_12.wipe(savedState.state); + if (savedState.buffer) { + wipe_12.wipe(savedState.buffer); + } + savedState.bufferLength = 0; + savedState.bytesHashed = 0; + }; + return SHA2562; + }() + ); + exports2.SHA256 = SHA256; + var K3 = 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 hashBlocks(w3, v3, p2, pos, len) { + while (len >= 64) { + var a3 = v3[0]; + var b3 = v3[1]; + var c2 = v3[2]; + var d5 = v3[3]; + var e2 = v3[4]; + var f3 = v3[5]; + var g3 = v3[6]; + var h4 = v3[7]; + for (var i2 = 0; i2 < 16; i2++) { + var j2 = pos + i2 * 4; + w3[i2] = binary_12.readUint32BE(p2, j2); + } + for (var i2 = 16; i2 < 64; i2++) { + var u3 = w3[i2 - 2]; + var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; + u3 = w3[i2 - 15]; + var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; + w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); + } + for (var i2 = 0; i2 < 64; i2++) { + var t1 = (((e2 >>> 6 | e2 << 32 - 6) ^ (e2 >>> 11 | e2 << 32 - 11) ^ (e2 >>> 25 | e2 << 32 - 25)) + (e2 & f3 ^ ~e2 & g3) | 0) + (h4 + (K3[i2] + w3[i2] | 0) | 0) | 0; + var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; + h4 = g3; + g3 = f3; + f3 = e2; + e2 = d5 + t1 | 0; + d5 = c2; + c2 = b3; + b3 = a3; + a3 = t1 + t2 | 0; + } + v3[0] += a3; + v3[1] += b3; + v3[2] += c2; + v3[3] += d5; + v3[4] += e2; + v3[5] += f3; + v3[6] += g3; + v3[7] += h4; + pos += 64; + len -= 64; + } + return pos; + } + function hash2(data) { + var h4 = new SHA256(); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.hash = hash2; +})(sha256); +var x25519 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.sharedKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.scalarMultBase = exports2.scalarMult = exports2.SHARED_KEY_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = void 0; + const random_1 = random; + const wipe_12 = wipe$1; + exports2.PUBLIC_KEY_LENGTH = 32; + exports2.SECRET_KEY_LENGTH = 32; + exports2.SHARED_KEY_LENGTH = 32; + function gf2(init) { + const r3 = new Float64Array(16); + if (init) { + for (let i2 = 0; i2 < init.length; i2++) { + r3[i2] = init[i2]; + } + } + return r3; + } + const _9 = new Uint8Array(32); + _9[0] = 9; + const _121665 = gf2([56129, 1]); + function car25519(o2) { + let c2 = 1; + for (let i2 = 0; i2 < 16; i2++) { + let v3 = o2[i2] + c2 + 65535; + c2 = Math.floor(v3 / 65536); + o2[i2] = v3 - c2 * 65536; + } + o2[0] += c2 - 1 + 37 * (c2 - 1); + } + function sel25519(p2, q2, b3) { + const c2 = ~(b3 - 1); + for (let i2 = 0; i2 < 16; i2++) { + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; + q2[i2] ^= t2; + } + } + function pack25519(o2, n4) { + const m3 = gf2(); + const t2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + t2[i2] = n4[i2]; + } + car25519(t2); + car25519(t2); + car25519(t2); + for (let j2 = 0; j2 < 2; j2++) { + m3[0] = t2[0] - 65517; + for (let i2 = 1; i2 < 15; i2++) { + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; + } + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); + } + for (let i2 = 0; i2 < 16; i2++) { + o2[2 * i2] = t2[i2] & 255; + o2[2 * i2 + 1] = t2[i2] >> 8; + } + } + function unpack25519(o2, n4) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); + } + o2[15] &= 32767; + } + function add(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] + b3[i2]; + } + } + function sub(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] - b3[i2]; + } + } + function mul(o2, a3, b3) { + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + v3 = a3[0]; + t0 += v3 * b02; + t1 += v3 * b1; + t2 += v3 * b22; + t3 += v3 * b32; + t4 += v3 * b4; + t5 += v3 * b5; + t6 += v3 * b6; + t7 += v3 * b7; + t8 += v3 * b8; + t9 += v3 * b9; + t10 += v3 * b10; + t11 += v3 * b11; + t12 += v3 * b12; + t13 += v3 * b13; + t14 += v3 * b14; + t15 += v3 * b15; + v3 = a3[1]; + t1 += v3 * b02; + t2 += v3 * b1; + t3 += v3 * b22; + t4 += v3 * b32; + t5 += v3 * b4; + t6 += v3 * b5; + t7 += v3 * b6; + t8 += v3 * b7; + t9 += v3 * b8; + t10 += v3 * b9; + t11 += v3 * b10; + t12 += v3 * b11; + t13 += v3 * b12; + t14 += v3 * b13; + t15 += v3 * b14; + t16 += v3 * b15; + v3 = a3[2]; + t2 += v3 * b02; + t3 += v3 * b1; + t4 += v3 * b22; + t5 += v3 * b32; + t6 += v3 * b4; + t7 += v3 * b5; + t8 += v3 * b6; + t9 += v3 * b7; + t10 += v3 * b8; + t11 += v3 * b9; + t12 += v3 * b10; + t13 += v3 * b11; + t14 += v3 * b12; + t15 += v3 * b13; + t16 += v3 * b14; + t17 += v3 * b15; + v3 = a3[3]; + t3 += v3 * b02; + t4 += v3 * b1; + t5 += v3 * b22; + t6 += v3 * b32; + t7 += v3 * b4; + t8 += v3 * b5; + t9 += v3 * b6; + t10 += v3 * b7; + t11 += v3 * b8; + t12 += v3 * b9; + t13 += v3 * b10; + t14 += v3 * b11; + t15 += v3 * b12; + t16 += v3 * b13; + t17 += v3 * b14; + t18 += v3 * b15; + v3 = a3[4]; + t4 += v3 * b02; + t5 += v3 * b1; + t6 += v3 * b22; + t7 += v3 * b32; + t8 += v3 * b4; + t9 += v3 * b5; + t10 += v3 * b6; + t11 += v3 * b7; + t12 += v3 * b8; + t13 += v3 * b9; + t14 += v3 * b10; + t15 += v3 * b11; + t16 += v3 * b12; + t17 += v3 * b13; + t18 += v3 * b14; + t19 += v3 * b15; + v3 = a3[5]; + t5 += v3 * b02; + t6 += v3 * b1; + t7 += v3 * b22; + t8 += v3 * b32; + t9 += v3 * b4; + t10 += v3 * b5; + t11 += v3 * b6; + t12 += v3 * b7; + t13 += v3 * b8; + t14 += v3 * b9; + t15 += v3 * b10; + t16 += v3 * b11; + t17 += v3 * b12; + t18 += v3 * b13; + t19 += v3 * b14; + t20 += v3 * b15; + v3 = a3[6]; + t6 += v3 * b02; + t7 += v3 * b1; + t8 += v3 * b22; + t9 += v3 * b32; + t10 += v3 * b4; + t11 += v3 * b5; + t12 += v3 * b6; + t13 += v3 * b7; + t14 += v3 * b8; + t15 += v3 * b9; + t16 += v3 * b10; + t17 += v3 * b11; + t18 += v3 * b12; + t19 += v3 * b13; + t20 += v3 * b14; + t21 += v3 * b15; + v3 = a3[7]; + t7 += v3 * b02; + t8 += v3 * b1; + t9 += v3 * b22; + t10 += v3 * b32; + t11 += v3 * b4; + t12 += v3 * b5; + t13 += v3 * b6; + t14 += v3 * b7; + t15 += v3 * b8; + t16 += v3 * b9; + t17 += v3 * b10; + t18 += v3 * b11; + t19 += v3 * b12; + t20 += v3 * b13; + t21 += v3 * b14; + t22 += v3 * b15; + v3 = a3[8]; + t8 += v3 * b02; + t9 += v3 * b1; + t10 += v3 * b22; + t11 += v3 * b32; + t12 += v3 * b4; + t13 += v3 * b5; + t14 += v3 * b6; + t15 += v3 * b7; + t16 += v3 * b8; + t17 += v3 * b9; + t18 += v3 * b10; + t19 += v3 * b11; + t20 += v3 * b12; + t21 += v3 * b13; + t22 += v3 * b14; + t23 += v3 * b15; + v3 = a3[9]; + t9 += v3 * b02; + t10 += v3 * b1; + t11 += v3 * b22; + t12 += v3 * b32; + t13 += v3 * b4; + t14 += v3 * b5; + t15 += v3 * b6; + t16 += v3 * b7; + t17 += v3 * b8; + t18 += v3 * b9; + t19 += v3 * b10; + t20 += v3 * b11; + t21 += v3 * b12; + t22 += v3 * b13; + t23 += v3 * b14; + t24 += v3 * b15; + v3 = a3[10]; + t10 += v3 * b02; + t11 += v3 * b1; + t12 += v3 * b22; + t13 += v3 * b32; + t14 += v3 * b4; + t15 += v3 * b5; + t16 += v3 * b6; + t17 += v3 * b7; + t18 += v3 * b8; + t19 += v3 * b9; + t20 += v3 * b10; + t21 += v3 * b11; + t22 += v3 * b12; + t23 += v3 * b13; + t24 += v3 * b14; + t25 += v3 * b15; + v3 = a3[11]; + t11 += v3 * b02; + t12 += v3 * b1; + t13 += v3 * b22; + t14 += v3 * b32; + t15 += v3 * b4; + t16 += v3 * b5; + t17 += v3 * b6; + t18 += v3 * b7; + t19 += v3 * b8; + t20 += v3 * b9; + t21 += v3 * b10; + t22 += v3 * b11; + t23 += v3 * b12; + t24 += v3 * b13; + t25 += v3 * b14; + t26 += v3 * b15; + v3 = a3[12]; + t12 += v3 * b02; + t13 += v3 * b1; + t14 += v3 * b22; + t15 += v3 * b32; + t16 += v3 * b4; + t17 += v3 * b5; + t18 += v3 * b6; + t19 += v3 * b7; + t20 += v3 * b8; + t21 += v3 * b9; + t22 += v3 * b10; + t23 += v3 * b11; + t24 += v3 * b12; + t25 += v3 * b13; + t26 += v3 * b14; + t27 += v3 * b15; + v3 = a3[13]; + t13 += v3 * b02; + t14 += v3 * b1; + t15 += v3 * b22; + t16 += v3 * b32; + t17 += v3 * b4; + t18 += v3 * b5; + t19 += v3 * b6; + t20 += v3 * b7; + t21 += v3 * b8; + t22 += v3 * b9; + t23 += v3 * b10; + t24 += v3 * b11; + t25 += v3 * b12; + t26 += v3 * b13; + t27 += v3 * b14; + t28 += v3 * b15; + v3 = a3[14]; + t14 += v3 * b02; + t15 += v3 * b1; + t16 += v3 * b22; + t17 += v3 * b32; + t18 += v3 * b4; + t19 += v3 * b5; + t20 += v3 * b6; + t21 += v3 * b7; + t22 += v3 * b8; + t23 += v3 * b9; + t24 += v3 * b10; + t25 += v3 * b11; + t26 += v3 * b12; + t27 += v3 * b13; + t28 += v3 * b14; + t29 += v3 * b15; + v3 = a3[15]; + t15 += v3 * b02; + t16 += v3 * b1; + t17 += v3 * b22; + t18 += v3 * b32; + t19 += v3 * b4; + t20 += v3 * b5; + t21 += v3 * b6; + t22 += v3 * b7; + t23 += v3 * b8; + t24 += v3 * b9; + t25 += v3 * b10; + t26 += v3 * b11; + t27 += v3 * b12; + t28 += v3 * b13; + t29 += v3 * b14; + t30 += v3 * b15; + t0 += 38 * t16; + t1 += 38 * t17; + t2 += 38 * t18; + t3 += 38 * t19; + t4 += 38 * t20; + t5 += 38 * t21; + t6 += 38 * t22; + t7 += 38 * t23; + t8 += 38 * t24; + t9 += 38 * t25; + t10 += 38 * t26; + t11 += 38 * t27; + t12 += 38 * t28; + t13 += 38 * t29; + t14 += 38 * t30; + c2 = 1; + v3 = t0 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t0 = v3 - c2 * 65536; + v3 = t1 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t1 = v3 - c2 * 65536; + v3 = t2 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t2 = v3 - c2 * 65536; + v3 = t3 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t3 = v3 - c2 * 65536; + v3 = t4 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t4 = v3 - c2 * 65536; + v3 = t5 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t5 = v3 - c2 * 65536; + v3 = t6 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t6 = v3 - c2 * 65536; + v3 = t7 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t7 = v3 - c2 * 65536; + v3 = t8 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t8 = v3 - c2 * 65536; + v3 = t9 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t9 = v3 - c2 * 65536; + v3 = t10 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t10 = v3 - c2 * 65536; + v3 = t11 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t11 = v3 - c2 * 65536; + v3 = t12 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t12 = v3 - c2 * 65536; + v3 = t13 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t13 = v3 - c2 * 65536; + v3 = t14 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t14 = v3 - c2 * 65536; + v3 = t15 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t15 = v3 - c2 * 65536; + t0 += c2 - 1 + 37 * (c2 - 1); + c2 = 1; + v3 = t0 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t0 = v3 - c2 * 65536; + v3 = t1 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t1 = v3 - c2 * 65536; + v3 = t2 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t2 = v3 - c2 * 65536; + v3 = t3 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t3 = v3 - c2 * 65536; + v3 = t4 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t4 = v3 - c2 * 65536; + v3 = t5 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t5 = v3 - c2 * 65536; + v3 = t6 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t6 = v3 - c2 * 65536; + v3 = t7 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t7 = v3 - c2 * 65536; + v3 = t8 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t8 = v3 - c2 * 65536; + v3 = t9 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t9 = v3 - c2 * 65536; + v3 = t10 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t10 = v3 - c2 * 65536; + v3 = t11 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t11 = v3 - c2 * 65536; + v3 = t12 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t12 = v3 - c2 * 65536; + v3 = t13 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t13 = v3 - c2 * 65536; + v3 = t14 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t14 = v3 - c2 * 65536; + v3 = t15 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t15 = v3 - c2 * 65536; + t0 += c2 - 1 + 37 * (c2 - 1); + o2[0] = t0; + o2[1] = t1; + o2[2] = t2; + o2[3] = t3; + o2[4] = t4; + o2[5] = t5; + o2[6] = t6; + o2[7] = t7; + o2[8] = t8; + o2[9] = t9; + o2[10] = t10; + o2[11] = t11; + o2[12] = t12; + o2[13] = t13; + o2[14] = t14; + o2[15] = t15; + } + function square(o2, a3) { + mul(o2, a3, a3); + } + function inv25519(o2, inp) { + const c2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + c2[i2] = inp[i2]; + } + for (let i2 = 253; i2 >= 0; i2--) { + square(c2, c2); + if (i2 !== 2 && i2 !== 4) { + mul(c2, c2, inp); + } + } + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = c2[i2]; + } + } + function scalarMult(n4, p2) { + const z2 = new Uint8Array(32); + const x2 = new Float64Array(80); + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(); + for (let i2 = 0; i2 < 31; i2++) { + z2[i2] = n4[i2]; + } + z2[31] = n4[31] & 127 | 64; + z2[0] &= 248; + unpack25519(x2, p2); + for (let i2 = 0; i2 < 16; i2++) { + b3[i2] = x2[i2]; + } + a3[0] = d5[0] = 1; + for (let i2 = 254; i2 >= 0; --i2) { + const r3 = z2[i2 >>> 3] >>> (i2 & 7) & 1; + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); + add(e2, a3, c2); + sub(a3, a3, c2); + add(c2, b3, d5); + sub(b3, b3, d5); + square(d5, e2); + square(f3, a3); + mul(a3, c2, a3); + mul(c2, b3, e2); + add(e2, a3, c2); + sub(a3, a3, c2); + square(b3, a3); + sub(c2, d5, f3); + mul(a3, c2, _121665); + add(a3, a3, d5); + mul(c2, c2, a3); + mul(a3, d5, f3); + mul(d5, b3, x2); + square(b3, e2); + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); + } + for (let i2 = 0; i2 < 16; i2++) { + x2[i2 + 16] = a3[i2]; + x2[i2 + 32] = c2[i2]; + x2[i2 + 48] = b3[i2]; + x2[i2 + 64] = d5[i2]; + } + const x32 = x2.subarray(32); + const x16 = x2.subarray(16); + inv25519(x32, x32); + mul(x16, x16, x32); + const q2 = new Uint8Array(32); + pack25519(q2, x16); + return q2; + } + exports2.scalarMult = scalarMult; + function scalarMultBase(n4) { + return scalarMult(n4, _9); + } + exports2.scalarMultBase = scalarMultBase; + function generateKeyPairFromSeed(seed) { + if (seed.length !== exports2.SECRET_KEY_LENGTH) { + throw new Error(`x25519: seed must be ${exports2.SECRET_KEY_LENGTH} bytes`); + } + const secretKey = new Uint8Array(seed); + const publicKey = scalarMultBase(secretKey); + return { + publicKey, + secretKey + }; + } + exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; + function generateKeyPair2(prng) { + const seed = (0, random_1.randomBytes)(32, prng); + const result = generateKeyPairFromSeed(seed); + (0, wipe_12.wipe)(seed); + return result; + } + exports2.generateKeyPair = generateKeyPair2; + function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { + if (mySecretKey.length !== exports2.PUBLIC_KEY_LENGTH) { + throw new Error("X25519: incorrect secret key length"); + } + if (theirPublicKey.length !== exports2.PUBLIC_KEY_LENGTH) { + throw new Error("X25519: incorrect public key length"); + } + const result = scalarMult(mySecretKey, theirPublicKey); + if (rejectZero) { + let zeros = 0; + for (let i2 = 0; i2 < result.length; i2++) { + zeros |= result[i2]; + } + if (zeros === 0) { + throw new Error("X25519: invalid shared key"); + } + } + return result; + } + exports2.sharedKey = sharedKey; +})(x25519); +const C$1 = { 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" } }; +const Ir$1 = ":"; +function dn(e2) { + const [t2, r3] = e2.split(Ir$1); + return { namespace: t2, reference: r3 }; +} +function _r$1(e2, t2) { + return e2.includes(":") ? [e2] : t2.chains || []; +} +var Qo = Object.defineProperty, bn = Object.getOwnPropertySymbols, Jo = Object.prototype.hasOwnProperty, Go = Object.prototype.propertyIsEnumerable, yn = (e2, t2, r3) => t2 in e2 ? Qo(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, wn = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Jo.call(t2, r3) && yn(e2, r3, t2[r3]); + if (bn) + for (var r3 of bn(t2)) + Go.call(t2, r3) && yn(e2, r3, t2[r3]); + return e2; +}; +const xn = "ReactNative", qt$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, En = "js"; +function pi() { + return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; +} +function er$1() { + return !getDocument_1() && !!getNavigator_1() && navigator.product === xn; +} +function pr$1() { + return !pi() && !!getNavigator_1() && !!getDocument_1(); +} +function We$2() { + return er$1() ? qt$1.reactNative : pi() ? qt$1.node : pr$1() ? qt$1.browser : qt$1.unknown; +} +function Wo() { + var e2; + try { + return er$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e2 = global.Application) == null ? void 0 : e2.applicationId : void 0; + } catch { + return; + } +} +function Sn(e2, t2) { + let r3 = queryString.parse(e2); + return r3 = wn(wn({}, r3), t2), e2 = queryString.stringify(r3), e2; +} +function Xo() { + return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; +} +function Nn() { + if (We$2() === qt$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { + const { OS: r3, Version: i2 } = global.Platform; + return [r3, i2].join("-"); + } + const e2 = detect(); + if (e2 === null) + return "unknown"; + const t2 = e2.os ? e2.os.replace(" ", "").toLowerCase() : "unknown"; + return e2.type === "browser" ? [t2, e2.name, e2.version].join("-") : [t2, e2.version].join("-"); +} +function In() { + var e2; + const t2 = We$2(); + return t2 === qt$1.browser ? [t2, ((e2 = getLocation_1()) == null ? void 0 : e2.host) || "unknown"].join(":") : t2; +} +function _n(e2, t2, r3) { + const i2 = Nn(), n4 = In(); + return [[e2, t2].join("-"), [En, r3].join("-"), i2, n4].join("/"); +} +function $o({ protocol: e2, version: t2, relayUrl: r3, sdkVersion: i2, auth: n4, projectId: o2, useOnCloseEvent: h4, bundleId: p2 }) { + const b3 = r3.split("?"), m3 = _n(e2, t2, i2), w3 = { auth: n4, ua: m3, projectId: o2, useOnCloseEvent: h4 || void 0, origin: p2 || void 0 }, y3 = Sn(b3[1] || "", w3); + return b3[0] + "?" + y3; +} +function _e$1(e2, t2) { + return e2.filter((r3) => t2.includes(r3)).length === e2.length; +} +function i0(e2) { + return Object.fromEntries(e2.entries()); +} +function n0(e2) { + return new Map(Object.entries(e2)); +} +function a0(e2 = cjs$3.FIVE_MINUTES, t2) { + const r3 = cjs$3.toMiliseconds(e2 || cjs$3.FIVE_MINUTES); + let i2, n4, o2; + return { resolve: (h4) => { + o2 && i2 && (clearTimeout(o2), i2(h4)); + }, reject: (h4) => { + o2 && n4 && (clearTimeout(o2), n4(h4)); + }, done: () => new Promise((h4, p2) => { + o2 = setTimeout(() => { + p2(new Error(t2)); + }, r3), i2 = h4, n4 = p2; + }) }; +} +function u0(e2, t2, r3) { + return new Promise(async (i2, n4) => { + const o2 = setTimeout(() => n4(new Error(r3)), t2); + try { + const h4 = await e2; + i2(h4); + } catch (h4) { + n4(h4); + } + clearTimeout(o2); + }); +} +function vi(e2, t2) { + if (typeof t2 == "string" && t2.startsWith(`${e2}:`)) + return t2; + if (e2.toLowerCase() === "topic") { + if (typeof t2 != "string") + throw new Error('Value must be "string" for expirer target type: topic'); + return `topic:${t2}`; + } else if (e2.toLowerCase() === "id") { + if (typeof t2 != "number") + throw new Error('Value must be "number" for expirer target type: id'); + return `id:${t2}`; + } + throw new Error(`Unknown expirer target type: ${e2}`); +} +function h0(e2) { + return vi("topic", e2); +} +function c0(e2) { + return vi("id", e2); +} +function l0(e2) { + const [t2, r3] = e2.split(":"), i2 = { id: void 0, topic: void 0 }; + if (t2 === "topic" && typeof r3 == "string") + i2.topic = r3; + else if (t2 === "id" && Number.isInteger(Number(r3))) + i2.id = Number(r3); + else + throw new Error(`Invalid target, expected id:number or topic:string, got ${t2}:${r3}`); + return i2; +} +function d0(e2, t2) { + return cjs$3.fromMiliseconds(Date.now() + cjs$3.toMiliseconds(e2)); +} +function p0(e2) { + return Date.now() >= cjs$3.toMiliseconds(e2); +} +function v0(e2, t2) { + return `${e2}${t2 ? `:${t2}` : ""}`; +} +function ge$1(e2 = [], t2 = []) { + return [.../* @__PURE__ */ new Set([...e2, ...t2])]; +} +async function m0({ id: e2, topic: t2, wcDeepLink: r3 }) { + try { + if (!r3) + return; + const i2 = typeof r3 == "string" ? JSON.parse(r3) : r3; + let n4 = i2 == null ? void 0 : i2.href; + if (typeof n4 != "string") + return; + n4.endsWith("/") && (n4 = n4.slice(0, -1)); + const o2 = `${n4}/wc?requestId=${e2}&sessionTopic=${t2}`, h4 = We$2(); + h4 === qt$1.browser ? o2.startsWith("https://") || o2.startsWith("http://") ? window.open(o2, "_blank", "noreferrer noopener") : window.open(o2, "_self", "noreferrer noopener") : h4 === qt$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(o2); + } catch (i2) { + console.error(i2); + } +} +async function g0(e2, t2) { + try { + return await e2.getItem(t2) || (pr$1() ? localStorage.getItem(t2) : void 0); + } catch (r3) { + console.error(r3); + } +} +var On$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function A0$1(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; +} +var Pn$1 = { exports: {} }; +/** +* [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 +*/ +(function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On$1 : o2 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s2(u3, E2, u3).update(B2)[_3](); + }; + }, H2 = function(u3, E2, _3) { + return function(B2, R2) { + return new s2(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s2(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H2(u3, E2, "hex"); + return _3.create = function(B2) { + return new s2(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H2, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s2(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s2(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N2[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; + } + return this; + }, s2.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s2.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s2.call(this, u3, E2, _3); + } + v3.prototype = new s2(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne, Ie; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z2 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z2 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _3 = D2 ^ (Z2 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne = u3[42] << 2 | u3[43] >>> 30, Ie = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne, u3[45] = Me2 ^ ~Se2 & Ie, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne & St2, u3[47] = Se2 ^ ~Ie & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne ^ ~St2 & Ve2, u3[49] = Ie ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); +})(Pn$1); +var b0 = Pn$1.exports; +const y0$1 = "logger/5.7.0"; +let Dn$1 = false, Fn$1 = false; +const Cr$2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let Tn$1 = Cr$2.default, gi$1 = null; +function w0$1() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; + } + return null; +} +const Un$1 = w0$1(); +var Ai$1; +(function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; +})(Ai$1 || (Ai$1 = {})); +var re$2; +(function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; +})(re$2 || (re$2 = {})); +const kn$1 = "0123456789abcdef"; +let L$3 = class L2 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); + } + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr$2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn$1 > Cr$2[i2]) && console.log.apply(console, r3); + } + debug(...t2) { + this._log(L2.levels.DEBUG, t2); + } + info(...t2) { + this._log(L2.levels.INFO, t2); + } + warn(...t2) { + this._log(L2.levels.WARNING, t2); + } + makeError(t2, r3, i2) { + if (Fn$1) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L2.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn$1[m3[y3] >> 4], w3 += kn$1[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o2 = t2; + let h4 = ""; + switch (r3) { + case re$2.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; + } + case re$2.CALL_EXCEPTION: + case re$2.INSUFFICIENT_FUNDS: + case re$2.MISSING_NEW: + case re$2.NONCE_EXPIRED: + case re$2.REPLACEMENT_UNDERPRICED: + case re$2.TRANSACTION_REPLACED: + case re$2.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; + } + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; + } + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); + } + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L2.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); + } + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); + } + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); + } + checkNormalize(t2) { + Un$1 && this.throwError("platform missing String.prototype.normalize", L2.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un$1 }); + } + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); + } + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L2.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L2.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); + } + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r3.name }); + } + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L2.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r3.name }); + } + static globalLogger() { + return gi$1 || (gi$1 = new L2(y0$1)), gi$1; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn$1) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); + } + Fn$1 = !!t2, Dn$1 = !!r3; + } + static setLogLevel(t2) { + const r3 = Cr$2[t2.toLowerCase()]; + if (r3 == null) { + L2.globalLogger().warn("invalid log level - " + t2); + return; + } + Tn$1 = r3; + } + static from(t2) { + return new L2(t2); + } +}; +L$3.errors = re$2, L$3.levels = Ai$1; +const x0$1 = "bytes/5.7.0", Dt$2 = new L$3(x0$1); +function qn$1(e2) { + return !!e2.toHexString; +} +function rr$2(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr$2(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; +} +function M0(e2) { + return Qt$1(e2) && !(e2.length % 2) || ir$2(e2); +} +function Kn$1(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; +} +function ir$2(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn$1(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn$1(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; +} +function Ot$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr$2(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2) && (e2 = e2.toHexString()), Qt$1(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr$2(new Uint8Array(i2)); + } + return ir$2(e2) ? rr$2(new Uint8Array(e2)) : Dt$2.throwArgumentError("invalid arrayify value", "value", e2); +} +function E0(e2) { + const t2 = e2.map((n4) => Ot$2(n4)), r3 = t2.reduce((n4, o2) => n4 + o2.length, 0), i2 = new Uint8Array(r3); + return t2.reduce((n4, o2) => (i2.set(o2, n4), n4 + o2.length), 0), rr$2(i2); +} +function S0(e2, t2) { + e2 = Ot$2(e2), e2.length > t2 && Dt$2.throwArgumentError("value out of range", "value", arguments[0]); + const r3 = new Uint8Array(t2); + return r3.set(e2, t2 - e2.length), rr$2(r3); +} +function Qt$1(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2 && e2.length !== 2 + 2 * t2); +} +const bi$1 = "0123456789abcdef"; +function Kt$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi$1[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2)) + return e2.toHexString(); + if (Qt$1(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir$2(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi$1[(n4 & 240) >> 4] + bi$1[n4 & 15]; + } + return r3; + } + return Dt$2.throwArgumentError("invalid hexlify value", "value", e2); +} +function N0(e2) { + if (typeof e2 != "string") + e2 = Kt$2(e2); + else if (!Qt$1(e2) || e2.length % 2) + return null; + return (e2.length - 2) / 2; +} +function Hn(e2, t2, r3) { + return typeof e2 != "string" ? e2 = Kt$2(e2) : (!Qt$1(e2) || e2.length % 2) && Dt$2.throwArgumentError("invalid hexData", "value", e2), t2 = 2 + 2 * t2, r3 != null ? "0x" + e2.substring(t2, 2 + 2 * r3) : "0x" + e2.substring(t2); +} +function oe$1(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt$2(e2) : Qt$1(e2) || Dt$2.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt$2.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; +} +function zn(e2) { + const t2 = { r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0, yParityAndS: "0x", compact: "0x" }; + if (M0(e2)) { + let r3 = Ot$2(e2); + r3.length === 64 ? (t2.v = 27 + (r3[32] >> 7), r3[32] &= 127, t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64))) : r3.length === 65 ? (t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64)), t2.v = r3[64]) : Dt$2.throwArgumentError("invalid signature string", "signature", e2), t2.v < 27 && (t2.v === 0 || t2.v === 1 ? t2.v += 27 : Dt$2.throwArgumentError("signature invalid v byte", "signature", e2)), t2.recoveryParam = 1 - t2.v % 2, t2.recoveryParam && (r3[32] |= 128), t2._vs = Kt$2(r3.slice(32, 64)); + } else { + if (t2.r = e2.r, t2.s = e2.s, t2.v = e2.v, t2.recoveryParam = e2.recoveryParam, t2._vs = e2._vs, t2._vs != null) { + const n4 = S0(Ot$2(t2._vs), 32); + t2._vs = Kt$2(n4); + const o2 = n4[0] >= 128 ? 1 : 0; + t2.recoveryParam == null ? t2.recoveryParam = o2 : t2.recoveryParam !== o2 && Dt$2.throwArgumentError("signature recoveryParam mismatch _vs", "signature", e2), n4[0] &= 127; + const h4 = Kt$2(n4); + t2.s == null ? t2.s = h4 : t2.s !== h4 && Dt$2.throwArgumentError("signature v mismatch _vs", "signature", e2); + } + if (t2.recoveryParam == null) + t2.v == null ? Dt$2.throwArgumentError("signature missing v and recoveryParam", "signature", e2) : t2.v === 0 || t2.v === 1 ? t2.recoveryParam = t2.v : t2.recoveryParam = 1 - t2.v % 2; + else if (t2.v == null) + t2.v = 27 + t2.recoveryParam; + else { + const n4 = t2.v === 0 || t2.v === 1 ? t2.v : 1 - t2.v % 2; + t2.recoveryParam !== n4 && Dt$2.throwArgumentError("signature recoveryParam mismatch v", "signature", e2); + } + t2.r == null || !Qt$1(t2.r) ? Dt$2.throwArgumentError("signature missing or invalid r", "signature", e2) : t2.r = oe$1(t2.r, 32), t2.s == null || !Qt$1(t2.s) ? Dt$2.throwArgumentError("signature missing or invalid s", "signature", e2) : t2.s = oe$1(t2.s, 32); + const r3 = Ot$2(t2.s); + r3[0] >= 128 && Dt$2.throwArgumentError("signature s out of range", "signature", e2), t2.recoveryParam && (r3[0] |= 128); + const i2 = Kt$2(r3); + t2._vs && (Qt$1(t2._vs) || Dt$2.throwArgumentError("signature invalid _vs", "signature", e2), t2._vs = oe$1(t2._vs, 32)), t2._vs == null ? t2._vs = i2 : t2._vs !== i2 && Dt$2.throwArgumentError("signature _vs mismatch v and s", "signature", e2); + } + return t2.yParityAndS = t2._vs, t2.compact = t2.r + t2.yParityAndS.substring(2), t2; +} +function yi(e2) { + return "0x" + b0.keccak_256(Ot$2(e2)); +} +var Ln$1 = { exports: {} }, I0$1 = {}, _0$1 = Object.freeze({ __proto__: null, default: I0$1 }), B0$1 = A0$1(_0$1); +(function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; + } + function o2(A2, f3, a3) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r3.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0$1.Buffer; + } catch { + } + o2.isBN = function(f3) { + return f3 instanceof o2 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o2.wordSize && Array.isArray(f3.words); + }, o2.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o2.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o2.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o2.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o2.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + } + this._strip(); + }; + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o2.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v3 = c2; v3 < l2; v3 += d5) + s2 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o2.prototype._move = function(f3) { + w3(f3, this); + }, o2.prototype.clone = function() { + var f3 = new o2(null); + return this.copy(f3), f3; + }, o2.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o2.prototype.inspect = y3; + } + else + o2.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s2 = I2[f3], v3 = N2[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s2 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o2.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o2.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o2.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o2.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o2.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o2.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; + } + return f3; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o2.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o2.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o2.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o2.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o2.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o2.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o2.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o2.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o2.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o2.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o2.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o2.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o2.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o2.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o2.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s2, f3.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s2 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s2] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s2] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s2, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te = d5[6] | 0, et2 = Te & 8191, rt2 = Te >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le = g3[3] | 0, vt2 = Le & 8191, mt2 = Le >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s2 = Math.imul(u3, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s2 = s2 + Math.imul(u3, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s2 = s2 + Math.imul(u3, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s2 = s2 + Math.imul(u3, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ne >>> 26) | 0, Ne &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v3 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s2 = s2 + Math.imul(u3, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v3 = v3 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s2 = s2 + Math.imul(u3, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v3 = v3 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s2 = s2 + Math.imul(u3, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v3 = v3 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s2 = s2 + Math.imul(u3, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v3 = v3 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s2 = s2 + Math.imul(u3, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v3 = v3 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s2 = s2 + Math.imul(u3, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v3 = v3 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v3 = v3 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v3 = v3 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v3 = v3 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v3 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne, x2[4] = Ie, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s2 = Math.max(0, g3 - A2.length + 1); s2 <= l2; s2++) { + var v3 = g3 - s2, k2 = A2.words[v3] | 0, u3 = f3.words[s2] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o2.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o2.prototype.mul = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o2.prototype.mulf = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o2.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o2.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o2.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o2(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o2.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o2.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v3 !== 0 || s2 >= d5); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o2.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o2.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o2.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o2.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o2.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o2.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o2.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o2.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o2.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o2.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o2.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s2; + if (a3 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v3 = 0; v3 < s2.length; v3++) + s2.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s2 && (s2.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s2 && (s2.words[u3] = E2); + } + return s2 && s2._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s2 || null, mod: d5 }; + }, o2.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o2(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o2(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o2(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o2.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o2.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o2.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o2.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o2.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o2.prototype.modn = function(f3) { + return this.modrn(f3); + }, o2.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o2.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o2.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s2), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s2 = 0, v3 = 1; !(c2.words[0] & v3) && s2 < 26; ++s2, v3 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o2.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o2.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o2.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o2.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; + } + } + return a3; + }, o2.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o2.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o2.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o2.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o2.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o2.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o2.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o2.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o2.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o2.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o2.red = function(f3) { + return new Y2(f3); + }, o2.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o2.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o2.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o2.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o2.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o2.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o2.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o2.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o2.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o2(f3, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o2(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o2._prime = function(f3) { + if (H2[f3]) + return H2[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H2[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o2._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v3 = this.pow(s2, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o2(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o2(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s2 = a3.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s2 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o2.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o2(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On$1); +})(Ln$1); +var K$2 = Ln$1.exports; +const jn$1 = "bignumber/5.7.0"; +var Rr$2 = K$2.BN; +const Ae$1 = new L$3(jn$1), wi$1 = {}, Qn$1 = 9007199254740991; +function C0$1(e2) { + return e2 != null && (V$2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt$1(e2) || typeof e2 == "bigint" || ir$2(e2)); +} +let Jn$1 = false; +let V$2 = class V { + constructor(t2, r3) { + t2 !== wi$1 && Ae$1.throwError("cannot call constructor directly; use BigNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); + } + fromTwos(t2) { + return Lt$2(j$2(this).fromTwos(t2)); + } + toTwos(t2) { + return Lt$2(j$2(this).toTwos(t2)); + } + abs() { + return this._hex[0] === "-" ? V.from(this._hex.substring(1)) : this; + } + add(t2) { + return Lt$2(j$2(this).add(j$2(t2))); + } + sub(t2) { + return Lt$2(j$2(this).sub(j$2(t2))); + } + div(t2) { + return V.from(t2).isZero() && Wt$3("division-by-zero", "div"), Lt$2(j$2(this).div(j$2(t2))); + } + mul(t2) { + return Lt$2(j$2(this).mul(j$2(t2))); + } + mod(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("division-by-zero", "mod"), Lt$2(j$2(this).umod(r3)); + } + pow(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("negative-power", "pow"), Lt$2(j$2(this).pow(r3)); + } + and(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "and"), Lt$2(j$2(this).and(r3)); + } + or(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "or"), Lt$2(j$2(this).or(r3)); + } + xor(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "xor"), Lt$2(j$2(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "mask"), Lt$2(j$2(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shl"), Lt$2(j$2(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shr"), Lt$2(j$2(this).shrn(t2)); + } + eq(t2) { + return j$2(this).eq(j$2(t2)); + } + lt(t2) { + return j$2(this).lt(j$2(t2)); + } + lte(t2) { + return j$2(this).lte(j$2(t2)); + } + gt(t2) { + return j$2(this).gt(j$2(t2)); + } + gte(t2) { + return j$2(this).gte(j$2(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j$2(this).isZero(); + } + toNumber() { + try { + return j$2(this).toNumber(); + } catch { + Wt$3("overflow", "toNumber", this.toString()); + } + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { + } + return Ae$1.throwError("this platform does not support BigInt", L$3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn$1 || (Jn$1 = true, Ae$1.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae$1.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L$3.errors.UNEXPECTED_ARGUMENT, {}) : Ae$1.throwError("BigNumber.toString does not accept parameters", L$3.errors.UNEXPECTED_ARGUMENT, {})), j$2(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V(wi$1, vr$1(t2)) : t2.match(/^-?[0-9]+$/) ? new V(wi$1, vr$1(new Rr$2(t2))) : Ae$1.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt$3("underflow", "BigNumber.from", t2), (t2 >= Qn$1 || t2 <= -Qn$1) && Wt$3("overflow", "BigNumber.from", t2), V.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V.from(r3.toString()); + if (ir$2(r3)) + return V.from(Kt$2(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V.from(i2); + } else { + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt$1(i2) || i2[0] === "-" && Qt$1(i2.substring(1)))) + return V.from(i2); + } + return Ae$1.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } +}; +function vr$1(e2) { + if (typeof e2 != "string") + return vr$1(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae$1.throwArgumentError("invalid hex", "value", e2), e2 = vr$1(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; +} +function Lt$2(e2) { + return V$2.from(vr$1(e2)); +} +function j$2(e2) { + const t2 = V$2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr$2("-" + t2.substring(3), 16) : new Rr$2(t2.substring(2), 16); +} +function Wt$3(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae$1.throwError(e2, L$3.errors.NUMERIC_FAULT, i2); +} +function R0(e2) { + return new Rr$2(e2, 36).toString(16); +} +const Ht$3 = new L$3(jn$1), mr$2 = {}, Gn$1 = V$2.from(0), Yn$1 = V$2.from(-1); +function Vn$1(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht$3.throwError(e2, L$3.errors.NUMERIC_FAULT, n4); +} +let gr$2 = "0"; +for (; gr$2.length < 256; ) + gr$2 += gr$2; +function xi$1(e2) { + if (typeof e2 != "number") + try { + e2 = V$2.from(e2).toNumber(); + } catch { + } + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr$2.substring(0, e2) : Ht$3.throwArgumentError("invalid decimal size", "decimals", e2); +} +function Mi$1(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + e2 = V$2.from(e2); + const i2 = e2.lt(Gn$1); + i2 && (e2 = e2.mul(Yn$1)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o2 : e2 = o2 + "." + n4, i2 && (e2 = "-" + e2), e2; +} +function be$2(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht$3.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht$3.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht$3.throwArgumentError("too many decimal points", "value", e2); + let o2 = n4[0], h4 = n4[1]; + for (o2 || (o2 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn$1("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V$2.from(o2), b3 = V$2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn$1)), m3; +} +let dr$2 = class dr { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi$1(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht$3.throwArgumentError("invalid fixed format", "format", t2), r3 = o2[1] !== "u", i2 = parseInt(o2[2]), n4 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht$3.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o2("signed", "boolean", r3), i2 = o2("width", "number", i2), n4 = o2("decimals", "number", n4); + } + return i2 % 8 && Ht$3.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht$3.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr(mr$2, r3, i2, n4); + } +}; +let Ut$2 = class Ut { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht$3.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn$1.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn$1.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht$3.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut.from("1" + gr$2.substring(0, t2), this.format), n4 = O0$1.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); + } + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht$3.throwArgumentError("invalid byte width", "width", t2); + const r3 = V$2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe$1(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0$1(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut.fromString(Mi$1(t2, r3), dr$2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3), n4 = be$2(t2, i2.decimals); + !i2.signed && n4.lt(Gn$1) && Vn$1("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n4.toTwos(i2.width).toHexString() : (o2 = n4.toHexString(), o2 = oe$1(o2, i2.width / 8)); + const h4 = Mi$1(n4, i2.decimals); + return new Ut(mr$2, o2, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3); + if (Ot$2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V$2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o2 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi$1(n4, i2.decimals); + return new Ut(mr$2, o2, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut.fromString(t2, r3); + if (ir$2(t2)) + return Ut.fromBytes(t2, r3); + try { + return Ut.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L$3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht$3.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } +}; +const Wn$1 = Ut$2.from(1), O0$1 = Ut$2.from("0.5"), P0 = "strings/5.7.0", Xn = new L$3(P0); +var Or$2; +(function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; +})(Or$2 || (Or$2 = {})); +var nr$2; +(function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; +})(nr$2 || (nr$2 = {})); +function Ei(e2, t2 = Or$2.current) { + t2 != Or$2.current && (Xn.checkNormalize(), e2 = e2.normalize(t2)); + let r3 = []; + for (let i2 = 0; i2 < e2.length; i2++) { + const n4 = e2.charCodeAt(i2); + if (n4 < 128) + r3.push(n4); + else if (n4 < 2048) + r3.push(n4 >> 6 | 192), r3.push(n4 & 63 | 128); + else if ((n4 & 64512) == 55296) { + i2++; + const o2 = e2.charCodeAt(i2); + if (i2 >= e2.length || (o2 & 64512) !== 56320) + throw new Error("invalid utf-8 string"); + const h4 = 65536 + ((n4 & 1023) << 10) + (o2 & 1023); + r3.push(h4 >> 18 | 240), r3.push(h4 >> 12 & 63 | 128), r3.push(h4 >> 6 & 63 | 128), r3.push(h4 & 63 | 128); + } else + r3.push(n4 >> 12 | 224), r3.push(n4 >> 6 & 63 | 128), r3.push(n4 & 63 | 128); + } + return Ot$2(r3); +} +function T0$1(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; +} +function Si$1(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; + }); + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o2 = n4.split(":"); + r3 += parseInt(o2[0], 16), i2[r3] = t2(o2[1]); + }), i2; +} +function $n$1(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); +} +$n$1("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si$1("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si$1("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si$1("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0$1), $n$1("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function U0$1(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot$2(t2); +} +function ef$1(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o2, h4) { + i2.call(o2, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); + }); + }; + return n4(e2, t2), r3; +} +function k0$1(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; +} +function q0$1(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y3; H2++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H2 < o2[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; + } + }); +} +function K0$1(e2) { + let t2 = 0; + return () => e2[t2++]; +} +function H0$1(e2) { + return K0$1(q0$1(e2)); +} +function z0$1(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; +} +function L0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; +} +function rf$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; +} +function j0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0$1(t2()); + return r3; +} +function Pr$2(e2, t2) { + let r3 = rf$1(e2(), e2), i2 = e2(), n4 = rf$1(i2, e2), o2 = L0$1(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o2[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; +} +function Q0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0$1(r3, e2)); + } + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0$1(r3, e2)); + } + return k0$1(ef$1(t2)); +} +function J0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); + } + return t2; +} +function nf$1(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0$1(e2, r3).forEach((o2, h4) => i2[h4].push(o2)); + return i2; +} +function G0$1(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0$1(t2), o2 = nf$1(n4.length, 1 + e2, t2); + return ef$1(o2.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; + }); + })); +} +function Y0$1(e2, t2) { + let r3 = 1 + t2(); + return nf$1(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); +} +function V0$1(e2) { + let t2 = Pr$2(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr$2(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o2 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o2, fe0f: h4, save: p2, check: b3 }; + } +} +function W0$1() { + return H0$1(U0$1("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); +} +const Dr$2 = W0$1(); +new Set(Pr$2(Dr$2)), new Set(Pr$2(Dr$2)), Q0$1(Dr$2), V0$1(Dr$2); +const X0$1 = new Uint8Array(32); +X0$1.fill(0); +const Z0 = `Ethereum Signed Message: +`; +function ff(e2) { + return typeof e2 == "string" && (e2 = Ei(e2)), yi(E0([Ei(Z0), Ei(String(e2.length)), e2])); +} +const ts$2 = "address/5.7.0", Ar$1 = new L$3(ts$2); +function of(e2) { + Qt$1(e2, 20) || Ar$1.throwArgumentError("invalid address", "address", e2), e2 = e2.toLowerCase(); + const t2 = e2.substring(2).split(""), r3 = new Uint8Array(40); + for (let n4 = 0; n4 < 40; n4++) + r3[n4] = t2[n4].charCodeAt(0); + const i2 = Ot$2(yi(r3)); + for (let n4 = 0; n4 < 40; n4 += 2) + i2[n4 >> 1] >> 4 >= 8 && (t2[n4] = t2[n4].toUpperCase()), (i2[n4 >> 1] & 15) >= 8 && (t2[n4 + 1] = t2[n4 + 1].toUpperCase()); + return "0x" + t2.join(""); +} +const es$2 = 9007199254740991; +function rs$2(e2) { + return Math.log10 ? Math.log10(e2) : Math.log(e2) / Math.LN10; +} +const Ni = {}; +for (let e2 = 0; e2 < 10; e2++) + Ni[String(e2)] = String(e2); +for (let e2 = 0; e2 < 26; e2++) + Ni[String.fromCharCode(65 + e2)] = String(10 + e2); +const sf = Math.floor(rs$2(es$2)); +function is$2(e2) { + e2 = e2.toUpperCase(), e2 = e2.substring(4) + e2.substring(0, 2) + "00"; + let t2 = e2.split("").map((i2) => Ni[i2]).join(""); + for (; t2.length >= sf; ) { + let i2 = t2.substring(0, sf); + t2 = parseInt(i2, 10) % 97 + t2.substring(i2.length); + } + let r3 = String(98 - parseInt(t2, 10) % 97); + for (; r3.length < 2; ) + r3 = "0" + r3; + return r3; +} +function ns$1(e2) { + let t2 = null; + if (typeof e2 != "string" && Ar$1.throwArgumentError("invalid address", "address", e2), e2.match(/^(0x)?[0-9a-fA-F]{40}$/)) + e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), t2 = of(e2), e2.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && t2 !== e2 && Ar$1.throwArgumentError("bad address checksum", "address", e2); + else if (e2.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + for (e2.substring(2, 4) !== is$2(e2) && Ar$1.throwArgumentError("bad icap checksum", "address", e2), t2 = R0(e2.substring(4)); t2.length < 40; ) + t2 = "0" + t2; + t2 = of("0x" + t2); + } else + Ar$1.throwArgumentError("invalid address", "address", e2); + return t2; +} +function br$1(e2, t2, r3) { + Object.defineProperty(e2, t2, { enumerable: true, value: r3, writable: false }); +} +const os$2 = new Uint8Array(32); +os$2.fill(0), V$2.from(-1); +const ss$3 = V$2.from(0), as$2 = V$2.from(1); +V$2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe$1(as$2.toHexString(), 32), oe$1(ss$3.toHexString(), 32); +var se$2 = {}, Q$2 = {}, yr$2 = af$1; +function af$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +af$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var Ii$1 = { exports: {} }; +typeof Object.create == "function" ? Ii$1.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); +} : Ii$1.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; + } +}; +var us$2 = yr$2, hs$2 = Ii$1.exports; +Q$2.inherits = hs$2; +function cs$2(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; +} +function ls$2(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o2 = e2.charCodeAt(n4); + o2 < 128 ? r3[i2++] = o2 : o2 < 2048 ? (r3[i2++] = o2 >> 6 | 192, r3[i2++] = o2 & 63 | 128) : cs$2(e2, n4) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o2 >> 18 | 240, r3[i2++] = o2 >> 12 & 63 | 128, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128) : (r3[i2++] = o2 >> 12 | 224, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128); + } + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; +} +Q$2.toArray = ls$2; +function ds$2(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf$1(e2[r3].toString(16)); + return t2; +} +Q$2.toHex = ds$2; +function uf$1(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; +} +Q$2.htonl = uf$1; +function ps$2(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf$1(n4)), r3 += cf$1(n4.toString(16)); + } + return r3; +} +Q$2.toHex32 = ps$2; +function hf$1(e2) { + return e2.length === 1 ? "0" + e2 : e2; +} +Q$2.zero2 = hf$1; +function cf$1(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; +} +Q$2.zero8 = cf$1; +function vs$2(e2, t2, r3, i2) { + var n4 = r3 - t2; + us$2(n4 % 4 === 0); + for (var o2 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o2.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h4] = b3 >>> 0; + } + return o2; +} +Q$2.join32 = vs$2; +function ms$3(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r3[n4] = o2 >>> 24, r3[n4 + 1] = o2 >>> 16 & 255, r3[n4 + 2] = o2 >>> 8 & 255, r3[n4 + 3] = o2 & 255) : (r3[n4 + 3] = o2 >>> 24, r3[n4 + 2] = o2 >>> 16 & 255, r3[n4 + 1] = o2 >>> 8 & 255, r3[n4] = o2 & 255); + } + return r3; +} +Q$2.split32 = ms$3; +function gs$2(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; +} +Q$2.rotr32 = gs$2; +function As$2(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; +} +Q$2.rotl32 = As$2; +function bs$2(e2, t2) { + return e2 + t2 >>> 0; +} +Q$2.sum32 = bs$2; +function ys$2(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; +} +Q$2.sum32_3 = ys$2; +function ws$2(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; +} +Q$2.sum32_4 = ws$2; +function xs$2(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; +} +Q$2.sum32_5 = xs$2; +function Ms$2(e2, t2, r3, i2) { + var n4 = e2[t2], o2 = e2[t2 + 1], h4 = i2 + o2 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; +} +Q$2.sum64 = Ms$2; +function Es$2(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o2 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o2 >>> 0; +} +Q$2.sum64_hi = Es$2; +function Ss$2(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; +} +Q$2.sum64_lo = Ss$2; +function Ns$2(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o2 >>> 0, b3 += m3 < o2 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; +} +Q$2.sum64_4_hi = Ns$2; +function Is$2(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = t2 + i2 + o2 + p2; + return b3 >>> 0; +} +Q$2.sum64_4_lo = Is$2; +function _s$2(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o2 >>> 0, w3 += y3 < o2 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; +} +Q$2.sum64_5_hi = _s$2; +function Bs$2(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = t2 + i2 + o2 + p2 + m3; + return w3 >>> 0; +} +Q$2.sum64_5_lo = Bs$2; +function Cs$2(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; +} +Q$2.rotr64_hi = Cs$2; +function Rs$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q$2.rotr64_lo = Rs$2; +function Os$2(e2, t2, r3) { + return e2 >>> r3; +} +Q$2.shr64_hi = Os$2; +function Ps$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q$2.shr64_lo = Ps$2; +var fr$1 = {}, lf$1 = Q$2, Ds$2 = yr$2; +function Fr$2() { + 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; +} +fr$1.BlockHash = Fr$2, Fr$2.prototype.update = function(t2, r3) { + if (t2 = lf$1.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf$1.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; +}, Fr$2.prototype.digest = function(t2) { + return this.update(this._pad()), Ds$2(this.pending === null), this._digest(t2); +}, Fr$2.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n4[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 & 255; + } else + for (n4[o2++] = t2 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + return n4; +}; +var or$2 = {}, ae$1 = {}, Fs$2 = Q$2, ue$1 = Fs$2.rotr32; +function Ts$2(e2, t2, r3, i2) { + if (e2 === 0) + return df$1(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf$1(t2, r3, i2); + if (e2 === 2) + return pf$1(t2, r3, i2); +} +ae$1.ft_1 = Ts$2; +function df$1(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; +} +ae$1.ch32 = df$1; +function pf$1(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; +} +ae$1.maj32 = pf$1; +function vf$1(e2, t2, r3) { + return e2 ^ t2 ^ r3; +} +ae$1.p32 = vf$1; +function Us$2(e2) { + return ue$1(e2, 2) ^ ue$1(e2, 13) ^ ue$1(e2, 22); +} +ae$1.s0_256 = Us$2; +function ks$2(e2) { + return ue$1(e2, 6) ^ ue$1(e2, 11) ^ ue$1(e2, 25); +} +ae$1.s1_256 = ks$2; +function qs$2(e2) { + return ue$1(e2, 7) ^ ue$1(e2, 18) ^ e2 >>> 3; +} +ae$1.g0_256 = qs$2; +function Ks$2(e2) { + return ue$1(e2, 17) ^ ue$1(e2, 19) ^ e2 >>> 10; +} +ae$1.g1_256 = Ks$2; +var sr$2 = Q$2, Hs$2 = fr$1, zs$2 = ae$1, _i$1 = sr$2.rotl32, wr$1 = sr$2.sum32, Ls$2 = sr$2.sum32_5, js$2 = zs$2.ft_1, mf$1 = Hs$2.BlockHash, Qs$2 = [1518500249, 1859775393, 2400959708, 3395469782]; +function he$1() { + if (!(this instanceof he$1)) + return new he$1(); + mf$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); +} +sr$2.inherits(he$1, mf$1); +var Js$2 = he$1; +he$1.blockSize = 512, he$1.outSize = 160, he$1.hmacStrength = 80, he$1.padLength = 64, he$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i$1(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls$2(_i$1(o2, 5), js$2(w3, h4, p2, b3), m3, i2[n4], Qs$2[w3]); + m3 = b3, b3 = p2, p2 = _i$1(h4, 30), h4 = o2, o2 = y3; + } + this.h[0] = wr$1(this.h[0], o2), this.h[1] = wr$1(this.h[1], h4), this.h[2] = wr$1(this.h[2], p2), this.h[3] = wr$1(this.h[3], b3), this.h[4] = wr$1(this.h[4], m3); +}, he$1.prototype._digest = function(t2) { + return t2 === "hex" ? sr$2.toHex32(this.h, "big") : sr$2.split32(this.h, "big"); +}; +var ar$2 = Q$2, Gs$2 = fr$1, ur$2 = ae$1, Ys$2 = yr$2, ie$3 = ar$2.sum32, Vs$2 = ar$2.sum32_4, Ws$2 = ar$2.sum32_5, Xs$2 = ur$2.ch32, Zs$2 = ur$2.maj32, $s$2 = ur$2.s0_256, ta$1 = ur$2.s1_256, ea$1 = ur$2.g0_256, ra$1 = ur$2.g1_256, gf$1 = Gs$2.BlockHash, ia$1 = [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 ce$1() { + if (!(this instanceof ce$1)) + return new ce$1(); + gf$1.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia$1, this.W = new Array(64); +} +ar$2.inherits(ce$1, gf$1); +var Af$1 = ce$1; +ce$1.blockSize = 512, ce$1.outSize = 256, ce$1.hmacStrength = 192, ce$1.padLength = 64, ce$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs$2(ra$1(i2[n4 - 2]), i2[n4 - 7], ea$1(i2[n4 - 15]), i2[n4 - 16]); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys$2(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws$2(S2, ta$1(m3), Xs$2(m3, w3, y3), this.k[n4], i2[n4]), N2 = ie$3($s$2(o2), Zs$2(o2, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie$3(b3, I2), b3 = p2, p2 = h4, h4 = o2, o2 = ie$3(I2, N2); + } + this.h[0] = ie$3(this.h[0], o2), this.h[1] = ie$3(this.h[1], h4), this.h[2] = ie$3(this.h[2], p2), this.h[3] = ie$3(this.h[3], b3), this.h[4] = ie$3(this.h[4], m3), this.h[5] = ie$3(this.h[5], w3), this.h[6] = ie$3(this.h[6], y3), this.h[7] = ie$3(this.h[7], S2); +}, ce$1.prototype._digest = function(t2) { + return t2 === "hex" ? ar$2.toHex32(this.h, "big") : ar$2.split32(this.h, "big"); +}; +var Bi$1 = Q$2, bf$1 = Af$1; +function ye$2() { + if (!(this instanceof ye$2)) + return new ye$2(); + bf$1.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; +} +Bi$1.inherits(ye$2, bf$1); +var na$1 = ye$2; +ye$2.blockSize = 512, ye$2.outSize = 224, ye$2.hmacStrength = 192, ye$2.padLength = 64, ye$2.prototype._digest = function(t2) { + return t2 === "hex" ? Bi$1.toHex32(this.h.slice(0, 7), "big") : Bi$1.split32(this.h.slice(0, 7), "big"); +}; +var jt$2 = Q$2, fa$1 = fr$1, oa$1 = yr$2, le$1 = jt$2.rotr64_hi, de$2 = jt$2.rotr64_lo, yf$1 = jt$2.shr64_hi, wf$1 = jt$2.shr64_lo, Be$3 = jt$2.sum64, Ci$1 = jt$2.sum64_hi, Ri$1 = jt$2.sum64_lo, sa$1 = jt$2.sum64_4_hi, aa$1 = jt$2.sum64_4_lo, ua$1 = jt$2.sum64_5_hi, ha$1 = jt$2.sum64_5_lo, xf$1 = fa$1.BlockHash, ca$1 = [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 ne$2() { + if (!(this instanceof ne$2)) + return new ne$2(); + xf$1.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca$1, this.W = new Array(160); +} +jt$2.inherits(ne$2, xf$1); +var Mf$1 = ne$2; +ne$2.blockSize = 1024, ne$2.outSize = 512, ne$2.hmacStrength = 192, ne$2.padLength = 128, ne$2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o2 = xa$1(i2[n4 - 4], i2[n4 - 3]), h4 = Ma$1(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya$1(i2[n4 - 30], i2[n4 - 29]), w3 = wa$1(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa$1(o2, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa$1(o2, h4, p2, b3, m3, w3, y3, S2); + } +}, ne$2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o2 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa$1(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa$1(S2, I2), W2 = ba$1(S2, I2), Rt2 = la$1(S2, I2, N2, C2, F2), Yt3 = da$1(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua$1(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha$1(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H2 = ma$1(n4, o2), z2 = ga$1(n4, o2), Pt2 = pa$1(n4, o2, h4, p2, b3), W2 = va$1(n4, o2, h4, p2, b3, m3); + var d5 = Ci$1(H2, z2, Pt2, W2), g3 = Ri$1(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci$1(w3, y3, a3, c2), I2 = Ri$1(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o2, n4 = Ci$1(a3, c2, d5, g3), o2 = Ri$1(a3, c2, d5, g3); + } + Be$3(this.h, 0, n4, o2), Be$3(this.h, 2, h4, p2), Be$3(this.h, 4, b3, m3), Be$3(this.h, 6, w3, y3), Be$3(this.h, 8, S2, I2), Be$3(this.h, 10, N2, C2), Be$3(this.h, 12, F2, U2), Be$3(this.h, 14, J2, Bt2); +}, ne$2.prototype._digest = function(t2) { + return t2 === "hex" ? jt$2.toHex32(this.h, "big") : jt$2.split32(this.h, "big"); +}; +function la$1(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ ~e2 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function da$1(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ ~t2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function pa$1(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function va$1(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function ma$1(e2, t2) { + var r3 = le$1(e2, t2, 28), i2 = le$1(t2, e2, 2), n4 = le$1(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ga$1(e2, t2) { + var r3 = de$2(e2, t2, 28), i2 = de$2(t2, e2, 2), n4 = de$2(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Aa$1(e2, t2) { + var r3 = le$1(e2, t2, 14), i2 = le$1(e2, t2, 18), n4 = le$1(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ba$1(e2, t2) { + var r3 = de$2(e2, t2, 14), i2 = de$2(e2, t2, 18), n4 = de$2(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ya$1(e2, t2) { + var r3 = le$1(e2, t2, 1), i2 = le$1(e2, t2, 8), n4 = yf$1(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function wa$1(e2, t2) { + var r3 = de$2(e2, t2, 1), i2 = de$2(e2, t2, 8), n4 = wf$1(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function xa$1(e2, t2) { + var r3 = le$1(e2, t2, 19), i2 = le$1(t2, e2, 29), n4 = yf$1(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Ma$1(e2, t2) { + var r3 = de$2(e2, t2, 19), i2 = de$2(t2, e2, 29), n4 = wf$1(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +var Oi$1 = Q$2, Ef$1 = Mf$1; +function we$1() { + if (!(this instanceof we$1)) + return new we$1(); + Ef$1.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; +} +Oi$1.inherits(we$1, Ef$1); +var Ea$1 = we$1; +we$1.blockSize = 1024, we$1.outSize = 384, we$1.hmacStrength = 192, we$1.padLength = 128, we$1.prototype._digest = function(t2) { + return t2 === "hex" ? Oi$1.toHex32(this.h.slice(0, 12), "big") : Oi$1.split32(this.h.slice(0, 12), "big"); +}, or$2.sha1 = Js$2, or$2.sha224 = na$1, or$2.sha256 = Af$1, or$2.sha384 = Ea$1, or$2.sha512 = Mf$1; +var Sf$1 = {}, Xe$3 = Q$2, Sa$1 = fr$1, Tr$2 = Xe$3.rotl32, Nf$1 = Xe$3.sum32, xr$2 = Xe$3.sum32_3, If$1 = Xe$3.sum32_4, _f$1 = Sa$1.BlockHash; +function pe$2() { + if (!(this instanceof pe$2)) + return new pe$2(); + _f$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; +} +Xe$3.inherits(pe$2, _f$1), Sf$1.ripemd160 = pe$2, pe$2.blockSize = 512, pe$2.outSize = 160, pe$2.hmacStrength = 192, pe$2.padLength = 64, pe$2.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o2 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o2, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf$1(Tr$2(If$1(i2, Bf$1(I2, n4, o2, h4), t2[_a$1[I2] + r3], Na$1(I2)), Ca$1[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr$2(o2, 10), o2 = n4, n4 = N2, N2 = Nf$1(Tr$2(If$1(b3, Bf$1(79 - I2, m3, w3, y3), t2[Ba$1[I2] + r3], Ia$1(I2)), Ra$1[I2]), S2), b3 = S2, S2 = y3, y3 = Tr$2(w3, 10), w3 = m3, m3 = N2; + } + N2 = xr$2(this.h[1], o2, y3), this.h[1] = xr$2(this.h[2], h4, S2), this.h[2] = xr$2(this.h[3], p2, b3), this.h[3] = xr$2(this.h[4], i2, m3), this.h[4] = xr$2(this.h[0], n4, w3), this.h[0] = N2; +}, pe$2.prototype._digest = function(t2) { + return t2 === "hex" ? Xe$3.toHex32(this.h, "little") : Xe$3.split32(this.h, "little"); +}; +function Bf$1(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); +} +function Na$1(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; +} +function Ia$1(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; +} +var _a$1 = [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], Ba$1 = [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], Ca$1 = [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], Ra$1 = [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], Oa$1 = Q$2, Pa$1 = yr$2; +function hr$2(e2, t2, r3) { + if (!(this instanceof hr$2)) + return new hr$2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa$1.toArray(t2, r3)); +} +var Da$1 = hr$2; +hr$2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa$1(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); +}, hr$2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; +}, hr$2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); +}, function(e2) { + var t2 = e2; + t2.utils = Q$2, t2.common = fr$1, t2.sha = or$2, t2.ripemd = Sf$1, t2.hmac = Da$1, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; +}(se$2); +function cr$2(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa$1(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; +} +function Fa$1() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var Pi$1 = Cf$1; +function Cf$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +Cf$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var fe$2 = cr$2(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); + } + return b3; + } + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; + } + r3.zero2 = n4; + function o2(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o2, r3.encode = function(p2, b3) { + return b3 === "hex" ? o2(p2) : p2; + }; +}), Jt$3 = cr$2(function(e2, t2) { + var r3 = t2; + r3.assert = Pi$1, r3.toArray = fe$2.toArray, r3.zero2 = fe$2.zero2, r3.toHex = fe$2.toHex, r3.encode = fe$2.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N2 = 0; N2 < y3.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N2] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N2 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o2(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o2; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K$2(b3, "hex", "le"); + } + r3.intFromLE = p2; +}), Ur$2 = Jt$3.getNAF, Ta$1 = Jt$3.getJSF, kr$2 = Jt$3.assert; +function Ce$1(e2, t2) { + this.type = e2, this.p = new K$2(t2.p, 16), this.red = t2.prime ? K$2.red(t2.prime) : K$2.mont(this.p), this.zero = new K$2(0).toRed(this.red), this.one = new K$2(1).toRed(this.red), this.two = new K$2(2).toRed(this.red), this.n = t2.n && new K$2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); +} +var Ze$2 = Ce$1; +Ce$1.prototype.point = function() { + throw new Error("Not implemented"); +}, Ce$1.prototype.validate = function() { + throw new Error("Not implemented"); +}, Ce$1.prototype._fixedNafMul = function(t2, r3) { + kr$2(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur$2(r3, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); +}, Ce$1.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o2 = n4.points, h4 = Ur$2(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr$2(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o2[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o2[w3 - 1 >> 1]) : p2 = p2.add(o2[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; +}, Ce$1.prototype._wnafMulAdd = function(t2, r3, i2, n4, o2) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N2 = w3 - 1, C2 = w3; + if (h4[N2] !== 1 || h4[C2] !== 1) { + b3[N2] = Ur$2(i2[N2], h4[N2], this._bitLength), b3[C2] = Ur$2(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N2].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; + } + var F2 = [r3[N2], null, null, r3[C2]]; + r3[N2].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N2].add(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())) : r3[N2].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].add(r3[C2].neg())) : (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta$1(i2[N2], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N2] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N2][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; + } + if (w3 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o2 ? H2 : H2.toP(); +}; +function Xt$3(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; +} +Ce$1.BasePoint = Xt$3, Xt$3.prototype.eq = function() { + throw new Error("Not implemented"); +}, Xt$3.prototype.validate = function() { + return this.curve.validate(this); +}, Ce$1.prototype.decodePoint = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr$2(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr$2(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); +}, Xt$3.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); +}, Xt$3.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); +}, Xt$3.prototype.encode = function(t2, r3) { + return Jt$3.encode(this._encode(r3), t2); +}, Xt$3.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; +}, Xt$3.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; +}, Xt$3.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o2 = 0; o2 < r3; o2 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; +}, Xt$3.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r3[o2] = r3[o2 - 1].add(n4); + return { wnd: t2, points: r3 }; +}, Xt$3.prototype._getBeta = function() { + return null; +}, Xt$3.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; +}; +var Di$1 = cr$2(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; +}), Ua$1 = Jt$3.assert; +function Zt$2(e2) { + Ze$2.call(this, "short", e2), this.a = new K$2(e2.a, 16).toRed(this.red), this.b = new K$2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +Di$1(Zt$2, Ze$2); +var ka$1 = Zt$2; +Zt$2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K$2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K$2(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua$1(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K$2(p2.a, 16), b: new K$2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } +}, Zt$2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K$2.mont(t2), i2 = new K$2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o2 = new K$2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o2).fromRed(), p2 = n4.redSub(o2).fromRed(); + return [h4, p2]; +}, Zt$2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o2 = new K$2(1), h4 = new K$2(0), p2 = new K$2(0), b3 = new K$2(1), m3, w3, y3, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o2, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o2, o2 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m3, N2 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y3, b: S2 }, { a: I2, b: N2 }]; +}, Zt$2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o2 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b3 = h4.mul(n4.a), m3 = o2.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; +}, Zt$2.prototype.pointFromX = function(t2, r3) { + t2 = new K$2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n4.fromRed().isOdd(); + return (r3 && !o2 || !r3 && o2) && (n4 = n4.redNeg()), this.point(t2, n4); +}, Zt$2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o2 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; +}, Zt$2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o2 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o2[h4 * 2] = p2.k1, o2[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o2, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o2[y3] = null; + return w3; +}; +function Ft$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); +} +Di$1(Ft$2, Ze$2.BasePoint), Zt$2.prototype.point = function(t2, r3, i2) { + return new Ft$2(this, t2, r3, i2); +}, Zt$2.prototype.pointFromJSON = function(t2, r3) { + return Ft$2.fromJSON(this, t2, r3); +}, Ft$2.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } +}, Ft$2.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; +}, Ft$2.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o2)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o2)) } }, n4; +}, Ft$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Ft$2.prototype.isInfinity = function() { + return this.inf; +}, Ft$2.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); +}, Ft$2.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); +}, Ft$2.prototype.getX = function() { + return this.x.fromRed(); +}, Ft$2.prototype.getY = function() { + return this.y.fromRed(); +}, Ft$2.prototype.mul = function(t2) { + return t2 = new K$2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); +}, Ft$2.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2) : this.curve._wnafMulAdd(1, n4, o2, 2); +}, Ft$2.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2, true) : this.curve._wnafMulAdd(1, n4, o2, 2, true); +}, Ft$2.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); +}, Ft$2.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o2) { + return o2.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; +}, Ft$2.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; +}; +function Tt$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K$2(0)) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), this.z = new K$2(i2, 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; +} +Di$1(Tt$2, Ze$2.BasePoint), Zt$2.prototype.jpoint = function(t2, r3, i2) { + return new Tt$2(this, t2, r3, i2); +}, Tt$2.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); +}, Tt$2.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}, Tt$2.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o2 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o2), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N2 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N2, C2); +}, Tt$2.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o2 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o2.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o2.redMul(w3)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); +}, Tt$2.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o2 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N2 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o2), b3); +}, Tt$2.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}, Tt$2.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r3 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt$2.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt$2.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o2 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o2)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N2, C2); +}, Tt$2.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h4 = o2.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o2.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N2); +}, Tt$2.prototype.mul = function(t2, r3) { + return t2 = new K$2(t2, r3), this.curve._wnafMul(this, t2); +}, Tt$2.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n4)).cmpn(0) === 0; +}, Tt$2.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o2 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } +}, Tt$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Tt$2.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var qr$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.base = Ze$2, r3.short = ka$1, r3.mont = null, r3.edwards = null; +}), Kr$1 = cr$2(function(e2, t2) { + var r3 = t2, i2 = Jt$3.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr$1.short(p2) : p2.type === "edwards" ? this.curve = new qr$1.edwards(p2) : this.curve = new qr$1.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o2(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o2("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: se$2.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se$2.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se$2.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se$2.sha384, gRed: false, 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"] }), o2("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: se$2.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se$2.sha256, gRed: false, g: ["9"] }), o2("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: se$2.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o2("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: se$2.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); +}); +function Re$2(e2) { + if (!(this instanceof Re$2)) + return new Re$2(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe$2.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe$2.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe$2.toArray(e2.pers, e2.persEnc || "hex"); + Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); +} +var Rf$1 = Re$2; +Re$2.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; +}, Re$2.prototype._hmac = function() { + return new se$2.hmac(this.hash, this.K); +}, Re$2.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); +}, Re$2.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe$2.toArray(t2, r3), i2 = fe$2.toArray(i2, n4), Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; +}, Re$2.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe$2.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h4 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe$2.encode(h4, r3); +}; +var Fi$1 = Jt$3.assert; +function kt$2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); +} +var Ti$1 = kt$2; +kt$2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { pub: r3, pubEnc: i2 }); +}, kt$2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { priv: r3, privEnc: i2 }); +}, kt$2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; +}, kt$2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; +}, kt$2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; +}, kt$2.prototype._importPrivate = function(t2, r3) { + this.priv = new K$2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); +}, kt$2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi$1(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi$1(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); +}, kt$2.prototype.derive = function(t2) { + return t2.validate() || Fi$1(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); +}, kt$2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); +}, kt$2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); +}, kt$2.prototype.inspect = function() { + return ""; +}; +var qa$1 = Jt$3.assert; +function Hr$1(e2, t2) { + if (e2 instanceof Hr$1) + return e2; + this._importDER(e2, t2) || (qa$1(e2.r && e2.s, "Signature without r or s"), this.r = new K$2(e2.r, 16), this.s = new K$2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); +} +var zr$2 = Hr$1; +function Ka$1() { + this.place = 0; +} +function Ui$1(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o2 = 0, h4 = t2.place; o2 < i2; o2++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); +} +function Of$1(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); +} +Hr$1.prototype._importDER = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = new Ka$1(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui$1(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui$1(t2, i2); + if (o2 === false) + return false; + var h4 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui$1(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K$2(h4), this.s = new K$2(b3), this.recoveryParam = null, true; +}; +function ki$1(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); +} +Hr$1.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of$1(r3), i2 = Of$1(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki$1(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki$1(n4, i2.length); + var o2 = n4.concat(i2), h4 = [48]; + return ki$1(h4, o2.length), h4 = h4.concat(o2), Jt$3.encode(h4, t2); +}; +var Ha$1 = function() { + throw new Error("unsupported"); +}, Pf$1 = Jt$3.assert; +function $t$2(e2) { + if (!(this instanceof $t$2)) + return new $t$2(e2); + typeof e2 == "string" && (Pf$1(Object.prototype.hasOwnProperty.call(Kr$1, e2), "Unknown curve " + e2), e2 = Kr$1[e2]), e2 instanceof Kr$1.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; +} +var za$1 = $t$2; +$t$2.prototype.keyPair = function(t2) { + return new Ti$1(this, t2); +}, $t$2.prototype.keyFromPrivate = function(t2, r3) { + return Ti$1.fromPrivate(this, t2, r3); +}, $t$2.prototype.keyFromPublic = function(t2, r3) { + return Ti$1.fromPublic(this, t2, r3); +}, $t$2.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf$1({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha$1(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K$2(2)); ; ) { + var o2 = new K$2(r3.generate(i2)); + if (!(o2.cmp(n4) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } +}, $t$2.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; +}, $t$2.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K$2(t2, 16)); + for (var o2 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b3 = new Rf$1({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K$2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K$2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N2.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr$2({ r: N2, s: C2, recoveryParam: F2 }); + } + } + } + } + } +}, $t$2.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K$2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr$2(r3, "hex"); + var o2 = r3.r, h4 = r3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o2).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o2)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o2) === 0); +}, $t$2.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf$1((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr$2(t2, i2); + var n4 = this.n, o2 = new K$2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o2).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); +}, $t$2.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr$2(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; + } + if (o2.eq(r3)) + return n4; + } + throw new Error("Unable to find valid recovery factor"); +}; +var La$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt$3, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr$1, r3.curves = Kr$1, r3.ec = za$1, r3.eddsa = null; +}), ja = La$1.ec; +const Qa = "signing-key/5.7.0", qi = new L$3(Qa); +let Ki = null; +function ve() { + return Ki || (Ki = new ja("secp256k1")), Ki; +} +class Ja { + constructor(t2) { + br$1(this, "curve", "secp256k1"), br$1(this, "privateKey", Kt$2(t2)), N0(this.privateKey) !== 32 && qi.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)); + br$1(this, "publicKey", "0x" + r3.getPublic(false, "hex")), br$1(this, "compressedPublicKey", "0x" + r3.getPublic(true, "hex")), br$1(this, "_isSigningKey", true); + } + _addPoint(t2) { + const r3 = ve().keyFromPublic(Ot$2(this.publicKey)), i2 = ve().keyFromPublic(Ot$2(t2)); + return "0x" + r3.pub.add(i2.pub).encodeCompressed("hex"); + } + signDigest(t2) { + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)), i2 = Ot$2(t2); + i2.length !== 32 && qi.throwArgumentError("bad digest length", "digest", t2); + const n4 = r3.sign(i2, { canonical: true }); + return zn({ recoveryParam: n4.recoveryParam, r: oe$1("0x" + n4.r.toString(16), 32), s: oe$1("0x" + n4.s.toString(16), 32) }); + } + computeSharedSecret(t2) { + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)), i2 = ve().keyFromPublic(Ot$2(Df(t2))); + return oe$1("0x" + r3.derive(i2.getPublic()).toString(16), 32); + } + static isSigningKey(t2) { + return !!(t2 && t2._isSigningKey); + } +} +function Ga(e2, t2) { + const r3 = zn(t2), i2 = { r: Ot$2(r3.r), s: Ot$2(r3.s) }; + return "0x" + ve().recoverPubKey(Ot$2(e2), i2, r3.recoveryParam).encode("hex", false); +} +function Df(e2, t2) { + const r3 = Ot$2(e2); + if (r3.length === 32) { + const i2 = new Ja(r3); + return i2.publicKey; + } else { + if (r3.length === 33) + return "0x" + ve().keyFromPublic(r3).getPublic(false, "hex"); + if (r3.length === 65) + return Kt$2(r3); + } + return qi.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} +var Ff$1; +(function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; +})(Ff$1 || (Ff$1 = {})); +function Va(e2) { + const t2 = Df(e2); + return ns$1(Hn(yi(Hn(t2, 1)), 12)); +} +function Wa(e2, t2) { + return Va(Ga(Ot$2(e2), t2)); +} +const Xa = "https://rpc.walletconnect.com/v1"; +async function Tf(e2, t2, r3, i2, n4, o2) { + switch (r3.t) { + case "eip191": + return Uf(e2, t2, r3.s); + case "eip1271": + return await kf(e2, t2, r3.s, i2, n4, o2); + default: + throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r3.t}`); + } +} +function Uf(e2, t2, r3) { + return Wa(ff(t2), r3).toLowerCase() === e2.toLowerCase(); +} +async function kf(e2, t2, r3, i2, n4, o2) { + try { + const h4 = "0x1626ba7e", p2 = "0000000000000000000000000000000000000000000000000000000000000040", b3 = "0000000000000000000000000000000000000000000000000000000000000041", m3 = r3.substring(2), w3 = ff(t2).substring(2), y3 = h4 + w3 + p2 + b3 + m3, S2 = await fetch(`${o2 || Xa}/?chainId=${i2}&projectId=${n4}`, { method: "POST", body: JSON.stringify({ id: Za(), jsonrpc: "2.0", method: "eth_call", params: [{ to: e2, data: y3 }, "latest"] }) }), { result: I2 } = await S2.json(); + return I2 ? I2.slice(0, h4.length).toLowerCase() === h4.toLowerCase() : false; + } catch (h4) { + return console.error("isValidEip1271Signature: ", h4), false; + } +} +function Za() { + return Date.now() + Math.floor(Math.random() * 1e3); +} +var $a = Object.defineProperty, tu = Object.defineProperties, eu = Object.getOwnPropertyDescriptors, qf = Object.getOwnPropertySymbols, ru = Object.prototype.hasOwnProperty, iu = Object.prototype.propertyIsEnumerable, Kf = (e2, t2, r3) => t2 in e2 ? $a(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, Hi$1 = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + ru.call(t2, r3) && Kf(e2, r3, t2[r3]); + if (qf) + for (var r3 of qf(t2)) + iu.call(t2, r3) && Kf(e2, r3, t2[r3]); + return e2; +}, Hf = (e2, t2) => tu(e2, eu(t2)); +const nu = "did:pkh:", Lr$1 = (e2) => e2 == null ? void 0 : e2.split(":"), zi = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return e2.includes(nu) ? t2[3] : t2[1]; +}, fu = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2[2] + ":" + t2[3]; +}, Li = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2.pop(); +}; +async function ou(e2) { + const { cacao: t2, projectId: r3 } = e2, { s: i2, p: n4 } = t2, o2 = zf(n4, n4.iss), h4 = Li(n4.iss); + return await Tf(h4, o2, i2, zi(n4.iss), r3); +} +const zf = (e2, t2) => { + const r3 = `${e2.domain} wants you to sign in with your Ethereum account:`, i2 = Li(t2); + if (!e2.aud && !e2.uri) + throw new Error("Either `aud` or `uri` is required to construct the message"); + let n4 = e2.statement || void 0; + const o2 = `URI: ${e2.aud || e2.uri}`, h4 = `Version: ${e2.version}`, p2 = `Chain ID: ${zi(t2)}`, b3 = `Nonce: ${e2.nonce}`, m3 = `Issued At: ${e2.iat}`, w3 = e2.resources ? `Resources:${e2.resources.map((S2) => ` +- ${S2}`).join("")}` : void 0, y3 = Qr(e2.resources); + if (y3) { + const S2 = Oe(y3); + n4 = Ji$1(n4, S2); + } + return [r3, i2, "", n4, "", o2, h4, p2, b3, m3, w3].filter((S2) => S2 != null).join(` +`); +}; +function Jf(e2) { + return Buffer.from(JSON.stringify(e2)).toString("base64"); +} +function Gf(e2) { + return JSON.parse(Buffer.from(e2, "base64").toString("utf-8")); +} +function me$1(e2) { + if (!e2) + throw new Error("No recap provided, value is undefined"); + if (!e2.att) + throw new Error("No `att` property found"); + const t2 = Object.keys(e2.att); + if (!(t2 != null && t2.length)) + throw new Error("No resources found in `att` property"); + t2.forEach((r3) => { + const i2 = e2.att[r3]; + if (Array.isArray(i2)) + throw new Error(`Resource must be an object: ${r3}`); + if (typeof i2 != "object") + throw new Error(`Resource must be an object: ${r3}`); + if (!Object.keys(i2).length) + throw new Error(`Resource object is empty: ${r3}`); + Object.keys(i2).forEach((n4) => { + const o2 = i2[n4]; + if (!Array.isArray(o2)) + throw new Error(`Ability limits ${n4} must be an array of objects, found: ${o2}`); + if (!o2.length) + throw new Error(`Value of ${n4} is empty array, must be an array with objects`); + o2.forEach((h4) => { + if (typeof h4 != "object") + throw new Error(`Ability limits (${n4}) must be an array of objects, found: ${h4}`); + }); + }); + }); +} +function Yf(e2, t2, r3, i2 = {}) { + return r3 == null ? void 0 : r3.sort((n4, o2) => n4.localeCompare(o2)), { att: { [e2]: ji(t2, r3, i2) } }; +} +function ji(e2, t2, r3 = {}) { + t2 = t2 == null ? void 0 : t2.sort((n4, o2) => n4.localeCompare(o2)); + const i2 = t2.map((n4) => ({ [`${e2}/${n4}`]: [r3] })); + return Object.assign({}, ...i2); +} +function jr(e2) { + return me$1(e2), `urn:recap:${Jf(e2).replace(/=/g, "")}`; +} +function Oe(e2) { + const t2 = Gf(e2.replace("urn:recap:", "")); + return me$1(t2), t2; +} +function cu(e2, t2, r3) { + const i2 = Yf(e2, t2, r3); + return jr(i2); +} +function Qi$1(e2) { + return e2 && e2.includes("urn:recap:"); +} +function lu(e2, t2) { + const r3 = Oe(e2), i2 = Oe(t2), n4 = Wf(r3, i2); + return jr(n4); +} +function Wf(e2, t2) { + me$1(e2), me$1(t2); + const r3 = Object.keys(e2.att).concat(Object.keys(t2.att)).sort((n4, o2) => n4.localeCompare(o2)), i2 = { att: {} }; + return r3.forEach((n4) => { + var o2, h4; + Object.keys(((o2 = e2.att) == null ? void 0 : o2[n4]) || {}).concat(Object.keys(((h4 = t2.att) == null ? void 0 : h4[n4]) || {})).sort((p2, b3) => p2.localeCompare(b3)).forEach((p2) => { + var b3, m3; + i2.att[n4] = Hf(Hi$1({}, i2.att[n4]), { [p2]: ((b3 = e2.att[n4]) == null ? void 0 : b3[p2]) || ((m3 = t2.att[n4]) == null ? void 0 : m3[p2]) }); + }); + }), i2; +} +function Ji$1(e2 = "", t2) { + me$1(t2); + const r3 = "I further authorize the stated URI to perform the following actions on my behalf: "; + if (e2.includes(r3)) + return e2; + const i2 = []; + let n4 = 0; + Object.keys(t2.att).forEach((p2) => { + const b3 = Object.keys(t2.att[p2]).map((y3) => ({ ability: y3.split("/")[0], action: y3.split("/")[1] })); + b3.sort((y3, S2) => y3.action.localeCompare(S2.action)); + const m3 = {}; + b3.forEach((y3) => { + m3[y3.ability] || (m3[y3.ability] = []), m3[y3.ability].push(y3.action); + }); + const w3 = Object.keys(m3).map((y3) => (n4++, `(${n4}) '${y3}': '${m3[y3].join("', '")}' for '${p2}'.`)); + i2.push(w3.join(", ").replace(".,", ".")); + }); + const o2 = i2.join(" "), h4 = `${r3}${o2}`; + return `${e2 ? e2 + " " : ""}${h4}`; +} +function du(e2) { + var t2; + const r3 = Oe(e2); + me$1(r3); + const i2 = (t2 = r3.att) == null ? void 0 : t2.eip155; + return i2 ? Object.keys(i2).map((n4) => n4.split("/")[1]) : []; +} +function pu(e2) { + const t2 = Oe(e2); + me$1(t2); + const r3 = []; + return Object.values(t2.att).forEach((i2) => { + Object.values(i2).forEach((n4) => { + var o2; + (o2 = n4 == null ? void 0 : n4[0]) != null && o2.chains && r3.push(n4[0].chains); + }); + }), [...new Set(r3.flat())]; +} +function Qr(e2) { + if (!e2) + return; + const t2 = e2 == null ? void 0 : e2[e2.length - 1]; + return Qi$1(t2) ? t2 : void 0; +} +const Gi = "base10", zt$1 = "base16", Jr = "base64pad", Gr = "utf8", Yi$1 = 0, lr$1 = 1, vu = 0, Zf = 1, Vi = 12, Wi$1 = 32; +function mu() { + const e2 = x25519.generateKeyPair(); + return { privateKey: toString(e2.secretKey, zt$1), publicKey: toString(e2.publicKey, zt$1) }; +} +function gu() { + const e2 = random.randomBytes(Wi$1); + return toString(e2, zt$1); +} +function Au(e2, t2) { + const r3 = x25519.sharedKey(fromString(e2, zt$1), fromString(t2, zt$1), true), i2 = new HKDF_1(sha256.SHA256, r3).expand(Wi$1); + return toString(i2, zt$1); +} +function bu(e2) { + const t2 = sha256.hash(fromString(e2, zt$1)); + return toString(t2, zt$1); +} +function yu(e2) { + const t2 = sha256.hash(fromString(e2, Gr)); + return toString(t2, zt$1); +} +function $f(e2) { + return fromString(`${e2}`, Gi); +} +function Mr(e2) { + return Number(toString(e2, Gi)); +} +function wu(e2) { + const t2 = $f(typeof e2.type < "u" ? e2.type : Yi$1); + if (Mr(t2) === lr$1 && typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + const r3 = typeof e2.senderPublicKey < "u" ? fromString(e2.senderPublicKey, zt$1) : void 0, i2 = typeof e2.iv < "u" ? fromString(e2.iv, zt$1) : random.randomBytes(Vi), n4 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)).seal(i2, fromString(e2.message, Gr)); + return to({ type: t2, sealed: n4, iv: i2, senderPublicKey: r3 }); +} +function xu(e2) { + const t2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)), { sealed: r3, iv: i2 } = Xi$1(e2.encoded), n4 = t2.open(i2, r3); + if (n4 === null) + throw new Error("Failed to decrypt"); + return toString(n4, Gr); +} +function to(e2) { + if (Mr(e2.type) === lr$1) { + if (typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + return toString(concat([e2.type, e2.senderPublicKey, e2.iv, e2.sealed]), Jr); + } + return toString(concat([e2.type, e2.iv, e2.sealed]), Jr); +} +function Xi$1(e2) { + const t2 = fromString(e2, Jr), r3 = t2.slice(vu, Zf), i2 = Zf; + if (Mr(r3) === lr$1) { + const p2 = i2 + Wi$1, b3 = p2 + Vi, m3 = t2.slice(i2, p2), w3 = t2.slice(p2, b3), y3 = t2.slice(b3); + return { type: r3, sealed: y3, iv: w3, senderPublicKey: m3 }; + } + const n4 = i2 + Vi, o2 = t2.slice(i2, n4), h4 = t2.slice(n4); + return { type: r3, sealed: h4, iv: o2 }; +} +function Mu(e2, t2) { + const r3 = Xi$1(e2); + return eo({ type: Mr(r3.type), senderPublicKey: typeof r3.senderPublicKey < "u" ? toString(r3.senderPublicKey, zt$1) : void 0, receiverPublicKey: t2 == null ? void 0 : t2.receiverPublicKey }); +} +function eo(e2) { + const t2 = (e2 == null ? void 0 : e2.type) || Yi$1; + if (t2 === lr$1) { + if (typeof (e2 == null ? void 0 : e2.senderPublicKey) > "u") + throw new Error("missing sender public key"); + if (typeof (e2 == null ? void 0 : e2.receiverPublicKey) > "u") + throw new Error("missing receiver public key"); + } + return { type: t2, senderPublicKey: e2 == null ? void 0 : e2.senderPublicKey, receiverPublicKey: e2 == null ? void 0 : e2.receiverPublicKey }; +} +function Eu(e2) { + return e2.type === lr$1 && typeof e2.senderPublicKey == "string" && typeof e2.receiverPublicKey == "string"; +} +const ro = "irn"; +function Su(e2) { + return (e2 == null ? void 0 : e2.relay) || { protocol: ro }; +} +function Nu(e2) { + const t2 = C$1[e2]; + if (typeof t2 > "u") + throw new Error(`Relay Protocol not supported: ${e2}`); + return t2; +} +var Iu = Object.defineProperty, _u = Object.defineProperties, Bu = Object.getOwnPropertyDescriptors, io = Object.getOwnPropertySymbols, Cu = Object.prototype.hasOwnProperty, Ru = Object.prototype.propertyIsEnumerable, no = (e2, t2, r3) => t2 in e2 ? Iu(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, fo = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Cu.call(t2, r3) && no(e2, r3, t2[r3]); + if (io) + for (var r3 of io(t2)) + Ru.call(t2, r3) && no(e2, r3, t2[r3]); + return e2; +}, Ou = (e2, t2) => _u(e2, Bu(t2)); +function oo(e2, t2 = "-") { + const r3 = {}, i2 = "relay" + t2; + return Object.keys(e2).forEach((n4) => { + if (n4.startsWith(i2)) { + const o2 = n4.replace(i2, ""), h4 = e2[n4]; + r3[o2] = h4; + } + }), r3; +} +function Pu(e2) { + e2 = e2.includes("wc://") ? e2.replace("wc://", "") : e2, e2 = e2.includes("wc:") ? e2.replace("wc:", "") : e2; + const t2 = e2.indexOf(":"), r3 = e2.indexOf("?") !== -1 ? e2.indexOf("?") : void 0, i2 = e2.substring(0, t2), n4 = e2.substring(t2 + 1, r3).split("@"), o2 = typeof r3 < "u" ? e2.substring(r3) : "", h4 = queryString.parse(o2), p2 = typeof h4.methods == "string" ? h4.methods.split(",") : void 0; + return { protocol: i2, topic: so(n4[0]), version: parseInt(n4[1], 10), symKey: h4.symKey, relay: oo(h4), methods: p2, expiryTimestamp: h4.expiryTimestamp ? parseInt(h4.expiryTimestamp, 10) : void 0 }; +} +function so(e2) { + return e2.startsWith("//") ? e2.substring(2) : e2; +} +function ao(e2, t2 = "-") { + const r3 = "relay", i2 = {}; + return Object.keys(e2).forEach((n4) => { + const o2 = r3 + t2 + n4; + e2[n4] && (i2[o2] = e2[n4]); + }), i2; +} +function Du(e2) { + return `${e2.protocol}:${e2.topic}@${e2.version}?` + queryString.stringify(fo(Ou(fo({ symKey: e2.symKey }, ao(e2.relay)), { expiryTimestamp: e2.expiryTimestamp }), e2.methods ? { methods: e2.methods.join(",") } : {})); +} +function $e$1(e2) { + const t2 = []; + return e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2.push(`${i2}:${n4}`); + }), t2; +} +function co(e2) { + const t2 = []; + return Object.values(e2).forEach((r3) => { + t2.push(...$e$1(r3.accounts)); + }), t2; +} +function lo(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.methods); + }), r3; +} +function po(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.events); + }), r3; +} +function mo(e2) { + const t2 = {}; + return e2 == null ? void 0 : e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2[i2] || (t2[i2] = { accounts: [], chains: [], events: [] }), t2[i2].accounts.push(r3), t2[i2].chains.push(`${i2}:${n4}`); + }), t2; +} +function ju(e2, t2) { + t2 = t2.map((i2) => i2.replace("did:pkh:", "")); + const r3 = mo(t2); + for (const [i2, n4] of Object.entries(r3)) + n4.methods ? n4.methods = ge$1(n4.methods, e2) : n4.methods = e2, n4.events = ["chainChanged", "accountsChanged"]; + return r3; +} +const go$1 = { 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 } }, Ao = { 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 xe(e2, t2) { + const { message: r3, code: i2 } = Ao[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; +} +function tr$2(e2, t2) { + const { message: r3, code: i2 } = go$1[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; +} +function Er(e2, t2) { + return Array.isArray(e2) ? true : false; +} +function Yr(e2) { + return Object.getPrototypeOf(e2) === Object.prototype && Object.keys(e2).length; +} +function Pe(e2) { + return typeof e2 > "u"; +} +function Gt$1(e2, t2) { + return t2 && Pe(e2) ? true : typeof e2 == "string" && !!e2.trim().length; +} +function Vr(e2, t2) { + return typeof e2 == "number" && !isNaN(e2); +} +function Qu(e2, t2) { + const { requiredNamespaces: r3 } = t2, i2 = Object.keys(e2.namespaces), n4 = Object.keys(r3); + let o2 = true; + return _e$1(n4, i2) ? (i2.forEach((h4) => { + const { accounts: p2, methods: b3, events: m3 } = e2.namespaces[h4], w3 = $e$1(p2), y3 = r3[h4]; + (!_e$1(_r$1(h4, y3), w3) || !_e$1(y3.methods, b3) || !_e$1(y3.events, m3)) && (o2 = false); + }), o2) : false; +} +function Sr$1(e2) { + return Gt$1(e2, false) && e2.includes(":") ? e2.split(":").length === 2 : false; +} +function bo(e2) { + if (Gt$1(e2, false) && e2.includes(":")) { + const t2 = e2.split(":"); + if (t2.length === 3) { + const r3 = t2[0] + ":" + t2[1]; + return !!t2[2] && Sr$1(r3); + } + } + return false; +} +function Ju(e2) { + if (Gt$1(e2, false)) + try { + return typeof new URL(e2) < "u"; + } catch { + return false; + } + return false; +} +function Gu(e2) { + var t2; + return (t2 = e2 == null ? void 0 : e2.proposer) == null ? void 0 : t2.publicKey; +} +function Yu(e2) { + return e2 == null ? void 0 : e2.topic; +} +function Vu(e2, t2) { + let r3 = null; + return Gt$1(e2 == null ? void 0 : e2.publicKey, false) || (r3 = xe("MISSING_OR_INVALID", `${t2} controller public key should be a string`)), r3; +} +function tn(e2) { + let t2 = true; + return Er(e2) ? e2.length && (t2 = e2.every((r3) => Gt$1(r3, false))) : t2 = false, t2; +} +function yo(e2, t2, r3) { + let i2 = null; + return Er(t2) && t2.length ? t2.forEach((n4) => { + i2 || Sr$1(n4) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, chain ${n4} should be a string and conform to "namespace:chainId" format`)); + }) : Sr$1(e2) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, 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"] }`)), i2; +} +function wo(e2, t2, r3) { + let i2 = null; + return Object.entries(e2).forEach(([n4, o2]) => { + if (i2) + return; + const h4 = yo(n4, _r$1(n4, o2), `${t2} ${r3}`); + h4 && (i2 = h4); + }), i2; +} +function xo(e2, t2) { + let r3 = null; + return Er(e2) ? e2.forEach((i2) => { + r3 || bo(i2) || (r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, account ${i2} should be a string and conform to "namespace:chainId:address" format`)); + }) : r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), r3; +} +function Mo(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = xo(i2 == null ? void 0 : i2.accounts, `${t2} namespace`); + n4 && (r3 = n4); + }), r3; +} +function Eo(e2, t2) { + let r3 = null; + return tn(e2 == null ? void 0 : e2.methods) ? tn(e2 == null ? void 0 : e2.events) || (r3 = tr$2("UNSUPPORTED_EVENTS", `${t2}, events should be an array of strings or empty array for no events`)) : r3 = tr$2("UNSUPPORTED_METHODS", `${t2}, methods should be an array of strings or empty array for no methods`), r3; +} +function en(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = Eo(i2, `${t2}, namespace`); + n4 && (r3 = n4); + }), r3; +} +function Wu(e2, t2, r3) { + let i2 = null; + if (e2 && Yr(e2)) { + const n4 = en(e2, t2); + n4 && (i2 = n4); + const o2 = wo(e2, t2, r3); + o2 && (i2 = o2); + } else + i2 = xe("MISSING_OR_INVALID", `${t2}, ${r3} should be an object with data`); + return i2; +} +function So(e2, t2) { + let r3 = null; + if (e2 && Yr(e2)) { + const i2 = en(e2, t2); + i2 && (r3 = i2); + const n4 = Mo(e2, t2); + n4 && (r3 = n4); + } else + r3 = xe("MISSING_OR_INVALID", `${t2}, namespaces should be an object with data`); + return r3; +} +function No(e2) { + return Gt$1(e2.protocol, true); +} +function Xu(e2, t2) { + let r3 = false; + return !e2 ? r3 = true : e2 && Er(e2) && e2.length && e2.forEach((i2) => { + r3 = No(i2); + }), r3; +} +function Zu(e2) { + return typeof e2 == "number"; +} +function $u(e2) { + return typeof e2 < "u" && typeof e2 !== null; +} +function th(e2) { + return !(!e2 || typeof e2 != "object" || !e2.code || !Vr(e2.code) || !e2.message || !Gt$1(e2.message, false)); +} +function eh(e2) { + return !(Pe(e2) || !Gt$1(e2.method, false)); +} +function rh(e2) { + return !(Pe(e2) || Pe(e2.result) && Pe(e2.error) || !Vr(e2.id) || !Gt$1(e2.jsonrpc, false)); +} +function ih(e2) { + return !(Pe(e2) || !Gt$1(e2.name, false)); +} +function nh(e2, t2) { + return !(!Sr$1(t2) || !co(e2).includes(t2)); +} +function fh(e2, t2, r3) { + return Gt$1(r3, false) ? lo(e2, t2).includes(r3) : false; +} +function oh(e2, t2, r3) { + return Gt$1(r3, false) ? po(e2, t2).includes(r3) : false; +} +function Io(e2, t2, r3) { + let i2 = null; + const n4 = sh(e2), o2 = ah(t2), h4 = Object.keys(n4), p2 = Object.keys(o2), b3 = _o(Object.keys(e2)), m3 = _o(Object.keys(t2)), w3 = b3.filter((y3) => !m3.includes(y3)); + return w3.length && (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces keys don't satisfy requiredNamespaces. + Required: ${w3.toString()} + Received: ${Object.keys(t2).toString()}`)), _e$1(h4, p2) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces chains don't satisfy required namespaces. + Required: ${h4.toString()} + Approved: ${p2.toString()}`)), Object.keys(t2).forEach((y3) => { + if (!y3.includes(":") || i2) + return; + const S2 = $e$1(t2[y3].accounts); + S2.includes(y3) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces accounts don't satisfy namespace accounts for ${y3} + Required: ${y3} + Approved: ${S2.toString()}`)); + }), h4.forEach((y3) => { + i2 || (_e$1(n4[y3].methods, o2[y3].methods) ? _e$1(n4[y3].events, o2[y3].events) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces events don't satisfy namespace events for ${y3}`)) : i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces methods don't satisfy namespace methods for ${y3}`)); + }), i2; +} +function sh(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + var i2; + r3.includes(":") ? t2[r3] = e2[r3] : (i2 = e2[r3].chains) == null || i2.forEach((n4) => { + t2[n4] = { methods: e2[r3].methods, events: e2[r3].events }; + }); + }), t2; +} +function _o(e2) { + return [...new Set(e2.map((t2) => t2.includes(":") ? t2.split(":")[0] : t2))]; +} +function ah(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + if (r3.includes(":")) + t2[r3] = e2[r3]; + else { + const i2 = $e$1(e2[r3].accounts); + i2 == null ? void 0 : i2.forEach((n4) => { + t2[n4] = { accounts: e2[r3].accounts.filter((o2) => o2.includes(`${n4}:`)), methods: e2[r3].methods, events: e2[r3].events }; + }); + } + }), t2; +} +function uh(e2, t2) { + return Vr(e2) && e2 <= t2.max && e2 >= t2.min; +} +function hh() { + const e2 = We$2(); + return new Promise((t2) => { + switch (e2) { + case qt$1.browser: + t2(Bo()); + break; + case qt$1.reactNative: + t2(Co()); + break; + case qt$1.node: + t2(Ro()); + break; + default: + t2(true); + } + }); +} +function Bo() { + return pr$1() && (navigator == null ? void 0 : navigator.onLine); +} +async function Co() { + if (er$1() && typeof global < "u" && global != null && global.NetInfo) { + const e2 = await (global == null ? void 0 : global.NetInfo.fetch()); + return e2 == null ? void 0 : e2.isConnected; + } + return true; +} +function Ro() { + return true; +} +function ch(e2) { + switch (We$2()) { + case qt$1.browser: + Oo(e2); + break; + case qt$1.reactNative: + Po(e2); + break; + } +} +function Oo(e2) { + !er$1() && pr$1() && (window.addEventListener("online", () => e2(true)), window.addEventListener("offline", () => e2(false))); +} +function Po(e2) { + er$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((t2) => e2(t2 == null ? void 0 : t2.isConnected))); +} +const rn = {}; +class lh { + static get(t2) { + return rn[t2]; + } + static set(t2, r3) { + rn[t2] = r3; + } + static delete(t2) { + delete rn[t2]; + } +} +const PARSE_ERROR = "PARSE_ERROR"; +const INVALID_REQUEST = "INVALID_REQUEST"; +const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; +const INVALID_PARAMS = "INVALID_PARAMS"; +const INTERNAL_ERROR = "INTERNAL_ERROR"; +const SERVER_ERROR = "SERVER_ERROR"; +const RESERVED_ERROR_CODES = [-32700, -32600, -32601, -32602, -32603]; +const STANDARD_ERROR_MAP = { + [PARSE_ERROR]: { code: -32700, message: "Parse error" }, + [INVALID_REQUEST]: { code: -32600, message: "Invalid Request" }, + [METHOD_NOT_FOUND]: { code: -32601, message: "Method not found" }, + [INVALID_PARAMS]: { code: -32602, message: "Invalid params" }, + [INTERNAL_ERROR]: { code: -32603, message: "Internal error" }, + [SERVER_ERROR]: { code: -32e3, message: "Server error" } +}; +const DEFAULT_ERROR = SERVER_ERROR; +function isReservedErrorCode(code) { + return RESERVED_ERROR_CODES.includes(code); +} +function getError(type2) { + if (!Object.keys(STANDARD_ERROR_MAP).includes(type2)) { + return STANDARD_ERROR_MAP[DEFAULT_ERROR]; + } + return STANDARD_ERROR_MAP[type2]; +} +function getErrorByCode(code) { + const match = Object.values(STANDARD_ERROR_MAP).find((e2) => e2.code === code); + if (!match) { + return STANDARD_ERROR_MAP[DEFAULT_ERROR]; + } + return match; +} +function parseConnectionError(e2, url, type2) { + return e2.message.includes("getaddrinfo ENOTFOUND") || e2.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${type2} RPC url at ${url}`) : e2; +} +var cjs = {}; +var crypto$1 = {}; +var hasRequiredCrypto; +function requireCrypto() { + if (hasRequiredCrypto) + return crypto$1; + hasRequiredCrypto = 1; + Object.defineProperty(crypto$1, "__esModule", { value: true }); + crypto$1.isBrowserCryptoAvailable = crypto$1.getSubtleCrypto = crypto$1.getBrowerCrypto = void 0; + function getBrowerCrypto() { + return (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.crypto) || (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.msCrypto) || {}; + } + crypto$1.getBrowerCrypto = getBrowerCrypto; + function getSubtleCrypto() { + const browserCrypto = getBrowerCrypto(); + return browserCrypto.subtle || browserCrypto.webkitSubtle; + } + crypto$1.getSubtleCrypto = getSubtleCrypto; + function isBrowserCryptoAvailable() { + return !!getBrowerCrypto() && !!getSubtleCrypto(); + } + crypto$1.isBrowserCryptoAvailable = isBrowserCryptoAvailable; + return crypto$1; +} +var env = {}; +var hasRequiredEnv; +function requireEnv() { + if (hasRequiredEnv) + return env; + hasRequiredEnv = 1; + Object.defineProperty(env, "__esModule", { value: true }); + env.isBrowser = env.isNode = env.isReactNative = void 0; + function isReactNative() { + return typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative"; + } + env.isReactNative = isReactNative; + function isNode() { + return typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined"; + } + env.isNode = isNode; + function isBrowser() { + return !isReactNative() && !isNode(); + } + env.isBrowser = isBrowser; + return env; +} +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireCrypto(), exports2); + tslib_1.__exportStar(requireEnv(), exports2); +})(cjs); +function payloadId(entropy = 3) { + const date = Date.now() * Math.pow(10, entropy); + const extra = Math.floor(Math.random() * Math.pow(10, entropy)); + return date + extra; +} +function getBigIntRpcId(entropy = 6) { + return BigInt(payloadId(entropy)); +} +function formatJsonRpcRequest(method, params, id) { + return { + id: id || payloadId(), + jsonrpc: "2.0", + method, + params + }; +} +function formatJsonRpcResult(id, result) { + return { + id, + jsonrpc: "2.0", + result + }; +} +function formatJsonRpcError(id, error, data) { + return { + id, + jsonrpc: "2.0", + error: formatErrorMessage(error) + }; +} +function formatErrorMessage(error, data) { + if (typeof error === "undefined") { + return getError(INTERNAL_ERROR); + } + if (typeof error === "string") { + error = Object.assign(Object.assign({}, getError(SERVER_ERROR)), { message: error }); + } + if (isReservedErrorCode(error.code)) { + error = getErrorByCode(error.code); + } + return error; +} +class e { +} +let n$1 = class n2 extends e { + constructor() { + super(); + } +}; +let r$1 = class r extends n$1 { + constructor(c2) { + super(); + } +}; +const WS_REGEX = "^wss?:"; +function getUrlProtocol(url) { + const matches = url.match(new RegExp(/^\w+:/, "gi")); + if (!matches || !matches.length) + return; + return matches[0]; +} +function matchRegexProtocol(url, regex) { + const protocol = getUrlProtocol(url); + if (typeof protocol === "undefined") + return false; + return new RegExp(regex).test(protocol); +} +function isWsUrl(url) { + return matchRegexProtocol(url, WS_REGEX); +} +function isLocalhostUrl(url) { + return new RegExp("wss?://localhost(:d{2,5})?").test(url); +} +function isJsonRpcPayload(payload) { + return typeof payload === "object" && "id" in payload && "jsonrpc" in payload && payload.jsonrpc === "2.0"; +} +function isJsonRpcRequest(payload) { + return isJsonRpcPayload(payload) && "method" in payload; +} +function isJsonRpcResponse(payload) { + return isJsonRpcPayload(payload) && (isJsonRpcResult(payload) || isJsonRpcError(payload)); +} +function isJsonRpcResult(payload) { + return "result" in payload; +} +function isJsonRpcError(payload) { + return "error" in payload; +} +class JsonRpcProvider extends r$1 { + constructor(connection2) { + super(connection2); + this.events = new eventsExports.EventEmitter(); + this.hasRegisteredEventListeners = false; + this.connection = this.setConnection(connection2); + if (this.connection.connected) { + this.registerEventListeners(); + } + } + async connect(connection2 = this.connection) { + await this.open(connection2); + } + async disconnect() { + await this.close(); + } + on(event, listener) { + this.events.on(event, listener); + } + once(event, listener) { + this.events.once(event, listener); + } + off(event, listener) { + this.events.off(event, listener); + } + removeListener(event, listener) { + this.events.removeListener(event, listener); + } + async request(request, context) { + return this.requestStrict(formatJsonRpcRequest(request.method, request.params || [], request.id || getBigIntRpcId().toString()), context); + } + async requestStrict(request, context) { + return new Promise(async (resolve, reject) => { + if (!this.connection.connected) { + try { + await this.open(); + } catch (e2) { + reject(e2); + } + } + this.events.on(`${request.id}`, (response) => { + if (isJsonRpcError(response)) { + reject(response.error); + } else { + resolve(response.result); + } + }); + try { + await this.connection.send(request, context); + } catch (e2) { + reject(e2); + } + }); + } + setConnection(connection2 = this.connection) { + return connection2; + } + onPayload(payload) { + this.events.emit("payload", payload); + if (isJsonRpcResponse(payload)) { + this.events.emit(`${payload.id}`, payload); + } else { + this.events.emit("message", { + type: payload.method, + data: payload.params + }); + } + } + onClose(event) { + if (event && event.code === 3e3) { + this.events.emit("error", new Error(`WebSocket connection closed abnormally with code: ${event.code} ${event.reason ? `(${event.reason})` : ""}`)); + } + this.events.emit("disconnect"); + } + async open(connection2 = this.connection) { + if (this.connection === connection2 && this.connection.connected) + return; + if (this.connection.connected) + this.close(); + if (typeof connection2 === "string") { + await this.connection.open(connection2); + connection2 = this.connection; + } + this.connection = this.setConnection(connection2); + await this.connection.open(); + this.registerEventListeners(); + this.events.emit("connect"); + } + async close() { + await this.connection.close(); + } + registerEventListeners() { + if (this.hasRegisteredEventListeners) + return; + this.connection.on("payload", (payload) => this.onPayload(payload)); + this.connection.on("close", (event) => this.onClose(event)); + this.connection.on("error", (error) => this.events.emit("error", error)); + this.connection.on("register_error", (error) => this.onClose()); + this.hasRegisteredEventListeners = true; + } +} +const w$1 = () => 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 : (() => {try { return require("ws") } catch (e) { } })(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a2 = (c2) => c2.split("?")[0], h3 = 10, S$2 = w$1(); +let f$2 = class f { + constructor(e2) { + if (this.url = e2, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(e2)) + throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); + this.url = e2; + } + get connected() { + return typeof this.socket < "u"; + } + get connecting() { + return this.registering; + } + on(e2, t2) { + this.events.on(e2, t2); + } + once(e2, t2) { + this.events.once(e2, t2); + } + off(e2, t2) { + this.events.off(e2, t2); + } + removeListener(e2, t2) { + this.events.removeListener(e2, t2); + } + async open(e2 = this.url) { + await this.register(e2); + } + async close() { + return new Promise((e2, t2) => { + if (typeof this.socket > "u") { + t2(new Error("Connection already closed")); + return; + } + this.socket.onclose = (n4) => { + this.onClose(n4), e2(); + }, this.socket.close(); + }); + } + async send(e2) { + typeof this.socket > "u" && (this.socket = await this.register()); + try { + this.socket.send(safeJsonStringify(e2)); + } catch (t2) { + this.onError(e2.id, t2); + } + } + register(e2 = this.url) { + if (!isWsUrl(e2)) + throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); + if (this.registering) { + const t2 = this.events.getMaxListeners(); + return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n4, o2) => { + this.events.once("register_error", (s2) => { + this.resetMaxListeners(), o2(s2); + }), this.events.once("open", () => { + if (this.resetMaxListeners(), typeof this.socket > "u") + return o2(new Error("WebSocket connection is missing or invalid")); + n4(this.socket); + }); + }); + } + return this.url = e2, this.registering = true, new Promise((t2, n4) => { + const o2 = new URLSearchParams(e2).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e2) }, i2 = new S$2(e2, [], s2); + b2() ? i2.onerror = (r3) => { + const l2 = r3; + n4(this.emitError(l2.error)); + } : i2.on("error", (r3) => { + n4(this.emitError(r3)); + }), i2.onopen = () => { + this.onOpen(i2), t2(i2); + }; + }); + } + onOpen(e2) { + e2.onmessage = (t2) => this.onPayload(t2), e2.onclose = (t2) => this.onClose(t2), this.socket = e2, this.registering = false, this.events.emit("open"); + } + onClose(e2) { + this.socket = void 0, this.registering = false, this.events.emit("close", e2); + } + onPayload(e2) { + if (typeof e2.data > "u") + return; + const t2 = typeof e2.data == "string" ? safeJsonParse(e2.data) : e2.data; + this.events.emit("payload", t2); + } + onError(e2, t2) { + const n4 = this.parseError(t2), o2 = n4.message || n4.toString(), s2 = formatJsonRpcError(e2, o2); + this.events.emit("payload", s2); + } + parseError(e2, t2 = this.url) { + return parseConnectionError(e2, a2(t2), "WS"); + } + resetMaxListeners() { + this.events.getMaxListeners() > h3 && this.events.setMaxListeners(h3); + } + emitError(e2) { + const t2 = this.parseError(new Error((e2 == null ? void 0 : e2.message) || `WebSocket connection failed for host: ${a2(this.url)}`)); + return this.events.emit("register_error", t2), t2; + } +}; +var lodash_isequal = { exports: {} }; +lodash_isequal.exports; +(function(module2, exports2) { + var LARGE_ARRAY_SIZE = 200; + var HASH_UNDEFINED = "__lodash_hash_undefined__"; + var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; + var MAX_SAFE_INTEGER = 9007199254740991; + var argsTag = "[object Arguments]", arrayTag = "[object Array]", asyncTag = "[object AsyncFunction]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", nullTag = "[object Null]", objectTag = "[object Object]", promiseTag = "[object Promise]", proxyTag = "[object Proxy]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", undefinedTag = "[object Undefined]", weakMapTag = "[object WeakMap]"; + var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; + var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + var reIsHostCtor = /^\[object .+?Constructor\]$/; + var reIsUint = /^(?:0|[1-9]\d*)$/; + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; + var freeSelf = typeof self == "object" && self && self.Object === Object && self; + var root = freeGlobal || freeSelf || Function("return this")(); + var freeExports = exports2 && !exports2.nodeType && exports2; + var freeModule = freeExports && true && module2 && !module2.nodeType && module2; + var moduleExports = freeModule && freeModule.exports === freeExports; + var freeProcess = moduleExports && freeGlobal.process; + var nodeUtil = function() { + try { + return freeProcess && freeProcess.binding && freeProcess.binding("util"); + } catch (e2) { + } + }(); + var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + function arrayFilter(array, predicate) { + var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; + } + function arrayPush(array, values) { + var index = -1, length = values.length, offset = array.length; + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + function arraySome(array, predicate) { + var index = -1, length = array == null ? 0 : array.length; + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; + } + function baseTimes(n4, iteratee) { + var index = -1, result = Array(n4); + while (++index < n4) { + result[index] = iteratee(index); + } + return result; + } + function baseUnary(func) { + return function(value) { + return func(value); + }; + } + function cacheHas(cache, key) { + return cache.has(key); + } + function getValue(object, key) { + return object == null ? void 0 : object[key]; + } + function mapToArray(map) { + var index = -1, result = Array(map.size); + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; + } + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } + function setToArray(set2) { + var index = -1, result = Array(set2.size); + set2.forEach(function(value) { + result[++index] = value; + }); + return result; + } + var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype; + var coreJsData = root["__core-js_shared__"]; + var funcToString = funcProto.toString; + var hasOwnProperty = objectProto.hasOwnProperty; + var maskSrcKey = function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); + return uid ? "Symbol(src)_1." + uid : ""; + }(); + var nativeObjectToString = objectProto.toString; + var reIsNative = RegExp( + "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" + ); + var Buffer2 = moduleExports ? root.Buffer : void 0, Symbol2 = root.Symbol, Uint8Array2 = root.Uint8Array, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0; + var nativeGetSymbols = Object.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0, nativeKeys = overArg(Object.keys, Object); + var DataView2 = getNative(root, "DataView"), Map2 = getNative(root, "Map"), Promise2 = getNative(root, "Promise"), Set2 = getNative(root, "Set"), WeakMap2 = getNative(root, "WeakMap"), nativeCreate = getNative(Object, "create"); + var dataViewCtorString = toSource(DataView2), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2); + var symbolProto = Symbol2 ? Symbol2.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0; + function Hash(entries) { + var index = -1, length = entries == null ? 0 : entries.length; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; + } + function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; + } + function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? void 0 : result; + } + return hasOwnProperty.call(data, key) ? data[key] : void 0; + } + function hashHas(key) { + var data = this.__data__; + return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key); + } + function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value; + return this; + } + Hash.prototype.clear = hashClear; + Hash.prototype["delete"] = hashDelete; + Hash.prototype.get = hashGet; + Hash.prototype.has = hashHas; + Hash.prototype.set = hashSet; + function ListCache(entries) { + var index = -1, length = entries == null ? 0 : entries.length; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + function listCacheClear() { + this.__data__ = []; + this.size = 0; + } + function listCacheDelete(key) { + var data = this.__data__, index = assocIndexOf(data, key); + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; + } + function listCacheGet(key) { + var data = this.__data__, index = assocIndexOf(data, key); + return index < 0 ? void 0 : data[index][1]; + } + function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; + } + function listCacheSet(key, value) { + var data = this.__data__, index = assocIndexOf(data, key); + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; + } + ListCache.prototype.clear = listCacheClear; + ListCache.prototype["delete"] = listCacheDelete; + ListCache.prototype.get = listCacheGet; + ListCache.prototype.has = listCacheHas; + ListCache.prototype.set = listCacheSet; + function MapCache(entries) { + var index = -1, length = entries == null ? 0 : entries.length; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + function mapCacheClear() { + this.size = 0; + this.__data__ = { + "hash": new Hash(), + "map": new (Map2 || ListCache)(), + "string": new Hash() + }; + } + function mapCacheDelete(key) { + var result = getMapData(this, key)["delete"](key); + this.size -= result ? 1 : 0; + return result; + } + function mapCacheGet(key) { + return getMapData(this, key).get(key); + } + function mapCacheHas(key) { + return getMapData(this, key).has(key); + } + function mapCacheSet(key, value) { + var data = getMapData(this, key), size = data.size; + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; + } + MapCache.prototype.clear = mapCacheClear; + MapCache.prototype["delete"] = mapCacheDelete; + MapCache.prototype.get = mapCacheGet; + MapCache.prototype.has = mapCacheHas; + MapCache.prototype.set = mapCacheSet; + function SetCache(values) { + var index = -1, length = values == null ? 0 : values.length; + this.__data__ = new MapCache(); + while (++index < length) { + this.add(values[index]); + } + } + function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; + } + function setCacheHas(value) { + return this.__data__.has(value); + } + SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; + SetCache.prototype.has = setCacheHas; + function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; + } + function stackClear() { + this.__data__ = new ListCache(); + this.size = 0; + } + function stackDelete(key) { + var data = this.__data__, result = data["delete"](key); + this.size = data.size; + return result; + } + function stackGet(key) { + return this.__data__.get(key); + } + function stackHas(key) { + return this.__data__.has(key); + } + function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; + } + Stack.prototype.clear = stackClear; + Stack.prototype["delete"] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; + function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; + for (var key in value) { + if (hasOwnProperty.call(value, key) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. + (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. + isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. + isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. + isIndex(key, length)))) { + result.push(key); + } + } + return result; + } + function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; + } + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); + } + function baseGetTag(value) { + if (value == null) { + return value === void 0 ? undefinedTag : nullTag; + } + return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); + } + function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; + } + function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); + } + function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other); + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack()); + return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__"); + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; + stack || (stack = new Stack()); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack()); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); + } + function baseIsNative(value) { + if (!isObject2(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); + } + function baseIsTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; + } + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != "constructor") { + result.push(key); + } + } + return result; + } + function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; + } + var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : void 0; + stack.set(array, other); + stack.set(other, array); + while (++index < arrLength) { + var arrValue = array[index], othValue = other[index]; + if (customizer) { + var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== void 0) { + if (compared) { + continue; + } + result = false; + break; + } + if (seen) { + if (!arraySome(other, function(othValue2, othIndex) { + if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + result = false; + break; + } + } + stack["delete"](array); + stack["delete"](other); + return result; + } + function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { + return false; + } + object = object.buffer; + other = other.buffer; + case arrayBufferTag: + if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) { + return false; + } + return true; + case boolTag: + case dateTag: + case numberTag: + return eq(+object, +other); + case errorTag: + return object.name == other.name && object.message == other.message; + case regexpTag: + case stringTag: + return object == other + ""; + case mapTag: + var convert2 = mapToArray; + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert2 || (convert2 = setToArray); + if (object.size != other.size && !isPartial) { + return false; + } + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; + stack.set(object, other); + var result = equalArrays(convert2(object), convert2(other), bitmask, customizer, equalFunc, stack); + stack["delete"](object); + return result; + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; + } + function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], othValue = other[key]; + if (customizer) { + var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); + } + if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { + result = false; + break; + } + skipCtor || (skipCtor = key == "constructor"); + } + if (result && !skipCtor) { + var objCtor = object.constructor, othCtor = other.constructor; + if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { + result = false; + } + } + stack["delete"](object); + stack["delete"](other); + return result; + } + function getAllKeys(object) { + return baseGetAllKeys(object, keys2, getSymbols); + } + function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; + } + function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : void 0; + } + function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; + try { + value[symToStringTag] = void 0; + var unmasked = true; + } catch (e2) { + } + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; + } + var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); + }; + var getTag = baseGetTag; + if (DataView2 && getTag(new DataView2(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) { + getTag = function(value) { + var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : ""; + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: + return dataViewTag; + case mapCtorString: + return mapTag; + case promiseCtorString: + return promiseTag; + case setCtorString: + return setTag; + case weakMapCtorString: + return weakMapTag; + } + } + return result; + }; + } + function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); + } + function isKeyable(value) { + var type2 = typeof value; + return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null; + } + function isMasked(func) { + return !!maskSrcKey && maskSrcKey in func; + } + function isPrototype(value) { + var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto; + return value === proto; + } + function objectToString(value) { + return nativeObjectToString.call(value); + } + function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e2) { + } + try { + return func + ""; + } catch (e2) { + } + } + return ""; + } + function eq(value, other) { + return value === other || value !== value && other !== other; + } + var isArguments = baseIsArguments(/* @__PURE__ */ function() { + return arguments; + }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); + }; + var isArray = Array.isArray; + function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); + } + var isBuffer = nativeIsBuffer || stubFalse; + function isEqual(value, other) { + return baseIsEqual(value, other); + } + function isFunction(value) { + if (!isObject2(value)) { + return false; + } + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; + } + function isLength(value) { + return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + function isObject2(value) { + var type2 = typeof value; + return value != null && (type2 == "object" || type2 == "function"); + } + function isObjectLike(value) { + return value != null && typeof value == "object"; + } + var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + function keys2(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + } + function stubArray() { + return []; + } + function stubFalse() { + return false; + } + module2.exports = isEqual; +})(lodash_isequal, lodash_isequal.exports); +var lodash_isequalExports = lodash_isequal.exports; +const Yi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); +function unfetch_module(e2, n4) { + return n4 = n4 || {}, new Promise(function(t2, r3) { + var s2 = new XMLHttpRequest(), o2 = [], u3 = [], i2 = {}, a3 = function() { + return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() { + return Promise.resolve(s2.responseText); + }, json: function() { + return Promise.resolve(s2.responseText).then(JSON.parse); + }, blob: function() { + return Promise.resolve(new Blob([s2.response])); + }, clone: a3, headers: { keys: function() { + return o2; + }, entries: function() { + return u3; + }, get: function(e3) { + return i2[e3.toLowerCase()]; + }, has: function(e3) { + return e3.toLowerCase() in i2; + } } }; + }; + for (var l2 in s2.open(n4.method || "get", e2, true), s2.onload = function() { + s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e3, n5, t3) { + o2.push(n5 = n5.toLowerCase()), u3.push([n5, t3]), i2[n5] = i2[n5] ? i2[n5] + "," + t3 : t3; + }), t2(a3()); + }, s2.onerror = r3, s2.withCredentials = "include" == n4.credentials, n4.headers) + s2.setRequestHeader(l2, n4.headers[l2]); + s2.send(n4.body || null); + }); +} +const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + default: unfetch_module +}, Symbol.toStringTag, { value: "Module" })); +const require$$0 = /* @__PURE__ */ getAugmentedNamespace(unfetch_module$1); +var browser$2 = fetch || (self.fetch = require$$0.default || require$$0); +const Hi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); +function Ji(n4, e2) { + if (n4.length >= 255) + throw new TypeError("Alphabet too long"); + for (var t2 = new Uint8Array(256), i2 = 0; i2 < t2.length; i2++) + t2[i2] = 255; + for (var s2 = 0; s2 < n4.length; s2++) { + var r3 = n4.charAt(s2), o2 = r3.charCodeAt(0); + if (t2[o2] !== 255) + throw new TypeError(r3 + " is ambiguous"); + t2[o2] = s2; + } + var a3 = n4.length, h4 = n4.charAt(0), l2 = Math.log(a3) / Math.log(256), d5 = Math.log(256) / Math.log(a3); + function g3(u3) { + if (u3 instanceof Uint8Array || (ArrayBuffer.isView(u3) ? u3 = new Uint8Array(u3.buffer, u3.byteOffset, u3.byteLength) : Array.isArray(u3) && (u3 = Uint8Array.from(u3))), !(u3 instanceof Uint8Array)) + throw new TypeError("Expected Uint8Array"); + if (u3.length === 0) + return ""; + for (var p2 = 0, _3 = 0, D2 = 0, P2 = u3.length; D2 !== P2 && u3[D2] === 0; ) + D2++, p2++; + for (var x2 = (P2 - D2) * d5 + 1 >>> 0, E2 = new Uint8Array(x2); D2 !== P2; ) { + for (var O3 = u3[D2], N2 = 0, R2 = x2 - 1; (O3 !== 0 || N2 < _3) && R2 !== -1; R2--, N2++) + O3 += 256 * E2[R2] >>> 0, E2[R2] = O3 % a3 >>> 0, O3 = O3 / a3 >>> 0; + if (O3 !== 0) + throw new Error("Non-zero carry"); + _3 = N2, D2++; + } + for (var A2 = x2 - _3; A2 !== x2 && E2[A2] === 0; ) + A2++; + for (var j2 = h4.repeat(p2); A2 < x2; ++A2) + j2 += n4.charAt(E2[A2]); + return j2; + } + function m3(u3) { + if (typeof u3 != "string") + throw new TypeError("Expected String"); + if (u3.length === 0) + return new Uint8Array(); + var p2 = 0; + if (u3[p2] !== " ") { + for (var _3 = 0, D2 = 0; u3[p2] === h4; ) + _3++, p2++; + for (var P2 = (u3.length - p2) * l2 + 1 >>> 0, x2 = new Uint8Array(P2); u3[p2]; ) { + var E2 = t2[u3.charCodeAt(p2)]; + if (E2 === 255) + return; + for (var O3 = 0, N2 = P2 - 1; (E2 !== 0 || O3 < D2) && N2 !== -1; N2--, O3++) + E2 += a3 * x2[N2] >>> 0, x2[N2] = E2 % 256 >>> 0, E2 = E2 / 256 >>> 0; + if (E2 !== 0) + throw new Error("Non-zero carry"); + D2 = O3, p2++; + } + if (u3[p2] !== " ") { + for (var R2 = P2 - D2; R2 !== P2 && x2[R2] === 0; ) + R2++; + for (var A2 = new Uint8Array(_3 + (P2 - R2)), j2 = _3; R2 !== P2; ) + A2[j2++] = x2[R2++]; + return A2; + } + } + } + function L4(u3) { + var p2 = m3(u3); + if (p2) + return p2; + throw new Error(`Non-${e2} character`); + } + return { encode: g3, decodeUnsafe: m3, decode: L4 }; +} +var Xi = Ji, Wi = Xi; +const Ue$1 = (n4) => { + if (n4 instanceof Uint8Array && n4.constructor.name === "Uint8Array") + return n4; + if (n4 instanceof ArrayBuffer) + return new Uint8Array(n4); + if (ArrayBuffer.isView(n4)) + return new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength); + throw new Error("Unknown type, must be binary type"); +}, Qi = (n4) => new TextEncoder().encode(n4), Zi = (n4) => new TextDecoder().decode(n4); +let es$1 = class es { + constructor(e2, t2, i2) { + this.name = e2, this.prefix = t2, this.baseEncode = i2; + } + encode(e2) { + if (e2 instanceof Uint8Array) + return `${this.prefix}${this.baseEncode(e2)}`; + throw Error("Unknown type, must be binary type"); + } +}; +let ts$1 = class ts { + constructor(e2, t2, i2) { + if (this.name = e2, this.prefix = t2, t2.codePointAt(0) === void 0) + throw new Error("Invalid prefix character"); + this.prefixCodePoint = t2.codePointAt(0), this.baseDecode = i2; + } + decode(e2) { + if (typeof e2 == "string") { + if (e2.codePointAt(0) !== this.prefixCodePoint) + throw Error(`Unable to decode multibase string ${JSON.stringify(e2)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); + return this.baseDecode(e2.slice(this.prefix.length)); + } else + throw Error("Can only multibase decode strings"); + } + or(e2) { + return $e(this, e2); + } +}; +let is$1 = class is { + constructor(e2) { + this.decoders = e2; + } + or(e2) { + return $e(this, e2); + } + decode(e2) { + const t2 = e2[0], i2 = this.decoders[t2]; + if (i2) + return i2.decode(e2); + throw RangeError(`Unable to decode multibase string ${JSON.stringify(e2)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + } +}; +const $e = (n4, e2) => new is$1({ ...n4.decoders || { [n4.prefix]: n4 }, ...e2.decoders || { [e2.prefix]: e2 } }); +let ss$2 = class ss { + constructor(e2, t2, i2, s2) { + this.name = e2, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new es$1(e2, t2, i2), this.decoder = new ts$1(e2, t2, s2); + } + encode(e2) { + return this.encoder.encode(e2); + } + decode(e2) { + return this.decoder.decode(e2); + } +}; +const Q$1 = ({ name: n4, prefix: e2, encode: t2, decode: i2 }) => new ss$2(n4, e2, t2, i2), K$1 = ({ prefix: n4, name: e2, alphabet: t2 }) => { + const { encode: i2, decode: s2 } = Wi(t2, e2); + return Q$1({ prefix: n4, name: e2, encode: i2, decode: (r3) => Ue$1(s2(r3)) }); +}, rs$1 = (n4, e2, t2, i2) => { + const s2 = {}; + for (let d5 = 0; d5 < e2.length; ++d5) + s2[e2[d5]] = d5; + let r3 = n4.length; + for (; n4[r3 - 1] === "="; ) + --r3; + const o2 = new Uint8Array(r3 * t2 / 8 | 0); + let a3 = 0, h4 = 0, l2 = 0; + for (let d5 = 0; d5 < r3; ++d5) { + const g3 = s2[n4[d5]]; + if (g3 === void 0) + throw new SyntaxError(`Non-${i2} character`); + h4 = h4 << t2 | g3, a3 += t2, a3 >= 8 && (a3 -= 8, o2[l2++] = 255 & h4 >> a3); + } + if (a3 >= t2 || 255 & h4 << 8 - a3) + throw new SyntaxError("Unexpected end of data"); + return o2; +}, ns = (n4, e2, t2) => { + const i2 = e2[e2.length - 1] === "=", s2 = (1 << t2) - 1; + let r3 = "", o2 = 0, a3 = 0; + for (let h4 = 0; h4 < n4.length; ++h4) + for (a3 = a3 << 8 | n4[h4], o2 += 8; o2 > t2; ) + o2 -= t2, r3 += e2[s2 & a3 >> o2]; + if (o2 && (r3 += e2[s2 & a3 << t2 - o2]), i2) + for (; r3.length * t2 & 7; ) + r3 += "="; + return r3; +}, y2 = ({ name: n4, prefix: e2, bitsPerChar: t2, alphabet: i2 }) => Q$1({ prefix: e2, name: n4, encode(s2) { + return ns(s2, i2, t2); +}, decode(s2) { + return rs$1(s2, i2, t2, n4); +} }), os$1 = Q$1({ prefix: "\0", name: "identity", encode: (n4) => Zi(n4), decode: (n4) => Qi(n4) }); +var as$1 = Object.freeze({ __proto__: null, identity: os$1 }); +const hs$1 = y2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); +var cs$1 = Object.freeze({ __proto__: null, base2: hs$1 }); +const ls$1 = y2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); +var us$1 = Object.freeze({ __proto__: null, base8: ls$1 }); +const ds$1 = K$1({ prefix: "9", name: "base10", alphabet: "0123456789" }); +var gs$1 = Object.freeze({ __proto__: null, base10: ds$1 }); +const ps$1 = y2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), Ds$1 = y2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); +var ys$1 = Object.freeze({ __proto__: null, base16: ps$1, base16upper: Ds$1 }); +const ms$2 = y2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), bs$1 = y2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), fs = y2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), Es$1 = y2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), ws$1 = y2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), vs$1 = y2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), Is$1 = y2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Cs$1 = y2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), _s$1 = y2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); +var Rs$1 = Object.freeze({ __proto__: null, base32: ms$2, base32upper: bs$1, base32pad: fs, base32padupper: Es$1, base32hex: ws$1, base32hexupper: vs$1, base32hexpad: Is$1, base32hexpadupper: Cs$1, base32z: _s$1 }); +const Ts$1 = K$1({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ss$1 = K$1({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); +var Ps$1 = Object.freeze({ __proto__: null, base36: Ts$1, base36upper: Ss$1 }); +const xs$1 = K$1({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), Os$1 = K$1({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); +var As$1 = Object.freeze({ __proto__: null, base58btc: xs$1, base58flickr: Os$1 }); +const zs$1 = y2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), Ns$1 = y2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ls$1 = y2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us$1 = y2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); +var $s$1 = Object.freeze({ __proto__: null, base64: zs$1, base64pad: Ns$1, base64url: Ls$1, base64urlpad: Us$1 }); +const Fe$1 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), Fs$1 = Fe$1.reduce((n4, e2, t2) => (n4[t2] = e2, n4), []), ks$1 = Fe$1.reduce((n4, e2, t2) => (n4[e2.codePointAt(0)] = t2, n4), []); +function Bs$1(n4) { + return n4.reduce((e2, t2) => (e2 += Fs$1[t2], e2), ""); +} +function Ms$1(n4) { + const e2 = []; + for (const t2 of n4) { + const i2 = ks$1[t2.codePointAt(0)]; + if (i2 === void 0) + throw new Error(`Non-base256emoji character: ${t2}`); + e2.push(i2); + } + return new Uint8Array(e2); +} +const Ks$1 = Q$1({ prefix: "🚀", name: "base256emoji", encode: Bs$1, decode: Ms$1 }); +var Vs$1 = Object.freeze({ __proto__: null, base256emoji: Ks$1 }), qs$1 = Be$2, ke$1 = 128, js$1 = 127, Gs$1 = ~js$1, Ys$1 = Math.pow(2, 31); +function Be$2(n4, e2, t2) { + e2 = e2 || [], t2 = t2 || 0; + for (var i2 = t2; n4 >= Ys$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 /= 128; + for (; n4 & Gs$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 >>>= 7; + return e2[t2] = n4 | 0, Be$2.bytes = t2 - i2 + 1, e2; +} +var Hs$1 = de$1, Js$1 = 128, Me = 127; +function de$1(n4, i2) { + var t2 = 0, i2 = i2 || 0, s2 = 0, r3 = i2, o2, a3 = n4.length; + do { + if (r3 >= a3) + throw de$1.bytes = 0, new RangeError("Could not decode varint"); + o2 = n4[r3++], t2 += s2 < 28 ? (o2 & Me) << s2 : (o2 & Me) * Math.pow(2, s2), s2 += 7; + } while (o2 >= Js$1); + return de$1.bytes = r3 - i2, t2; +} +var Xs$1 = Math.pow(2, 7), Ws$1 = Math.pow(2, 14), Qs$1 = Math.pow(2, 21), Zs$1 = Math.pow(2, 28), er = Math.pow(2, 35), tr$1 = Math.pow(2, 42), ir$1 = Math.pow(2, 49), sr$1 = Math.pow(2, 56), rr$1 = Math.pow(2, 63), nr$1 = function(n4) { + return n4 < Xs$1 ? 1 : n4 < Ws$1 ? 2 : n4 < Qs$1 ? 3 : n4 < Zs$1 ? 4 : n4 < er ? 5 : n4 < tr$1 ? 6 : n4 < ir$1 ? 7 : n4 < sr$1 ? 8 : n4 < rr$1 ? 9 : 10; +}, or$1 = { encode: qs$1, decode: Hs$1, encodingLength: nr$1 }, Ke$1 = or$1; +const Ve = (n4, e2, t2 = 0) => (Ke$1.encode(n4, e2, t2), e2), qe = (n4) => Ke$1.encodingLength(n4), ge = (n4, e2) => { + const t2 = e2.byteLength, i2 = qe(n4), s2 = i2 + qe(t2), r3 = new Uint8Array(s2 + t2); + return Ve(n4, r3, 0), Ve(t2, r3, i2), r3.set(e2, s2), new ar$1(n4, t2, e2, r3); +}; +let ar$1 = class ar { + constructor(e2, t2, i2, s2) { + this.code = e2, this.size = t2, this.digest = i2, this.bytes = s2; + } +}; +const je$1 = ({ name: n4, code: e2, encode: t2 }) => new hr$1(n4, e2, t2); +let hr$1 = class hr { + constructor(e2, t2, i2) { + this.name = e2, this.code = t2, this.encode = i2; + } + digest(e2) { + if (e2 instanceof Uint8Array) { + const t2 = this.encode(e2); + return t2 instanceof Uint8Array ? ge(this.code, t2) : t2.then((i2) => ge(this.code, i2)); + } else + throw Error("Unknown type, must be binary type"); + } +}; +const Ge$1 = (n4) => async (e2) => new Uint8Array(await crypto.subtle.digest(n4, e2)), cr$1 = je$1({ name: "sha2-256", code: 18, encode: Ge$1("SHA-256") }), lr = je$1({ name: "sha2-512", code: 19, encode: Ge$1("SHA-512") }); +var ur$1 = Object.freeze({ __proto__: null, sha256: cr$1, sha512: lr }); +const Ye$1 = 0, dr$1 = "identity", He$1 = Ue$1, gr$1 = (n4) => ge(Ye$1, He$1(n4)), pr = { code: Ye$1, name: dr$1, encode: He$1, digest: gr$1 }; +var Dr$1 = Object.freeze({ __proto__: null, identity: pr }); +new TextEncoder(), new TextDecoder(); +const Je$1 = { ...as$1, ...cs$1, ...us$1, ...gs$1, ...ys$1, ...Rs$1, ...Ps$1, ...As$1, ...$s$1, ...Vs$1 }; +({ ...ur$1, ...Dr$1 }); +function Xe$2(n4) { + return globalThis.Buffer != null ? new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength) : n4; +} +function yr$1(n4 = 0) { + return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? Xe$2(globalThis.Buffer.allocUnsafe(n4)) : new Uint8Array(n4); +} +function We$1(n4, e2, t2, i2) { + return { name: n4, prefix: e2, encoder: { name: n4, prefix: e2, encode: t2 }, decoder: { decode: i2 } }; +} +const Qe$1 = We$1("utf8", "u", (n4) => "u" + new TextDecoder("utf8").decode(n4), (n4) => new TextEncoder().encode(n4.substring(1))), pe$1 = We$1("ascii", "a", (n4) => { + let e2 = "a"; + for (let t2 = 0; t2 < n4.length; t2++) + e2 += String.fromCharCode(n4[t2]); + return e2; +}, (n4) => { + n4 = n4.substring(1); + const e2 = yr$1(n4.length); + for (let t2 = 0; t2 < n4.length; t2++) + e2[t2] = n4.charCodeAt(t2); + return e2; +}), mr$1 = { utf8: Qe$1, "utf-8": Qe$1, hex: Je$1.base16, latin1: pe$1, ascii: pe$1, binary: pe$1, ...Je$1 }; +function br(n4, e2 = "utf8") { + const t2 = mr$1[e2]; + if (!t2) + throw new Error(`Unsupported encoding "${e2}"`); + return (e2 === "utf8" || e2 === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? Xe$2(globalThis.Buffer.from(n4, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n4}`); +} +const De = "wc", Ze$1 = 2, Z = "core", z$1 = `${De}@2:${Z}:`, et = { name: Z, logger: "error" }, tt = { database: ":memory:" }, it = "crypto", ye$1 = "client_ed25519_seed", st = cjs$3.ONE_DAY, rt = "keychain", nt = "0.3", ot = "messages", at = "0.3", ht = cjs$3.SIX_HOURS, ct = "publisher", lt = "irn", ut = "error", me = "wss://relay.walletconnect.com", be$1 = "wss://relay.walletconnect.org", dt = "relayer", v2 = { 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" }, gt = "_subscription", f$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, pt = cjs$3.ONE_SECOND, Dt$1 = "2.12.2", yt = 1e4, mt = "0.3", bt = "WALLETCONNECT_CLIENT_ID", S$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, ft = "subscription", Et = "0.3", wt = cjs$3.FIVE_SECONDS * 1e3, vt = "pairing", It = "0.3", F$1 = { wc_pairingDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 } } }, V$1 = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, I$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, Ct = "history", _t = "0.3", Rt = "expirer", C = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Tt$1 = "0.3", ee = "verify-api", k$1 = "https://verify.walletconnect.com", te = "https://verify.walletconnect.org", St = [k$1, te], Pt = "echo", xt = "https://echo.walletconnect.com"; +let Ot$1 = class Ot { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = rt, this.version = nt, this.initialized = false, this.storagePrefix = z$1, this.init = async () => { + if (!this.initialized) { + const i2 = await this.getKeyChain(); + typeof i2 < "u" && (this.keychain = i2), this.initialized = true; + } + }, this.has = (i2) => (this.isInitialized(), this.keychain.has(i2)), this.set = async (i2, s2) => { + this.isInitialized(), this.keychain.set(i2, s2), await this.persist(); + }, this.get = (i2) => { + this.isInitialized(); + const s2 = this.keychain.get(i2); + if (typeof s2 > "u") { + const { message: r3 } = xe("NO_MATCHING_KEY", `${this.name}: ${i2}`); + throw new Error(r3); + } + return s2; + }, this.del = async (i2) => { + this.isInitialized(), this.keychain.delete(i2), await this.persist(); + }, this.core = e2, this.logger = E$1(t2, this.name); + } + get context() { + return y$2(this.logger); + } + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; + } + async setKeyChain(e2) { + await this.core.storage.setItem(this.storageKey, i0(e2)); + } + async getKeyChain() { + const e2 = await this.core.storage.getItem(this.storageKey); + return typeof e2 < "u" ? n0(e2) : void 0; + } + async persist() { + await this.setKeyChain(this.keychain); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +}; +class At { + constructor(e2, t2, i2) { + this.core = e2, this.logger = t2, this.name = it, this.initialized = false, this.init = async () => { + this.initialized || (await this.keychain.init(), this.initialized = true); + }, this.hasKeys = (s2) => (this.isInitialized(), this.keychain.has(s2)), this.getClientId = async () => { + this.isInitialized(); + const s2 = await this.getClientSeed(), r3 = generateKeyPair(s2); + return encodeIss(r3.publicKey); + }, this.generateKeyPair = () => { + this.isInitialized(); + const s2 = mu(); + return this.setPrivateKey(s2.publicKey, s2.privateKey); + }, this.signJWT = async (s2) => { + this.isInitialized(); + const r3 = await this.getClientSeed(), o2 = generateKeyPair(r3), a3 = gu(), h4 = st; + return await signJWT(a3, s2, h4, o2); + }, this.generateSharedKey = (s2, r3, o2) => { + this.isInitialized(); + const a3 = this.getPrivateKey(s2), h4 = Au(a3, r3); + return this.setSymKey(h4, o2); + }, this.setSymKey = async (s2, r3) => { + this.isInitialized(); + const o2 = r3 || bu(s2); + return await this.keychain.set(o2, s2), o2; + }, this.deleteKeyPair = async (s2) => { + this.isInitialized(), await this.keychain.del(s2); + }, this.deleteSymKey = async (s2) => { + this.isInitialized(), await this.keychain.del(s2); + }, this.encode = async (s2, r3, o2) => { + this.isInitialized(); + const a3 = eo(o2), h4 = safeJsonStringify(r3); + if (Eu(a3)) { + const m3 = a3.senderPublicKey, L4 = a3.receiverPublicKey; + s2 = await this.generateSharedKey(m3, L4); + } + const l2 = this.getSymKey(s2), { type: d5, senderPublicKey: g3 } = a3; + return wu({ type: d5, symKey: l2, message: h4, senderPublicKey: g3 }); + }, this.decode = async (s2, r3, o2) => { + this.isInitialized(); + const a3 = Mu(r3, o2); + if (Eu(a3)) { + const h4 = a3.receiverPublicKey, l2 = a3.senderPublicKey; + s2 = await this.generateSharedKey(h4, l2); + } + try { + const h4 = this.getSymKey(s2), l2 = xu({ symKey: h4, encoded: r3 }); + return safeJsonParse(l2); + } catch (h4) { + this.logger.error(`Failed to decode message from topic: '${s2}', clientId: '${await this.getClientId()}'`), this.logger.error(h4); + } + }, this.getPayloadType = (s2) => { + const r3 = Xi$1(s2); + return Mr(r3.type); + }, this.getPayloadSenderPublicKey = (s2) => { + const r3 = Xi$1(s2); + return r3.senderPublicKey ? toString(r3.senderPublicKey, zt$1) : void 0; + }, this.core = e2, this.logger = E$1(t2, this.name), this.keychain = i2 || new Ot$1(this.core, this.logger); + } + get context() { + return y$2(this.logger); + } + async setPrivateKey(e2, t2) { + return await this.keychain.set(e2, t2), e2; + } + getPrivateKey(e2) { + return this.keychain.get(e2); + } + async getClientSeed() { + let e2 = ""; + try { + e2 = this.keychain.get(ye$1); + } catch { + e2 = gu(), await this.keychain.set(ye$1, e2); + } + return br(e2, "base16"); + } + getSymKey(e2) { + return this.keychain.get(e2); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +} +class zt extends a$1 { + constructor(e2, t2) { + super(e2, t2), this.logger = e2, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = ot, this.version = at, this.initialized = false, this.storagePrefix = z$1, this.init = async () => { + if (!this.initialized) { + this.logger.trace("Initialized"); + try { + const i2 = await this.getRelayerMessages(); + typeof i2 < "u" && (this.messages = i2), this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", size: this.messages.size }); + } catch (i2) { + this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(i2); + } finally { + this.initialized = true; + } + } + }, this.set = async (i2, s2) => { + this.isInitialized(); + const r3 = yu(s2); + let o2 = this.messages.get(i2); + return typeof o2 > "u" && (o2 = {}), typeof o2[r3] < "u" || (o2[r3] = s2, this.messages.set(i2, o2), await this.persist()), r3; + }, this.get = (i2) => { + this.isInitialized(); + let s2 = this.messages.get(i2); + return typeof s2 > "u" && (s2 = {}), s2; + }, this.has = (i2, s2) => { + this.isInitialized(); + const r3 = this.get(i2), o2 = yu(s2); + return typeof r3[o2] < "u"; + }, this.del = async (i2) => { + this.isInitialized(), this.messages.delete(i2), await this.persist(); + }, this.logger = E$1(e2, this.name), this.core = t2; + } + get context() { + return y$2(this.logger); + } + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; + } + async setRelayerMessages(e2) { + await this.core.storage.setItem(this.storageKey, i0(e2)); + } + async getRelayerMessages() { + const e2 = await this.core.storage.getItem(this.storageKey); + return typeof e2 < "u" ? n0(e2) : void 0; + } + async persist() { + await this.setRelayerMessages(this.messages); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +} +class Ir extends u$1 { + constructor(e2, t2) { + super(e2, t2), this.relayer = e2, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = ct, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.failedPublishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_SECOND), this.needsTransportRestart = false, this.publish = async (i2, s2, r3) => { + var o2; + this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r3 } }); + const a3 = (r3 == null ? void 0 : r3.ttl) || ht, h4 = Su(r3), l2 = (r3 == null ? void 0 : r3.prompt) || false, d5 = (r3 == null ? void 0 : r3.tag) || 0, g3 = (r3 == null ? void 0 : r3.id) || getBigIntRpcId().toString(), m3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d5, id: g3 } }, L4 = `Failed to publish payload, please try again. id:${g3} tag:${d5}`, u3 = Date.now(); + let p2, _3 = 1; + try { + for (; p2 === void 0; ) { + if (Date.now() - u3 > this.publishTimeout) + throw new Error(L4); + this.logger.trace({ id: g3, attempts: _3 }, `publisher.publish - attempt ${_3}`), p2 = await await u0(this.rpcPublish(i2, s2, a3, h4, l2, d5, g3).catch((D2) => this.logger.warn(D2)), this.publishTimeout, L4), _3++, p2 || await new Promise((D2) => setTimeout(D2, this.failedPublishTimeout)); + } + this.relayer.events.emit(v2.publish, m3), this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { id: g3, topic: i2, message: s2, opts: r3 } }); + } catch (D2) { + if (this.logger.debug("Failed to Publish Payload"), this.logger.error(D2), (o2 = r3 == null ? void 0 : r3.internal) != null && o2.throwOnFailedPublish) + throw D2; + this.queue.set(g3, m3); + } + }, this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.registerEventListeners(); + } + get context() { + return y$2(this.logger); + } + rpcPublish(e2, t2, i2, s2, r3, o2, a3) { + var h4, l2, d5, g3; + const m3 = { method: Nu(s2.protocol).publish, params: { topic: e2, message: t2, ttl: i2, prompt: r3, tag: o2 }, id: a3 }; + return Pe((h4 = m3.params) == null ? void 0 : h4.prompt) && ((l2 = m3.params) == null || delete l2.prompt), Pe((d5 = m3.params) == null ? void 0 : d5.tag) && ((g3 = m3.params) == null || delete g3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: m3 }), this.relayer.request(m3); + } + removeRequestFromQueue(e2) { + this.queue.delete(e2); + } + checkQueue() { + this.queue.forEach(async (e2) => { + const { topic: t2, message: i2, opts: s2 } = e2; + await this.publish(t2, i2, s2); + }); + } + registerEventListeners() { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { + if (this.needsTransportRestart) { + this.needsTransportRestart = false, this.relayer.events.emit(v2.connection_stalled); + return; + } + this.checkQueue(); + }), this.relayer.on(v2.message_ack, (e2) => { + this.removeRequestFromQueue(e2.id.toString()); + }); + } +} +let Cr$1 = class Cr { + constructor() { + this.map = /* @__PURE__ */ new Map(), this.set = (e2, t2) => { + const i2 = this.get(e2); + this.exists(e2, t2) || this.map.set(e2, [...i2, t2]); + }, this.get = (e2) => this.map.get(e2) || [], this.exists = (e2, t2) => this.get(e2).includes(t2), this.delete = (e2, t2) => { + if (typeof t2 > "u") { + this.map.delete(e2); + return; + } + if (!this.map.has(e2)) + return; + const i2 = this.get(e2); + if (!this.exists(e2, t2)) + return; + const s2 = i2.filter((r3) => r3 !== t2); + if (!s2.length) { + this.map.delete(e2); + return; + } + this.map.set(e2, s2); + }, this.clear = () => { + this.map.clear(); + }; + } + get topics() { + return Array.from(this.map.keys()); + } +}; +var _r = Object.defineProperty, Rr$1 = Object.defineProperties, Tr$1 = Object.getOwnPropertyDescriptors, Nt = Object.getOwnPropertySymbols, Sr = Object.prototype.hasOwnProperty, Pr$1 = Object.prototype.propertyIsEnumerable, Lt$1 = (n4, e2, t2) => e2 in n4 ? _r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, q$2 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Sr.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + if (Nt) + for (var t2 of Nt(e2)) + Pr$1.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + return n4; +}, fe$1 = (n4, e2) => Rr$1(n4, Tr$1(e2)); +let Ut$1 = class Ut2 extends d$1 { + constructor(e2, t2) { + super(e2, t2), this.relayer = e2, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Cr$1(), this.events = new eventsExports.EventEmitter(), this.name = ft, this.version = Et, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = z$1, this.subscribeTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), this.clientId = await this.relayer.core.crypto.getClientId()); + }, this.subscribe = async (i2, s2) => { + await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }); + try { + const r3 = Su(s2), o2 = { topic: i2, relay: r3 }; + this.pending.set(i2, o2); + const a3 = await this.rpcSubscribe(i2, r3); + return typeof a3 == "string" && (this.onSubscribe(a3, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } })), a3; + } catch (r3) { + throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r3), r3; + } + }, this.unsubscribe = async (i2, s2) => { + await this.restartToComplete(), this.isInitialized(), typeof (s2 == null ? void 0 : s2.id) < "u" ? await this.unsubscribeById(i2, s2.id, s2) : await this.unsubscribeByTopic(i2, s2); + }, this.isSubscribed = async (i2) => { + if (this.topics.includes(i2)) + return true; + const s2 = `${this.pendingSubscriptionWatchLabel}_${i2}`; + return await new Promise((r3, o2) => { + const a3 = new cjs$3.Watch(); + a3.start(s2); + const h4 = setInterval(() => { + !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r3(true)), a3.elapsed(s2) >= wt && (clearInterval(h4), a3.stop(s2), o2(new Error("Subscription resolution timeout"))); + }, this.pollingInterval); + }).catch(() => false); + }, this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.start = async () => { + await this.onConnect(); + }, this.stop = async () => { + await this.onDisconnect(); + }, this.restart = async () => { + this.restartInProgress = true, await this.restore(), await this.reset(), this.restartInProgress = false; + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.clientId = ""; + } + get context() { + return y$2(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(e2, t2) { + let i2 = false; + try { + i2 = this.getSubscription(e2).topic === t2; + } catch { + } + return i2; + } + onEnable() { + this.cached = [], this.initialized = true; + } + onDisable() { + this.cached = this.values, this.subscriptions.clear(), this.topicMap.clear(); + } + async unsubscribeByTopic(e2, t2) { + const i2 = this.topicMap.get(e2); + await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e2, s2, t2))); + } + async unsubscribeById(e2, t2, i2) { + this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); + try { + const s2 = Su(i2); + await this.rpcUnsubscribe(e2, t2, s2); + const r3 = tr$2("USER_DISCONNECTED", `${this.name}, ${e2}`); + await this.onUnsubscribe(e2, t2, r3), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); + } catch (s2) { + throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s2), s2; + } + } + async rpcSubscribe(e2, t2) { + const i2 = { method: Nu(t2.protocol).subscribe, params: { topic: e2 } }; + this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); + try { + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout) ? yu(e2 + this.clientId) : null; + } catch { + this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(v2.connection_stalled); + } + return null; + } + async rpcBatchSubscribe(e2) { + if (!e2.length) + return; + const t2 = e2[0].relay, i2 = { method: Nu(t2.protocol).batchSubscribe, params: { topics: e2.map((s2) => s2.topic) } }; + this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); + try { + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout); + } catch { + this.relayer.events.emit(v2.connection_stalled); + } + } + rpcUnsubscribe(e2, t2, i2) { + const s2 = { method: Nu(i2.protocol).unsubscribe, params: { topic: e2, id: t2 } }; + return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s2 }), this.relayer.request(s2); + } + onSubscribe(e2, t2) { + this.setSubscription(e2, fe$1(q$2({}, t2), { id: e2 })), this.pending.delete(t2.topic); + } + onBatchSubscribe(e2) { + e2.length && e2.forEach((t2) => { + this.setSubscription(t2.id, q$2({}, t2)), this.pending.delete(t2.topic); + }); + } + async onUnsubscribe(e2, t2, i2) { + this.events.removeAllListeners(t2), this.hasSubscription(t2, e2) && this.deleteSubscription(t2, i2), await this.relayer.messages.del(e2); + } + async setRelayerSubscriptions(e2) { + await this.relayer.core.storage.setItem(this.storageKey, e2); + } + async getRelayerSubscriptions() { + return await this.relayer.core.storage.getItem(this.storageKey); + } + setSubscription(e2, t2) { + this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e2, subscription: t2 }), this.addSubscription(e2, t2); + } + addSubscription(e2, t2) { + this.subscriptions.set(e2, q$2({}, t2)), this.topicMap.set(t2.topic, e2), this.events.emit(S$1.created, t2); + } + getSubscription(e2) { + this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e2 }); + const t2 = this.subscriptions.get(e2); + if (!t2) { + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw new Error(i2); + } + return t2; + } + deleteSubscription(e2, t2) { + this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e2, reason: t2 }); + const i2 = this.getSubscription(e2); + this.subscriptions.delete(e2), this.topicMap.delete(i2.topic, e2), this.events.emit(S$1.deleted, fe$1(q$2({}, i2), { reason: t2 })); + } + async persist() { + await this.setRelayerSubscriptions(this.values), this.events.emit(S$1.sync); + } + async reset() { + if (this.cached.length) { + const e2 = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); + for (let t2 = 0; t2 < e2; t2++) { + const i2 = this.cached.splice(0, this.batchSubscribeTopicsLimit); + await this.batchSubscribe(i2); + } + } + this.events.emit(S$1.resubscribed); + } + async restore() { + try { + const e2 = await this.getRelayerSubscriptions(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.subscriptions.size) { + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored subscriptions for ${this.name}`), this.logger.trace({ type: "method", method: "restore", subscriptions: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore subscriptions for ${this.name}`), this.logger.error(e2); + } + } + async batchSubscribe(e2) { + if (!e2.length) + return; + const t2 = await this.rpcBatchSubscribe(e2); + Er(t2) && this.onBatchSubscribe(t2.map((i2, s2) => fe$1(q$2({}, e2[s2]), { id: i2 }))); + } + async onConnect() { + await this.restart(), this.onEnable(); + } + onDisconnect() { + this.onDisable(); + } + async checkPending() { + if (!this.initialized || !this.relayer.connected) + return; + const e2 = []; + this.pending.forEach((t2) => { + e2.push(t2); + }), await this.batchSubscribe(e2); + } + registerEventListeners() { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, async () => { + await this.checkPending(); + }), this.events.on(S$1.created, async (e2) => { + const t2 = S$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); + }), this.events.on(S$1.deleted, async (e2) => { + const t2 = S$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); + }); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } + async restartToComplete() { + this.restartInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.restartInProgress || (clearInterval(t2), e2()); + }, this.pollingInterval); + }); + } +}; +var xr$1 = Object.defineProperty, $t$1 = Object.getOwnPropertySymbols, Or$1 = Object.prototype.hasOwnProperty, Ar = Object.prototype.propertyIsEnumerable, Ft$1 = (n4, e2, t2) => e2 in n4 ? xr$1(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, zr$1 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Or$1.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + if ($t$1) + for (var t2 of $t$1(e2)) + Ar.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + return n4; +}; +let kt$1 = class kt extends g$1 { + constructor(e2) { + super(e2), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = dt, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled", "interrupted"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.heartBeatTimeout = cjs$3.toMiliseconds(cjs$3.THIRTY_SECONDS + cjs$3.ONE_SECOND), this.request = async (t2) => { + var i2, s2; + this.logger.debug("Publishing Request Payload"); + const r3 = t2.id || getBigIntRpcId().toString(); + await this.toEstablishConnection(); + try { + const o2 = this.provider.request(t2); + this.requestsInFlight.set(r3, { promise: o2, request: t2 }), this.logger.trace({ id: r3, method: t2.method, topic: (i2 = t2.params) == null ? void 0 : i2.topic }, "relayer.request - attempt to publish..."); + const a3 = await new Promise(async (h4, l2) => { + const d5 = () => { + l2(new Error(`relayer.request - publish interrupted, id: ${r3}`)); + }; + this.provider.on(f$1.disconnect, d5); + const g3 = await o2; + this.provider.off(f$1.disconnect, d5), h4(g3); + }); + return this.logger.trace({ id: r3, method: t2.method, topic: (s2 = t2.params) == null ? void 0 : s2.topic }, "relayer.request - published"), a3; + } catch (o2) { + throw this.logger.debug(`Failed to Publish Request: ${r3}`), o2; + } finally { + this.requestsInFlight.delete(r3); + } + }, this.resetPingTimeout = () => { + if (pi()) + try { + clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => { + var t2, i2, s2; + (s2 = (i2 = (t2 = this.provider) == null ? void 0 : t2.connection) == null ? void 0 : i2.socket) == null || s2.terminate(); + }, this.heartBeatTimeout); + } catch (t2) { + this.logger.warn(t2); + } + }, this.onPayloadHandler = (t2) => { + this.onProviderPayload(t2), this.resetPingTimeout(); + }, this.onConnectHandler = () => { + this.startPingTimeout(), this.events.emit(v2.connect); + }, this.onDisconnectHandler = () => { + this.onProviderDisconnect(); + }, this.onProviderErrorHandler = (t2) => { + this.logger.error(t2), this.events.emit(v2.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); + }, this.registerProviderListeners = () => { + this.provider.on(f$1.payload, this.onPayloadHandler), this.provider.on(f$1.connect, this.onConnectHandler), this.provider.on(f$1.disconnect, this.onDisconnectHandler), this.provider.on(f$1.error, this.onProviderErrorHandler); + }, this.core = e2.core, this.logger = typeof e2.logger < "u" && typeof e2.logger != "string" ? E$1(e2.logger, this.name) : nt$1(k$2({ level: e2.logger || ut })), this.messages = new zt(this.logger, e2.core), this.subscriber = new Ut$1(this, this.logger), this.publisher = new Ir(this, this.logger), this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me, this.projectId = e2.projectId, this.bundleId = Wo(), this.provider = {}; + } + async init() { + this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); + try { + await this.transportOpen(); + } catch { + this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${be$1}...`), await this.restartTransport(be$1); + } + this.initialized = true, setTimeout(async () => { + this.subscriber.topics.length === 0 && this.subscriber.pending.size === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); + }, yt); + } + get context() { + return y$2(this.logger); + } + get connected() { + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 1; + } + get connecting() { + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 0; + } + async publish(e2, t2, i2) { + this.isInitialized(), await this.publisher.publish(e2, t2, i2), await this.recordMessageEvent({ topic: e2, message: t2, publishedAt: Date.now() }); + } + async subscribe(e2, t2) { + var i2; + this.isInitialized(); + let s2 = ((i2 = this.subscriber.topicMap.get(e2)) == null ? void 0 : i2[0]) || "", r3; + const o2 = (a3) => { + a3.topic === e2 && (this.subscriber.off(S$1.created, o2), r3()); + }; + return await Promise.all([new Promise((a3) => { + r3 = a3, this.subscriber.on(S$1.created, o2); + }), new Promise(async (a3) => { + s2 = await this.subscriber.subscribe(e2, t2) || s2, a3(); + })]), s2; + } + async unsubscribe(e2, t2) { + this.isInitialized(), await this.subscriber.unsubscribe(e2, t2); + } + on(e2, t2) { + this.events.on(e2, t2); + } + once(e2, t2) { + this.events.once(e2, t2); + } + off(e2, t2) { + this.events.off(e2, t2); + } + removeListener(e2, t2) { + this.events.removeListener(e2, t2); + } + async transportDisconnect() { + if (!this.hasExperiencedNetworkDisruption && this.connected && this.requestsInFlight.size > 0) + try { + await Promise.all(Array.from(this.requestsInFlight.values()).map((e2) => e2.promise)); + } catch (e2) { + this.logger.warn(e2); + } + this.hasExperiencedNetworkDisruption || this.connected ? await u0(this.provider.disconnect(), 2e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.onProviderDisconnect(); + } + async transportClose() { + this.transportExplicitlyClosed = true, await this.transportDisconnect(); + } + async transportOpen(e2) { + await this.confirmOnlineStateOrThrow(), e2 && e2 !== this.relayUrl && (this.relayUrl = e2, await this.transportDisconnect(), await this.createProvider()), this.connectionAttemptInProgress = true, this.transportExplicitlyClosed = false; + try { + await new Promise(async (t2, i2) => { + const s2 = () => { + this.provider.off(f$1.disconnect, s2), i2(new Error("Connection interrupted while trying to subscribe")); + }; + this.provider.on(f$1.disconnect, s2), await u0(this.provider.connect(), cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), `Socket stalled when trying to connect to ${this.relayUrl}`).catch((r3) => { + i2(r3); + }), await this.subscriber.start(), this.hasExperiencedNetworkDisruption = false, t2(); + }); + } catch (t2) { + this.logger.error(t2); + const i2 = t2; + if (!this.isConnectionStalled(i2.message)) + throw t2; + } finally { + this.connectionAttemptInProgress = false; + } + } + async restartTransport(e2) { + this.connectionAttemptInProgress || (this.relayUrl = e2 || this.relayUrl, await this.confirmOnlineStateOrThrow(), await this.transportClose(), await this.createProvider(), await this.transportOpen()); + } + async confirmOnlineStateOrThrow() { + if (!await hh()) + throw new Error("No internet connection detected. Please restart your network and try again."); + } + startPingTimeout() { + var e2, t2, i2, s2, r3; + if (pi()) + try { + (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) != null && t2.socket && ((r3 = (s2 = (i2 = this.provider) == null ? void 0 : i2.connection) == null ? void 0 : s2.socket) == null || r3.once("ping", () => { + this.resetPingTimeout(); + })), this.resetPingTimeout(); + } catch (o2) { + this.logger.warn(o2); + } + } + isConnectionStalled(e2) { + return this.staleConnectionErrors.some((t2) => e2.includes(t2)); + } + async createProvider() { + this.provider.connection && this.unregisterProviderListeners(); + const e2 = await this.core.crypto.signJWT(this.relayUrl); + this.provider = new JsonRpcProvider(new f$2($o({ sdkVersion: Dt$1, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e2, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); + } + async recordMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; + await this.messages.set(t2, i2); + } + async shouldIgnoreMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; + if (!i2 || i2.length === 0) + return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; + if (!await this.subscriber.isSubscribed(t2)) + return this.logger.debug(`Ignoring message for non-subscribed topic ${t2}`), true; + const s2 = this.messages.has(t2, i2); + return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; + } + async onProviderPayload(e2) { + if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e2 }), isJsonRpcRequest(e2)) { + if (!e2.method.endsWith(gt)) + return; + const t2 = e2.params, { topic: i2, message: s2, publishedAt: r3 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r3 }; + this.logger.debug("Emitting Relayer Payload"), this.logger.trace(zr$1({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e2), await this.onMessageEvent(o2); + } else + isJsonRpcResponse(e2) && this.events.emit(v2.message_ack, e2); + } + async onMessageEvent(e2) { + await this.shouldIgnoreMessageEvent(e2) || (this.events.emit(v2.message, e2), await this.recordMessageEvent(e2)); + } + async acknowledgePayload(e2) { + const t2 = formatJsonRpcResult(e2.id, true); + await this.provider.connection.send(t2); + } + unregisterProviderListeners() { + this.provider.off(f$1.payload, this.onPayloadHandler), this.provider.off(f$1.connect, this.onConnectHandler), this.provider.off(f$1.disconnect, this.onDisconnectHandler), this.provider.off(f$1.error, this.onProviderErrorHandler); + } + async registerEventListeners() { + let e2 = await hh(); + ch(async (t2) => { + e2 !== t2 && (e2 = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportDisconnect(), this.transportExplicitlyClosed = false)); + }); + } + async onProviderDisconnect() { + await this.subscriber.stop(), this.events.emit(v2.disconnect), this.connectionAttemptInProgress = false, !this.transportExplicitlyClosed && setTimeout(async () => { + await this.transportOpen().catch((e2) => this.logger.error(e2)); + }, cjs$3.toMiliseconds(pt)); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } + async toEstablishConnection() { + await this.confirmOnlineStateOrThrow(), !this.connected && (this.connectionAttemptInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.connected && (clearInterval(t2), e2()); + }, this.connectionStatusPollingInterval); + }), await this.transportOpen()); + } +}; +var Nr = Object.defineProperty, Bt$1 = Object.getOwnPropertySymbols, Lr = Object.prototype.hasOwnProperty, Ur$1 = Object.prototype.propertyIsEnumerable, Mt = (n4, e2, t2) => e2 in n4 ? Nr(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Kt$1 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Lr.call(e2, t2) && Mt(n4, t2, e2[t2]); + if (Bt$1) + for (var t2 of Bt$1(e2)) + Ur$1.call(e2, t2) && Mt(n4, t2, e2[t2]); + return n4; +}; +class Vt extends p { + constructor(e2, t2, i2, s2 = z$1, r3 = void 0) { + super(e2, t2, i2, s2), this.core = e2, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = mt, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.recentlyDeleted = [], this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o2) => { + this.getKey && o2 !== null && !Pe(o2) ? this.map.set(this.getKey(o2), o2) : Gu(o2) ? this.map.set(o2.id, o2) : Yu(o2) && this.map.set(o2.topic, o2); + }), this.cached = [], this.initialized = true); + }, this.set = async (o2, a3) => { + this.isInitialized(), this.map.has(o2) ? await this.update(o2, a3) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o2, value: a3 }), this.map.set(o2, a3), await this.persist()); + }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a3) => Object.keys(o2).every((h4) => Yi(a3[h4], o2[h4]))) : this.values), this.update = async (o2, a3) => { + this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o2, update: a3 }); + const h4 = Kt$1(Kt$1({}, this.getData(o2)), a3); + this.map.set(o2, h4), await this.persist(); + }, this.delete = async (o2, a3) => { + this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a3 }), this.map.delete(o2), this.addToRecentlyDeleted(o2), await this.persist()); + }, this.logger = E$1(t2, this.name), this.storagePrefix = s2, this.getKey = r3; + } + get context() { + return y$2(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(e2) { + this.recentlyDeleted.push(e2), this.recentlyDeleted.length >= this.recentlyDeletedLimit && this.recentlyDeleted.splice(0, this.recentlyDeletedLimit / 2); + } + async setDataStore(e2) { + await this.core.storage.setItem(this.storageKey, e2); + } + async getDataStore() { + return await this.core.storage.getItem(this.storageKey); + } + getData(e2) { + const t2 = this.map.get(e2); + if (!t2) { + if (this.recentlyDeleted.includes(e2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e2}`); + throw this.logger.error(s2), new Error(s2); + } + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.error(i2), new Error(i2); + } + return t2; + } + async persist() { + await this.setDataStore(this.values); + } + async restore() { + try { + const e2 = await this.getDataStore(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.map.size) { + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored value for ${this.name}`), this.logger.trace({ type: "method", method: "restore", value: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore value for ${this.name}`), this.logger.error(e2); + } + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +} +class qt { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.name = vt, this.version = It, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = z$1, this.ignoredPayloadTypes = [lr$1], this.registeredMethods = [], this.init = async () => { + this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); + }, this.register = ({ methods: i2 }) => { + this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; + }, this.create = async (i2) => { + this.isInitialized(); + const s2 = gu(), r3 = await this.core.crypto.setSymKey(s2), o2 = d0(cjs$3.FIVE_MINUTES), a3 = { protocol: lt }, h4 = { topic: r3, expiry: o2, relay: a3, active: false }, l2 = Du({ protocol: this.core.protocol, version: this.core.version, topic: r3, symKey: s2, relay: a3, expiryTimestamp: o2, methods: i2 == null ? void 0 : i2.methods }); + return await this.pairings.set(r3, h4), await this.core.relayer.subscribe(r3), this.core.expirer.set(r3, o2), { topic: r3, uri: l2 }; + }, this.pair = async (i2) => { + this.isInitialized(), this.isValidPair(i2); + const { topic: s2, symKey: r3, relay: o2, expiryTimestamp: a3, methods: h4 } = Pu(i2.uri); + let l2; + if (this.pairings.keys.includes(s2) && (l2 = this.pairings.get(s2), l2.active)) + throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); + const d5 = a3 || d0(cjs$3.FIVE_MINUTES), g3 = { topic: s2, relay: o2, expiry: d5, active: false, methods: h4 }; + return await this.pairings.set(s2, g3), this.core.expirer.set(s2, d5), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V$1.create, g3), this.core.crypto.keychain.has(s2) || await this.core.crypto.setSymKey(r3, s2), await this.core.relayer.subscribe(s2, { relay: o2 }), g3; + }, this.activate = async ({ topic: i2 }) => { + this.isInitialized(); + const s2 = d0(cjs$3.THIRTY_DAYS); + await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); + }, this.ping = async (i2) => { + this.isInitialized(), await this.isValidPing(i2); + const { topic: s2 } = i2; + if (this.pairings.keys.includes(s2)) { + const r3 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a3, reject: h4 } = a0(); + this.events.once(v0("pairing_ping", r3), ({ error: l2 }) => { + l2 ? h4(l2) : a3(); + }), await o2(); + } + }, this.updateExpiry = async ({ topic: i2, expiry: s2 }) => { + this.isInitialized(), await this.pairings.update(i2, { expiry: s2 }); + }, this.updateMetadata = async ({ topic: i2, metadata: s2 }) => { + this.isInitialized(), await this.pairings.update(i2, { peerMetadata: s2 }); + }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { + this.isInitialized(), await this.isValidDisconnect(i2); + const { topic: s2 } = i2; + this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", tr$2("USER_DISCONNECTED")), await this.deletePairing(s2)); + }, this.sendRequest = async (i2, s2, r3) => { + const o2 = formatJsonRpcRequest(s2, r3), a3 = await this.core.crypto.encode(i2, o2), h4 = F$1[s2].req; + return this.core.history.set(i2, o2), this.core.relayer.publish(i2, a3, h4), o2.id; + }, this.sendResult = async (i2, s2, r3) => { + const o2 = formatJsonRpcResult(i2, r3), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = F$1[h4.request.method].res; + await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); + }, this.sendError = async (i2, s2, r3) => { + const o2 = formatJsonRpcError(i2, r3), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = F$1[h4.request.method] ? F$1[h4.request.method].res : F$1.unregistered_method.res; + await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); + }, this.deletePairing = async (i2, s2) => { + await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, tr$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); + }, this.cleanup = async () => { + const i2 = this.pairings.getAll().filter((s2) => p0(s2.expiry)); + await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); + }, this.onRelayEventRequest = (i2) => { + const { topic: s2, payload: r3 } = i2; + switch (r3.method) { + case "wc_pairingPing": + return this.onPairingPingRequest(s2, r3); + case "wc_pairingDelete": + return this.onPairingDeleteRequest(s2, r3); + default: + return this.onUnknownRpcMethodRequest(s2, r3); + } + }, this.onRelayEventResponse = async (i2) => { + const { topic: s2, payload: r3 } = i2, o2 = (await this.core.history.get(s2, r3.id)).request.method; + switch (o2) { + case "wc_pairingPing": + return this.onPairingPingResponse(s2, r3); + default: + return this.onUnknownRpcMethodResponse(o2); + } + }, this.onPairingPingRequest = async (i2, s2) => { + const { id: r3 } = s2; + try { + this.isValidPing({ topic: i2 }), await this.sendResult(r3, i2, true), this.events.emit(V$1.ping, { id: r3, topic: i2 }); + } catch (o2) { + await this.sendError(r3, i2, o2), this.logger.error(o2); + } + }, this.onPairingPingResponse = (i2, s2) => { + const { id: r3 } = s2; + setTimeout(() => { + isJsonRpcResult(s2) ? this.events.emit(v0("pairing_ping", r3), {}) : isJsonRpcError(s2) && this.events.emit(v0("pairing_ping", r3), { error: s2.error }); + }, 500); + }, this.onPairingDeleteRequest = async (i2, s2) => { + const { id: r3 } = s2; + try { + this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V$1.delete, { id: r3, topic: i2 }); + } catch (o2) { + await this.sendError(r3, i2, o2), this.logger.error(o2); + } + }, this.onUnknownRpcMethodRequest = async (i2, s2) => { + const { id: r3, method: o2 } = s2; + try { + if (this.registeredMethods.includes(o2)) + return; + const a3 = tr$2("WC_METHOD_UNSUPPORTED", o2); + await this.sendError(r3, i2, a3), this.logger.error(a3); + } catch (a3) { + await this.sendError(r3, i2, a3), this.logger.error(a3); + } + }, this.onUnknownRpcMethodResponse = (i2) => { + this.registeredMethods.includes(i2) || this.logger.error(tr$2("WC_METHOD_UNSUPPORTED", i2)); + }, this.isValidPair = (i2) => { + var s2; + if (!$u(i2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `pair() params: ${i2}`); + throw new Error(o2); + } + if (!Ju(i2.uri)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); + throw new Error(o2); + } + const r3 = Pu(i2.uri); + if (!((s2 = r3 == null ? void 0 : r3.relay) != null && s2.protocol)) { + const { message: o2 } = xe("MISSING_OR_INVALID", "pair() uri#relay-protocol"); + throw new Error(o2); + } + if (!(r3 != null && r3.symKey)) { + const { message: o2 } = xe("MISSING_OR_INVALID", "pair() uri#symKey"); + throw new Error(o2); + } + if (r3 != null && r3.expiryTimestamp && cjs$3.toMiliseconds(r3 == null ? void 0 : r3.expiryTimestamp) < Date.now()) { + const { message: o2 } = xe("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); + throw new Error(o2); + } + }, this.isValidPing = async (i2) => { + if (!$u(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `ping() params: ${i2}`); + throw new Error(r3); + } + const { topic: s2 } = i2; + await this.isValidPairingTopic(s2); + }, this.isValidDisconnect = async (i2) => { + if (!$u(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `disconnect() params: ${i2}`); + throw new Error(r3); + } + const { topic: s2 } = i2; + await this.isValidPairingTopic(s2); + }, this.isValidPairingTopic = async (i2) => { + if (!Gt$1(i2, false)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); + throw new Error(s2); + } + if (!this.pairings.keys.includes(i2)) { + const { message: s2 } = xe("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); + throw new Error(s2); + } + if (p0(this.pairings.get(i2).expiry)) { + await this.deletePairing(i2); + const { message: s2 } = xe("EXPIRED", `pairing topic: ${i2}`); + throw new Error(s2); + } + }, this.core = e2, this.logger = E$1(t2, this.name), this.pairings = new Vt(this.core, this.logger, this.name, this.storagePrefix); + } + get context() { + return y$2(this.logger); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } + registerRelayerEvents() { + this.core.relayer.on(v2.message, async (e2) => { + const { topic: t2, message: i2 } = e2; + if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) + return; + const s2 = await this.core.crypto.decode(t2, i2); + try { + isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); + } catch (r3) { + this.logger.error(r3); + } + }); + } + registerExpirerEvents() { + this.core.expirer.on(C.expired, async (e2) => { + const { topic: t2 } = l0(e2.target); + t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V$1.expire, { topic: t2 })); + }); + } +} +let jt$1 = class jt extends h$1 { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = _t, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); + }, this.set = (i2, s2, r3) => { + if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r3 }), this.records.has(s2.id)) + return; + const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r3, expiry: d0(cjs$3.THIRTY_DAYS) }; + this.records.set(o2.id, o2), this.persist(), this.events.emit(I$1.created, o2); + }, this.resolve = async (i2) => { + if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) + return; + const s2 = await this.getRecord(i2.id); + typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.persist(), this.events.emit(I$1.updated, s2)); + }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { + this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r3) => { + if (r3.topic === i2) { + if (typeof s2 < "u" && r3.id !== s2) + return; + this.records.delete(r3.id), this.events.emit(I$1.deleted, r3); + } + }), this.persist(); + }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.logger = E$1(t2, this.name); + } + get context() { + return y$2(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() { + const e2 = []; + return this.values.forEach((t2) => { + if (typeof t2.response < "u") + return; + const i2 = { topic: t2.topic, request: formatJsonRpcRequest(t2.request.method, t2.request.params, t2.id), chainId: t2.chainId }; + return e2.push(i2); + }), e2; + } + async setJsonRpcRecords(e2) { + await this.core.storage.setItem(this.storageKey, e2); + } + async getJsonRpcRecords() { + return await this.core.storage.getItem(this.storageKey); + } + getRecord(e2) { + this.isInitialized(); + const t2 = this.records.get(e2); + if (!t2) { + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw new Error(i2); + } + return t2; + } + async persist() { + await this.setJsonRpcRecords(this.values), this.events.emit(I$1.sync); + } + async restore() { + try { + const e2 = await this.getJsonRpcRecords(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.records.size) { + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", records: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(e2); + } + } + registerEventListeners() { + this.events.on(I$1.created, (e2) => { + const t2 = I$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.updated, (e2) => { + const t2 = I$1.updated; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.deleted, (e2) => { + const t2 = I$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { + this.cleanup(); + }); + } + cleanup() { + try { + this.isInitialized(); + let e2 = false; + this.records.forEach((t2) => { + cjs$3.toMiliseconds(t2.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${t2.id}`), this.records.delete(t2.id), this.events.emit(I$1.deleted, t2, false), e2 = true); + }), e2 && this.persist(); + } catch (e2) { + this.logger.warn(e2); + } + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +}; +class Gt extends E { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Rt, this.version = Tt$1, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); + }, this.has = (i2) => { + try { + const s2 = this.formatTarget(i2); + return typeof this.getExpiration(s2) < "u"; + } catch { + return false; + } + }, this.set = (i2, s2) => { + this.isInitialized(); + const r3 = this.formatTarget(i2), o2 = { target: r3, expiry: s2 }; + this.expirations.set(r3, o2), this.checkExpiry(r3, o2), this.events.emit(C.created, { target: r3, expiration: o2 }); + }, this.get = (i2) => { + this.isInitialized(); + const s2 = this.formatTarget(i2); + return this.getExpiration(s2); + }, this.del = (i2) => { + if (this.isInitialized(), this.has(i2)) { + const s2 = this.formatTarget(i2), r3 = this.getExpiration(s2); + this.expirations.delete(s2), this.events.emit(C.deleted, { target: s2, expiration: r3 }); + } + }, this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.logger = E$1(t2, this.name); + } + get context() { + return y$2(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(e2) { + if (typeof e2 == "string") + return h0(e2); + if (typeof e2 == "number") + return c0(e2); + const { message: t2 } = xe("UNKNOWN_TYPE", `Target type: ${typeof e2}`); + throw new Error(t2); + } + async setExpirations(e2) { + await this.core.storage.setItem(this.storageKey, e2); + } + async getExpirations() { + return await this.core.storage.getItem(this.storageKey); + } + async persist() { + await this.setExpirations(this.values), this.events.emit(C.sync); + } + async restore() { + try { + const e2 = await this.getExpirations(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.expirations.size) { + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored expirations for ${this.name}`), this.logger.trace({ type: "method", method: "restore", expirations: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore expirations for ${this.name}`), this.logger.error(e2); + } + } + getExpiration(e2) { + const t2 = this.expirations.get(e2); + if (!t2) { + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.warn(i2), new Error(i2); + } + return t2; + } + checkExpiry(e2, t2) { + const { expiry: i2 } = t2; + cjs$3.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e2, t2); + } + expire(e2, t2) { + this.expirations.delete(e2), this.events.emit(C.expired, { target: e2, expiration: t2 }); + } + checkExpirations() { + this.core.relayer.connected && this.expirations.forEach((e2, t2) => this.checkExpiry(t2, e2)); + } + registerEventListeners() { + this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(C.created, (e2) => { + const t2 = C.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C.expired, (e2) => { + const t2 = C.expired; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C.deleted, (e2) => { + const t2 = C.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +} +let Yt$1 = class Yt extends y$1 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.name = ee, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { + if (this.verifyDisabled || er$1() || !pr$1()) + return; + const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); + this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; + try { + await this.createIframe(); + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3); + } + if (!this.initialized) { + this.removeIframe(), this.verifyUrl = te; + try { + await this.createIframe(); + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3), this.verifyDisabled = true; + } + } + }, this.register = async (i2) => { + this.initialized ? this.sendPost(i2.attestationId) : (this.addToQueue(i2.attestationId), await this.init()); + }, this.resolve = async (i2) => { + if (this.isDevEnv) + return ""; + const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); + let r3; + try { + r3 = await this.fetchAttestation(i2.attestationId, s2); + } catch (o2) { + this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r3 = await this.fetchAttestation(i2.attestationId, te); + } + return r3; + }, this.fetchAttestation = async (i2, s2) => { + this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); + const r3 = this.startAbortTimer(cjs$3.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); + return clearTimeout(r3), o2.status === 200 ? await o2.json() : void 0; + }, this.addToQueue = (i2) => { + this.queue.push(i2); + }, this.processQueue = () => { + this.queue.length !== 0 && (this.queue.forEach((i2) => this.sendPost(i2)), this.queue = []); + }, this.sendPost = (i2) => { + var s2; + try { + if (!this.iframe) + return; + (s2 = this.iframe.contentWindow) == null || s2.postMessage(i2, "*"), this.logger.info(`postMessage sent: ${i2} ${this.verifyUrl}`); + } catch { + } + }, this.createIframe = async () => { + let i2; + const s2 = (r3) => { + r3.data === "verify_ready" && (this.onInit(), window.removeEventListener("message", s2), i2()); + }; + await Promise.race([new Promise((r3) => { + const o2 = document.getElementById(ee); + if (o2) + return this.iframe = o2, this.onInit(), r3(); + window.addEventListener("message", s2); + const a3 = document.createElement("iframe"); + a3.id = ee, a3.src = `${this.verifyUrl}/${this.projectId}`, a3.style.display = "none", document.body.append(a3), this.iframe = a3, i2 = r3; + }), new Promise((r3, o2) => setTimeout(() => { + window.removeEventListener("message", s2), o2("verify iframe load timeout"); + }, cjs$3.toMiliseconds(cjs$3.FIVE_SECONDS)))]); + }, this.onInit = () => { + this.initialized = true, this.processQueue(); + }, this.removeIframe = () => { + this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); + }, this.getVerifyUrl = (i2) => { + let s2 = i2 || k$1; + return St.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${k$1}`), s2 = k$1), s2; + }, this.logger = E$1(t2, this.name), this.verifyUrl = k$1, this.abortController = new AbortController(), this.isDevEnv = pi() && process.env.IS_VITEST; + } + get context() { + return y$2(this.logger); + } + startAbortTimer(e2) { + return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$3.toMiliseconds(e2)); + } +}; +let Ht$2 = class Ht extends v$1 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.context = Pt, this.registerDeviceToken = async (i2) => { + const { clientId: s2, token: r3, notificationType: o2, enableEncrypted: a3 = false } = i2, h4 = `${xt}/${this.projectId}/clients`; + await Hi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r3, always_raw: a3 }) }); + }, this.logger = E$1(t2, this.context); + } +}; +var $r = Object.defineProperty, Jt$2 = Object.getOwnPropertySymbols, Fr$1 = Object.prototype.hasOwnProperty, kr$1 = Object.prototype.propertyIsEnumerable, Xt$2 = (n4, e2, t2) => e2 in n4 ? $r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Wt$2 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Fr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + if (Jt$2) + for (var t2 of Jt$2(e2)) + kr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + return n4; +}; +let ie$2 = class ie extends n$2 { + constructor(e2) { + var t2; + super(e2), this.protocol = De, this.version = Ze$1, this.name = Z, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (o2, a3) => this.events.on(o2, a3), this.once = (o2, a3) => this.events.once(o2, a3), this.off = (o2, a3) => this.events.off(o2, a3), this.removeListener = (o2, a3) => this.events.removeListener(o2, a3), this.projectId = e2 == null ? void 0 : e2.projectId, this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me, this.customStoragePrefix = e2 != null && e2.customStoragePrefix ? `:${e2.customStoragePrefix}` : ""; + const i2 = k$2({ level: typeof (e2 == null ? void 0 : e2.logger) == "string" && e2.logger ? e2.logger : et.logger }), { logger: s2, chunkLoggerController: r3 } = A$2({ opts: i2, maxSizeInBytes: e2 == null ? void 0 : e2.maxLogBlobSizeInBytes, loggerOverride: e2 == null ? void 0 : e2.logger }); + this.logChunkController = r3, (t2 = this.logChunkController) != null && t2.downloadLogsBlobInBrowser && (window.downloadLogsBlobInBrowser = async () => { + var o2, a3; + (o2 = this.logChunkController) != null && o2.downloadLogsBlobInBrowser && ((a3 = this.logChunkController) == null || a3.downloadLogsBlobInBrowser({ clientId: await this.crypto.getClientId() })); + }), this.logger = E$1(s2, this.name), this.heartbeat = new cjs$4.HeartBeat(), this.crypto = new At(this, this.logger, e2 == null ? void 0 : e2.keychain), this.history = new jt$1(this, this.logger), this.expirer = new Gt(this, this.logger), this.storage = e2 != null && e2.storage ? e2.storage : new h$2(Wt$2(Wt$2({}, tt), e2 == null ? void 0 : e2.storageOptions)), this.relayer = new kt$1({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new qt(this, this.logger), this.verify = new Yt$1(this.projectId || "", this.logger), this.echoClient = new Ht$2(this.projectId || "", this.logger); + } + static async init(e2) { + const t2 = new ie(e2); + await t2.initialize(); + const i2 = await t2.crypto.getClientId(); + return await t2.storage.setItem(bt, i2), t2; + } + get context() { + return y$2(this.logger); + } + async start() { + this.initialized || await this.initialize(); + } + async getLogsBlob() { + var e2; + return (e2 = this.logChunkController) == null ? void 0 : e2.logsToBlob({ clientId: await this.crypto.getClientId() }); + } + 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.initialized = true, this.logger.info("Core Initialization Success"); + } catch (e2) { + throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`, e2), this.logger.error(e2.message), e2; + } + } +}; +const Br = ie$2; +const Se = "wc", Ee = 2, _e = "client", se$1 = `${Se}@${Ee}:${_e}:`, ie$1 = { name: _e, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, Re$1 = "WALLETCONNECT_DEEPLINK_CHOICE", Ke = "proposal", Ue = "Proposal expired", Ge = "session", L$2 = cjs$3.SEVEN_DAYS, ke = "engine", q$1 = { wc_sessionPropose: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1114 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1115 } }, wc_sessionAuthenticate: { req: { ttl: cjs$3.ONE_HOUR, prompt: true, tag: 1116 }, res: { ttl: cjs$3.ONE_HOUR, prompt: false, tag: 1117 } } }, re$1 = { min: cjs$3.FIVE_MINUTES, max: cjs$3.SEVEN_DAYS }, A$1 = { idle: "IDLE", active: "ACTIVE" }, Fe = "request", je = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"], Qe = "wc", ze = "auth", He = "authKeys", Ye = "pairingTopics", Xe$1 = "requests", X = `${Qe}@${1.5}:${ze}:`, J = `${X}:PUB_KEY`; +var Ht$1 = Object.defineProperty, Yt2 = Object.defineProperties, Xt$1 = Object.getOwnPropertyDescriptors, Je = Object.getOwnPropertySymbols, Jt$1 = Object.prototype.hasOwnProperty, Bt = Object.prototype.propertyIsEnumerable, Be$1 = (S2, n4, t2) => n4 in S2 ? Ht$1(S2, n4, { enumerable: true, configurable: true, writable: true, value: t2 }) : S2[n4] = t2, m2 = (S2, n4) => { + for (var t2 in n4 || (n4 = {})) + Jt$1.call(n4, t2) && Be$1(S2, t2, n4[t2]); + if (Je) + for (var t2 of Je(n4)) + Bt.call(n4, t2) && Be$1(S2, t2, n4[t2]); + return S2; +}, F = (S2, n4) => Yt2(S2, Xt$1(n4)); +let Wt$1 = class Wt extends w$2 { + constructor(n4) { + super(n4), this.name = ke, this.events = new EventEmitter$1(), this.initialized = false, this.requestQueue = { state: A$1.idle, queue: [] }, this.sessionRequestQueue = { state: A$1.idle, queue: [] }, this.requestQueueDelay = cjs$3.ONE_SECOND, this.expectedPairingMethodMap = /* @__PURE__ */ new Map(), this.recentlyDeletedMap = /* @__PURE__ */ new Map(), this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(q$1) }), this.initialized = true, setTimeout(() => { + this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay))); + }, this.connect = async (t2) => { + await this.isInitialized(); + const e2 = F(m2({}, t2), { requiredNamespaces: t2.requiredNamespaces || {}, optionalNamespaces: t2.optionalNamespaces || {} }); + await this.isValidConnect(e2); + const { pairingTopic: s2, requiredNamespaces: i2, optionalNamespaces: r3, sessionProperties: o2, relays: a3 } = e2; + let c2 = s2, d5, p2 = false; + try { + c2 && (p2 = this.client.core.pairing.pairings.get(c2).active); + } catch (f3) { + throw this.client.logger.error(`connect() -> pairing.get(${c2}) failed`), f3; + } + if (!c2 || !p2) { + const { topic: f3, uri: v3 } = await this.client.core.pairing.create(); + c2 = f3, d5 = v3; + } + if (!c2) { + const { message: f3 } = xe("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); + throw new Error(f3); + } + const g3 = await this.client.core.crypto.generateKeyPair(), h4 = q$1.wc_sessionPropose.req.ttl || cjs$3.FIVE_MINUTES, y3 = d0(h4), w3 = m2({ requiredNamespaces: i2, optionalNamespaces: r3, relays: a3 ?? [{ protocol: lt }], proposer: { publicKey: g3, metadata: this.client.metadata }, expiryTimestamp: y3 }, o2 && { sessionProperties: o2 }), { reject: I2, resolve: D2, done: E2 } = a0(h4, Ue); + this.events.once(v0("session_connect"), async ({ error: f3, session: v3 }) => { + if (f3) + I2(f3); + else if (v3) { + v3.self.publicKey = g3; + const j2 = F(m2({}, v3), { requiredNamespaces: w3.requiredNamespaces, optionalNamespaces: w3.optionalNamespaces }); + await this.client.session.set(v3.topic, j2), await this.setExpiry(v3.topic, v3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: v3.peer.metadata }), D2(j2); + } + }); + const P2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: w3, throwOnFailedPublish: true }); + return await this.setProposal(P2, m2({ id: P2 }, w3)), { uri: d5, approval: E2 }; + }, this.pair = async (t2) => { + await this.isInitialized(); + try { + return await this.client.core.pairing.pair(t2); + } catch (e2) { + throw this.client.logger.error("pair() failed"), e2; + } + }, this.approve = async (t2) => { + await this.isInitialized(); + try { + await this.isValidApprove(t2); + } catch (E2) { + throw this.client.logger.error("approve() -> isValidApprove() failed"), E2; + } + const { id: e2, relayProtocol: s2, namespaces: i2, sessionProperties: r3, sessionConfig: o2 } = t2; + let a3; + try { + a3 = this.client.proposal.get(e2); + } catch (E2) { + throw this.client.logger.error(`approve() -> proposal.get(${e2}) failed`), E2; + } + let { pairingTopic: c2, proposer: d5, requiredNamespaces: p2, optionalNamespaces: g3 } = a3; + c2 = c2 || ""; + const h4 = await this.client.core.crypto.generateKeyPair(), y3 = d5.publicKey, w3 = await this.client.core.crypto.generateSharedKey(h4, y3), I2 = m2(m2({ relay: { protocol: s2 ?? "irn" }, namespaces: i2, pairingTopic: c2, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: d0(L$2) }, r3 && { sessionProperties: r3 }), o2 && { sessionConfig: o2 }); + await this.client.core.relayer.subscribe(w3); + const D2 = F(m2({}, I2), { topic: w3, requiredNamespaces: p2, optionalNamespaces: g3, pairingTopic: c2, acknowledged: false, self: I2.controller, peer: { publicKey: d5.publicKey, metadata: d5.metadata }, controller: h4 }); + await this.client.session.set(w3, D2); + try { + await this.sendResult({ id: e2, topic: c2, result: { relay: { protocol: s2 ?? "irn" }, responderPublicKey: h4 }, throwOnFailedPublish: true }), await this.sendRequest({ topic: w3, method: "wc_sessionSettle", params: I2, throwOnFailedPublish: true }); + } catch (E2) { + throw this.client.logger.error(E2), this.client.session.delete(w3, tr$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(w3), E2; + } + return await this.client.core.pairing.updateMetadata({ topic: c2, metadata: d5.metadata }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: c2 }), await this.setExpiry(w3, d0(L$2)), { topic: w3, acknowledged: () => new Promise((E2) => setTimeout(() => E2(this.client.session.get(w3)), 500)) }; + }, this.reject = async (t2) => { + await this.isInitialized(); + try { + await this.isValidReject(t2); + } catch (r3) { + throw this.client.logger.error("reject() -> isValidReject() failed"), r3; + } + const { id: e2, reason: s2 } = t2; + let i2; + try { + i2 = this.client.proposal.get(e2).pairingTopic; + } catch (r3) { + throw this.client.logger.error(`reject() -> proposal.get(${e2}) failed`), r3; + } + i2 && (await this.sendError({ id: e2, topic: i2, error: s2 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED"))); + }, this.update = async (t2) => { + await this.isInitialized(); + try { + await this.isValidUpdate(t2); + } catch (p2) { + throw this.client.logger.error("update() -> isValidUpdate() failed"), p2; + } + const { topic: e2, namespaces: s2 } = t2, { done: i2, resolve: r3, reject: o2 } = a0(), a3 = payloadId(), c2 = getBigIntRpcId().toString(), d5 = this.client.session.get(e2).namespaces; + return this.events.once(v0("session_update", a3), ({ error: p2 }) => { + p2 ? o2(p2) : r3(); + }), await this.client.session.update(e2, { namespaces: s2 }), this.sendRequest({ topic: e2, method: "wc_sessionUpdate", params: { namespaces: s2 }, throwOnFailedPublish: true, clientRpcId: a3, relayRpcId: c2 }).catch((p2) => { + this.client.logger.error(p2), this.client.session.update(e2, { namespaces: d5 }), o2(p2); + }), { acknowledged: i2 }; + }, this.extend = async (t2) => { + await this.isInitialized(); + try { + await this.isValidExtend(t2); + } catch (a3) { + throw this.client.logger.error("extend() -> isValidExtend() failed"), a3; + } + const { topic: e2 } = t2, s2 = payloadId(), { done: i2, resolve: r3, reject: o2 } = a0(); + return this.events.once(v0("session_extend", s2), ({ error: a3 }) => { + a3 ? o2(a3) : r3(); + }), await this.setExpiry(e2, d0(L$2)), this.sendRequest({ topic: e2, method: "wc_sessionExtend", params: {}, clientRpcId: s2, throwOnFailedPublish: true }).catch((a3) => { + o2(a3); + }), { acknowledged: i2 }; + }, this.request = async (t2) => { + await this.isInitialized(); + try { + await this.isValidRequest(t2); + } catch (h4) { + throw this.client.logger.error("request() -> isValidRequest() failed"), h4; + } + const { chainId: e2, request: s2, topic: i2, expiry: r3 = q$1.wc_sessionRequest.req.ttl } = t2, o2 = this.client.session.get(i2), a3 = payloadId(), c2 = getBigIntRpcId().toString(), { done: d5, resolve: p2, reject: g3 } = a0(r3, "Request expired. Please try again."); + return this.events.once(v0("session_request", a3), ({ error: h4, result: y3 }) => { + h4 ? g3(h4) : p2(y3); + }), await Promise.all([new Promise(async (h4) => { + await this.sendRequest({ clientRpcId: a3, relayRpcId: c2, topic: i2, method: "wc_sessionRequest", params: { request: F(m2({}, s2), { expiryTimestamp: d0(r3) }), chainId: e2 }, expiry: r3, throwOnFailedPublish: true }).catch((y3) => g3(y3)), this.client.events.emit("session_request_sent", { topic: i2, request: s2, chainId: e2, id: a3 }), h4(); + }), new Promise(async (h4) => { + var y3; + if (!((y3 = o2.sessionConfig) != null && y3.disableDeepLink)) { + const w3 = await g0(this.client.core.storage, Re$1); + m0({ id: a3, topic: i2, wcDeepLink: w3 }); + } + h4(); + }), d5()]).then((h4) => h4[2]); + }, this.respond = async (t2) => { + await this.isInitialized(), await this.isValidRespond(t2); + const { topic: e2, response: s2 } = t2, { id: i2 } = s2; + isJsonRpcResult(s2) ? await this.sendResult({ id: i2, topic: e2, result: s2.result, throwOnFailedPublish: true }) : isJsonRpcError(s2) && await this.sendError({ id: i2, topic: e2, error: s2.error }), this.cleanupAfterResponse(t2); + }, this.ping = async (t2) => { + await this.isInitialized(); + try { + await this.isValidPing(t2); + } catch (s2) { + throw this.client.logger.error("ping() -> isValidPing() failed"), s2; + } + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) { + const s2 = payloadId(), i2 = getBigIntRpcId().toString(), { done: r3, resolve: o2, reject: a3 } = a0(); + this.events.once(v0("session_ping", s2), ({ error: c2 }) => { + c2 ? a3(c2) : o2(); + }), await Promise.all([this.sendRequest({ topic: e2, method: "wc_sessionPing", params: {}, throwOnFailedPublish: true, clientRpcId: s2, relayRpcId: i2 }), r3()]); + } else + this.client.core.pairing.pairings.keys.includes(e2) && await this.client.core.pairing.ping({ topic: e2 }); + }, this.emit = async (t2) => { + await this.isInitialized(), await this.isValidEmit(t2); + const { topic: e2, event: s2, chainId: i2 } = t2, r3 = getBigIntRpcId().toString(); + await this.sendRequest({ topic: e2, method: "wc_sessionEvent", params: { event: s2, chainId: i2 }, throwOnFailedPublish: true, relayRpcId: r3 }); + }, this.disconnect = async (t2) => { + await this.isInitialized(), await this.isValidDisconnect(t2); + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) + await this.sendRequest({ topic: e2, method: "wc_sessionDelete", params: tr$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: e2, emitEvent: false }); + else if (this.client.core.pairing.pairings.keys.includes(e2)) + await this.client.core.pairing.disconnect({ topic: e2 }); + else { + const { message: s2 } = xe("MISMATCHED_TOPIC", `Session or pairing topic not found: ${e2}`); + throw new Error(s2); + } + }, this.find = (t2) => (this.isInitialized(), this.client.session.getAll().filter((e2) => Qu(e2, t2))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (t2) => { + this.isInitialized(), this.isValidAuthenticate(t2); + const { chains: e2, statement: s2 = "", uri: i2, domain: r3, nonce: o2, type: a3, exp: c2, nbf: d5, methods: p2 = [] } = t2, g3 = [...t2.resources || []], { topic: h4, uri: y3 } = await this.client.core.pairing.create({ methods: ["wc_sessionAuthenticate"] }); + this.client.logger.info({ message: "Generated new pairing", pairing: { topic: h4, uri: y3 } }); + const w3 = await this.client.core.crypto.generateKeyPair(), I2 = bu(w3); + if (await Promise.all([this.client.auth.authKeys.set(J, { responseTopic: I2, publicKey: w3 }), this.client.auth.pairingTopics.set(I2, { topic: I2, pairingTopic: h4 })]), await this.client.core.relayer.subscribe(I2), this.client.logger.info(`sending request to new pairing topic: ${h4}`), p2.length > 0) { + const { namespace: O3 } = dn(e2[0]); + let _3 = cu(O3, "request", p2); + Qr(g3) && (_3 = lu(_3, g3.pop())), g3.push(_3); + } + const D2 = d0(q$1.wc_sessionPropose.req.ttl), E2 = { authPayload: { type: a3 ?? "caip122", chains: e2, statement: s2, aud: i2, domain: r3, version: "1", nonce: o2, iat: (/* @__PURE__ */ new Date()).toISOString(), exp: c2, nbf: d5, resources: g3 }, requester: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, P2 = { eip155: { chains: e2, methods: [.../* @__PURE__ */ new Set(["personal_sign", ...p2])], events: ["chainChanged", "accountsChanged"] } }, f3 = { requiredNamespaces: {}, optionalNamespaces: P2, relays: [{ protocol: "irn" }], proposer: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, { done: v3, resolve: j2, reject: oe2 } = a0(q$1.wc_sessionAuthenticate.req.ttl, "Request expired"), B2 = async ({ error: O3, session: _3 }) => { + if (this.events.off(v0("session_request", M2), ae2), O3) + oe2(O3); + else if (_3) { + _3.self.publicKey = w3, await this.client.session.set(_3.topic, _3), await this.setExpiry(_3.topic, _3.expiry), h4 && await this.client.core.pairing.updateMetadata({ topic: h4, metadata: _3.peer.metadata }); + const Q2 = this.client.session.get(_3.topic); + j2({ session: Q2 }); + } + }, ae2 = async (O3) => { + if (O3.error) { + const z2 = tr$2("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate"); + return O3.error.code === z2.code ? void 0 : (this.events.off(v0("session_connect"), B2), oe2(O3.error.message)); + } + this.events.off(v0("session_connect"), B2); + const { cacaos: _3, responder: Q2 } = O3.result, le2 = [], Ie = []; + for (const z2 of _3) { + await ou({ cacao: z2, projectId: this.client.core.projectId }) || (this.client.logger.error(z2, "Signature verification failed"), oe2(tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"))); + const { p: he2 } = z2, pe2 = Qr(he2.resources), fe2 = [fu(he2.iss)], Ze2 = Li(he2.iss); + if (pe2) { + const de2 = du(pe2), et2 = pu(pe2); + le2.push(...de2), fe2.push(...et2); + } + for (const de2 of fe2) + Ie.push(`${de2}:${Ze2}`); + } + const W2 = await this.client.core.crypto.generateSharedKey(w3, Q2.publicKey); + let Z2; + le2.length > 0 && (Z2 = { topic: W2, acknowledged: true, self: { publicKey: w3, metadata: this.client.metadata }, peer: Q2, controller: Q2.publicKey, expiry: d0(L$2), requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: h4, namespaces: ju([...new Set(le2)], [...new Set(Ie)]) }, await this.client.core.relayer.subscribe(W2), await this.client.session.set(W2, Z2), Z2 = this.client.session.get(W2)), j2({ auths: _3, session: Z2 }); + }, M2 = payloadId(), ce2 = payloadId(); + this.events.once(v0("session_connect"), B2), this.events.once(v0("session_request", M2), ae2); + try { + await Promise.all([this.sendRequest({ topic: h4, method: "wc_sessionAuthenticate", params: E2, expiry: t2.expiry, throwOnFailedPublish: true, clientRpcId: M2 }), this.sendRequest({ topic: h4, method: "wc_sessionPropose", params: f3, expiry: q$1.wc_sessionPropose.req.ttl, throwOnFailedPublish: true, clientRpcId: ce2 })]); + } catch (O3) { + throw this.events.off(v0("session_connect"), B2), this.events.off(v0("session_request", M2), ae2), O3; + } + return await this.setProposal(ce2, m2({ id: ce2 }, f3)), await this.client.auth.requests.set(M2, { authPayload: E2.authPayload, requester: E2.requester, expiryTimestamp: D2, id: M2, pairingTopic: h4, verifyContext: {} }), { uri: y3, response: v3 }; + }, this.approveSessionAuthenticate = async (t2) => { + this.isInitialized(); + const { id: e2, auths: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o2 }, d5 = [], p2 = []; + for (const y3 of s2) { + if (!await ou({ cacao: y3, projectId: this.client.core.projectId })) { + const P2 = tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"); + throw await this.sendError({ id: e2, topic: a3, error: P2, encodeOpts: c2 }), new Error(P2.message); + } + const { p: w3 } = y3, I2 = Qr(w3.resources), D2 = [fu(w3.iss)], E2 = Li(w3.iss); + if (I2) { + const P2 = du(I2), f3 = pu(I2); + d5.push(...P2), D2.push(...f3); + } + for (const P2 of D2) + p2.push(`${P2}:${E2}`); + } + const g3 = await this.client.core.crypto.generateSharedKey(o2, r3); + let h4; + return (d5 == null ? void 0 : d5.length) > 0 && (h4 = { topic: g3, acknowledged: true, self: { publicKey: o2, metadata: this.client.metadata }, peer: { publicKey: r3, metadata: i2.requester.metadata }, controller: r3, expiry: d0(L$2), authentication: s2, requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: "", namespaces: ju([...new Set(d5)], [...new Set(p2)]) }, await this.client.core.relayer.subscribe(g3), await this.client.session.set(g3, h4)), await this.sendResult({ topic: a3, id: e2, result: { cacaos: s2, responder: { publicKey: o2, metadata: this.client.metadata } }, encodeOpts: c2, throwOnFailedPublish: true }), await this.client.auth.requests.delete(e2, { message: "fullfilled", code: 0 }), await this.client.core.pairing.activate({ topic: i2.pairingTopic }), { session: h4 }; + }, this.rejectSessionAuthenticate = async (t2) => { + await this.isInitialized(); + const { id: e2, reason: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o2 }; + await this.sendError({ id: e2, topic: a3, error: s2, encodeOpts: c2 }), await this.client.auth.requests.delete(e2, { message: "rejected", code: 0 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")); + }, this.formatAuthMessage = (t2) => { + this.isInitialized(); + const { request: e2, iss: s2 } = t2; + return zf(e2, s2); + }, this.cleanupDuplicatePairings = async (t2) => { + if (t2.pairingTopic) + try { + const e2 = this.client.core.pairing.pairings.get(t2.pairingTopic), s2 = this.client.core.pairing.pairings.getAll().filter((i2) => { + var r3, o2; + return ((r3 = i2.peerMetadata) == null ? void 0 : r3.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === t2.peer.metadata.url && i2.topic && i2.topic !== e2.topic; + }); + if (s2.length === 0) + return; + this.client.logger.info(`Cleaning up ${s2.length} duplicate pairing(s)`), await Promise.all(s2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.deleteSession = async (t2) => { + const { topic: e2, expirerHasDeleted: s2 = false, emitEvent: i2 = true, id: r3 = 0 } = t2, { self: o2 } = this.client.session.get(e2); + await this.client.core.relayer.unsubscribe(e2), await this.client.session.delete(e2, tr$2("USER_DISCONNECTED")), this.addToRecentlyDeleted(e2, "session"), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(e2) && await this.client.core.crypto.deleteSymKey(e2), s2 || this.client.core.expirer.del(e2), this.client.core.storage.removeItem(Re$1).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { + a3.topic === e2 && this.deletePendingSessionRequest(a3.id, tr$2("USER_DISCONNECTED")); + }), i2 && this.client.events.emit("session_delete", { id: r3, topic: e2 }); + }, this.deleteProposal = async (t2, e2) => { + await Promise.all([this.client.proposal.delete(t2, tr$2("USER_DISCONNECTED")), e2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "proposal"); + }, this.deletePendingSessionRequest = async (t2, e2, s2 = false) => { + await Promise.all([this.client.pendingRequest.delete(t2, e2), s2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== t2), s2 && (this.sessionRequestQueue.state = A$1.idle, this.client.events.emit("session_request_expire", { id: t2 })); + }, this.setExpiry = async (t2, e2) => { + this.client.session.keys.includes(t2) && await this.client.session.update(t2, { expiry: e2 }), this.client.core.expirer.set(t2, e2); + }, this.setProposal = async (t2, e2) => { + await this.client.proposal.set(t2, e2), this.client.core.expirer.set(t2, d0(q$1.wc_sessionPropose.req.ttl)); + }, this.setPendingSessionRequest = async (t2) => { + const { id: e2, topic: s2, params: i2, verifyContext: r3 } = t2, o2 = i2.request.expiryTimestamp || d0(q$1.wc_sessionRequest.req.ttl); + await this.client.pendingRequest.set(e2, { id: e2, topic: s2, params: i2, verifyContext: r3 }), o2 && this.client.core.expirer.set(e2, o2); + }, this.sendRequest = async (t2) => { + const { topic: e2, method: s2, params: i2, expiry: r3, relayRpcId: o2, clientRpcId: a3, throwOnFailedPublish: c2 } = t2, d5 = formatJsonRpcRequest(s2, i2, a3); + if (pr$1() && je.includes(s2)) { + const h4 = yu(JSON.stringify(d5)); + this.client.core.verify.register({ attestationId: h4 }); + } + let p2; + try { + p2 = await this.client.core.crypto.encode(e2, d5); + } catch (h4) { + throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e2} failed`), h4; + } + const g3 = q$1[s2].req; + return r3 && (g3.ttl = r3), o2 && (g3.id = o2), this.client.core.history.set(e2, d5), c2 ? (g3.internal = F(m2({}, g3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(e2, p2, g3)) : this.client.core.relayer.publish(e2, p2, g3).catch((h4) => this.client.logger.error(h4)), d5.id; + }, this.sendResult = async (t2) => { + const { id: e2, topic: s2, result: i2, throwOnFailedPublish: r3, encodeOpts: o2 } = t2, a3 = formatJsonRpcResult(e2, i2); + let c2; + try { + c2 = await this.client.core.crypto.encode(s2, a3, o2); + } catch (g3) { + throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s2} failed`), g3; + } + let d5; + try { + d5 = await this.client.core.history.get(s2, e2); + } catch (g3) { + throw this.client.logger.error(`sendResult() -> history.get(${s2}, ${e2}) failed`), g3; + } + const p2 = q$1[d5.request.method].res; + r3 ? (p2.internal = F(m2({}, p2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, c2, p2)) : this.client.core.relayer.publish(s2, c2, p2).catch((g3) => this.client.logger.error(g3)), await this.client.core.history.resolve(a3); + }, this.sendError = async (t2) => { + const { id: e2, topic: s2, error: i2, encodeOpts: r3 } = t2, o2 = formatJsonRpcError(e2, i2); + let a3; + try { + a3 = await this.client.core.crypto.encode(s2, o2, r3); + } catch (p2) { + throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s2} failed`), p2; + } + let c2; + try { + c2 = await this.client.core.history.get(s2, e2); + } catch (p2) { + throw this.client.logger.error(`sendError() -> history.get(${s2}, ${e2}) failed`), p2; + } + const d5 = q$1[c2.request.method].res; + this.client.core.relayer.publish(s2, a3, d5), await this.client.core.history.resolve(o2); + }, this.cleanup = async () => { + const t2 = [], e2 = []; + this.client.session.getAll().forEach((s2) => { + let i2 = false; + p0(s2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(s2.topic) || (i2 = true), i2 && t2.push(s2.topic); + }), this.client.proposal.getAll().forEach((s2) => { + p0(s2.expiryTimestamp) && e2.push(s2.id); + }), await Promise.all([...t2.map((s2) => this.deleteSession({ topic: s2 })), ...e2.map((s2) => this.deleteProposal(s2))]); + }, this.onRelayEventRequest = async (t2) => { + this.requestQueue.queue.push(t2), await this.processRequestsQueue(); + }, this.processRequestsQueue = async () => { + if (this.requestQueue.state === A$1.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 = A$1.active; + const t2 = this.requestQueue.queue.shift(); + if (t2) + try { + this.processRequest(t2), await new Promise((e2) => setTimeout(e2, 300)); + } catch (e2) { + this.client.logger.warn(e2); + } + } + this.requestQueue.state = A$1.idle; + }, this.processRequest = (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = s2.method; + if (!this.shouldIgnorePairingRequest({ topic: e2, requestMethod: i2 })) + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeRequest(e2, s2); + case "wc_sessionSettle": + return this.onSessionSettleRequest(e2, s2); + case "wc_sessionUpdate": + return this.onSessionUpdateRequest(e2, s2); + case "wc_sessionExtend": + return this.onSessionExtendRequest(e2, s2); + case "wc_sessionPing": + return this.onSessionPingRequest(e2, s2); + case "wc_sessionDelete": + return this.onSessionDeleteRequest(e2, s2); + case "wc_sessionRequest": + return this.onSessionRequest(e2, s2); + case "wc_sessionEvent": + return this.onSessionEventRequest(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateRequest(e2, s2); + default: + return this.client.logger.info(`Unsupported request method ${i2}`); + } + }, this.onRelayEventResponse = async (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = (await this.client.core.history.get(e2, s2.id)).request.method; + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeResponse(e2, s2); + case "wc_sessionSettle": + return this.onSessionSettleResponse(e2, s2); + case "wc_sessionUpdate": + return this.onSessionUpdateResponse(e2, s2); + case "wc_sessionExtend": + return this.onSessionExtendResponse(e2, s2); + case "wc_sessionPing": + return this.onSessionPingResponse(e2, s2); + case "wc_sessionRequest": + return this.onSessionRequestResponse(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateResponse(e2, s2); + default: + return this.client.logger.info(`Unsupported response method ${i2}`); + } + }, this.onRelayEventUnknownPayload = (t2) => { + const { topic: e2 } = t2, { message: s2 } = xe("MISSING_OR_INVALID", `Decoded payload on topic ${e2} is not identifiable as a JSON-RPC request or a response.`); + throw new Error(s2); + }, this.shouldIgnorePairingRequest = (t2) => { + const { topic: e2, requestMethod: s2 } = t2, i2 = this.expectedPairingMethodMap.get(e2); + return !i2 || i2.includes(s2) ? false : !!(i2.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0); + }, this.onSessionProposeRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; + try { + this.isValidConnect(m2({}, e2.params)); + const r3 = s2.expiryTimestamp || d0(q$1.wc_sessionPropose.req.ttl), o2 = m2({ id: i2, pairingTopic: t2, expiryTimestamp: r3 }, s2); + await this.setProposal(i2, o2); + const a3 = yu(JSON.stringify(e2)), c2 = await this.getVerifyContext(a3, o2.proposer.metadata); + this.client.events.emit("session_proposal", { id: i2, params: o2, verifyContext: c2 }); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionProposeResponse = async (t2, e2) => { + const { id: s2 } = e2; + if (isJsonRpcResult(e2)) { + const { result: i2 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); + const r3 = this.client.proposal.get(s2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: r3 }); + const o2 = r3.proposer.publicKey; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o2 }); + const a3 = i2.responderPublicKey; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a3 }); + const c2 = await this.client.core.crypto.generateSharedKey(o2, a3); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); + const d5 = await this.client.core.relayer.subscribe(c2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: d5 }), await this.client.core.pairing.activate({ topic: t2 }); + } else if (isJsonRpcError(e2)) { + await this.client.proposal.delete(s2, tr$2("USER_DISCONNECTED")); + const i2 = v0("session_connect"); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners, 954`); + this.events.emit(v0("session_connect"), { error: e2.error }); + } + }, this.onSessionSettleRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + this.isValidSessionSettleRequest(i2); + const { relay: r3, controller: o2, expiry: a3, namespaces: c2, sessionProperties: d5, pairingTopic: p2, sessionConfig: g3 } = e2.params, h4 = m2(m2({ topic: t2, relay: r3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: p2, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, d5 && { sessionProperties: d5 }), g3 && { sessionConfig: g3 }); + await this.sendResult({ id: e2.id, topic: t2, result: true, throwOnFailedPublish: true }); + const y3 = v0("session_connect"); + if (this.events.listenerCount(y3) === 0) + throw new Error(`emitting ${y3} without any listeners 997`); + this.events.emit(v0("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionSettleResponse = async (t2, e2) => { + const { id: s2 } = e2; + isJsonRpcResult(e2) ? (await this.client.session.update(t2, { acknowledged: true }), this.events.emit(v0("session_approve", s2), {})) : isJsonRpcError(e2) && (await this.client.session.delete(t2, tr$2("USER_DISCONNECTED")), this.events.emit(v0("session_approve", s2), { error: e2.error })); + }, this.onSessionUpdateRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; + try { + const r3 = `${t2}_session_update`, o2 = lh.get(r3); + if (o2 && this.isRequestOutOfSync(o2, i2)) { + this.client.logger.info(`Discarding out of sync request - ${i2}`), this.sendError({ id: i2, topic: t2, error: tr$2("INVALID_UPDATE_REQUEST") }); + return; + } + this.isValidUpdate(m2({ topic: t2 }, s2)); + try { + lh.set(r3, i2), await this.client.session.update(t2, { namespaces: s2.namespaces }), await this.sendResult({ id: i2, topic: t2, result: true, throwOnFailedPublish: true }); + } catch (a3) { + throw lh.delete(r3), a3; + } + this.client.events.emit("session_update", { id: i2, topic: t2, params: s2 }); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.isRequestOutOfSync = (t2, e2) => parseInt(e2.toString().slice(0, -3)) <= parseInt(t2.toString().slice(0, -3)), this.onSessionUpdateResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_update", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_update", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_update", s2), { error: e2.error }); + }, this.onSessionExtendRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidExtend({ topic: t2 }), await this.setExpiry(t2, d0(L$2)), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_extend", { id: s2, topic: t2 }); + } catch (i2) { + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionExtendResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_extend", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_extend", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_extend", s2), { error: e2.error }); + }, this.onSessionPingRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidPing({ topic: t2 }), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_ping", { id: s2, topic: t2 }); + } catch (i2) { + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionPingResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_ping", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + setTimeout(() => { + isJsonRpcResult(e2) ? this.events.emit(v0("session_ping", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_ping", s2), { error: e2.error }); + }, 500); + }, this.onSessionDeleteRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidDisconnect({ topic: t2, reason: e2.params }), await Promise.all([new Promise((i2) => { + this.client.core.relayer.once(v2.publish, async () => { + i2(await this.deleteSession({ topic: t2, id: s2 })); + }); + }), this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.cleanupPendingSentRequestsForTopic({ topic: t2, error: tr$2("USER_DISCONNECTED") })]); + } catch (i2) { + this.client.logger.error(i2); + } + }, this.onSessionRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + await this.isValidRequest(m2({ topic: t2 }, i2)); + const r3 = yu(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, s2))), o2 = this.client.session.get(t2), a3 = await this.getVerifyContext(r3, o2.peer.metadata), c2 = { id: s2, topic: t2, params: i2, verifyContext: a3 }; + await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionRequestResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_request", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionEventRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + const r3 = `${t2}_session_event_${i2.event.name}`, o2 = lh.get(r3); + if (o2 && this.isRequestOutOfSync(o2, s2)) { + this.client.logger.info(`Discarding out of sync request - ${s2}`); + return; + } + this.isValidEmit(m2({ topic: t2 }, i2)), this.client.events.emit("session_event", { id: s2, topic: t2, params: i2 }), lh.set(r3, s2); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionAuthenticateResponse = (t2, e2) => { + const { id: s2 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionAuthenticateResponse", topic: t2, payload: e2 }), isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionAuthenticateRequest = async (t2, e2) => { + const { requester: s2, authPayload: i2, expiryTimestamp: r3 } = e2.params, o2 = yu(JSON.stringify(e2)), a3 = await this.getVerifyContext(o2, this.client.metadata), c2 = { requester: s2, pairingTopic: t2, id: e2.id, authPayload: i2, verifyContext: a3, expiryTimestamp: r3 }; + await this.client.auth.requests.set(e2.id, c2), this.client.events.emit("session_authenticate", { topic: t2, params: e2.params, id: e2.id }); + }, this.addSessionRequestToSessionRequestQueue = (t2) => { + this.sessionRequestQueue.queue.push(t2); + }, this.cleanupAfterResponse = (t2) => { + this.deletePendingSessionRequest(t2.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { + this.sessionRequestQueue.state = A$1.idle, this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay)); + }, this.cleanupPendingSentRequestsForTopic = ({ topic: t2, error: e2 }) => { + const s2 = this.client.core.history.pending; + s2.length > 0 && s2.filter((i2) => i2.topic === t2 && i2.request.method === "wc_sessionRequest").forEach((i2) => { + const r3 = i2.request.id, o2 = v0("session_request", r3); + if (this.events.listenerCount(o2) === 0) + throw new Error(`emitting ${o2} without any listeners`); + this.events.emit(v0("session_request", i2.request.id), { error: e2 }); + }); + }, this.processSessionRequestQueue = () => { + if (this.sessionRequestQueue.state === A$1.active) { + this.client.logger.info("session request queue is already active."); + return; + } + const t2 = this.sessionRequestQueue.queue[0]; + if (!t2) { + this.client.logger.info("session request queue is empty."); + return; + } + try { + this.sessionRequestQueue.state = A$1.active, this.client.events.emit("session_request", t2); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.onPairingCreated = (t2) => { + if (t2.methods && this.expectedPairingMethodMap.set(t2.topic, t2.methods), t2.active) + return; + const e2 = this.client.proposal.getAll().find((s2) => s2.pairingTopic === t2.topic); + e2 && this.onSessionProposeRequest(t2.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: e2.requiredNamespaces, optionalNamespaces: e2.optionalNamespaces, relays: e2.relays, proposer: e2.proposer, sessionProperties: e2.sessionProperties }, e2.id)); + }, this.isValidConnect = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(t2)}`); + throw new Error(a3); + } + const { pairingTopic: e2, requiredNamespaces: s2, optionalNamespaces: i2, sessionProperties: r3, relays: o2 } = t2; + if (Pe(e2) || await this.isValidPairingTopic(e2), !Xu(o2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `connect() relays: ${o2}`); + throw new Error(a3); + } + !Pe(s2) && Yr(s2) !== 0 && this.validateNamespaces(s2, "requiredNamespaces"), !Pe(i2) && Yr(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), Pe(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.validateNamespaces = (t2, e2) => { + const s2 = Wu(t2, "connect()", e2); + if (s2) + throw new Error(s2.message); + }, this.isValidApprove = async (t2) => { + if (!$u(t2)) + throw new Error(xe("MISSING_OR_INVALID", `approve() params: ${t2}`).message); + const { id: e2, namespaces: s2, relayProtocol: i2, sessionProperties: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2); + const o2 = this.client.proposal.get(e2), a3 = So(s2, "approve()"); + if (a3) + throw new Error(a3.message); + const c2 = Io(o2.requiredNamespaces, s2, "approve()"); + if (c2) + throw new Error(c2.message); + if (!Gt$1(i2, true)) { + const { message: d5 } = xe("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); + throw new Error(d5); + } + Pe(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.isValidReject = async (t2) => { + if (!$u(t2)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `reject() params: ${t2}`); + throw new Error(i2); + } + const { id: e2, reason: s2 } = t2; + if (this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2), !th(s2)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(s2)}`); + throw new Error(i2); + } + }, this.isValidSessionSettleRequest = (t2) => { + if (!$u(t2)) { + const { message: c2 } = xe("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${t2}`); + throw new Error(c2); + } + const { relay: e2, controller: s2, namespaces: i2, expiry: r3 } = t2; + if (!No(e2)) { + const { message: c2 } = xe("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); + throw new Error(c2); + } + const o2 = Vu(s2, "onSessionSettleRequest()"); + if (o2) + throw new Error(o2.message); + const a3 = So(i2, "onSessionSettleRequest()"); + if (a3) + throw new Error(a3.message); + if (p0(r3)) { + const { message: c2 } = xe("EXPIRED", "onSessionSettleRequest()"); + throw new Error(c2); + } + }, this.isValidUpdate = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `update() params: ${t2}`); + throw new Error(a3); + } + const { topic: e2, namespaces: s2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const i2 = this.client.session.get(e2), r3 = So(s2, "update()"); + if (r3) + throw new Error(r3.message); + const o2 = Io(i2.requiredNamespaces, s2, "update()"); + if (o2) + throw new Error(o2.message); + }, this.isValidExtend = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `extend() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + }, this.isValidRequest = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() params: ${t2}`); + throw new Error(a3); + } + const { topic: e2, request: s2, chainId: i2, expiry: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const { namespaces: o2 } = this.client.session.get(e2); + if (!nh(o2, i2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() chainId: ${i2}`); + throw new Error(a3); + } + if (!eh(s2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() ${JSON.stringify(s2)}`); + throw new Error(a3); + } + if (!fh(o2, i2, s2.method)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() method: ${s2.method}`); + throw new Error(a3); + } + if (r3 && !uh(r3, re$1)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() expiry: ${r3}. Expiry must be a number (in seconds) between ${re$1.min} and ${re$1.max}`); + throw new Error(a3); + } + }, this.isValidRespond = async (t2) => { + var e2; + if (!$u(t2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `respond() params: ${t2}`); + throw new Error(r3); + } + const { topic: s2, response: i2 } = t2; + try { + await this.isValidSessionTopic(s2); + } catch (r3) { + throw (e2 = t2 == null ? void 0 : t2.response) != null && e2.id && this.cleanupAfterResponse(t2), r3; + } + if (!rh(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); + throw new Error(r3); + } + }, this.isValidPing = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `ping() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidEmit = async (t2) => { + if (!$u(t2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() params: ${t2}`); + throw new Error(o2); + } + const { topic: e2, event: s2, chainId: i2 } = t2; + await this.isValidSessionTopic(e2); + const { namespaces: r3 } = this.client.session.get(e2); + if (!nh(r3, i2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() chainId: ${i2}`); + throw new Error(o2); + } + if (!ih(s2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); + throw new Error(o2); + } + if (!oh(r3, i2, s2.name)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); + throw new Error(o2); + } + }, this.isValidDisconnect = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `disconnect() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidAuthenticate = (t2) => { + const { chains: e2, uri: s2, domain: i2, nonce: r3 } = t2; + if (!Array.isArray(e2) || e2.length === 0) + throw new Error("chains is required and must be a non-empty array"); + if (!Gt$1(s2, false)) + throw new Error("uri is required parameter"); + if (!Gt$1(i2, false)) + throw new Error("domain is required parameter"); + if (!Gt$1(r3, false)) + throw new Error("nonce is required parameter"); + if ([...new Set(e2.map((a3) => dn(a3).namespace))].length > 1) + throw new Error("Multi-namespace requests are not supported. Please request single namespace only."); + const { namespace: o2 } = dn(e2[0]); + if (o2 !== "eip155") + throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains."); + }, this.getVerifyContext = async (t2, e2) => { + const s2 = { verified: { verifyUrl: e2.verifyUrl || k$1, validation: "UNKNOWN", origin: e2.url || "" } }; + try { + const i2 = await this.client.core.verify.resolve({ attestationId: t2, verifyUrl: e2.verifyUrl }); + i2 && (s2.verified.origin = i2.origin, s2.verified.isScam = i2.isScam, s2.verified.validation = i2.origin === new URL(e2.url).origin ? "VALID" : "INVALID"); + } catch (i2) { + this.client.logger.info(i2); + } + return this.client.logger.info(`Verify context: ${JSON.stringify(s2)}`), s2; + }, this.validateSessionProps = (t2, e2) => { + Object.values(t2).forEach((s2) => { + if (!Gt$1(s2, false)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `${e2} must be in Record format. Received: ${JSON.stringify(s2)}`); + throw new Error(i2); + } + }); + }, this.getPendingAuthRequest = (t2) => { + const e2 = this.client.auth.requests.get(t2); + return typeof e2 == "object" ? e2 : void 0; + }, this.addToRecentlyDeleted = (t2, e2) => { + if (this.recentlyDeletedMap.set(t2, e2), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) { + let s2 = 0; + const i2 = this.recentlyDeletedLimit / 2; + for (const r3 of this.recentlyDeletedMap.keys()) { + if (s2++ >= i2) + break; + this.recentlyDeletedMap.delete(r3); + } + } + }, this.checkRecentlyDeleted = (t2) => { + const e2 = this.recentlyDeletedMap.get(t2); + if (e2) { + const { message: s2 } = xe("MISSING_OR_INVALID", `Record was recently deleted - ${e2}: ${t2}`); + throw new Error(s2); + } + }; + } + async isInitialized() { + if (!this.initialized) { + const { message: n4 } = xe("NOT_INITIALIZED", this.name); + throw new Error(n4); + } + await this.client.core.relayer.confirmOnlineStateOrThrow(); + } + registerRelayerEvents() { + this.client.core.relayer.on(v2.message, async (n4) => { + const { topic: t2, message: e2 } = n4, { publicKey: s2 } = this.client.auth.authKeys.keys.includes(J) ? this.client.auth.authKeys.get(J) : { responseTopic: void 0, publicKey: void 0 }, i2 = await this.client.core.crypto.decode(t2, e2, { receiverPublicKey: s2 }); + try { + isJsonRpcRequest(i2) ? (this.client.core.history.set(t2, i2), this.onRelayEventRequest({ topic: t2, payload: i2 })) : isJsonRpcResponse(i2) ? (await this.client.core.history.resolve(i2), await this.onRelayEventResponse({ topic: t2, payload: i2 }), this.client.core.history.delete(t2, i2.id)) : this.onRelayEventUnknownPayload({ topic: t2, payload: i2 }); + } catch (r3) { + this.client.logger.error(r3); + } + }); + } + registerExpirerEvents() { + this.client.core.expirer.on(C.expired, async (n4) => { + const { topic: t2, id: e2 } = l0(n4.target); + if (e2 && this.client.pendingRequest.keys.includes(e2)) + return await this.deletePendingSessionRequest(e2, xe("EXPIRED"), true); + t2 ? this.client.session.keys.includes(t2) && (await this.deleteSession({ topic: t2, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: t2 })) : e2 && (await this.deleteProposal(e2, true), this.client.events.emit("proposal_expire", { id: e2 })); + }); + } + registerPairingEvents() { + this.client.core.pairing.events.on(V$1.create, (n4) => this.onPairingCreated(n4)), this.client.core.pairing.events.on(V$1.delete, (n4) => { + this.addToRecentlyDeleted(n4.topic, "pairing"); + }); + } + isValidPairingTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `pairing topic should be a string: ${n4}`); + throw new Error(t2); + } + if (!this.client.core.pairing.pairings.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `pairing topic doesn't exist: ${n4}`); + throw new Error(t2); + } + if (p0(this.client.core.pairing.pairings.get(n4).expiry)) { + const { message: t2 } = xe("EXPIRED", `pairing topic: ${n4}`); + throw new Error(t2); + } + } + async isValidSessionTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `session topic should be a string: ${n4}`); + throw new Error(t2); + } + if (this.checkRecentlyDeleted(n4), !this.client.session.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `session topic doesn't exist: ${n4}`); + throw new Error(t2); + } + if (p0(this.client.session.get(n4).expiry)) { + await this.deleteSession({ topic: n4 }); + const { message: t2 } = xe("EXPIRED", `session topic: ${n4}`); + throw new Error(t2); + } + if (!this.client.core.crypto.keychain.has(n4)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `session topic does not exist in keychain: ${n4}`); + throw await this.deleteSession({ topic: n4 }), new Error(t2); + } + } + async isValidSessionOrPairingTopic(n4) { + if (this.checkRecentlyDeleted(n4), this.client.session.keys.includes(n4)) + await this.isValidSessionTopic(n4); + else if (this.client.core.pairing.pairings.keys.includes(n4)) + this.isValidPairingTopic(n4); + else if (Gt$1(n4, false)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${n4}`); + throw new Error(t2); + } else { + const { message: t2 } = xe("MISSING_OR_INVALID", `session or pairing topic should be a string: ${n4}`); + throw new Error(t2); + } + } + async isValidProposalId(n4) { + if (!Zu(n4)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `proposal id should be a number: ${n4}`); + throw new Error(t2); + } + if (!this.client.proposal.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `proposal id doesn't exist: ${n4}`); + throw new Error(t2); + } + if (p0(this.client.proposal.get(n4).expiryTimestamp)) { + await this.deleteProposal(n4); + const { message: t2 } = xe("EXPIRED", `proposal id: ${n4}`); + throw new Error(t2); + } + } +}; +let Zt$1 = class Zt extends Vt { + constructor(n4, t2) { + super(n4, t2, Ke, se$1), this.core = n4, this.logger = t2; + } +}; +class We extends Vt { + constructor(n4, t2) { + super(n4, t2, Ge, se$1), this.core = n4, this.logger = t2; + } +} +class es2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Fe, se$1, (e2) => e2.id), this.core = n4, this.logger = t2; + } +} +class ts2 extends Vt { + constructor(n4, t2) { + super(n4, t2, He, X, () => J), this.core = n4, this.logger = t2; + } +} +let ss$1 = class ss2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Ye, X), this.core = n4, this.logger = t2; + } +}; +class is2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Xe$1, X, (e2) => e2.id), this.core = n4, this.logger = t2; + } +} +class rs { + constructor(n4, t2) { + this.core = n4, this.logger = t2, this.authKeys = new ts2(this.core, this.logger), this.pairingTopics = new ss$1(this.core, this.logger), this.requests = new is2(this.core, this.logger); + } + async init() { + await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init(); + } +} +let ne$1 = class ne extends b$1 { + constructor(n4) { + super(n4), this.protocol = Se, this.version = Ee, this.name = ie$1.name, this.events = new eventsExports.EventEmitter(), this.on = (e2, s2) => this.events.on(e2, s2), this.once = (e2, s2) => this.events.once(e2, s2), this.off = (e2, s2) => this.events.off(e2, s2), this.removeListener = (e2, s2) => this.events.removeListener(e2, s2), this.removeAllListeners = (e2) => this.events.removeAllListeners(e2), this.connect = async (e2) => { + try { + return await this.engine.connect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.pair = async (e2) => { + try { + return await this.engine.pair(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approve = async (e2) => { + try { + return await this.engine.approve(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.reject = async (e2) => { + try { + return await this.engine.reject(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.update = async (e2) => { + try { + return await this.engine.update(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.extend = async (e2) => { + try { + return await this.engine.extend(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.request = async (e2) => { + try { + return await this.engine.request(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.respond = async (e2) => { + try { + return await this.engine.respond(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.ping = async (e2) => { + try { + return await this.engine.ping(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.emit = async (e2) => { + try { + return await this.engine.emit(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.disconnect = async (e2) => { + try { + return await this.engine.disconnect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.find = (e2) => { + try { + return this.engine.find(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.getPendingSessionRequests = () => { + try { + return this.engine.getPendingSessionRequests(); + } catch (e2) { + throw this.logger.error(e2.message), e2; + } + }, this.authenticate = async (e2) => { + try { + return await this.engine.authenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.formatAuthMessage = (e2) => { + try { + return this.engine.formatAuthMessage(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approveSessionAuthenticate = async (e2) => { + try { + return await this.engine.approveSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.rejectSessionAuthenticate = async (e2) => { + try { + return await this.engine.rejectSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.name = (n4 == null ? void 0 : n4.name) || ie$1.name, this.metadata = (n4 == null ? void 0 : n4.metadata) || Xo(); + const t2 = typeof (n4 == null ? void 0 : n4.logger) < "u" && typeof (n4 == null ? void 0 : n4.logger) != "string" ? n4.logger : nt$1(k$2({ level: (n4 == null ? void 0 : n4.logger) || ie$1.logger })); + this.core = (n4 == null ? void 0 : n4.core) || new Br(n4), this.logger = E$1(t2, this.name), this.session = new We(this.core, this.logger), this.proposal = new Zt$1(this.core, this.logger), this.pendingRequest = new es2(this.core, this.logger), this.engine = new Wt$1(this), this.auth = new rs(this.core, this.logger); + } + static async init(n4) { + const t2 = new ne(n4); + return await t2.initialize(), t2; + } + get context() { + return y$2(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.engine.init(), await this.auth.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); + } catch (n4) { + throw this.logger.info("SignClient Initialization Failure"), this.logger.error(n4.message), n4; + } + } +}; +var N = Object.defineProperty, T = Object.defineProperties, U = Object.getOwnPropertyDescriptors, I = Object.getOwnPropertySymbols, A = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable, M = (e2, t2, a3) => t2 in e2 ? N(e2, t2, { enumerable: true, configurable: true, writable: true, value: a3 }) : e2[t2] = a3, q = (e2, t2) => { + for (var a3 in t2 || (t2 = {})) + A.call(t2, a3) && M(e2, a3, t2[a3]); + if (I) + for (var a3 of I(t2)) + D.call(t2, a3) && M(e2, a3, t2[a3]); + return e2; +}, L$1 = (e2, t2) => T(e2, U(t2)), g2 = (e2, t2, a3) => { + if (!t2.has(e2)) + throw TypeError("Cannot " + a3); +}, s = (e2, t2, a3) => (g2(e2, t2, "read from private field"), a3 ? a3.call(e2) : t2.get(e2)), d4 = (e2, t2, a3) => { + if (t2.has(e2)) + throw TypeError("Cannot add the same private member more than once"); + t2 instanceof WeakSet ? t2.add(e2) : t2.set(e2, a3); +}, S = (e2, t2, a3, h4) => (g2(e2, t2, "write to private field"), t2.set(e2, a3), a3), n3 = (e2, t2, a3) => (g2(e2, t2, "access private method"), a3), w2, f2, u2, o, O2, k, r2, c, j$1, P; +class G { + constructor(t2) { + d4(this, O2), d4(this, r2), d4(this, j$1), d4(this, w2, void 0), d4(this, f2, void 0), d4(this, u2, void 0), d4(this, o, void 0), S(this, w2, t2), S(this, f2, n3(this, O2, k).call(this)), n3(this, r2, c).call(this); + } + async connect(t2, a3 = true) { + const { requiredNamespaces: h4, optionalNamespaces: y3 } = t2; + return new Promise(async (W2, E2) => { + var _3, C2; + if (await n3(this, r2, c).call(this), a3) { + const p2 = s(this, f2).subscribeModal((i2) => { + i2.open || (p2(), E2(new Error("Modal closed"))); + }), { uri: v3, approval: m3 } = await s(this, o).connect(t2); + if (v3) { + const i2 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), y3 && Object.values(y3).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), await s(this, f2).openModal({ uri: v3, chains: Array.from(i2) }); + } + try { + const i2 = await m3(); + W2(i2); + } catch (i2) { + E2(i2); + } finally { + p2(), s(this, f2).closeModal(); + } + } else { + const { uri: p2, approval: v3 } = await s(this, o).connect(t2); + if (p2) { + const m3 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }), y3 && Object.values(y3).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }); + try { + if ((_3 = window == null ? void 0 : window.aleo) != null && _3.connectPuzzle) { + (C2 = window == null ? void 0 : window.aleo) == null || C2.connectPuzzle({ wc: { uri: p2 } }); + const i2 = await v3(); + W2(i2); + } else + throw new Error("window.aleo.connectPuzzle is undefined! Set showModal to true."); + } catch (i2) { + console.error(i2), E2(i2); + } + } + } + }); + } + async disconnect(t2) { + await n3(this, r2, c).call(this), await s(this, o).disconnect(t2); + } + async request(t2) { + return await n3(this, r2, c).call(this), await s(this, o).request(t2); + } + async getSessions() { + return await n3(this, r2, c).call(this), s(this, o).session.getAll(); + } + async getSession() { + return await n3(this, r2, c).call(this), s(this, o).session.getAll().at(-1); + } + async onSessionEvent(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_event", t2); + } + async offSessionEvent(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_event", t2); + } + async onSessionUpdate(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_update", t2); + } + async offSessionUpdate(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_update", t2); + } + async onSessionDelete(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_delete", t2); + } + async offSessionDelete(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_delete", t2); + } + async onSessionExpire(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_expire", t2); + } + async offSessionExpire(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_expire", t2); + } +} +w2 = /* @__PURE__ */ new WeakMap(), f2 = /* @__PURE__ */ new WeakMap(), u2 = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), O2 = /* @__PURE__ */ new WeakSet(), k = function() { + const { modalOptions: e2, projectId: t2 } = s(this, w2); + return new d$3(L$1(q({}, e2), { projectId: t2 })); +}, r2 = /* @__PURE__ */ new WeakSet(), c = async function() { + return s(this, o) ? true : (!s(this, u2) && typeof window < "u" && S(this, u2, n3(this, j$1, P).call(this)), s(this, u2)); +}, j$1 = /* @__PURE__ */ new WeakSet(), P = async function() { + S(this, o, await ne$1.init({ metadata: s(this, w2).metadata, projectId: s(this, w2).projectId, relayUrl: s(this, w2).relayUrl })); + const e2 = await s(this, o).core.crypto.getClientId(); + try { + localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e2); + } catch { + console.info("Unable to set client id"); + } +}; +var util; +(function(util2) { + util2.assertEqual = (val) => val; + function assertIs(_arg) { + } + util2.assertIs = assertIs; + function assertNever(_x) { + throw new Error(); + } + util2.assertNever = assertNever; + util2.arrayToEnum = (items) => { + const obj = {}; + for (const item of items) { + obj[item] = item; + } + return obj; + }; + util2.getValidEnumValues = (obj) => { + const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number"); + const filtered = {}; + for (const k2 of validKeys) { + filtered[k2] = obj[k2]; + } + return util2.objectValues(filtered); + }; + util2.objectValues = (obj) => { + return util2.objectKeys(obj).map(function(e2) { + return obj[e2]; + }); + }; + util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { + const keys2 = []; + for (const key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + keys2.push(key); + } + } + return keys2; + }; + util2.find = (arr, checker) => { + for (const item of arr) { + if (checker(item)) + return item; + } + return void 0; + }; + util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val; + function joinValues(array, separator = " | ") { + return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator); + } + util2.joinValues = joinValues; + util2.jsonStringifyReplacer = (_3, value) => { + if (typeof value === "bigint") { + return value.toString(); + } + return value; + }; +})(util || (util = {})); +var objectUtil; +(function(objectUtil2) { + objectUtil2.mergeShapes = (first, second) => { + return { + ...first, + ...second + // second overwrites first + }; + }; +})(objectUtil || (objectUtil = {})); +const ZodParsedType = util.arrayToEnum([ + "string", + "nan", + "number", + "integer", + "float", + "boolean", + "date", + "bigint", + "symbol", + "function", + "undefined", + "null", + "array", + "object", + "unknown", + "promise", + "void", + "never", + "map", + "set" +]); +const getParsedType = (data) => { + const t2 = typeof data; + switch (t2) { + case "undefined": + return ZodParsedType.undefined; + case "string": + return ZodParsedType.string; + case "number": + return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number; + case "boolean": + return ZodParsedType.boolean; + case "function": + return ZodParsedType.function; + case "bigint": + return ZodParsedType.bigint; + case "symbol": + return ZodParsedType.symbol; + case "object": + if (Array.isArray(data)) { + return ZodParsedType.array; + } + if (data === null) { + return ZodParsedType.null; + } + if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { + return ZodParsedType.promise; + } + if (typeof Map !== "undefined" && data instanceof Map) { + return ZodParsedType.map; + } + if (typeof Set !== "undefined" && data instanceof Set) { + return ZodParsedType.set; + } + if (typeof Date !== "undefined" && data instanceof Date) { + return ZodParsedType.date; + } + return ZodParsedType.object; + default: + return ZodParsedType.unknown; + } +}; +const ZodIssueCode = util.arrayToEnum([ + "invalid_type", + "invalid_literal", + "custom", + "invalid_union", + "invalid_union_discriminator", + "invalid_enum_value", + "unrecognized_keys", + "invalid_arguments", + "invalid_return_type", + "invalid_date", + "invalid_string", + "too_small", + "too_big", + "invalid_intersection_types", + "not_multiple_of", + "not_finite" +]); +const quotelessJson = (obj) => { + const json = JSON.stringify(obj, null, 2); + return json.replace(/"([^"]+)":/g, "$1:"); +}; +class ZodError extends Error { + constructor(issues) { + super(); + this.issues = []; + this.addIssue = (sub) => { + this.issues = [...this.issues, sub]; + }; + this.addIssues = (subs = []) => { + this.issues = [...this.issues, ...subs]; + }; + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } else { + this.__proto__ = actualProto; + } + this.name = "ZodError"; + this.issues = issues; + } + get errors() { + return this.issues; + } + format(_mapper) { + const mapper = _mapper || function(issue) { + return issue.message; + }; + const fieldErrors = { _errors: [] }; + const processError = (error) => { + for (const issue of error.issues) { + if (issue.code === "invalid_union") { + issue.unionErrors.map(processError); + } else if (issue.code === "invalid_return_type") { + processError(issue.returnTypeError); + } else if (issue.code === "invalid_arguments") { + processError(issue.argumentsError); + } else if (issue.path.length === 0) { + fieldErrors._errors.push(mapper(issue)); + } else { + let curr = fieldErrors; + let i2 = 0; + while (i2 < issue.path.length) { + const el = issue.path[i2]; + const terminal = i2 === issue.path.length - 1; + if (!terminal) { + curr[el] = curr[el] || { _errors: [] }; + } else { + curr[el] = curr[el] || { _errors: [] }; + curr[el]._errors.push(mapper(issue)); + } + curr = curr[el]; + i2++; + } + } + } + }; + processError(this); + return fieldErrors; + } + toString() { + return this.message; + } + get message() { + return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2); + } + get isEmpty() { + return this.issues.length === 0; + } + flatten(mapper = (issue) => issue.message) { + const fieldErrors = {}; + const formErrors = []; + for (const sub of this.issues) { + if (sub.path.length > 0) { + fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; + fieldErrors[sub.path[0]].push(mapper(sub)); + } else { + formErrors.push(mapper(sub)); + } + } + return { formErrors, fieldErrors }; + } + get formErrors() { + return this.flatten(); + } +} +ZodError.create = (issues) => { + const error = new ZodError(issues); + return error; +}; +const errorMap = (issue, _ctx) => { + let message; + switch (issue.code) { + case ZodIssueCode.invalid_type: + if (issue.received === ZodParsedType.undefined) { + message = "Required"; + } else { + message = `Expected ${issue.expected}, received ${issue.received}`; + } + break; + case ZodIssueCode.invalid_literal: + message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`; + break; + case ZodIssueCode.unrecognized_keys: + message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`; + break; + case ZodIssueCode.invalid_union: + message = `Invalid input`; + break; + case ZodIssueCode.invalid_union_discriminator: + message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`; + break; + case ZodIssueCode.invalid_enum_value: + message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`; + break; + case ZodIssueCode.invalid_arguments: + message = `Invalid function arguments`; + break; + case ZodIssueCode.invalid_return_type: + message = `Invalid function return type`; + break; + case ZodIssueCode.invalid_date: + message = `Invalid date`; + break; + case ZodIssueCode.invalid_string: + if (typeof issue.validation === "object") { + if ("includes" in issue.validation) { + message = `Invalid input: must include "${issue.validation.includes}"`; + if (typeof issue.validation.position === "number") { + message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; + } + } else if ("startsWith" in issue.validation) { + message = `Invalid input: must start with "${issue.validation.startsWith}"`; + } else if ("endsWith" in issue.validation) { + message = `Invalid input: must end with "${issue.validation.endsWith}"`; + } else { + util.assertNever(issue.validation); + } + } else if (issue.validation !== "regex") { + message = `Invalid ${issue.validation}`; + } else { + message = "Invalid"; + } + break; + case ZodIssueCode.too_small: + if (issue.type === "array") + message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`; + else if (issue.type === "string") + message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`; + else if (issue.type === "number") + message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`; + else if (issue.type === "date") + message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`; + else + message = "Invalid input"; + break; + case ZodIssueCode.too_big: + if (issue.type === "array") + message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`; + else if (issue.type === "string") + message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`; + else if (issue.type === "number") + message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; + else if (issue.type === "bigint") + message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; + else if (issue.type === "date") + message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`; + else + message = "Invalid input"; + break; + case ZodIssueCode.custom: + message = `Invalid input`; + break; + case ZodIssueCode.invalid_intersection_types: + message = `Intersection results could not be merged`; + break; + case ZodIssueCode.not_multiple_of: + message = `Number must be a multiple of ${issue.multipleOf}`; + break; + case ZodIssueCode.not_finite: + message = "Number must be finite"; + break; + default: + message = _ctx.defaultError; + util.assertNever(issue); + } + return { message }; +}; +let overrideErrorMap = errorMap; +function setErrorMap(map) { + overrideErrorMap = map; +} +function getErrorMap() { + return overrideErrorMap; +} +const makeIssue = (params) => { + const { data, path, errorMaps, issueData } = params; + const fullPath = [...path, ...issueData.path || []]; + const fullIssue = { + ...issueData, + path: fullPath + }; + let errorMessage = ""; + const maps = errorMaps.filter((m3) => !!m3).slice().reverse(); + for (const map of maps) { + errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; + } + return { + ...issueData, + path: fullPath, + message: issueData.message || errorMessage + }; +}; +const EMPTY_PATH = []; +function addIssueToContext(ctx, issueData) { + const issue = makeIssue({ + issueData, + data: ctx.data, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + // then global default map + ].filter((x2) => !!x2) + }); + ctx.common.issues.push(issue); +} +class ParseStatus { + constructor() { + this.value = "valid"; + } + dirty() { + if (this.value === "valid") + this.value = "dirty"; + } + abort() { + if (this.value !== "aborted") + this.value = "aborted"; + } + static mergeArray(status, results) { + const arrayValue = []; + for (const s2 of results) { + if (s2.status === "aborted") + return INVALID; + if (s2.status === "dirty") + status.dirty(); + arrayValue.push(s2.value); + } + return { status: status.value, value: arrayValue }; + } + static async mergeObjectAsync(status, pairs) { + const syncPairs = []; + for (const pair of pairs) { + syncPairs.push({ + key: await pair.key, + value: await pair.value + }); + } + return ParseStatus.mergeObjectSync(status, syncPairs); + } + static mergeObjectSync(status, pairs) { + const finalObject = {}; + for (const pair of pairs) { + const { key, value } = pair; + if (key.status === "aborted") + return INVALID; + if (value.status === "aborted") + return INVALID; + if (key.status === "dirty") + status.dirty(); + if (value.status === "dirty") + status.dirty(); + if (typeof value.value !== "undefined" || pair.alwaysSet) { + finalObject[key.value] = value.value; + } + } + return { status: status.value, value: finalObject }; + } +} +const INVALID = Object.freeze({ + status: "aborted" +}); +const DIRTY = (value) => ({ status: "dirty", value }); +const OK = (value) => ({ status: "valid", value }); +const isAborted = (x2) => x2.status === "aborted"; +const isDirty = (x2) => x2.status === "dirty"; +const isValid = (x2) => x2.status === "valid"; +const isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise; +var errorUtil; +(function(errorUtil2) { + errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {}; + errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; +})(errorUtil || (errorUtil = {})); +class ParseInputLazyPath { + constructor(parent, value, path, key) { + this._cachedPath = []; + this.parent = parent; + this.data = value; + this._path = path; + this._key = key; + } + get path() { + if (!this._cachedPath.length) { + if (this._key instanceof Array) { + this._cachedPath.push(...this._path, ...this._key); + } else { + this._cachedPath.push(...this._path, this._key); + } + } + return this._cachedPath; + } +} +const handleResult = (ctx, result) => { + if (isValid(result)) { + return { success: true, data: result.value }; + } else { + if (!ctx.common.issues.length) { + throw new Error("Validation failed but no issues detected."); + } + return { + success: false, + get error() { + if (this._error) + return this._error; + const error = new ZodError(ctx.common.issues); + this._error = error; + return this._error; + } + }; + } +}; +function processCreateParams(params) { + if (!params) + return {}; + const { errorMap: errorMap2, invalid_type_error, required_error, description: description2 } = params; + if (errorMap2 && (invalid_type_error || required_error)) { + throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); + } + if (errorMap2) + return { errorMap: errorMap2, description: description2 }; + const customMap = (iss, ctx) => { + if (iss.code !== "invalid_type") + return { message: ctx.defaultError }; + if (typeof ctx.data === "undefined") { + return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError }; + } + return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError }; + }; + return { errorMap: customMap, description: description2 }; +} +class ZodType { + constructor(def) { + this.spa = this.safeParseAsync; + this._def = def; + this.parse = this.parse.bind(this); + this.safeParse = this.safeParse.bind(this); + this.parseAsync = this.parseAsync.bind(this); + this.safeParseAsync = this.safeParseAsync.bind(this); + this.spa = this.spa.bind(this); + this.refine = this.refine.bind(this); + this.refinement = this.refinement.bind(this); + this.superRefine = this.superRefine.bind(this); + this.optional = this.optional.bind(this); + this.nullable = this.nullable.bind(this); + this.nullish = this.nullish.bind(this); + this.array = this.array.bind(this); + this.promise = this.promise.bind(this); + this.or = this.or.bind(this); + this.and = this.and.bind(this); + this.transform = this.transform.bind(this); + this.brand = this.brand.bind(this); + this.default = this.default.bind(this); + this.catch = this.catch.bind(this); + this.describe = this.describe.bind(this); + this.pipe = this.pipe.bind(this); + this.isNullable = this.isNullable.bind(this); + this.isOptional = this.isOptional.bind(this); + } + get description() { + return this._def.description; + } + _getType(input) { + return getParsedType(input.data); + } + _getOrReturnCtx(input, ctx) { + return ctx || { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + }; + } + _processInputParams(input) { + return { + status: new ParseStatus(), + ctx: { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + } + }; + } + _parseSync(input) { + const result = this._parse(input); + if (isAsync(result)) { + throw new Error("Synchronous parse encountered promise."); + } + return result; + } + _parseAsync(input) { + const result = this._parse(input); + return Promise.resolve(result); + } + parse(data, params) { + const result = this.safeParse(data, params); + if (result.success) + return result.data; + throw result.error; + } + safeParse(data, params) { + var _a2; + const ctx = { + common: { + issues: [], + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, + contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap + }, + path: (params === null || params === void 0 ? void 0 : params.path) || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }; + const result = this._parseSync({ data, path: ctx.path, parent: ctx }); + return handleResult(ctx, result); + } + async parseAsync(data, params) { + const result = await this.safeParseAsync(data, params); + if (result.success) + return result.data; + throw result.error; + } + async safeParseAsync(data, params) { + const ctx = { + common: { + issues: [], + contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap, + async: true + }, + path: (params === null || params === void 0 ? void 0 : params.path) || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }; + const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }); + const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); + return handleResult(ctx, result); + } + refine(check, message) { + const getIssueProperties = (val) => { + if (typeof message === "string" || typeof message === "undefined") { + return { message }; + } else if (typeof message === "function") { + return message(val); + } else { + return message; + } + }; + return this._refinement((val, ctx) => { + const result = check(val); + const setError = () => ctx.addIssue({ + code: ZodIssueCode.custom, + ...getIssueProperties(val) + }); + if (typeof Promise !== "undefined" && result instanceof Promise) { + return result.then((data) => { + if (!data) { + setError(); + return false; + } else { + return true; + } + }); + } + if (!result) { + setError(); + return false; + } else { + return true; + } + }); + } + refinement(check, refinementData) { + return this._refinement((val, ctx) => { + if (!check(val)) { + ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData); + return false; + } else { + return true; + } + }); + } + _refinement(refinement) { + return new ZodEffects({ + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "refinement", refinement } + }); + } + superRefine(refinement) { + return this._refinement(refinement); + } + optional() { + return ZodOptional.create(this, this._def); + } + nullable() { + return ZodNullable.create(this, this._def); + } + nullish() { + return this.nullable().optional(); + } + array() { + return ZodArray.create(this, this._def); + } + promise() { + return ZodPromise.create(this, this._def); + } + or(option) { + return ZodUnion.create([this, option], this._def); + } + and(incoming) { + return ZodIntersection.create(this, incoming, this._def); + } + transform(transform) { + return new ZodEffects({ + ...processCreateParams(this._def), + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "transform", transform } + }); + } + default(def) { + const defaultValueFunc = typeof def === "function" ? def : () => def; + return new ZodDefault({ + ...processCreateParams(this._def), + innerType: this, + defaultValue: defaultValueFunc, + typeName: ZodFirstPartyTypeKind.ZodDefault + }); + } + brand() { + return new ZodBranded({ + typeName: ZodFirstPartyTypeKind.ZodBranded, + type: this, + ...processCreateParams(this._def) + }); + } + catch(def) { + const catchValueFunc = typeof def === "function" ? def : () => def; + return new ZodCatch({ + ...processCreateParams(this._def), + innerType: this, + catchValue: catchValueFunc, + typeName: ZodFirstPartyTypeKind.ZodCatch + }); + } + describe(description2) { + const This = this.constructor; + return new This({ + ...this._def, + description: description2 + }); + } + pipe(target) { + return ZodPipeline.create(this, target); + } + isOptional() { + return this.safeParse(void 0).success; + } + isNullable() { + return this.safeParse(null).success; + } +} +const cuidRegex = /^c[^\s-]{8,}$/i; +const cuid2Regex = /^[a-z][a-z0-9]*$/; +const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/; +const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; +const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/; +const emojiRegex = new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u"); +const ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; +const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/; +const datetimeRegex = (args) => { + if (args.precision) { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`); + } + } else if (args.precision === 0) { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`); + } + } else { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`); + } + } +}; +function isValidIP(ip, version2) { + if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) { + return true; + } + if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) { + return true; + } + return false; +} +class ZodString extends ZodType { + constructor() { + super(...arguments); + this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), { + validation, + code: ZodIssueCode.invalid_string, + ...errorUtil.errToObj(message) + }); + this.nonempty = (message) => this.min(1, errorUtil.errToObj(message)); + this.trim = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "trim" }] + }); + this.toLowerCase = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toLowerCase" }] + }); + this.toUpperCase = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toUpperCase" }] + }); + } + _parse(input) { + if (this._def.coerce) { + input.data = String(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.string) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext( + ctx2, + { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.string, + received: ctx2.parsedType + } + // + ); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.length < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: true, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.length > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: true, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "length") { + const tooBig = input.data.length > check.value; + const tooSmall = input.data.length < check.value; + if (tooBig || tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + if (tooBig) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: true, + exact: true, + message: check.message + }); + } else if (tooSmall) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: true, + exact: true, + message: check.message + }); + } + status.dirty(); + } + } else if (check.kind === "email") { + if (!emailRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "email", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "emoji") { + if (!emojiRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "emoji", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "uuid") { + if (!uuidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "uuid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "cuid") { + if (!cuidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "cuid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "cuid2") { + if (!cuid2Regex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "cuid2", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "ulid") { + if (!ulidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "ulid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "url") { + try { + new URL(input.data); + } catch (_a2) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "url", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "regex") { + check.regex.lastIndex = 0; + const testResult = check.regex.test(input.data); + if (!testResult) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "regex", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "trim") { + input.data = input.data.trim(); + } else if (check.kind === "includes") { + if (!input.data.includes(check.value, check.position)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { includes: check.value, position: check.position }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "toLowerCase") { + input.data = input.data.toLowerCase(); + } else if (check.kind === "toUpperCase") { + input.data = input.data.toUpperCase(); + } else if (check.kind === "startsWith") { + if (!input.data.startsWith(check.value)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { startsWith: check.value }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "endsWith") { + if (!input.data.endsWith(check.value)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { endsWith: check.value }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "datetime") { + const regex = datetimeRegex(check); + if (!regex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: "datetime", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "ip") { + if (!isValidIP(input.data, check.version)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "ip", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + _addCheck(check) { + return new ZodString({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + email(message) { + return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) }); + } + url(message) { + return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) }); + } + emoji(message) { + return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) }); + } + uuid(message) { + return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) }); + } + cuid(message) { + return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) }); + } + cuid2(message) { + return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) }); + } + ulid(message) { + return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) }); + } + ip(options) { + return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); + } + datetime(options) { + var _a2; + if (typeof options === "string") { + return this._addCheck({ + kind: "datetime", + precision: null, + offset: false, + message: options + }); + } + return this._addCheck({ + kind: "datetime", + precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, + ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) + }); + } + regex(regex, message) { + return this._addCheck({ + kind: "regex", + regex, + ...errorUtil.errToObj(message) + }); + } + includes(value, options) { + return this._addCheck({ + kind: "includes", + value, + position: options === null || options === void 0 ? void 0 : options.position, + ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) + }); + } + startsWith(value, message) { + return this._addCheck({ + kind: "startsWith", + value, + ...errorUtil.errToObj(message) + }); + } + endsWith(value, message) { + return this._addCheck({ + kind: "endsWith", + value, + ...errorUtil.errToObj(message) + }); + } + min(minLength, message) { + return this._addCheck({ + kind: "min", + value: minLength, + ...errorUtil.errToObj(message) + }); + } + max(maxLength, message) { + return this._addCheck({ + kind: "max", + value: maxLength, + ...errorUtil.errToObj(message) + }); + } + length(len, message) { + return this._addCheck({ + kind: "length", + value: len, + ...errorUtil.errToObj(message) + }); + } + get isDatetime() { + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); + } + get isEmail() { + return !!this._def.checks.find((ch2) => ch2.kind === "email"); + } + get isURL() { + return !!this._def.checks.find((ch2) => ch2.kind === "url"); + } + get isEmoji() { + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); + } + get isUUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); + } + get isCUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); + } + get isCUID2() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); + } + get isULID() { + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); + } + get isIP() { + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); + } + get minLength() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxLength() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } +} +ZodString.create = (params) => { + var _a2; + return new ZodString({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodString, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams(params) + }); +}; +function floatSafeRemainder(val, step) { + const valDecCount = (val.toString().split(".")[1] || "").length; + const stepDecCount = (step.toString().split(".")[1] || "").length; + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; + const valInt = parseInt(val.toFixed(decCount).replace(".", "")); + const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); + return valInt % stepInt / Math.pow(10, decCount); +} +class ZodNumber extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + this.step = this.multipleOf; + } + _parse(input) { + if (this._def.coerce) { + input.data = Number(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.number) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.number, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "int") { + if (!util.isInteger(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: "integer", + received: "float", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (floatSafeRemainder(input.data, check.value) !== 0) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "finite") { + if (!Number.isFinite(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_finite, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodNumber({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodNumber({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + int(message) { + return this._addCheck({ + kind: "int", + message: errorUtil.toString(message) + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: false, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: false, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: true, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: true, + message: errorUtil.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + finite(message) { + return this._addCheck({ + kind: "finite", + message: errorUtil.toString(message) + }); + } + safe(message) { + return this._addCheck({ + kind: "min", + inclusive: true, + value: Number.MIN_SAFE_INTEGER, + message: errorUtil.toString(message) + })._addCheck({ + kind: "max", + inclusive: true, + value: Number.MAX_SAFE_INTEGER, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } + get isInt() { + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util.isInteger(ch2.value)); + } + get isFinite() { + let max = null, min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { + return true; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return Number.isFinite(min) && Number.isFinite(max); + } +} +ZodNumber.create = (params) => { + return new ZodNumber({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodNumber, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); +}; +class ZodBigInt extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + } + _parse(input) { + if (this._def.coerce) { + input.data = BigInt(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.bigint) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.bigint, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + type: "bigint", + minimum: check.value, + inclusive: check.inclusive, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + type: "bigint", + maximum: check.value, + inclusive: check.inclusive, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (input.data % check.value !== BigInt(0)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodBigInt({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodBigInt({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: false, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: false, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } +} +ZodBigInt.create = (params) => { + var _a2; + return new ZodBigInt({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodBigInt, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams(params) + }); +}; +class ZodBoolean extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = Boolean(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.boolean) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.boolean, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodBoolean.create = (params) => { + return new ZodBoolean({ + typeName: ZodFirstPartyTypeKind.ZodBoolean, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); +}; +class ZodDate extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = new Date(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.date) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.date, + received: ctx2.parsedType + }); + return INVALID; + } + if (isNaN(input.data.getTime())) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_date + }); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.getTime() < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + message: check.message, + inclusive: true, + exact: false, + minimum: check.value, + type: "date" + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.getTime() > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + message: check.message, + inclusive: true, + exact: false, + maximum: check.value, + type: "date" + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { + status: status.value, + value: new Date(input.data.getTime()) + }; + } + _addCheck(check) { + return new ZodDate({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + min(minDate, message) { + return this._addCheck({ + kind: "min", + value: minDate.getTime(), + message: errorUtil.toString(message) + }); + } + max(maxDate, message) { + return this._addCheck({ + kind: "max", + value: maxDate.getTime(), + message: errorUtil.toString(message) + }); + } + get minDate() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min != null ? new Date(min) : null; + } + get maxDate() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max != null ? new Date(max) : null; + } +} +ZodDate.create = (params) => { + return new ZodDate({ + checks: [], + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + typeName: ZodFirstPartyTypeKind.ZodDate, + ...processCreateParams(params) + }); +}; +class ZodSymbol extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.symbol) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.symbol, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodSymbol.create = (params) => { + return new ZodSymbol({ + typeName: ZodFirstPartyTypeKind.ZodSymbol, + ...processCreateParams(params) + }); +}; +class ZodUndefined extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.undefined, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodUndefined.create = (params) => { + return new ZodUndefined({ + typeName: ZodFirstPartyTypeKind.ZodUndefined, + ...processCreateParams(params) + }); +}; +class ZodNull extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.null) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.null, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodNull.create = (params) => { + return new ZodNull({ + typeName: ZodFirstPartyTypeKind.ZodNull, + ...processCreateParams(params) + }); +}; +class ZodAny extends ZodType { + constructor() { + super(...arguments); + this._any = true; + } + _parse(input) { + return OK(input.data); + } +} +ZodAny.create = (params) => { + return new ZodAny({ + typeName: ZodFirstPartyTypeKind.ZodAny, + ...processCreateParams(params) + }); +}; +class ZodUnknown extends ZodType { + constructor() { + super(...arguments); + this._unknown = true; + } + _parse(input) { + return OK(input.data); + } +} +ZodUnknown.create = (params) => { + return new ZodUnknown({ + typeName: ZodFirstPartyTypeKind.ZodUnknown, + ...processCreateParams(params) + }); +}; +class ZodNever extends ZodType { + _parse(input) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.never, + received: ctx.parsedType + }); + return INVALID; + } +} +ZodNever.create = (params) => { + return new ZodNever({ + typeName: ZodFirstPartyTypeKind.ZodNever, + ...processCreateParams(params) + }); +}; +class ZodVoid extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.void, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodVoid.create = (params) => { + return new ZodVoid({ + typeName: ZodFirstPartyTypeKind.ZodVoid, + ...processCreateParams(params) + }); +}; +class ZodArray extends ZodType { + _parse(input) { + const { ctx, status } = this._processInputParams(input); + const def = this._def; + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (def.exactLength !== null) { + const tooBig = ctx.data.length > def.exactLength.value; + const tooSmall = ctx.data.length < def.exactLength.value; + if (tooBig || tooSmall) { + addIssueToContext(ctx, { + code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, + minimum: tooSmall ? def.exactLength.value : void 0, + maximum: tooBig ? def.exactLength.value : void 0, + type: "array", + inclusive: true, + exact: true, + message: def.exactLength.message + }); + status.dirty(); + } + } + if (def.minLength !== null) { + if (ctx.data.length < def.minLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.minLength.message + }); + status.dirty(); + } + } + if (def.maxLength !== null) { + if (ctx.data.length > def.maxLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.maxLength.message + }); + status.dirty(); + } + } + if (ctx.common.async) { + return Promise.all([...ctx.data].map((item, i2) => { + return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); + })).then((result2) => { + return ParseStatus.mergeArray(status, result2); + }); + } + const result = [...ctx.data].map((item, i2) => { + return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); + }); + return ParseStatus.mergeArray(status, result); + } + get element() { + return this._def.type; + } + min(minLength, message) { + return new ZodArray({ + ...this._def, + minLength: { value: minLength, message: errorUtil.toString(message) } + }); + } + max(maxLength, message) { + return new ZodArray({ + ...this._def, + maxLength: { value: maxLength, message: errorUtil.toString(message) } + }); + } + length(len, message) { + return new ZodArray({ + ...this._def, + exactLength: { value: len, message: errorUtil.toString(message) } + }); + } + nonempty(message) { + return this.min(1, message); + } +} +ZodArray.create = (schema, params) => { + return new ZodArray({ + type: schema, + minLength: null, + maxLength: null, + exactLength: null, + typeName: ZodFirstPartyTypeKind.ZodArray, + ...processCreateParams(params) + }); +}; +function deepPartialify(schema) { + if (schema instanceof ZodObject) { + const newShape = {}; + for (const key in schema.shape) { + const fieldSchema = schema.shape[key]; + newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); + } + return new ZodObject({ + ...schema._def, + shape: () => newShape + }); + } else if (schema instanceof ZodArray) { + return new ZodArray({ + ...schema._def, + type: deepPartialify(schema.element) + }); + } else if (schema instanceof ZodOptional) { + return ZodOptional.create(deepPartialify(schema.unwrap())); + } else if (schema instanceof ZodNullable) { + return ZodNullable.create(deepPartialify(schema.unwrap())); + } else if (schema instanceof ZodTuple) { + return ZodTuple.create(schema.items.map((item) => deepPartialify(item))); + } else { + return schema; + } +} +class ZodObject extends ZodType { + constructor() { + super(...arguments); + this._cached = null; + this.nonstrict = this.passthrough; + this.augment = this.extend; + } + _getCached() { + if (this._cached !== null) + return this._cached; + const shape = this._def.shape(); + const keys2 = util.objectKeys(shape); + return this._cached = { shape, keys: keys2 }; + } + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.object) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx2.parsedType + }); + return INVALID; + } + const { status, ctx } = this._processInputParams(input); + const { shape, keys: shapeKeys } = this._getCached(); + const extraKeys = []; + if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); + } + } + } + const pairs = []; + for (const key of shapeKeys) { + const keyValidator = shape[key]; + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), + alwaysSet: key in ctx.data + }); + } + if (this._def.catchall instanceof ZodNever) { + const unknownKeys = this._def.unknownKeys; + if (unknownKeys === "passthrough") { + for (const key of extraKeys) { + pairs.push({ + key: { status: "valid", value: key }, + value: { status: "valid", value: ctx.data[key] } + }); + } + } else if (unknownKeys === "strict") { + if (extraKeys.length > 0) { + addIssueToContext(ctx, { + code: ZodIssueCode.unrecognized_keys, + keys: extraKeys + }); + status.dirty(); + } + } else if (unknownKeys === "strip") + ; + else { + throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); + } + } else { + const catchall = this._def.catchall; + for (const key of extraKeys) { + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: catchall._parse( + new ParseInputLazyPath(ctx, value, ctx.path, key) + //, ctx.child(key), value, getParsedType(value) + ), + alwaysSet: key in ctx.data + }); + } + } + if (ctx.common.async) { + return Promise.resolve().then(async () => { + const syncPairs = []; + for (const pair of pairs) { + const key = await pair.key; + syncPairs.push({ + key, + value: await pair.value, + alwaysSet: pair.alwaysSet + }); + } + return syncPairs; + }).then((syncPairs) => { + return ParseStatus.mergeObjectSync(status, syncPairs); + }); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } + } + get shape() { + return this._def.shape(); + } + strict(message) { + errorUtil.errToObj; + return new ZodObject({ + ...this._def, + unknownKeys: "strict", + ...message !== void 0 ? { + errorMap: (issue, ctx) => { + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + if (issue.code === "unrecognized_keys") + return { + message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError + }; + return { + message: defaultError + }; + } + } : {} + }); + } + strip() { + return new ZodObject({ + ...this._def, + unknownKeys: "strip" + }); + } + passthrough() { + return new ZodObject({ + ...this._def, + unknownKeys: "passthrough" + }); + } + // const AugmentFactory = + // (def: Def) => + // ( + // augmentation: Augmentation + // ): ZodObject< + // extendShape, Augmentation>, + // Def["unknownKeys"], + // Def["catchall"] + // > => { + // return new ZodObject({ + // ...def, + // shape: () => ({ + // ...def.shape(), + // ...augmentation, + // }), + // }) as any; + // }; + extend(augmentation) { + return new ZodObject({ + ...this._def, + shape: () => ({ + ...this._def.shape(), + ...augmentation + }) + }); + } + /** + * Prior to zod@1.0.12 there was a bug in the + * inferred type of merged objects. Please + * upgrade if you are experiencing issues. + */ + merge(merging) { + const merged = new ZodObject({ + unknownKeys: merging._def.unknownKeys, + catchall: merging._def.catchall, + shape: () => ({ + ...this._def.shape(), + ...merging._def.shape() + }), + typeName: ZodFirstPartyTypeKind.ZodObject + }); + return merged; + } + // merge< + // Incoming extends AnyZodObject, + // Augmentation extends Incoming["shape"], + // NewOutput extends { + // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation + // ? Augmentation[k]["_output"] + // : k extends keyof Output + // ? Output[k] + // : never; + // }, + // NewInput extends { + // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation + // ? Augmentation[k]["_input"] + // : k extends keyof Input + // ? Input[k] + // : never; + // } + // >( + // merging: Incoming + // ): ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"], + // NewOutput, + // NewInput + // > { + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + setKey(key, schema) { + return this.augment({ [key]: schema }); + } + // merge( + // merging: Incoming + // ): //ZodObject = (merging) => { + // ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"] + // > { + // // const mergedShape = objectUtil.mergeShapes( + // // this._def.shape(), + // // merging._def.shape() + // // ); + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + catchall(index) { + return new ZodObject({ + ...this._def, + catchall: index + }); + } + pick(mask) { + const shape = {}; + util.objectKeys(mask).forEach((key) => { + if (mask[key] && this.shape[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ + ...this._def, + shape: () => shape + }); + } + omit(mask) { + const shape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (!mask[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ + ...this._def, + shape: () => shape + }); + } + /** + * @deprecated + */ + deepPartial() { + return deepPartialify(this); + } + partial(mask) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + const fieldSchema = this.shape[key]; + if (mask && !mask[key]) { + newShape[key] = fieldSchema; + } else { + newShape[key] = fieldSchema.optional(); + } + }); + return new ZodObject({ + ...this._def, + shape: () => newShape + }); + } + required(mask) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (mask && !mask[key]) { + newShape[key] = this.shape[key]; + } else { + const fieldSchema = this.shape[key]; + let newField = fieldSchema; + while (newField instanceof ZodOptional) { + newField = newField._def.innerType; + } + newShape[key] = newField; + } + }); + return new ZodObject({ + ...this._def, + shape: () => newShape + }); + } + keyof() { + return createZodEnum(util.objectKeys(this.shape)); + } +} +ZodObject.create = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +ZodObject.strictCreate = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strict", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +ZodObject.lazycreate = (shape, params) => { + return new ZodObject({ + shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +class ZodUnion extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const options = this._def.options; + function handleResults(results) { + for (const result of results) { + if (result.result.status === "valid") { + return result.result; + } + } + for (const result of results) { + if (result.result.status === "dirty") { + ctx.common.issues.push(...result.ctx.common.issues); + return result.result; + } + } + const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + if (ctx.common.async) { + return Promise.all(options.map(async (option) => { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + return { + result: await option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }), + ctx: childCtx + }; + })).then(handleResults); + } else { + let dirty = void 0; + const issues = []; + for (const option of options) { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + const result = option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }); + if (result.status === "valid") { + return result; + } else if (result.status === "dirty" && !dirty) { + dirty = { result, ctx: childCtx }; + } + if (childCtx.common.issues.length) { + issues.push(childCtx.common.issues); + } + } + if (dirty) { + ctx.common.issues.push(...dirty.ctx.common.issues); + return dirty.result; + } + const unionErrors = issues.map((issues2) => new ZodError(issues2)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + } + get options() { + return this._def.options; + } +} +ZodUnion.create = (types2, params) => { + return new ZodUnion({ + options: types2, + typeName: ZodFirstPartyTypeKind.ZodUnion, + ...processCreateParams(params) + }); +}; +const getDiscriminator = (type2) => { + if (type2 instanceof ZodLazy) { + return getDiscriminator(type2.schema); + } else if (type2 instanceof ZodEffects) { + return getDiscriminator(type2.innerType()); + } else if (type2 instanceof ZodLiteral) { + return [type2.value]; + } else if (type2 instanceof ZodEnum) { + return type2.options; + } else if (type2 instanceof ZodNativeEnum) { + return Object.keys(type2.enum); + } else if (type2 instanceof ZodDefault) { + return getDiscriminator(type2._def.innerType); + } else if (type2 instanceof ZodUndefined) { + return [void 0]; + } else if (type2 instanceof ZodNull) { + return [null]; + } else { + return null; + } +}; +class ZodDiscriminatedUnion extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }); + return INVALID; + } + const discriminator = this.discriminator; + const discriminatorValue = ctx.data[discriminator]; + const option = this.optionsMap.get(discriminatorValue); + if (!option) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union_discriminator, + options: Array.from(this.optionsMap.keys()), + path: [discriminator] + }); + return INVALID; + } + if (ctx.common.async) { + return option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } else { + return option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } + } + get discriminator() { + return this._def.discriminator; + } + get options() { + return this._def.options; + } + get optionsMap() { + return this._def.optionsMap; + } + /** + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must + * have a different value for each object in the union. + * @param discriminator the name of the discriminator property + * @param types an array of object schemas + * @param params + */ + static create(discriminator, options, params) { + const optionsMap = /* @__PURE__ */ new Map(); + for (const type2 of options) { + const discriminatorValues = getDiscriminator(type2.shape[discriminator]); + if (!discriminatorValues) { + throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); + } + for (const value of discriminatorValues) { + if (optionsMap.has(value)) { + throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); + } + optionsMap.set(value, type2); + } + } + return new ZodDiscriminatedUnion({ + typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, + discriminator, + options, + optionsMap, + ...processCreateParams(params) + }); + } +} +function mergeValues(a3, b3) { + const aType = getParsedType(a3); + const bType = getParsedType(b3); + if (a3 === b3) { + return { valid: true, data: a3 }; + } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) { + const bKeys = util.objectKeys(b3); + const sharedKeys = util.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1); + const newObj = { ...a3, ...b3 }; + for (const key of sharedKeys) { + const sharedValue = mergeValues(a3[key], b3[key]); + if (!sharedValue.valid) { + return { valid: false }; + } + newObj[key] = sharedValue.data; + } + return { valid: true, data: newObj }; + } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { + if (a3.length !== b3.length) { + return { valid: false }; + } + const newArray = []; + for (let index = 0; index < a3.length; index++) { + const itemA = a3[index]; + const itemB = b3[index]; + const sharedValue = mergeValues(itemA, itemB); + if (!sharedValue.valid) { + return { valid: false }; + } + newArray.push(sharedValue.data); + } + return { valid: true, data: newArray }; + } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a3 === +b3) { + return { valid: true, data: a3 }; + } else { + return { valid: false }; + } +} +class ZodIntersection extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const handleParsed = (parsedLeft, parsedRight) => { + if (isAborted(parsedLeft) || isAborted(parsedRight)) { + return INVALID; + } + const merged = mergeValues(parsedLeft.value, parsedRight.value); + if (!merged.valid) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_intersection_types + }); + return INVALID; + } + if (isDirty(parsedLeft) || isDirty(parsedRight)) { + status.dirty(); + } + return { status: status.value, value: merged.data }; + }; + if (ctx.common.async) { + return Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)); + } else { + return handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); + } + } +} +ZodIntersection.create = (left, right, params) => { + return new ZodIntersection({ + left, + right, + typeName: ZodFirstPartyTypeKind.ZodIntersection, + ...processCreateParams(params) + }); +}; +class ZodTuple extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (ctx.data.length < this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + return INVALID; + } + const rest = this._def.rest; + if (!rest && ctx.data.length > this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + status.dirty(); + } + const items = [...ctx.data].map((item, itemIndex) => { + const schema = this._def.items[itemIndex] || this._def.rest; + if (!schema) + return null; + return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)); + }).filter((x2) => !!x2); + if (ctx.common.async) { + return Promise.all(items).then((results) => { + return ParseStatus.mergeArray(status, results); + }); + } else { + return ParseStatus.mergeArray(status, items); + } + } + get items() { + return this._def.items; + } + rest(rest) { + return new ZodTuple({ + ...this._def, + rest + }); + } +} +ZodTuple.create = (schemas, params) => { + if (!Array.isArray(schemas)) { + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + } + return new ZodTuple({ + items: schemas, + typeName: ZodFirstPartyTypeKind.ZodTuple, + rest: null, + ...processCreateParams(params) + }); +}; +class ZodRecord extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }); + return INVALID; + } + const pairs = []; + const keyType = this._def.keyType; + const valueType = this._def.valueType; + for (const key in ctx.data) { + pairs.push({ + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) + }); + } + if (ctx.common.async) { + return ParseStatus.mergeObjectAsync(status, pairs); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } + } + get element() { + return this._def.valueType; + } + static create(first, second, third) { + if (second instanceof ZodType) { + return new ZodRecord({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(third) + }); + } + return new ZodRecord({ + keyType: ZodString.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(second) + }); + } +} +class ZodMap extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.map) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.map, + received: ctx.parsedType + }); + return INVALID; + } + const keyType = this._def.keyType; + const valueType = this._def.valueType; + const pairs = [...ctx.data.entries()].map(([key, value], index) => { + return { + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])), + value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"])) + }; + }); + if (ctx.common.async) { + const finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (const pair of pairs) { + const key = await pair.key; + const value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + const finalMap = /* @__PURE__ */ new Map(); + for (const pair of pairs) { + const key = pair.key; + const value = pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } + } +} +ZodMap.create = (keyType, valueType, params) => { + return new ZodMap({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind.ZodMap, + ...processCreateParams(params) + }); +}; +class ZodSet extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.set) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.set, + received: ctx.parsedType + }); + return INVALID; + } + const def = this._def; + if (def.minSize !== null) { + if (ctx.data.size < def.minSize.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.minSize.message + }); + status.dirty(); + } + } + if (def.maxSize !== null) { + if (ctx.data.size > def.maxSize.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.maxSize.message + }); + status.dirty(); + } + } + const valueType = this._def.valueType; + function finalizeSet(elements2) { + const parsedSet = /* @__PURE__ */ new Set(); + for (const element of elements2) { + if (element.status === "aborted") + return INVALID; + if (element.status === "dirty") + status.dirty(); + parsedSet.add(element.value); + } + return { status: status.value, value: parsedSet }; + } + const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2))); + if (ctx.common.async) { + return Promise.all(elements).then((elements2) => finalizeSet(elements2)); + } else { + return finalizeSet(elements); + } + } + min(minSize, message) { + return new ZodSet({ + ...this._def, + minSize: { value: minSize, message: errorUtil.toString(message) } + }); + } + max(maxSize, message) { + return new ZodSet({ + ...this._def, + maxSize: { value: maxSize, message: errorUtil.toString(message) } + }); + } + size(size, message) { + return this.min(size, message).max(size, message); + } + nonempty(message) { + return this.min(1, message); + } +} +ZodSet.create = (valueType, params) => { + return new ZodSet({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind.ZodSet, + ...processCreateParams(params) + }); +}; +class ZodFunction extends ZodType { + constructor() { + super(...arguments); + this.validate = this.implement; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.function) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.function, + received: ctx.parsedType + }); + return INVALID; + } + function makeArgsIssue(args, error) { + return makeIssue({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode.invalid_arguments, + argumentsError: error + } + }); + } + function makeReturnsIssue(returns, error) { + return makeIssue({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode.invalid_return_type, + returnTypeError: error + } + }); + } + const params = { errorMap: ctx.common.contextualErrorMap }; + const fn = ctx.data; + if (this._def.returns instanceof ZodPromise) { + return OK(async (...args) => { + const error = new ZodError([]); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { + error.addIssue(makeArgsIssue(args, e2)); + throw error; + }); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { + error.addIssue(makeReturnsIssue(result, e2)); + throw error; + }); + return parsedReturns; + }); + } else { + return OK((...args) => { + const parsedArgs = this._def.args.safeParse(args, params); + if (!parsedArgs.success) { + throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); + } + const result = fn(...parsedArgs.data); + const parsedReturns = this._def.returns.safeParse(result, params); + if (!parsedReturns.success) { + throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); + } + return parsedReturns.data; + }); + } + } + parameters() { + return this._def.args; + } + returnType() { + return this._def.returns; + } + args(...items) { + return new ZodFunction({ + ...this._def, + args: ZodTuple.create(items).rest(ZodUnknown.create()) + }); + } + returns(returnType) { + return new ZodFunction({ + ...this._def, + returns: returnType + }); + } + implement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + strictImplement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + static create(args, returns, params) { + return new ZodFunction({ + args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()), + returns: returns || ZodUnknown.create(), + typeName: ZodFirstPartyTypeKind.ZodFunction, + ...processCreateParams(params) + }); + } +} +class ZodLazy extends ZodType { + get schema() { + return this._def.getter(); + } + _parse(input) { + const { ctx } = this._processInputParams(input); + const lazySchema = this._def.getter(); + return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + } +} +ZodLazy.create = (getter, params) => { + return new ZodLazy({ + getter, + typeName: ZodFirstPartyTypeKind.ZodLazy, + ...processCreateParams(params) + }); +}; +class ZodLiteral extends ZodType { + _parse(input) { + if (input.data !== this._def.value) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_literal, + expected: this._def.value + }); + return INVALID; + } + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } +} +ZodLiteral.create = (value, params) => { + return new ZodLiteral({ + value, + typeName: ZodFirstPartyTypeKind.ZodLiteral, + ...processCreateParams(params) + }); +}; +function createZodEnum(values, params) { + return new ZodEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodEnum, + ...processCreateParams(params) + }); +} +class ZodEnum extends ZodType { + _parse(input) { + if (typeof input.data !== "string") { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (this._def.values.indexOf(input.data) === -1) { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); + } + get options() { + return this._def.values; + } + get enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Values() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + extract(values) { + return ZodEnum.create(values); + } + exclude(values) { + return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + } +} +ZodEnum.create = createZodEnum; +class ZodNativeEnum extends ZodType { + _parse(input) { + const nativeEnumValues = util.getValidEnumValues(this._def.values); + const ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (nativeEnumValues.indexOf(input.data) === -1) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); + } + get enum() { + return this._def.values; + } +} +ZodNativeEnum.create = (values, params) => { + return new ZodNativeEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodNativeEnum, + ...processCreateParams(params) + }); +}; +class ZodPromise extends ZodType { + unwrap() { + return this._def.type; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.promise, + received: ctx.parsedType + }); + return INVALID; + } + const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); + return OK(promisified.then((data) => { + return this._def.type.parseAsync(data, { + path: ctx.path, + errorMap: ctx.common.contextualErrorMap + }); + })); + } +} +ZodPromise.create = (schema, params) => { + return new ZodPromise({ + type: schema, + typeName: ZodFirstPartyTypeKind.ZodPromise, + ...processCreateParams(params) + }); +}; +class ZodEffects extends ZodType { + innerType() { + return this._def.schema; + } + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const effect = this._def.effect || null; + if (effect.type === "preprocess") { + const processed = effect.transform(ctx.data); + if (ctx.common.async) { + return Promise.resolve(processed).then((processed2) => { + return this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + }); + }); + } else { + return this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx + }); + } + } + const checkCtx = { + addIssue: (arg) => { + addIssueToContext(ctx, arg); + if (arg.fatal) { + status.abort(); + } else { + status.dirty(); + } + }, + get path() { + return ctx.path; + } + }; + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); + if (effect.type === "refinement") { + const executeRefinement = (acc) => { + const result = effect.refinement(acc, checkCtx); + if (ctx.common.async) { + return Promise.resolve(result); + } + if (result instanceof Promise) { + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + } + return acc; + }; + if (ctx.common.async === false) { + const inner = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + executeRefinement(inner.value); + return { status: status.value, value: inner.value }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + return executeRefinement(inner.value).then(() => { + return { status: status.value, value: inner.value }; + }); + }); + } + } + if (effect.type === "transform") { + if (ctx.common.async === false) { + const base3 = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (!isValid(base3)) + return base3; + const result = effect.transform(base3.value, checkCtx); + if (result instanceof Promise) { + throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + } + return { status: status.value, value: result }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { + if (!isValid(base3)) + return base3; + return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); + }); + } + } + util.assertNever(effect); + } +} +ZodEffects.create = (schema, effect, params) => { + return new ZodEffects({ + schema, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect, + ...processCreateParams(params) + }); +}; +ZodEffects.createWithPreprocess = (preprocess, schema, params) => { + return new ZodEffects({ + schema, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind.ZodEffects, + ...processCreateParams(params) + }); +}; +class ZodOptional extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.undefined) { + return OK(void 0); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } +} +ZodOptional.create = (type2, params) => { + return new ZodOptional({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodOptional, + ...processCreateParams(params) + }); +}; +class ZodNullable extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.null) { + return OK(null); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } +} +ZodNullable.create = (type2, params) => { + return new ZodNullable({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodNullable, + ...processCreateParams(params) + }); +}; +class ZodDefault extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + let data = ctx.data; + if (ctx.parsedType === ZodParsedType.undefined) { + data = this._def.defaultValue(); + } + return this._def.innerType._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + removeDefault() { + return this._def.innerType; + } +} +ZodDefault.create = (type2, params) => { + return new ZodDefault({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodDefault, + defaultValue: typeof params.default === "function" ? params.default : () => params.default, + ...processCreateParams(params) + }); +}; +class ZodCatch extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + } + }; + const result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx + } + }); + if (isAsync(result)) { + return result.then((result2) => { + return { + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + } + }) + }; + }); + } else { + return { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + } + }) + }; + } + } + removeCatch() { + return this._def.innerType; + } +} +ZodCatch.create = (type2, params) => { + return new ZodCatch({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodCatch, + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, + ...processCreateParams(params) + }); +}; +class ZodNaN extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.nan) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.nan, + received: ctx.parsedType + }); + return INVALID; + } + return { status: "valid", value: input.data }; + } +} +ZodNaN.create = (params) => { + return new ZodNaN({ + typeName: ZodFirstPartyTypeKind.ZodNaN, + ...processCreateParams(params) + }); +}; +const BRAND = Symbol("zod_brand"); +class ZodBranded extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const data = ctx.data; + return this._def.type._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + unwrap() { + return this._def.type; + } +} +class ZodPipeline extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.common.async) { + const handleAsync = async () => { + const inResult = await this._def.in._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return DIRTY(inResult.value); + } else { + return this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + }; + return handleAsync(); + } else { + const inResult = this._def.in._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return { + status: "dirty", + value: inResult.value + }; + } else { + return this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + } + } + static create(a3, b3) { + return new ZodPipeline({ + in: a3, + out: b3, + typeName: ZodFirstPartyTypeKind.ZodPipeline + }); + } +} +const custom = (check, params = {}, fatal) => { + if (check) + return ZodAny.create().superRefine((data, ctx) => { + var _a2, _b; + if (!check(data)) { + const p2 = typeof params === "function" ? params(data) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; + ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); + } + }); + return ZodAny.create(); +}; +const late = { + object: ZodObject.lazycreate +}; +var ZodFirstPartyTypeKind; +(function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; + ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; + ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; + ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; + ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; + ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; + ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; + ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; + ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; + ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; + ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; + ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; + ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; + ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; + ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; + ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; + ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; + ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; + ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; + ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; + ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; + ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; + ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; + ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; + ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; + ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; + ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; + ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; + ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; + ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; + ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; + ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; + ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; + ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; + ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; +})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); +const instanceOfType = (cls, params = { + message: `Input not instance of ${cls.name}` +}) => custom((data) => data instanceof cls, params); +const stringType = ZodString.create; +const numberType = ZodNumber.create; +const nanType = ZodNaN.create; +const bigIntType = ZodBigInt.create; +const booleanType = ZodBoolean.create; +const dateType = ZodDate.create; +const symbolType = ZodSymbol.create; +const undefinedType = ZodUndefined.create; +const nullType = ZodNull.create; +const anyType = ZodAny.create; +const unknownType = ZodUnknown.create; +const neverType = ZodNever.create; +const voidType = ZodVoid.create; +const arrayType = ZodArray.create; +const objectType = ZodObject.create; +const strictObjectType = ZodObject.strictCreate; +const unionType = ZodUnion.create; +const discriminatedUnionType = ZodDiscriminatedUnion.create; +const intersectionType = ZodIntersection.create; +const tupleType = ZodTuple.create; +const recordType = ZodRecord.create; +const mapType = ZodMap.create; +const setType = ZodSet.create; +const functionType = ZodFunction.create; +const lazyType = ZodLazy.create; +const literalType = ZodLiteral.create; +const enumType = ZodEnum.create; +const nativeEnumType = ZodNativeEnum.create; +const promiseType = ZodPromise.create; +const effectsType = ZodEffects.create; +const optionalType = ZodOptional.create; +const nullableType = ZodNullable.create; +const preprocessType = ZodEffects.createWithPreprocess; +const pipelineType = ZodPipeline.create; +const ostring = () => stringType().optional(); +const onumber = () => numberType().optional(); +const oboolean = () => booleanType().optional(); +const coerce = { + string: (arg) => ZodString.create({ ...arg, coerce: true }), + number: (arg) => ZodNumber.create({ ...arg, coerce: true }), + boolean: (arg) => ZodBoolean.create({ + ...arg, + coerce: true + }), + bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }), + date: (arg) => ZodDate.create({ ...arg, coerce: true }) +}; +const NEVER = INVALID; +var z = /* @__PURE__ */ Object.freeze({ + __proto__: null, + defaultErrorMap: errorMap, + setErrorMap, + getErrorMap, + makeIssue, + EMPTY_PATH, + addIssueToContext, + ParseStatus, + INVALID, + DIRTY, + OK, + isAborted, + isDirty, + isValid, + isAsync, + get util() { + return util; + }, + get objectUtil() { + return objectUtil; + }, + ZodParsedType, + getParsedType, + ZodType, + ZodString, + ZodNumber, + ZodBigInt, + ZodBoolean, + ZodDate, + ZodSymbol, + ZodUndefined, + ZodNull, + ZodAny, + ZodUnknown, + ZodNever, + ZodVoid, + ZodArray, + ZodObject, + ZodUnion, + ZodDiscriminatedUnion, + ZodIntersection, + ZodTuple, + ZodRecord, + ZodMap, + ZodSet, + ZodFunction, + ZodLazy, + ZodLiteral, + ZodEnum, + ZodNativeEnum, + ZodPromise, + ZodEffects, + ZodTransformer: ZodEffects, + ZodOptional, + ZodNullable, + ZodDefault, + ZodCatch, + ZodNaN, + BRAND, + ZodBranded, + ZodPipeline, + custom, + Schema: ZodType, + ZodSchema: ZodType, + late, + get ZodFirstPartyTypeKind() { + return ZodFirstPartyTypeKind; + }, + coerce, + any: anyType, + array: arrayType, + bigint: bigIntType, + boolean: booleanType, + date: dateType, + discriminatedUnion: discriminatedUnionType, + effect: effectsType, + "enum": enumType, + "function": functionType, + "instanceof": instanceOfType, + intersection: intersectionType, + lazy: lazyType, + literal: literalType, + map: mapType, + nan: nanType, + nativeEnum: nativeEnumType, + never: neverType, + "null": nullType, + nullable: nullableType, + number: numberType, + object: objectType, + oboolean, + onumber, + optional: optionalType, + ostring, + pipeline: pipelineType, + preprocess: preprocessType, + promise: promiseType, + record: recordType, + set: setType, + strictObject: strictObjectType, + string: stringType, + symbol: symbolType, + transformer: effectsType, + tuple: tupleType, + "undefined": undefinedType, + union: unionType, + unknown: unknownType, + "void": voidType, + NEVER, + ZodIssueCode, + quotelessJson, + ZodError +}); +const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; +const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; +const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; +const aleoTransitionIdRegex = /^au1[a-z0-9]{58}$/i; +const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; +const aleoFieldRegex = /^\d+field$/; +const aleoU32 = /^\d+u32$/; +const aleoU64 = /^\d+u64$/; +const zodAddress = z.string().regex(aleoAddressRegex); +const zodViewKey = z.string().regex(aleoViewKeyRegex); +const zodPrivateKey = z.string().regex(aleoPrivateKeyRegex); +z.string().regex(aleoTransitionIdRegex); +const zodTransactionId = z.string().regex(aleoTransactionIdRegex); +const zodField = z.string().regex(aleoFieldRegex); +const zodU32 = z.string().regex(aleoU32); +const zodU64 = z.string().regex(aleoU64); +var InputOutputType; +(function(InputOutputType2) { + InputOutputType2["Record"] = "record"; + InputOutputType2["OutputRecord"] = "outputRecord"; + InputOutputType2["Public"] = "public"; + InputOutputType2["Private"] = "private"; + InputOutputType2["Constant"] = "constant"; + InputOutputType2["Future"] = "future"; + InputOutputType2["ExternalRecord"] = "external_record"; +})(InputOutputType || (InputOutputType = {})); +var EventType; +(function(EventType2) { + EventType2["Deploy"] = "Deploy"; + EventType2["Execute"] = "Execute"; + EventType2["Send"] = "Send"; + EventType2["Receive"] = "Receive"; + EventType2["Join"] = "Join"; + EventType2["Split"] = "Split"; + EventType2["Shield"] = "Shield"; + EventType2["Unshield"] = "Unshield"; + EventType2["Referral"] = "Referral"; + EventType2["Points"] = "Points"; + EventType2["Raffle"] = "Raffle"; +})(EventType || (EventType = {})); +var EventStatus; +(function(EventStatus2) { + EventStatus2["Creating"] = "Creating"; + EventStatus2["Pending"] = "Pending"; + EventStatus2["Settled"] = "Settled"; + EventStatus2["Failed"] = "Failed"; +})(EventStatus || (EventStatus = {})); +var Visibility; +(function(Visibility2) { + Visibility2["Private"] = "Private"; + Visibility2["Public"] = "Public"; +})(Visibility || (Visibility = {})); +var Network; +(function(Network2) { + Network2["AleoTestnet"] = "AleoTestnet"; + Network2["AleoCanarynet"] = "AleoCanarynet"; + Network2["AleoMainnet"] = "AleoMainnet"; +})(Network || (Network = {})); +const zodEventType = z.nativeEnum(EventType); +const zodEventStatus = z.nativeEnum(EventStatus); +const zodNetwork = z.nativeEnum(Network); +const zodVisibility = z.nativeEnum(Visibility); +const wc_aleo_methods = [ + "decrypt", + "disconnect", + "getSelectedAccount", + "getBalance", + "getRecords", + "requestCreateEvent", + "getEvent", + "getEvents", + "createSharedState", + "importSharedState", + "requestSignature" +]; +const wc_required_aleo_chains = ["aleo:1"]; +const wc_optional_aleo_chains = [ + "aleo:0" + // for eventual mainnet +]; +const wc_aleo_chains = [ + ...wc_required_aleo_chains, + ...wc_optional_aleo_chains +]; +const wc_events = [ + "chainChanged", + "accountSelected", + "selectedAccountSynced", + "sharedAccountSynced" +]; +const projectId = "f0aaeffe71b636da453fce042d79d723"; +function isAndroid() { + if (typeof navigator === "undefined") { + return false; + } + return /Android/i.test(navigator.userAgent); +} +const web3modal_puzzle_props_android = { + projectId, + chains: wc_aleo_chains, + enableExplorer: true, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png" + } +}; +const web3modal_puzzle_props_default = { + projectId, + chains: wc_aleo_chains, + enableExplorer: false, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + desktopWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "", + universal: "https://walletconnect.puzzle.online/" + } + }, + { + id: "avail", + name: "Avail Wallet", + links: { + native: "avail://", + universal: "https://avail.global" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png", + avail: "https://i.imgur.com/GxNn8BO.png" + } +}; +const web3modal_puzzle_props = isAndroid() ? web3modal_puzzle_props_android : web3modal_puzzle_props_default; +const signClient_puzzleProps = { + requiredNamespaces: { + aleo: { + methods: wc_aleo_methods, + chains: web3modal_puzzle_props.chains, + events: wc_events + } + } +}; +const networkToChainId = (network, includePrefix = true) => { + let chain; + switch (network) { + case Network.AleoMainnet: + chain = "aleo:0"; + break; + case Network.AleoCanarynet: + chain = "aleo:0"; + break; + case Network.AleoTestnet: + chain = "aleo:1"; + break; + } + return includePrefix ? chain : chain.replace("aleo:", ""); +}; +const chainIdToNetwork = (chainId) => { + switch (chainId) { + case "aleo:0": + return Network.AleoCanarynet; + case "aleo:1": + return Network.AleoTestnet; + } +}; +const name = "@puzzlehq/sdk-core"; +const displayName = "Puzzle SDK"; +const version = "0.4.0"; +const description = "Your portal to privacy"; +const main = "./dist/puzzle.cjs.js"; +const module = "./dist/puzzle.es.js"; +const browser$1 = "./dist/puzzle.umd.js"; +const types = "./dist/types/src/index.d.ts"; +const exports = { + ".": { + "import": "./dist/puzzle.es.js", + require: "./dist/puzzle.cjs.js", + browser: "./dist/puzzle.umd.js", + types: "./dist/types/src/index.d.ts" + } +}; +const type = "module"; +const scripts = { + "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", + "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, + build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", + "type-check": "tsc --noEmit" +}; +const repository = { + type: "git", + url: "git+https://github.com/puzzlehq/puzzle-sdk.git" +}; +const dependencies = { + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", + "@walletconnect/types": "^2.11.2", + "@walletconnect/utils": "^2.11.2", + debug: "^4.3.4", + events: "^3.3.0", + ws: "^8.16.0" +}; +const peerDependencies = { + buffer: "^6.0.3" +}; +const keywords = [ + "puzzle", + "cryptocurrency wallet", + "privacy", + "aleo", + "web3", + "crypto", + "typescript" +]; +const author = "Puzzle"; +const license = "ISC"; +const bugs = { + url: "https://github.com/puzzlehq/puzzle-sdk/issues" +}; +const homepage = "https://github.com/puzzlehq/puzzle-sdk#readme"; +const pkg = { + name, + displayName, + version, + description, + main, + module, + browser: browser$1, + types, + "private": false, + exports, + type, + scripts, + repository, + dependencies, + peerDependencies, + keywords, + author, + license, + bugs, + homepage +}; +var On = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function A0(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; +} +var Pn = { exports: {} }; +/** +* [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 +*/ +(function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On : o2 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s2(u3, E2, u3).update(B2)[_3](); + }; + }, H2 = function(u3, E2, _3) { + return function(B2, R2) { + return new s2(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s2(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H2(u3, E2, "hex"); + return _3.create = function(B2) { + return new s2(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H2, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s2(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s2(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N2[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; + } + return this; + }, s2.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s2.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s2.call(this, u3, E2, _3); + } + v3.prototype = new s2(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne, Ie; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z2 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z2 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _3 = D2 ^ (Z2 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne = u3[42] << 2 | u3[43] >>> 30, Ie = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne, u3[45] = Me2 ^ ~Se2 & Ie, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne & St2, u3[47] = Se2 ^ ~Ie & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne ^ ~St2 & Ve2, u3[49] = Ie ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); +})(Pn); +const y0 = "logger/5.7.0"; +let Dn = false, Fn = false; +const Cr2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let Tn = Cr2.default, gi = null; +function w0() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; + } + return null; +} +const Un = w0(); +var Ai; +(function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; +})(Ai || (Ai = {})); +var re; +(function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; +})(re || (re = {})); +const kn = "0123456789abcdef"; +class L3 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); + } + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn > Cr2[i2]) && console.log.apply(console, r3); + } + debug(...t2) { + this._log(L3.levels.DEBUG, t2); + } + info(...t2) { + this._log(L3.levels.INFO, t2); + } + warn(...t2) { + this._log(L3.levels.WARNING, t2); + } + makeError(t2, r3, i2) { + if (Fn) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L3.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn[m3[y3] >> 4], w3 += kn[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o2 = t2; + let h4 = ""; + switch (r3) { + case re.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; + } + case re.CALL_EXCEPTION: + case re.INSUFFICIENT_FUNDS: + case re.MISSING_NEW: + case re.NONCE_EXPIRED: + case re.REPLACEMENT_UNDERPRICED: + case re.TRANSACTION_REPLACED: + case re.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; + } + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; + } + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); + } + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L3.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); + } + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); + } + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); + } + checkNormalize(t2) { + Un && this.throwError("platform missing String.prototype.normalize", L3.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un }); + } + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); + } + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L3.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L3.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); + } + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); + } + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L3.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); + } + static globalLogger() { + return gi || (gi = new L3(y0)), gi; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); + } + Fn = !!t2, Dn = !!r3; + } + static setLogLevel(t2) { + const r3 = Cr2[t2.toLowerCase()]; + if (r3 == null) { + L3.globalLogger().warn("invalid log level - " + t2); + return; + } + Tn = r3; + } + static from(t2) { + return new L3(t2); + } +} +L3.errors = re, L3.levels = Ai; +const x0 = "bytes/5.7.0", Dt = new L3(x0); +function qn(e2) { + return !!e2.toHexString; +} +function rr(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; +} +function Kn(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; +} +function ir(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; +} +function Ot2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2) && (e2 = e2.toHexString()), Qt(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr(new Uint8Array(i2)); + } + return ir(e2) ? rr(new Uint8Array(e2)) : Dt.throwArgumentError("invalid arrayify value", "value", e2); +} +function Qt(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2); +} +const bi = "0123456789abcdef"; +function Kt(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2)) + return e2.toHexString(); + if (Qt(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi[(n4 & 240) >> 4] + bi[n4 & 15]; + } + return r3; + } + return Dt.throwArgumentError("invalid hexlify value", "value", e2); +} +function oe(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt(e2) : Qt(e2) || Dt.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; +} +var Ln = { exports: {} }, I0 = {}, _0 = Object.freeze({ __proto__: null, default: I0 }), B0 = A0(_0); +(function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; + } + function o2(A2, f3, a3) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r3.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0.Buffer; + } catch { + } + o2.isBN = function(f3) { + return f3 instanceof o2 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o2.wordSize && Array.isArray(f3.words); + }, o2.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o2.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o2.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o2.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o2.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + } + this._strip(); + }; + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o2.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v3 = c2; v3 < l2; v3 += d5) + s2 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o2.prototype._move = function(f3) { + w3(f3, this); + }, o2.prototype.clone = function() { + var f3 = new o2(null); + return this.copy(f3), f3; + }, o2.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o2.prototype.inspect = y3; + } + else + o2.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s2 = I2[f3], v3 = N2[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s2 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o2.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o2.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o2.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o2.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o2.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o2.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; + } + return f3; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o2.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o2.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o2.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o2.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o2.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o2.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o2.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o2.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o2.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o2.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o2.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o2.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o2.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o2.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o2.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s2, f3.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s2 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s2] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s2] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s2, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te = d5[6] | 0, et2 = Te & 8191, rt2 = Te >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le = g3[3] | 0, vt2 = Le & 8191, mt2 = Le >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s2 = Math.imul(u3, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s2 = s2 + Math.imul(u3, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s2 = s2 + Math.imul(u3, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s2 = s2 + Math.imul(u3, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ne >>> 26) | 0, Ne &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v3 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s2 = s2 + Math.imul(u3, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v3 = v3 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s2 = s2 + Math.imul(u3, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v3 = v3 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s2 = s2 + Math.imul(u3, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v3 = v3 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s2 = s2 + Math.imul(u3, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v3 = v3 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s2 = s2 + Math.imul(u3, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v3 = v3 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s2 = s2 + Math.imul(u3, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v3 = v3 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v3 = v3 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v3 = v3 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v3 = v3 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v3 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne, x2[4] = Ie, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s2 = Math.max(0, g3 - A2.length + 1); s2 <= l2; s2++) { + var v3 = g3 - s2, k2 = A2.words[v3] | 0, u3 = f3.words[s2] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o2.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o2.prototype.mul = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o2.prototype.mulf = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o2.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o2.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o2.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o2(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o2.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o2.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v3 !== 0 || s2 >= d5); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o2.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o2.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o2.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o2.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o2.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o2.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o2.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o2.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o2.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o2.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o2.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s2; + if (a3 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v3 = 0; v3 < s2.length; v3++) + s2.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s2 && (s2.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s2 && (s2.words[u3] = E2); + } + return s2 && s2._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s2 || null, mod: d5 }; + }, o2.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o2(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o2(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o2(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o2.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o2.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o2.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o2.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o2.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o2.prototype.modn = function(f3) { + return this.modrn(f3); + }, o2.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o2.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o2.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s2), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s2 = 0, v3 = 1; !(c2.words[0] & v3) && s2 < 26; ++s2, v3 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o2.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o2.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o2.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o2.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; + } + } + return a3; + }, o2.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o2.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o2.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o2.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o2.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o2.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o2.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o2.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o2.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o2.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o2.red = function(f3) { + return new Y2(f3); + }, o2.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o2.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o2.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o2.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o2.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o2.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o2.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o2.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o2.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o2(f3, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o2(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o2._prime = function(f3) { + if (H2[f3]) + return H2[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H2[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o2._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v3 = this.pow(s2, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o2(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o2(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s2 = a3.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s2 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o2.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o2(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On); +})(Ln); +var K2 = Ln.exports; +const jn = "bignumber/5.7.0"; +var Rr = K2.BN; +const Ae = new L3(jn), wi = {}, Qn = 9007199254740991; +function C0(e2) { + return e2 != null && (V2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt(e2) || typeof e2 == "bigint" || ir(e2)); +} +let Jn = false; +class V2 { + constructor(t2, r3) { + t2 !== wi && Ae.throwError("cannot call constructor directly; use BigNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); + } + fromTwos(t2) { + return Lt(j(this).fromTwos(t2)); + } + toTwos(t2) { + return Lt(j(this).toTwos(t2)); + } + abs() { + return this._hex[0] === "-" ? V2.from(this._hex.substring(1)) : this; + } + add(t2) { + return Lt(j(this).add(j(t2))); + } + sub(t2) { + return Lt(j(this).sub(j(t2))); + } + div(t2) { + return V2.from(t2).isZero() && Wt2("division-by-zero", "div"), Lt(j(this).div(j(t2))); + } + mul(t2) { + return Lt(j(this).mul(j(t2))); + } + mod(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("division-by-zero", "mod"), Lt(j(this).umod(r3)); + } + pow(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("negative-power", "pow"), Lt(j(this).pow(r3)); + } + and(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "and"), Lt(j(this).and(r3)); + } + or(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "or"), Lt(j(this).or(r3)); + } + xor(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "xor"), Lt(j(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "mask"), Lt(j(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shl"), Lt(j(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shr"), Lt(j(this).shrn(t2)); + } + eq(t2) { + return j(this).eq(j(t2)); + } + lt(t2) { + return j(this).lt(j(t2)); + } + lte(t2) { + return j(this).lte(j(t2)); + } + gt(t2) { + return j(this).gt(j(t2)); + } + gte(t2) { + return j(this).gte(j(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j(this).isZero(); + } + toNumber() { + try { + return j(this).toNumber(); + } catch { + Wt2("overflow", "toNumber", this.toString()); + } + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { + } + return Ae.throwError("this platform does not support BigInt", L3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn || (Jn = true, Ae.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L3.errors.UNEXPECTED_ARGUMENT, {}) : Ae.throwError("BigNumber.toString does not accept parameters", L3.errors.UNEXPECTED_ARGUMENT, {})), j(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V2) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V2(wi, vr(t2)) : t2.match(/^-?[0-9]+$/) ? new V2(wi, vr(new Rr(t2))) : Ae.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt2("underflow", "BigNumber.from", t2), (t2 >= Qn || t2 <= -Qn) && Wt2("overflow", "BigNumber.from", t2), V2.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V2.from(r3.toString()); + if (ir(r3)) + return V2.from(Kt(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V2.from(i2); + } else { + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt(i2) || i2[0] === "-" && Qt(i2.substring(1)))) + return V2.from(i2); + } + return Ae.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } +} +function vr(e2) { + if (typeof e2 != "string") + return vr(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae.throwArgumentError("invalid hex", "value", e2), e2 = vr(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; +} +function Lt(e2) { + return V2.from(vr(e2)); +} +function j(e2) { + const t2 = V2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr("-" + t2.substring(3), 16) : new Rr(t2.substring(2), 16); +} +function Wt2(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae.throwError(e2, L3.errors.NUMERIC_FAULT, i2); +} +const Ht2 = new L3(jn), mr = {}, Gn = V2.from(0), Yn = V2.from(-1); +function Vn(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht2.throwError(e2, L3.errors.NUMERIC_FAULT, n4); +} +let gr = "0"; +for (; gr.length < 256; ) + gr += gr; +function xi(e2) { + if (typeof e2 != "number") + try { + e2 = V2.from(e2).toNumber(); + } catch { + } + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr.substring(0, e2) : Ht2.throwArgumentError("invalid decimal size", "decimals", e2); +} +function Mi(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + e2 = V2.from(e2); + const i2 = e2.lt(Gn); + i2 && (e2 = e2.mul(Yn)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o2 : e2 = o2 + "." + n4, i2 && (e2 = "-" + e2), e2; +} +function be(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht2.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht2.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht2.throwArgumentError("too many decimal points", "value", e2); + let o2 = n4[0], h4 = n4[1]; + for (o2 || (o2 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V2.from(o2), b3 = V2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn)), m3; +} +class dr2 { + constructor(t2, r3, i2, n4) { + t2 !== mr && Ht2.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr2) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht2.throwArgumentError("invalid fixed format", "format", t2), r3 = o2[1] !== "u", i2 = parseInt(o2[2]), n4 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht2.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o2("signed", "boolean", r3), i2 = o2("width", "number", i2), n4 = o2("decimals", "number", n4); + } + return i2 % 8 && Ht2.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht2.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr2(mr, r3, i2, n4); + } +} +class Ut3 { + constructor(t2, r3, i2, n4) { + t2 !== mr && Ht2.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht2.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht2.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut3.from("1" + gr.substring(0, t2), this.format), n4 = O0.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); + } + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht2.throwArgumentError("invalid byte width", "width", t2); + const r3 = V2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut3.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut3.fromString(Mi(t2, r3), dr2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3), n4 = be(t2, i2.decimals); + !i2.signed && n4.lt(Gn) && Vn("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n4.toTwos(i2.width).toHexString() : (o2 = n4.toHexString(), o2 = oe(o2, i2.width / 8)); + const h4 = Mi(n4, i2.decimals); + return new Ut3(mr, o2, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3); + if (Ot2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o2 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi(n4, i2.decimals); + return new Ut3(mr, o2, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut3.fromString(t2, r3); + if (ir(t2)) + return Ut3.fromBytes(t2, r3); + try { + return Ut3.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht2.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } +} +const Wn = Ut3.from(1), O0 = Ut3.from("0.5"); +var Or; +(function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; +})(Or || (Or = {})); +var nr; +(function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; +})(nr || (nr = {})); +function T0(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; +} +function Si(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; + }); + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o2 = n4.split(":"); + r3 += parseInt(o2[0], 16), i2[r3] = t2(o2[1]); + }), i2; +} +function $n(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); +} +$n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0), $n("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function U0(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot2(t2); +} +function ef(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o2, h4) { + i2.call(o2, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); + }); + }; + return n4(e2, t2), r3; +} +function k0(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; +} +function q0(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y3; H2++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H2 < o2[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; + } + }); +} +function K0(e2) { + let t2 = 0; + return () => e2[t2++]; +} +function H0(e2) { + return K0(q0(e2)); +} +function z0(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; +} +function L0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; +} +function rf(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; +} +function j0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0(t2()); + return r3; +} +function Pr(e2, t2) { + let r3 = rf(e2(), e2), i2 = e2(), n4 = rf(i2, e2), o2 = L0(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o2[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; +} +function Q0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0(r3, e2)); + } + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0(r3, e2)); + } + return k0(ef(t2)); +} +function J0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); + } + return t2; +} +function nf(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0(e2, r3).forEach((o2, h4) => i2[h4].push(o2)); + return i2; +} +function G0(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0(t2), o2 = nf(n4.length, 1 + e2, t2); + return ef(o2.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; + }); + })); +} +function Y0(e2, t2) { + let r3 = 1 + t2(); + return nf(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); +} +function V0(e2) { + let t2 = Pr(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o2 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o2, fe0f: h4, save: p2, check: b3 }; + } +} +function W0() { + return H0(U0("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); +} +const Dr = W0(); +new Set(Pr(Dr)), new Set(Pr(Dr)), Q0(Dr), V0(Dr); +const X0 = new Uint8Array(32); +X0.fill(0); +const os = new Uint8Array(32); +os.fill(0), V2.from(-1); +const ss3 = V2.from(0), as = V2.from(1); +V2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe(as.toHexString(), 32), oe(ss3.toHexString(), 32); +var se = {}, Q = {}, yr = af; +function af(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +af.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var Ii = { exports: {} }; +typeof Object.create == "function" ? Ii.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); +} : Ii.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; + } +}; +var us = yr, hs = Ii.exports; +Q.inherits = hs; +function cs(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; +} +function ls(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o2 = e2.charCodeAt(n4); + o2 < 128 ? r3[i2++] = o2 : o2 < 2048 ? (r3[i2++] = o2 >> 6 | 192, r3[i2++] = o2 & 63 | 128) : cs(e2, n4) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o2 >> 18 | 240, r3[i2++] = o2 >> 12 & 63 | 128, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128) : (r3[i2++] = o2 >> 12 | 224, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128); + } + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; +} +Q.toArray = ls; +function ds(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf(e2[r3].toString(16)); + return t2; +} +Q.toHex = ds; +function uf(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; +} +Q.htonl = uf; +function ps(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf(n4)), r3 += cf(n4.toString(16)); + } + return r3; +} +Q.toHex32 = ps; +function hf(e2) { + return e2.length === 1 ? "0" + e2 : e2; +} +Q.zero2 = hf; +function cf(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; +} +Q.zero8 = cf; +function vs(e2, t2, r3, i2) { + var n4 = r3 - t2; + us(n4 % 4 === 0); + for (var o2 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o2.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h4] = b3 >>> 0; + } + return o2; +} +Q.join32 = vs; +function ms$1(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r3[n4] = o2 >>> 24, r3[n4 + 1] = o2 >>> 16 & 255, r3[n4 + 2] = o2 >>> 8 & 255, r3[n4 + 3] = o2 & 255) : (r3[n4 + 3] = o2 >>> 24, r3[n4 + 2] = o2 >>> 16 & 255, r3[n4 + 1] = o2 >>> 8 & 255, r3[n4] = o2 & 255); + } + return r3; +} +Q.split32 = ms$1; +function gs(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; +} +Q.rotr32 = gs; +function As(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; +} +Q.rotl32 = As; +function bs(e2, t2) { + return e2 + t2 >>> 0; +} +Q.sum32 = bs; +function ys(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; +} +Q.sum32_3 = ys; +function ws(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; +} +Q.sum32_4 = ws; +function xs(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; +} +Q.sum32_5 = xs; +function Ms(e2, t2, r3, i2) { + var n4 = e2[t2], o2 = e2[t2 + 1], h4 = i2 + o2 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; +} +Q.sum64 = Ms; +function Es(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o2 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o2 >>> 0; +} +Q.sum64_hi = Es; +function Ss(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; +} +Q.sum64_lo = Ss; +function Ns(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o2 >>> 0, b3 += m3 < o2 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; +} +Q.sum64_4_hi = Ns; +function Is(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = t2 + i2 + o2 + p2; + return b3 >>> 0; +} +Q.sum64_4_lo = Is; +function _s(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o2 >>> 0, w3 += y3 < o2 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; +} +Q.sum64_5_hi = _s; +function Bs(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = t2 + i2 + o2 + p2 + m3; + return w3 >>> 0; +} +Q.sum64_5_lo = Bs; +function Cs(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; +} +Q.rotr64_hi = Cs; +function Rs(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q.rotr64_lo = Rs; +function Os(e2, t2, r3) { + return e2 >>> r3; +} +Q.shr64_hi = Os; +function Ps(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q.shr64_lo = Ps; +var fr = {}, lf = Q, Ds = yr; +function Fr() { + 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; +} +fr.BlockHash = Fr, Fr.prototype.update = function(t2, r3) { + if (t2 = lf.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; +}, Fr.prototype.digest = function(t2) { + return this.update(this._pad()), Ds(this.pending === null), this._digest(t2); +}, Fr.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n4[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 & 255; + } else + for (n4[o2++] = t2 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + return n4; +}; +var or = {}, ae = {}, Fs = Q, ue = Fs.rotr32; +function Ts(e2, t2, r3, i2) { + if (e2 === 0) + return df(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf(t2, r3, i2); + if (e2 === 2) + return pf(t2, r3, i2); +} +ae.ft_1 = Ts; +function df(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; +} +ae.ch32 = df; +function pf(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; +} +ae.maj32 = pf; +function vf(e2, t2, r3) { + return e2 ^ t2 ^ r3; +} +ae.p32 = vf; +function Us(e2) { + return ue(e2, 2) ^ ue(e2, 13) ^ ue(e2, 22); +} +ae.s0_256 = Us; +function ks(e2) { + return ue(e2, 6) ^ ue(e2, 11) ^ ue(e2, 25); +} +ae.s1_256 = ks; +function qs(e2) { + return ue(e2, 7) ^ ue(e2, 18) ^ e2 >>> 3; +} +ae.g0_256 = qs; +function Ks(e2) { + return ue(e2, 17) ^ ue(e2, 19) ^ e2 >>> 10; +} +ae.g1_256 = Ks; +var sr = Q, Hs = fr, zs = ae, _i = sr.rotl32, wr = sr.sum32, Ls = sr.sum32_5, js = zs.ft_1, mf = Hs.BlockHash, Qs = [1518500249, 1859775393, 2400959708, 3395469782]; +function he() { + if (!(this instanceof he)) + return new he(); + mf.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); +} +sr.inherits(he, mf); +var Js = he; +he.blockSize = 512, he.outSize = 160, he.hmacStrength = 80, he.padLength = 64, he.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls(_i(o2, 5), js(w3, h4, p2, b3), m3, i2[n4], Qs[w3]); + m3 = b3, b3 = p2, p2 = _i(h4, 30), h4 = o2, o2 = y3; + } + this.h[0] = wr(this.h[0], o2), this.h[1] = wr(this.h[1], h4), this.h[2] = wr(this.h[2], p2), this.h[3] = wr(this.h[3], b3), this.h[4] = wr(this.h[4], m3); +}, he.prototype._digest = function(t2) { + return t2 === "hex" ? sr.toHex32(this.h, "big") : sr.split32(this.h, "big"); +}; +var ar2 = Q, Gs = fr, ur = ae, Ys = yr, ie2 = ar2.sum32, Vs = ar2.sum32_4, Ws = ar2.sum32_5, Xs = ur.ch32, Zs = ur.maj32, $s = ur.s0_256, ta = ur.s1_256, ea = ur.g0_256, ra = ur.g1_256, gf = Gs.BlockHash, ia = [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 ce() { + if (!(this instanceof ce)) + return new ce(); + gf.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia, this.W = new Array(64); +} +ar2.inherits(ce, gf); +var Af = ce; +ce.blockSize = 512, ce.outSize = 256, ce.hmacStrength = 192, ce.padLength = 64, ce.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs(ra(i2[n4 - 2]), i2[n4 - 7], ea(i2[n4 - 15]), i2[n4 - 16]); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws(S2, ta(m3), Xs(m3, w3, y3), this.k[n4], i2[n4]), N2 = ie2($s(o2), Zs(o2, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie2(b3, I2), b3 = p2, p2 = h4, h4 = o2, o2 = ie2(I2, N2); + } + this.h[0] = ie2(this.h[0], o2), this.h[1] = ie2(this.h[1], h4), this.h[2] = ie2(this.h[2], p2), this.h[3] = ie2(this.h[3], b3), this.h[4] = ie2(this.h[4], m3), this.h[5] = ie2(this.h[5], w3), this.h[6] = ie2(this.h[6], y3), this.h[7] = ie2(this.h[7], S2); +}, ce.prototype._digest = function(t2) { + return t2 === "hex" ? ar2.toHex32(this.h, "big") : ar2.split32(this.h, "big"); +}; +var Bi = Q, bf = Af; +function ye() { + if (!(this instanceof ye)) + return new ye(); + bf.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; +} +Bi.inherits(ye, bf); +var na = ye; +ye.blockSize = 512, ye.outSize = 224, ye.hmacStrength = 192, ye.padLength = 64, ye.prototype._digest = function(t2) { + return t2 === "hex" ? Bi.toHex32(this.h.slice(0, 7), "big") : Bi.split32(this.h.slice(0, 7), "big"); +}; +var jt2 = Q, fa = fr, oa = yr, le = jt2.rotr64_hi, de = jt2.rotr64_lo, yf = jt2.shr64_hi, wf = jt2.shr64_lo, Be = jt2.sum64, Ci = jt2.sum64_hi, Ri = jt2.sum64_lo, sa = jt2.sum64_4_hi, aa = jt2.sum64_4_lo, ua = jt2.sum64_5_hi, ha = jt2.sum64_5_lo, xf = fa.BlockHash, ca = [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 ne2() { + if (!(this instanceof ne2)) + return new ne2(); + xf.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca, this.W = new Array(160); +} +jt2.inherits(ne2, xf); +var Mf = ne2; +ne2.blockSize = 1024, ne2.outSize = 512, ne2.hmacStrength = 192, ne2.padLength = 128, ne2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o2 = xa(i2[n4 - 4], i2[n4 - 3]), h4 = Ma(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya(i2[n4 - 30], i2[n4 - 29]), w3 = wa(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa(o2, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa(o2, h4, p2, b3, m3, w3, y3, S2); + } +}, ne2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o2 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa(S2, I2), W2 = ba(S2, I2), Rt2 = la(S2, I2, N2, C2, F2), Yt3 = da(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H2 = ma(n4, o2), z2 = ga(n4, o2), Pt2 = pa(n4, o2, h4, p2, b3), W2 = va(n4, o2, h4, p2, b3, m3); + var d5 = Ci(H2, z2, Pt2, W2), g3 = Ri(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci(w3, y3, a3, c2), I2 = Ri(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o2, n4 = Ci(a3, c2, d5, g3), o2 = Ri(a3, c2, d5, g3); + } + Be(this.h, 0, n4, o2), Be(this.h, 2, h4, p2), Be(this.h, 4, b3, m3), Be(this.h, 6, w3, y3), Be(this.h, 8, S2, I2), Be(this.h, 10, N2, C2), Be(this.h, 12, F2, U2), Be(this.h, 14, J2, Bt2); +}, ne2.prototype._digest = function(t2) { + return t2 === "hex" ? jt2.toHex32(this.h, "big") : jt2.split32(this.h, "big"); +}; +function la(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ ~e2 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function da(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ ~t2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function pa(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function va(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function ma(e2, t2) { + var r3 = le(e2, t2, 28), i2 = le(t2, e2, 2), n4 = le(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ga(e2, t2) { + var r3 = de(e2, t2, 28), i2 = de(t2, e2, 2), n4 = de(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Aa(e2, t2) { + var r3 = le(e2, t2, 14), i2 = le(e2, t2, 18), n4 = le(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ba(e2, t2) { + var r3 = de(e2, t2, 14), i2 = de(e2, t2, 18), n4 = de(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ya(e2, t2) { + var r3 = le(e2, t2, 1), i2 = le(e2, t2, 8), n4 = yf(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function wa(e2, t2) { + var r3 = de(e2, t2, 1), i2 = de(e2, t2, 8), n4 = wf(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function xa(e2, t2) { + var r3 = le(e2, t2, 19), i2 = le(t2, e2, 29), n4 = yf(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Ma(e2, t2) { + var r3 = de(e2, t2, 19), i2 = de(t2, e2, 29), n4 = wf(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +var Oi = Q, Ef = Mf; +function we() { + if (!(this instanceof we)) + return new we(); + Ef.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; +} +Oi.inherits(we, Ef); +var Ea = we; +we.blockSize = 1024, we.outSize = 384, we.hmacStrength = 192, we.padLength = 128, we.prototype._digest = function(t2) { + return t2 === "hex" ? Oi.toHex32(this.h.slice(0, 12), "big") : Oi.split32(this.h.slice(0, 12), "big"); +}, or.sha1 = Js, or.sha224 = na, or.sha256 = Af, or.sha384 = Ea, or.sha512 = Mf; +var Sf = {}, Xe = Q, Sa = fr, Tr = Xe.rotl32, Nf = Xe.sum32, xr = Xe.sum32_3, If = Xe.sum32_4, _f = Sa.BlockHash; +function pe() { + if (!(this instanceof pe)) + return new pe(); + _f.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; +} +Xe.inherits(pe, _f), Sf.ripemd160 = pe, pe.blockSize = 512, pe.outSize = 160, pe.hmacStrength = 192, pe.padLength = 64, pe.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o2 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o2, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf(Tr(If(i2, Bf(I2, n4, o2, h4), t2[_a[I2] + r3], Na(I2)), Ca[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr(o2, 10), o2 = n4, n4 = N2, N2 = Nf(Tr(If(b3, Bf(79 - I2, m3, w3, y3), t2[Ba[I2] + r3], Ia(I2)), Ra[I2]), S2), b3 = S2, S2 = y3, y3 = Tr(w3, 10), w3 = m3, m3 = N2; + } + N2 = xr(this.h[1], o2, y3), this.h[1] = xr(this.h[2], h4, S2), this.h[2] = xr(this.h[3], p2, b3), this.h[3] = xr(this.h[4], i2, m3), this.h[4] = xr(this.h[0], n4, w3), this.h[0] = N2; +}, pe.prototype._digest = function(t2) { + return t2 === "hex" ? Xe.toHex32(this.h, "little") : Xe.split32(this.h, "little"); +}; +function Bf(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); +} +function Na(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; +} +function Ia(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; +} +var _a = [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], Ba = [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], Ca = [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], Ra = [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], Oa = Q, Pa = yr; +function hr2(e2, t2, r3) { + if (!(this instanceof hr2)) + return new hr2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa.toArray(t2, r3)); +} +var Da = hr2; +hr2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); +}, hr2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; +}, hr2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); +}, function(e2) { + var t2 = e2; + t2.utils = Q, t2.common = fr, t2.sha = or, t2.ripemd = Sf, t2.hmac = Da, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; +}(se); +function cr(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; +} +function Fa() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var Pi = Cf; +function Cf(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +Cf.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var fe = cr(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); + } + return b3; + } + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; + } + r3.zero2 = n4; + function o2(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o2, r3.encode = function(p2, b3) { + return b3 === "hex" ? o2(p2) : p2; + }; +}), Jt = cr(function(e2, t2) { + var r3 = t2; + r3.assert = Pi, r3.toArray = fe.toArray, r3.zero2 = fe.zero2, r3.toHex = fe.toHex, r3.encode = fe.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N2 = 0; N2 < y3.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N2] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N2 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o2(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o2; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K2(b3, "hex", "le"); + } + r3.intFromLE = p2; +}), Ur = Jt.getNAF, Ta = Jt.getJSF, kr = Jt.assert; +function Ce(e2, t2) { + this.type = e2, this.p = new K2(t2.p, 16), this.red = t2.prime ? K2.red(t2.prime) : K2.mont(this.p), this.zero = new K2(0).toRed(this.red), this.one = new K2(1).toRed(this.red), this.two = new K2(2).toRed(this.red), this.n = t2.n && new K2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); +} +var Ze = Ce; +Ce.prototype.point = function() { + throw new Error("Not implemented"); +}, Ce.prototype.validate = function() { + throw new Error("Not implemented"); +}, Ce.prototype._fixedNafMul = function(t2, r3) { + kr(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur(r3, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); +}, Ce.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o2 = n4.points, h4 = Ur(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o2[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o2[w3 - 1 >> 1]) : p2 = p2.add(o2[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; +}, Ce.prototype._wnafMulAdd = function(t2, r3, i2, n4, o2) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N2 = w3 - 1, C2 = w3; + if (h4[N2] !== 1 || h4[C2] !== 1) { + b3[N2] = Ur(i2[N2], h4[N2], this._bitLength), b3[C2] = Ur(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N2].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; + } + var F2 = [r3[N2], null, null, r3[C2]]; + r3[N2].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N2].add(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())) : r3[N2].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].add(r3[C2].neg())) : (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta(i2[N2], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N2] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N2][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; + } + if (w3 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o2 ? H2 : H2.toP(); +}; +function Xt(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; +} +Ce.BasePoint = Xt, Xt.prototype.eq = function() { + throw new Error("Not implemented"); +}, Xt.prototype.validate = function() { + return this.curve.validate(this); +}, Ce.prototype.decodePoint = function(t2, r3) { + t2 = Jt.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); +}, Xt.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); +}, Xt.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); +}, Xt.prototype.encode = function(t2, r3) { + return Jt.encode(this._encode(r3), t2); +}, Xt.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; +}, Xt.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; +}, Xt.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o2 = 0; o2 < r3; o2 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; +}, Xt.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r3[o2] = r3[o2 - 1].add(n4); + return { wnd: t2, points: r3 }; +}, Xt.prototype._getBeta = function() { + return null; +}, Xt.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; +}; +var Di = cr(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; +}), Ua = Jt.assert; +function Zt2(e2) { + Ze.call(this, "short", e2), this.a = new K2(e2.a, 16).toRed(this.red), this.b = new K2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +Di(Zt2, Ze); +var ka = Zt2; +Zt2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K2(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K2(p2.a, 16), b: new K2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } +}, Zt2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K2.mont(t2), i2 = new K2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o2 = new K2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o2).fromRed(), p2 = n4.redSub(o2).fromRed(); + return [h4, p2]; +}, Zt2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o2 = new K2(1), h4 = new K2(0), p2 = new K2(0), b3 = new K2(1), m3, w3, y3, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o2, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o2, o2 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m3, N2 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y3, b: S2 }, { a: I2, b: N2 }]; +}, Zt2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o2 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b3 = h4.mul(n4.a), m3 = o2.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; +}, Zt2.prototype.pointFromX = function(t2, r3) { + t2 = new K2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n4.fromRed().isOdd(); + return (r3 && !o2 || !r3 && o2) && (n4 = n4.redNeg()), this.point(t2, n4); +}, Zt2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o2 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; +}, Zt2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o2 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o2[h4 * 2] = p2.k1, o2[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o2, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o2[y3] = null; + return w3; +}; +function Ft(e2, t2, r3, i2) { + Ze.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); +} +Di(Ft, Ze.BasePoint), Zt2.prototype.point = function(t2, r3, i2) { + return new Ft(this, t2, r3, i2); +}, Zt2.prototype.pointFromJSON = function(t2, r3) { + return Ft.fromJSON(this, t2, r3); +}, Ft.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } +}, Ft.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; +}, Ft.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o2)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o2)) } }, n4; +}, Ft.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Ft.prototype.isInfinity = function() { + return this.inf; +}, Ft.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); +}, Ft.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); +}, Ft.prototype.getX = function() { + return this.x.fromRed(); +}, Ft.prototype.getY = function() { + return this.y.fromRed(); +}, Ft.prototype.mul = function(t2) { + return t2 = new K2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); +}, Ft.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2) : this.curve._wnafMulAdd(1, n4, o2, 2); +}, Ft.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2, true) : this.curve._wnafMulAdd(1, n4, o2, 2, true); +}, Ft.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); +}, Ft.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o2) { + return o2.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; +}, Ft.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; +}; +function Tt(e2, t2, r3, i2) { + Ze.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K2(0)) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), this.z = new K2(i2, 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; +} +Di(Tt, Ze.BasePoint), Zt2.prototype.jpoint = function(t2, r3, i2) { + return new Tt(this, t2, r3, i2); +}, Tt.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); +}, Tt.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}, Tt.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o2 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o2), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N2 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N2, C2); +}, Tt.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o2 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o2.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o2.redMul(w3)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); +}, Tt.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o2 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N2 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o2), b3); +}, Tt.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}, Tt.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r3 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o2 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o2)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N2, C2); +}, Tt.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h4 = o2.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o2.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N2); +}, Tt.prototype.mul = function(t2, r3) { + return t2 = new K2(t2, r3), this.curve._wnafMul(this, t2); +}, Tt.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n4)).cmpn(0) === 0; +}, Tt.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o2 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } +}, Tt.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Tt.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var qr = cr(function(e2, t2) { + var r3 = t2; + r3.base = Ze, r3.short = ka, r3.mont = null, r3.edwards = null; +}), Kr = cr(function(e2, t2) { + var r3 = t2, i2 = Jt.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr.short(p2) : p2.type === "edwards" ? this.curve = new qr.edwards(p2) : this.curve = new qr.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o2(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o2("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: se.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se.sha384, gRed: false, 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"] }), o2("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: se.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se.sha256, gRed: false, g: ["9"] }), o2("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: se.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o2("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: se.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); +}); +function Re(e2) { + if (!(this instanceof Re)) + return new Re(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe.toArray(e2.pers, e2.persEnc || "hex"); + Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); +} +var Rf = Re; +Re.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; +}, Re.prototype._hmac = function() { + return new se.hmac(this.hash, this.K); +}, Re.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); +}, Re.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe.toArray(t2, r3), i2 = fe.toArray(i2, n4), Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; +}, Re.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h4 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe.encode(h4, r3); +}; +var Fi = Jt.assert; +function kt2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); +} +var Ti = kt2; +kt2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { pub: r3, pubEnc: i2 }); +}, kt2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { priv: r3, privEnc: i2 }); +}, kt2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; +}, kt2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; +}, kt2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; +}, kt2.prototype._importPrivate = function(t2, r3) { + this.priv = new K2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); +}, kt2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); +}, kt2.prototype.derive = function(t2) { + return t2.validate() || Fi(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); +}, kt2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); +}, kt2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); +}, kt2.prototype.inspect = function() { + return ""; +}; +var qa = Jt.assert; +function Hr(e2, t2) { + if (e2 instanceof Hr) + return e2; + this._importDER(e2, t2) || (qa(e2.r && e2.s, "Signature without r or s"), this.r = new K2(e2.r, 16), this.s = new K2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); +} +var zr = Hr; +function Ka() { + this.place = 0; +} +function Ui(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o2 = 0, h4 = t2.place; o2 < i2; o2++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); +} +function Of(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); +} +Hr.prototype._importDER = function(t2, r3) { + t2 = Jt.toArray(t2, r3); + var i2 = new Ka(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui(t2, i2); + if (o2 === false) + return false; + var h4 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K2(h4), this.s = new K2(b3), this.recoveryParam = null, true; +}; +function ki(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); +} +Hr.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of(r3), i2 = Of(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki(n4, i2.length); + var o2 = n4.concat(i2), h4 = [48]; + return ki(h4, o2.length), h4 = h4.concat(o2), Jt.encode(h4, t2); +}; +var Ha = function() { + throw new Error("unsupported"); +}, Pf = Jt.assert; +function $t(e2) { + if (!(this instanceof $t)) + return new $t(e2); + typeof e2 == "string" && (Pf(Object.prototype.hasOwnProperty.call(Kr, e2), "Unknown curve " + e2), e2 = Kr[e2]), e2 instanceof Kr.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; +} +var za = $t; +$t.prototype.keyPair = function(t2) { + return new Ti(this, t2); +}, $t.prototype.keyFromPrivate = function(t2, r3) { + return Ti.fromPrivate(this, t2, r3); +}, $t.prototype.keyFromPublic = function(t2, r3) { + return Ti.fromPublic(this, t2, r3); +}, $t.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K2(2)); ; ) { + var o2 = new K2(r3.generate(i2)); + if (!(o2.cmp(n4) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } +}, $t.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; +}, $t.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K2(t2, 16)); + for (var o2 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b3 = new Rf({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N2.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr({ r: N2, s: C2, recoveryParam: F2 }); + } + } + } + } + } +}, $t.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr(r3, "hex"); + var o2 = r3.r, h4 = r3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o2).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o2)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o2) === 0); +}, $t.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr(t2, i2); + var n4 = this.n, o2 = new K2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o2).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); +}, $t.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; + } + if (o2.eq(r3)) + return n4; + } + throw new Error("Unable to find valid recovery factor"); +}; +var La = cr(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr, r3.curves = Kr, r3.ec = za, r3.eddsa = null; +}); +La.ec; +var Ff; +(function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; +})(Ff || (Ff = {})); +const go = { 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 } }; +function tr(e2, t2) { + const { message: r3, code: i2 } = go[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; +} +const emitter = new EventEmitter$1(); +let connection = void 0; +async function configureConnection(options) { + let disconnectSessions = false; + const thisVersion = pkg.version; + const prevVersion = localStorage.getItem("puzzle_sdk_version"); + if (thisVersion !== prevVersion) { + console.log( + `${pkg.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" + ); + localStorage.setItem("puzzle_sdk_version", thisVersion); + disconnectSessions = true; + } + connection = new G({ + projectId: options.projectId ?? projectId, + metadata: { + name: options.dAppName, + description: options.dAppDescription, + url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", + icons: [options.dAppIconURL] + }, + modalOptions: { ...web3modal_puzzle_props } + }); + if (disconnectSessions) { + localStorage.removeItem("puzzle-hasInjectedConnection"); + try { + disconnectOnVersionChange(connection, options.onDisconnect); + } catch (e2) { + console.error(e2); + } + } + connection.onSessionDelete(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + connection.onSessionExpire(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + if (typeof window !== "undefined") { + window.puzzleSdkConnection = connection; + } + return connection; +} +async function disconnectOnVersionChange(connection2, onDisconnect) { + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (session) { + console.log("Disconnecting session", session); + onDisconnect && onDisconnect(); + connection2.disconnect({ + topic: session.topic, + reason: tr("USER_DISCONNECTED") + }); + } +} +async function getWalletConnectModalSignClient() { + return new Promise((resolve) => { + if (connection) { + resolve(connection); + } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { + resolve(window.puzzleSdkConnection); + } else { + const interval = setInterval(() => { + if (connection) { + clearInterval(interval); + resolve(connection); + } + }, 200); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + }); +} +const checkForDesktopConnection = async (sessionTopic) => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + try { + const res = await window.aleo.puzzleWalletClient.isConnected.query( + { sessionTopic } + ); + if (res) { + localStorage.setItem("puzzle-hasInjectedConnection", "true"); + return true; + } else { + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + } catch (e2) { + console.warn(e2); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } +}; +const hasInjectedConnection = () => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + return false; + } + const puzzleHasDesktopConnection = localStorage.getItem( + "puzzle-hasInjectedConnection" + ); + return puzzleHasDesktopConnection === "true"; +}; +const getAccount = async (network) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await connection2.getSession(); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getSelectedAccount" + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getSelectedAccount.query(query); + return response; + } catch (e2) { + console.error("getAccount error", e2); + return { error: e2.message }; + } + } + try { + const response = await connection2.request(query); + return response; + } catch (e2) { + console.error("getAccount error", e2); + const error = e2.message; + return { error }; + } +}; +const getBalance = async ({ + address, + network +}) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await connection2.getSession(); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getBalance", + params: { + address + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getBalance.query(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); + return { error }; + } + } + try { + const response = await connection2.request(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); + return { error }; + } +}; +const connect = async (showModal = true) => { + const connection2 = await getWalletConnectModalSignClient(); + if (!connection2) { + throw new Error("call configureConnection() first!"); + } + const existingSession = await connection2.getSession(); + if (existingSession) { + console.log("Already connected!", existingSession); + return existingSession; + } + try { + const newSession = await connection2.connect({ + requiredNamespaces: { + aleo: { + methods: wc_aleo_methods, + chains: wc_required_aleo_chains, + events: wc_events + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains, + methods: wc_aleo_methods, + events: wc_events + } + } + }, showModal); + emitter.emit("session_change"); + if (newSession) { + await checkForDesktopConnection(newSession.topic); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + return newSession; + } catch (e2) { + console.error("connect error", e2); + } +}; +const requestCreateEvent = async (requestData, network) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { + if (typeof input === "string") { + return input; + } + return input.plaintext; + }); + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + try { + const response = await connection2.request({ + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "requestCreateEvent", + params: { + ...requestData, + inputs + } + } + }); + return response; + } catch (e2) { + console.error("createEvent error", e2); + const error = e2.message; + return { error }; + } +}; +const createSharedState = async (network) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "createSharedState", + params: {} + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.createSharedState.mutate(query); + return response; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; + return { error }; + } + } + try { + const response = await connection2.request(query); + return response; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; + return { error }; + } +}; +const decrypt = async (ciphertexts, network) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "decrypt", + params: { + ciphertexts + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.decrypt.query(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("decrypt error", e2); + return { error }; + } + } + try { + const response = await connection2.request(query); + return response; + } catch (e2) { + console.error("decrypt error", e2); + return { error: e2.message }; + } +}; +const disconnect = async () => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + try { + try { + await connection2.disconnect({ + reason: tr("USER_DISCONNECTED"), + topic: session.topic + }); + localStorage.removeItem("puzzle-hasInjectedConnection"); + emitter.emit("session_change"); + } catch (e2) { + console.warn(e2); + } + return {}; + } catch (e2) { + console.error("error disconnecting", e2); + const error = e2.message; + return { error }; + } +}; +const getEvent = async ({ + id, + address, + network +}) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { event: void 0, error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getEvent", + params: { + id, + address + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getEvent.query(query); + return response; + } catch (e2) { + console.error("getEvent error", e2); + const error = e2.message; + return { error }; + } + } + const fetchEvent = async () => { + const response = await connection2.request(query); + return response; + }; + try { + const response = await fetchEvent(); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } +}; +const getEvents = async (filter, network) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { events: void 0, error: "no session or connection" }; + } + if ((filter == null ? void 0 : filter.programId) === "") { + filter.programId = void 0; + } + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getEvents", + params: { + filter, + page: 0 + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getEvents.query(query); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } + } + const fetchPage = async (page = 0) => { + const response = await connection2.request(query); + return response; + }; + try { + const response = await fetchPage(); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } +}; +const importSharedState = async (seed, network) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "importSharedState", + params: { + seed + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.importSharedState.mutate(query); + return response; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; + return { error }; + } + } + try { + const response = await connection2.request(query); + return response; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; + return { error }; + } +}; +const getRecords = async ({ + address, + filter, + page = 0, + network +}) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getRecords", + params: { + address, + filter, + page + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getRecords.query(query); + return response; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; + return { error }; + } + } + const fetchPage = async (page2 = 0) => { + const response = await connection2.request(query); + return response; + }; + try { + const response = await fetchPage(); + return response; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; + return { error }; + } +}; +const requestSignature = async ({ + message, + address, + network, + method +}) => { + const connection2 = await getWalletConnectModalSignClient(); + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + try { + const response = await connection2.request({ + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "requestSignature", + params: { + message, + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method + } + } + }); + return response; + } catch (e2) { + console.error("signature error", e2); + const error = e2.message; + return { error }; + } +}; +const PAGE_SIZE = 20; +var browser = { exports: {} }; +var ms; +var hasRequiredMs; +function requireMs() { + if (hasRequiredMs) + return ms; + hasRequiredMs = 1; + var s2 = 1e3; + var m3 = s2 * 60; + var h4 = m3 * 60; + var d5 = h4 * 24; + var w3 = d5 * 7; + var y3 = d5 * 365.25; + ms = function(val, options) { + options = options || {}; + var type2 = typeof val; + if (type2 === "string" && val.length > 0) { + return parse(val); + } else if (type2 === "number" && isFinite(val)) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + "val is not a non-empty string or a valid number. val=" + JSON.stringify(val) + ); + }; + function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n4 = parseFloat(match[1]); + var type2 = (match[2] || "ms").toLowerCase(); + switch (type2) { + case "years": + case "year": + case "yrs": + case "yr": + case "y": + return n4 * y3; + case "weeks": + case "week": + case "w": + return n4 * w3; + case "days": + case "day": + case "d": + return n4 * d5; + case "hours": + case "hour": + case "hrs": + case "hr": + case "h": + return n4 * h4; + case "minutes": + case "minute": + case "mins": + case "min": + case "m": + return n4 * m3; + case "seconds": + case "second": + case "secs": + case "sec": + case "s": + return n4 * s2; + case "milliseconds": + case "millisecond": + case "msecs": + case "msec": + case "ms": + return n4; + default: + return void 0; + } + } + function fmtShort(ms2) { + var msAbs = Math.abs(ms2); + if (msAbs >= d5) { + return Math.round(ms2 / d5) + "d"; + } + if (msAbs >= h4) { + return Math.round(ms2 / h4) + "h"; + } + if (msAbs >= m3) { + return Math.round(ms2 / m3) + "m"; + } + if (msAbs >= s2) { + return Math.round(ms2 / s2) + "s"; + } + return ms2 + "ms"; + } + function fmtLong(ms2) { + var msAbs = Math.abs(ms2); + if (msAbs >= d5) { + return plural(ms2, msAbs, d5, "day"); + } + if (msAbs >= h4) { + return plural(ms2, msAbs, h4, "hour"); + } + if (msAbs >= m3) { + return plural(ms2, msAbs, m3, "minute"); + } + if (msAbs >= s2) { + return plural(ms2, msAbs, s2, "second"); + } + return ms2 + " ms"; + } + function plural(ms2, msAbs, n4, name2) { + var isPlural = msAbs >= n4 * 1.5; + return Math.round(ms2 / n4) + " " + name2 + (isPlural ? "s" : ""); + } + return ms; +} +function setup(env2) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce2; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = requireMs(); + createDebug.destroy = destroy; + Object.keys(env2).forEach((key) => { + createDebug[key] = env2[key]; + }); + createDebug.names = []; + createDebug.skips = []; + createDebug.formatters = {}; + function selectColor(namespace) { + let hash2 = 0; + for (let i2 = 0; i2 < namespace.length; i2++) { + hash2 = (hash2 << 5) - hash2 + namespace.charCodeAt(i2); + hash2 |= 0; + } + return createDebug.colors[Math.abs(hash2) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; + function debug2(...args) { + if (!debug2.enabled) { + return; + } + const self2 = debug2; + const curr = Number(/* @__PURE__ */ new Date()); + const ms2 = curr - (prevTime || curr); + self2.diff = ms2; + self2.prev = prevTime; + self2.curr = curr; + prevTime = curr; + args[0] = createDebug.coerce(args[0]); + if (typeof args[0] !== "string") { + args.unshift("%O"); + } + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => { + if (match === "%%") { + return "%"; + } + index++; + const formatter = createDebug.formatters[format2]; + if (typeof formatter === "function") { + const val = args[index]; + match = formatter.call(self2, val); + args.splice(index, 1); + index--; + } + return match; + }); + createDebug.formatArgs.call(self2, args); + const logFn = self2.log || createDebug.log; + logFn.apply(self2, args); + } + debug2.namespace = namespace; + debug2.useColors = createDebug.useColors(); + debug2.color = createDebug.selectColor(namespace); + debug2.extend = extend; + debug2.destroy = createDebug.destroy; + Object.defineProperty(debug2, "enabled", { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + return enabledCache; + }, + set: (v3) => { + enableOverride = v3; + } + }); + if (typeof createDebug.init === "function") { + createDebug.init(debug2); + } + return debug2; + } + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; + createDebug.names = []; + createDebug.skips = []; + let i2; + const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); + const len = split.length; + for (i2 = 0; i2 < len; i2++) { + if (!split[i2]) { + continue; + } + namespaces = split[i2].replace(/\*/g, ".*?"); + if (namespaces[0] === "-") { + createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")); + } else { + createDebug.names.push(new RegExp("^" + namespaces + "$")); + } + } + } + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace) + ].join(","); + createDebug.enable(""); + return namespaces; + } + function enabled(name2) { + if (name2[name2.length - 1] === "*") { + return true; + } + let i2; + let len; + for (i2 = 0, len = createDebug.skips.length; i2 < len; i2++) { + if (createDebug.skips[i2].test(name2)) { + return false; + } + } + for (i2 = 0, len = createDebug.names.length; i2 < len; i2++) { + if (createDebug.names[i2].test(name2)) { + return true; + } + } + return false; + } + function toNamespace(regexp) { + return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*"); + } + function coerce2(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } + function destroy() { + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + createDebug.enable(createDebug.load()); + return createDebug; +} +var common = setup; +(function(module2, exports2) { + exports2.formatArgs = formatArgs; + exports2.save = save; + exports2.load = load; + exports2.useColors = useColors; + exports2.storage = localstorage(); + exports2.destroy = /* @__PURE__ */ (() => { + let warned = false; + return () => { + if (!warned) { + warned = true; + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + }; + })(); + exports2.colors = [ + "#0000CC", + "#0000FF", + "#0033CC", + "#0033FF", + "#0066CC", + "#0066FF", + "#0099CC", + "#0099FF", + "#00CC00", + "#00CC33", + "#00CC66", + "#00CC99", + "#00CCCC", + "#00CCFF", + "#3300CC", + "#3300FF", + "#3333CC", + "#3333FF", + "#3366CC", + "#3366FF", + "#3399CC", + "#3399FF", + "#33CC00", + "#33CC33", + "#33CC66", + "#33CC99", + "#33CCCC", + "#33CCFF", + "#6600CC", + "#6600FF", + "#6633CC", + "#6633FF", + "#66CC00", + "#66CC33", + "#9900CC", + "#9900FF", + "#9933CC", + "#9933FF", + "#99CC00", + "#99CC33", + "#CC0000", + "#CC0033", + "#CC0066", + "#CC0099", + "#CC00CC", + "#CC00FF", + "#CC3300", + "#CC3333", + "#CC3366", + "#CC3399", + "#CC33CC", + "#CC33FF", + "#CC6600", + "#CC6633", + "#CC9900", + "#CC9933", + "#CCCC00", + "#CCCC33", + "#FF0000", + "#FF0033", + "#FF0066", + "#FF0099", + "#FF00CC", + "#FF00FF", + "#FF3300", + "#FF3333", + "#FF3366", + "#FF3399", + "#FF33CC", + "#FF33FF", + "#FF6600", + "#FF6633", + "#FF9900", + "#FF9933", + "#FFCC00", + "#FFCC33" + ]; + function useColors() { + if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) { + return true; + } + if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 + typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker + typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); + } + function formatArgs(args) { + args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff); + if (!this.useColors) { + return; + } + const c2 = "color: " + this.color; + args.splice(1, 0, c2, "color: inherit"); + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, (match) => { + if (match === "%%") { + return; + } + index++; + if (match === "%c") { + lastC = index; + } + }); + args.splice(lastC, 0, c2); + } + exports2.log = console.debug || console.log || (() => { + }); + function save(namespaces) { + try { + if (namespaces) { + exports2.storage.setItem("debug", namespaces); + } else { + exports2.storage.removeItem("debug"); + } + } catch (error) { + } + } + function load() { + let r3; + try { + r3 = exports2.storage.getItem("debug"); + } catch (error) { + } + if (!r3 && typeof process !== "undefined" && "env" in process) { + r3 = process.env.DEBUG; + } + return r3; + } + function localstorage() { + try { + return localStorage; + } catch (error) { + } + } + module2.exports = common(exports2); + const { formatters } = module2.exports; + formatters.j = function(v3) { + try { + return JSON.stringify(v3); + } catch (error) { + return "[UnexpectedJSONParseError]: " + error.message; + } + }; +})(browser, browser.exports); +var browserExports = browser.exports; +const debug = /* @__PURE__ */ getDefaultExportFromCjs(browserExports); +const log_sdk = debug("wallet:sdk"); +log_sdk.enabled = true; +export { + signClient_puzzleProps as $, + getAccount as A, + getBalance as B, + connect as C, + requestCreateEvent as D, + EventStatus as E, + createSharedState as F, + decrypt as G, + disconnect as H, + getEvent as I, + getEvents as J, + importSharedState as K, + getRecords as L, + requestSignature as M, + Network as N, + wc_aleo_methods as O, + PAGE_SIZE as P, + wc_required_aleo_chains as Q, + R$1 as R, + wc_optional_aleo_chains as S, + T$2 as T, + wc_aleo_chains as U, + Visibility as V, + wc_events as W, + projectId as X, + web3modal_puzzle_props_android as Y, + web3modal_puzzle_props_default as Z, + web3modal_puzzle_props as _, + EventType as a, + networkToChainId as a0, + chainIdToNetwork as a1, + log_sdk as a2, + checkForDesktopConnection as a3, + hasInjectedConnection as a4, + emitter as a5, + connection as a6, + configureConnection as a7, + getWalletConnectModalSignClient as a8, + aleoAddressRegex as b, + aleoFieldRegex as c, + aleoPrivateKeyRegex as d, + aleoTransactionIdRegex as e, + aleoU32 as f, + aleoU64 as g, + aleoViewKeyRegex as h, + i$1 as i, + zodEventStatus as j, + zodEventType as k, + zodField as l, + zodNetwork as m, + ne$3 as n, + oe$2 as o, + p$2 as p, + zodPrivateKey as q, + zodTransactionId as r, + se$3 as s, + te$1 as t, + zodU32 as u, + zodU64 as v, + zodViewKey as w, + zodVisibility as x, + y$4 as y, + zodAddress as z +}; diff --git a/packages/core/dist/index-DeMTjw2J.cjs b/packages/core/dist/index-CBnMNmep.cjs similarity index 64% rename from packages/core/dist/index-DeMTjw2J.cjs rename to packages/core/dist/index-CBnMNmep.cjs index d2fcad59..afe9ac8f 100644 --- a/packages/core/dist/index-DeMTjw2J.cjs +++ b/packages/core/dist/index-CBnMNmep.cjs @@ -1,24 +1,24 @@ "use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); -const index = require("./index-rLSm9-3e.cjs"); +const index = require("./index-Cc7iYKrS.cjs"); /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$3 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); +const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$4 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); let o$4 = class o { constructor(t2, e2, n2) { - if (this._$cssResult$ = true, n2 !== s$3) + if (this._$cssResult$ = true, n2 !== s$4) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t2, this.t = e2; } get styleSheet() { let t2 = this.o; - const s2 = this.t; + const s3 = this.t; if (e$5 && void 0 === t2) { - const e2 = void 0 !== s2 && 1 === s2.length; - e2 && (t2 = n$5.get(s2)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s2, t2)); + const e2 = void 0 !== s3 && 1 === s3.length; + e2 && (t2 = n$5.get(s3)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s3, t2)); } return t2; } @@ -26,24 +26,24 @@ let o$4 = class o { return this.cssText; } }; -const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), i$3 = (t2, ...e2) => { - const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s2, n3) => e3 + ((t3) => { +const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$4), i$3 = (t2, ...e2) => { + const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s3, n3) => e3 + ((t3) => { if (true === t3._$cssResult$) return t3.cssText; if ("number" == typeof t3) return t3; throw Error("Value passed to 'css' function must be a 'css' function result: " + t3 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); - })(s2) + t2[n3 + 1], t2[0]); - return new o$4(n2, t2, s$3); -}, S$2 = (s2, n2) => { - e$5 ? s2.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { + })(s3) + t2[n3 + 1], t2[0]); + return new o$4(n2, t2, s$4); +}, S$2 = (s3, n2) => { + e$5 ? s3.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { const n3 = document.createElement("style"), o3 = t$3.litNonce; - void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s2.appendChild(n3); + void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s3.appendChild(n3); }); -}, c$2 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { +}, c$1 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { let e2 = ""; - for (const s2 of t3.cssRules) - e2 += s2.cssText; + for (const s3 of t3.cssRules) + e2 += s3.cssText; return r$2(e2); })(t2) : t2; /** @@ -51,7 +51,7 @@ const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -var s$2; +var s$3; const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$3 = e$4.reactiveElementPolyfillSupport, n$4 = { toAttribute(t2, i2) { switch (i2) { case Boolean: @@ -63,23 +63,23 @@ const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$ } return t2; }, fromAttribute(t2, i2) { - let s2 = t2; + let s3 = t2; switch (i2) { case Boolean: - s2 = null !== t2; + s3 = null !== t2; break; case Number: - s2 = null === t2 ? null : Number(t2); + s3 = null === t2 ? null : Number(t2); break; case Object: case Array: try { - s2 = JSON.parse(t2); + s3 = JSON.parse(t2); } catch (t3) { - s2 = null; + s3 = null; } } - return s2; + return s3; } }, a$1 = (t2, i2) => i2 !== t2 && (i2 == i2 || t2 == t2), l$3 = { attribute: true, type: String, converter: n$4, reflect: false, hasChanged: a$1 }, d$1 = "finalized"; let u$1 = class u extends HTMLElement { constructor() { @@ -92,23 +92,23 @@ let u$1 = class u extends HTMLElement { static get observedAttributes() { this.finalize(); const t2 = []; - return this.elementProperties.forEach((i2, s2) => { - const e2 = this._$Ep(s2, i2); - void 0 !== e2 && (this._$Ev.set(e2, s2), t2.push(e2)); + return this.elementProperties.forEach((i2, s3) => { + const e2 = this._$Ep(s3, i2); + void 0 !== e2 && (this._$Ev.set(e2, s3), t2.push(e2)); }), t2; } static createProperty(t2, i2 = l$3) { if (i2.state && (i2.attribute = false), this.finalize(), this.elementProperties.set(t2, i2), !i2.noAccessor && !this.prototype.hasOwnProperty(t2)) { - const s2 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s2, i2); + const s3 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s3, i2); void 0 !== e2 && Object.defineProperty(this.prototype, t2, e2); } } - static getPropertyDescriptor(t2, i2, s2) { + static getPropertyDescriptor(t2, i2, s3) { return { get() { return this[i2]; }, set(e2) { const r2 = this[t2]; - this[i2] = e2, this.requestUpdate(t2, r2, s2); + this[i2] = e2, this.requestUpdate(t2, r2, s3); }, configurable: true, enumerable: true }; } static getPropertyOptions(t2) { @@ -121,32 +121,32 @@ let u$1 = class u extends HTMLElement { const t2 = Object.getPrototypeOf(this); if (t2.finalize(), void 0 !== t2.h && (this.h = [...t2.h]), this.elementProperties = new Map(t2.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { const t3 = this.properties, i2 = [...Object.getOwnPropertyNames(t3), ...Object.getOwnPropertySymbols(t3)]; - for (const s2 of i2) - this.createProperty(s2, t3[s2]); + for (const s3 of i2) + this.createProperty(s3, t3[s3]); } return this.elementStyles = this.finalizeStyles(this.styles), true; } static finalizeStyles(i2) { - const s2 = []; + const s3 = []; if (Array.isArray(i2)) { const e2 = new Set(i2.flat(1 / 0).reverse()); for (const i3 of e2) - s2.unshift(c$2(i3)); + s3.unshift(c$1(i3)); } else - void 0 !== i2 && s2.push(c$2(i2)); - return s2; + void 0 !== i2 && s3.push(c$1(i2)); + return s3; } static _$Ep(t2, i2) { - const s2 = i2.attribute; - return false === s2 ? void 0 : "string" == typeof s2 ? s2 : "string" == typeof t2 ? t2.toLowerCase() : void 0; + const s3 = i2.attribute; + return false === s3 ? void 0 : "string" == typeof s3 ? s3 : "string" == typeof t2 ? t2.toLowerCase() : void 0; } _$Eu() { var t2; this._$E_ = new Promise((t3) => this.enableUpdating = t3), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t2 = this.constructor.h) || void 0 === t2 || t2.forEach((t3) => t3(this)); } addController(t2) { - var i2, s2; - (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s2 = t2.hostConnected) || void 0 === s2 || s2.call(t2)); + var i2, s3; + (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s3 = t2.hostConnected) || void 0 === s3 || s3.call(t2)); } removeController(t2) { var i2; @@ -159,8 +159,8 @@ let u$1 = class u extends HTMLElement { } createRenderRoot() { var t2; - const s2 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); - return S$2(s2, this.constructor.elementStyles), s2; + const s3 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); + return S$2(s3, this.constructor.elementStyles), s3; } connectedCallback() { var t2; @@ -178,28 +178,28 @@ let u$1 = class u extends HTMLElement { return null === (i2 = t3.hostDisconnected) || void 0 === i2 ? void 0 : i2.call(t3); }); } - attributeChangedCallback(t2, i2, s2) { - this._$AK(t2, s2); + attributeChangedCallback(t2, i2, s3) { + this._$AK(t2, s3); } - _$EO(t2, i2, s2 = l$3) { + _$EO(t2, i2, s3 = l$3) { var e2; - const r2 = this.constructor._$Ep(t2, s2); - if (void 0 !== r2 && true === s2.reflect) { - const h2 = (void 0 !== (null === (e2 = s2.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s2.converter : n$4).toAttribute(i2, s2.type); + const r2 = this.constructor._$Ep(t2, s3); + if (void 0 !== r2 && true === s3.reflect) { + const h2 = (void 0 !== (null === (e2 = s3.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s3.converter : n$4).toAttribute(i2, s3.type); this._$El = t2, null == h2 ? this.removeAttribute(r2) : this.setAttribute(r2, h2), this._$El = null; } } _$AK(t2, i2) { - var s2; + var s3; const e2 = this.constructor, r2 = e2._$Ev.get(t2); if (void 0 !== r2 && this._$El !== r2) { - const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s2 = t3.converter) || void 0 === s2 ? void 0 : s2.fromAttribute) ? t3.converter : n$4; + const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s3 = t3.converter) || void 0 === s3 ? void 0 : s3.fromAttribute) ? t3.converter : n$4; this._$El = r2, this[r2] = h2.fromAttribute(i2, t3.type), this._$El = null; } } - requestUpdate(t2, i2, s2) { + requestUpdate(t2, i2, s3) { let e2 = true; - void 0 !== t2 && (((s2 = s2 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s2.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s2))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); + void 0 !== t2 && (((s3 = s3 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s3.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s3))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); } async _$Ej() { this.isUpdatePending = true; @@ -220,16 +220,16 @@ let u$1 = class u extends HTMLElement { return; this.hasUpdated, this._$Ei && (this._$Ei.forEach((t3, i3) => this[i3] = t3), this._$Ei = void 0); let i2 = false; - const s2 = this._$AL; + const s3 = this._$AL; try { - i2 = this.shouldUpdate(s2), i2 ? (this.willUpdate(s2), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { + i2 = this.shouldUpdate(s3), i2 ? (this.willUpdate(s3), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { var i3; return null === (i3 = t3.hostUpdate) || void 0 === i3 ? void 0 : i3.call(t3); - }), this.update(s2)) : this._$Ek(); + }), this.update(s3)) : this._$Ek(); } catch (t3) { throw i2 = false, this._$Ek(), t3; } - i2 && this._$AE(s2); + i2 && this._$AE(s3); } willUpdate(t2) { } @@ -260,34 +260,34 @@ let u$1 = class u extends HTMLElement { firstUpdated(t2) { } }; -u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$2 = e$4.reactiveElementVersions) && void 0 !== s$2 ? s$2 : e$4.reactiveElementVersions = []).push("1.6.3"); +u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$3 = e$4.reactiveElementVersions) && void 0 !== s$3 ? s$3 : e$4.reactiveElementVersions = []).push("1.6.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var t$2; -const i$2 = window, s$1 = i$2.trustedTypes, e$3 = s$1 ? s$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c$1 = Array.isArray, v$1 = (t2) => c$1(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), b = w(2), T$1 = Symbol.for("lit-noChange"), A$1 = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); -function P(t2, i2) { +const i$2 = window, s$2 = i$2.trustedTypes, e$3 = s$2 ? s$2.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s3) => ({ _$litType$: t2, strings: i2, values: s3 }), x = w(1), b$1 = w(2), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); +function P$1(t2, i2) { if (!Array.isArray(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array"); return void 0 !== e$3 ? e$3.createHTML(i2) : i2; } const V = (t2, i2) => { - const s2 = t2.length - 1, e2 = []; + const s3 = t2.length - 1, e2 = []; let l2, r2 = 2 === i2 ? "" : "", u3 = f; - for (let i3 = 0; i3 < s2; i3++) { - const s3 = t2[i3]; + for (let i3 = 0; i3 < s3; i3++) { + const s4 = t2[i3]; let d2, c2, v2 = -1, a2 = 0; - for (; a2 < s3.length && (u3.lastIndex = a2, c2 = u3.exec(s3), null !== c2); ) + for (; a2 < s4.length && (u3.lastIndex = a2, c2 = u3.exec(s4), null !== c2); ) a2 = u3.lastIndex, u3 === f ? "!--" === c2[1] ? u3 = _$1 : void 0 !== c2[1] ? u3 = m : void 0 !== c2[2] ? (y.test(c2[2]) && (l2 = RegExp("" === c2[0] ? (u3 = null != l2 ? l2 : f, v2 = -1) : void 0 === c2[1] ? v2 = -2 : (v2 = u3.lastIndex - c2[2].length, d2 = c2[1], u3 = void 0 === c2[3] ? p : '"' === c2[3] ? $ : g) : u3 === $ || u3 === g ? u3 = p : u3 === _$1 || u3 === m ? u3 = f : (u3 = p, l2 = void 0); const w2 = u3 === p && t2[i3 + 1].startsWith("/>") ? " " : ""; - r2 += u3 === f ? s3 + h$1 : v2 >= 0 ? (e2.push(d2), s3.slice(0, v2) + o$2 + s3.slice(v2) + n$3 + w2) : s3 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); + r2 += u3 === f ? s4 + h$1 : v2 >= 0 ? (e2.push(d2), s4.slice(0, v2) + o$2 + s4.slice(v2) + n$3 + w2) : s4 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); } - return [P(t2, r2 + (t2[s2] || "") + (2 === i2 ? "" : "")), e2]; + return [P$1(t2, r2 + (t2[s3] || "") + (2 === i2 ? "" : "")), e2]; }; -class N { +let N$1 = class N { constructor({ strings: t2, _$litType$: i2 }, e2) { let h2; this.parts = []; @@ -303,10 +303,10 @@ class N { const t3 = []; for (const i3 of h2.getAttributeNames()) if (i3.endsWith(o$2) || i3.startsWith(n$3)) { - const s2 = f2[d2++]; - if (t3.push(i3), void 0 !== s2) { - const t4 = h2.getAttribute(s2.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s2); - v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); + const s3 = f2[d2++]; + if (t3.push(i3), void 0 !== s3) { + const t4 = h2.getAttribute(s3.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s3); + v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H$1 : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); } else v2.push({ type: 6, index: r2 }); } @@ -316,9 +316,9 @@ class N { if (y.test(h2.tagName)) { const t3 = h2.textContent.split(n$3), i3 = t3.length - 1; if (i3 > 0) { - h2.textContent = s$1 ? s$1.emptyScript : ""; - for (let s2 = 0; s2 < i3; s2++) - h2.append(t3[s2], u2()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); + h2.textContent = s$2 ? s$2.emptyScript : ""; + for (let s3 = 0; s3 < i3; s3++) + h2.append(t3[s3], u2()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); h2.append(t3[i3], u2()); } } @@ -334,17 +334,17 @@ class N { } } static createElement(t2, i2) { - const s2 = r.createElement("template"); - return s2.innerHTML = t2, s2; + const s3 = r.createElement("template"); + return s3.innerHTML = t2, s3; } -} -function S$1(t2, i2, s2 = t2, e2) { +}; +function S$1(t2, i2, s3 = t2, e2) { var o3, n2, l2, h2; - if (i2 === T$1) + if (i2 === T) return i2; - let r2 = void 0 !== e2 ? null === (o3 = s2._$Co) || void 0 === o3 ? void 0 : o3[e2] : s2._$Cl; + let r2 = void 0 !== e2 ? null === (o3 = s3._$Co) || void 0 === o3 ? void 0 : o3[e2] : s3._$Cl; const u3 = d(i2) ? void 0 : i2._$litDirective$; - return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s2, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s2)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s2._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; + return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s3, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s3)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s3._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; } class M { constructor(t2, i2) { @@ -358,7 +358,7 @@ class M { } u(t2) { var i2; - const { el: { content: s2 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s2, true); + const { el: { content: s3 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s3, true); C.currentNode = o3; let n2 = C.nextNode(), l2 = 0, h2 = 0, u3 = e2[0]; for (; void 0 !== u3; ) { @@ -372,14 +372,14 @@ class M { } v(t2) { let i2 = 0; - for (const s2 of this._$AV) - void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++; + for (const s3 of this._$AV) + void 0 !== s3 && (void 0 !== s3.strings ? (s3._$AI(t2, s3, i2), i2 += s3.strings.length - 2) : s3._$AI(t2[i2])), i2++; } } class R { - constructor(t2, i2, s2, e2) { + constructor(t2, i2, s3, e2) { var o3; - this.type = 2, this._$AH = A$1, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; + this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s3, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; } get _$AU() { var t2, i2; @@ -397,7 +397,7 @@ class R { return this._$AB; } _$AI(t2, i2 = this) { - t2 = S$1(this, t2, i2), d(t2) ? t2 === A$1 || null == t2 || "" === t2 ? (this._$AH !== A$1 && this._$AR(), this._$AH = A$1) : t2 !== this._$AH && t2 !== T$1 && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v$1(t2) ? this.T(t2) : this._(t2); + t2 = S$1(this, t2, i2), d(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v(t2) ? this.T(t2) : this._(t2); } k(t2) { return this._$AA.parentNode.insertBefore(t2, this._$AB); @@ -406,33 +406,33 @@ class R { this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2)); } _(t2) { - this._$AH !== A$1 && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; + this._$AH !== A && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; } g(t2) { var i2; - const { values: s2, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N.createElement(P(e2.h, e2.h[0]), this.options)), e2); + const { values: s3, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N$1.createElement(P$1(e2.h, e2.h[0]), this.options)), e2); if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o3) - this._$AH.v(s2); + this._$AH.v(s3); else { const t3 = new M(o3, this), i3 = t3.u(this.options); - t3.v(s2), this.$(i3), this._$AH = t3; + t3.v(s3), this.$(i3), this._$AH = t3; } } _$AC(t2) { let i2 = E.get(t2.strings); - return void 0 === i2 && E.set(t2.strings, i2 = new N(t2)), i2; + return void 0 === i2 && E.set(t2.strings, i2 = new N$1(t2)), i2; } T(t2) { - c$1(this._$AH) || (this._$AH = [], this._$AR()); + c(this._$AH) || (this._$AH = [], this._$AR()); const i2 = this._$AH; - let s2, e2 = 0; + let s3, e2 = 0; for (const o3 of t2) - e2 === i2.length ? i2.push(s2 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s2 = i2[e2], s2._$AI(o3), e2++; - e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2); + e2 === i2.length ? i2.push(s3 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s3 = i2[e2], s3._$AI(o3), e2++; + e2 < i2.length && (this._$AR(s3 && s3._$AB.nextSibling, e2), i2.length = e2); } _$AR(t2 = this._$AA.nextSibling, i2) { - var s2; - for (null === (s2 = this._$AP) || void 0 === s2 || s2.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { + var s3; + for (null === (s3 = this._$AP) || void 0 === s3 || s3.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { const i3 = t2.nextSibling; t2.remove(), t2 = i3; } @@ -443,8 +443,8 @@ class R { } } class k { - constructor(t2, i2, s2, e2, o3) { - this.type = 1, this._$AH = A$1, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = A$1; + constructor(t2, i2, s3, e2, o3) { + this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s3.length > 2 || "" !== s3[0] || "" !== s3[1] ? (this._$AH = Array(s3.length - 1).fill(new String()), this.strings = s3) : this._$AH = A; } get tagName() { return this.element.tagName; @@ -452,59 +452,59 @@ class k { get _$AU() { return this._$AM._$AU; } - _$AI(t2, i2 = this, s2, e2) { + _$AI(t2, i2 = this, s3, e2) { const o3 = this.strings; let n2 = false; if (void 0 === o3) - t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T$1, n2 && (this._$AH = t2); + t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T, n2 && (this._$AH = t2); else { const e3 = t2; let l2, h2; for (t2 = o3[0], l2 = 0; l2 < o3.length - 1; l2++) - h2 = S$1(this, e3[s2 + l2], i2, l2), h2 === T$1 && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A$1 ? t2 = A$1 : t2 !== A$1 && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; + h2 = S$1(this, e3[s3 + l2], i2, l2), h2 === T && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A ? t2 = A : t2 !== A && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; } n2 && !e2 && this.j(t2); } j(t2) { - t2 === A$1 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); + t2 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); } } -class H extends k { +let H$1 = class H extends k { constructor() { super(...arguments), this.type = 3; } j(t2) { - this.element[this.name] = t2 === A$1 ? void 0 : t2; + this.element[this.name] = t2 === A ? void 0 : t2; } -} -const I = s$1 ? s$1.emptyScript : ""; +}; +const I = s$2 ? s$2.emptyScript : ""; let L$1 = class L extends k { constructor() { super(...arguments), this.type = 4; } j(t2) { - t2 && t2 !== A$1 ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); + t2 && t2 !== A ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); } }; class z extends k { - constructor(t2, i2, s2, e2, o3) { - super(t2, i2, s2, e2, o3), this.type = 5; + constructor(t2, i2, s3, e2, o3) { + super(t2, i2, s3, e2, o3), this.type = 5; } _$AI(t2, i2 = this) { - var s2; - if ((t2 = null !== (s2 = S$1(this, t2, i2, 0)) && void 0 !== s2 ? s2 : A$1) === T$1) + var s3; + if ((t2 = null !== (s3 = S$1(this, t2, i2, 0)) && void 0 !== s3 ? s3 : A) === T) return; - const e2 = this._$AH, o3 = t2 === A$1 && e2 !== A$1 || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A$1 && (e2 === A$1 || o3); + const e2 = this._$AH, o3 = t2 === A && e2 !== A || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A && (e2 === A || o3); o3 && this.element.removeEventListener(this.name, this, e2), n2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2; } handleEvent(t2) { - var i2, s2; - "function" == typeof this._$AH ? this._$AH.call(null !== (s2 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s2 ? s2 : this.element, t2) : this._$AH.handleEvent(t2); + var i2, s3; + "function" == typeof this._$AH ? this._$AH.call(null !== (s3 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s3 ? s3 : this.element, t2) : this._$AH.handleEvent(t2); } } let Z$1 = class Z { - constructor(t2, i2, s2) { - this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s2; + constructor(t2, i2, s3) { + this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s3; } get _$AU() { return this._$AM._$AU; @@ -514,14 +514,14 @@ let Z$1 = class Z { } }; const B$1 = i$2.litHtmlPolyfillSupport; -null == B$1 || B$1(N, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); -const D$1 = (t2, i2, s2) => { +null == B$1 || B$1(N$1, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); +const D = (t2, i2, s3) => { var e2, o3; - const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2; + const n2 = null !== (e2 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== e2 ? e2 : i2; let l2 = n2._$litPart$; if (void 0 === l2) { - const t3 = null !== (o3 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== o3 ? o3 : null; - n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s2 ? s2 : {}); + const t3 = null !== (o3 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== o3 ? o3 : null; + n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s3 ? s3 : {}); } return l2._$AI(t2), l2; }; @@ -531,7 +531,7 @@ const D$1 = (t2, i2, s2) => { * SPDX-License-Identifier: BSD-3-Clause */ var l$1, o$1; -class s extends u$1 { +let s$1 = class s extends u$1 { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } @@ -542,7 +542,7 @@ class s extends u$1 { } update(t2) { const i2 = this.render(); - this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t2), this._$Do = D$1(i2, this.renderRoot, this.renderOptions); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t2), this._$Do = D(i2, this.renderRoot, this.renderOptions); } connectedCallback() { var t2; @@ -553,12 +553,12 @@ class s extends u$1 { super.disconnectedCallback(), null === (t2 = this._$Do) || void 0 === t2 || t2.setConnected(false); } render() { - return T$1; + return T; } -} -s.finalized = true, s._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s }); +}; +s$1.finalized = true, s$1._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s$1 }); const n$2 = globalThis.litElementPolyfillSupport; -null == n$2 || n$2({ LitElement: s }); +null == n$2 || n$2({ LitElement: s$1 }); (null !== (o$1 = globalThis.litElementVersions) && void 0 !== o$1 ? o$1 : globalThis.litElementVersions = []).push("3.3.3"); /** * @license @@ -566,8 +566,8 @@ null == n$2 || n$2({ LitElement: s }); * SPDX-License-Identifier: BSD-3-Clause */ const e$2 = (e2) => (n2) => "function" == typeof n2 ? ((e3, n3) => (customElements.define(e3, n3), n3))(e2, n2) : ((e3, n3) => { - const { kind: t2, elements: s2 } = n3; - return { kind: t2, elements: s2, finisher(n4) { + const { kind: t2, elements: s3 } = n3; + return { kind: t2, elements: s3, finisher(n4) { customElements.define(e3, n4); } }; })(e2, n2); @@ -639,23 +639,23 @@ const o2 = e(class extends i { render(t2) { return " " + Object.keys(t2).filter((i2) => t2[i2]).join(" ") + " "; } - update(i2, [s2]) { + update(i2, [s3]) { var r2, o3; if (void 0 === this.it) { this.it = /* @__PURE__ */ new Set(), void 0 !== i2.strings && (this.nt = new Set(i2.strings.join(" ").split(/\s/).filter((t2) => "" !== t2))); - for (const t2 in s2) - s2[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); - return this.render(s2); + for (const t2 in s3) + s3[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); + return this.render(s3); } const e2 = i2.element.classList; this.it.forEach((t2) => { - t2 in s2 || (e2.remove(t2), this.it.delete(t2)); + t2 in s3 || (e2.remove(t2), this.it.delete(t2)); }); - for (const t2 in s2) { - const i3 = !!s2[t2]; + for (const t2 in s3) { + const i3 = !!s3[t2]; i3 === this.it.has(t2) || (null === (o3 = this.nt) || void 0 === o3 ? void 0 : o3.has(t2)) || (i3 ? (e2.add(t2), this.it.add(t2)) : (e2.remove(t2), this.it.delete(t2))); } - return T$1; + return T; } }); function addUniqueItem(array, item) { @@ -1215,12 +1215,8 @@ const getOptions = (options, key) => ( options[key] ? Object.assign(Object.assign({}, options), options[key]) : Object.assign({}, options) ); function resolveElements(elements, selectorCache) { - var _a; if (typeof elements === "string") { - if (selectorCache) { - (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : selectorCache[elements] = document.querySelectorAll(elements); - elements = selectorCache[elements]; - } else { + { elements = document.querySelectorAll(elements); } } else if (elements instanceof Element) { @@ -1334,7 +1330,7 @@ function animate(target, keyframesOrOptions, options) { * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const l = (l2) => null != l2 ? l2 : A$1; +const l = (l2) => null != l2 ? l2 : A; var browser = {}; var canPromise$1 = function() { return typeof Promise === "function" && Promise.prototype && Promise.prototype.then; @@ -1532,13 +1528,13 @@ var alignmentPattern = {}; const pos = exports2.getRowColCoords(version2); const posLength = pos.length; for (let i2 = 0; i2 < posLength; i2++) { - for (let j2 = 0; j2 < posLength; j2++) { - if (i2 === 0 && j2 === 0 || // top-left - i2 === 0 && j2 === posLength - 1 || // bottom-left - i2 === posLength - 1 && j2 === 0) { + for (let j = 0; j < posLength; j++) { + if (i2 === 0 && j === 0 || // top-left + i2 === 0 && j === posLength - 1 || // bottom-left + i2 === posLength - 1 && j === 0) { continue; } - coords.push([pos[i2], pos[j2]]); + coords.push([pos[i2], pos[j]]); } } return coords; @@ -1657,24 +1653,24 @@ var maskPattern = {}; const k2 = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10); return k2 * PenaltyScores.N4; }; - function getMaskAt(maskPattern2, i2, j2) { + function getMaskAt(maskPattern2, i2, j) { switch (maskPattern2) { case exports2.Patterns.PATTERN000: - return (i2 + j2) % 2 === 0; + return (i2 + j) % 2 === 0; case exports2.Patterns.PATTERN001: return i2 % 2 === 0; case exports2.Patterns.PATTERN010: - return j2 % 3 === 0; + return j % 3 === 0; case exports2.Patterns.PATTERN011: - return (i2 + j2) % 3 === 0; + return (i2 + j) % 3 === 0; case exports2.Patterns.PATTERN100: - return (Math.floor(i2 / 2) + Math.floor(j2 / 3)) % 2 === 0; + return (Math.floor(i2 / 2) + Math.floor(j / 3)) % 2 === 0; case exports2.Patterns.PATTERN101: - return i2 * j2 % 2 + i2 * j2 % 3 === 0; + return i2 * j % 2 + i2 * j % 3 === 0; case exports2.Patterns.PATTERN110: - return (i2 * j2 % 2 + i2 * j2 % 3) % 2 === 0; + return (i2 * j % 2 + i2 * j % 3) % 2 === 0; case exports2.Patterns.PATTERN111: - return (i2 * j2 % 3 + (i2 + j2) % 2) % 2 === 0; + return (i2 * j % 3 + (i2 + j) % 2) % 2 === 0; default: throw new Error("bad maskPattern:" + maskPattern2); } @@ -2098,8 +2094,8 @@ galoisField.mul = function mul(x2, y2) { exports2.mul = function mul2(p1, p2) { const coeff = new Uint8Array(p1.length + p2.length - 1); for (let i2 = 0; i2 < p1.length; i2++) { - for (let j2 = 0; j2 < p2.length; j2++) { - coeff[i2 + j2] ^= GF.mul(p1[i2], p2[j2]); + for (let j = 0; j < p2.length; j++) { + coeff[i2 + j] ^= GF.mul(p1[i2], p2[j]); } } return coeff; @@ -2574,12 +2570,12 @@ var kanjiData = KanjiData; var dijkstra = { exports: {} }; (function(module2) { var dijkstra2 = { - single_source_shortest_paths: function(graph, s2, d2) { + single_source_shortest_paths: function(graph, s3, d2) { var predecessors = {}; var costs = {}; - costs[s2] = 0; + costs[s3] = 0; var open = dijkstra2.PriorityQueue.make(); - open.push(s2, 0); + open.push(s3, 0); var closest, u3, v2, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; while (!open.empty()) { closest = open.pop(); @@ -2601,7 +2597,7 @@ var dijkstra = { exports: {} }; } } if (typeof d2 !== "undefined" && typeof costs[d2] === "undefined") { - var msg = ["Could not find a path from ", s2, " to ", d2, "."].join(""); + var msg = ["Could not find a path from ", s3, " to ", d2, "."].join(""); throw new Error(msg); } return predecessors; @@ -2617,8 +2613,8 @@ var dijkstra = { exports: {} }; nodes.reverse(); return nodes; }, - find_path: function(graph, s2, d2) { - var predecessors = dijkstra2.single_source_shortest_paths(graph, s2, d2); + find_path: function(graph, s3, d2) { + var predecessors = dijkstra2.single_source_shortest_paths(graph, s3, d2); return dijkstra2.extract_shortest_path_from_predecessor_list( predecessors, d2 @@ -2706,8 +2702,8 @@ var dijkstraExports = dijkstra.exports; kanjiSegs = []; } const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs); - return segs.sort(function(s1, s2) { - return s1.index - s2.index; + return segs.sort(function(s1, s22) { + return s1.index - s22.index; }).map(function(obj) { return { data: obj.data, @@ -2778,9 +2774,9 @@ var dijkstraExports = dijkstra.exports; for (let i2 = 0; i2 < nodes.length; i2++) { const nodeGroup = nodes[i2]; const currentNodeIds = []; - for (let j2 = 0; j2 < nodeGroup.length; j2++) { - const node = nodeGroup[j2]; - const key = "" + i2 + j2; + for (let j = 0; j < nodeGroup.length; j++) { + const node = nodeGroup[j]; + const key = "" + i2 + j; currentNodeIds.push(key); table[key] = { node, lastCount: 0 }; graph[key] = {}; @@ -3174,12 +3170,12 @@ var utils = {}; const scaledMargin = opts.margin * scale; const palette = [opts.color.light, opts.color.dark]; for (let i2 = 0; i2 < symbolSize; i2++) { - for (let j2 = 0; j2 < symbolSize; j2++) { - let posDst = (i2 * symbolSize + j2) * 4; + for (let j = 0; j < symbolSize; j++) { + let posDst = (i2 * symbolSize + j) * 4; let pxColor = opts.color.light; - if (i2 >= scaledMargin && j2 >= scaledMargin && i2 < symbolSize - scaledMargin && j2 < symbolSize - scaledMargin) { + if (i2 >= scaledMargin && j >= scaledMargin && i2 < symbolSize - scaledMargin && j < symbolSize - scaledMargin) { const iSrc = Math.floor((i2 - scaledMargin) / scale); - const jSrc = Math.floor((j2 - scaledMargin) / scale); + const jSrc = Math.floor((j - scaledMargin) / scale); pxColor = palette[data2[iSrc * size + jSrc] ? 1 : 0]; } imgData[posDst++] = pxColor.r; @@ -3360,150 +3356,54 @@ browser.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL); browser.toString = renderCanvas.bind(null, function(data2, _2, opts) { return SvgRenderer.render(data2, opts); }); -var et = Object.defineProperty, Be = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Ue = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, ve = (e2, o3) => { +var et = Object.defineProperty, Se = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Be = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, fe = (e2, o3) => { for (var r2 in o3 || (o3 = {})) - tt.call(o3, r2) && Ue(e2, r2, o3[r2]); - if (Be) - for (var r2 of Be(o3)) - ot.call(o3, r2) && Ue(e2, r2, o3[r2]); + tt.call(o3, r2) && Be(e2, r2, o3[r2]); + if (Se) + for (var r2 of Se(o3)) + ot.call(o3, r2) && Be(e2, r2, o3[r2]); return e2; }; function rt() { var e2; - const o3 = (e2 = index.ne.state.themeMode) != null ? e2 : "dark", r2 = { - light: { - foreground: { - 1: "rgb(20,20,20)", - 2: "rgb(121,134,134)", - 3: "rgb(158,169,169)" - }, - background: { - 1: "rgb(255,255,255)", - 2: "rgb(241,243,243)", - 3: "rgb(228,231,231)" - }, - overlay: "rgba(0,0,0,0.1)" - }, - dark: { - foreground: { - 1: "rgb(228,231,231)", - 2: "rgb(148,158,158)", - 3: "rgb(110,119,119)" - }, - background: { - 1: "rgb(20,20,20)", - 2: "rgb(39,42,42)", - 3: "rgb(59,64,64)" - }, - overlay: "rgba(255,255,255,0.1)" - } - }[o3]; - return { - "--wcm-color-fg-1": r2.foreground[1], - "--wcm-color-fg-2": r2.foreground[2], - "--wcm-color-fg-3": r2.foreground[3], - "--wcm-color-bg-1": r2.background[1], - "--wcm-color-bg-2": r2.background[2], - "--wcm-color-bg-3": r2.background[3], - "--wcm-color-overlay": r2.overlay - }; + const o3 = (e2 = index.ne.state.themeMode) != null ? e2 : "dark", r2 = { light: { foreground: { 1: "rgb(20,20,20)", 2: "rgb(121,134,134)", 3: "rgb(158,169,169)" }, background: { 1: "rgb(255,255,255)", 2: "rgb(241,243,243)", 3: "rgb(228,231,231)" }, overlay: "rgba(0,0,0,0.1)" }, dark: { foreground: { 1: "rgb(228,231,231)", 2: "rgb(148,158,158)", 3: "rgb(110,119,119)" }, background: { 1: "rgb(20,20,20)", 2: "rgb(39,42,42)", 3: "rgb(59,64,64)" }, overlay: "rgba(255,255,255,0.1)" } }[o3]; + return { "--wcm-color-fg-1": r2.foreground[1], "--wcm-color-fg-2": r2.foreground[2], "--wcm-color-fg-3": r2.foreground[3], "--wcm-color-bg-1": r2.background[1], "--wcm-color-bg-2": r2.background[2], "--wcm-color-bg-3": r2.background[3], "--wcm-color-overlay": r2.overlay }; } -function He() { - return { - "--wcm-accent-color": "#3396FF", - "--wcm-accent-fill-color": "#FFFFFF", - "--wcm-z-index": "89", - "--wcm-background-color": "#3396FF", - "--wcm-background-border-radius": "8px", - "--wcm-container-border-radius": "30px", - "--wcm-wallet-icon-border-radius": "15px", - "--wcm-wallet-icon-large-border-radius": "30px", - "--wcm-wallet-icon-small-border-radius": "7px", - "--wcm-input-border-radius": "28px", - "--wcm-button-border-radius": "10px", - "--wcm-notification-border-radius": "36px", - "--wcm-secondary-button-border-radius": "28px", - "--wcm-icon-button-border-radius": "50%", - "--wcm-button-hover-highlight-border-radius": "10px", - "--wcm-text-big-bold-size": "20px", - "--wcm-text-big-bold-weight": "600", - "--wcm-text-big-bold-line-height": "24px", - "--wcm-text-big-bold-letter-spacing": "-0.03em", - "--wcm-text-big-bold-text-transform": "none", - "--wcm-text-xsmall-bold-size": "10px", - "--wcm-text-xsmall-bold-weight": "700", - "--wcm-text-xsmall-bold-line-height": "12px", - "--wcm-text-xsmall-bold-letter-spacing": "0.02em", - "--wcm-text-xsmall-bold-text-transform": "uppercase", - "--wcm-text-xsmall-regular-size": "12px", - "--wcm-text-xsmall-regular-weight": "600", - "--wcm-text-xsmall-regular-line-height": "14px", - "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", - "--wcm-text-xsmall-regular-text-transform": "none", - "--wcm-text-small-thin-size": "14px", - "--wcm-text-small-thin-weight": "500", - "--wcm-text-small-thin-line-height": "16px", - "--wcm-text-small-thin-letter-spacing": "-0.03em", - "--wcm-text-small-thin-text-transform": "none", - "--wcm-text-small-regular-size": "14px", - "--wcm-text-small-regular-weight": "600", - "--wcm-text-small-regular-line-height": "16px", - "--wcm-text-small-regular-letter-spacing": "-0.03em", - "--wcm-text-small-regular-text-transform": "none", - "--wcm-text-medium-regular-size": "16px", - "--wcm-text-medium-regular-weight": "600", - "--wcm-text-medium-regular-line-height": "20px", - "--wcm-text-medium-regular-letter-spacing": "-0.03em", - "--wcm-text-medium-regular-text-transform": "none", - "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", - "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", - "--wcm-success-color": "rgb(38,181,98)", - "--wcm-error-color": "rgb(242, 90, 103)", - "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", - "--wcm-overlay-backdrop-filter": "none" - }; +function Ue() { + return { "--wcm-accent-color": "#3396FF", "--wcm-accent-fill-color": "#FFFFFF", "--wcm-z-index": "89", "--wcm-background-color": "#3396FF", "--wcm-background-border-radius": "8px", "--wcm-container-border-radius": "30px", "--wcm-wallet-icon-border-radius": "15px", "--wcm-wallet-icon-large-border-radius": "30px", "--wcm-wallet-icon-small-border-radius": "7px", "--wcm-input-border-radius": "28px", "--wcm-button-border-radius": "10px", "--wcm-notification-border-radius": "36px", "--wcm-secondary-button-border-radius": "28px", "--wcm-icon-button-border-radius": "50%", "--wcm-button-hover-highlight-border-radius": "10px", "--wcm-text-big-bold-size": "20px", "--wcm-text-big-bold-weight": "600", "--wcm-text-big-bold-line-height": "24px", "--wcm-text-big-bold-letter-spacing": "-0.03em", "--wcm-text-big-bold-text-transform": "none", "--wcm-text-xsmall-bold-size": "10px", "--wcm-text-xsmall-bold-weight": "700", "--wcm-text-xsmall-bold-line-height": "12px", "--wcm-text-xsmall-bold-letter-spacing": "0.02em", "--wcm-text-xsmall-bold-text-transform": "uppercase", "--wcm-text-xsmall-regular-size": "12px", "--wcm-text-xsmall-regular-weight": "600", "--wcm-text-xsmall-regular-line-height": "14px", "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", "--wcm-text-xsmall-regular-text-transform": "none", "--wcm-text-small-thin-size": "14px", "--wcm-text-small-thin-weight": "500", "--wcm-text-small-thin-line-height": "16px", "--wcm-text-small-thin-letter-spacing": "-0.03em", "--wcm-text-small-thin-text-transform": "none", "--wcm-text-small-regular-size": "14px", "--wcm-text-small-regular-weight": "600", "--wcm-text-small-regular-line-height": "16px", "--wcm-text-small-regular-letter-spacing": "-0.03em", "--wcm-text-small-regular-text-transform": "none", "--wcm-text-medium-regular-size": "16px", "--wcm-text-medium-regular-weight": "600", "--wcm-text-medium-regular-line-height": "20px", "--wcm-text-medium-regular-letter-spacing": "-0.03em", "--wcm-text-medium-regular-text-transform": "none", "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", "--wcm-success-color": "rgb(38,181,98)", "--wcm-error-color": "rgb(242, 90, 103)", "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", "--wcm-overlay-backdrop-filter": "none" }; } -const h = { - getPreset(e2) { - return He()[e2]; - }, - setTheme() { - const e2 = document.querySelector(":root"), { themeVariables: o3 } = index.ne.state; - if (e2) { - const r2 = ve(ve(ve({}, rt()), He()), o3); - Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); - } - }, - globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` -}, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; -var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, F = (e2, o3, r2, a2) => { +const h = { getPreset(e2) { + return Ue()[e2]; +}, setTheme() { + const e2 = document.querySelector(":root"), { themeVariables: o3 } = index.ne.state; + if (e2) { + const r2 = fe(fe(fe({}, rt()), Ue()), o3); + Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); + } +}, globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` }, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; +var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? it(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && lt(o3, r2, t2), t2; }; -let T = class extends s { +let _ = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.iconLeft = void 0, this.iconRight = void 0, this.onClick = () => null, this.variant = "default"; } render() { - const e2 = { - "wcm-icon-left": this.iconLeft !== void 0, - "wcm-icon-right": this.iconRight !== void 0, - "wcm-ghost": this.variant === "ghost", - "wcm-outline": this.variant === "outline" - }; + const e2 = { "wcm-icon-left": this.iconLeft !== void 0, "wcm-icon-right": this.iconRight !== void 0, "wcm-ghost": this.variant === "ghost", "wcm-outline": this.variant === "outline" }; let o$12 = "inverse"; return this.variant === "ghost" && (o$12 = "secondary"), this.variant === "outline" && (o$12 = "accent"), x``; } }; -T.styles = [h.globalCss, at], F([n$1({ type: Boolean })], T.prototype, "disabled", 2), F([n$1()], T.prototype, "iconLeft", 2), F([n$1()], T.prototype, "iconRight", 2), F([n$1()], T.prototype, "onClick", 2), F([n$1()], T.prototype, "variant", 2), T = F([e$2("wcm-button")], T); +_.styles = [h.globalCss, at], K([n$1({ type: Boolean })], _.prototype, "disabled", 2), K([n$1()], _.prototype, "iconLeft", 2), K([n$1()], _.prototype, "iconRight", 2), K([n$1()], _.prototype, "onClick", 2), K([n$1()], _.prototype, "variant", 2), _ = K([e$2("wcm-button")], _); const nt = i$3`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`; -var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, ue = (e2, o3, r2, a2) => { +var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, xe = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? st(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && ct(o3, r2, t2), t2; }; -let ee = class extends s { +let re = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.variant = "primary"; } @@ -3512,86 +3412,67 @@ let ee = class extends s { return x``; } }; -ee.styles = [h.globalCss, nt], ue([n$1({ type: Boolean })], ee.prototype, "disabled", 2), ue([n$1()], ee.prototype, "variant", 2), ee = ue([e$2("wcm-button-big")], ee); +re.styles = [h.globalCss, nt], xe([n$1({ type: Boolean })], re.prototype, "disabled", 2), xe([n$1()], re.prototype, "variant", 2), re = xe([e$2("wcm-button-big")], re); const dt = i$3`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`; -var mt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, wt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && mt(o3, r2, t2), t2; +var ht = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let be = class extends s { +let ye = class extends s$1 { render() { return x`
`; } }; -be.styles = [h.globalCss, dt], be = wt([e$2("wcm-info-footer")], be); -const v = { - CROSS_ICON: b``, - WALLET_CONNECT_LOGO: b``, - WALLET_CONNECT_ICON: b``, - WALLET_CONNECT_ICON_COLORED: b``, - BACK_ICON: b``, - COPY_ICON: b``, - RETRY_ICON: b``, - DESKTOP_ICON: b``, - MOBILE_ICON: b``, - ARROW_DOWN_ICON: b``, - ARROW_UP_RIGHT_ICON: b``, - ARROW_RIGHT_ICON: b``, - QRCODE_ICON: b``, - SCAN_ICON: b``, - CHECKMARK_ICON: b``, - SEARCH_ICON: b``, - WALLET_PLACEHOLDER: b``, - GLOBE_ICON: b`` -}, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; -var gt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, ut = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? vt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && gt(o3, r2, t2), t2; +ye.styles = [h.globalCss, dt], ye = ht([e$2("wcm-info-footer")], ye); +const b = { CROSS_ICON: b$1``, WALLET_CONNECT_LOGO: b$1``, WALLET_CONNECT_ICON: b$1``, WALLET_CONNECT_ICON_COLORED: b$1``, BACK_ICON: b$1``, COPY_ICON: b$1``, RETRY_ICON: b$1``, DESKTOP_ICON: b$1``, MOBILE_ICON: b$1``, ARROW_DOWN_ICON: b$1``, ARROW_UP_RIGHT_ICON: b$1``, ARROW_RIGHT_ICON: b$1``, QRCODE_ICON: b$1``, SCAN_ICON: b$1``, CHECKMARK_ICON: b$1``, SEARCH_ICON: b$1``, WALLET_PLACEHOLDER: b$1``, GLOBE_ICON: b$1`` }, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; +var ut = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let fe = class extends s { +let $e = class extends s$1 { render() { - return x`
${v.WALLET_CONNECT_LOGO}
`; + return x`
${b.WALLET_CONNECT_LOGO}
`; } }; -fe.styles = [h.globalCss, pt], fe = ut([e$2("wcm-modal-backcard")], fe); +$e.styles = [h.globalCss, pt], $e = ut([e$2("wcm-modal-backcard")], $e); const bt = i$3`main{padding:20px;padding-top:0;width:100%}`; -var ft = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, yt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? xt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ft(o3, r2, t2), t2; +var yt = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let xe = class extends s { +let Ce = class extends s$1 { render() { return x`
`; } }; -xe.styles = [h.globalCss, bt], xe = yt([e$2("wcm-modal-content")], xe); +Ce.styles = [h.globalCss, bt], Ce = yt([e$2("wcm-modal-content")], Ce); const $t = i$3`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`; -var Ct = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, Ot = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? kt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ct(o3, r2, t2), t2; +var Ot = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let ye = class extends s { +let ke = class extends s$1 { render() { return x`
`; } }; -ye.styles = [h.globalCss, $t], ye = Ot([e$2("wcm-modal-footer")], ye); -const Wt = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; -var It = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, te = (e2, o3, r2, a2) => { +ke.styles = [h.globalCss, $t], ke = Ot([e$2("wcm-modal-footer")], ke); +const It = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; +var Wt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, ae = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Et(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && It(o3, r2, t2), t2; + return a2 && t2 && Wt(o3, r2, t2), t2; }; -let S = class extends s { +let B = class extends s$1 { constructor() { super(...arguments), this.title = "", this.onAction = void 0, this.actionIcon = void 0, this.border = false; } backBtnTemplate() { - return x``; + return x``; } actionBtnTemplate() { return x``; @@ -3601,112 +3482,87 @@ let S = class extends s { return x`
${o$12 ? this.backBtnTemplate() : null} ${r2} ${this.onAction ? this.actionBtnTemplate() : null}
`; } }; -S.styles = [h.globalCss, Wt], te([n$1()], S.prototype, "title", 2), te([n$1()], S.prototype, "onAction", 2), te([n$1()], S.prototype, "actionIcon", 2), te([n$1({ type: Boolean })], S.prototype, "border", 2), S = te([e$2("wcm-modal-header")], S); -const c = { - MOBILE_BREAKPOINT: 600, - WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", - EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", - getShadowRootElement(e2, o3) { - const r2 = e2.renderRoot.querySelector(o3); - if (!r2) - throw new Error(`${o3} not found`); - return r2; - }, - getWalletIcon({ id: e2, image_id: o3 }) { - const { walletImages: r2 } = index.y.state; - return r2 != null && r2[e2] ? r2[e2] : o3 ? index.te.getWalletImageUrl(o3) : ""; - }, - getWalletName(e2, o3 = false) { - return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; - }, - isMobileAnimation() { - return window.innerWidth <= c.MOBILE_BREAKPOINT; - }, - async preloadImage(e2) { - const o3 = new Promise((r2, a2) => { - const t2 = new Image(); - t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; - }); - return Promise.race([o3, index.a.wait(3e3)]); - }, - getErrorMessage(e2) { - return e2 instanceof Error ? e2.message : "Unknown Error"; - }, - debounce(e2, o3 = 500) { - let r2; - return (...a2) => { - function t2() { - e2(...a2); - } - r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); - }; - }, - handleMobileLinking(e2) { - const { walletConnectUri: o3 } = index.p.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - c.setRecentWallet(e2); - function i2(s2) { - let $2 = ""; - t2 ? $2 = index.a.formatUniversalUrl(t2, s2, a2) : l2 && ($2 = index.a.formatNativeUrl(l2, s2, a2)), index.a.openHref($2, "_self"); - } - o3 && i2(o3); - }, - async handleUriCopy() { - const { walletConnectUri: e2 } = index.p.state; - if (e2) - try { - await navigator.clipboard.writeText(e2), index.oe.openToast("Link copied", "success"); - } catch { - index.oe.openToast("Failed to copy", "error"); - } - }, - getCustomImageUrls() { - const { walletImages: e2 } = index.y.state, o3 = Object.values(e2 ?? {}); - return Object.values(o3); - }, - truncate(e2, o3 = 8) { - return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; - }, - setRecentWallet(e2) { - try { - localStorage.setItem(c.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); - } catch { - console.info("Unable to set recent wallet"); +B.styles = [h.globalCss, It], ae([n$1()], B.prototype, "title", 2), ae([n$1()], B.prototype, "onAction", 2), ae([n$1()], B.prototype, "actionIcon", 2), ae([n$1({ type: Boolean })], B.prototype, "border", 2), B = ae([e$2("wcm-modal-header")], B); +const s2 = { MOBILE_BREAKPOINT: 600, WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", getShadowRootElement(e2, o3) { + const r2 = e2.renderRoot.querySelector(o3); + if (!r2) + throw new Error(`${o3} not found`); + return r2; +}, getWalletIcon({ id: e2, image_id: o3 }) { + const { walletImages: r2 } = index.y.state; + return r2 != null && r2[e2] ? r2[e2] : o3 ? index.te.getWalletImageUrl(o3) : ""; +}, getWalletName(e2, o3 = false) { + return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; +}, isMobileAnimation() { + return window.innerWidth <= s2.MOBILE_BREAKPOINT; +}, async preloadImage(e2) { + const o3 = new Promise((r2, a2) => { + const t2 = new Image(); + t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; + }); + return Promise.race([o3, index.i.wait(3e3)]); +}, getErrorMessage(e2) { + return e2 instanceof Error ? e2.message : "Unknown Error"; +}, debounce(e2, o3 = 500) { + let r2; + return (...a2) => { + function t2() { + e2(...a2); } - }, - getRecentWallet() { + r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); + }; +}, handleMobileLinking(e2) { + const { walletConnectUri: o3 } = index.p.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; + s2.setRecentWallet(e2); + function i2(c2) { + let u3 = ""; + t2 ? u3 = index.i.formatUniversalUrl(t2, c2, a2) : l2 && (u3 = index.i.formatNativeUrl(l2, c2, a2)), index.i.openHref(u3, "_self"); + } + o3 && i2(o3); +}, async handleUriCopy() { + const { walletConnectUri: e2 } = index.p.state; + if (e2) try { - const e2 = localStorage.getItem(c.WCM_RECENT_WALLET_DATA); - return e2 ? JSON.parse(e2) : void 0; + await navigator.clipboard.writeText(e2), index.oe.openToast("Link copied", "success"); } catch { - console.info("Unable to get recent wallet"); + index.oe.openToast("Failed to copy", "error"); } - }, - caseSafeIncludes(e2, o3) { - return e2.toUpperCase().includes(o3.toUpperCase()); - }, - openWalletExplorerUrl() { - index.a.openHref(c.EXPLORER_WALLET_URL, "_blank"); - }, - getCachedRouterWalletPlatforms() { - const { desktop: e2, mobile: o3 } = index.a.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); - return { isDesktop: r2, isMobile: t2, isWeb: a2 }; - }, - goToConnectingView(e2) { - index.T.setData({ Wallet: e2 }); - const o3 = index.a.isMobile(), { - isDesktop: r2, - isWeb: a2, - isMobile: t2 - } = c.getCachedRouterWalletPlatforms(); - o3 ? t2 ? index.T.push("MobileConnecting") : a2 ? index.T.push("WebConnecting") : index.T.push("InstallWallet") : r2 ? index.T.push("DesktopConnecting") : a2 ? index.T.push("WebConnecting") : t2 ? index.T.push("MobileQrcodeConnecting") : index.T.push("InstallWallet"); - } -}, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; -var Lt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, $e = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Rt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +}, getCustomImageUrls() { + const { walletImages: e2 } = index.y.state, o3 = Object.values(e2 ?? {}); + return Object.values(o3); +}, truncate(e2, o3 = 8) { + return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; +}, setRecentWallet(e2) { + try { + localStorage.setItem(s2.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); + } catch { + console.info("Unable to set recent wallet"); + } +}, getRecentWallet() { + try { + const e2 = localStorage.getItem(s2.WCM_RECENT_WALLET_DATA); + return e2 ? JSON.parse(e2) : void 0; + } catch { + console.info("Unable to get recent wallet"); + } +}, caseSafeIncludes(e2, o3) { + return e2.toUpperCase().includes(o3.toUpperCase()); +}, openWalletExplorerUrl() { + index.i.openHref(s2.EXPLORER_WALLET_URL, "_blank"); +}, getCachedRouterWalletPlatforms() { + const { desktop: e2, mobile: o3 } = index.i.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); + return { isDesktop: r2, isMobile: t2, isWeb: a2 }; +}, goToConnectingView(e2) { + index.T.setData({ Wallet: e2 }); + const o3 = index.i.isMobile(), { isDesktop: r2, isWeb: a2, isMobile: t2 } = s2.getCachedRouterWalletPlatforms(); + o3 ? t2 ? index.T.push("MobileConnecting") : a2 ? index.T.push("WebConnecting") : index.T.push("InstallWallet") : r2 ? index.T.push("DesktopConnecting") : a2 ? index.T.push("WebConnecting") : t2 ? index.T.push("MobileQrcodeConnecting") : index.T.push("InstallWallet"); +} }, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; +var Pt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Lt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Lt(o3, r2, t2), t2; + return a2 && t2 && Pt(o3, r2, t2), t2; }; -let oe = class extends s { +let le = class extends s$1 { constructor() { super(), this.view = index.T.state.view, this.prevView = index.T.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = index.T.subscribe((e2) => { this.view !== e2.view && this.onChangeRoute(); @@ -3723,10 +3579,10 @@ let oe = class extends s { (e2 = this.unsubscribe) == null || e2.call(this), (o3 = this.resizeObserver) == null || o3.disconnect(); } get routerEl() { - return c.getShadowRootElement(this, ".wcm-router"); + return s2.getShadowRootElement(this, ".wcm-router"); } get contentEl() { - return c.getShadowRootElement(this, ".wcm-content"); + return s2.getShadowRootElement(this, ".wcm-content"); } viewTemplate() { switch (this.view) { @@ -3751,28 +3607,20 @@ let oe = class extends s { } } async onChangeRoute() { - await animate( - this.routerEl, - { opacity: [1, 0], scale: [1, 1.02] }, - { duration: 0.15, delay: 0.1 } - ).finished, this.view = index.T.state.view, animate( - this.routerEl, - { opacity: [0, 1], scale: [0.99, 1] }, - { duration: 0.37, delay: 0.05 } - ); + await animate(this.routerEl, { opacity: [1, 0], scale: [1, 1.02] }, { duration: 0.15, delay: 0.1 }).finished, this.view = index.T.state.view, animate(this.routerEl, { opacity: [0, 1], scale: [0.99, 1] }, { duration: 0.37, delay: 0.05 }); } render() { return x`
${this.viewTemplate()}
`; } }; -oe.styles = [h.globalCss, Mt], $e([t$1()], oe.prototype, "view", 2), $e([t$1()], oe.prototype, "prevView", 2), oe = $e([e$2("wcm-modal-router")], oe); -const At = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; -var Pt = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, ze = (e2, o3, r2, a2) => { +le.styles = [h.globalCss, Mt], Oe([t$1()], le.prototype, "view", 2), Oe([t$1()], le.prototype, "prevView", 2), le = Oe([e$2("wcm-modal-router")], le); +const Rt = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; +var At = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, He = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Tt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Pt(o3, r2, t2), t2; + return a2 && t2 && At(o3, r2, t2), t2; }; -let ne = class extends s { +let de = class extends s$1 { constructor() { super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = index.oe.subscribe((e2) => { e2.open ? (this.open = true, this.timeout = setTimeout(() => index.oe.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); @@ -3784,163 +3632,132 @@ let ne = class extends s { } render() { const { message: e2, variant: o$12 } = index.oe.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; - return this.open ? x`
${o$12 === "success" ? v.CHECKMARK_ICON : null} ${o$12 === "error" ? v.CROSS_ICON : null}${e2}
` : null; + return this.open ? x`
${o$12 === "success" ? b.CHECKMARK_ICON : null} ${o$12 === "error" ? b.CROSS_ICON : null}${e2}
` : null; } }; -ne.styles = [h.globalCss, At], ze([t$1()], ne.prototype, "open", 2), ne = ze([e$2("wcm-modal-toast")], ne); -const jt = 0.1, Ve = 2.5, A = 7; -function Ce(e2, o3, r2) { +de.styles = [h.globalCss, Rt], He([t$1()], de.prototype, "open", 2), de = He([e$2("wcm-modal-toast")], de); +const jt = 0.1, Ve = 2.5, L2 = 7; +function Ie(e2, o3, r2) { return e2 === o3 ? false : (e2 - o3 < 0 ? o3 - e2 : e2 - o3) <= r2 + jt; } function _t(e2, o3) { - const r2 = Array.prototype.slice.call( - browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, - 0 - ), a2 = Math.sqrt(r2.length); - return r2.reduce( - (t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, - [] - ); + const r2 = Array.prototype.slice.call(browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, 0), a2 = Math.sqrt(r2.length); + return r2.reduce((t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, []); } -const Dt = { - generate(e2, o3, r2) { - const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), s2 = o3 / i2.length, $2 = [ - { x: 0, y: 0 }, - { x: 1, y: 0 }, - { x: 0, y: 1 } - ]; - $2.forEach(({ x: y2, y: u3 }) => { - const O = (i2.length - A) * s2 * y2, b$1 = (i2.length - A) * s2 * u3, E2 = 0.45; - for (let M2 = 0; M2 < $2.length; M2 += 1) { - const V2 = s2 * (A - M2 * 2); - l2.push( - b`` - ); +const Dt = { generate(e2, o3, r2) { + const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), c2 = o3 / i2.length, u3 = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }]; + u3.forEach(({ x: $2, y: f2 }) => { + const O = (i2.length - L2) * c2 * $2, x2 = (i2.length - L2) * c2 * f2, E2 = 0.45; + for (let M2 = 0; M2 < u3.length; M2 += 1) { + const Q = c2 * (L2 - M2 * 2); + l2.push(b$1``); + } + }); + const w2 = Math.floor((r2 + 25) / c2), F = i2.length / 2 - w2 / 2, T2 = i2.length / 2 + w2 / 2 - 1, j = []; + i2.forEach(($2, f2) => { + $2.forEach((O, x2) => { + if (i2[f2][x2] && !(f2 < L2 && x2 < L2 || f2 > i2.length - (L2 + 1) && x2 < L2 || f2 < L2 && x2 > i2.length - (L2 + 1)) && !(f2 > F && f2 < T2 && x2 > F && x2 < T2)) { + const E2 = f2 * c2 + c2 / 2, M2 = x2 * c2 + c2 / 2; + j.push([E2, M2]); } }); - const f2 = Math.floor((r2 + 25) / s2), Ne = i2.length / 2 - f2 / 2, Ze = i2.length / 2 + f2 / 2 - 1, Se = []; - i2.forEach((y2, u3) => { - y2.forEach((O, b2) => { - if (i2[u3][b2] && !(u3 < A && b2 < A || u3 > i2.length - (A + 1) && b2 < A || u3 < A && b2 > i2.length - (A + 1)) && !(u3 > Ne && u3 < Ze && b2 > Ne && b2 < Ze)) { - const E2 = u3 * s2 + s2 / 2, M2 = b2 * s2 + s2 / 2; - Se.push([E2, M2]); - } - }); + }); + const oe = {}; + return j.forEach(([$2, f2]) => { + oe[$2] ? oe[$2].push(f2) : oe[$2] = [f2]; + }), Object.entries(oe).map(([$2, f2]) => { + const O = f2.filter((x2) => f2.every((E2) => !Ie(x2, E2, c2))); + return [Number($2), O]; + }).forEach(([$2, f2]) => { + f2.forEach((O) => { + l2.push(b$1``); }); - const J = {}; - return Se.forEach(([y2, u3]) => { - J[y2] ? J[y2].push(u3) : J[y2] = [u3]; - }), Object.entries(J).map(([y2, u3]) => { - const O = u3.filter((b2) => u3.every((E2) => !Ce(b2, E2, s2))); - return [Number(y2), O]; - }).forEach(([y2, u3]) => { - u3.forEach((O) => { - l2.push( - b`` - ); - }); - }), Object.entries(J).filter(([y2, u3]) => u3.length > 1).map(([y2, u3]) => { - const O = u3.filter((b2) => u3.some((E2) => Ce(b2, E2, s2))); - return [Number(y2), O]; - }).map(([y2, u3]) => { - u3.sort((b2, E2) => b2 < E2 ? -1 : 1); - const O = []; - for (const b2 of u3) { - const E2 = O.find((M2) => M2.some((V2) => Ce(b2, V2, s2))); - E2 ? E2.push(b2) : O.push([b2]); - } - return [y2, O.map((b2) => [b2[0], b2[b2.length - 1]])]; - }).forEach(([y2, u3]) => { - u3.forEach(([O, b$1]) => { - l2.push( - b`` - ); - }); - }), l2; - } -}, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; -var Zt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, q = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? St(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + }), Object.entries(oe).filter(([$2, f2]) => f2.length > 1).map(([$2, f2]) => { + const O = f2.filter((x2) => f2.some((E2) => Ie(x2, E2, c2))); + return [Number($2), O]; + }).map(([$2, f2]) => { + f2.sort((x2, E2) => x2 < E2 ? -1 : 1); + const O = []; + for (const x2 of f2) { + const E2 = O.find((M2) => M2.some((Q) => Ie(x2, Q, c2))); + E2 ? E2.push(x2) : O.push([x2]); + } + return [$2, O.map((x2) => [x2[0], x2[x2.length - 1]])]; + }).forEach(([$2, f2]) => { + f2.forEach(([O, x2]) => { + l2.push(b$1``); + }); + }), l2; +} }, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; +var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Y = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zt(o3, r2, t2), t2; }; -exports.WcmQrCode = class j extends s { +exports.WcmQrCode = class D2 extends s$1 { constructor() { super(...arguments), this.uri = "", this.size = 0, this.imageId = void 0, this.walletId = void 0, this.imageUrl = void 0; } svgTemplate() { const e2 = index.ne.state.themeMode === "light" ? this.size : this.size - 36; - return b`${Dt.generate(this.uri, e2, e2 / 4)}`; + return b$1`${Dt.generate(this.uri, e2, e2 / 4)}`; } render() { const e2 = { "wcm-dark": index.ne.state.themeMode === "dark" }; - return x`
${this.walletId || this.imageUrl ? x`` : v.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; + return x`
${this.walletId || this.imageUrl ? x`` : b.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; } }; -exports.WcmQrCode.styles = [h.globalCss, Nt], q([n$1()], exports.WcmQrCode.prototype, "uri", 2), q([n$1({ type: Number })], exports.WcmQrCode.prototype, "size", 2), q([n$1()], exports.WcmQrCode.prototype, "imageId", 2), q([n$1()], exports.WcmQrCode.prototype, "walletId", 2), q([n$1()], exports.WcmQrCode.prototype, "imageUrl", 2), exports.WcmQrCode = q([e$2("wcm-qrcode")], exports.WcmQrCode); -const Bt = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; -var Ut = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +exports.WcmQrCode.styles = [h.globalCss, Nt], Y([n$1()], exports.WcmQrCode.prototype, "uri", 2), Y([n$1({ type: Number })], exports.WcmQrCode.prototype, "size", 2), Y([n$1()], exports.WcmQrCode.prototype, "imageId", 2), Y([n$1()], exports.WcmQrCode.prototype, "walletId", 2), Y([n$1()], exports.WcmQrCode.prototype, "imageUrl", 2), exports.WcmQrCode = Y([e$2("wcm-qrcode")], exports.WcmQrCode); +const St = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; +var Bt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ut(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ut(o3, r2, t2), t2; + return a2 && t2 && Bt(o3, r2, t2), t2; }; -let ce = class extends s { +let me = class extends s$1 { constructor() { super(...arguments), this.onChange = () => null; } render() { - return x` ${v.SEARCH_ICON}`; + return x` ${b.SEARCH_ICON}`; } }; -ce.styles = [h.globalCss, Bt], Fe([n$1()], ce.prototype, "onChange", 2), ce = Fe([e$2("wcm-search-input")], ce); -const zt = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; -var Vt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, qt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ft(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Vt(o3, r2, t2), t2; +me.styles = [h.globalCss, St], qe([n$1()], me.prototype, "onChange", 2), me = qe([e$2("wcm-search-input")], me); +const Ht = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; +var Ft = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let ke = class extends s { +let We = class extends s$1 { render() { return x``; } }; -ke.styles = [h.globalCss, zt], ke = qt([e$2("wcm-spinner")], ke); +We.styles = [h.globalCss, Ht], We = Ft([e$2("wcm-spinner")], We); const Qt = i$3`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`; -var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a2) => { +var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Ee = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Yt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Kt(o3, r2, t2), t2; }; -let re = class extends s { +let ie = class extends s$1 { constructor() { super(...arguments), this.variant = "medium-regular", this.color = "primary"; } render() { - const e2 = { - "wcm-big-bold": this.variant === "big-bold", - "wcm-medium-regular": this.variant === "medium-regular", - "wcm-small-regular": this.variant === "small-regular", - "wcm-small-thin": this.variant === "small-thin", - "wcm-xsmall-regular": this.variant === "xsmall-regular", - "wcm-xsmall-bold": this.variant === "xsmall-bold", - "wcm-color-primary": this.color === "primary", - "wcm-color-secondary": this.color === "secondary", - "wcm-color-tertiary": this.color === "tertiary", - "wcm-color-inverse": this.color === "inverse", - "wcm-color-accnt": this.color === "accent", - "wcm-color-error": this.color === "error" - }; + const e2 = { "wcm-big-bold": this.variant === "big-bold", "wcm-medium-regular": this.variant === "medium-regular", "wcm-small-regular": this.variant === "small-regular", "wcm-small-thin": this.variant === "small-thin", "wcm-xsmall-regular": this.variant === "xsmall-regular", "wcm-xsmall-bold": this.variant === "xsmall-bold", "wcm-color-primary": this.color === "primary", "wcm-color-secondary": this.color === "secondary", "wcm-color-tertiary": this.color === "tertiary", "wcm-color-inverse": this.color === "inverse", "wcm-color-accnt": this.color === "accent", "wcm-color-error": this.color === "error" }; return x``; } }; -re.styles = [h.globalCss, Qt], Oe([n$1()], re.prototype, "variant", 2), Oe([n$1()], re.prototype, "color", 2), re = Oe([e$2("wcm-text")], re); +ie.styles = [h.globalCss, Qt], Ee([n$1()], ie.prototype, "variant", 2), Ee([n$1()], ie.prototype, "color", 2), ie = Ee([e$2("wcm-text")], ie); const Gt = i$3`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`; -var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, _ = (e2, o3, r2, a2) => { +var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, N2 = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xt(o3, r2, t2), t2; }; -let L2 = class extends s { +let P = class extends s$1 { constructor() { super(...arguments), this.onClick = () => null, this.name = "", this.walletId = "", this.label = void 0, this.imageId = void 0, this.installed = false, this.recent = false; } @@ -3952,39 +3769,39 @@ let L2 = class extends s { } render() { var e2; - return x``; + return x``; } }; -L2.styles = [h.globalCss, Gt], _([n$1()], L2.prototype, "onClick", 2), _([n$1()], L2.prototype, "name", 2), _([n$1()], L2.prototype, "walletId", 2), _([n$1()], L2.prototype, "label", 2), _([n$1()], L2.prototype, "imageId", 2), _([n$1({ type: Boolean })], L2.prototype, "installed", 2), _([n$1({ type: Boolean })], L2.prototype, "recent", 2), L2 = _([e$2("wcm-wallet-button")], L2); +P.styles = [h.globalCss, Gt], N2([n$1()], P.prototype, "onClick", 2), N2([n$1()], P.prototype, "name", 2), N2([n$1()], P.prototype, "walletId", 2), N2([n$1()], P.prototype, "label", 2), N2([n$1()], P.prototype, "imageId", 2), N2([n$1({ type: Boolean })], P.prototype, "installed", 2), N2([n$1({ type: Boolean })], P.prototype, "recent", 2), P = N2([e$2("wcm-wallet-button")], P); const eo = i$3`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a2) => { +var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, we = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? oo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && to(o3, r2, t2), t2; }; -let Q = class extends s { +let G = class extends s$1 { constructor() { super(...arguments), this.walletId = "", this.imageId = void 0, this.imageUrl = void 0; } render() { var e2; - const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : c.getWalletIcon({ id: this.walletId, image_id: this.imageId }); - return x`${o3.length ? x`
${this.id}
` : v.WALLET_PLACEHOLDER}`; + const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : s2.getWalletIcon({ id: this.walletId, image_id: this.imageId }); + return x`${o3.length ? x`
${this.id}
` : b.WALLET_PLACEHOLDER}`; } }; -Q.styles = [h.globalCss, eo], se([n$1()], Q.prototype, "walletId", 2), se([n$1()], Q.prototype, "imageId", 2), se([n$1()], Q.prototype, "imageUrl", 2), Q = se([e$2("wcm-wallet-image")], Q); -var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a2) => { +G.styles = [h.globalCss, eo], we([n$1()], G.prototype, "walletId", 2), we([n$1()], G.prototype, "imageId", 2), we([n$1()], G.prototype, "imageUrl", 2), G = we([e$2("wcm-wallet-image")], G); +var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && ro(o3, r2, t2), t2; }; -let We = class extends s { +let Me = class extends s$1 { constructor() { super(), this.preload = true, this.preloadData(); } async loadImages(e2) { try { - e2 != null && e2.length && await Promise.all(e2.map(async (o3) => c.preloadImage(o3))); + e2 != null && e2.length && await Promise.all(e2.map(async (o3) => s2.preloadImage(o3))); } catch { console.info("Unsuccessful attempt at preloading some images", e2); } @@ -3992,33 +3809,30 @@ let We = class extends s { async preloadListings() { if (index.y.state.enableExplorer) { await index.te.getRecomendedWallets(), index.p.setIsDataLoaded(true); - const { recomendedWallets: e2 } = index.te.state, o3 = e2.map((r2) => c.getWalletIcon(r2)); + const { recomendedWallets: e2 } = index.te.state, o3 = e2.map((r2) => s2.getWalletIcon(r2)); await this.loadImages(o3); } else index.p.setIsDataLoaded(true); } async preloadCustomImages() { - const e2 = c.getCustomImageUrls(); + const e2 = s2.getCustomImageUrls(); await this.loadImages(e2); } async preloadData() { try { - this.preload && (this.preload = false, await Promise.all([ - this.preloadListings(), - this.preloadCustomImages() - ])); + this.preload && (this.preload = false, await Promise.all([this.preloadListings(), this.preloadCustomImages()])); } catch (e2) { console.error(e2), index.oe.openToast("Failed preloading", "error"); } } }; -qe([t$1()], We.prototype, "preload", 2), We = qe([e$2("wcm-explorer-context")], We); -var lo = Object.defineProperty, io = Object.getOwnPropertyDescriptor, no = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? io(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && lo(o3, r2, t2), t2; +Fe([t$1()], Me.prototype, "preload", 2), Me = Fe([e$2("wcm-explorer-context")], Me); +var no = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Qe = class extends s { +let Qe = class extends s$1 { constructor() { super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = index.ne.subscribe(h.setTheme); } @@ -4029,36 +3843,34 @@ let Qe = class extends s { }; Qe = no([e$2("wcm-theme-context")], Qe); const co = i$3`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var so = Object.defineProperty, mo = Object.getOwnPropertyDescriptor, ho = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? mo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && so(o3, r2, t2), t2; +var wo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ie = class extends s { +let Pe = class extends s$1 { onConnect(e2) { - index.a.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + index.i.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onGoToQrcode() { index.T.push("Qrcode"); } render() { - const { recomendedWallets: e2 } = index.te.state, o3 = [...e2, ...e2], r2 = index.a.RECOMMENDED_WALLET_AMOUNT * 2; - return x`
${v.MOBILE_ICON}WalletConnect
${[ - ...Array(r2) - ].map((a2, t2) => { + const { recomendedWallets: e2 } = index.te.state, o3 = [...e2, ...e2], r2 = index.i.RECOMMENDED_WALLET_AMOUNT * 2; + return x`
${b.MOBILE_ICON}WalletConnect
${[...Array(r2)].map((a2, t2) => { const l2 = o3[t2 % o3.length]; - return l2 ? x`` : v.WALLET_PLACEHOLDER; + return l2 ? x`` : b.WALLET_PLACEHOLDER; })}
Select Wallet
Choose WalletConnect to see supported apps on your device`; } }; -Ie.styles = [h.globalCss, co], Ie = ho([e$2("wcm-android-wallet-selection")], Ie); -const wo = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; -var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a2) => { +Pe.styles = [h.globalCss, co], Pe = wo([e$2("wcm-android-wallet-selection")], Pe); +const ho = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; +var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, X = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? go(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && po(o3, r2, t2), t2; }; -let D = class extends s { +let Z2 = class extends s$1 { constructor() { super(...arguments), this.walletId = void 0, this.imageId = void 0, this.isError = false, this.isStale = false, this.label = ""; } @@ -4075,111 +3887,88 @@ let D = class extends s { return x`
${this.svgLoaderTemplate()}
${this.isError ? "Connection declined" : this.label}`; } }; -D.styles = [h.globalCss, wo], K([n$1()], D.prototype, "walletId", 2), K([n$1()], D.prototype, "imageId", 2), K([n$1({ type: Boolean })], D.prototype, "isError", 2), K([n$1({ type: Boolean })], D.prototype, "isStale", 2), K([n$1()], D.prototype, "label", 2), D = K([e$2("wcm-connector-waiting")], D); -const G = { - manualWallets() { - var e2, o3; - const { mobileWallets: r2, desktopWallets: a2 } = index.y.state, t2 = (e2 = G.recentWallet()) == null ? void 0 : e2.id, l2 = index.a.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((s2) => t2 !== s2.id); - return (o3 = index.a.isMobile() ? i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - mobile: f2, - links: f2 - })) : i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - desktop: f2, - links: f2 - }))) != null ? o3 : []; - }, - recentWallet() { - return c.getRecentWallet(); - }, - recomendedWallets(e2 = false) { - var o3; - const r2 = e2 || (o3 = G.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a2 } = index.te.state; - return a2.filter((t2) => r2 !== t2.id); - } -}, Z2 = { - onConnecting(e2) { - c.goToConnectingView(e2); - }, - manualWalletsTemplate() { - return G.manualWallets().map( - (e2) => x`` - ); - }, - recomendedWalletsTemplate(e2 = false) { - return G.recomendedWallets(e2).map( - (o3) => x`` - ); - }, - recentWalletTemplate() { - const e2 = G.recentWallet(); - if (e2) - return x``; - } -}, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; -var uo = Object.defineProperty, bo = Object.getOwnPropertyDescriptor, fo = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? bo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && uo(o3, r2, t2), t2; +Z2.styles = [h.globalCss, ho], X([n$1()], Z2.prototype, "walletId", 2), X([n$1()], Z2.prototype, "imageId", 2), X([n$1({ type: Boolean })], Z2.prototype, "isError", 2), X([n$1({ type: Boolean })], Z2.prototype, "isStale", 2), X([n$1()], Z2.prototype, "label", 2), Z2 = X([e$2("wcm-connector-waiting")], Z2); +const ee = { manualWallets() { + var e2, o3; + const { mobileWallets: r2, desktopWallets: a2 } = index.y.state, t2 = (e2 = ee.recentWallet()) == null ? void 0 : e2.id, l2 = index.i.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((c2) => t2 !== c2.id); + return (o3 = index.i.isMobile() ? i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w2 }) => ({ id: c2, name: u3, mobile: w2, links: w2 })) : i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w2 }) => ({ id: c2, name: u3, desktop: w2, links: w2 }))) != null ? o3 : []; +}, recentWallet() { + return s2.getRecentWallet(); +}, recomendedWallets(e2 = false) { + var o3; + const r2 = e2 || (o3 = ee.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a2 } = index.te.state; + return a2.filter((t2) => r2 !== t2.id); +} }, S = { onConnecting(e2) { + s2.goToConnectingView(e2); +}, manualWalletsTemplate() { + return ee.manualWallets().map((e2) => x``); +}, recomendedWalletsTemplate(e2 = false) { + return ee.recomendedWallets(e2).map((o3) => x``); +}, recentWalletTemplate() { + const e2 = ee.recentWallet(); + if (e2) + return x``; +} }, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; +var fo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ee = class extends s { +let Le = class extends s$1 { render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = index.y.state, r2 = e2 !== "ALL" && o3, a2 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = index.y.state, r2 = e2 !== "ALL" && o3, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 4 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 3) : s2 = l2; - const $2 = Boolean(s2.length); - return x`
${v.MOBILE_ICON}Mobile
${v.SCAN_ICON}Scan with your wallet
${$2 ? x`
${v.DESKTOP_ICON}Desktop
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 3) : c2 = l2; + const u3 = Boolean(c2.length); + return x`
${b.MOBILE_ICON}Mobile
${b.SCAN_ICON}Scan with your wallet
${u3 ? x`
${b.DESKTOP_ICON}Desktop
${c2} ${i2 ? x`` : null}
` : null}`; } }; -Ee.styles = [h.globalCss, vo], Ee = fo([e$2("wcm-desktop-wallet-selection")], Ee); +Le.styles = [h.globalCss, vo], Le = fo([e$2("wcm-desktop-wallet-selection")], Le); const xo = i$3`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`; -var yo = Object.defineProperty, $o = Object.getOwnPropertyDescriptor, Co = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? $o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && yo(o3, r2, t2), t2; +var Co = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Me = class extends s { +let Re = class extends s$1 { render() { const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = index.y.state; return e2 ?? o3 ? x`
By connecting your wallet to this app, you agree to the app's ${e2 ? x`Terms of Service` : null} ${e2 && o3 ? "and" : null} ${o3 ? x`Privacy Policy` : null}
` : null; } }; -Me.styles = [h.globalCss, xo], Me = Co([e$2("wcm-legal-notice")], Me); +Re.styles = [h.globalCss, xo], Re = Co([e$2("wcm-legal-notice")], Re); const ko = i$3`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`; -var Oo = Object.defineProperty, Wo = Object.getOwnPropertyDescriptor, Io = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Wo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Oo(o3, r2, t2), t2; +var Wo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Le = class extends s { +let Ae = class extends s$1 { onQrcode() { index.T.push("Qrcode"); } render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = index.y.state, r2 = e2 !== "ALL" && o3, a2 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = index.y.state, r2 = e2 !== "ALL" && o3, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 8 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 7) : s2 = l2; - const $2 = Boolean(s2.length); - return x`${$2 ? x`
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 7) : c2 = l2; + const u3 = Boolean(c2.length); + return x`${u3 ? x`
${c2} ${i2 ? x`` : null}
` : null}`; } }; -Le.styles = [h.globalCss, ko], Le = Io([e$2("wcm-mobile-wallet-selection")], Le); +Ae.styles = [h.globalCss, ko], Ae = Wo([e$2("wcm-mobile-wallet-selection")], Ae); const Eo = i$3`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`; -var Mo = Object.defineProperty, Lo = Object.getOwnPropertyDescriptor, Re = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Lo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var Mo = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, Te = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Mo(o3, r2, t2), t2; }; -exports.WcmModal = class ae extends s { +exports.WcmModal = class ne extends s$1 { constructor() { super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = index.se.subscribe((e2) => { e2.open ? this.onOpenModalEvent() : this.onCloseModalEvent(); @@ -4190,10 +3979,10 @@ exports.WcmModal = class ae extends s { (e2 = this.unsubscribeModal) == null || e2.call(this); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-overlay"); + return s2.getShadowRootElement(this, ".wcm-overlay"); } get containerEl() { - return c.getShadowRootElement(this, ".wcm-container"); + return s2.getShadowRootElement(this, ".wcm-container"); } toggleBodyScroll(e2) { if (document.querySelector("body")) @@ -4201,40 +3990,27 @@ exports.WcmModal = class ae extends s { const o3 = document.getElementById("wcm-styles"); o3 == null ? void 0 : o3.remove(); } else - document.head.insertAdjacentHTML( - "beforeend", - '' - ); + document.head.insertAdjacentHTML("beforeend", ''); } onCloseModal(e2) { e2.target === e2.currentTarget && index.se.close(); } onOpenModalEvent() { this.toggleBodyScroll(false), this.addKeyboardEvents(), this.open = true, setTimeout(async () => { - const e2 = c.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, - animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished - ]), this.active = true; + const e2 = s2.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished]), this.active = true; }, 0); } async onCloseModalEvent() { this.toggleBodyScroll(true), this.removeKeyboardEvents(); - const e2 = c.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, - animate(this.containerEl, e2, { duration: o3 }).finished - ]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; + const e2 = s2.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, animate(this.containerEl, e2, { duration: o3 }).finished]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; } addKeyboardEvents() { - this.abortController = new AbortController(), window.addEventListener( - "keydown", - (e2) => { - var o3; - e2.key === "Escape" ? index.se.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); - }, - this.abortController - ), this.containerEl.focus(); + this.abortController = new AbortController(), window.addEventListener("keydown", (e2) => { + var o3; + e2.key === "Escape" ? index.se.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); + }, this.abortController), this.containerEl.focus(); } removeKeyboardEvents() { var e2; @@ -4245,19 +4021,19 @@ exports.WcmModal = class ae extends s { return x`
${this.open ? x`
` : null}
`; } }; -exports.WcmModal.styles = [h.globalCss, Eo], Re([t$1()], exports.WcmModal.prototype, "open", 2), Re([t$1()], exports.WcmModal.prototype, "active", 2), exports.WcmModal = Re([e$2("wcm-modal")], exports.WcmModal); -const Ro = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; -var Ao = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, le = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +exports.WcmModal.styles = [h.globalCss, Eo], Te([t$1()], exports.WcmModal.prototype, "open", 2), Te([t$1()], exports.WcmModal.prototype, "active", 2), exports.WcmModal = Te([e$2("wcm-modal")], exports.WcmModal); +const Lo = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; +var Ro = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, ce = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ao(o3, r2, t2), t2; + return a2 && t2 && Ro(o3, r2, t2), t2; }; -let B = class extends s { +let U = class extends s$1 { constructor() { super(...arguments), this.isMobile = false, this.isDesktop = false, this.isWeb = false, this.isRetry = false; } onMobile() { - index.a.isMobile() ? index.T.replace("MobileConnecting") : index.T.replace("MobileQrcodeConnecting"); + index.i.isMobile() ? index.T.replace("MobileConnecting") : index.T.replace("MobileQrcodeConnecting"); } onDesktop() { index.T.replace("DesktopConnecting"); @@ -4266,41 +4042,39 @@ let B = class extends s { index.T.replace("WebConnecting"); } render() { - return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; + return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; } }; -B.styles = [h.globalCss, Ro], le([n$1({ type: Boolean })], B.prototype, "isMobile", 2), le([n$1({ type: Boolean })], B.prototype, "isDesktop", 2), le([n$1({ type: Boolean })], B.prototype, "isWeb", 2), le([n$1({ type: Boolean })], B.prototype, "isRetry", 2), B = le([e$2("wcm-platform-selection")], B); +U.styles = [h.globalCss, Lo], ce([n$1({ type: Boolean })], U.prototype, "isMobile", 2), ce([n$1({ type: Boolean })], U.prototype, "isDesktop", 2), ce([n$1({ type: Boolean })], U.prototype, "isWeb", 2), ce([n$1({ type: Boolean })], U.prototype, "isRetry", 2), U = ce([e$2("wcm-platform-selection")], U); const To = i$3`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var jo = Object.defineProperty, _o = Object.getOwnPropertyDescriptor, Do = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? _o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && jo(o3, r2, t2), t2; +var Do = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ae = class extends s { +let je = class extends s$1 { onClick() { index.T.push("WalletExplorer"); } render() { - const { recomendedWallets: e2 } = index.te.state, o3 = G.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); - return x``; + const { recomendedWallets: e2 } = index.te.state, o3 = ee.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); + return x``; } }; -Ae.styles = [h.globalCss, To], Ae = Do([e$2("wcm-view-all-wallets-button")], Ae); +je.styles = [h.globalCss, To], je = Do([e$2("wcm-view-all-wallets-button")], je); const No = i$3`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`; -var Zo = Object.defineProperty, So = Object.getOwnPropertyDescriptor, de = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? So(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var Zo = Object.defineProperty, zo = Object.getOwnPropertyDescriptor, he = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zo(o3, r2, t2), t2; }; -let Y = class extends s { +let J = class extends s$1 { constructor() { super(), this.walletId = "", this.imageId = "", this.uri = "", setTimeout(() => { const { walletConnectUri: e2 } = index.p.state; @@ -4308,148 +4082,151 @@ let Y = class extends s { }, 0); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-qr-container"); + return s2.getShadowRootElement(this, ".wcm-qr-container"); } render() { return x`
${this.uri ? x`` : x``}
`; } }; -Y.styles = [h.globalCss, No], de([n$1()], Y.prototype, "walletId", 2), de([n$1()], Y.prototype, "imageId", 2), de([t$1()], Y.prototype, "uri", 2), Y = de([e$2("wcm-walletconnect-qr")], Y); -var Bo = Object.defineProperty, Uo = Object.getOwnPropertyDescriptor, Ho = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Uo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Bo(o3, r2, t2), t2; +J.styles = [h.globalCss, No], he([n$1()], J.prototype, "walletId", 2), he([n$1()], J.prototype, "imageId", 2), he([t$1()], J.prototype, "uri", 2), J = he([e$2("wcm-walletconnect-qr")], J); +var Uo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Pe = class extends s { +let _e = class extends s$1 { viewTemplate() { - return index.a.isAndroid() ? x`` : index.a.isMobile() ? x`` : x``; + return index.i.isAndroid() ? x`` : index.i.isMobile() ? x`` : x``; } render() { return x`${this.viewTemplate()}`; } }; -Pe.styles = [h.globalCss], Pe = Ho([e$2("wcm-connect-wallet-view")], Pe); -const zo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var Vo = Object.defineProperty, Fo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Fo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +_e.styles = [h.globalCss], _e = Uo([e$2("wcm-connect-wallet-view")], _e); +const Ho = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; +var Vo = Object.defineProperty, qo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? qo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Vo(o3, r2, t2), t2; }; -let me = class extends s { +let pe = class extends s$1 { constructor() { super(), this.isError = false, this.openDesktopApp(); } onFormatAndRedirect(e2) { - const { desktop: o3, name: r2 } = index.a.getWalletRouterData(), a2 = o3 == null ? void 0 : o3.native; - if (a2) { - const t2 = index.a.formatNativeUrl(a2, e2, r2); - index.a.openHref(t2, "_self"); + var o3; + const { desktop: r2, name: a2 } = index.i.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native; + if (t2) { + const l2 = index.i.formatNativeUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + index.i.openHref(l2, "_self"); } } openDesktopApp() { - const { walletConnectUri: e2 } = index.p.state, o3 = index.a.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = index.p.state, o3 = index.i.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = index.a.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; + const { name: e2, id: o3, image_id: r2 } = index.i.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; } }; -me.styles = [h.globalCss, zo], Ke([t$1()], me.prototype, "isError", 2), me = Ke([e$2("wcm-desktop-connecting-view")], me); -const qo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; -var Qo = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, Yo = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ko(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Qo(o3, r2, t2), t2; +pe.styles = [h.globalCss, Ho], Ke([t$1()], pe.prototype, "isError", 2), pe = Ke([e$2("wcm-desktop-connecting-view")], pe); +const Fo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; +var Yo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Te = class extends s { +let De = class extends s$1 { onInstall(e2) { - e2 && index.a.openHref(e2, "_blank"); + e2 && index.i.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - homepage: a2 - } = index.a.getWalletRouterData(); - return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; + const { name: e2, id: o3, image_id: r2, homepage: a2 } = index.i.getWalletRouterData(); + return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; } }; -Te.styles = [h.globalCss, qo], Te = Yo([e$2("wcm-install-wallet-view")], Te); +De.styles = [h.globalCss, Fo], De = Yo([e$2("wcm-install-wallet-view")], De); const Go = i$3`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`; var Xo = Object.defineProperty, Jo = Object.getOwnPropertyDescriptor, Ye = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xo(o3, r2, t2), t2; }; -let he = class extends s { +let ge = class extends s$1 { constructor() { super(), this.isError = false, this.openMobileApp(); } onFormatAndRedirect(e2, o3 = false) { - const { mobile: r2, name: a2 } = index.a.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - if (t2 && !o3) { - const i2 = index.a.formatNativeUrl(t2, e2, a2); - index.a.openHref(i2, "_self"); - } else if (l2) { - const i2 = index.a.formatUniversalUrl(l2, e2, a2); - index.a.openHref(i2, "_self"); + var r2, a2; + const { mobile: t2, name: l2 } = index.i.getWalletRouterData(), i2 = t2 == null ? void 0 : t2.native, c2 = t2 == null ? void 0 : t2.universal; + if (i2 && !o3) { + const u3 = index.i.formatNativeUrl(i2, e2, l2); + if (l2 === "Puzzle Wallet" && (r2 = window == null ? void 0 : window.aleo) != null && r2.connectPuzzle) { + const w2 = new URL(u3).searchParams, F = w2.get("uri"), T2 = w2.get("requestId"), j = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F, requestId: T2 ?? void 0, sessionTopic: j ?? void 0 } }); + } else + index.i.openHref(u3, "_self"); + } else if (c2) { + const u3 = index.i.formatUniversalUrl(c2, e2, l2); + if (l2 === "Puzzle Wallet" && (a2 = window == null ? void 0 : window.aleo) != null && a2.connectPuzzle) { + const w2 = new URL(u3).searchParams, F = w2.get("uri"), T2 = w2.get("requestId"), j = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F, requestId: T2 ?? void 0, sessionTopic: j ?? void 0 } }); + } else + index.i.openHref(u3, "_self"); } } openMobileApp(e2 = false) { - const { walletConnectUri: o3 } = index.p.state, r2 = index.a.getWalletRouterData(); - c.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); + const { walletConnectUri: o3 } = index.p.state, r2 = index.i.getWalletRouterData(); + s2.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); } onGoToAppStore(e2) { - e2 && index.a.openHref(e2, "_blank"); + e2 && index.i.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - app: a2, - mobile: t2 - } = index.a.getWalletRouterData(), { isWeb: l$12 } = c.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, s2 = t2 == null ? void 0 : t2.universal; - return x`Retry${s2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; + const { name: e2, id: o3, image_id: r2, app: a2, mobile: t2 } = index.i.getWalletRouterData(), { isWeb: l$12 } = s2.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, c2 = t2 == null ? void 0 : t2.universal; + return x`Retry${c2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; } }; -he.styles = [h.globalCss, Go], Ye([t$1()], he.prototype, "isError", 2), he = Ye([e$2("wcm-mobile-connecting-view")], he); +ge.styles = [h.globalCss, Go], Ye([t$1()], ge.prototype, "isError", 2), ge = Ye([e$2("wcm-mobile-connecting-view")], ge); const er = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var tr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, rr = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? or(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && tr(o3, r2, t2), t2; +var rr = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let je = class extends s { +let Ne = class extends s$1 { render() { - const { name: e2, id: o3, image_id: r2 } = index.a.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; + const { name: e2, id: o3, image_id: r2 } = index.i.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; } }; -je.styles = [h.globalCss, er], je = rr([e$2("wcm-mobile-qr-connecting-view")], je); -var ar = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, ir = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? lr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ar(o3, r2, t2), t2; +Ne.styles = [h.globalCss, er], Ne = rr([e$2("wcm-mobile-qr-connecting-view")], Ne); +var ir = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let _e = class extends s { +let Ze = class extends s$1 { render() { - return x``; + return x``; } }; -_e.styles = [h.globalCss], _e = ir([e$2("wcm-qrcode-view")], _e); +Ze.styles = [h.globalCss], Ze = ir([e$2("wcm-qrcode-view")], Ze); const nr = i$3`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`; -var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, ie = (e2, o3, r2, a2) => { +var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? sr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && cr(o3, r2, t2), t2; }; -const De = 40; -let U = class extends s { +const ze = 40; +let H2 = class extends s$1 { constructor() { - super(...arguments), this.loading = !index.te.state.wallets.listings.length, this.firstFetch = !index.te.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = c.debounce((e2) => { + super(...arguments), this.loading = !index.te.state.wallets.listings.length, this.firstFetch = !index.te.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = s2.debounce((e2) => { e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, index.te.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), index.te.resetSearch()); }); } @@ -4461,7 +4238,7 @@ let U = class extends s { (e2 = this.intersectionObserver) == null || e2.disconnect(); } get placeholderEl() { - return c.getShadowRootElement(this, ".wcm-placeholder-block"); + return s2.getShadowRootElement(this, ".wcm-placeholder-block"); } createPaginationObserver() { this.intersectionObserver = new IntersectionObserver(([e2]) => { @@ -4470,33 +4247,24 @@ let U = class extends s { } isLastPage() { const { wallets: e2, search: o3 } = index.te.state, { listings: r2, total: a2 } = this.search ? o3 : e2; - return a2 <= De || r2.length >= a2; + return a2 <= ze || r2.length >= a2; } async fetchWallets() { var e2; const { wallets: o3, search: r2 } = index.te.state, { listings: a2, total: t2, page: l2 } = this.search ? r2 : o3; - if (!this.endReached && (this.firstFetch || t2 > De && a2.length < t2)) + if (!this.endReached && (this.firstFetch || t2 > ze && a2.length < t2)) try { this.loading = true; - const i2 = (e2 = index.p.state.chains) == null ? void 0 : e2.join(","), { listings: s2 } = await index.te.getWallets({ - page: this.firstFetch ? 1 : l2 + 1, - entries: De, - search: this.search, - version: 2, - chains: i2 - }), $2 = s2.map((f2) => c.getWalletIcon(f2)); - await Promise.all([ - ...$2.map(async (f2) => c.preloadImage(f2)), - index.a.wait(300) - ]), this.endReached = this.isLastPage(); + const i2 = (e2 = index.p.state.chains) == null ? void 0 : e2.join(","), { listings: c2 } = await index.te.getWallets({ page: this.firstFetch ? 1 : l2 + 1, entries: ze, search: this.search, version: 2, chains: i2 }), u3 = c2.map((w2) => s2.getWalletIcon(w2)); + await Promise.all([...u3.map(async (w2) => s2.preloadImage(w2)), index.i.wait(300)]), this.endReached = this.isLastPage(); } catch (i2) { - console.error(i2), index.oe.openToast(c.getErrorMessage(i2), "error"); + console.error(i2), index.oe.openToast(s2.getErrorMessage(i2), "error"); } finally { this.loading = false, this.firstFetch = false; } } onConnect(e2) { - index.a.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + index.i.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onSearchChange(e2) { const { value: o3 } = e2.target; @@ -4504,57 +4272,42 @@ let U = class extends s { } render() { const { wallets: e2, search: o$12 } = index.te.state, { listings: r2 } = this.search ? o$12 : e2, a2 = this.loading && !r2.length, t2 = this.search.length >= 3; - let l2 = Z2.manualWalletsTemplate(), i2 = Z2.recomendedWalletsTemplate(true); - t2 && (l2 = l2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search)), i2 = i2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search))); - const s2 = !this.loading && !r2.length && !i2.length, $2 = { - "wcm-loading": a2, - "wcm-end-reached": this.endReached || !this.loading, - "wcm-empty": s2 - }; - return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((f2) => x`${f2 ? x`` : null}`)}
${s2 ? x`No results found` : null} ${!s2 && this.loading ? x`` : null}
`; + let l2 = S.manualWalletsTemplate(), i2 = S.recomendedWalletsTemplate(true); + t2 && (l2 = l2.filter(({ values: w2 }) => s2.caseSafeIncludes(w2[0], this.search)), i2 = i2.filter(({ values: w2 }) => s2.caseSafeIncludes(w2[0], this.search))); + const c2 = !this.loading && !r2.length && !i2.length, u3 = { "wcm-loading": a2, "wcm-end-reached": this.endReached || !this.loading, "wcm-empty": c2 }; + return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((w2) => x`${w2 ? x`` : null}`)}
${c2 ? x`No results found` : null} ${!c2 && this.loading ? x`` : null}
`; } }; -U.styles = [h.globalCss, nr], ie([t$1()], U.prototype, "loading", 2), ie([t$1()], U.prototype, "firstFetch", 2), ie([t$1()], U.prototype, "search", 2), ie([t$1()], U.prototype, "endReached", 2), U = ie([e$2("wcm-wallet-explorer-view")], U); +H2.styles = [h.globalCss, nr], se([t$1()], H2.prototype, "loading", 2), se([t$1()], H2.prototype, "firstFetch", 2), se([t$1()], H2.prototype, "search", 2), se([t$1()], H2.prototype, "endReached", 2), H2 = se([e$2("wcm-wallet-explorer-view")], H2); const dr = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var mr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? hr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var mr = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? wr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && mr(o3, r2, t2), t2; }; -let we = class extends s { +let ve = class extends s$1 { constructor() { super(), this.isError = false, this.openWebWallet(); } onFormatAndRedirect(e2) { - var _a; - const { desktop: o3, name: r2 } = index.a.getWalletRouterData(), a2 = o3 == null ? void 0 : o3.universal; - if (a2) { - const t2 = index.a.formatUniversalUrl(a2, e2, r2); - if (r2 === "Puzzle Wallet" && window && ((_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient)) { - const url = new URL(t2); - const params = url.searchParams; - const wcUri = params.get("uri"); - const requestId = params.get("requestId"); - const sessionTopic = params.get("sessionTopic"); - void window.aleo.connectPuzzle({ - wc: { - uri: wcUri, - requestId: requestId ?? void 0, - sessionTopic: sessionTopic ?? void 0 - } - }); - } else { - index.a.openHref(t2, "_blank"); - } + var o3; + const { desktop: r2, name: a2 } = index.i.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.universal; + if (t2) { + const l2 = index.i.formatUniversalUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + index.i.openHref(l2, "_blank"); } } openWebWallet() { - const { walletConnectUri: e2 } = index.p.state, o3 = index.a.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = index.p.state, o3 = index.i.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = index.a.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = c.getCachedRouterWalletPlatforms(), l$12 = index.a.isMobile(); - return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; + const { name: e2, id: o3, image_id: r2 } = index.i.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = s2.getCachedRouterWalletPlatforms(), l$12 = index.i.isMobile(); + return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; } }; -we.styles = [h.globalCss, dr], Ge([t$1()], we.prototype, "isError", 2), we = Ge([e$2("wcm-web-connecting-view")], we); +ve.styles = [h.globalCss, dr], Ge([t$1()], ve.prototype, "isError", 2), ve = Ge([e$2("wcm-web-connecting-view")], ve); diff --git a/packages/core/dist/index-Cc7iYKrS.cjs b/packages/core/dist/index-Cc7iYKrS.cjs new file mode 100644 index 00000000..cc9581c3 --- /dev/null +++ b/packages/core/dist/index-Cc7iYKrS.cjs @@ -0,0 +1,24685 @@ +"use strict"; +const t = Symbol(); +const s$1 = Object.getPrototypeOf, c$4 = /* @__PURE__ */ new WeakMap(), l$2 = (e2) => e2 && (c$4.has(e2) ? c$4.get(e2) : s$1(e2) === Object.prototype || s$1(e2) === Array.prototype), y$5 = (e2) => l$2(e2) && e2[t] || null, h$3 = (e2, t2 = true) => { + c$4.set(e2, t2); +}; +var define_import_meta_env_default = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false }; +const isObject = (x2) => typeof x2 === "object" && x2 !== null; +const proxyStateMap = /* @__PURE__ */ new WeakMap(); +const refSet = /* @__PURE__ */ new WeakSet(); +const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x2) => isObject(x2) && !refSet.has(x2) && (Array.isArray(x2) || !(Symbol.iterator in x2)) && !(x2 instanceof WeakMap) && !(x2 instanceof WeakSet) && !(x2 instanceof Error) && !(x2 instanceof Number) && !(x2 instanceof Date) && !(x2 instanceof String) && !(x2 instanceof RegExp) && !(x2 instanceof ArrayBuffer), defaultHandlePromise = (promise) => { + switch (promise.status) { + case "fulfilled": + return promise.value; + case "rejected": + throw promise.reason; + default: + throw promise; + } +}, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version2, handlePromise = defaultHandlePromise) => { + const cache = snapCache.get(target); + if ((cache == null ? void 0 : cache[0]) === version2) { + return cache[1]; + } + const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); + h$3(snap, true); + snapCache.set(target, [version2, snap]); + Reflect.ownKeys(target).forEach((key) => { + if (Object.getOwnPropertyDescriptor(snap, key)) { + return; + } + const value = Reflect.get(target, key); + const desc = { + value, + enumerable: true, + // This is intentional to avoid copying with proxy-compare. + // It's still non-writable, so it avoids assigning a value. + configurable: true + }; + if (refSet.has(value)) { + h$3(value, false); + } else if (value instanceof Promise) { + delete desc.value; + desc.get = () => handlePromise(value); + } else if (proxyStateMap.has(value)) { + const [target2, ensureVersion] = proxyStateMap.get( + value + ); + desc.value = createSnapshot( + target2, + ensureVersion(), + handlePromise + ); + } + Object.defineProperty(snap, key, desc); + }); + return Object.preventExtensions(snap); +}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { + if (!isObject(initialObject)) { + throw new Error("object required"); + } + const found = proxyCache.get(initialObject); + if (found) { + return found; + } + let version2 = versionHolder[0]; + const listeners2 = /* @__PURE__ */ new Set(); + const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => { + if (version2 !== nextVersion) { + version2 = nextVersion; + listeners2.forEach((listener) => listener(op, nextVersion)); + } + }; + let checkVersion = versionHolder[1]; + const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => { + if (checkVersion !== nextCheckVersion && !listeners2.size) { + checkVersion = nextCheckVersion; + propProxyStates.forEach(([propProxyState]) => { + const propVersion = propProxyState[1](nextCheckVersion); + if (propVersion > version2) { + version2 = propVersion; + } + }); + } + return version2; + }; + const createPropListener = (prop) => (op, nextVersion) => { + const newOp = [...op]; + newOp[1] = [prop, ...newOp[1]]; + notifyUpdate(newOp, nextVersion); + }; + const propProxyStates = /* @__PURE__ */ new Map(); + const addPropListener = (prop, propProxyState) => { + if ((define_import_meta_env_default ? "production" : void 0) !== "production" && propProxyStates.has(prop)) { + throw new Error("prop listener already exists"); + } + if (listeners2.size) { + const remove = propProxyState[3](createPropListener(prop)); + propProxyStates.set(prop, [propProxyState, remove]); + } else { + propProxyStates.set(prop, [propProxyState]); + } + }; + const removePropListener = (prop) => { + var _a2; + const entry = propProxyStates.get(prop); + if (entry) { + propProxyStates.delete(prop); + (_a2 = entry[1]) == null ? void 0 : _a2.call(entry); + } + }; + const addListener2 = (listener) => { + listeners2.add(listener); + if (listeners2.size === 1) { + propProxyStates.forEach(([propProxyState, prevRemove], prop) => { + if ((define_import_meta_env_default ? "production" : void 0) !== "production" && prevRemove) { + throw new Error("remove already exists"); + } + const remove = propProxyState[3](createPropListener(prop)); + propProxyStates.set(prop, [propProxyState, remove]); + }); + } + const removeListener2 = () => { + listeners2.delete(listener); + if (listeners2.size === 0) { + propProxyStates.forEach(([propProxyState, remove], prop) => { + if (remove) { + remove(); + propProxyStates.set(prop, [propProxyState]); + } + }); + } + }; + return removeListener2; + }; + const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); + const handler = { + deleteProperty(target, prop) { + const prevValue = Reflect.get(target, prop); + removePropListener(prop); + const deleted = Reflect.deleteProperty(target, prop); + if (deleted) { + notifyUpdate(["delete", [prop], prevValue]); + } + return deleted; + }, + set(target, prop, value, receiver) { + const hasPrevValue = Reflect.has(target, prop); + const prevValue = Reflect.get(target, prop, receiver); + if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { + return true; + } + removePropListener(prop); + if (isObject(value)) { + value = y$5(value) || value; + } + let nextValue = value; + if (value instanceof Promise) { + value.then((v3) => { + value.status = "fulfilled"; + value.value = v3; + notifyUpdate(["resolve", [prop], v3]); + }).catch((e2) => { + value.status = "rejected"; + value.reason = e2; + notifyUpdate(["reject", [prop], e2]); + }); + } else { + if (!proxyStateMap.has(value) && canProxy(value)) { + nextValue = proxyFunction(value); + } + const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); + if (childProxyState) { + addPropListener(prop, childProxyState); + } + } + Reflect.set(target, prop, nextValue, receiver); + notifyUpdate(["set", [prop], value, prevValue]); + return true; + } + }; + const proxyObject = newProxy(baseObject, handler); + proxyCache.set(initialObject, proxyObject); + const proxyState = [ + baseObject, + ensureVersion, + createSnapshot, + addListener2 + ]; + proxyStateMap.set(proxyObject, proxyState); + Reflect.ownKeys(initialObject).forEach((key) => { + const desc = Object.getOwnPropertyDescriptor( + initialObject, + key + ); + if ("value" in desc) { + proxyObject[key] = initialObject[key]; + delete desc.value; + delete desc.writable; + } + Object.defineProperty(baseObject, key, desc); + }); + return proxyObject; +}) => [ + // public functions + proxyFunction, + // shared state + proxyStateMap, + refSet, + // internal things + objectIs, + newProxy, + canProxy, + defaultHandlePromise, + snapCache, + createSnapshot, + proxyCache, + versionHolder +]; +const [defaultProxyFunction] = buildProxyFunction(); +function proxy(initialObject = {}) { + return defaultProxyFunction(initialObject); +} +function subscribe(proxyObject, callback, notifyInSync) { + const proxyState = proxyStateMap.get(proxyObject); + if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !proxyState) { + console.warn("Please use proxy object"); + } + let promise; + const ops = []; + const addListener2 = proxyState[3]; + let isListenerActive = false; + const listener = (op) => { + ops.push(op); + if (!promise) { + promise = Promise.resolve().then(() => { + promise = void 0; + if (isListenerActive) { + callback(ops.splice(0)); + } + }); + } + }; + const removeListener2 = addListener2(listener); + isListenerActive = true; + return () => { + isListenerActive = false; + removeListener2(); + }; +} +function snapshot(proxyObject, handlePromise) { + const proxyState = proxyStateMap.get(proxyObject); + if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !proxyState) { + console.warn("Please use proxy object"); + } + const [target, ensureVersion, createSnapshot] = proxyState; + return createSnapshot(target, ensureVersion(), handlePromise); +} +const o$1 = proxy({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), T$2 = { state: o$1, subscribe(e2) { + return subscribe(o$1, () => e2(o$1)); +}, push(e2, t2) { + e2 !== o$1.view && (o$1.view = e2, t2 && (o$1.data = t2), o$1.history.push(e2)); +}, reset(e2) { + o$1.view = e2, o$1.history = [e2]; +}, replace(e2) { + o$1.history.length > 1 && (o$1.history[o$1.history.length - 1] = e2, o$1.view = e2); +}, goBack() { + if (o$1.history.length > 1) { + o$1.history.pop(); + const [e2] = o$1.history.slice(-1); + o$1.view = e2; + } +}, setData(e2) { + o$1.data = e2; +} }, i$1 = { WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", WCM_VERSION: "WCM_VERSION", RECOMMENDED_WALLET_AMOUNT: 9, isMobile() { + return typeof window < "u" ? Boolean(window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : false; +}, isAndroid() { + return i$1.isMobile() && navigator.userAgent.toLowerCase().includes("android"); +}, isIos() { + const e2 = navigator.userAgent.toLowerCase(); + return i$1.isMobile() && (e2.includes("iphone") || e2.includes("ipad")); +}, isHttpUrl(e2) { + return e2.startsWith("http://") || e2.startsWith("https://"); +}, isArray(e2) { + return Array.isArray(e2) && e2.length > 0; +}, formatNativeUrl(e2, t2, s2) { + if (i$1.isHttpUrl(e2)) + return this.formatUniversalUrl(e2, t2, s2); + let n4 = e2; + n4.includes("://") || (n4 = e2.replaceAll("/", "").replaceAll(":", ""), n4 = `${n4}://`), n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s2); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; +}, formatUniversalUrl(e2, t2, s2) { + if (!i$1.isHttpUrl(e2)) + return this.formatNativeUrl(e2, t2, s2); + let n4 = e2; + n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s2); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; +}, async wait(e2) { + return new Promise((t2) => { + setTimeout(t2, e2); + }); +}, openHref(e2, t2) { + window.open(e2, t2, "noreferrer noopener"); +}, setWalletConnectDeepLink(e2, t2) { + try { + localStorage.setItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: e2, name: t2 })); + } catch { + console.info("Unable to set WalletConnect deep link"); + } +}, setWalletConnectAndroidDeepLink(e2) { + try { + const [t2] = e2.split("?"); + localStorage.setItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: t2, name: "Android" })); + } catch { + console.info("Unable to set WalletConnect android deep link"); + } +}, removeWalletConnectDeepLink() { + try { + localStorage.removeItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE); + } catch { + console.info("Unable to remove WalletConnect deep link"); + } +}, setModalVersionInStorage() { + try { + typeof localStorage < "u" && localStorage.setItem(i$1.WCM_VERSION, "0.0.6"); + } catch { + console.info("Unable to set Web3Modal version in storage"); + } +}, getWalletRouterData() { + var e2; + const t2 = (e2 = T$2.state.data) == null ? void 0 : e2.Wallet; + if (!t2) + throw new Error('Missing "Wallet" view data'); + return t2; +} }, _$2 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), a$2 = proxy({ enabled: _$2, userSessionId: "", events: [], connectedWalletId: void 0 }), R$1 = { state: a$2, subscribe(e2) { + return subscribe(a$2.events, () => e2(snapshot(a$2.events[a$2.events.length - 1]))); +}, initialize() { + a$2.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (a$2.userSessionId = crypto.randomUUID()); +}, setConnectedWalletId(e2) { + a$2.connectedWalletId = e2; +}, click(e2) { + if (a$2.enabled) { + const t2 = { type: "CLICK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +}, track(e2) { + if (a$2.enabled) { + const t2 = { type: "TRACK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +}, view(e2) { + if (a$2.enabled) { + const t2 = { type: "VIEW", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +} }, c$3 = proxy({ chains: void 0, walletConnectUri: void 0, isAuth: false, isCustomDesktop: false, isCustomMobile: false, isDataLoaded: false, isUiLoaded: false }), p$2 = { state: c$3, subscribe(e2) { + return subscribe(c$3, () => e2(c$3)); +}, setChains(e2) { + c$3.chains = e2; +}, setWalletConnectUri(e2) { + c$3.walletConnectUri = e2; +}, setIsCustomDesktop(e2) { + c$3.isCustomDesktop = e2; +}, setIsCustomMobile(e2) { + c$3.isCustomMobile = e2; +}, setIsDataLoaded(e2) { + c$3.isDataLoaded = e2; +}, setIsUiLoaded(e2) { + c$3.isUiLoaded = e2; +}, setIsAuth(e2) { + c$3.isAuth = e2; +} }, W = proxy({ projectId: "", mobileWallets: void 0, desktopWallets: void 0, walletImages: void 0, chains: void 0, enableAuthMode: false, enableExplorer: true, explorerExcludedWalletIds: void 0, explorerRecommendedWalletIds: void 0, termsOfServiceUrl: void 0, privacyPolicyUrl: void 0 }), y$4 = { state: W, subscribe(e2) { + return subscribe(W, () => e2(W)); +}, setConfig(e2) { + var t2, s2; + R$1.initialize(), p$2.setChains(e2.chains), p$2.setIsAuth(Boolean(e2.enableAuthMode)), p$2.setIsCustomMobile(Boolean((t2 = e2.mobileWallets) == null ? void 0 : t2.length)), p$2.setIsCustomDesktop(Boolean((s2 = e2.desktopWallets) == null ? void 0 : s2.length)), i$1.setModalVersionInStorage(), Object.assign(W, e2); +} }; +var V$3 = Object.defineProperty, D$2 = Object.getOwnPropertySymbols, H = Object.prototype.hasOwnProperty, B$1 = Object.prototype.propertyIsEnumerable, M$1 = (e2, t2, s2) => t2 in e2 ? V$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, K$4 = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + H.call(t2, s2) && M$1(e2, s2, t2[s2]); + if (D$2) + for (var s2 of D$2(t2)) + B$1.call(t2, s2) && M$1(e2, s2, t2[s2]); + return e2; +}; +const L$5 = "https://explorer-api.walletconnect.com", E$3 = "wcm", O$3 = "js-0.0.6"; +async function w$4(e2, t2) { + const s2 = K$4({ sdkType: E$3, sdkVersion: O$3 }, t2), n4 = new URL(e2, L$5); + return n4.searchParams.append("projectId", y$4.state.projectId), Object.entries(s2).forEach(([r3, l2]) => { + l2 && n4.searchParams.append(r3, String(l2)); + }), (await fetch(n4)).json(); +} +const m$2 = { async getDesktopListings(e2) { + return w$4("/w3m/v1/getDesktopListings", e2); +}, async getMobileListings(e2) { + return w$4("/w3m/v1/getMobileListings", e2); +}, async getInjectedListings(e2) { + return w$4("/w3m/v1/getInjectedListings", e2); +}, async getAllListings(e2) { + return w$4("/w3m/v1/getAllListings", e2); +}, getWalletImageUrl(e2) { + return `${L$5}/w3m/v1/getWalletImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; +}, getAssetImageUrl(e2) { + return `${L$5}/w3m/v1/getAssetImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; +} }; +var z$4 = Object.defineProperty, j$4 = Object.getOwnPropertySymbols, J$1 = Object.prototype.hasOwnProperty, q$3 = Object.prototype.propertyIsEnumerable, k$4 = (e2, t2, s2) => t2 in e2 ? z$4(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, F$2 = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + J$1.call(t2, s2) && k$4(e2, s2, t2[s2]); + if (j$4) + for (var s2 of j$4(t2)) + q$3.call(t2, s2) && k$4(e2, s2, t2[s2]); + return e2; +}; +const N$2 = i$1.isMobile(), d$4 = proxy({ wallets: { listings: [], total: 0, page: 1 }, search: { listings: [], total: 0, page: 1 }, recomendedWallets: [] }), te$1 = { state: d$4, async getRecomendedWallets() { + const { explorerRecommendedWalletIds: e2, explorerExcludedWalletIds: t2 } = y$4.state; + if (e2 === "NONE" || t2 === "ALL" && !e2) + return d$4.recomendedWallets; + if (i$1.isArray(e2)) { + const s2 = { recommendedIds: e2.join(",") }, { listings: n4 } = await m$2.getAllListings(s2), r3 = Object.values(n4); + n4 && r3.sort && r3.sort((l2, v3) => { + const b3 = e2.indexOf(l2.id), f3 = e2.indexOf(v3.id); + return b3 - f3; + }), d$4.recomendedWallets = r3; + } else { + const { chains: s2, isAuth: n4 } = p$2.state, r3 = s2 == null ? void 0 : s2.join(","), l2 = i$1.isArray(t2), v3 = { page: 1, sdks: n4 ? "auth_v1" : void 0, entries: i$1.RECOMMENDED_WALLET_AMOUNT, chains: r3, version: 2, excludedIds: l2 ? t2.join(",") : void 0 }, { listings: b3 } = N$2 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); + d$4.recomendedWallets = Object.values(b3); + } + return d$4.recomendedWallets; +}, async getWallets(e2) { + const t2 = F$2({}, e2), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n4 } = y$4.state, { recomendedWallets: r3 } = d$4; + if (n4 === "ALL") + return d$4.wallets; + r3.length ? t2.excludedIds = r3.map((x2) => x2.id).join(",") : i$1.isArray(s2) && (t2.excludedIds = s2.join(",")), i$1.isArray(n4) && (t2.excludedIds = [t2.excludedIds, n4].filter(Boolean).join(",")), p$2.state.isAuth && (t2.sdks = "auth_v1"); + const { page: l2, search: v3 } = e2, { listings: b3, total: f3 } = N$2 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; + return d$4[U2] = { listings: [...d$4[U2].listings, ...A2], total: f3, page: l2 ?? 1 }, { listings: A2, total: f3 }; +}, getWalletImageUrl(e2) { + return m$2.getWalletImageUrl(e2); +}, getAssetImageUrl(e2) { + return m$2.getAssetImageUrl(e2); +}, resetSearch() { + d$4.search = { listings: [], total: 0, page: 1 }; +} }, I$3 = proxy({ open: false }), se$3 = { state: I$3, subscribe(e2) { + return subscribe(I$3, () => e2(I$3)); +}, async open(e2) { + return new Promise((t2) => { + const { isUiLoaded: s2, isDataLoaded: n4 } = p$2.state; + if (i$1.removeWalletConnectDeepLink(), p$2.setWalletConnectUri(e2 == null ? void 0 : e2.uri), p$2.setChains(e2 == null ? void 0 : e2.chains), T$2.reset("ConnectWallet"), s2 && n4) + I$3.open = true, t2(); + else { + const r3 = setInterval(() => { + const l2 = p$2.state; + l2.isUiLoaded && l2.isDataLoaded && (clearInterval(r3), I$3.open = true, t2()); + }, 200); + } + }); +}, close() { + I$3.open = false; +} }; +var G$1 = Object.defineProperty, $ = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$1 = Object.prototype.propertyIsEnumerable, S$4 = (e2, t2, s2) => t2 in e2 ? G$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, Y = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + Q$3.call(t2, s2) && S$4(e2, s2, t2[s2]); + if ($) + for (var s2 of $(t2)) + X$1.call(t2, s2) && S$4(e2, s2, t2[s2]); + return e2; +}; +function Z$1() { + return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; +} +const C$3 = proxy({ themeMode: Z$1() ? "dark" : "light" }), ne$3 = { state: C$3, subscribe(e2) { + return subscribe(C$3, () => e2(C$3)); +}, setThemeConfig(e2) { + const { themeMode: t2, themeVariables: s2 } = e2; + t2 && (C$3.themeMode = t2), s2 && (C$3.themeVariables = Y({}, s2)); +} }, g$3 = proxy({ open: false, message: "", variant: "success" }), oe$2 = { state: g$3, subscribe(e2) { + return subscribe(g$3, () => e2(g$3)); +}, openToast(e2, t2) { + g$3.open = true, g$3.message = e2, g$3.variant = t2; +}, closeToast() { + g$3.open = false; +} }; +let d$3 = class d { + constructor(e2) { + this.openModal = se$3.open, this.closeModal = se$3.close, this.subscribeModal = se$3.subscribe, this.setTheme = ne$3.setThemeConfig, ne$3.setThemeConfig(e2), y$4.setConfig(e2), this.initUi(); + } + async initUi() { + if (typeof window < "u") { + await Promise.resolve().then(() => require("./index-CBnMNmep.cjs")); + const e2 = document.createElement("wcm-modal"); + document.body.insertAdjacentElement("beforeend", e2), p$2.setIsUiLoaded(true); + } + } +}; +var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; +function getDefaultExportFromCjs(x2) { + return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; +} +function getAugmentedNamespace(n4) { + if (n4.__esModule) + return n4; + var f3 = n4.default; + if (typeof f3 == "function") { + var a3 = function a4() { + if (this instanceof a4) { + return Reflect.construct(f3, arguments, this.constructor); + } + return f3.apply(this, arguments); + }; + a3.prototype = f3.prototype; + } else + a3 = {}; + Object.defineProperty(a3, "__esModule", { value: true }); + Object.keys(n4).forEach(function(k2) { + var d5 = Object.getOwnPropertyDescriptor(n4, k2); + Object.defineProperty(a3, k2, d5.get ? d5 : { + enumerable: true, + get: function() { + return n4[k2]; + } + }); + }); + return a3; +} +var events = { exports: {} }; +var R = typeof Reflect === "object" ? Reflect : null; +var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); +}; +var ReflectOwnKeys; +if (R && typeof R.ownKeys === "function") { + ReflectOwnKeys = R.ownKeys; +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys2(target) { + return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys2(target) { + return Object.getOwnPropertyNames(target); + }; +} +function ProcessEmitWarning(warning) { + if (console && console.warn) + console.warn(warning); +} +var NumberIsNaN = Number.isNaN || function NumberIsNaN2(value) { + return value !== value; +}; +function EventEmitter() { + EventEmitter.init.call(this); +} +events.exports = EventEmitter; +events.exports.once = once2; +EventEmitter.EventEmitter = EventEmitter; +EventEmitter.prototype._events = void 0; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = void 0; +var defaultMaxListeners = 10; +function checkListener(listener) { + if (typeof listener !== "function") { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } +} +Object.defineProperty(EventEmitter, "defaultMaxListeners", { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + "."); + } + defaultMaxListeners = arg; + } +}); +EventEmitter.init = function() { + if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) { + this._events = /* @__PURE__ */ Object.create(null); + this._eventsCount = 0; + } + this._maxListeners = this._maxListeners || void 0; +}; +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n4) { + if (typeof n4 !== "number" || n4 < 0 || NumberIsNaN(n4)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n4 + "."); + } + this._maxListeners = n4; + return this; +}; +function _getMaxListeners(that) { + if (that._maxListeners === void 0) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return _getMaxListeners(this); +}; +EventEmitter.prototype.emit = function emit(type2) { + var args = []; + for (var i2 = 1; i2 < arguments.length; i2++) + args.push(arguments[i2]); + var doError = type2 === "error"; + var events2 = this._events; + if (events2 !== void 0) + doError = doError && events2.error === void 0; + else if (!doError) + return false; + if (doError) { + var er2; + if (args.length > 0) + er2 = args[0]; + if (er2 instanceof Error) { + throw er2; + } + var err = new Error("Unhandled error." + (er2 ? " (" + er2.message + ")" : "")); + err.context = er2; + throw err; + } + var handler = events2[type2]; + if (handler === void 0) + return false; + if (typeof handler === "function") { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners2 = arrayClone(handler, len); + for (var i2 = 0; i2 < len; ++i2) + ReflectApply(listeners2[i2], this, args); + } + return true; +}; +function _addListener(target, type2, listener, prepend) { + var m3; + var events2; + var existing; + checkListener(listener); + events2 = target._events; + if (events2 === void 0) { + events2 = target._events = /* @__PURE__ */ Object.create(null); + target._eventsCount = 0; + } else { + if (events2.newListener !== void 0) { + target.emit( + "newListener", + type2, + listener.listener ? listener.listener : listener + ); + events2 = target._events; + } + existing = events2[type2]; + } + if (existing === void 0) { + existing = events2[type2] = listener; + ++target._eventsCount; + } else { + if (typeof existing === "function") { + existing = events2[type2] = prepend ? [listener, existing] : [existing, listener]; + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + m3 = _getMaxListeners(target); + if (m3 > 0 && existing.length > m3 && !existing.warned) { + existing.warned = true; + var w3 = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type2) + " listeners added. Use emitter.setMaxListeners() to increase limit"); + w3.name = "MaxListenersExceededWarning"; + w3.emitter = target; + w3.type = type2; + w3.count = existing.length; + ProcessEmitWarning(w3); + } + } + return target; +} +EventEmitter.prototype.addListener = function addListener(type2, listener) { + return _addListener(this, type2, listener, false); +}; +EventEmitter.prototype.on = EventEmitter.prototype.addListener; +EventEmitter.prototype.prependListener = function prependListener(type2, listener) { + return _addListener(this, type2, listener, true); +}; +function onceWrapper() { + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + if (arguments.length === 0) + return this.listener.call(this.target); + return this.listener.apply(this.target, arguments); + } +} +function _onceWrap(target, type2, listener) { + var state = { fired: false, wrapFn: void 0, target, type: type2, listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} +EventEmitter.prototype.once = function once(type2, listener) { + checkListener(listener); + this.on(type2, _onceWrap(this, type2, listener)); + return this; +}; +EventEmitter.prototype.prependOnceListener = function prependOnceListener(type2, listener) { + checkListener(listener); + this.prependListener(type2, _onceWrap(this, type2, listener)); + return this; +}; +EventEmitter.prototype.removeListener = function removeListener(type2, listener) { + var list, events2, position, i2, originalListener; + checkListener(listener); + events2 = this._events; + if (events2 === void 0) + return this; + list = events2[type2]; + if (list === void 0) + return this; + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = /* @__PURE__ */ Object.create(null); + else { + delete events2[type2]; + if (events2.removeListener) + this.emit("removeListener", type2, list.listener || listener); + } + } else if (typeof list !== "function") { + position = -1; + for (i2 = list.length - 1; i2 >= 0; i2--) { + if (list[i2] === listener || list[i2].listener === listener) { + originalListener = list[i2].listener; + position = i2; + break; + } + } + if (position < 0) + return this; + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + if (list.length === 1) + events2[type2] = list[0]; + if (events2.removeListener !== void 0) + this.emit("removeListener", type2, originalListener || listener); + } + return this; +}; +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; +EventEmitter.prototype.removeAllListeners = function removeAllListeners(type2) { + var listeners2, events2, i2; + events2 = this._events; + if (events2 === void 0) + return this; + if (events2.removeListener === void 0) { + if (arguments.length === 0) { + this._events = /* @__PURE__ */ Object.create(null); + this._eventsCount = 0; + } else if (events2[type2] !== void 0) { + if (--this._eventsCount === 0) + this._events = /* @__PURE__ */ Object.create(null); + else + delete events2[type2]; + } + return this; + } + if (arguments.length === 0) { + var keys2 = Object.keys(events2); + var key; + for (i2 = 0; i2 < keys2.length; ++i2) { + key = keys2[i2]; + if (key === "removeListener") + continue; + this.removeAllListeners(key); + } + this.removeAllListeners("removeListener"); + this._events = /* @__PURE__ */ Object.create(null); + this._eventsCount = 0; + return this; + } + listeners2 = events2[type2]; + if (typeof listeners2 === "function") { + this.removeListener(type2, listeners2); + } else if (listeners2 !== void 0) { + for (i2 = listeners2.length - 1; i2 >= 0; i2--) { + this.removeListener(type2, listeners2[i2]); + } + } + return this; +}; +function _listeners(target, type2, unwrap) { + var events2 = target._events; + if (events2 === void 0) + return []; + var evlistener = events2[type2]; + if (evlistener === void 0) + return []; + if (typeof evlistener === "function") + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); +} +EventEmitter.prototype.listeners = function listeners(type2) { + return _listeners(this, type2, true); +}; +EventEmitter.prototype.rawListeners = function rawListeners(type2) { + return _listeners(this, type2, false); +}; +EventEmitter.listenerCount = function(emitter2, type2) { + if (typeof emitter2.listenerCount === "function") { + return emitter2.listenerCount(type2); + } else { + return listenerCount.call(emitter2, type2); + } +}; +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type2) { + var events2 = this._events; + if (events2 !== void 0) { + var evlistener = events2[type2]; + if (typeof evlistener === "function") { + return 1; + } else if (evlistener !== void 0) { + return evlistener.length; + } + } + return 0; +} +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; +function arrayClone(arr, n4) { + var copy = new Array(n4); + for (var i2 = 0; i2 < n4; ++i2) + copy[i2] = arr[i2]; + return copy; +} +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i2 = 0; i2 < ret.length; ++i2) { + ret[i2] = arr[i2].listener || arr[i2]; + } + return ret; +} +function once2(emitter2, name2) { + return new Promise(function(resolve, reject) { + function errorListener(err) { + emitter2.removeListener(name2, resolver); + reject(err); + } + function resolver() { + if (typeof emitter2.removeListener === "function") { + emitter2.removeListener("error", errorListener); + } + resolve([].slice.call(arguments)); + } + eventTargetAgnosticAddListener(emitter2, name2, resolver, { once: true }); + if (name2 !== "error") { + addErrorHandlerIfEventEmitter(emitter2, errorListener, { once: true }); + } + }); +} +function addErrorHandlerIfEventEmitter(emitter2, handler, flags) { + if (typeof emitter2.on === "function") { + eventTargetAgnosticAddListener(emitter2, "error", handler, flags); + } +} +function eventTargetAgnosticAddListener(emitter2, name2, listener, flags) { + if (typeof emitter2.on === "function") { + if (flags.once) { + emitter2.once(name2, listener); + } else { + emitter2.on(name2, listener); + } + } else if (typeof emitter2.addEventListener === "function") { + emitter2.addEventListener(name2, function wrapListener(arg) { + if (flags.once) { + emitter2.removeEventListener(name2, wrapListener); + } + listener(arg); + }); + } else { + throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter2); + } +} +var eventsExports = events.exports; +const EventEmitter$1 = /* @__PURE__ */ getDefaultExportFromCjs(eventsExports); +const suspectProtoRx = /"(?:_|\\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*:/; +const suspectConstructorRx = /"(?: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*:/; +const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/; +function jsonParseTransform(key, value) { + if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) { + warnKeyDropped(key); + return; + } + return value; +} +function warnKeyDropped(key) { + console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`); +} +function destr(value, options = {}) { + if (typeof value !== "string") { + return value; + } + const _value = value.trim(); + if ( + // eslint-disable-next-line unicorn/prefer-at + value[0] === '"' && value.endsWith('"') && !value.includes("\\") + ) { + return _value.slice(1, -1); + } + if (_value.length <= 9) { + const _lval = _value.toLowerCase(); + if (_lval === "true") { + return true; + } + if (_lval === "false") { + return false; + } + if (_lval === "undefined") { + return void 0; + } + if (_lval === "null") { + return null; + } + if (_lval === "nan") { + return Number.NaN; + } + if (_lval === "infinity") { + return Number.POSITIVE_INFINITY; + } + if (_lval === "-infinity") { + return Number.NEGATIVE_INFINITY; + } + } + if (!JsonSigRx.test(value)) { + if (options.strict) { + throw new SyntaxError("[destr] Invalid JSON"); + } + return value; + } + try { + if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) { + if (options.strict) { + throw new Error("[destr] Possible prototype pollution"); + } + return JSON.parse(value, jsonParseTransform); + } + return JSON.parse(value); + } catch (error) { + if (options.strict) { + throw error; + } + return value; + } +} +function wrapToPromise(value) { + if (!value || typeof value.then !== "function") { + return Promise.resolve(value); + } + return value; +} +function asyncCall(function_, ...arguments_) { + try { + return wrapToPromise(function_(...arguments_)); + } catch (error) { + return Promise.reject(error); + } +} +function isPrimitive(value) { + const type2 = typeof value; + return value === null || type2 !== "object" && type2 !== "function"; +} +function isPureObject(value) { + const proto = Object.getPrototypeOf(value); + return !proto || proto.isPrototypeOf(Object); +} +function stringify(value) { + if (isPrimitive(value)) { + return String(value); + } + if (isPureObject(value) || Array.isArray(value)) { + return JSON.stringify(value); + } + if (typeof value.toJSON === "function") { + return stringify(value.toJSON()); + } + throw new Error("[unstorage] Cannot stringify value!"); +} +function checkBufferSupport() { + if (typeof Buffer === void 0) { + throw new TypeError("[unstorage] Buffer is not supported!"); + } +} +const BASE64_PREFIX = "base64:"; +function serializeRaw(value) { + if (typeof value === "string") { + return value; + } + checkBufferSupport(); + const base642 = Buffer.from(value).toString("base64"); + return BASE64_PREFIX + base642; +} +function deserializeRaw(value) { + if (typeof value !== "string") { + return value; + } + if (!value.startsWith(BASE64_PREFIX)) { + return value; + } + checkBufferSupport(); + return Buffer.from(value.slice(BASE64_PREFIX.length), "base64"); +} +function normalizeKey(key) { + if (!key) { + return ""; + } + return key.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, ""); +} +function joinKeys(...keys2) { + return normalizeKey(keys2.join(":")); +} +function normalizeBaseKey(base3) { + base3 = normalizeKey(base3); + return base3 ? base3 + ":" : ""; +} +function defineDriver(factory) { + return factory; +} +const DRIVER_NAME = "memory"; +const memory = defineDriver(() => { + const data = /* @__PURE__ */ new Map(); + return { + name: DRIVER_NAME, + options: {}, + hasItem(key) { + return data.has(key); + }, + getItem(key) { + return data.get(key) ?? null; + }, + getItemRaw(key) { + return data.get(key) ?? null; + }, + setItem(key, value) { + data.set(key, value); + }, + setItemRaw(key, value) { + data.set(key, value); + }, + removeItem(key) { + data.delete(key); + }, + getKeys() { + return Array.from(data.keys()); + }, + clear() { + data.clear(); + }, + dispose() { + data.clear(); + } + }; +}); +function createStorage(options = {}) { + const context = { + mounts: { "": options.driver || memory() }, + mountpoints: [""], + watching: false, + watchListeners: [], + unwatch: {} + }; + const getMount = (key) => { + for (const base3 of context.mountpoints) { + if (key.startsWith(base3)) { + return { + base: base3, + relativeKey: key.slice(base3.length), + driver: context.mounts[base3] + }; + } + } + return { + base: "", + relativeKey: key, + driver: context.mounts[""] + }; + }; + const getMounts = (base3, includeParent) => { + return context.mountpoints.filter( + (mountpoint) => mountpoint.startsWith(base3) || includeParent && base3.startsWith(mountpoint) + ).map((mountpoint) => ({ + relativeBase: base3.length > mountpoint.length ? base3.slice(mountpoint.length) : void 0, + mountpoint, + driver: context.mounts[mountpoint] + })); + }; + const onChange = (event, key) => { + if (!context.watching) { + return; + } + key = normalizeKey(key); + for (const listener of context.watchListeners) { + listener(event, key); + } + }; + const startWatch = async () => { + if (context.watching) { + return; + } + context.watching = true; + for (const mountpoint in context.mounts) { + context.unwatch[mountpoint] = await watch$2( + context.mounts[mountpoint], + onChange, + mountpoint + ); + } + }; + const stopWatch = async () => { + if (!context.watching) { + return; + } + for (const mountpoint in context.unwatch) { + await context.unwatch[mountpoint](); + } + context.unwatch = {}; + context.watching = false; + }; + const runBatch = (items, commonOptions, cb) => { + const batches = /* @__PURE__ */ new Map(); + const getBatch = (mount) => { + let batch = batches.get(mount.base); + if (!batch) { + batch = { + driver: mount.driver, + base: mount.base, + items: [] + }; + batches.set(mount.base, batch); + } + return batch; + }; + for (const item of items) { + const isStringItem = typeof item === "string"; + const key = normalizeKey(isStringItem ? item : item.key); + const value = isStringItem ? void 0 : item.value; + const options2 = isStringItem || !item.options ? commonOptions : { ...commonOptions, ...item.options }; + const mount = getMount(key); + getBatch(mount).items.push({ + key, + value, + relativeKey: mount.relativeKey, + options: options2 + }); + } + return Promise.all([...batches.values()].map((batch) => cb(batch))).then( + (r3) => r3.flat() + ); + }; + const storage = { + // Item + hasItem(key, opts = {}) { + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + return asyncCall(driver.hasItem, relativeKey, opts); + }, + getItem(key, opts = {}) { + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + return asyncCall(driver.getItem, relativeKey, opts).then( + (value) => destr(value) + ); + }, + getItems(items, commonOptions) { + return runBatch(items, commonOptions, (batch) => { + if (batch.driver.getItems) { + return asyncCall( + batch.driver.getItems, + batch.items.map((item) => ({ + key: item.relativeKey, + options: item.options + })), + commonOptions + ).then( + (r3) => r3.map((item) => ({ + key: joinKeys(batch.base, item.key), + value: destr(item.value) + })) + ); + } + return Promise.all( + batch.items.map((item) => { + return asyncCall( + batch.driver.getItem, + item.relativeKey, + item.options + ).then((value) => ({ + key: item.key, + value: destr(value) + })); + }) + ); + }); + }, + getItemRaw(key, opts = {}) { + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + if (driver.getItemRaw) { + return asyncCall(driver.getItemRaw, relativeKey, opts); + } + return asyncCall(driver.getItem, relativeKey, opts).then( + (value) => deserializeRaw(value) + ); + }, + async setItem(key, value, opts = {}) { + if (value === void 0) { + return storage.removeItem(key); + } + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + if (!driver.setItem) { + return; + } + await asyncCall(driver.setItem, relativeKey, stringify(value), opts); + if (!driver.watch) { + onChange("update", key); + } + }, + async setItems(items, commonOptions) { + await runBatch(items, commonOptions, async (batch) => { + if (batch.driver.setItems) { + return asyncCall( + batch.driver.setItems, + batch.items.map((item) => ({ + key: item.relativeKey, + value: stringify(item.value), + options: item.options + })), + commonOptions + ); + } + if (!batch.driver.setItem) { + return; + } + await Promise.all( + batch.items.map((item) => { + return asyncCall( + batch.driver.setItem, + item.relativeKey, + stringify(item.value), + item.options + ); + }) + ); + }); + }, + async setItemRaw(key, value, opts = {}) { + if (value === void 0) { + return storage.removeItem(key, opts); + } + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + if (driver.setItemRaw) { + await asyncCall(driver.setItemRaw, relativeKey, value, opts); + } else if (driver.setItem) { + await asyncCall(driver.setItem, relativeKey, serializeRaw(value), opts); + } else { + return; + } + if (!driver.watch) { + onChange("update", key); + } + }, + async removeItem(key, opts = {}) { + if (typeof opts === "boolean") { + opts = { removeMeta: opts }; + } + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + if (!driver.removeItem) { + return; + } + await asyncCall(driver.removeItem, relativeKey, opts); + if (opts.removeMeta || opts.removeMata) { + await asyncCall(driver.removeItem, relativeKey + "$", opts); + } + if (!driver.watch) { + onChange("remove", key); + } + }, + // Meta + async getMeta(key, opts = {}) { + if (typeof opts === "boolean") { + opts = { nativeOnly: opts }; + } + key = normalizeKey(key); + const { relativeKey, driver } = getMount(key); + const meta = /* @__PURE__ */ Object.create(null); + if (driver.getMeta) { + Object.assign(meta, await asyncCall(driver.getMeta, relativeKey, opts)); + } + if (!opts.nativeOnly) { + const value = await asyncCall( + driver.getItem, + relativeKey + "$", + opts + ).then((value_) => destr(value_)); + if (value && typeof value === "object") { + if (typeof value.atime === "string") { + value.atime = new Date(value.atime); + } + if (typeof value.mtime === "string") { + value.mtime = new Date(value.mtime); + } + Object.assign(meta, value); + } + } + return meta; + }, + setMeta(key, value, opts = {}) { + return this.setItem(key + "$", value, opts); + }, + removeMeta(key, opts = {}) { + return this.removeItem(key + "$", opts); + }, + // Keys + async getKeys(base3, opts = {}) { + base3 = normalizeBaseKey(base3); + const mounts = getMounts(base3, true); + let maskedMounts = []; + const allKeys = []; + for (const mount of mounts) { + const rawKeys = await asyncCall( + mount.driver.getKeys, + mount.relativeBase, + opts + ); + const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p2) => key.startsWith(p2))); + allKeys.push(...keys2); + maskedMounts = [ + mount.mountpoint, + ...maskedMounts.filter((p2) => !p2.startsWith(mount.mountpoint)) + ]; + } + return base3 ? allKeys.filter((key) => key.startsWith(base3) && !key.endsWith("$")) : allKeys.filter((key) => !key.endsWith("$")); + }, + // Utils + async clear(base3, opts = {}) { + base3 = normalizeBaseKey(base3); + await Promise.all( + getMounts(base3, false).map(async (m3) => { + if (m3.driver.clear) { + return asyncCall(m3.driver.clear, m3.relativeBase, opts); + } + if (m3.driver.removeItem) { + const keys2 = await m3.driver.getKeys(m3.relativeBase || "", opts); + return Promise.all( + keys2.map((key) => m3.driver.removeItem(key, opts)) + ); + } + }) + ); + }, + async dispose() { + await Promise.all( + Object.values(context.mounts).map((driver) => dispose(driver)) + ); + }, + async watch(callback) { + await startWatch(); + context.watchListeners.push(callback); + return async () => { + context.watchListeners = context.watchListeners.filter( + (listener) => listener !== callback + ); + if (context.watchListeners.length === 0) { + await stopWatch(); + } + }; + }, + async unwatch() { + context.watchListeners = []; + await stopWatch(); + }, + // Mount + mount(base3, driver) { + base3 = normalizeBaseKey(base3); + if (base3 && context.mounts[base3]) { + throw new Error(`already mounted at ${base3}`); + } + if (base3) { + context.mountpoints.push(base3); + context.mountpoints.sort((a3, b3) => b3.length - a3.length); + } + context.mounts[base3] = driver; + if (context.watching) { + Promise.resolve(watch$2(driver, onChange, base3)).then((unwatcher) => { + context.unwatch[base3] = unwatcher; + }).catch(console.error); + } + return storage; + }, + async unmount(base3, _dispose = true) { + base3 = normalizeBaseKey(base3); + if (!base3 || !context.mounts[base3]) { + return; + } + if (context.watching && base3 in context.unwatch) { + context.unwatch[base3](); + delete context.unwatch[base3]; + } + if (_dispose) { + await dispose(context.mounts[base3]); + } + context.mountpoints = context.mountpoints.filter((key) => key !== base3); + delete context.mounts[base3]; + }, + getMount(key = "") { + key = normalizeKey(key) + ":"; + const m3 = getMount(key); + return { + driver: m3.driver, + base: m3.base + }; + }, + getMounts(base3 = "", opts = {}) { + base3 = normalizeKey(base3); + const mounts = getMounts(base3, opts.parents); + return mounts.map((m3) => ({ + driver: m3.driver, + base: m3.mountpoint + })); + } + }; + return storage; +} +function watch$2(driver, onChange, base3) { + return driver.watch ? driver.watch((event, key) => onChange(event, base3 + key)) : () => { + }; +} +async function dispose(driver) { + if (typeof driver.dispose === "function") { + await asyncCall(driver.dispose); + } +} +function promisifyRequest(request) { + return new Promise((resolve, reject) => { + request.oncomplete = request.onsuccess = () => resolve(request.result); + request.onabort = request.onerror = () => reject(request.error); + }); +} +function createStore(dbName, storeName) { + const request = indexedDB.open(dbName); + request.onupgradeneeded = () => request.result.createObjectStore(storeName); + const dbp = promisifyRequest(request); + return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName))); +} +let defaultGetStoreFunc; +function defaultGetStore() { + if (!defaultGetStoreFunc) { + defaultGetStoreFunc = createStore("keyval-store", "keyval"); + } + return defaultGetStoreFunc; +} +function get(key, customStore = defaultGetStore()) { + return customStore("readonly", (store) => promisifyRequest(store.get(key))); +} +function set$1(key, value, customStore = defaultGetStore()) { + return customStore("readwrite", (store) => { + store.put(value, key); + return promisifyRequest(store.transaction); + }); +} +function del(key, customStore = defaultGetStore()) { + return customStore("readwrite", (store) => { + store.delete(key); + return promisifyRequest(store.transaction); + }); +} +function clear(customStore = defaultGetStore()) { + return customStore("readwrite", (store) => { + store.clear(); + return promisifyRequest(store.transaction); + }); +} +function eachCursor(store, callback) { + store.openCursor().onsuccess = function() { + if (!this.result) + return; + callback(this.result); + this.result.continue(); + }; + return promisifyRequest(store.transaction); +} +function keys(customStore = defaultGetStore()) { + return customStore("readonly", (store) => { + if (store.getAllKeys) { + return promisifyRequest(store.getAllKeys()); + } + const items = []; + return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items); + }); +} +const JSONStringify = (data) => JSON.stringify(data, (_3, value) => typeof value === "bigint" ? value.toString() + "n" : value); +const JSONParse = (json) => { + const numbersBiggerThanMaxInt = /([\[:])?(\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; + const serializedData = json.replace(numbersBiggerThanMaxInt, '$1"$2n"$3'); + return JSON.parse(serializedData, (_3, value) => { + const isCustomFormatBigInt = typeof value === "string" && value.match(/^\d+n$/); + if (isCustomFormatBigInt) + return BigInt(value.substring(0, value.length - 1)); + return value; + }); +}; +function safeJsonParse(value) { + if (typeof value !== "string") { + throw new Error(`Cannot safe json parse value of type ${typeof value}`); + } + try { + return JSONParse(value); + } catch (_a2) { + return value; + } +} +function safeJsonStringify(value) { + return typeof value === "string" ? value : JSONStringify(value) || ""; +} +const x$1 = "idb-keyval"; +var z$3 = (i2 = {}) => { + const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e2 = (s2) => t2 + s2; + let n4; + return i2.dbName && i2.storeName && (n4 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { + return !(typeof await get(e2(s2), n4) > "u"); + }, async getItem(s2) { + return await get(e2(s2), n4) ?? null; + }, setItem(s2, a3) { + return set$1(e2(s2), a3, n4); + }, removeItem(s2) { + return del(e2(s2), n4); + }, getKeys() { + return keys(n4); + }, clear() { + return clear(n4); + } }; +}; +const D$1 = "WALLET_CONNECT_V2_INDEXED_DB", E$2 = "keyvaluestorage"; +let _$1 = class _ { + constructor() { + this.indexedDb = createStorage({ driver: z$3({ dbName: D$1, storeName: E$2 }) }); + } + async getKeys() { + return this.indexedDb.getKeys(); + } + async getEntries() { + return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((t2) => [t2.key, t2.value]); + } + async getItem(t2) { + const e2 = await this.indexedDb.getItem(t2); + if (e2 !== null) + return e2; + } + async setItem(t2, e2) { + await this.indexedDb.setItem(t2, safeJsonStringify(e2)); + } + async removeItem(t2) { + await this.indexedDb.removeItem(t2); + } +}; +var l$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c$2 = { exports: {} }; +(function() { + let i2; + function t2() { + } + i2 = t2, i2.prototype.getItem = function(e2) { + return this.hasOwnProperty(e2) ? String(this[e2]) : null; + }, i2.prototype.setItem = function(e2, n4) { + this[e2] = String(n4); + }, i2.prototype.removeItem = function(e2) { + delete this[e2]; + }, i2.prototype.clear = function() { + const e2 = this; + Object.keys(e2).forEach(function(n4) { + e2[n4] = void 0, delete e2[n4]; + }); + }, i2.prototype.key = function(e2) { + return e2 = e2 || 0, Object.keys(this)[e2]; + }, i2.prototype.__defineGetter__("length", function() { + return Object.keys(this).length; + }), typeof l$1 < "u" && l$1.localStorage ? c$2.exports = l$1.localStorage : typeof window < "u" && window.localStorage ? c$2.exports = window.localStorage : c$2.exports = new t2(); +})(); +function k$3(i2) { + var t2; + return [i2[0], safeJsonParse((t2 = i2[1]) != null ? t2 : "")]; +} +let K$3 = class K { + constructor() { + this.localStorage = c$2.exports; + } + async getKeys() { + return Object.keys(this.localStorage); + } + async getEntries() { + return Object.entries(this.localStorage).map(k$3); + } + async getItem(t2) { + const e2 = this.localStorage.getItem(t2); + if (e2 !== null) + return safeJsonParse(e2); + } + async setItem(t2, e2) { + this.localStorage.setItem(t2, safeJsonStringify(e2)); + } + async removeItem(t2) { + this.localStorage.removeItem(t2); + } +}; +const N$1 = "wc_storage_version", y$3 = 1, O$2 = async (i2, t2, e2) => { + const n4 = N$1, s2 = await t2.getItem(n4); + if (s2 && s2 >= y$3) { + e2(t2); + return; + } + const a3 = await i2.getKeys(); + if (!a3.length) { + e2(t2); + return; + } + const m3 = []; + for (; a3.length; ) { + const r3 = a3.shift(); + if (!r3) + continue; + const o2 = r3.toLowerCase(); + if (o2.includes("wc@") || o2.includes("walletconnect") || o2.includes("wc_") || o2.includes("wallet_connect")) { + const f3 = await i2.getItem(r3); + await t2.setItem(r3, f3), m3.push(r3); + } + } + await t2.setItem(n4, y$3), e2(t2), j$3(i2, m3); +}, j$3 = async (i2, t2) => { + t2.length && t2.forEach(async (e2) => { + await i2.removeItem(e2); + }); +}; +let h$2 = class h { + constructor() { + this.initialized = false, this.setInitialized = (e2) => { + this.storage = e2, this.initialized = true; + }; + const t2 = new K$3(); + this.storage = t2; + try { + const e2 = new _$1(); + O$2(t2, e2, this.setInitialized); + } catch { + this.initialized = true; + } + } + async getKeys() { + return await this.initialize(), this.storage.getKeys(); + } + async getEntries() { + return await this.initialize(), this.storage.getEntries(); + } + async getItem(t2) { + return await this.initialize(), this.storage.getItem(t2); + } + async setItem(t2, e2) { + return await this.initialize(), this.storage.setItem(t2, e2); + } + async removeItem(t2) { + return await this.initialize(), this.storage.removeItem(t2); + } + async initialize() { + this.initialized || await new Promise((t2) => { + const e2 = setInterval(() => { + this.initialized && (clearInterval(e2), t2()); + }, 20); + }); + } +}; +var cjs$4 = {}; +/*! ***************************************************************************** +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. +***************************************************************************** */ +var extendStatics = function(d5, b3) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d6, b4) { + d6.__proto__ = b4; + } || function(d6, b4) { + for (var p2 in b4) + if (b4.hasOwnProperty(p2)) + d6[p2] = b4[p2]; + }; + return extendStatics(d5, b3); +}; +function __extends(d5, b3) { + extendStatics(d5, b3); + function __() { + this.constructor = d5; + } + d5.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); +} +var __assign = function() { + __assign = Object.assign || function __assign2(t2) { + for (var s2, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { + s2 = arguments[i2]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2)) + t2[p2] = s2[p2]; + } + return t2; + }; + return __assign.apply(this, arguments); +}; +function __rest(s2, e2) { + var t2 = {}; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0) + t2[p2] = s2[p2]; + if (s2 != null && typeof Object.getOwnPropertySymbols === "function") + for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++) { + if (e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i2])) + t2[p2[i2]] = s2[p2[i2]]; + } + return t2; +} +function __decorate(decorators, target, key, desc) { + var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d5; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") + r3 = Reflect.decorate(decorators, target, key, desc); + else + for (var i2 = decorators.length - 1; i2 >= 0; i2--) + if (d5 = decorators[i2]) + r3 = (c2 < 3 ? d5(r3) : c2 > 3 ? d5(target, key, r3) : d5(target, key)) || r3; + return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3; +} +function __param(paramIndex, decorator) { + return function(target, key) { + decorator(target, key, paramIndex); + }; +} +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") + return Reflect.metadata(metadataKey, metadataValue); +} +function __awaiter(thisArg, _arguments, P2, generator) { + function adopt(value) { + return value instanceof P2 ? value : new P2(function(resolve) { + resolve(value); + }); + } + return new (P2 || (P2 = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e2) { + reject(e2); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e2) { + reject(e2); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} +function __generator(thisArg, body) { + var _3 = { label: 0, sent: function() { + if (t2[0] & 1) + throw t2[1]; + return t2[1]; + }, trys: [], ops: [] }, f3, y3, t2, g3; + return g3 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() { + return this; + }), g3; + function verb(n4) { + return function(v3) { + return step([n4, v3]); + }; + } + function step(op) { + if (f3) + throw new TypeError("Generator is already executing."); + while (_3) + try { + if (f3 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) + return t2; + if (y3 = 0, t2) + op = [op[0] & 2, t2.value]; + switch (op[0]) { + case 0: + case 1: + t2 = op; + break; + case 4: + _3.label++; + return { value: op[1], done: false }; + case 5: + _3.label++; + y3 = op[1]; + op = [0]; + continue; + case 7: + op = _3.ops.pop(); + _3.trys.pop(); + continue; + default: + if (!(t2 = _3.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) { + _3 = 0; + continue; + } + if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) { + _3.label = op[1]; + break; + } + if (op[0] === 6 && _3.label < t2[1]) { + _3.label = t2[1]; + t2 = op; + break; + } + if (t2 && _3.label < t2[2]) { + _3.label = t2[2]; + _3.ops.push(op); + break; + } + if (t2[2]) + _3.ops.pop(); + _3.trys.pop(); + continue; + } + op = body.call(thisArg, _3); + } catch (e2) { + op = [6, e2]; + y3 = 0; + } finally { + f3 = t2 = 0; + } + if (op[0] & 5) + throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } +} +function __createBinding(o2, m3, k2, k22) { + if (k22 === void 0) + k22 = k2; + o2[k22] = m3[k2]; +} +function __exportStar(m3, exports2) { + for (var p2 in m3) + if (p2 !== "default" && !exports2.hasOwnProperty(p2)) + exports2[p2] = m3[p2]; +} +function __values(o2) { + var s2 = typeof Symbol === "function" && Symbol.iterator, m3 = s2 && o2[s2], i2 = 0; + if (m3) + return m3.call(o2); + if (o2 && typeof o2.length === "number") + return { + next: function() { + if (o2 && i2 >= o2.length) + o2 = void 0; + return { value: o2 && o2[i2++], done: !o2 }; + } + }; + throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined."); +} +function __read(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) + return o2; + var i2 = m3.call(o2), r3, ar3 = [], e2; + try { + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); + } catch (error) { + e2 = { error }; + } finally { + try { + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); + } finally { + if (e2) + throw e2.error; + } + } + return ar3; +} +function __spread() { + for (var ar3 = [], i2 = 0; i2 < arguments.length; i2++) + ar3 = ar3.concat(__read(arguments[i2])); + return ar3; +} +function __spreadArrays() { + for (var s2 = 0, i2 = 0, il = arguments.length; i2 < il; i2++) + s2 += arguments[i2].length; + for (var r3 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) + for (var a3 = arguments[i2], j2 = 0, jl = a3.length; j2 < jl; j2++, k2++) + r3[k2] = a3[j2]; + return r3; +} +function __await(v3) { + return this instanceof __await ? (this.v = v3, this) : new __await(v3); +} +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) + throw new TypeError("Symbol.asyncIterator is not defined."); + var g3 = generator.apply(thisArg, _arguments || []), i2, q2 = []; + return i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { + return this; + }, i2; + function verb(n4) { + if (g3[n4]) + i2[n4] = function(v3) { + return new Promise(function(a3, b3) { + q2.push([n4, v3, a3, b3]) > 1 || resume(n4, v3); + }); + }; + } + function resume(n4, v3) { + try { + step(g3[n4](v3)); + } catch (e2) { + settle(q2[0][3], e2); + } + } + function step(r3) { + r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q2[0][2], r3); + } + function fulfill(value) { + resume("next", value); + } + function reject(value) { + resume("throw", value); + } + function settle(f3, v3) { + if (f3(v3), q2.shift(), q2.length) + resume(q2[0][0], q2[0][1]); + } +} +function __asyncDelegator(o2) { + var i2, p2; + return i2 = {}, verb("next"), verb("throw", function(e2) { + throw e2; + }), verb("return"), i2[Symbol.iterator] = function() { + return this; + }, i2; + function verb(n4, f3) { + i2[n4] = o2[n4] ? function(v3) { + return (p2 = !p2) ? { value: __await(o2[n4](v3)), done: n4 === "return" } : f3 ? f3(v3) : v3; + } : f3; + } +} +function __asyncValues(o2) { + if (!Symbol.asyncIterator) + throw new TypeError("Symbol.asyncIterator is not defined."); + var m3 = o2[Symbol.asyncIterator], i2; + return m3 ? m3.call(o2) : (o2 = typeof __values === "function" ? __values(o2) : o2[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { + return this; + }, i2); + function verb(n4) { + i2[n4] = o2[n4] && function(v3) { + return new Promise(function(resolve, reject) { + v3 = o2[n4](v3), settle(resolve, reject, v3.done, v3.value); + }); + }; + } + function settle(resolve, reject, d5, v3) { + Promise.resolve(v3).then(function(v4) { + resolve({ value: v4, done: d5 }); + }, reject); + } +} +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { + Object.defineProperty(cooked, "raw", { value: raw }); + } else { + cooked.raw = raw; + } + return cooked; +} +function __importStar(mod) { + if (mod && mod.__esModule) + return mod; + var result = {}; + if (mod != null) { + for (var k2 in mod) + if (Object.hasOwnProperty.call(mod, k2)) + result[k2] = mod[k2]; + } + result.default = mod; + return result; +} +function __importDefault(mod) { + return mod && mod.__esModule ? mod : { default: mod }; +} +function __classPrivateFieldGet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + return privateMap.get(receiver); +} +function __classPrivateFieldSet(receiver, privateMap, value) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + privateMap.set(receiver, value); + return value; +} +const tslib_es6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + get __assign() { + return __assign; + }, + __asyncDelegator, + __asyncGenerator, + __asyncValues, + __await, + __awaiter, + __classPrivateFieldGet, + __classPrivateFieldSet, + __createBinding, + __decorate, + __exportStar, + __extends, + __generator, + __importDefault, + __importStar, + __makeTemplateObject, + __metadata, + __param, + __read, + __rest, + __spread, + __spreadArrays, + __values +}, Symbol.toStringTag, { value: "Module" })); +const require$$0$2 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6); +var heartbeat$2 = {}; +var cjs$3 = {}; +var utils = {}; +var delay = {}; +var hasRequiredDelay; +function requireDelay() { + if (hasRequiredDelay) + return delay; + hasRequiredDelay = 1; + Object.defineProperty(delay, "__esModule", { value: true }); + delay.delay = void 0; + function delay$1(timeout) { + return new Promise((resolve) => { + setTimeout(() => { + resolve(true); + }, timeout); + }); + } + delay.delay = delay$1; + return delay; +} +var convert = {}; +var constants$1 = {}; +var misc = {}; +var hasRequiredMisc; +function requireMisc() { + if (hasRequiredMisc) + return misc; + hasRequiredMisc = 1; + Object.defineProperty(misc, "__esModule", { value: true }); + misc.ONE_THOUSAND = misc.ONE_HUNDRED = void 0; + misc.ONE_HUNDRED = 100; + misc.ONE_THOUSAND = 1e3; + return misc; +} +var time = {}; +var hasRequiredTime; +function requireTime() { + if (hasRequiredTime) + return time; + hasRequiredTime = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.ONE_YEAR = exports2.FOUR_WEEKS = exports2.THREE_WEEKS = exports2.TWO_WEEKS = exports2.ONE_WEEK = exports2.THIRTY_DAYS = exports2.SEVEN_DAYS = exports2.FIVE_DAYS = exports2.THREE_DAYS = exports2.ONE_DAY = exports2.TWENTY_FOUR_HOURS = exports2.TWELVE_HOURS = exports2.SIX_HOURS = exports2.THREE_HOURS = exports2.ONE_HOUR = exports2.SIXTY_MINUTES = exports2.THIRTY_MINUTES = exports2.TEN_MINUTES = exports2.FIVE_MINUTES = exports2.ONE_MINUTE = exports2.SIXTY_SECONDS = exports2.THIRTY_SECONDS = exports2.TEN_SECONDS = exports2.FIVE_SECONDS = exports2.ONE_SECOND = void 0; + exports2.ONE_SECOND = 1; + exports2.FIVE_SECONDS = 5; + exports2.TEN_SECONDS = 10; + exports2.THIRTY_SECONDS = 30; + exports2.SIXTY_SECONDS = 60; + exports2.ONE_MINUTE = exports2.SIXTY_SECONDS; + exports2.FIVE_MINUTES = exports2.ONE_MINUTE * 5; + exports2.TEN_MINUTES = exports2.ONE_MINUTE * 10; + exports2.THIRTY_MINUTES = exports2.ONE_MINUTE * 30; + exports2.SIXTY_MINUTES = exports2.ONE_MINUTE * 60; + exports2.ONE_HOUR = exports2.SIXTY_MINUTES; + exports2.THREE_HOURS = exports2.ONE_HOUR * 3; + exports2.SIX_HOURS = exports2.ONE_HOUR * 6; + exports2.TWELVE_HOURS = exports2.ONE_HOUR * 12; + exports2.TWENTY_FOUR_HOURS = exports2.ONE_HOUR * 24; + exports2.ONE_DAY = exports2.TWENTY_FOUR_HOURS; + exports2.THREE_DAYS = exports2.ONE_DAY * 3; + exports2.FIVE_DAYS = exports2.ONE_DAY * 5; + exports2.SEVEN_DAYS = exports2.ONE_DAY * 7; + exports2.THIRTY_DAYS = exports2.ONE_DAY * 30; + exports2.ONE_WEEK = exports2.SEVEN_DAYS; + exports2.TWO_WEEKS = exports2.ONE_WEEK * 2; + exports2.THREE_WEEKS = exports2.ONE_WEEK * 3; + exports2.FOUR_WEEKS = exports2.ONE_WEEK * 4; + exports2.ONE_YEAR = exports2.ONE_DAY * 365; + })(time); + return time; +} +var hasRequiredConstants$1; +function requireConstants$1() { + if (hasRequiredConstants$1) + return constants$1; + hasRequiredConstants$1 = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireMisc(), exports2); + tslib_1.__exportStar(requireTime(), exports2); + })(constants$1); + return constants$1; +} +var hasRequiredConvert; +function requireConvert() { + if (hasRequiredConvert) + return convert; + hasRequiredConvert = 1; + Object.defineProperty(convert, "__esModule", { value: true }); + convert.fromMiliseconds = convert.toMiliseconds = void 0; + const constants_1 = requireConstants$1(); + function toMiliseconds(seconds) { + return seconds * constants_1.ONE_THOUSAND; + } + convert.toMiliseconds = toMiliseconds; + function fromMiliseconds(miliseconds) { + return Math.floor(miliseconds / constants_1.ONE_THOUSAND); + } + convert.fromMiliseconds = fromMiliseconds; + return convert; +} +var hasRequiredUtils; +function requireUtils() { + if (hasRequiredUtils) + return utils; + hasRequiredUtils = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireDelay(), exports2); + tslib_1.__exportStar(requireConvert(), exports2); + })(utils); + return utils; +} +var watch$1 = {}; +var hasRequiredWatch$1; +function requireWatch$1() { + if (hasRequiredWatch$1) + return watch$1; + hasRequiredWatch$1 = 1; + Object.defineProperty(watch$1, "__esModule", { value: true }); + watch$1.Watch = void 0; + class Watch { + constructor() { + this.timestamps = /* @__PURE__ */ new Map(); + } + start(label) { + if (this.timestamps.has(label)) { + throw new Error(`Watch already started for label: ${label}`); + } + this.timestamps.set(label, { started: Date.now() }); + } + stop(label) { + const timestamp = this.get(label); + if (typeof timestamp.elapsed !== "undefined") { + throw new Error(`Watch already stopped for label: ${label}`); + } + const elapsed = Date.now() - timestamp.started; + this.timestamps.set(label, { started: timestamp.started, elapsed }); + } + get(label) { + const timestamp = this.timestamps.get(label); + if (typeof timestamp === "undefined") { + throw new Error(`No timestamp found for label: ${label}`); + } + return timestamp; + } + elapsed(label) { + const timestamp = this.get(label); + const elapsed = timestamp.elapsed || Date.now() - timestamp.started; + return elapsed; + } + } + watch$1.Watch = Watch; + watch$1.default = Watch; + return watch$1; +} +var types$2 = {}; +var watch = {}; +var hasRequiredWatch; +function requireWatch() { + if (hasRequiredWatch) + return watch; + hasRequiredWatch = 1; + Object.defineProperty(watch, "__esModule", { value: true }); + watch.IWatch = void 0; + class IWatch { + } + watch.IWatch = IWatch; + return watch; +} +var hasRequiredTypes$1; +function requireTypes$1() { + if (hasRequiredTypes$1) + return types$2; + hasRequiredTypes$1 = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireWatch(), exports2); + })(types$2); + return types$2; +} +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireUtils(), exports2); + tslib_1.__exportStar(requireWatch$1(), exports2); + tslib_1.__exportStar(requireTypes$1(), exports2); + tslib_1.__exportStar(requireConstants$1(), exports2); +})(cjs$3); +var types$1 = {}; +var heartbeat$1 = {}; +class IEvents { +} +const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + IEvents +}, Symbol.toStringTag, { value: "Module" })); +const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(esm); +var hasRequiredHeartbeat$2; +function requireHeartbeat$2() { + if (hasRequiredHeartbeat$2) + return heartbeat$1; + hasRequiredHeartbeat$2 = 1; + Object.defineProperty(heartbeat$1, "__esModule", { value: true }); + heartbeat$1.IHeartBeat = void 0; + const events_1 = require$$0$1; + class IHeartBeat extends events_1.IEvents { + constructor(opts) { + super(); + } + } + heartbeat$1.IHeartBeat = IHeartBeat; + return heartbeat$1; +} +var hasRequiredTypes; +function requireTypes() { + if (hasRequiredTypes) + return types$1; + hasRequiredTypes = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireHeartbeat$2(), exports2); + })(types$1); + return types$1; +} +var constants = {}; +var heartbeat = {}; +var hasRequiredHeartbeat$1; +function requireHeartbeat$1() { + if (hasRequiredHeartbeat$1) + return heartbeat; + hasRequiredHeartbeat$1 = 1; + Object.defineProperty(heartbeat, "__esModule", { value: true }); + heartbeat.HEARTBEAT_EVENTS = heartbeat.HEARTBEAT_INTERVAL = void 0; + const time_1 = cjs$3; + heartbeat.HEARTBEAT_INTERVAL = time_1.FIVE_SECONDS; + heartbeat.HEARTBEAT_EVENTS = { + pulse: "heartbeat_pulse" + }; + return heartbeat; +} +var hasRequiredConstants; +function requireConstants() { + if (hasRequiredConstants) + return constants; + hasRequiredConstants = 1; + (function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireHeartbeat$1(), exports2); + })(constants); + return constants; +} +var hasRequiredHeartbeat; +function requireHeartbeat() { + if (hasRequiredHeartbeat) + return heartbeat$2; + hasRequiredHeartbeat = 1; + Object.defineProperty(heartbeat$2, "__esModule", { value: true }); + heartbeat$2.HeartBeat = void 0; + const tslib_1 = require$$0$2; + const events_1 = eventsExports; + const time_1 = cjs$3; + const types_1 = requireTypes(); + const constants_1 = requireConstants(); + class HeartBeat extends types_1.IHeartBeat { + constructor(opts) { + super(opts); + this.events = new events_1.EventEmitter(); + this.interval = constants_1.HEARTBEAT_INTERVAL; + this.interval = (opts === null || opts === void 0 ? void 0 : opts.interval) || constants_1.HEARTBEAT_INTERVAL; + } + static init(opts) { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + const heartbeat2 = new HeartBeat(opts); + yield heartbeat2.init(); + return heartbeat2; + }); + } + init() { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + yield this.initialize(); + }); + } + stop() { + clearInterval(this.intervalRef); + } + on(event, listener) { + this.events.on(event, listener); + } + once(event, listener) { + this.events.once(event, listener); + } + off(event, listener) { + this.events.off(event, listener); + } + removeListener(event, listener) { + this.events.removeListener(event, listener); + } + initialize() { + return tslib_1.__awaiter(this, void 0, void 0, function* () { + this.intervalRef = setInterval(() => this.pulse(), time_1.toMiliseconds(this.interval)); + }); + } + pulse() { + this.events.emit(constants_1.HEARTBEAT_EVENTS.pulse); + } + } + heartbeat$2.HeartBeat = HeartBeat; + return heartbeat$2; +} +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireHeartbeat(), exports2); + tslib_1.__exportStar(requireTypes(), exports2); + tslib_1.__exportStar(requireConstants(), exports2); +})(cjs$4); +function tryStringify(o2) { + try { + return JSON.stringify(o2); + } catch (e2) { + return '"[Circular]"'; + } +} +var quickFormatUnescaped = format$1; +function format$1(f3, args, opts) { + var ss4 = opts && opts.stringify || tryStringify; + var offset = 1; + if (typeof f3 === "object" && f3 !== null) { + var len = args.length + offset; + if (len === 1) + return f3; + var objects = new Array(len); + objects[0] = ss4(f3); + for (var index = 1; index < len; index++) { + objects[index] = ss4(args[index]); + } + return objects.join(" "); + } + if (typeof f3 !== "string") { + return f3; + } + var argLen = args.length; + if (argLen === 0) + return f3; + var str = ""; + var a3 = 1 - offset; + var lastPos = -1; + var flen = f3 && f3.length || 0; + for (var i2 = 0; i2 < flen; ) { + if (f3.charCodeAt(i2) === 37 && i2 + 1 < flen) { + lastPos = lastPos > -1 ? lastPos : 0; + switch (f3.charCodeAt(i2 + 1)) { + case 100: + case 102: + if (a3 >= argLen) + break; + if (args[a3] == null) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Number(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 105: + if (a3 >= argLen) + break; + if (args[a3] == null) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Math.floor(Number(args[a3])); + lastPos = i2 + 2; + i2++; + break; + case 79: + case 111: + case 106: + if (a3 >= argLen) + break; + if (args[a3] === void 0) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + var type2 = typeof args[a3]; + if (type2 === "string") { + str += "'" + args[a3] + "'"; + lastPos = i2 + 2; + i2++; + break; + } + if (type2 === "function") { + str += args[a3].name || ""; + lastPos = i2 + 2; + i2++; + break; + } + str += ss4(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 115: + if (a3 >= argLen) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += String(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 37: + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += "%"; + lastPos = i2 + 2; + i2++; + a3--; + break; + } + ++a3; + } + ++i2; + } + if (lastPos === -1) + return f3; + else if (lastPos < flen) { + str += f3.slice(lastPos); + } + return str; +} +const format = quickFormatUnescaped; +var browser$4 = pino; +const _console = pfGlobalThisOrFallback().console || {}; +const stdSerializers = { + mapHttpRequest: mock, + mapHttpResponse: mock, + wrapRequestSerializer: passthrough, + wrapResponseSerializer: passthrough, + wrapErrorSerializer: passthrough, + req: mock, + res: mock, + err: asErrValue +}; +function shouldSerialize(serialize, serializers) { + if (Array.isArray(serialize)) { + const hasToFilter = serialize.filter(function(k2) { + return k2 !== "!stdSerializers.err"; + }); + return hasToFilter; + } else if (serialize === true) { + return Object.keys(serializers); + } + return false; +} +function pino(opts) { + opts = opts || {}; + opts.browser = opts.browser || {}; + const transmit2 = opts.browser.transmit; + if (transmit2 && typeof transmit2.send !== "function") { + throw Error("pino: transmit option must have a send function"); + } + const proto = opts.browser.write || _console; + if (opts.browser.write) + opts.browser.asObject = true; + const serializers = opts.serializers || {}; + const serialize = shouldSerialize(opts.browser.serialize, serializers); + let stdErrSerialize = opts.browser.serialize; + if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) + stdErrSerialize = false; + const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; + if (typeof proto === "function") { + proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; + } + if (opts.enabled === false) + opts.level = "silent"; + const level = opts.level || "info"; + const logger = Object.create(proto); + if (!logger.log) + logger.log = noop; + Object.defineProperty(logger, "levelVal", { + get: getLevelVal + }); + Object.defineProperty(logger, "level", { + get: getLevel, + set: setLevel + }); + const setOpts = { + transmit: transmit2, + serialize, + asObject: opts.browser.asObject, + levels, + timestamp: getTimeFunction(opts) + }; + logger.levels = pino.levels; + logger.level = level; + logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop; + logger.serializers = serializers; + logger._serialize = serialize; + logger._stdErrSerialize = stdErrSerialize; + logger.child = child; + if (transmit2) + logger._logEvent = createLogEventShape(); + function getLevelVal() { + return this.level === "silent" ? Infinity : this.levels.values[this.level]; + } + function getLevel() { + return this._level; + } + function setLevel(level2) { + if (level2 !== "silent" && !this.levels.values[level2]) { + throw Error("unknown level " + level2); + } + this._level = level2; + set(setOpts, logger, "error", "log"); + set(setOpts, logger, "fatal", "error"); + set(setOpts, logger, "warn", "error"); + set(setOpts, logger, "info", "log"); + set(setOpts, logger, "debug", "log"); + set(setOpts, logger, "trace", "log"); + } + function child(bindings, childOptions) { + if (!bindings) { + throw new Error("missing bindings for child Pino"); + } + childOptions = childOptions || {}; + if (serialize && bindings.serializers) { + childOptions.serializers = bindings.serializers; + } + const childOptionsSerializers = childOptions.serializers; + if (serialize && childOptionsSerializers) { + var childSerializers = Object.assign({}, serializers, childOptionsSerializers); + var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; + delete bindings.serializers; + applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); + } + function Child(parent) { + this._childLevel = (parent._childLevel | 0) + 1; + this.error = bind(parent, bindings, "error"); + this.fatal = bind(parent, bindings, "fatal"); + this.warn = bind(parent, bindings, "warn"); + this.info = bind(parent, bindings, "info"); + this.debug = bind(parent, bindings, "debug"); + this.trace = bind(parent, bindings, "trace"); + if (childSerializers) { + this.serializers = childSerializers; + this._serialize = childSerialize; + } + if (transmit2) { + this._logEvent = createLogEventShape( + [].concat(parent._logEvent.bindings, bindings) + ); + } + } + Child.prototype = this; + return new Child(this); + } + return logger; +} +pino.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" + } +}; +pino.stdSerializers = stdSerializers; +pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); +function set(opts, logger, level, fallback) { + const proto = Object.getPrototypeOf(logger); + logger[level] = logger.levelVal > logger.levels.values[level] ? noop : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop; + wrap(opts, logger, level); +} +function wrap(opts, logger, level) { + if (!opts.transmit && logger[level] === noop) + return; + logger[level] = /* @__PURE__ */ function(write) { + return function LOG() { + const ts3 = opts.timestamp(); + const args = new Array(arguments.length); + const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; + for (var i2 = 0; i2 < args.length; i2++) + args[i2] = arguments[i2]; + if (opts.serialize && !opts.asObject) { + applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); + } + if (opts.asObject) + write.call(proto, asObject(this, level, args, ts3)); + else + write.apply(proto, args); + if (opts.transmit) { + const transmitLevel = opts.transmit.level || logger.level; + const transmitValue = pino.levels.values[transmitLevel]; + const methodValue = pino.levels.values[level]; + if (methodValue < transmitValue) + return; + transmit(this, { + ts: ts3, + methodLevel: level, + methodValue, + transmitLevel, + transmitValue: pino.levels.values[opts.transmit.level || logger.level], + send: opts.transmit.send, + val: logger.levelVal + }, args); + } + }; + }(logger[level]); +} +function asObject(logger, level, args, ts3) { + if (logger._serialize) + applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); + const argsCloned = args.slice(); + let msg = argsCloned[0]; + const o2 = {}; + if (ts3) { + o2.time = ts3; + } + o2.level = pino.levels.values[level]; + let lvl = (logger._childLevel | 0) + 1; + if (lvl < 1) + lvl = 1; + if (msg !== null && typeof msg === "object") { + while (lvl-- && typeof argsCloned[0] === "object") { + Object.assign(o2, argsCloned.shift()); + } + msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; + } else if (typeof msg === "string") + msg = format(argsCloned.shift(), argsCloned); + if (msg !== void 0) + o2.msg = msg; + return o2; +} +function applySerializers(args, serialize, serializers, stdErrSerialize) { + for (const i2 in args) { + if (stdErrSerialize && args[i2] instanceof Error) { + args[i2] = pino.stdSerializers.err(args[i2]); + } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { + for (const k2 in args[i2]) { + if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { + args[i2][k2] = serializers[k2](args[i2][k2]); + } + } + } + } +} +function bind(parent, bindings, level) { + return function() { + const args = new Array(1 + arguments.length); + args[0] = bindings; + for (var i2 = 1; i2 < args.length; i2++) { + args[i2] = arguments[i2 - 1]; + } + return parent[level].apply(this, args); + }; +} +function transmit(logger, opts, args) { + const send = opts.send; + const ts3 = opts.ts; + const methodLevel = opts.methodLevel; + const methodValue = opts.methodValue; + const val = opts.val; + const bindings = logger._logEvent.bindings; + applySerializers( + args, + logger._serialize || Object.keys(logger.serializers), + logger.serializers, + logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize + ); + logger._logEvent.ts = ts3; + logger._logEvent.messages = args.filter(function(arg) { + return bindings.indexOf(arg) === -1; + }); + logger._logEvent.level.label = methodLevel; + logger._logEvent.level.value = methodValue; + send(methodLevel, logger._logEvent, val); + logger._logEvent = createLogEventShape(bindings); +} +function createLogEventShape(bindings) { + return { + ts: 0, + messages: [], + bindings: bindings || [], + level: { label: "", value: 0 } + }; +} +function asErrValue(err) { + const obj = { + type: err.constructor.name, + msg: err.message, + stack: err.stack + }; + for (const key in err) { + if (obj[key] === void 0) { + obj[key] = err[key]; + } + } + return obj; +} +function getTimeFunction(opts) { + if (typeof opts.timestamp === "function") { + return opts.timestamp; + } + if (opts.timestamp === false) { + return nullTime; + } + return epochTime; +} +function mock() { + return {}; +} +function passthrough(a3) { + return a3; +} +function noop() { +} +function nullTime() { + return false; +} +function epochTime() { + return Date.now(); +} +function unixTime() { + return Math.round(Date.now() / 1e3); +} +function isoTime() { + return new Date(Date.now()).toISOString(); +} +function pfGlobalThisOrFallback() { + function defd(o2) { + return typeof o2 !== "undefined" && o2; + } + try { + if (typeof globalThis !== "undefined") + return globalThis; + Object.defineProperty(Object.prototype, "globalThis", { + get: function() { + delete Object.prototype.globalThis; + return this.globalThis = this; + }, + configurable: true + }); + return globalThis; + } catch (e2) { + return defd(self) || defd(window) || defd(this) || {}; + } +} +const nt$1 = /* @__PURE__ */ getDefaultExportFromCjs(browser$4); +const c$1 = { level: "info" }, n$3 = "custom_context", l = 1e3 * 1024; +let O$1 = class O { + constructor(e2) { + this.nodeValue = e2, this.sizeInBytes = new TextEncoder().encode(this.nodeValue).length, this.next = null; + } + get value() { + return this.nodeValue; + } + get size() { + return this.sizeInBytes; + } +}; +let d$2 = class d2 { + constructor(e2) { + this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e2, this.sizeInBytes = 0; + } + append(e2) { + const t2 = new O$1(e2); + if (t2.size > this.maxSizeInBytes) + throw new Error(`[LinkedList] Value too big to insert into list: ${e2} with size ${t2.size}`); + for (; this.size + t2.size > this.maxSizeInBytes; ) + this.shift(); + this.head ? (this.tail && (this.tail.next = t2), this.tail = t2) : (this.head = t2, this.tail = t2), this.lengthInNodes++, this.sizeInBytes += t2.size; + } + shift() { + if (!this.head) + return; + const e2 = this.head; + this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e2.size; + } + toArray() { + const e2 = []; + let t2 = this.head; + for (; t2 !== null; ) + e2.push(t2.value), t2 = t2.next; + return e2; + } + get length() { + return this.lengthInNodes; + } + get size() { + return this.sizeInBytes; + } + toOrderedArray() { + return Array.from(this); + } + [Symbol.iterator]() { + let e2 = this.head; + return { next: () => { + if (!e2) + return { done: true, value: null }; + const t2 = e2.value; + return e2 = e2.next, { done: false, value: t2 }; + } }; + } +}; +let L$4 = class L { + constructor(e2, t2 = l) { + this.level = e2 ?? "error", this.levelValue = browser$4.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = t2, this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); + } + forwardToConsole(e2, t2) { + t2 === browser$4.levels.values.error ? console.error(e2) : t2 === browser$4.levels.values.warn ? console.warn(e2) : t2 === browser$4.levels.values.debug ? console.debug(e2) : t2 === browser$4.levels.values.trace ? console.trace(e2) : console.log(e2); + } + appendToLogs(e2) { + this.logs.append(safeJsonStringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: e2 })); + const t2 = typeof e2 == "string" ? JSON.parse(e2).level : e2.level; + t2 >= this.levelValue && this.forwardToConsole(e2, t2); + } + getLogs() { + return this.logs; + } + clearLogs() { + this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); + } + getLogArray() { + return Array.from(this.logs); + } + logsToBlob(e2) { + const t2 = this.getLogArray(); + return t2.push(safeJsonStringify({ extraMetadata: e2 })), new Blob(t2, { type: "application/json" }); + } +}; +let m$1 = class m { + constructor(e2, t2 = l) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } + downloadLogsBlobInBrowser(e2) { + const t2 = URL.createObjectURL(this.logsToBlob(e2)), o2 = document.createElement("a"); + o2.href = t2, o2.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(o2), o2.click(), document.body.removeChild(o2), URL.revokeObjectURL(t2); + } +}; +class B { + constructor(e2, t2 = l) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } +} +var x = Object.defineProperty, S$3 = Object.defineProperties, _2 = Object.getOwnPropertyDescriptors, p$1 = Object.getOwnPropertySymbols, T$1 = Object.prototype.hasOwnProperty, z$2 = Object.prototype.propertyIsEnumerable, f$3 = (r3, e2, t2) => e2 in r3 ? x(r3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : r3[e2] = t2, i = (r3, e2) => { + for (var t2 in e2 || (e2 = {})) + T$1.call(e2, t2) && f$3(r3, t2, e2[t2]); + if (p$1) + for (var t2 of p$1(e2)) + z$2.call(e2, t2) && f$3(r3, t2, e2[t2]); + return r3; +}, g$2 = (r3, e2) => S$3(r3, _2(e2)); +function k$2(r3) { + return g$2(i({}, r3), { level: (r3 == null ? void 0 : r3.level) || c$1.level }); +} +function v$2(r3, e2 = n$3) { + return r3[e2] || ""; +} +function b$2(r3, e2, t2 = n$3) { + return r3[t2] = e2, r3; +} +function y$2(r3, e2 = n$3) { + let t2 = ""; + return typeof r3.bindings > "u" ? t2 = v$2(r3, e2) : t2 = r3.bindings().context || "", t2; +} +function w$3(r3, e2, t2 = n$3) { + const o2 = y$2(r3, t2); + return o2.trim() ? `${o2}/${e2}` : e2; +} +function E$1(r3, e2, t2 = n$3) { + const o2 = w$3(r3, e2, t2), a3 = r3.child({ context: o2 }); + return b$2(a3, o2, t2); +} +function C$2(r3) { + var e2, t2; + const o2 = new m$1((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i({}, r3.opts), { level: "trace", browser: g$2(i({}, (t2 = r3.opts) == null ? void 0 : t2.browser), { write: (a3) => o2.write(a3) }) })), chunkLoggerController: o2 }; +} +function I$2(r3) { + var e2; + const t2 = new B((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i({}, r3.opts), { level: "trace" }), t2), chunkLoggerController: t2 }; +} +function A$2(r3) { + return typeof r3.loggerOverride < "u" && typeof r3.loggerOverride != "string" ? { logger: r3.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? C$2(r3) : I$2(r3); +} +let n$2 = class n extends IEvents { + constructor(s2) { + super(), this.opts = s2, this.protocol = "wc", this.version = 2; + } +}; +let h$1 = class h2 extends IEvents { + constructor(s2, t2) { + super(), this.core = s2, this.logger = t2, this.records = /* @__PURE__ */ new Map(); + } +}; +let a$1 = class a { + constructor(s2, t2) { + this.logger = s2, this.core = t2; + } +}; +let u$1 = class u extends IEvents { + constructor(s2, t2) { + super(), this.relayer = s2, this.logger = t2; + } +}; +let g$1 = class g extends IEvents { + constructor(s2) { + super(); + } +}; +class p { + constructor(s2, t2, o2, M2) { + this.core = s2, this.logger = t2, this.name = o2; + } +} +let d$1 = class d3 extends IEvents { + constructor(s2, t2) { + super(), this.relayer = s2, this.logger = t2; + } +}; +class E extends IEvents { + constructor(s2, t2) { + super(), this.core = s2, this.logger = t2; + } +} +let y$1 = class y { + constructor(s2, t2) { + this.projectId = s2, this.logger = t2; + } +}; +let v$1 = class v { + constructor(s2, t2) { + this.projectId = s2, this.logger = t2; + } +}; +let b$1 = class b { + constructor(s2) { + this.opts = s2, this.protocol = "wc", this.version = 2; + } +}; +let w$2 = class w { + constructor(s2) { + this.client = s2; + } +}; +var ed25519 = {}; +var random = {}; +var system = {}; +var browser$3 = {}; +Object.defineProperty(browser$3, "__esModule", { value: true }); +browser$3.BrowserRandomSource = void 0; +const QUOTA = 65536; +class BrowserRandomSource { + constructor() { + this.isAvailable = false; + this.isInstantiated = false; + const browserCrypto = typeof self !== "undefined" ? self.crypto || self.msCrypto : null; + if (browserCrypto && browserCrypto.getRandomValues !== void 0) { + this._crypto = browserCrypto; + this.isAvailable = true; + this.isInstantiated = true; + } + } + randomBytes(length) { + if (!this.isAvailable || !this._crypto) { + throw new Error("Browser random byte generator is not available."); + } + const out = new Uint8Array(length); + for (let i2 = 0; i2 < out.length; i2 += QUOTA) { + this._crypto.getRandomValues(out.subarray(i2, i2 + Math.min(out.length - i2, QUOTA))); + } + return out; + } +} +browser$3.BrowserRandomSource = BrowserRandomSource; +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} +var node = {}; +var wipe$1 = {}; +Object.defineProperty(wipe$1, "__esModule", { value: true }); +function wipe(array) { + for (var i2 = 0; i2 < array.length; i2++) { + array[i2] = 0; + } + return array; +} +wipe$1.wipe = wipe; +const __viteBrowserExternal = {}; +const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + default: __viteBrowserExternal +}, Symbol.toStringTag, { value: "Module" })); +const require$$1 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1); +Object.defineProperty(node, "__esModule", { value: true }); +node.NodeRandomSource = void 0; +const wipe_1$3 = wipe$1; +class NodeRandomSource { + constructor() { + this.isAvailable = false; + this.isInstantiated = false; + if (typeof commonjsRequire !== "undefined") { + const nodeCrypto = require$$1; + if (nodeCrypto && nodeCrypto.randomBytes) { + this._crypto = nodeCrypto; + this.isAvailable = true; + this.isInstantiated = true; + } + } + } + randomBytes(length) { + if (!this.isAvailable || !this._crypto) { + throw new Error("Node.js random byte generator is not available."); + } + let buffer = this._crypto.randomBytes(length); + if (buffer.length !== length) { + throw new Error("NodeRandomSource: got fewer bytes than requested"); + } + const out = new Uint8Array(length); + for (let i2 = 0; i2 < out.length; i2++) { + out[i2] = buffer[i2]; + } + (0, wipe_1$3.wipe)(buffer); + return out; + } +} +node.NodeRandomSource = NodeRandomSource; +Object.defineProperty(system, "__esModule", { value: true }); +system.SystemRandomSource = void 0; +const browser_1 = browser$3; +const node_1 = node; +class SystemRandomSource { + constructor() { + this.isAvailable = false; + this.name = ""; + this._source = new browser_1.BrowserRandomSource(); + if (this._source.isAvailable) { + this.isAvailable = true; + this.name = "Browser"; + return; + } + this._source = new node_1.NodeRandomSource(); + if (this._source.isAvailable) { + this.isAvailable = true; + this.name = "Node"; + return; + } + } + randomBytes(length) { + if (!this.isAvailable) { + throw new Error("System random byte generator is not available."); + } + return this._source.randomBytes(length); + } +} +system.SystemRandomSource = SystemRandomSource; +var binary = {}; +var int = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + function imulShim(a3, b3) { + var ah2 = a3 >>> 16 & 65535, al = a3 & 65535; + var bh = b3 >>> 16 & 65535, bl = b3 & 65535; + return al * bl + (ah2 * bl + al * bh << 16 >>> 0) | 0; + } + exports2.mul = Math.imul || imulShim; + function add(a3, b3) { + return a3 + b3 | 0; + } + exports2.add = add; + function sub(a3, b3) { + return a3 - b3 | 0; + } + exports2.sub = sub; + function rotl(x2, n4) { + return x2 << n4 | x2 >>> 32 - n4; + } + exports2.rotl = rotl; + function rotr(x2, n4) { + return x2 << 32 - n4 | x2 >>> n4; + } + exports2.rotr = rotr; + function isIntegerShim(n4) { + return typeof n4 === "number" && isFinite(n4) && Math.floor(n4) === n4; + } + exports2.isInteger = Number.isInteger || isIntegerShim; + exports2.MAX_SAFE_INTEGER = 9007199254740991; + exports2.isSafeInteger = function(n4) { + return exports2.isInteger(n4) && (n4 >= -exports2.MAX_SAFE_INTEGER && n4 <= exports2.MAX_SAFE_INTEGER); + }; +})(int); +Object.defineProperty(binary, "__esModule", { value: true }); +var int_1 = int; +function readInt16BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 0] << 8 | array[offset + 1]) << 16 >> 16; +} +binary.readInt16BE = readInt16BE; +function readUint16BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 0] << 8 | array[offset + 1]) >>> 0; +} +binary.readUint16BE = readUint16BE; +function readInt16LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 1] << 8 | array[offset]) << 16 >> 16; +} +binary.readInt16LE = readInt16LE; +function readUint16LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 1] << 8 | array[offset]) >>> 0; +} +binary.readUint16LE = readUint16LE; +function writeUint16BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(2); + } + if (offset === void 0) { + offset = 0; + } + out[offset + 0] = value >>> 8; + out[offset + 1] = value >>> 0; + return out; +} +binary.writeUint16BE = writeUint16BE; +binary.writeInt16BE = writeUint16BE; +function writeUint16LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(2); + } + if (offset === void 0) { + offset = 0; + } + out[offset + 0] = value >>> 0; + out[offset + 1] = value >>> 8; + return out; +} +binary.writeUint16LE = writeUint16LE; +binary.writeInt16LE = writeUint16LE; +function readInt32BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3]; +} +binary.readInt32BE = readInt32BE; +function readUint32BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3]) >>> 0; +} +binary.readUint32BE = readUint32BE; +function readInt32LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return array[offset + 3] << 24 | array[offset + 2] << 16 | array[offset + 1] << 8 | array[offset]; +} +binary.readInt32LE = readInt32LE; +function readUint32LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + return (array[offset + 3] << 24 | array[offset + 2] << 16 | array[offset + 1] << 8 | array[offset]) >>> 0; +} +binary.readUint32LE = readUint32LE; +function writeUint32BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(4); + } + if (offset === void 0) { + offset = 0; + } + out[offset + 0] = value >>> 24; + out[offset + 1] = value >>> 16; + out[offset + 2] = value >>> 8; + out[offset + 3] = value >>> 0; + return out; +} +binary.writeUint32BE = writeUint32BE; +binary.writeInt32BE = writeUint32BE; +function writeUint32LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(4); + } + if (offset === void 0) { + offset = 0; + } + out[offset + 0] = value >>> 0; + out[offset + 1] = value >>> 8; + out[offset + 2] = value >>> 16; + out[offset + 3] = value >>> 24; + return out; +} +binary.writeUint32LE = writeUint32LE; +binary.writeInt32LE = writeUint32LE; +function readInt64BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var hi = readInt32BE(array, offset); + var lo2 = readInt32BE(array, offset + 4); + return hi * 4294967296 + lo2 - (lo2 >> 31) * 4294967296; +} +binary.readInt64BE = readInt64BE; +function readUint64BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var hi = readUint32BE(array, offset); + var lo2 = readUint32BE(array, offset + 4); + return hi * 4294967296 + lo2; +} +binary.readUint64BE = readUint64BE; +function readInt64LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var lo2 = readInt32LE(array, offset); + var hi = readInt32LE(array, offset + 4); + return hi * 4294967296 + lo2 - (lo2 >> 31) * 4294967296; +} +binary.readInt64LE = readInt64LE; +function readUint64LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var lo2 = readUint32LE(array, offset); + var hi = readUint32LE(array, offset + 4); + return hi * 4294967296 + lo2; +} +binary.readUint64LE = readUint64LE; +function writeUint64BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(8); + } + if (offset === void 0) { + offset = 0; + } + writeUint32BE(value / 4294967296 >>> 0, out, offset); + writeUint32BE(value >>> 0, out, offset + 4); + return out; +} +binary.writeUint64BE = writeUint64BE; +binary.writeInt64BE = writeUint64BE; +function writeUint64LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(8); + } + if (offset === void 0) { + offset = 0; + } + writeUint32LE(value >>> 0, out, offset); + writeUint32LE(value / 4294967296 >>> 0, out, offset + 4); + return out; +} +binary.writeUint64LE = writeUint64LE; +binary.writeInt64LE = writeUint64LE; +function readUintBE(bitLength, array, offset) { + if (offset === void 0) { + offset = 0; + } + if (bitLength % 8 !== 0) { + throw new Error("readUintBE supports only bitLengths divisible by 8"); + } + if (bitLength / 8 > array.length - offset) { + throw new Error("readUintBE: array is too short for the given bitLength"); + } + var result = 0; + var mul = 1; + for (var i2 = bitLength / 8 + offset - 1; i2 >= offset; i2--) { + result += array[i2] * mul; + mul *= 256; + } + return result; +} +binary.readUintBE = readUintBE; +function readUintLE(bitLength, array, offset) { + if (offset === void 0) { + offset = 0; + } + if (bitLength % 8 !== 0) { + throw new Error("readUintLE supports only bitLengths divisible by 8"); + } + if (bitLength / 8 > array.length - offset) { + throw new Error("readUintLE: array is too short for the given bitLength"); + } + var result = 0; + var mul = 1; + for (var i2 = offset; i2 < offset + bitLength / 8; i2++) { + result += array[i2] * mul; + mul *= 256; + } + return result; +} +binary.readUintLE = readUintLE; +function writeUintBE(bitLength, value, out, offset) { + if (out === void 0) { + out = new Uint8Array(bitLength / 8); + } + if (offset === void 0) { + offset = 0; + } + if (bitLength % 8 !== 0) { + throw new Error("writeUintBE supports only bitLengths divisible by 8"); + } + if (!int_1.isSafeInteger(value)) { + throw new Error("writeUintBE value must be an integer"); + } + var div = 1; + for (var i2 = bitLength / 8 + offset - 1; i2 >= offset; i2--) { + out[i2] = value / div & 255; + div *= 256; + } + return out; +} +binary.writeUintBE = writeUintBE; +function writeUintLE(bitLength, value, out, offset) { + if (out === void 0) { + out = new Uint8Array(bitLength / 8); + } + if (offset === void 0) { + offset = 0; + } + if (bitLength % 8 !== 0) { + throw new Error("writeUintLE supports only bitLengths divisible by 8"); + } + if (!int_1.isSafeInteger(value)) { + throw new Error("writeUintLE value must be an integer"); + } + var div = 1; + for (var i2 = offset; i2 < offset + bitLength / 8; i2++) { + out[i2] = value / div & 255; + div *= 256; + } + return out; +} +binary.writeUintLE = writeUintLE; +function readFloat32BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var view = new DataView(array.buffer, array.byteOffset, array.byteLength); + return view.getFloat32(offset); +} +binary.readFloat32BE = readFloat32BE; +function readFloat32LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var view = new DataView(array.buffer, array.byteOffset, array.byteLength); + return view.getFloat32(offset, true); +} +binary.readFloat32LE = readFloat32LE; +function readFloat64BE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var view = new DataView(array.buffer, array.byteOffset, array.byteLength); + return view.getFloat64(offset); +} +binary.readFloat64BE = readFloat64BE; +function readFloat64LE(array, offset) { + if (offset === void 0) { + offset = 0; + } + var view = new DataView(array.buffer, array.byteOffset, array.byteLength); + return view.getFloat64(offset, true); +} +binary.readFloat64LE = readFloat64LE; +function writeFloat32BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(4); + } + if (offset === void 0) { + offset = 0; + } + var view = new DataView(out.buffer, out.byteOffset, out.byteLength); + view.setFloat32(offset, value); + return out; +} +binary.writeFloat32BE = writeFloat32BE; +function writeFloat32LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(4); + } + if (offset === void 0) { + offset = 0; + } + var view = new DataView(out.buffer, out.byteOffset, out.byteLength); + view.setFloat32(offset, value, true); + return out; +} +binary.writeFloat32LE = writeFloat32LE; +function writeFloat64BE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(8); + } + if (offset === void 0) { + offset = 0; + } + var view = new DataView(out.buffer, out.byteOffset, out.byteLength); + view.setFloat64(offset, value); + return out; +} +binary.writeFloat64BE = writeFloat64BE; +function writeFloat64LE(value, out, offset) { + if (out === void 0) { + out = new Uint8Array(8); + } + if (offset === void 0) { + offset = 0; + } + var view = new DataView(out.buffer, out.byteOffset, out.byteLength); + view.setFloat64(offset, value, true); + return out; +} +binary.writeFloat64LE = writeFloat64LE; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.randomStringForEntropy = exports2.randomString = exports2.randomUint32 = exports2.randomBytes = exports2.defaultRandomSource = void 0; + const system_1 = system; + const binary_12 = binary; + const wipe_12 = wipe$1; + exports2.defaultRandomSource = new system_1.SystemRandomSource(); + function randomBytes(length, prng = exports2.defaultRandomSource) { + return prng.randomBytes(length); + } + exports2.randomBytes = randomBytes; + function randomUint32(prng = exports2.defaultRandomSource) { + const buf = randomBytes(4, prng); + const result = (0, binary_12.readUint32LE)(buf); + (0, wipe_12.wipe)(buf); + return result; + } + exports2.randomUint32 = randomUint32; + const ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + function randomString(length, charset = ALPHANUMERIC, prng = exports2.defaultRandomSource) { + if (charset.length < 2) { + throw new Error("randomString charset is too short"); + } + if (charset.length > 256) { + throw new Error("randomString charset is too long"); + } + let out = ""; + const charsLen = charset.length; + const maxByte = 256 - 256 % charsLen; + while (length > 0) { + const buf = randomBytes(Math.ceil(length * 256 / maxByte), prng); + for (let i2 = 0; i2 < buf.length && length > 0; i2++) { + const randomByte = buf[i2]; + if (randomByte < maxByte) { + out += charset.charAt(randomByte % charsLen); + length--; + } + } + (0, wipe_12.wipe)(buf); + } + return out; + } + exports2.randomString = randomString; + function randomStringForEntropy(bits, charset = ALPHANUMERIC, prng = exports2.defaultRandomSource) { + const length = Math.ceil(bits / (Math.log(charset.length) / Math.LN2)); + return randomString(length, charset, prng); + } + exports2.randomStringForEntropy = randomStringForEntropy; +})(random); +var sha512 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var binary_12 = binary; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 64; + exports2.BLOCK_SIZE = 128; + var SHA512 = ( + /** @class */ + function() { + function SHA5122() { + this.digestLength = exports2.DIGEST_LENGTH; + this.blockSize = exports2.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 = false; + this.reset(); + } + SHA5122.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; + }; + SHA5122.prototype.reset = function() { + this._initState(); + this._bufferLength = 0; + this._bytesHashed = 0; + this._finished = false; + return this; + }; + SHA5122.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._tempHi); + wipe_12.wipe(this._tempLo); + this.reset(); + }; + SHA5122.prototype.update = function(data, dataLength) { + if (dataLength === void 0) { + dataLength = data.length; + } + if (this._finished) { + throw new Error("SHA512: can't update because hash was finished."); + } + var dataPos = 0; + this._bytesHashed += dataLength; + if (this._bufferLength > 0) { + while (this._bufferLength < exports2.BLOCK_SIZE && dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + if (this._bufferLength === this.blockSize) { + hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, this.blockSize); + this._bufferLength = 0; + } + } + if (dataLength >= this.blockSize) { + dataPos = hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, data, dataPos, dataLength); + dataLength %= this.blockSize; + } + while (dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + return this; + }; + SHA5122.prototype.finish = function(out) { + if (!this._finished) { + var bytesHashed = this._bytesHashed; + var left = this._bufferLength; + var bitLenHi = bytesHashed / 536870912 | 0; + var bitLenLo = bytesHashed << 3; + var padLength = bytesHashed % 128 < 112 ? 128 : 256; + this._buffer[left] = 128; + for (var i2 = left + 1; i2 < padLength - 8; i2++) { + this._buffer[i2] = 0; + } + binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); + binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); + hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, padLength); + this._finished = true; + } + for (var i2 = 0; i2 < this.digestLength / 8; i2++) { + binary_12.writeUint32BE(this._stateHi[i2], out, i2 * 8); + binary_12.writeUint32BE(this._stateLo[i2], out, i2 * 8 + 4); + } + return this; + }; + SHA5122.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + SHA5122.prototype.saveState = function() { + if (this._finished) { + throw new Error("SHA256: cannot save finished state"); + } + return { + stateHi: new Int32Array(this._stateHi), + stateLo: new Int32Array(this._stateLo), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }; + SHA5122.prototype.restoreState = function(savedState) { + this._stateHi.set(savedState.stateHi); + this._stateLo.set(savedState.stateLo); + this._bufferLength = savedState.bufferLength; + if (savedState.buffer) { + this._buffer.set(savedState.buffer); + } + this._bytesHashed = savedState.bytesHashed; + this._finished = false; + return this; + }; + SHA5122.prototype.cleanSavedState = function(savedState) { + wipe_12.wipe(savedState.stateHi); + wipe_12.wipe(savedState.stateLo); + if (savedState.buffer) { + wipe_12.wipe(savedState.buffer); + } + savedState.bufferLength = 0; + savedState.bytesHashed = 0; + }; + return SHA5122; + }() + ); + exports2.SHA512 = SHA512; + var K3 = 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 hashBlocks(wh, wl, hh2, hl, m3, pos, len) { + var ah0 = hh2[0], ah1 = hh2[1], ah2 = hh2[2], ah3 = hh2[3], ah4 = hh2[4], ah5 = hh2[5], ah6 = hh2[6], ah7 = hh2[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; + var h4, l2; + var th2, tl; + var a3, b3, c2, d5; + while (len >= 128) { + for (var i2 = 0; i2 < 16; i2++) { + var j2 = 8 * i2 + pos; + wh[i2] = binary_12.readUint32BE(m3, j2); + wl[i2] = binary_12.readUint32BE(m3, j2 + 4); + } + for (var i2 = 0; i2 < 80; i2++) { + var bh0 = ah0; + var bh1 = ah1; + var bh2 = ah2; + var bh3 = ah3; + var bh4 = ah4; + var bh5 = ah5; + var bh6 = ah6; + var bh7 = ah7; + var bl0 = al0; + var bl1 = al1; + var bl2 = al2; + var bl3 = al3; + var bl4 = al4; + var bl5 = al5; + var bl6 = al6; + var bl7 = al7; + h4 = ah7; + l2 = al7; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32)); + l2 = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32)); + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + h4 = ah4 & ah5 ^ ~ah4 & ah6; + l2 = al4 & al5 ^ ~al4 & al6; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + h4 = K3[i2 * 2]; + l2 = K3[i2 * 2 + 1]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + h4 = wh[i2 % 16]; + l2 = wl[i2 % 16]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + th2 = c2 & 65535 | d5 << 16; + tl = a3 & 65535 | b3 << 16; + h4 = th2; + l2 = tl; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32)); + l2 = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32)); + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + h4 = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2; + l2 = al0 & al1 ^ al0 & al2 ^ al1 & al2; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + bh7 = c2 & 65535 | d5 << 16; + bl7 = a3 & 65535 | b3 << 16; + h4 = bh3; + l2 = bl3; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = th2; + l2 = tl; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + bh3 = c2 & 65535 | d5 << 16; + bl3 = a3 & 65535 | b3 << 16; + ah1 = bh0; + ah2 = bh1; + ah3 = bh2; + ah4 = bh3; + ah5 = bh4; + ah6 = bh5; + ah7 = bh6; + ah0 = bh7; + al1 = bl0; + al2 = bl1; + al3 = bl2; + al4 = bl3; + al5 = bl4; + al6 = bl5; + al7 = bl6; + al0 = bl7; + if (i2 % 16 === 15) { + for (var j2 = 0; j2 < 16; j2++) { + h4 = wh[j2]; + l2 = wl[j2]; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = wh[(j2 + 9) % 16]; + l2 = wl[(j2 + 9) % 16]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + th2 = wh[(j2 + 1) % 16]; + tl = wl[(j2 + 1) % 16]; + h4 = (th2 >>> 1 | tl << 32 - 1) ^ (th2 >>> 8 | tl << 32 - 8) ^ th2 >>> 7; + l2 = (tl >>> 1 | th2 << 32 - 1) ^ (tl >>> 8 | th2 << 32 - 8) ^ (tl >>> 7 | th2 << 32 - 7); + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + th2 = wh[(j2 + 14) % 16]; + tl = wl[(j2 + 14) % 16]; + h4 = (th2 >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th2 << 32 - (61 - 32)) ^ th2 >>> 6; + l2 = (tl >>> 19 | th2 << 32 - 19) ^ (th2 >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th2 << 32 - 6); + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + wh[j2] = c2 & 65535 | d5 << 16; + wl[j2] = a3 & 65535 | b3 << 16; + } + } + } + h4 = ah0; + l2 = al0; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[0]; + l2 = hl[0]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[0] = ah0 = c2 & 65535 | d5 << 16; + hl[0] = al0 = a3 & 65535 | b3 << 16; + h4 = ah1; + l2 = al1; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[1]; + l2 = hl[1]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[1] = ah1 = c2 & 65535 | d5 << 16; + hl[1] = al1 = a3 & 65535 | b3 << 16; + h4 = ah2; + l2 = al2; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[2]; + l2 = hl[2]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[2] = ah2 = c2 & 65535 | d5 << 16; + hl[2] = al2 = a3 & 65535 | b3 << 16; + h4 = ah3; + l2 = al3; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[3]; + l2 = hl[3]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[3] = ah3 = c2 & 65535 | d5 << 16; + hl[3] = al3 = a3 & 65535 | b3 << 16; + h4 = ah4; + l2 = al4; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[4]; + l2 = hl[4]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[4] = ah4 = c2 & 65535 | d5 << 16; + hl[4] = al4 = a3 & 65535 | b3 << 16; + h4 = ah5; + l2 = al5; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[5]; + l2 = hl[5]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[5] = ah5 = c2 & 65535 | d5 << 16; + hl[5] = al5 = a3 & 65535 | b3 << 16; + h4 = ah6; + l2 = al6; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[6]; + l2 = hl[6]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[6] = ah6 = c2 & 65535 | d5 << 16; + hl[6] = al6 = a3 & 65535 | b3 << 16; + h4 = ah7; + l2 = al7; + a3 = l2 & 65535; + b3 = l2 >>> 16; + c2 = h4 & 65535; + d5 = h4 >>> 16; + h4 = hh2[7]; + l2 = hl[7]; + a3 += l2 & 65535; + b3 += l2 >>> 16; + c2 += h4 & 65535; + d5 += h4 >>> 16; + b3 += a3 >>> 16; + c2 += b3 >>> 16; + d5 += c2 >>> 16; + hh2[7] = ah7 = c2 & 65535 | d5 << 16; + hl[7] = al7 = a3 & 65535 | b3 << 16; + pos += 128; + len -= 128; + } + return pos; + } + function hash2(data) { + var h4 = new SHA512(); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.hash = hash2; +})(sha512); +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.convertSecretKeyToX25519 = exports2.convertPublicKeyToX25519 = exports2.verify = exports2.sign = exports2.extractPublicKeyFromSecretKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.SEED_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = exports2.SIGNATURE_LENGTH = void 0; + const random_1 = random; + const sha512_1 = sha512; + const wipe_12 = wipe$1; + exports2.SIGNATURE_LENGTH = 64; + exports2.PUBLIC_KEY_LENGTH = 32; + exports2.SECRET_KEY_LENGTH = 64; + exports2.SEED_LENGTH = 32; + function gf2(init) { + const r3 = new Float64Array(16); + if (init) { + for (let i2 = 0; i2 < init.length; i2++) { + r3[i2] = init[i2]; + } + } + return r3; + } + const _9 = new Uint8Array(32); + _9[0] = 9; + const gf0 = gf2(); + const gf1 = gf2([1]); + const D2 = gf2([ + 30883, + 4953, + 19914, + 30187, + 55467, + 16705, + 2637, + 112, + 59544, + 30585, + 16505, + 36039, + 65139, + 11119, + 27886, + 20995 + ]); + const D22 = gf2([ + 61785, + 9906, + 39828, + 60374, + 45398, + 33411, + 5274, + 224, + 53552, + 61171, + 33010, + 6542, + 64743, + 22239, + 55772, + 9222 + ]); + const X2 = gf2([ + 54554, + 36645, + 11616, + 51542, + 42930, + 38181, + 51040, + 26924, + 56412, + 64982, + 57905, + 49316, + 21502, + 52590, + 14035, + 8553 + ]); + const Y2 = gf2([ + 26200, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214 + ]); + const I2 = gf2([ + 41136, + 18958, + 6951, + 50414, + 58488, + 44335, + 6150, + 12099, + 55207, + 15867, + 153, + 11085, + 57099, + 20417, + 9344, + 11139 + ]); + function set25519(r3, a3) { + for (let i2 = 0; i2 < 16; i2++) { + r3[i2] = a3[i2] | 0; + } + } + function car25519(o2) { + let c2 = 1; + for (let i2 = 0; i2 < 16; i2++) { + let v3 = o2[i2] + c2 + 65535; + c2 = Math.floor(v3 / 65536); + o2[i2] = v3 - c2 * 65536; + } + o2[0] += c2 - 1 + 37 * (c2 - 1); + } + function sel25519(p2, q2, b3) { + const c2 = ~(b3 - 1); + for (let i2 = 0; i2 < 16; i2++) { + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; + q2[i2] ^= t2; + } + } + function pack25519(o2, n4) { + const m3 = gf2(); + const t2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + t2[i2] = n4[i2]; + } + car25519(t2); + car25519(t2); + car25519(t2); + for (let j2 = 0; j2 < 2; j2++) { + m3[0] = t2[0] - 65517; + for (let i2 = 1; i2 < 15; i2++) { + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; + } + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); + } + for (let i2 = 0; i2 < 16; i2++) { + o2[2 * i2] = t2[i2] & 255; + o2[2 * i2 + 1] = t2[i2] >> 8; + } + } + function verify32(x2, y3) { + let d5 = 0; + for (let i2 = 0; i2 < 32; i2++) { + d5 |= x2[i2] ^ y3[i2]; + } + return (1 & d5 - 1 >>> 8) - 1; + } + function neq25519(a3, b3) { + const c2 = new Uint8Array(32); + const d5 = new Uint8Array(32); + pack25519(c2, a3); + pack25519(d5, b3); + return verify32(c2, d5); + } + function par25519(a3) { + const d5 = new Uint8Array(32); + pack25519(d5, a3); + return d5[0] & 1; + } + function unpack25519(o2, n4) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); + } + o2[15] &= 32767; + } + function add(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] + b3[i2]; + } + } + function sub(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] - b3[i2]; + } + } + function mul(o2, a3, b3) { + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + v3 = a3[0]; + t0 += v3 * b02; + t1 += v3 * b1; + t2 += v3 * b22; + t3 += v3 * b32; + t4 += v3 * b4; + t5 += v3 * b5; + t6 += v3 * b6; + t7 += v3 * b7; + t8 += v3 * b8; + t9 += v3 * b9; + t10 += v3 * b10; + t11 += v3 * b11; + t12 += v3 * b12; + t13 += v3 * b13; + t14 += v3 * b14; + t15 += v3 * b15; + v3 = a3[1]; + t1 += v3 * b02; + t2 += v3 * b1; + t3 += v3 * b22; + t4 += v3 * b32; + t5 += v3 * b4; + t6 += v3 * b5; + t7 += v3 * b6; + t8 += v3 * b7; + t9 += v3 * b8; + t10 += v3 * b9; + t11 += v3 * b10; + t12 += v3 * b11; + t13 += v3 * b12; + t14 += v3 * b13; + t15 += v3 * b14; + t16 += v3 * b15; + v3 = a3[2]; + t2 += v3 * b02; + t3 += v3 * b1; + t4 += v3 * b22; + t5 += v3 * b32; + t6 += v3 * b4; + t7 += v3 * b5; + t8 += v3 * b6; + t9 += v3 * b7; + t10 += v3 * b8; + t11 += v3 * b9; + t12 += v3 * b10; + t13 += v3 * b11; + t14 += v3 * b12; + t15 += v3 * b13; + t16 += v3 * b14; + t17 += v3 * b15; + v3 = a3[3]; + t3 += v3 * b02; + t4 += v3 * b1; + t5 += v3 * b22; + t6 += v3 * b32; + t7 += v3 * b4; + t8 += v3 * b5; + t9 += v3 * b6; + t10 += v3 * b7; + t11 += v3 * b8; + t12 += v3 * b9; + t13 += v3 * b10; + t14 += v3 * b11; + t15 += v3 * b12; + t16 += v3 * b13; + t17 += v3 * b14; + t18 += v3 * b15; + v3 = a3[4]; + t4 += v3 * b02; + t5 += v3 * b1; + t6 += v3 * b22; + t7 += v3 * b32; + t8 += v3 * b4; + t9 += v3 * b5; + t10 += v3 * b6; + t11 += v3 * b7; + t12 += v3 * b8; + t13 += v3 * b9; + t14 += v3 * b10; + t15 += v3 * b11; + t16 += v3 * b12; + t17 += v3 * b13; + t18 += v3 * b14; + t19 += v3 * b15; + v3 = a3[5]; + t5 += v3 * b02; + t6 += v3 * b1; + t7 += v3 * b22; + t8 += v3 * b32; + t9 += v3 * b4; + t10 += v3 * b5; + t11 += v3 * b6; + t12 += v3 * b7; + t13 += v3 * b8; + t14 += v3 * b9; + t15 += v3 * b10; + t16 += v3 * b11; + t17 += v3 * b12; + t18 += v3 * b13; + t19 += v3 * b14; + t20 += v3 * b15; + v3 = a3[6]; + t6 += v3 * b02; + t7 += v3 * b1; + t8 += v3 * b22; + t9 += v3 * b32; + t10 += v3 * b4; + t11 += v3 * b5; + t12 += v3 * b6; + t13 += v3 * b7; + t14 += v3 * b8; + t15 += v3 * b9; + t16 += v3 * b10; + t17 += v3 * b11; + t18 += v3 * b12; + t19 += v3 * b13; + t20 += v3 * b14; + t21 += v3 * b15; + v3 = a3[7]; + t7 += v3 * b02; + t8 += v3 * b1; + t9 += v3 * b22; + t10 += v3 * b32; + t11 += v3 * b4; + t12 += v3 * b5; + t13 += v3 * b6; + t14 += v3 * b7; + t15 += v3 * b8; + t16 += v3 * b9; + t17 += v3 * b10; + t18 += v3 * b11; + t19 += v3 * b12; + t20 += v3 * b13; + t21 += v3 * b14; + t22 += v3 * b15; + v3 = a3[8]; + t8 += v3 * b02; + t9 += v3 * b1; + t10 += v3 * b22; + t11 += v3 * b32; + t12 += v3 * b4; + t13 += v3 * b5; + t14 += v3 * b6; + t15 += v3 * b7; + t16 += v3 * b8; + t17 += v3 * b9; + t18 += v3 * b10; + t19 += v3 * b11; + t20 += v3 * b12; + t21 += v3 * b13; + t22 += v3 * b14; + t23 += v3 * b15; + v3 = a3[9]; + t9 += v3 * b02; + t10 += v3 * b1; + t11 += v3 * b22; + t12 += v3 * b32; + t13 += v3 * b4; + t14 += v3 * b5; + t15 += v3 * b6; + t16 += v3 * b7; + t17 += v3 * b8; + t18 += v3 * b9; + t19 += v3 * b10; + t20 += v3 * b11; + t21 += v3 * b12; + t22 += v3 * b13; + t23 += v3 * b14; + t24 += v3 * b15; + v3 = a3[10]; + t10 += v3 * b02; + t11 += v3 * b1; + t12 += v3 * b22; + t13 += v3 * b32; + t14 += v3 * b4; + t15 += v3 * b5; + t16 += v3 * b6; + t17 += v3 * b7; + t18 += v3 * b8; + t19 += v3 * b9; + t20 += v3 * b10; + t21 += v3 * b11; + t22 += v3 * b12; + t23 += v3 * b13; + t24 += v3 * b14; + t25 += v3 * b15; + v3 = a3[11]; + t11 += v3 * b02; + t12 += v3 * b1; + t13 += v3 * b22; + t14 += v3 * b32; + t15 += v3 * b4; + t16 += v3 * b5; + t17 += v3 * b6; + t18 += v3 * b7; + t19 += v3 * b8; + t20 += v3 * b9; + t21 += v3 * b10; + t22 += v3 * b11; + t23 += v3 * b12; + t24 += v3 * b13; + t25 += v3 * b14; + t26 += v3 * b15; + v3 = a3[12]; + t12 += v3 * b02; + t13 += v3 * b1; + t14 += v3 * b22; + t15 += v3 * b32; + t16 += v3 * b4; + t17 += v3 * b5; + t18 += v3 * b6; + t19 += v3 * b7; + t20 += v3 * b8; + t21 += v3 * b9; + t22 += v3 * b10; + t23 += v3 * b11; + t24 += v3 * b12; + t25 += v3 * b13; + t26 += v3 * b14; + t27 += v3 * b15; + v3 = a3[13]; + t13 += v3 * b02; + t14 += v3 * b1; + t15 += v3 * b22; + t16 += v3 * b32; + t17 += v3 * b4; + t18 += v3 * b5; + t19 += v3 * b6; + t20 += v3 * b7; + t21 += v3 * b8; + t22 += v3 * b9; + t23 += v3 * b10; + t24 += v3 * b11; + t25 += v3 * b12; + t26 += v3 * b13; + t27 += v3 * b14; + t28 += v3 * b15; + v3 = a3[14]; + t14 += v3 * b02; + t15 += v3 * b1; + t16 += v3 * b22; + t17 += v3 * b32; + t18 += v3 * b4; + t19 += v3 * b5; + t20 += v3 * b6; + t21 += v3 * b7; + t22 += v3 * b8; + t23 += v3 * b9; + t24 += v3 * b10; + t25 += v3 * b11; + t26 += v3 * b12; + t27 += v3 * b13; + t28 += v3 * b14; + t29 += v3 * b15; + v3 = a3[15]; + t15 += v3 * b02; + t16 += v3 * b1; + t17 += v3 * b22; + t18 += v3 * b32; + t19 += v3 * b4; + t20 += v3 * b5; + t21 += v3 * b6; + t22 += v3 * b7; + t23 += v3 * b8; + t24 += v3 * b9; + t25 += v3 * b10; + t26 += v3 * b11; + t27 += v3 * b12; + t28 += v3 * b13; + t29 += v3 * b14; + t30 += v3 * b15; + t0 += 38 * t16; + t1 += 38 * t17; + t2 += 38 * t18; + t3 += 38 * t19; + t4 += 38 * t20; + t5 += 38 * t21; + t6 += 38 * t22; + t7 += 38 * t23; + t8 += 38 * t24; + t9 += 38 * t25; + t10 += 38 * t26; + t11 += 38 * t27; + t12 += 38 * t28; + t13 += 38 * t29; + t14 += 38 * t30; + c2 = 1; + v3 = t0 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t0 = v3 - c2 * 65536; + v3 = t1 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t1 = v3 - c2 * 65536; + v3 = t2 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t2 = v3 - c2 * 65536; + v3 = t3 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t3 = v3 - c2 * 65536; + v3 = t4 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t4 = v3 - c2 * 65536; + v3 = t5 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t5 = v3 - c2 * 65536; + v3 = t6 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t6 = v3 - c2 * 65536; + v3 = t7 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t7 = v3 - c2 * 65536; + v3 = t8 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t8 = v3 - c2 * 65536; + v3 = t9 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t9 = v3 - c2 * 65536; + v3 = t10 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t10 = v3 - c2 * 65536; + v3 = t11 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t11 = v3 - c2 * 65536; + v3 = t12 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t12 = v3 - c2 * 65536; + v3 = t13 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t13 = v3 - c2 * 65536; + v3 = t14 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t14 = v3 - c2 * 65536; + v3 = t15 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t15 = v3 - c2 * 65536; + t0 += c2 - 1 + 37 * (c2 - 1); + c2 = 1; + v3 = t0 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t0 = v3 - c2 * 65536; + v3 = t1 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t1 = v3 - c2 * 65536; + v3 = t2 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t2 = v3 - c2 * 65536; + v3 = t3 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t3 = v3 - c2 * 65536; + v3 = t4 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t4 = v3 - c2 * 65536; + v3 = t5 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t5 = v3 - c2 * 65536; + v3 = t6 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t6 = v3 - c2 * 65536; + v3 = t7 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t7 = v3 - c2 * 65536; + v3 = t8 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t8 = v3 - c2 * 65536; + v3 = t9 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t9 = v3 - c2 * 65536; + v3 = t10 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t10 = v3 - c2 * 65536; + v3 = t11 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t11 = v3 - c2 * 65536; + v3 = t12 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t12 = v3 - c2 * 65536; + v3 = t13 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t13 = v3 - c2 * 65536; + v3 = t14 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t14 = v3 - c2 * 65536; + v3 = t15 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t15 = v3 - c2 * 65536; + t0 += c2 - 1 + 37 * (c2 - 1); + o2[0] = t0; + o2[1] = t1; + o2[2] = t2; + o2[3] = t3; + o2[4] = t4; + o2[5] = t5; + o2[6] = t6; + o2[7] = t7; + o2[8] = t8; + o2[9] = t9; + o2[10] = t10; + o2[11] = t11; + o2[12] = t12; + o2[13] = t13; + o2[14] = t14; + o2[15] = t15; + } + function square(o2, a3) { + mul(o2, a3, a3); + } + function inv25519(o2, i2) { + const c2 = gf2(); + let a3; + for (a3 = 0; a3 < 16; a3++) { + c2[a3] = i2[a3]; + } + for (a3 = 253; a3 >= 0; a3--) { + square(c2, c2); + if (a3 !== 2 && a3 !== 4) { + mul(c2, c2, i2); + } + } + for (a3 = 0; a3 < 16; a3++) { + o2[a3] = c2[a3]; + } + } + function pow2523(o2, i2) { + const c2 = gf2(); + let a3; + for (a3 = 0; a3 < 16; a3++) { + c2[a3] = i2[a3]; + } + for (a3 = 250; a3 >= 0; a3--) { + square(c2, c2); + if (a3 !== 1) { + mul(c2, c2, i2); + } + } + for (a3 = 0; a3 < 16; a3++) { + o2[a3] = c2[a3]; + } + } + function edadd(p2, q2) { + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(), g3 = gf2(), h4 = gf2(), t2 = gf2(); + sub(a3, p2[1], p2[0]); + sub(t2, q2[1], q2[0]); + mul(a3, a3, t2); + add(b3, p2[0], p2[1]); + add(t2, q2[0], q2[1]); + mul(b3, b3, t2); + mul(c2, p2[3], q2[3]); + mul(c2, c2, D22); + mul(d5, p2[2], q2[2]); + add(d5, d5, d5); + sub(e2, b3, a3); + sub(f3, d5, c2); + add(g3, d5, c2); + add(h4, b3, a3); + mul(p2[0], e2, f3); + mul(p2[1], h4, g3); + mul(p2[2], g3, f3); + mul(p2[3], e2, h4); + } + function cswap(p2, q2, b3) { + for (let i2 = 0; i2 < 4; i2++) { + sel25519(p2[i2], q2[i2], b3); + } + } + function pack(r3, p2) { + const tx = gf2(), ty = gf2(), zi2 = gf2(); + inv25519(zi2, p2[2]); + mul(tx, p2[0], zi2); + mul(ty, p2[1], zi2); + pack25519(r3, ty); + r3[31] ^= par25519(tx) << 7; + } + function scalarmult(p2, q2, s2) { + set25519(p2[0], gf0); + set25519(p2[1], gf1); + set25519(p2[2], gf1); + set25519(p2[3], gf0); + for (let i2 = 255; i2 >= 0; --i2) { + const b3 = s2[i2 / 8 | 0] >> (i2 & 7) & 1; + cswap(p2, q2, b3); + edadd(q2, p2); + edadd(p2, p2); + cswap(p2, q2, b3); + } + } + function scalarbase(p2, s2) { + const q2 = [gf2(), gf2(), gf2(), gf2()]; + set25519(q2[0], X2); + set25519(q2[1], Y2); + set25519(q2[2], gf1); + mul(q2[3], X2, Y2); + scalarmult(p2, q2, s2); + } + function generateKeyPairFromSeed(seed) { + if (seed.length !== exports2.SEED_LENGTH) { + throw new Error(`ed25519: seed must be ${exports2.SEED_LENGTH} bytes`); + } + const d5 = (0, sha512_1.hash)(seed); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const publicKey = new Uint8Array(32); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + scalarbase(p2, d5); + pack(publicKey, p2); + const secretKey = new Uint8Array(64); + secretKey.set(seed); + secretKey.set(publicKey, 32); + return { + publicKey, + secretKey + }; + } + exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; + function generateKeyPair2(prng) { + const seed = (0, random_1.randomBytes)(32, prng); + const result = generateKeyPairFromSeed(seed); + (0, wipe_12.wipe)(seed); + return result; + } + exports2.generateKeyPair = generateKeyPair2; + function extractPublicKeyFromSecretKey(secretKey) { + if (secretKey.length !== exports2.SECRET_KEY_LENGTH) { + throw new Error(`ed25519: secret key must be ${exports2.SECRET_KEY_LENGTH} bytes`); + } + return new Uint8Array(secretKey.subarray(32)); + } + exports2.extractPublicKeyFromSecretKey = extractPublicKeyFromSecretKey; + const L4 = 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 modL(r3, x2) { + let carry; + let i2; + let j2; + let k2; + for (i2 = 63; i2 >= 32; --i2) { + carry = 0; + for (j2 = i2 - 32, k2 = i2 - 12; j2 < k2; ++j2) { + x2[j2] += carry - 16 * x2[i2] * L4[j2 - (i2 - 32)]; + carry = Math.floor((x2[j2] + 128) / 256); + x2[j2] -= carry * 256; + } + x2[j2] += carry; + x2[i2] = 0; + } + carry = 0; + for (j2 = 0; j2 < 32; j2++) { + x2[j2] += carry - (x2[31] >> 4) * L4[j2]; + carry = x2[j2] >> 8; + x2[j2] &= 255; + } + for (j2 = 0; j2 < 32; j2++) { + x2[j2] -= carry * L4[j2]; + } + for (i2 = 0; i2 < 32; i2++) { + x2[i2 + 1] += x2[i2] >> 8; + r3[i2] = x2[i2] & 255; + } + } + function reduce(r3) { + const x2 = new Float64Array(64); + for (let i2 = 0; i2 < 64; i2++) { + x2[i2] = r3[i2]; + } + for (let i2 = 0; i2 < 64; i2++) { + r3[i2] = 0; + } + modL(r3, x2); + } + function sign(secretKey, message) { + const x2 = new Float64Array(64); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const signature = new Uint8Array(64); + signature.set(d5.subarray(32), 32); + const hs2 = new sha512_1.SHA512(); + hs2.update(signature.subarray(32)); + hs2.update(message); + const r3 = hs2.digest(); + hs2.clean(); + reduce(r3); + scalarbase(p2, r3); + pack(signature, p2); + hs2.reset(); + hs2.update(signature.subarray(0, 32)); + hs2.update(secretKey.subarray(32)); + hs2.update(message); + const h4 = hs2.digest(); + reduce(h4); + for (let i2 = 0; i2 < 32; i2++) { + x2[i2] = r3[i2]; + } + for (let i2 = 0; i2 < 32; i2++) { + for (let j2 = 0; j2 < 32; j2++) { + x2[i2 + j2] += h4[i2] * d5[j2]; + } + } + modL(signature.subarray(32), x2); + return signature; + } + exports2.sign = sign; + function unpackneg(r3, p2) { + const t2 = gf2(), chk = gf2(), num = gf2(), den = gf2(), den2 = gf2(), den4 = gf2(), den6 = gf2(); + set25519(r3[2], gf1); + unpack25519(r3[1], p2); + square(num, r3[1]); + mul(den, num, D2); + sub(num, num, r3[2]); + add(den, r3[2], den); + square(den2, den); + square(den4, den2); + mul(den6, den4, den2); + mul(t2, den6, num); + mul(t2, t2, den); + pow2523(t2, t2); + mul(t2, t2, num); + mul(t2, t2, den); + mul(t2, t2, den); + mul(r3[0], t2, den); + square(chk, r3[0]); + mul(chk, chk, den); + if (neq25519(chk, num)) { + mul(r3[0], r3[0], I2); + } + square(chk, r3[0]); + mul(chk, chk, den); + if (neq25519(chk, num)) { + return -1; + } + if (par25519(r3[0]) === p2[31] >> 7) { + sub(r3[0], gf0, r3[0]); + } + mul(r3[3], r3[0], r3[1]); + return 0; + } + function verify(publicKey, message, signature) { + const t2 = new Uint8Array(32); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const q2 = [gf2(), gf2(), gf2(), gf2()]; + if (signature.length !== exports2.SIGNATURE_LENGTH) { + throw new Error(`ed25519: signature must be ${exports2.SIGNATURE_LENGTH} bytes`); + } + if (unpackneg(q2, publicKey)) { + return false; + } + const hs2 = new sha512_1.SHA512(); + hs2.update(signature.subarray(0, 32)); + hs2.update(publicKey); + hs2.update(message); + const h4 = hs2.digest(); + reduce(h4); + scalarmult(p2, q2, h4); + scalarbase(q2, signature.subarray(32)); + edadd(p2, q2); + pack(t2, p2); + if (verify32(signature, t2)) { + return false; + } + return true; + } + exports2.verify = verify; + function convertPublicKeyToX25519(publicKey) { + let q2 = [gf2(), gf2(), gf2(), gf2()]; + if (unpackneg(q2, publicKey)) { + throw new Error("Ed25519: invalid public key"); + } + let a3 = gf2(); + let b3 = gf2(); + let y3 = q2[1]; + add(a3, gf1, y3); + sub(b3, gf1, y3); + inv25519(b3, b3); + mul(a3, a3, b3); + let z2 = new Uint8Array(32); + pack25519(z2, a3); + return z2; + } + exports2.convertPublicKeyToX25519 = convertPublicKeyToX25519; + function convertSecretKeyToX25519(secretKey) { + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const o2 = new Uint8Array(d5.subarray(0, 32)); + (0, wipe_12.wipe)(d5); + return o2; + } + exports2.convertSecretKeyToX25519 = convertSecretKeyToX25519; +})(ed25519); +const JWT_IRIDIUM_ALG = "EdDSA"; +const JWT_IRIDIUM_TYP = "JWT"; +const JWT_DELIMITER = "."; +const JWT_ENCODING = "base64url"; +const JSON_ENCODING = "utf8"; +const DATA_ENCODING = "utf8"; +const DID_DELIMITER = ":"; +const DID_PREFIX = "did"; +const DID_METHOD = "key"; +const MULTICODEC_ED25519_ENCODING = "base58btc"; +const MULTICODEC_ED25519_BASE = "z"; +const MULTICODEC_ED25519_HEADER = "K36"; +const KEY_PAIR_SEED_LENGTH = 32; +function asUint8Array(buf) { + if (globalThis.Buffer != null) { + return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength); + } + return buf; +} +function allocUnsafe(size = 0) { + if (globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null) { + return asUint8Array(globalThis.Buffer.allocUnsafe(size)); + } + return new Uint8Array(size); +} +function concat(arrays, length) { + if (!length) { + length = arrays.reduce((acc, curr) => acc + curr.length, 0); + } + const output = allocUnsafe(length); + let offset = 0; + for (const arr of arrays) { + output.set(arr, offset); + offset += arr.length; + } + return asUint8Array(output); +} +function base(ALPHABET, name2) { + if (ALPHABET.length >= 255) { + throw new TypeError("Alphabet too long"); + } + var BASE_MAP = new Uint8Array(256); + for (var j2 = 0; j2 < BASE_MAP.length; j2++) { + BASE_MAP[j2] = 255; + } + for (var i2 = 0; i2 < ALPHABET.length; i2++) { + var x2 = ALPHABET.charAt(i2); + var xc = x2.charCodeAt(0); + if (BASE_MAP[xc] !== 255) { + throw new TypeError(x2 + " is ambiguous"); + } + BASE_MAP[xc] = i2; + } + var BASE = ALPHABET.length; + var LEADER = ALPHABET.charAt(0); + var FACTOR = Math.log(BASE) / Math.log(256); + var iFACTOR = Math.log(256) / Math.log(BASE); + function encode2(source) { + if (source instanceof Uint8Array) + ; + else if (ArrayBuffer.isView(source)) { + source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength); + } else if (Array.isArray(source)) { + source = Uint8Array.from(source); + } + if (!(source instanceof Uint8Array)) { + throw new TypeError("Expected Uint8Array"); + } + if (source.length === 0) { + return ""; + } + var zeroes = 0; + var length = 0; + var pbegin = 0; + var pend = source.length; + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++; + zeroes++; + } + var size = (pend - pbegin) * iFACTOR + 1 >>> 0; + var b58 = new Uint8Array(size); + while (pbegin !== pend) { + var carry = source[pbegin]; + var i3 = 0; + for (var it1 = size - 1; (carry !== 0 || i3 < length) && it1 !== -1; it1--, i3++) { + carry += 256 * b58[it1] >>> 0; + b58[it1] = carry % BASE >>> 0; + carry = carry / BASE >>> 0; + } + if (carry !== 0) { + throw new Error("Non-zero carry"); + } + length = i3; + pbegin++; + } + var it2 = size - length; + while (it2 !== size && b58[it2] === 0) { + it2++; + } + var str = LEADER.repeat(zeroes); + for (; it2 < size; ++it2) { + str += ALPHABET.charAt(b58[it2]); + } + return str; + } + function decodeUnsafe(source) { + if (typeof source !== "string") { + throw new TypeError("Expected String"); + } + if (source.length === 0) { + return new Uint8Array(); + } + var psz = 0; + if (source[psz] === " ") { + return; + } + var zeroes = 0; + var length = 0; + while (source[psz] === LEADER) { + zeroes++; + psz++; + } + var size = (source.length - psz) * FACTOR + 1 >>> 0; + var b256 = new Uint8Array(size); + while (source[psz]) { + var carry = BASE_MAP[source.charCodeAt(psz)]; + if (carry === 255) { + return; + } + var i3 = 0; + for (var it3 = size - 1; (carry !== 0 || i3 < length) && it3 !== -1; it3--, i3++) { + carry += BASE * b256[it3] >>> 0; + b256[it3] = carry % 256 >>> 0; + carry = carry / 256 >>> 0; + } + if (carry !== 0) { + throw new Error("Non-zero carry"); + } + length = i3; + psz++; + } + if (source[psz] === " ") { + return; + } + var it4 = size - length; + while (it4 !== size && b256[it4] === 0) { + it4++; + } + var vch = new Uint8Array(zeroes + (size - it4)); + var j3 = zeroes; + while (it4 !== size) { + vch[j3++] = b256[it4++]; + } + return vch; + } + function decode2(string2) { + var buffer = decodeUnsafe(string2); + if (buffer) { + return buffer; + } + throw new Error(`Non-${name2} character`); + } + return { + encode: encode2, + decodeUnsafe, + decode: decode2 + }; +} +var src = base; +var _brrp__multiformats_scope_baseX = src; +const coerce$1 = (o2) => { + if (o2 instanceof Uint8Array && o2.constructor.name === "Uint8Array") + return o2; + if (o2 instanceof ArrayBuffer) + return new Uint8Array(o2); + if (ArrayBuffer.isView(o2)) { + return new Uint8Array(o2.buffer, o2.byteOffset, o2.byteLength); + } + throw new Error("Unknown type, must be binary type"); +}; +const fromString$1 = (str) => new TextEncoder().encode(str); +const toString$1 = (b3) => new TextDecoder().decode(b3); +class Encoder { + constructor(name2, prefix, baseEncode) { + this.name = name2; + this.prefix = prefix; + this.baseEncode = baseEncode; + } + encode(bytes) { + if (bytes instanceof Uint8Array) { + return `${this.prefix}${this.baseEncode(bytes)}`; + } else { + throw Error("Unknown type, must be binary type"); + } + } +} +class Decoder { + constructor(name2, prefix, baseDecode) { + this.name = name2; + this.prefix = prefix; + if (prefix.codePointAt(0) === void 0) { + throw new Error("Invalid prefix character"); + } + this.prefixCodePoint = prefix.codePointAt(0); + this.baseDecode = baseDecode; + } + decode(text) { + if (typeof text === "string") { + if (text.codePointAt(0) !== this.prefixCodePoint) { + throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); + } + return this.baseDecode(text.slice(this.prefix.length)); + } else { + throw Error("Can only multibase decode strings"); + } + } + or(decoder) { + return or$3(this, decoder); + } +} +class ComposedDecoder { + constructor(decoders) { + this.decoders = decoders; + } + or(decoder) { + return or$3(this, decoder); + } + decode(input) { + const prefix = input[0]; + const decoder = this.decoders[prefix]; + if (decoder) { + return decoder.decode(input); + } else { + throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + } + } +} +const or$3 = (left, right) => new ComposedDecoder({ + ...left.decoders || { [left.prefix]: left }, + ...right.decoders || { [right.prefix]: right } +}); +class Codec { + constructor(name2, prefix, baseEncode, baseDecode) { + this.name = name2; + this.prefix = prefix; + this.baseEncode = baseEncode; + this.baseDecode = baseDecode; + this.encoder = new Encoder(name2, prefix, baseEncode); + this.decoder = new Decoder(name2, prefix, baseDecode); + } + encode(input) { + return this.encoder.encode(input); + } + decode(input) { + return this.decoder.decode(input); + } +} +const from = ({ name: name2, prefix, encode: encode2, decode: decode2 }) => new Codec(name2, prefix, encode2, decode2); +const baseX = ({ prefix, name: name2, alphabet: alphabet2 }) => { + const { encode: encode2, decode: decode2 } = _brrp__multiformats_scope_baseX(alphabet2, name2); + return from({ + prefix, + name: name2, + encode: encode2, + decode: (text) => coerce$1(decode2(text)) + }); +}; +const decode$2 = (string2, alphabet2, bitsPerChar, name2) => { + const codes = {}; + for (let i2 = 0; i2 < alphabet2.length; ++i2) { + codes[alphabet2[i2]] = i2; + } + let end = string2.length; + while (string2[end - 1] === "=") { + --end; + } + const out = new Uint8Array(end * bitsPerChar / 8 | 0); + let bits = 0; + let buffer = 0; + let written = 0; + for (let i2 = 0; i2 < end; ++i2) { + const value = codes[string2[i2]]; + if (value === void 0) { + throw new SyntaxError(`Non-${name2} character`); + } + buffer = buffer << bitsPerChar | value; + bits += bitsPerChar; + if (bits >= 8) { + bits -= 8; + out[written++] = 255 & buffer >> bits; + } + } + if (bits >= bitsPerChar || 255 & buffer << 8 - bits) { + throw new SyntaxError("Unexpected end of data"); + } + return out; +}; +const encode$1 = (data, alphabet2, bitsPerChar) => { + const pad = alphabet2[alphabet2.length - 1] === "="; + const mask = (1 << bitsPerChar) - 1; + let out = ""; + let bits = 0; + let buffer = 0; + for (let i2 = 0; i2 < data.length; ++i2) { + buffer = buffer << 8 | data[i2]; + bits += 8; + while (bits > bitsPerChar) { + bits -= bitsPerChar; + out += alphabet2[mask & buffer >> bits]; + } + } + if (bits) { + out += alphabet2[mask & buffer << bitsPerChar - bits]; + } + if (pad) { + while (out.length * bitsPerChar & 7) { + out += "="; + } + } + return out; +}; +const rfc4648 = ({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) => { + return from({ + prefix, + name: name2, + encode(input) { + return encode$1(input, alphabet2, bitsPerChar); + }, + decode(input) { + return decode$2(input, alphabet2, bitsPerChar, name2); + } + }); +}; +const identity = from({ + prefix: "\0", + name: "identity", + encode: (buf) => toString$1(buf), + decode: (str) => fromString$1(str) +}); +const identityBase = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + identity +}, Symbol.toStringTag, { value: "Module" })); +const base2 = rfc4648({ + prefix: "0", + name: "base2", + alphabet: "01", + bitsPerChar: 1 +}); +const base2$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base2 +}, Symbol.toStringTag, { value: "Module" })); +const base8 = rfc4648({ + prefix: "7", + name: "base8", + alphabet: "01234567", + bitsPerChar: 3 +}); +const base8$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base8 +}, Symbol.toStringTag, { value: "Module" })); +const base10 = baseX({ + prefix: "9", + name: "base10", + alphabet: "0123456789" +}); +const base10$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base10 +}, Symbol.toStringTag, { value: "Module" })); +const base16 = rfc4648({ + prefix: "f", + name: "base16", + alphabet: "0123456789abcdef", + bitsPerChar: 4 +}); +const base16upper = rfc4648({ + prefix: "F", + name: "base16upper", + alphabet: "0123456789ABCDEF", + bitsPerChar: 4 +}); +const base16$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base16, + base16upper +}, Symbol.toStringTag, { value: "Module" })); +const base32 = rfc4648({ + prefix: "b", + name: "base32", + alphabet: "abcdefghijklmnopqrstuvwxyz234567", + bitsPerChar: 5 +}); +const base32upper = rfc4648({ + prefix: "B", + name: "base32upper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", + bitsPerChar: 5 +}); +const base32pad = rfc4648({ + prefix: "c", + name: "base32pad", + alphabet: "abcdefghijklmnopqrstuvwxyz234567=", + bitsPerChar: 5 +}); +const base32padupper = rfc4648({ + prefix: "C", + name: "base32padupper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", + bitsPerChar: 5 +}); +const base32hex = rfc4648({ + prefix: "v", + name: "base32hex", + alphabet: "0123456789abcdefghijklmnopqrstuv", + bitsPerChar: 5 +}); +const base32hexupper = rfc4648({ + prefix: "V", + name: "base32hexupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", + bitsPerChar: 5 +}); +const base32hexpad = rfc4648({ + prefix: "t", + name: "base32hexpad", + alphabet: "0123456789abcdefghijklmnopqrstuv=", + bitsPerChar: 5 +}); +const base32hexpadupper = rfc4648({ + prefix: "T", + name: "base32hexpadupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", + bitsPerChar: 5 +}); +const base32z = rfc4648({ + prefix: "h", + name: "base32z", + alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", + bitsPerChar: 5 +}); +const base32$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base32, + base32hex, + base32hexpad, + base32hexpadupper, + base32hexupper, + base32pad, + base32padupper, + base32upper, + base32z +}, Symbol.toStringTag, { value: "Module" })); +const base36 = baseX({ + prefix: "k", + name: "base36", + alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" +}); +const base36upper = baseX({ + prefix: "K", + name: "base36upper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" +}); +const base36$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base36, + base36upper +}, Symbol.toStringTag, { value: "Module" })); +const base58btc = baseX({ + name: "base58btc", + prefix: "z", + alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" +}); +const base58flickr = baseX({ + name: "base58flickr", + prefix: "Z", + alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" +}); +const base58 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base58btc, + base58flickr +}, Symbol.toStringTag, { value: "Module" })); +const base64 = rfc4648({ + prefix: "m", + name: "base64", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + bitsPerChar: 6 +}); +const base64pad = rfc4648({ + prefix: "M", + name: "base64pad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + bitsPerChar: 6 +}); +const base64url = rfc4648({ + prefix: "u", + name: "base64url", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", + bitsPerChar: 6 +}); +const base64urlpad = rfc4648({ + prefix: "U", + name: "base64urlpad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", + bitsPerChar: 6 +}); +const base64$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base64, + base64pad, + base64url, + base64urlpad +}, Symbol.toStringTag, { value: "Module" })); +const alphabet = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"); +const alphabetBytesToChars = alphabet.reduce((p2, c2, i2) => { + p2[i2] = c2; + return p2; +}, []); +const alphabetCharsToBytes = alphabet.reduce((p2, c2, i2) => { + p2[c2.codePointAt(0)] = i2; + return p2; +}, []); +function encode(data) { + return data.reduce((p2, c2) => { + p2 += alphabetBytesToChars[c2]; + return p2; + }, ""); +} +function decode$1(str) { + const byts = []; + for (const char of str) { + const byt = alphabetCharsToBytes[char.codePointAt(0)]; + if (byt === void 0) { + throw new Error(`Non-base256emoji character: ${char}`); + } + byts.push(byt); + } + return new Uint8Array(byts); +} +const base256emoji = from({ + prefix: "🚀", + name: "base256emoji", + encode, + decode: decode$1 +}); +const base256emoji$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base256emoji +}, Symbol.toStringTag, { value: "Module" })); +new TextEncoder(); +new TextDecoder(); +const bases = { + ...identityBase, + ...base2$1, + ...base8$1, + ...base10$1, + ...base16$1, + ...base32$1, + ...base36$1, + ...base58, + ...base64$1, + ...base256emoji$1 +}; +function createCodec(name2, prefix, encode2, decode2) { + return { + name: name2, + prefix, + encoder: { + name: name2, + prefix, + encode: encode2 + }, + decoder: { decode: decode2 } + }; +} +const string = createCodec("utf8", "u", (buf) => { + const decoder = new TextDecoder("utf8"); + return "u" + decoder.decode(buf); +}, (str) => { + const encoder = new TextEncoder(); + return encoder.encode(str.substring(1)); +}); +const ascii = createCodec("ascii", "a", (buf) => { + let string2 = "a"; + for (let i2 = 0; i2 < buf.length; i2++) { + string2 += String.fromCharCode(buf[i2]); + } + return string2; +}, (str) => { + str = str.substring(1); + const buf = allocUnsafe(str.length); + for (let i2 = 0; i2 < str.length; i2++) { + buf[i2] = str.charCodeAt(i2); + } + return buf; +}); +const BASES = { + utf8: string, + "utf-8": string, + hex: bases.base16, + latin1: ascii, + ascii, + binary: ascii, + ...bases +}; +function toString(array, encoding = "utf8") { + const base3 = BASES[encoding]; + if (!base3) { + throw new Error(`Unsupported encoding "${encoding}"`); + } + if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { + return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString("utf8"); + } + return base3.encoder.encode(array).substring(1); +} +function fromString(string2, encoding = "utf8") { + const base3 = BASES[encoding]; + if (!base3) { + throw new Error(`Unsupported encoding "${encoding}"`); + } + if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { + return asUint8Array(globalThis.Buffer.from(string2, "utf-8")); + } + return base3.decoder.decode(`${base3.prefix}${string2}`); +} +function encodeJSON(val) { + return toString(fromString(safeJsonStringify(val), JSON_ENCODING), JWT_ENCODING); +} +function encodeIss(publicKey) { + const header = fromString(MULTICODEC_ED25519_HEADER, MULTICODEC_ED25519_ENCODING); + const multicodec = MULTICODEC_ED25519_BASE + toString(concat([header, publicKey]), MULTICODEC_ED25519_ENCODING); + return [DID_PREFIX, DID_METHOD, multicodec].join(DID_DELIMITER); +} +function encodeSig(bytes) { + return toString(bytes, JWT_ENCODING); +} +function encodeData(params) { + return fromString([encodeJSON(params.header), encodeJSON(params.payload)].join(JWT_DELIMITER), DATA_ENCODING); +} +function encodeJWT(params) { + return [ + encodeJSON(params.header), + encodeJSON(params.payload), + encodeSig(params.signature) + ].join(JWT_DELIMITER); +} +function generateKeyPair(seed = random.randomBytes(KEY_PAIR_SEED_LENGTH)) { + return ed25519.generateKeyPairFromSeed(seed); +} +async function signJWT(sub, aud, ttl, keyPair, iat = cjs$3.fromMiliseconds(Date.now())) { + const header = { alg: JWT_IRIDIUM_ALG, typ: JWT_IRIDIUM_TYP }; + const iss = encodeIss(keyPair.publicKey); + const exp = iat + ttl; + const payload = { iss, sub, aud, iat, exp }; + const data = encodeData({ header, payload }); + const signature = ed25519.sign(keyPair.secretKey, data); + return encodeJWT({ header, payload, signature }); +} +var __spreadArray = function(to2, from2, pack) { + if (pack || arguments.length === 2) + for (var i2 = 0, l2 = from2.length, ar3; i2 < l2; i2++) { + if (ar3 || !(i2 in from2)) { + if (!ar3) + ar3 = Array.prototype.slice.call(from2, 0, i2); + ar3[i2] = from2[i2]; + } + } + return to2.concat(ar3 || Array.prototype.slice.call(from2)); +}; +var BrowserInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BrowserInfo2(name2, version2, os2) { + this.name = name2; + this.version = version2; + this.os = os2; + this.type = "browser"; + } + return BrowserInfo2; + }() +); +var NodeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function NodeInfo2(version2) { + this.version = version2; + this.type = "node"; + this.name = "node"; + this.os = process.platform; + } + return NodeInfo2; + }() +); +var SearchBotDeviceInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function SearchBotDeviceInfo2(name2, version2, os2, bot) { + this.name = name2; + this.version = version2; + this.os = os2; + this.bot = bot; + this.type = "bot-device"; + } + return SearchBotDeviceInfo2; + }() +); +var BotInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BotInfo2() { + this.type = "bot"; + this.bot = true; + this.name = "bot"; + this.version = null; + this.os = null; + } + return BotInfo2; + }() +); +var ReactNativeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function ReactNativeInfo2() { + this.type = "react-native"; + this.name = "react-native"; + this.version = null; + this.os = null; + } + return ReactNativeInfo2; + }() +); +var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; +var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; +var REQUIRED_VERSION_PARTS = 3; +var userAgentRules = [ + ["aol", /AOLShield\/([0-9\._]+)/], + ["edge", /Edge\/([0-9\._]+)/], + ["edge-ios", /EdgiOS\/([0-9\._]+)/], + ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], + ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], + ["samsung", /SamsungBrowser\/([0-9\.]+)/], + ["silk", /\bSilk\/([0-9._-]+)\b/], + ["miui", /MiuiBrowser\/([0-9\.]+)$/], + ["beaker", /BeakerBrowser\/([0-9\.]+)/], + ["edge-chromium", /EdgA?\/([0-9\.]+)/], + [ + "chromium-webview", + /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ + ], + ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], + ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], + ["fxios", /FxiOS\/([0-9\.]+)/], + ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], + ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], + ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], + ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], + ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], + ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], + ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ["ie", /MSIE\s(7\.0)/], + ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], + ["android", /Android\s([0-9\.]+)/], + ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ["safari", /Version\/([0-9\._]+).*Safari/], + ["facebook", /FB[AS]V\/([0-9\.]+)/], + ["instagram", /Instagram\s([0-9\.]+)/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ["curl", /^curl\/([0-9\.]+)$/], + ["searchbot", SEARCHBOX_UA_REGEX] +]; +var operatingSystemRules = [ + ["iOS", /iP(hone|od|ad)/], + ["Android OS", /Android/], + ["BlackBerry OS", /BlackBerry|BB10/], + ["Windows Mobile", /IEMobile/], + ["Amazon OS", /Kindle/], + ["Windows 3.11", /Win16/], + ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], + ["Windows 98", /(Windows 98)|(Win98)/], + ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], + ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], + ["Windows Server 2003", /(Windows NT 5.2)/], + ["Windows Vista", /(Windows NT 6.0)/], + ["Windows 7", /(Windows NT 6.1)/], + ["Windows 8", /(Windows NT 6.2)/], + ["Windows 8.1", /(Windows NT 6.3)/], + ["Windows 10", /(Windows NT 10.0)/], + ["Windows ME", /Windows ME/], + ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], + ["Open BSD", /OpenBSD/], + ["Sun OS", /SunOS/], + ["Chrome OS", /CrOS/], + ["Linux", /(Linux)|(X11)/], + ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], + ["QNX", /QNX/], + ["BeOS", /BeOS/], + ["OS/2", /OS\/2/] +]; +function detect(userAgent) { + if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { + return new ReactNativeInfo(); + } + if (typeof navigator !== "undefined") { + return parseUserAgent(navigator.userAgent); + } + return getNodeVersion(); +} +function matchUserAgent(ua2) { + return ua2 !== "" && userAgentRules.reduce(function(matched, _a2) { + var browser2 = _a2[0], regex = _a2[1]; + if (matched) { + return matched; + } + var uaMatch = regex.exec(ua2); + return !!uaMatch && [browser2, uaMatch]; + }, false); +} +function parseUserAgent(ua2) { + var matchedRule = matchUserAgent(ua2); + if (!matchedRule) { + return null; + } + var name2 = matchedRule[0], match = matchedRule[1]; + if (name2 === "searchbot") { + return new BotInfo(); + } + var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); + if (versionParts) { + if (versionParts.length < REQUIRED_VERSION_PARTS) { + versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); + } + } else { + versionParts = []; + } + var version2 = versionParts.join("."); + var os2 = detectOS(ua2); + var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua2); + if (searchBotMatch && searchBotMatch[1]) { + return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); + } + return new BrowserInfo(name2, version2, os2); +} +function detectOS(ua2) { + for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { + var _a2 = operatingSystemRules[ii], os2 = _a2[0], regex = _a2[1]; + var match = regex.exec(ua2); + if (match) { + return os2; + } + } + return null; +} +function getNodeVersion() { + var isNode = typeof process !== "undefined" && process.version; + return isNode ? new NodeInfo(process.version.slice(1)) : null; +} +function createVersionParts(count) { + var output = []; + for (var ii = 0; ii < count; ii++) { + output.push("0"); + } + return output; +} +var cjs$2 = {}; +Object.defineProperty(cjs$2, "__esModule", { value: true }); +cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; +function getFromWindow(name2) { + let res = void 0; + if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { + res = window[name2]; + } + return res; +} +cjs$2.getFromWindow = getFromWindow; +function getFromWindowOrThrow(name2) { + const res = getFromWindow(name2); + if (!res) { + throw new Error(`${name2} is not defined in Window`); + } + return res; +} +cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; +function getDocumentOrThrow() { + return getFromWindowOrThrow("document"); +} +cjs$2.getDocumentOrThrow = getDocumentOrThrow; +function getDocument() { + return getFromWindow("document"); +} +var getDocument_1 = cjs$2.getDocument = getDocument; +function getNavigatorOrThrow() { + return getFromWindowOrThrow("navigator"); +} +cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; +function getNavigator() { + return getFromWindow("navigator"); +} +var getNavigator_1 = cjs$2.getNavigator = getNavigator; +function getLocationOrThrow() { + return getFromWindowOrThrow("location"); +} +cjs$2.getLocationOrThrow = getLocationOrThrow; +function getLocation() { + return getFromWindow("location"); +} +var getLocation_1 = cjs$2.getLocation = getLocation; +function getCryptoOrThrow() { + return getFromWindowOrThrow("crypto"); +} +cjs$2.getCryptoOrThrow = getCryptoOrThrow; +function getCrypto() { + return getFromWindow("crypto"); +} +cjs$2.getCrypto = getCrypto; +function getLocalStorageOrThrow() { + return getFromWindowOrThrow("localStorage"); +} +cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; +function getLocalStorage() { + return getFromWindow("localStorage"); +} +cjs$2.getLocalStorage = getLocalStorage; +var cjs$1 = {}; +Object.defineProperty(cjs$1, "__esModule", { value: true }); +var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; +const window_getters_1 = cjs$2; +function getWindowMetadata() { + let doc; + let loc; + try { + doc = window_getters_1.getDocumentOrThrow(); + loc = window_getters_1.getLocationOrThrow(); + } catch (e2) { + return null; + } + function getIcons() { + const links = doc.getElementsByTagName("link"); + const icons2 = []; + for (let i2 = 0; i2 < links.length; i2++) { + const link = links[i2]; + const rel = link.getAttribute("rel"); + if (rel) { + if (rel.toLowerCase().indexOf("icon") > -1) { + const href = link.getAttribute("href"); + if (href) { + if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { + let absoluteHref = loc.protocol + "//" + loc.host; + if (href.indexOf("/") === 0) { + absoluteHref += href; + } else { + const path = loc.pathname.split("/"); + path.pop(); + const finalPath = path.join("/"); + absoluteHref += finalPath + "/" + href; + } + icons2.push(absoluteHref); + } else if (href.indexOf("//") === 0) { + const absoluteUrl = loc.protocol + href; + icons2.push(absoluteUrl); + } else { + icons2.push(href); + } + } + } + } + } + return icons2; + } + function getWindowMetadataOfAny(...args) { + const metaTags = doc.getElementsByTagName("meta"); + for (let i2 = 0; i2 < metaTags.length; i2++) { + const tag = metaTags[i2]; + const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { + if (attr) { + return args.includes(attr); + } + return false; + }); + if (attributes.length && attributes) { + const content = tag.getAttribute("content"); + if (content) { + return content; + } + } + } + return ""; + } + function getName() { + let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); + if (!name3) { + name3 = doc.title; + } + return name3; + } + function getDescription() { + const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); + return description3; + } + const name2 = getName(); + const description2 = getDescription(); + const url = loc.origin; + const icons = getIcons(); + const meta = { + description: description2, + url, + icons, + name: name2 + }; + return meta; +} +getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; +var queryString = {}; +var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); +var token = "%[a-f0-9]{2}"; +var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); +var multiMatcher = new RegExp("(" + token + ")+", "gi"); +function decodeComponents(components, split) { + try { + return [decodeURIComponent(components.join(""))]; + } catch (err) { + } + if (components.length === 1) { + return components; + } + split = split || 1; + var left = components.slice(0, split); + var right = components.slice(split); + return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); +} +function decode(input) { + try { + return decodeURIComponent(input); + } catch (err) { + var tokens = input.match(singleMatcher) || []; + for (var i2 = 1; i2 < tokens.length; i2++) { + input = decodeComponents(tokens, i2).join(""); + tokens = input.match(singleMatcher) || []; + } + return input; + } +} +function customDecodeURIComponent(input) { + var replaceMap = { + "%FE%FF": "��", + "%FF%FE": "��" + }; + var match = multiMatcher.exec(input); + while (match) { + try { + replaceMap[match[0]] = decodeURIComponent(match[0]); + } catch (err) { + var result = decode(match[0]); + if (result !== match[0]) { + replaceMap[match[0]] = result; + } + } + match = multiMatcher.exec(input); + } + replaceMap["%C2"] = "�"; + var entries = Object.keys(replaceMap); + for (var i2 = 0; i2 < entries.length; i2++) { + var key = entries[i2]; + input = input.replace(new RegExp(key, "g"), replaceMap[key]); + } + return input; +} +var decodeUriComponent = function(encodedURI) { + if (typeof encodedURI !== "string") { + throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + } + try { + encodedURI = encodedURI.replace(/\+/g, " "); + return decodeURIComponent(encodedURI); + } catch (err) { + return customDecodeURIComponent(encodedURI); + } +}; +var splitOnFirst = (string2, separator) => { + if (!(typeof string2 === "string" && typeof separator === "string")) { + throw new TypeError("Expected the arguments to be of type `string`"); + } + if (separator === "") { + return [string2]; + } + const separatorIndex = string2.indexOf(separator); + if (separatorIndex === -1) { + return [string2]; + } + return [ + string2.slice(0, separatorIndex), + string2.slice(separatorIndex + separator.length) + ]; +}; +var filterObj = function(obj, predicate) { + var ret = {}; + var keys2 = Object.keys(obj); + var isArr = Array.isArray(predicate); + for (var i2 = 0; i2 < keys2.length; i2++) { + var key = keys2[i2]; + var val = obj[key]; + if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { + ret[key] = val; + } + } + return ret; +}; +(function(exports2) { + const strictUriEncode$1 = strictUriEncode; + const decodeComponent = decodeUriComponent; + const splitOnFirst$1 = splitOnFirst; + const filterObject = filterObj; + const isNullOrUndefined = (value) => value === null || value === void 0; + const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); + function encoderForArrayFormat(options) { + switch (options.arrayFormat) { + case "index": + return (key) => (result, value) => { + const index = result.length; + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), "[", index, "]"].join("")]; + } + return [ + ...result, + [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") + ]; + }; + case "bracket": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), "[]"].join("")]; + } + return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; + }; + case "colon-list-separator": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), ":list="].join("")]; + } + return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; + }; + case "comma": + case "separator": + case "bracket-separator": { + const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + value = value === null ? "" : value; + if (result.length === 0) { + return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; + } + return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; + }; + } + default: + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, encode2(key, options)]; + } + return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; + }; + } + } + function parserForArrayFormat(options) { + let result; + switch (options.arrayFormat) { + case "index": + return (key, value, accumulator) => { + result = /\[(\d*)\]$/.exec(key); + key = key.replace(/\[\d*\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = {}; + } + accumulator[key][result[1]] = value; + }; + case "bracket": + return (key, value, accumulator) => { + result = /(\[\])$/.exec(key); + key = key.replace(/\[\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "colon-list-separator": + return (key, value, accumulator) => { + result = /(:list)$/.exec(key); + key = key.replace(/:list$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "comma": + case "separator": + return (key, value, accumulator) => { + const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator); + const isEncodedArray = typeof value === "string" && !isArray && decode2(value, options).includes(options.arrayFormatSeparator); + value = isEncodedArray ? decode2(value, options) : value; + const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); + accumulator[key] = newValue; + }; + case "bracket-separator": + return (key, value, accumulator) => { + const isArray = /(\[\])$/.test(key); + key = key.replace(/\[\]$/, ""); + if (!isArray) { + accumulator[key] = value ? decode2(value, options) : value; + return; + } + const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); + if (accumulator[key] === void 0) { + accumulator[key] = arrayValue; + return; + } + accumulator[key] = [].concat(accumulator[key], arrayValue); + }; + default: + return (key, value, accumulator) => { + if (accumulator[key] === void 0) { + accumulator[key] = value; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + } + } + function validateArrayFormatSeparator(value) { + if (typeof value !== "string" || value.length !== 1) { + throw new TypeError("arrayFormatSeparator must be single character string"); + } + } + function encode2(value, options) { + if (options.encode) { + return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); + } + return value; + } + function decode2(value, options) { + if (options.decode) { + return decodeComponent(value); + } + return value; + } + function keysSorter(input) { + if (Array.isArray(input)) { + return input.sort(); + } + if (typeof input === "object") { + return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); + } + return input; + } + function removeHash(input) { + const hashStart = input.indexOf("#"); + if (hashStart !== -1) { + input = input.slice(0, hashStart); + } + return input; + } + function getHash(url) { + let hash2 = ""; + const hashStart = url.indexOf("#"); + if (hashStart !== -1) { + hash2 = url.slice(hashStart); + } + return hash2; + } + function extract(input) { + input = removeHash(input); + const queryStart = input.indexOf("?"); + if (queryStart === -1) { + return ""; + } + return input.slice(queryStart + 1); + } + function parseValue(value, options) { + if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { + value = Number(value); + } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { + value = value.toLowerCase() === "true"; + } + return value; + } + function parse(query, options) { + options = Object.assign({ + decode: true, + sort: true, + arrayFormat: "none", + arrayFormatSeparator: ",", + parseNumbers: false, + parseBooleans: false + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const formatter = parserForArrayFormat(options); + const ret = /* @__PURE__ */ Object.create(null); + if (typeof query !== "string") { + return ret; + } + query = query.trim().replace(/^[?#&]/, ""); + if (!query) { + return ret; + } + for (const param of query.split("&")) { + if (param === "") { + continue; + } + let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); + value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); + formatter(decode2(key, options), value, ret); + } + for (const key of Object.keys(ret)) { + const value = ret[key]; + if (typeof value === "object" && value !== null) { + for (const k2 of Object.keys(value)) { + value[k2] = parseValue(value[k2], options); + } + } else { + ret[key] = parseValue(value, options); + } + } + if (options.sort === false) { + return ret; + } + return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { + const value = ret[key]; + if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { + result[key] = keysSorter(value); + } else { + result[key] = value; + } + return result; + }, /* @__PURE__ */ Object.create(null)); + } + exports2.extract = extract; + exports2.parse = parse; + exports2.stringify = (object, options) => { + if (!object) { + return ""; + } + options = Object.assign({ + encode: true, + strict: true, + arrayFormat: "none", + arrayFormatSeparator: "," + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; + const formatter = encoderForArrayFormat(options); + const objectCopy = {}; + for (const key of Object.keys(object)) { + if (!shouldFilter(key)) { + objectCopy[key] = object[key]; + } + } + const keys2 = Object.keys(objectCopy); + if (options.sort !== false) { + keys2.sort(options.sort); + } + return keys2.map((key) => { + const value = object[key]; + if (value === void 0) { + return ""; + } + if (value === null) { + return encode2(key, options); + } + if (Array.isArray(value)) { + if (value.length === 0 && options.arrayFormat === "bracket-separator") { + return encode2(key, options) + "[]"; + } + return value.reduce(formatter(key), []).join("&"); + } + return encode2(key, options) + "=" + encode2(value, options); + }).filter((x2) => x2.length > 0).join("&"); + }; + exports2.parseUrl = (url, options) => { + options = Object.assign({ + decode: true + }, options); + const [url_, hash2] = splitOnFirst$1(url, "#"); + return Object.assign( + { + url: url_.split("?")[0] || "", + query: parse(extract(url), options) + }, + options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} + ); + }; + exports2.stringifyUrl = (object, options) => { + options = Object.assign({ + encode: true, + strict: true, + [encodeFragmentIdentifier]: true + }, options); + const url = removeHash(object.url).split("?")[0] || ""; + const queryFromUrl = exports2.extract(object.url); + const parsedQueryFromUrl = exports2.parse(queryFromUrl, { sort: false }); + const query = Object.assign(parsedQueryFromUrl, object.query); + let queryString2 = exports2.stringify(query, options); + if (queryString2) { + queryString2 = `?${queryString2}`; + } + let hash2 = getHash(object.url); + if (object.fragmentIdentifier) { + hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + } + return `${url}${queryString2}${hash2}`; + }; + exports2.pick = (input, filter, options) => { + options = Object.assign({ + parseFragmentIdentifier: true, + [encodeFragmentIdentifier]: false + }, options); + const { url, query, fragmentIdentifier } = exports2.parseUrl(input, options); + return exports2.stringifyUrl({ + url, + query: filterObject(query, filter), + fragmentIdentifier + }, options); + }; + exports2.exclude = (input, filter, options) => { + const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); + return exports2.pick(input, exclusionFilter, options); + }; +})(queryString); +var chacha20poly1305 = {}; +var chacha = {}; +Object.defineProperty(chacha, "__esModule", { value: true }); +var binary_1 = binary; +var wipe_1$2 = wipe$1; +var ROUNDS = 20; +function core(out, input, key) { + var j02 = 1634760805; + var j1 = 857760878; + var j2 = 2036477234; + var j3 = 1797285236; + var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; + var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; + var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; + var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; + var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; + var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; + var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; + var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; + var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; + var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; + var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; + var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; + var x02 = j02; + var x1 = j1; + var x2 = j2; + var x3 = j3; + var x4 = j4; + var x5 = j5; + var x6 = j6; + var x7 = j7; + var x8 = j8; + var x9 = j9; + var x10 = j10; + var x11 = j11; + var x12 = j12; + var x13 = j13; + var x14 = j14; + var x15 = j15; + for (var i2 = 0; i2 < ROUNDS; i2 += 2) { + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 16 | x12 << 16; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 12 | x4 << 12; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 16 | x13 << 16; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 12 | x5 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 16 | x14 << 16; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 12 | x6 << 12; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 16 | x15 << 16; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 12 | x7 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 8 | x14 << 8; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 7 | x6 << 7; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 8 | x15 << 8; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 7 | x7 << 7; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 8 | x13 << 8; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 7 | x5 << 7; + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 8 | x12 << 8; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 7 | x4 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 16 | x15 << 16; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 12 | x5 << 12; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 16 | x12 << 16; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 12 | x6 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 16 | x13 << 16; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 12 | x7 << 12; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 16 | x14 << 16; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 12 | x4 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 8 | x13 << 8; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 7 | x7 << 7; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 8 | x14 << 8; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 7 | x4 << 7; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 8 | x12 << 8; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 7 | x6 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 8 | x15 << 8; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 7 | x5 << 7; + } + binary_1.writeUint32LE(x02 + j02 | 0, out, 0); + binary_1.writeUint32LE(x1 + j1 | 0, out, 4); + binary_1.writeUint32LE(x2 + j2 | 0, out, 8); + binary_1.writeUint32LE(x3 + j3 | 0, out, 12); + binary_1.writeUint32LE(x4 + j4 | 0, out, 16); + binary_1.writeUint32LE(x5 + j5 | 0, out, 20); + binary_1.writeUint32LE(x6 + j6 | 0, out, 24); + binary_1.writeUint32LE(x7 + j7 | 0, out, 28); + binary_1.writeUint32LE(x8 + j8 | 0, out, 32); + binary_1.writeUint32LE(x9 + j9 | 0, out, 36); + binary_1.writeUint32LE(x10 + j10 | 0, out, 40); + binary_1.writeUint32LE(x11 + j11 | 0, out, 44); + binary_1.writeUint32LE(x12 + j12 | 0, out, 48); + binary_1.writeUint32LE(x13 + j13 | 0, out, 52); + binary_1.writeUint32LE(x14 + j14 | 0, out, 56); + binary_1.writeUint32LE(x15 + j15 | 0, out, 60); +} +function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + if (key.length !== 32) { + throw new Error("ChaCha: key size must be 32 bytes"); + } + if (dst.length < src2.length) { + throw new Error("ChaCha: destination is shorter than source"); + } + var nc; + var counterLength; + if (nonceInplaceCounterLength === 0) { + if (nonce.length !== 8 && nonce.length !== 12) { + throw new Error("ChaCha nonce must be 8 or 12 bytes"); + } + nc = new Uint8Array(16); + counterLength = nc.length - nonce.length; + nc.set(nonce, counterLength); + } else { + if (nonce.length !== 16) { + throw new Error("ChaCha nonce with counter must be 16 bytes"); + } + nc = nonce; + counterLength = nonceInplaceCounterLength; + } + var block = new Uint8Array(64); + for (var i2 = 0; i2 < src2.length; i2 += 64) { + core(block, nc, key); + for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { + dst[j2] = src2[j2] ^ block[j2 - i2]; + } + incrementCounter(nc, 0, counterLength); + } + wipe_1$2.wipe(block); + if (nonceInplaceCounterLength === 0) { + wipe_1$2.wipe(nc); + } + return dst; +} +chacha.streamXOR = streamXOR; +function stream(key, nonce, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + wipe_1$2.wipe(dst); + return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); +} +chacha.stream = stream; +function incrementCounter(counter, pos, len) { + var carry = 1; + while (len--) { + carry = carry + (counter[pos] & 255) | 0; + counter[pos] = carry & 255; + carry >>>= 8; + pos++; + } + if (carry > 0) { + throw new Error("ChaCha: counter overflow"); + } +} +var poly1305 = {}; +var constantTime = {}; +Object.defineProperty(constantTime, "__esModule", { value: true }); +function select(subject, resultIfOne, resultIfZero) { + return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; +} +constantTime.select = select; +function lessOrEqual(a3, b3) { + return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; +} +constantTime.lessOrEqual = lessOrEqual; +function compare(a3, b3) { + if (a3.length !== b3.length) { + return 0; + } + var result = 0; + for (var i2 = 0; i2 < a3.length; i2++) { + result |= a3[i2] ^ b3[i2]; + } + return 1 & result - 1 >>> 8; +} +constantTime.compare = compare; +function equal(a3, b3) { + if (a3.length === 0 || b3.length === 0) { + return false; + } + return compare(a3, b3) !== 0; +} +constantTime.equal = equal; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var constant_time_12 = constantTime; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 16; + var Poly1305 = ( + /** @class */ + function() { + function Poly13052(key) { + this.digestLength = exports2.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 = false; + var t0 = key[0] | key[1] << 8; + this._r[0] = t0 & 8191; + var t1 = key[2] | key[3] << 8; + this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; + var t2 = key[4] | key[5] << 8; + this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; + var t3 = key[6] | key[7] << 8; + this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; + var t4 = key[8] | key[9] << 8; + this._r[4] = (t3 >>> 4 | t4 << 12) & 255; + this._r[5] = t4 >>> 1 & 8190; + var t5 = key[10] | key[11] << 8; + this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; + var t6 = key[12] | key[13] << 8; + this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; + var t7 = key[14] | key[15] << 8; + this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; + this._r[9] = t7 >>> 5 & 127; + this._pad[0] = key[16] | key[17] << 8; + this._pad[1] = key[18] | key[19] << 8; + this._pad[2] = key[20] | key[21] << 8; + this._pad[3] = key[22] | key[23] << 8; + this._pad[4] = key[24] | key[25] << 8; + this._pad[5] = key[26] | key[27] << 8; + this._pad[6] = key[28] | key[29] << 8; + this._pad[7] = key[30] | key[31] << 8; + } + Poly13052.prototype._blocks = function(m3, mpos, bytes) { + var hibit = this._fin ? 0 : 1 << 11; + var h02 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; + var r0 = this._r[0], r1 = this._r[1], r22 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; + while (bytes >= 16) { + var t0 = m3[mpos + 0] | m3[mpos + 1] << 8; + h02 += t0 & 8191; + var t1 = m3[mpos + 2] | m3[mpos + 3] << 8; + h1 += (t0 >>> 13 | t1 << 3) & 8191; + var t2 = m3[mpos + 4] | m3[mpos + 5] << 8; + h22 += (t1 >>> 10 | t2 << 6) & 8191; + var t3 = m3[mpos + 6] | m3[mpos + 7] << 8; + h32 += (t2 >>> 7 | t3 << 9) & 8191; + var t4 = m3[mpos + 8] | m3[mpos + 9] << 8; + h4 += (t3 >>> 4 | t4 << 12) & 8191; + h5 += t4 >>> 1 & 8191; + var t5 = m3[mpos + 10] | m3[mpos + 11] << 8; + h6 += (t4 >>> 14 | t5 << 2) & 8191; + var t6 = m3[mpos + 12] | m3[mpos + 13] << 8; + h7 += (t5 >>> 11 | t6 << 5) & 8191; + var t7 = m3[mpos + 14] | m3[mpos + 15] << 8; + h8 += (t6 >>> 8 | t7 << 8) & 8191; + h9 += t7 >>> 5 | hibit; + var c2 = 0; + var d02 = c2; + d02 += h02 * r0; + d02 += h1 * (5 * r9); + d02 += h22 * (5 * r8); + d02 += h32 * (5 * r7); + d02 += h4 * (5 * r6); + c2 = d02 >>> 13; + d02 &= 8191; + d02 += h5 * (5 * r5); + d02 += h6 * (5 * r4); + d02 += h7 * (5 * r3); + d02 += h8 * (5 * r22); + d02 += h9 * (5 * r1); + c2 += d02 >>> 13; + d02 &= 8191; + var d1 = c2; + d1 += h02 * r1; + d1 += h1 * r0; + d1 += h22 * (5 * r9); + d1 += h32 * (5 * r8); + d1 += h4 * (5 * r7); + c2 = d1 >>> 13; + d1 &= 8191; + d1 += h5 * (5 * r6); + d1 += h6 * (5 * r5); + d1 += h7 * (5 * r4); + d1 += h8 * (5 * r3); + d1 += h9 * (5 * r22); + c2 += d1 >>> 13; + d1 &= 8191; + var d22 = c2; + d22 += h02 * r22; + d22 += h1 * r1; + d22 += h22 * r0; + d22 += h32 * (5 * r9); + d22 += h4 * (5 * r8); + c2 = d22 >>> 13; + d22 &= 8191; + d22 += h5 * (5 * r7); + d22 += h6 * (5 * r6); + d22 += h7 * (5 * r5); + d22 += h8 * (5 * r4); + d22 += h9 * (5 * r3); + c2 += d22 >>> 13; + d22 &= 8191; + var d32 = c2; + d32 += h02 * r3; + d32 += h1 * r22; + d32 += h22 * r1; + d32 += h32 * r0; + d32 += h4 * (5 * r9); + c2 = d32 >>> 13; + d32 &= 8191; + d32 += h5 * (5 * r8); + d32 += h6 * (5 * r7); + d32 += h7 * (5 * r6); + d32 += h8 * (5 * r5); + d32 += h9 * (5 * r4); + c2 += d32 >>> 13; + d32 &= 8191; + var d42 = c2; + d42 += h02 * r4; + d42 += h1 * r3; + d42 += h22 * r22; + d42 += h32 * r1; + d42 += h4 * r0; + c2 = d42 >>> 13; + d42 &= 8191; + d42 += h5 * (5 * r9); + d42 += h6 * (5 * r8); + d42 += h7 * (5 * r7); + d42 += h8 * (5 * r6); + d42 += h9 * (5 * r5); + c2 += d42 >>> 13; + d42 &= 8191; + var d5 = c2; + d5 += h02 * r5; + d5 += h1 * r4; + d5 += h22 * r3; + d5 += h32 * r22; + d5 += h4 * r1; + c2 = d5 >>> 13; + d5 &= 8191; + d5 += h5 * r0; + d5 += h6 * (5 * r9); + d5 += h7 * (5 * r8); + d5 += h8 * (5 * r7); + d5 += h9 * (5 * r6); + c2 += d5 >>> 13; + d5 &= 8191; + var d6 = c2; + d6 += h02 * r6; + d6 += h1 * r5; + d6 += h22 * r4; + d6 += h32 * r3; + d6 += h4 * r22; + c2 = d6 >>> 13; + d6 &= 8191; + d6 += h5 * r1; + d6 += h6 * r0; + d6 += h7 * (5 * r9); + d6 += h8 * (5 * r8); + d6 += h9 * (5 * r7); + c2 += d6 >>> 13; + d6 &= 8191; + var d7 = c2; + d7 += h02 * r7; + d7 += h1 * r6; + d7 += h22 * r5; + d7 += h32 * r4; + d7 += h4 * r3; + c2 = d7 >>> 13; + d7 &= 8191; + d7 += h5 * r22; + d7 += h6 * r1; + d7 += h7 * r0; + d7 += h8 * (5 * r9); + d7 += h9 * (5 * r8); + c2 += d7 >>> 13; + d7 &= 8191; + var d8 = c2; + d8 += h02 * r8; + d8 += h1 * r7; + d8 += h22 * r6; + d8 += h32 * r5; + d8 += h4 * r4; + c2 = d8 >>> 13; + d8 &= 8191; + d8 += h5 * r3; + d8 += h6 * r22; + d8 += h7 * r1; + d8 += h8 * r0; + d8 += h9 * (5 * r9); + c2 += d8 >>> 13; + d8 &= 8191; + var d9 = c2; + d9 += h02 * r9; + d9 += h1 * r8; + d9 += h22 * r7; + d9 += h32 * r6; + d9 += h4 * r5; + c2 = d9 >>> 13; + d9 &= 8191; + d9 += h5 * r4; + d9 += h6 * r3; + d9 += h7 * r22; + d9 += h8 * r1; + d9 += h9 * r0; + c2 += d9 >>> 13; + d9 &= 8191; + c2 = (c2 << 2) + c2 | 0; + c2 = c2 + d02 | 0; + d02 = c2 & 8191; + c2 = c2 >>> 13; + d1 += c2; + h02 = d02; + h1 = d1; + h22 = d22; + h32 = d32; + h4 = d42; + h5 = d5; + h6 = d6; + h7 = d7; + h8 = d8; + h9 = d9; + mpos += 16; + bytes -= 16; + } + this._h[0] = h02; + this._h[1] = h1; + this._h[2] = h22; + this._h[3] = h32; + this._h[4] = h4; + this._h[5] = h5; + this._h[6] = h6; + this._h[7] = h7; + this._h[8] = h8; + this._h[9] = h9; + }; + Poly13052.prototype.finish = function(mac, macpos) { + if (macpos === void 0) { + macpos = 0; + } + var g3 = new Uint16Array(10); + var c2; + var mask; + var f3; + var i2; + if (this._leftover) { + i2 = this._leftover; + this._buffer[i2++] = 1; + for (; i2 < 16; i2++) { + this._buffer[i2] = 0; + } + this._fin = 1; + this._blocks(this._buffer, 0, 16); + } + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + for (i2 = 2; i2 < 10; i2++) { + this._h[i2] += c2; + c2 = this._h[i2] >>> 13; + this._h[i2] &= 8191; + } + this._h[0] += c2 * 5; + c2 = this._h[0] >>> 13; + this._h[0] &= 8191; + this._h[1] += c2; + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + this._h[2] += c2; + g3[0] = this._h[0] + 5; + c2 = g3[0] >>> 13; + g3[0] &= 8191; + for (i2 = 1; i2 < 10; i2++) { + g3[i2] = this._h[i2] + c2; + c2 = g3[i2] >>> 13; + g3[i2] &= 8191; + } + g3[9] -= 1 << 13; + mask = (c2 ^ 1) - 1; + for (i2 = 0; i2 < 10; i2++) { + g3[i2] &= mask; + } + mask = ~mask; + for (i2 = 0; i2 < 10; i2++) { + this._h[i2] = this._h[i2] & mask | g3[i2]; + } + 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; + f3 = this._h[0] + this._pad[0]; + this._h[0] = f3 & 65535; + for (i2 = 1; i2 < 8; i2++) { + f3 = (this._h[i2] + this._pad[i2] | 0) + (f3 >>> 16) | 0; + this._h[i2] = f3 & 65535; + } + mac[macpos + 0] = this._h[0] >>> 0; + mac[macpos + 1] = this._h[0] >>> 8; + mac[macpos + 2] = this._h[1] >>> 0; + mac[macpos + 3] = this._h[1] >>> 8; + mac[macpos + 4] = this._h[2] >>> 0; + mac[macpos + 5] = this._h[2] >>> 8; + mac[macpos + 6] = this._h[3] >>> 0; + mac[macpos + 7] = this._h[3] >>> 8; + mac[macpos + 8] = this._h[4] >>> 0; + mac[macpos + 9] = this._h[4] >>> 8; + mac[macpos + 10] = this._h[5] >>> 0; + mac[macpos + 11] = this._h[5] >>> 8; + mac[macpos + 12] = this._h[6] >>> 0; + mac[macpos + 13] = this._h[6] >>> 8; + mac[macpos + 14] = this._h[7] >>> 0; + mac[macpos + 15] = this._h[7] >>> 8; + this._finished = true; + return this; + }; + Poly13052.prototype.update = function(m3) { + var mpos = 0; + var bytes = m3.length; + var want; + if (this._leftover) { + want = 16 - this._leftover; + if (want > bytes) { + want = bytes; + } + for (var i2 = 0; i2 < want; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + bytes -= want; + mpos += want; + this._leftover += want; + if (this._leftover < 16) { + return this; + } + this._blocks(this._buffer, 0, 16); + this._leftover = 0; + } + if (bytes >= 16) { + want = bytes - bytes % 16; + this._blocks(m3, mpos, want); + mpos += want; + bytes -= want; + } + if (bytes) { + for (var i2 = 0; i2 < bytes; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + this._leftover += bytes; + } + return this; + }; + Poly13052.prototype.digest = function() { + if (this._finished) { + throw new Error("Poly1305 was finished"); + } + var mac = new Uint8Array(16); + this.finish(mac); + return mac; + }; + Poly13052.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._r); + wipe_12.wipe(this._h); + wipe_12.wipe(this._pad); + this._leftover = 0; + this._fin = 0; + this._finished = true; + return this; + }; + return Poly13052; + }() + ); + exports2.Poly1305 = Poly1305; + function oneTimeAuth(key, data) { + var h4 = new Poly1305(key); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.oneTimeAuth = oneTimeAuth; + function equal2(a3, b3) { + if (a3.length !== exports2.DIGEST_LENGTH || b3.length !== exports2.DIGEST_LENGTH) { + return false; + } + return constant_time_12.equal(a3, b3); + } + exports2.equal = equal2; +})(poly1305); +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var chacha_1 = chacha; + var poly1305_1 = poly1305; + var wipe_12 = wipe$1; + var binary_12 = binary; + var constant_time_12 = constantTime; + exports2.KEY_LENGTH = 32; + exports2.NONCE_LENGTH = 12; + exports2.TAG_LENGTH = 16; + var ZEROS = new Uint8Array(16); + var ChaCha20Poly1305 = ( + /** @class */ + function() { + function ChaCha20Poly13052(key) { + this.nonceLength = exports2.NONCE_LENGTH; + this.tagLength = exports2.TAG_LENGTH; + if (key.length !== exports2.KEY_LENGTH) { + throw new Error("ChaCha20Poly1305 needs 32-byte key"); + } + this._key = new Uint8Array(key); + } + ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var resultLength = plaintext.length + this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, plaintext, result, 4); + this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + if (sealed.length < this.tagLength) { + return null; + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var calculatedTag = new Uint8Array(this.tagLength); + this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); + if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { + return null; + } + var resultLength = sealed.length - this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.clean = function() { + wipe_12.wipe(this._key); + return this; + }; + ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { + var h4 = new poly1305_1.Poly1305(authKey); + if (associatedData) { + h4.update(associatedData); + if (associatedData.length % 16 > 0) { + h4.update(ZEROS.subarray(associatedData.length % 16)); + } + } + h4.update(ciphertext); + if (ciphertext.length % 16 > 0) { + h4.update(ZEROS.subarray(ciphertext.length % 16)); + } + var length = new Uint8Array(8); + if (associatedData) { + binary_12.writeUint64LE(associatedData.length, length); + } + h4.update(length); + binary_12.writeUint64LE(ciphertext.length, length); + h4.update(length); + var tag = h4.digest(); + for (var i2 = 0; i2 < tag.length; i2++) { + tagOut[i2] = tag[i2]; + } + h4.clean(); + wipe_12.wipe(tag); + wipe_12.wipe(length); + }; + return ChaCha20Poly13052; + }() + ); + exports2.ChaCha20Poly1305 = ChaCha20Poly1305; +})(chacha20poly1305); +var hkdf = {}; +var hmac$1 = {}; +var hash = {}; +Object.defineProperty(hash, "__esModule", { value: true }); +function isSerializableHash(h4) { + return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; +} +hash.isSerializableHash = isSerializableHash; +Object.defineProperty(hmac$1, "__esModule", { value: true }); +var hash_1 = hash; +var constant_time_1 = constantTime; +var wipe_1$1 = wipe$1; +var HMAC = ( + /** @class */ + function() { + function HMAC2(hash2, key) { + this._finished = false; + this._inner = new hash2(); + this._outer = new hash2(); + this.blockSize = this._outer.blockSize; + this.digestLength = this._outer.digestLength; + var pad = new Uint8Array(this.blockSize); + if (key.length > this.blockSize) { + this._inner.update(key).finish(pad).clean(); + } else { + pad.set(key); + } + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54; + } + this._inner.update(pad); + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54 ^ 92; + } + this._outer.update(pad); + if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { + this._innerKeyedState = this._inner.saveState(); + this._outerKeyedState = this._outer.saveState(); + } + wipe_1$1.wipe(pad); + } + HMAC2.prototype.reset = function() { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); + } + this._inner.restoreState(this._innerKeyedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.clean = function() { + if (hash_1.isSerializableHash(this._inner)) { + this._inner.cleanSavedState(this._innerKeyedState); + } + if (hash_1.isSerializableHash(this._outer)) { + this._outer.cleanSavedState(this._outerKeyedState); + } + this._inner.clean(); + this._outer.clean(); + }; + HMAC2.prototype.update = function(data) { + this._inner.update(data); + return this; + }; + HMAC2.prototype.finish = function(out) { + if (this._finished) { + this._outer.finish(out); + return this; + } + this._inner.finish(out); + this._outer.update(out.subarray(0, this.digestLength)).finish(out); + this._finished = true; + return this; + }; + HMAC2.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + HMAC2.prototype.saveState = function() { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't saveState() because hash doesn't implement it"); + } + return this._inner.saveState(); + }; + HMAC2.prototype.restoreState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't restoreState() because hash doesn't implement it"); + } + this._inner.restoreState(savedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.cleanSavedState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); + } + this._inner.cleanSavedState(savedState); + }; + return HMAC2; + }() +); +hmac$1.HMAC = HMAC; +function hmac(hash2, key, data) { + var h4 = new HMAC(hash2, key); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; +} +hmac$1.hmac = hmac; +hmac$1.equal = constant_time_1.equal; +Object.defineProperty(hkdf, "__esModule", { value: true }); +var hmac_1 = hmac$1; +var wipe_1 = wipe$1; +var HKDF = ( + /** @class */ + function() { + function HKDF2(hash2, key, salt, info) { + if (salt === void 0) { + salt = new Uint8Array(0); + } + this._counter = new Uint8Array(1); + this._hash = hash2; + this._info = info; + var okm = hmac_1.hmac(this._hash, salt, key); + this._hmac = new hmac_1.HMAC(hash2, okm); + this._buffer = new Uint8Array(this._hmac.digestLength); + this._bufpos = this._buffer.length; + } + HKDF2.prototype._fillBuffer = function() { + this._counter[0]++; + var ctr = this._counter[0]; + if (ctr === 0) { + throw new Error("hkdf: cannot expand more"); + } + this._hmac.reset(); + if (ctr > 1) { + this._hmac.update(this._buffer); + } + if (this._info) { + this._hmac.update(this._info); + } + this._hmac.update(this._counter); + this._hmac.finish(this._buffer); + this._bufpos = 0; + }; + HKDF2.prototype.expand = function(length) { + var out = new Uint8Array(length); + for (var i2 = 0; i2 < out.length; i2++) { + if (this._bufpos === this._buffer.length) { + this._fillBuffer(); + } + out[i2] = this._buffer[this._bufpos++]; + } + return out; + }; + HKDF2.prototype.clean = function() { + this._hmac.clean(); + wipe_1.wipe(this._buffer); + wipe_1.wipe(this._counter); + this._bufpos = 0; + }; + return HKDF2; + }() +); +var HKDF_1 = hkdf.HKDF = HKDF; +var sha256 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var binary_12 = binary; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 32; + exports2.BLOCK_SIZE = 64; + var SHA256 = ( + /** @class */ + function() { + function SHA2562() { + this.digestLength = exports2.DIGEST_LENGTH; + this.blockSize = exports2.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 = false; + this.reset(); + } + SHA2562.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; + }; + SHA2562.prototype.reset = function() { + this._initState(); + this._bufferLength = 0; + this._bytesHashed = 0; + this._finished = false; + return this; + }; + SHA2562.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._temp); + this.reset(); + }; + SHA2562.prototype.update = function(data, dataLength) { + if (dataLength === void 0) { + dataLength = data.length; + } + if (this._finished) { + throw new Error("SHA256: can't update because hash was finished."); + } + var dataPos = 0; + this._bytesHashed += dataLength; + if (this._bufferLength > 0) { + while (this._bufferLength < this.blockSize && dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + if (this._bufferLength === this.blockSize) { + hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); + this._bufferLength = 0; + } + } + if (dataLength >= this.blockSize) { + dataPos = hashBlocks(this._temp, this._state, data, dataPos, dataLength); + dataLength %= this.blockSize; + } + while (dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + return this; + }; + SHA2562.prototype.finish = function(out) { + if (!this._finished) { + var bytesHashed = this._bytesHashed; + var left = this._bufferLength; + var bitLenHi = bytesHashed / 536870912 | 0; + var bitLenLo = bytesHashed << 3; + var padLength = bytesHashed % 64 < 56 ? 64 : 128; + this._buffer[left] = 128; + for (var i2 = left + 1; i2 < padLength - 8; i2++) { + this._buffer[i2] = 0; + } + binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); + binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); + hashBlocks(this._temp, this._state, this._buffer, 0, padLength); + this._finished = true; + } + for (var i2 = 0; i2 < this.digestLength / 4; i2++) { + binary_12.writeUint32BE(this._state[i2], out, i2 * 4); + } + return this; + }; + SHA2562.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + SHA2562.prototype.saveState = function() { + if (this._finished) { + throw new Error("SHA256: cannot save finished state"); + } + return { + state: new Int32Array(this._state), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }; + SHA2562.prototype.restoreState = function(savedState) { + this._state.set(savedState.state); + this._bufferLength = savedState.bufferLength; + if (savedState.buffer) { + this._buffer.set(savedState.buffer); + } + this._bytesHashed = savedState.bytesHashed; + this._finished = false; + return this; + }; + SHA2562.prototype.cleanSavedState = function(savedState) { + wipe_12.wipe(savedState.state); + if (savedState.buffer) { + wipe_12.wipe(savedState.buffer); + } + savedState.bufferLength = 0; + savedState.bytesHashed = 0; + }; + return SHA2562; + }() + ); + exports2.SHA256 = SHA256; + var K3 = 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 hashBlocks(w3, v3, p2, pos, len) { + while (len >= 64) { + var a3 = v3[0]; + var b3 = v3[1]; + var c2 = v3[2]; + var d5 = v3[3]; + var e2 = v3[4]; + var f3 = v3[5]; + var g3 = v3[6]; + var h4 = v3[7]; + for (var i2 = 0; i2 < 16; i2++) { + var j2 = pos + i2 * 4; + w3[i2] = binary_12.readUint32BE(p2, j2); + } + for (var i2 = 16; i2 < 64; i2++) { + var u3 = w3[i2 - 2]; + var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; + u3 = w3[i2 - 15]; + var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; + w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); + } + for (var i2 = 0; i2 < 64; i2++) { + var t1 = (((e2 >>> 6 | e2 << 32 - 6) ^ (e2 >>> 11 | e2 << 32 - 11) ^ (e2 >>> 25 | e2 << 32 - 25)) + (e2 & f3 ^ ~e2 & g3) | 0) + (h4 + (K3[i2] + w3[i2] | 0) | 0) | 0; + var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; + h4 = g3; + g3 = f3; + f3 = e2; + e2 = d5 + t1 | 0; + d5 = c2; + c2 = b3; + b3 = a3; + a3 = t1 + t2 | 0; + } + v3[0] += a3; + v3[1] += b3; + v3[2] += c2; + v3[3] += d5; + v3[4] += e2; + v3[5] += f3; + v3[6] += g3; + v3[7] += h4; + pos += 64; + len -= 64; + } + return pos; + } + function hash2(data) { + var h4 = new SHA256(); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.hash = hash2; +})(sha256); +var x25519 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.sharedKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.scalarMultBase = exports2.scalarMult = exports2.SHARED_KEY_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = void 0; + const random_1 = random; + const wipe_12 = wipe$1; + exports2.PUBLIC_KEY_LENGTH = 32; + exports2.SECRET_KEY_LENGTH = 32; + exports2.SHARED_KEY_LENGTH = 32; + function gf2(init) { + const r3 = new Float64Array(16); + if (init) { + for (let i2 = 0; i2 < init.length; i2++) { + r3[i2] = init[i2]; + } + } + return r3; + } + const _9 = new Uint8Array(32); + _9[0] = 9; + const _121665 = gf2([56129, 1]); + function car25519(o2) { + let c2 = 1; + for (let i2 = 0; i2 < 16; i2++) { + let v3 = o2[i2] + c2 + 65535; + c2 = Math.floor(v3 / 65536); + o2[i2] = v3 - c2 * 65536; + } + o2[0] += c2 - 1 + 37 * (c2 - 1); + } + function sel25519(p2, q2, b3) { + const c2 = ~(b3 - 1); + for (let i2 = 0; i2 < 16; i2++) { + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; + q2[i2] ^= t2; + } + } + function pack25519(o2, n4) { + const m3 = gf2(); + const t2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + t2[i2] = n4[i2]; + } + car25519(t2); + car25519(t2); + car25519(t2); + for (let j2 = 0; j2 < 2; j2++) { + m3[0] = t2[0] - 65517; + for (let i2 = 1; i2 < 15; i2++) { + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; + } + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); + } + for (let i2 = 0; i2 < 16; i2++) { + o2[2 * i2] = t2[i2] & 255; + o2[2 * i2 + 1] = t2[i2] >> 8; + } + } + function unpack25519(o2, n4) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); + } + o2[15] &= 32767; + } + function add(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] + b3[i2]; + } + } + function sub(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] - b3[i2]; + } + } + function mul(o2, a3, b3) { + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + v3 = a3[0]; + t0 += v3 * b02; + t1 += v3 * b1; + t2 += v3 * b22; + t3 += v3 * b32; + t4 += v3 * b4; + t5 += v3 * b5; + t6 += v3 * b6; + t7 += v3 * b7; + t8 += v3 * b8; + t9 += v3 * b9; + t10 += v3 * b10; + t11 += v3 * b11; + t12 += v3 * b12; + t13 += v3 * b13; + t14 += v3 * b14; + t15 += v3 * b15; + v3 = a3[1]; + t1 += v3 * b02; + t2 += v3 * b1; + t3 += v3 * b22; + t4 += v3 * b32; + t5 += v3 * b4; + t6 += v3 * b5; + t7 += v3 * b6; + t8 += v3 * b7; + t9 += v3 * b8; + t10 += v3 * b9; + t11 += v3 * b10; + t12 += v3 * b11; + t13 += v3 * b12; + t14 += v3 * b13; + t15 += v3 * b14; + t16 += v3 * b15; + v3 = a3[2]; + t2 += v3 * b02; + t3 += v3 * b1; + t4 += v3 * b22; + t5 += v3 * b32; + t6 += v3 * b4; + t7 += v3 * b5; + t8 += v3 * b6; + t9 += v3 * b7; + t10 += v3 * b8; + t11 += v3 * b9; + t12 += v3 * b10; + t13 += v3 * b11; + t14 += v3 * b12; + t15 += v3 * b13; + t16 += v3 * b14; + t17 += v3 * b15; + v3 = a3[3]; + t3 += v3 * b02; + t4 += v3 * b1; + t5 += v3 * b22; + t6 += v3 * b32; + t7 += v3 * b4; + t8 += v3 * b5; + t9 += v3 * b6; + t10 += v3 * b7; + t11 += v3 * b8; + t12 += v3 * b9; + t13 += v3 * b10; + t14 += v3 * b11; + t15 += v3 * b12; + t16 += v3 * b13; + t17 += v3 * b14; + t18 += v3 * b15; + v3 = a3[4]; + t4 += v3 * b02; + t5 += v3 * b1; + t6 += v3 * b22; + t7 += v3 * b32; + t8 += v3 * b4; + t9 += v3 * b5; + t10 += v3 * b6; + t11 += v3 * b7; + t12 += v3 * b8; + t13 += v3 * b9; + t14 += v3 * b10; + t15 += v3 * b11; + t16 += v3 * b12; + t17 += v3 * b13; + t18 += v3 * b14; + t19 += v3 * b15; + v3 = a3[5]; + t5 += v3 * b02; + t6 += v3 * b1; + t7 += v3 * b22; + t8 += v3 * b32; + t9 += v3 * b4; + t10 += v3 * b5; + t11 += v3 * b6; + t12 += v3 * b7; + t13 += v3 * b8; + t14 += v3 * b9; + t15 += v3 * b10; + t16 += v3 * b11; + t17 += v3 * b12; + t18 += v3 * b13; + t19 += v3 * b14; + t20 += v3 * b15; + v3 = a3[6]; + t6 += v3 * b02; + t7 += v3 * b1; + t8 += v3 * b22; + t9 += v3 * b32; + t10 += v3 * b4; + t11 += v3 * b5; + t12 += v3 * b6; + t13 += v3 * b7; + t14 += v3 * b8; + t15 += v3 * b9; + t16 += v3 * b10; + t17 += v3 * b11; + t18 += v3 * b12; + t19 += v3 * b13; + t20 += v3 * b14; + t21 += v3 * b15; + v3 = a3[7]; + t7 += v3 * b02; + t8 += v3 * b1; + t9 += v3 * b22; + t10 += v3 * b32; + t11 += v3 * b4; + t12 += v3 * b5; + t13 += v3 * b6; + t14 += v3 * b7; + t15 += v3 * b8; + t16 += v3 * b9; + t17 += v3 * b10; + t18 += v3 * b11; + t19 += v3 * b12; + t20 += v3 * b13; + t21 += v3 * b14; + t22 += v3 * b15; + v3 = a3[8]; + t8 += v3 * b02; + t9 += v3 * b1; + t10 += v3 * b22; + t11 += v3 * b32; + t12 += v3 * b4; + t13 += v3 * b5; + t14 += v3 * b6; + t15 += v3 * b7; + t16 += v3 * b8; + t17 += v3 * b9; + t18 += v3 * b10; + t19 += v3 * b11; + t20 += v3 * b12; + t21 += v3 * b13; + t22 += v3 * b14; + t23 += v3 * b15; + v3 = a3[9]; + t9 += v3 * b02; + t10 += v3 * b1; + t11 += v3 * b22; + t12 += v3 * b32; + t13 += v3 * b4; + t14 += v3 * b5; + t15 += v3 * b6; + t16 += v3 * b7; + t17 += v3 * b8; + t18 += v3 * b9; + t19 += v3 * b10; + t20 += v3 * b11; + t21 += v3 * b12; + t22 += v3 * b13; + t23 += v3 * b14; + t24 += v3 * b15; + v3 = a3[10]; + t10 += v3 * b02; + t11 += v3 * b1; + t12 += v3 * b22; + t13 += v3 * b32; + t14 += v3 * b4; + t15 += v3 * b5; + t16 += v3 * b6; + t17 += v3 * b7; + t18 += v3 * b8; + t19 += v3 * b9; + t20 += v3 * b10; + t21 += v3 * b11; + t22 += v3 * b12; + t23 += v3 * b13; + t24 += v3 * b14; + t25 += v3 * b15; + v3 = a3[11]; + t11 += v3 * b02; + t12 += v3 * b1; + t13 += v3 * b22; + t14 += v3 * b32; + t15 += v3 * b4; + t16 += v3 * b5; + t17 += v3 * b6; + t18 += v3 * b7; + t19 += v3 * b8; + t20 += v3 * b9; + t21 += v3 * b10; + t22 += v3 * b11; + t23 += v3 * b12; + t24 += v3 * b13; + t25 += v3 * b14; + t26 += v3 * b15; + v3 = a3[12]; + t12 += v3 * b02; + t13 += v3 * b1; + t14 += v3 * b22; + t15 += v3 * b32; + t16 += v3 * b4; + t17 += v3 * b5; + t18 += v3 * b6; + t19 += v3 * b7; + t20 += v3 * b8; + t21 += v3 * b9; + t22 += v3 * b10; + t23 += v3 * b11; + t24 += v3 * b12; + t25 += v3 * b13; + t26 += v3 * b14; + t27 += v3 * b15; + v3 = a3[13]; + t13 += v3 * b02; + t14 += v3 * b1; + t15 += v3 * b22; + t16 += v3 * b32; + t17 += v3 * b4; + t18 += v3 * b5; + t19 += v3 * b6; + t20 += v3 * b7; + t21 += v3 * b8; + t22 += v3 * b9; + t23 += v3 * b10; + t24 += v3 * b11; + t25 += v3 * b12; + t26 += v3 * b13; + t27 += v3 * b14; + t28 += v3 * b15; + v3 = a3[14]; + t14 += v3 * b02; + t15 += v3 * b1; + t16 += v3 * b22; + t17 += v3 * b32; + t18 += v3 * b4; + t19 += v3 * b5; + t20 += v3 * b6; + t21 += v3 * b7; + t22 += v3 * b8; + t23 += v3 * b9; + t24 += v3 * b10; + t25 += v3 * b11; + t26 += v3 * b12; + t27 += v3 * b13; + t28 += v3 * b14; + t29 += v3 * b15; + v3 = a3[15]; + t15 += v3 * b02; + t16 += v3 * b1; + t17 += v3 * b22; + t18 += v3 * b32; + t19 += v3 * b4; + t20 += v3 * b5; + t21 += v3 * b6; + t22 += v3 * b7; + t23 += v3 * b8; + t24 += v3 * b9; + t25 += v3 * b10; + t26 += v3 * b11; + t27 += v3 * b12; + t28 += v3 * b13; + t29 += v3 * b14; + t30 += v3 * b15; + t0 += 38 * t16; + t1 += 38 * t17; + t2 += 38 * t18; + t3 += 38 * t19; + t4 += 38 * t20; + t5 += 38 * t21; + t6 += 38 * t22; + t7 += 38 * t23; + t8 += 38 * t24; + t9 += 38 * t25; + t10 += 38 * t26; + t11 += 38 * t27; + t12 += 38 * t28; + t13 += 38 * t29; + t14 += 38 * t30; + c2 = 1; + v3 = t0 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t0 = v3 - c2 * 65536; + v3 = t1 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t1 = v3 - c2 * 65536; + v3 = t2 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t2 = v3 - c2 * 65536; + v3 = t3 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t3 = v3 - c2 * 65536; + v3 = t4 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t4 = v3 - c2 * 65536; + v3 = t5 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t5 = v3 - c2 * 65536; + v3 = t6 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t6 = v3 - c2 * 65536; + v3 = t7 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t7 = v3 - c2 * 65536; + v3 = t8 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t8 = v3 - c2 * 65536; + v3 = t9 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t9 = v3 - c2 * 65536; + v3 = t10 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t10 = v3 - c2 * 65536; + v3 = t11 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t11 = v3 - c2 * 65536; + v3 = t12 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t12 = v3 - c2 * 65536; + v3 = t13 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t13 = v3 - c2 * 65536; + v3 = t14 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t14 = v3 - c2 * 65536; + v3 = t15 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t15 = v3 - c2 * 65536; + t0 += c2 - 1 + 37 * (c2 - 1); + c2 = 1; + v3 = t0 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t0 = v3 - c2 * 65536; + v3 = t1 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t1 = v3 - c2 * 65536; + v3 = t2 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t2 = v3 - c2 * 65536; + v3 = t3 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t3 = v3 - c2 * 65536; + v3 = t4 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t4 = v3 - c2 * 65536; + v3 = t5 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t5 = v3 - c2 * 65536; + v3 = t6 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t6 = v3 - c2 * 65536; + v3 = t7 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t7 = v3 - c2 * 65536; + v3 = t8 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t8 = v3 - c2 * 65536; + v3 = t9 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t9 = v3 - c2 * 65536; + v3 = t10 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t10 = v3 - c2 * 65536; + v3 = t11 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t11 = v3 - c2 * 65536; + v3 = t12 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t12 = v3 - c2 * 65536; + v3 = t13 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t13 = v3 - c2 * 65536; + v3 = t14 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t14 = v3 - c2 * 65536; + v3 = t15 + c2 + 65535; + c2 = Math.floor(v3 / 65536); + t15 = v3 - c2 * 65536; + t0 += c2 - 1 + 37 * (c2 - 1); + o2[0] = t0; + o2[1] = t1; + o2[2] = t2; + o2[3] = t3; + o2[4] = t4; + o2[5] = t5; + o2[6] = t6; + o2[7] = t7; + o2[8] = t8; + o2[9] = t9; + o2[10] = t10; + o2[11] = t11; + o2[12] = t12; + o2[13] = t13; + o2[14] = t14; + o2[15] = t15; + } + function square(o2, a3) { + mul(o2, a3, a3); + } + function inv25519(o2, inp) { + const c2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + c2[i2] = inp[i2]; + } + for (let i2 = 253; i2 >= 0; i2--) { + square(c2, c2); + if (i2 !== 2 && i2 !== 4) { + mul(c2, c2, inp); + } + } + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = c2[i2]; + } + } + function scalarMult(n4, p2) { + const z2 = new Uint8Array(32); + const x2 = new Float64Array(80); + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(); + for (let i2 = 0; i2 < 31; i2++) { + z2[i2] = n4[i2]; + } + z2[31] = n4[31] & 127 | 64; + z2[0] &= 248; + unpack25519(x2, p2); + for (let i2 = 0; i2 < 16; i2++) { + b3[i2] = x2[i2]; + } + a3[0] = d5[0] = 1; + for (let i2 = 254; i2 >= 0; --i2) { + const r3 = z2[i2 >>> 3] >>> (i2 & 7) & 1; + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); + add(e2, a3, c2); + sub(a3, a3, c2); + add(c2, b3, d5); + sub(b3, b3, d5); + square(d5, e2); + square(f3, a3); + mul(a3, c2, a3); + mul(c2, b3, e2); + add(e2, a3, c2); + sub(a3, a3, c2); + square(b3, a3); + sub(c2, d5, f3); + mul(a3, c2, _121665); + add(a3, a3, d5); + mul(c2, c2, a3); + mul(a3, d5, f3); + mul(d5, b3, x2); + square(b3, e2); + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); + } + for (let i2 = 0; i2 < 16; i2++) { + x2[i2 + 16] = a3[i2]; + x2[i2 + 32] = c2[i2]; + x2[i2 + 48] = b3[i2]; + x2[i2 + 64] = d5[i2]; + } + const x32 = x2.subarray(32); + const x16 = x2.subarray(16); + inv25519(x32, x32); + mul(x16, x16, x32); + const q2 = new Uint8Array(32); + pack25519(q2, x16); + return q2; + } + exports2.scalarMult = scalarMult; + function scalarMultBase(n4) { + return scalarMult(n4, _9); + } + exports2.scalarMultBase = scalarMultBase; + function generateKeyPairFromSeed(seed) { + if (seed.length !== exports2.SECRET_KEY_LENGTH) { + throw new Error(`x25519: seed must be ${exports2.SECRET_KEY_LENGTH} bytes`); + } + const secretKey = new Uint8Array(seed); + const publicKey = scalarMultBase(secretKey); + return { + publicKey, + secretKey + }; + } + exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; + function generateKeyPair2(prng) { + const seed = (0, random_1.randomBytes)(32, prng); + const result = generateKeyPairFromSeed(seed); + (0, wipe_12.wipe)(seed); + return result; + } + exports2.generateKeyPair = generateKeyPair2; + function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { + if (mySecretKey.length !== exports2.PUBLIC_KEY_LENGTH) { + throw new Error("X25519: incorrect secret key length"); + } + if (theirPublicKey.length !== exports2.PUBLIC_KEY_LENGTH) { + throw new Error("X25519: incorrect public key length"); + } + const result = scalarMult(mySecretKey, theirPublicKey); + if (rejectZero) { + let zeros = 0; + for (let i2 = 0; i2 < result.length; i2++) { + zeros |= result[i2]; + } + if (zeros === 0) { + throw new Error("X25519: invalid shared key"); + } + } + return result; + } + exports2.sharedKey = sharedKey; +})(x25519); +const C$1 = { 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" } }; +const Ir$1 = ":"; +function dn(e2) { + const [t2, r3] = e2.split(Ir$1); + return { namespace: t2, reference: r3 }; +} +function _r$1(e2, t2) { + return e2.includes(":") ? [e2] : t2.chains || []; +} +var Qo = Object.defineProperty, bn = Object.getOwnPropertySymbols, Jo = Object.prototype.hasOwnProperty, Go = Object.prototype.propertyIsEnumerable, yn = (e2, t2, r3) => t2 in e2 ? Qo(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, wn = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Jo.call(t2, r3) && yn(e2, r3, t2[r3]); + if (bn) + for (var r3 of bn(t2)) + Go.call(t2, r3) && yn(e2, r3, t2[r3]); + return e2; +}; +const xn = "ReactNative", qt$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, En = "js"; +function pi() { + return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; +} +function er$1() { + return !getDocument_1() && !!getNavigator_1() && navigator.product === xn; +} +function pr$1() { + return !pi() && !!getNavigator_1() && !!getDocument_1(); +} +function We$2() { + return er$1() ? qt$1.reactNative : pi() ? qt$1.node : pr$1() ? qt$1.browser : qt$1.unknown; +} +function Wo() { + var e2; + try { + return er$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e2 = global.Application) == null ? void 0 : e2.applicationId : void 0; + } catch { + return; + } +} +function Sn(e2, t2) { + let r3 = queryString.parse(e2); + return r3 = wn(wn({}, r3), t2), e2 = queryString.stringify(r3), e2; +} +function Xo() { + return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; +} +function Nn() { + if (We$2() === qt$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { + const { OS: r3, Version: i2 } = global.Platform; + return [r3, i2].join("-"); + } + const e2 = detect(); + if (e2 === null) + return "unknown"; + const t2 = e2.os ? e2.os.replace(" ", "").toLowerCase() : "unknown"; + return e2.type === "browser" ? [t2, e2.name, e2.version].join("-") : [t2, e2.version].join("-"); +} +function In() { + var e2; + const t2 = We$2(); + return t2 === qt$1.browser ? [t2, ((e2 = getLocation_1()) == null ? void 0 : e2.host) || "unknown"].join(":") : t2; +} +function _n(e2, t2, r3) { + const i2 = Nn(), n4 = In(); + return [[e2, t2].join("-"), [En, r3].join("-"), i2, n4].join("/"); +} +function $o({ protocol: e2, version: t2, relayUrl: r3, sdkVersion: i2, auth: n4, projectId: o2, useOnCloseEvent: h4, bundleId: p2 }) { + const b3 = r3.split("?"), m3 = _n(e2, t2, i2), w3 = { auth: n4, ua: m3, projectId: o2, useOnCloseEvent: h4 || void 0, origin: p2 || void 0 }, y3 = Sn(b3[1] || "", w3); + return b3[0] + "?" + y3; +} +function _e$1(e2, t2) { + return e2.filter((r3) => t2.includes(r3)).length === e2.length; +} +function i0(e2) { + return Object.fromEntries(e2.entries()); +} +function n0(e2) { + return new Map(Object.entries(e2)); +} +function a0(e2 = cjs$3.FIVE_MINUTES, t2) { + const r3 = cjs$3.toMiliseconds(e2 || cjs$3.FIVE_MINUTES); + let i2, n4, o2; + return { resolve: (h4) => { + o2 && i2 && (clearTimeout(o2), i2(h4)); + }, reject: (h4) => { + o2 && n4 && (clearTimeout(o2), n4(h4)); + }, done: () => new Promise((h4, p2) => { + o2 = setTimeout(() => { + p2(new Error(t2)); + }, r3), i2 = h4, n4 = p2; + }) }; +} +function u0(e2, t2, r3) { + return new Promise(async (i2, n4) => { + const o2 = setTimeout(() => n4(new Error(r3)), t2); + try { + const h4 = await e2; + i2(h4); + } catch (h4) { + n4(h4); + } + clearTimeout(o2); + }); +} +function vi(e2, t2) { + if (typeof t2 == "string" && t2.startsWith(`${e2}:`)) + return t2; + if (e2.toLowerCase() === "topic") { + if (typeof t2 != "string") + throw new Error('Value must be "string" for expirer target type: topic'); + return `topic:${t2}`; + } else if (e2.toLowerCase() === "id") { + if (typeof t2 != "number") + throw new Error('Value must be "number" for expirer target type: id'); + return `id:${t2}`; + } + throw new Error(`Unknown expirer target type: ${e2}`); +} +function h0(e2) { + return vi("topic", e2); +} +function c0(e2) { + return vi("id", e2); +} +function l0(e2) { + const [t2, r3] = e2.split(":"), i2 = { id: void 0, topic: void 0 }; + if (t2 === "topic" && typeof r3 == "string") + i2.topic = r3; + else if (t2 === "id" && Number.isInteger(Number(r3))) + i2.id = Number(r3); + else + throw new Error(`Invalid target, expected id:number or topic:string, got ${t2}:${r3}`); + return i2; +} +function d0(e2, t2) { + return cjs$3.fromMiliseconds(Date.now() + cjs$3.toMiliseconds(e2)); +} +function p0(e2) { + return Date.now() >= cjs$3.toMiliseconds(e2); +} +function v0(e2, t2) { + return `${e2}${t2 ? `:${t2}` : ""}`; +} +function ge$1(e2 = [], t2 = []) { + return [.../* @__PURE__ */ new Set([...e2, ...t2])]; +} +async function m0({ id: e2, topic: t2, wcDeepLink: r3 }) { + try { + if (!r3) + return; + const i2 = typeof r3 == "string" ? JSON.parse(r3) : r3; + let n4 = i2 == null ? void 0 : i2.href; + if (typeof n4 != "string") + return; + n4.endsWith("/") && (n4 = n4.slice(0, -1)); + const o2 = `${n4}/wc?requestId=${e2}&sessionTopic=${t2}`, h4 = We$2(); + h4 === qt$1.browser ? o2.startsWith("https://") || o2.startsWith("http://") ? window.open(o2, "_blank", "noreferrer noopener") : window.open(o2, "_self", "noreferrer noopener") : h4 === qt$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(o2); + } catch (i2) { + console.error(i2); + } +} +async function g0(e2, t2) { + try { + return await e2.getItem(t2) || (pr$1() ? localStorage.getItem(t2) : void 0); + } catch (r3) { + console.error(r3); + } +} +var On$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function A0$1(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; +} +var Pn$1 = { exports: {} }; +/** +* [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 +*/ +(function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On$1 : o2 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s2(u3, E2, u3).update(B2)[_3](); + }; + }, H2 = function(u3, E2, _3) { + return function(B2, R2) { + return new s2(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s2(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H2(u3, E2, "hex"); + return _3.create = function(B2) { + return new s2(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H2, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s2(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s2(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N2[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; + } + return this; + }, s2.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s2.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s2.call(this, u3, E2, _3); + } + v3.prototype = new s2(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne, Ie; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z2 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z2 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _3 = D2 ^ (Z2 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne = u3[42] << 2 | u3[43] >>> 30, Ie = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne, u3[45] = Me2 ^ ~Se2 & Ie, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne & St2, u3[47] = Se2 ^ ~Ie & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne ^ ~St2 & Ve2, u3[49] = Ie ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); +})(Pn$1); +var b0 = Pn$1.exports; +const y0$1 = "logger/5.7.0"; +let Dn$1 = false, Fn$1 = false; +const Cr$2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let Tn$1 = Cr$2.default, gi$1 = null; +function w0$1() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; + } + return null; +} +const Un$1 = w0$1(); +var Ai$1; +(function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; +})(Ai$1 || (Ai$1 = {})); +var re$2; +(function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; +})(re$2 || (re$2 = {})); +const kn$1 = "0123456789abcdef"; +let L$3 = class L2 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); + } + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr$2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn$1 > Cr$2[i2]) && console.log.apply(console, r3); + } + debug(...t2) { + this._log(L2.levels.DEBUG, t2); + } + info(...t2) { + this._log(L2.levels.INFO, t2); + } + warn(...t2) { + this._log(L2.levels.WARNING, t2); + } + makeError(t2, r3, i2) { + if (Fn$1) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L2.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn$1[m3[y3] >> 4], w3 += kn$1[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o2 = t2; + let h4 = ""; + switch (r3) { + case re$2.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; + } + case re$2.CALL_EXCEPTION: + case re$2.INSUFFICIENT_FUNDS: + case re$2.MISSING_NEW: + case re$2.NONCE_EXPIRED: + case re$2.REPLACEMENT_UNDERPRICED: + case re$2.TRANSACTION_REPLACED: + case re$2.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; + } + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; + } + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); + } + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L2.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); + } + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); + } + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); + } + checkNormalize(t2) { + Un$1 && this.throwError("platform missing String.prototype.normalize", L2.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un$1 }); + } + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); + } + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L2.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L2.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); + } + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r3.name }); + } + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L2.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r3.name }); + } + static globalLogger() { + return gi$1 || (gi$1 = new L2(y0$1)), gi$1; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn$1) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); + } + Fn$1 = !!t2, Dn$1 = !!r3; + } + static setLogLevel(t2) { + const r3 = Cr$2[t2.toLowerCase()]; + if (r3 == null) { + L2.globalLogger().warn("invalid log level - " + t2); + return; + } + Tn$1 = r3; + } + static from(t2) { + return new L2(t2); + } +}; +L$3.errors = re$2, L$3.levels = Ai$1; +const x0$1 = "bytes/5.7.0", Dt$2 = new L$3(x0$1); +function qn$1(e2) { + return !!e2.toHexString; +} +function rr$2(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr$2(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; +} +function M0(e2) { + return Qt$1(e2) && !(e2.length % 2) || ir$2(e2); +} +function Kn$1(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; +} +function ir$2(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn$1(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn$1(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; +} +function Ot$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr$2(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2) && (e2 = e2.toHexString()), Qt$1(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr$2(new Uint8Array(i2)); + } + return ir$2(e2) ? rr$2(new Uint8Array(e2)) : Dt$2.throwArgumentError("invalid arrayify value", "value", e2); +} +function E0(e2) { + const t2 = e2.map((n4) => Ot$2(n4)), r3 = t2.reduce((n4, o2) => n4 + o2.length, 0), i2 = new Uint8Array(r3); + return t2.reduce((n4, o2) => (i2.set(o2, n4), n4 + o2.length), 0), rr$2(i2); +} +function S0(e2, t2) { + e2 = Ot$2(e2), e2.length > t2 && Dt$2.throwArgumentError("value out of range", "value", arguments[0]); + const r3 = new Uint8Array(t2); + return r3.set(e2, t2 - e2.length), rr$2(r3); +} +function Qt$1(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2 && e2.length !== 2 + 2 * t2); +} +const bi$1 = "0123456789abcdef"; +function Kt$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi$1[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2)) + return e2.toHexString(); + if (Qt$1(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir$2(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi$1[(n4 & 240) >> 4] + bi$1[n4 & 15]; + } + return r3; + } + return Dt$2.throwArgumentError("invalid hexlify value", "value", e2); +} +function N0(e2) { + if (typeof e2 != "string") + e2 = Kt$2(e2); + else if (!Qt$1(e2) || e2.length % 2) + return null; + return (e2.length - 2) / 2; +} +function Hn(e2, t2, r3) { + return typeof e2 != "string" ? e2 = Kt$2(e2) : (!Qt$1(e2) || e2.length % 2) && Dt$2.throwArgumentError("invalid hexData", "value", e2), t2 = 2 + 2 * t2, r3 != null ? "0x" + e2.substring(t2, 2 + 2 * r3) : "0x" + e2.substring(t2); +} +function oe$1(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt$2(e2) : Qt$1(e2) || Dt$2.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt$2.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; +} +function zn(e2) { + const t2 = { r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0, yParityAndS: "0x", compact: "0x" }; + if (M0(e2)) { + let r3 = Ot$2(e2); + r3.length === 64 ? (t2.v = 27 + (r3[32] >> 7), r3[32] &= 127, t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64))) : r3.length === 65 ? (t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64)), t2.v = r3[64]) : Dt$2.throwArgumentError("invalid signature string", "signature", e2), t2.v < 27 && (t2.v === 0 || t2.v === 1 ? t2.v += 27 : Dt$2.throwArgumentError("signature invalid v byte", "signature", e2)), t2.recoveryParam = 1 - t2.v % 2, t2.recoveryParam && (r3[32] |= 128), t2._vs = Kt$2(r3.slice(32, 64)); + } else { + if (t2.r = e2.r, t2.s = e2.s, t2.v = e2.v, t2.recoveryParam = e2.recoveryParam, t2._vs = e2._vs, t2._vs != null) { + const n4 = S0(Ot$2(t2._vs), 32); + t2._vs = Kt$2(n4); + const o2 = n4[0] >= 128 ? 1 : 0; + t2.recoveryParam == null ? t2.recoveryParam = o2 : t2.recoveryParam !== o2 && Dt$2.throwArgumentError("signature recoveryParam mismatch _vs", "signature", e2), n4[0] &= 127; + const h4 = Kt$2(n4); + t2.s == null ? t2.s = h4 : t2.s !== h4 && Dt$2.throwArgumentError("signature v mismatch _vs", "signature", e2); + } + if (t2.recoveryParam == null) + t2.v == null ? Dt$2.throwArgumentError("signature missing v and recoveryParam", "signature", e2) : t2.v === 0 || t2.v === 1 ? t2.recoveryParam = t2.v : t2.recoveryParam = 1 - t2.v % 2; + else if (t2.v == null) + t2.v = 27 + t2.recoveryParam; + else { + const n4 = t2.v === 0 || t2.v === 1 ? t2.v : 1 - t2.v % 2; + t2.recoveryParam !== n4 && Dt$2.throwArgumentError("signature recoveryParam mismatch v", "signature", e2); + } + t2.r == null || !Qt$1(t2.r) ? Dt$2.throwArgumentError("signature missing or invalid r", "signature", e2) : t2.r = oe$1(t2.r, 32), t2.s == null || !Qt$1(t2.s) ? Dt$2.throwArgumentError("signature missing or invalid s", "signature", e2) : t2.s = oe$1(t2.s, 32); + const r3 = Ot$2(t2.s); + r3[0] >= 128 && Dt$2.throwArgumentError("signature s out of range", "signature", e2), t2.recoveryParam && (r3[0] |= 128); + const i2 = Kt$2(r3); + t2._vs && (Qt$1(t2._vs) || Dt$2.throwArgumentError("signature invalid _vs", "signature", e2), t2._vs = oe$1(t2._vs, 32)), t2._vs == null ? t2._vs = i2 : t2._vs !== i2 && Dt$2.throwArgumentError("signature _vs mismatch v and s", "signature", e2); + } + return t2.yParityAndS = t2._vs, t2.compact = t2.r + t2.yParityAndS.substring(2), t2; +} +function yi(e2) { + return "0x" + b0.keccak_256(Ot$2(e2)); +} +var Ln$1 = { exports: {} }, I0$1 = {}, _0$1 = Object.freeze({ __proto__: null, default: I0$1 }), B0$1 = A0$1(_0$1); +(function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; + } + function o2(A2, f3, a3) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r3.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0$1.Buffer; + } catch { + } + o2.isBN = function(f3) { + return f3 instanceof o2 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o2.wordSize && Array.isArray(f3.words); + }, o2.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o2.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o2.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o2.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o2.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + } + this._strip(); + }; + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o2.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v3 = c2; v3 < l2; v3 += d5) + s2 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o2.prototype._move = function(f3) { + w3(f3, this); + }, o2.prototype.clone = function() { + var f3 = new o2(null); + return this.copy(f3), f3; + }, o2.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o2.prototype.inspect = y3; + } + else + o2.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s2 = I2[f3], v3 = N2[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s2 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o2.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o2.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o2.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o2.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o2.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o2.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; + } + return f3; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o2.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o2.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o2.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o2.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o2.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o2.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o2.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o2.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o2.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o2.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o2.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o2.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o2.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o2.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o2.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s2, f3.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s2 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s2] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s2] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s2, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te = d5[6] | 0, et2 = Te & 8191, rt2 = Te >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le = g3[3] | 0, vt2 = Le & 8191, mt2 = Le >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s2 = Math.imul(u3, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s2 = s2 + Math.imul(u3, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s2 = s2 + Math.imul(u3, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s2 = s2 + Math.imul(u3, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ne >>> 26) | 0, Ne &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v3 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s2 = s2 + Math.imul(u3, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v3 = v3 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s2 = s2 + Math.imul(u3, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v3 = v3 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s2 = s2 + Math.imul(u3, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v3 = v3 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s2 = s2 + Math.imul(u3, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v3 = v3 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s2 = s2 + Math.imul(u3, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v3 = v3 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s2 = s2 + Math.imul(u3, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v3 = v3 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v3 = v3 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v3 = v3 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v3 = v3 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v3 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne, x2[4] = Ie, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s2 = Math.max(0, g3 - A2.length + 1); s2 <= l2; s2++) { + var v3 = g3 - s2, k2 = A2.words[v3] | 0, u3 = f3.words[s2] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o2.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o2.prototype.mul = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o2.prototype.mulf = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o2.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o2.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o2.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o2(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o2.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o2.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v3 !== 0 || s2 >= d5); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o2.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o2.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o2.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o2.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o2.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o2.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o2.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o2.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o2.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o2.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o2.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s2; + if (a3 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v3 = 0; v3 < s2.length; v3++) + s2.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s2 && (s2.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s2 && (s2.words[u3] = E2); + } + return s2 && s2._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s2 || null, mod: d5 }; + }, o2.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o2(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o2(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o2(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o2.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o2.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o2.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o2.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o2.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o2.prototype.modn = function(f3) { + return this.modrn(f3); + }, o2.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o2.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o2.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s2), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s2 = 0, v3 = 1; !(c2.words[0] & v3) && s2 < 26; ++s2, v3 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o2.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o2.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o2.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o2.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; + } + } + return a3; + }, o2.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o2.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o2.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o2.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o2.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o2.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o2.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o2.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o2.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o2.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o2.red = function(f3) { + return new Y2(f3); + }, o2.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o2.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o2.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o2.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o2.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o2.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o2.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o2.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o2.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o2(f3, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o2(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o2._prime = function(f3) { + if (H2[f3]) + return H2[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H2[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o2._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v3 = this.pow(s2, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o2(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o2(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s2 = a3.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s2 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o2.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o2(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On$1); +})(Ln$1); +var K$2 = Ln$1.exports; +const jn$1 = "bignumber/5.7.0"; +var Rr$2 = K$2.BN; +const Ae$1 = new L$3(jn$1), wi$1 = {}, Qn$1 = 9007199254740991; +function C0$1(e2) { + return e2 != null && (V$2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt$1(e2) || typeof e2 == "bigint" || ir$2(e2)); +} +let Jn$1 = false; +let V$2 = class V { + constructor(t2, r3) { + t2 !== wi$1 && Ae$1.throwError("cannot call constructor directly; use BigNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); + } + fromTwos(t2) { + return Lt$2(j$2(this).fromTwos(t2)); + } + toTwos(t2) { + return Lt$2(j$2(this).toTwos(t2)); + } + abs() { + return this._hex[0] === "-" ? V.from(this._hex.substring(1)) : this; + } + add(t2) { + return Lt$2(j$2(this).add(j$2(t2))); + } + sub(t2) { + return Lt$2(j$2(this).sub(j$2(t2))); + } + div(t2) { + return V.from(t2).isZero() && Wt$3("division-by-zero", "div"), Lt$2(j$2(this).div(j$2(t2))); + } + mul(t2) { + return Lt$2(j$2(this).mul(j$2(t2))); + } + mod(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("division-by-zero", "mod"), Lt$2(j$2(this).umod(r3)); + } + pow(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("negative-power", "pow"), Lt$2(j$2(this).pow(r3)); + } + and(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "and"), Lt$2(j$2(this).and(r3)); + } + or(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "or"), Lt$2(j$2(this).or(r3)); + } + xor(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "xor"), Lt$2(j$2(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "mask"), Lt$2(j$2(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shl"), Lt$2(j$2(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shr"), Lt$2(j$2(this).shrn(t2)); + } + eq(t2) { + return j$2(this).eq(j$2(t2)); + } + lt(t2) { + return j$2(this).lt(j$2(t2)); + } + lte(t2) { + return j$2(this).lte(j$2(t2)); + } + gt(t2) { + return j$2(this).gt(j$2(t2)); + } + gte(t2) { + return j$2(this).gte(j$2(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j$2(this).isZero(); + } + toNumber() { + try { + return j$2(this).toNumber(); + } catch { + Wt$3("overflow", "toNumber", this.toString()); + } + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { + } + return Ae$1.throwError("this platform does not support BigInt", L$3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn$1 || (Jn$1 = true, Ae$1.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae$1.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L$3.errors.UNEXPECTED_ARGUMENT, {}) : Ae$1.throwError("BigNumber.toString does not accept parameters", L$3.errors.UNEXPECTED_ARGUMENT, {})), j$2(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V(wi$1, vr$1(t2)) : t2.match(/^-?[0-9]+$/) ? new V(wi$1, vr$1(new Rr$2(t2))) : Ae$1.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt$3("underflow", "BigNumber.from", t2), (t2 >= Qn$1 || t2 <= -Qn$1) && Wt$3("overflow", "BigNumber.from", t2), V.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V.from(r3.toString()); + if (ir$2(r3)) + return V.from(Kt$2(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V.from(i2); + } else { + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt$1(i2) || i2[0] === "-" && Qt$1(i2.substring(1)))) + return V.from(i2); + } + return Ae$1.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } +}; +function vr$1(e2) { + if (typeof e2 != "string") + return vr$1(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae$1.throwArgumentError("invalid hex", "value", e2), e2 = vr$1(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; +} +function Lt$2(e2) { + return V$2.from(vr$1(e2)); +} +function j$2(e2) { + const t2 = V$2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr$2("-" + t2.substring(3), 16) : new Rr$2(t2.substring(2), 16); +} +function Wt$3(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae$1.throwError(e2, L$3.errors.NUMERIC_FAULT, i2); +} +function R0(e2) { + return new Rr$2(e2, 36).toString(16); +} +const Ht$3 = new L$3(jn$1), mr$2 = {}, Gn$1 = V$2.from(0), Yn$1 = V$2.from(-1); +function Vn$1(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht$3.throwError(e2, L$3.errors.NUMERIC_FAULT, n4); +} +let gr$2 = "0"; +for (; gr$2.length < 256; ) + gr$2 += gr$2; +function xi$1(e2) { + if (typeof e2 != "number") + try { + e2 = V$2.from(e2).toNumber(); + } catch { + } + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr$2.substring(0, e2) : Ht$3.throwArgumentError("invalid decimal size", "decimals", e2); +} +function Mi$1(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + e2 = V$2.from(e2); + const i2 = e2.lt(Gn$1); + i2 && (e2 = e2.mul(Yn$1)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o2 : e2 = o2 + "." + n4, i2 && (e2 = "-" + e2), e2; +} +function be$2(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht$3.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht$3.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht$3.throwArgumentError("too many decimal points", "value", e2); + let o2 = n4[0], h4 = n4[1]; + for (o2 || (o2 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn$1("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V$2.from(o2), b3 = V$2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn$1)), m3; +} +let dr$2 = class dr { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi$1(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht$3.throwArgumentError("invalid fixed format", "format", t2), r3 = o2[1] !== "u", i2 = parseInt(o2[2]), n4 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht$3.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o2("signed", "boolean", r3), i2 = o2("width", "number", i2), n4 = o2("decimals", "number", n4); + } + return i2 % 8 && Ht$3.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht$3.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr(mr$2, r3, i2, n4); + } +}; +let Ut$2 = class Ut { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht$3.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn$1.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn$1.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht$3.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut.from("1" + gr$2.substring(0, t2), this.format), n4 = O0$1.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); + } + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht$3.throwArgumentError("invalid byte width", "width", t2); + const r3 = V$2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe$1(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0$1(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut.fromString(Mi$1(t2, r3), dr$2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3), n4 = be$2(t2, i2.decimals); + !i2.signed && n4.lt(Gn$1) && Vn$1("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n4.toTwos(i2.width).toHexString() : (o2 = n4.toHexString(), o2 = oe$1(o2, i2.width / 8)); + const h4 = Mi$1(n4, i2.decimals); + return new Ut(mr$2, o2, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3); + if (Ot$2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V$2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o2 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi$1(n4, i2.decimals); + return new Ut(mr$2, o2, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut.fromString(t2, r3); + if (ir$2(t2)) + return Ut.fromBytes(t2, r3); + try { + return Ut.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L$3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht$3.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } +}; +const Wn$1 = Ut$2.from(1), O0$1 = Ut$2.from("0.5"), P0 = "strings/5.7.0", Xn = new L$3(P0); +var Or$2; +(function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; +})(Or$2 || (Or$2 = {})); +var nr$2; +(function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; +})(nr$2 || (nr$2 = {})); +function Ei(e2, t2 = Or$2.current) { + t2 != Or$2.current && (Xn.checkNormalize(), e2 = e2.normalize(t2)); + let r3 = []; + for (let i2 = 0; i2 < e2.length; i2++) { + const n4 = e2.charCodeAt(i2); + if (n4 < 128) + r3.push(n4); + else if (n4 < 2048) + r3.push(n4 >> 6 | 192), r3.push(n4 & 63 | 128); + else if ((n4 & 64512) == 55296) { + i2++; + const o2 = e2.charCodeAt(i2); + if (i2 >= e2.length || (o2 & 64512) !== 56320) + throw new Error("invalid utf-8 string"); + const h4 = 65536 + ((n4 & 1023) << 10) + (o2 & 1023); + r3.push(h4 >> 18 | 240), r3.push(h4 >> 12 & 63 | 128), r3.push(h4 >> 6 & 63 | 128), r3.push(h4 & 63 | 128); + } else + r3.push(n4 >> 12 | 224), r3.push(n4 >> 6 & 63 | 128), r3.push(n4 & 63 | 128); + } + return Ot$2(r3); +} +function T0$1(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; +} +function Si$1(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; + }); + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o2 = n4.split(":"); + r3 += parseInt(o2[0], 16), i2[r3] = t2(o2[1]); + }), i2; +} +function $n$1(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); +} +$n$1("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si$1("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si$1("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si$1("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0$1), $n$1("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function U0$1(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot$2(t2); +} +function ef$1(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o2, h4) { + i2.call(o2, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); + }); + }; + return n4(e2, t2), r3; +} +function k0$1(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; +} +function q0$1(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y3; H2++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H2 < o2[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; + } + }); +} +function K0$1(e2) { + let t2 = 0; + return () => e2[t2++]; +} +function H0$1(e2) { + return K0$1(q0$1(e2)); +} +function z0$1(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; +} +function L0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; +} +function rf$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; +} +function j0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0$1(t2()); + return r3; +} +function Pr$2(e2, t2) { + let r3 = rf$1(e2(), e2), i2 = e2(), n4 = rf$1(i2, e2), o2 = L0$1(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o2[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; +} +function Q0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0$1(r3, e2)); + } + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0$1(r3, e2)); + } + return k0$1(ef$1(t2)); +} +function J0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); + } + return t2; +} +function nf$1(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0$1(e2, r3).forEach((o2, h4) => i2[h4].push(o2)); + return i2; +} +function G0$1(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0$1(t2), o2 = nf$1(n4.length, 1 + e2, t2); + return ef$1(o2.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; + }); + })); +} +function Y0$1(e2, t2) { + let r3 = 1 + t2(); + return nf$1(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); +} +function V0$1(e2) { + let t2 = Pr$2(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr$2(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o2 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o2, fe0f: h4, save: p2, check: b3 }; + } +} +function W0$1() { + return H0$1(U0$1("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); +} +const Dr$2 = W0$1(); +new Set(Pr$2(Dr$2)), new Set(Pr$2(Dr$2)), Q0$1(Dr$2), V0$1(Dr$2); +const X0$1 = new Uint8Array(32); +X0$1.fill(0); +const Z0 = `Ethereum Signed Message: +`; +function ff(e2) { + return typeof e2 == "string" && (e2 = Ei(e2)), yi(E0([Ei(Z0), Ei(String(e2.length)), e2])); +} +const ts$2 = "address/5.7.0", Ar$1 = new L$3(ts$2); +function of(e2) { + Qt$1(e2, 20) || Ar$1.throwArgumentError("invalid address", "address", e2), e2 = e2.toLowerCase(); + const t2 = e2.substring(2).split(""), r3 = new Uint8Array(40); + for (let n4 = 0; n4 < 40; n4++) + r3[n4] = t2[n4].charCodeAt(0); + const i2 = Ot$2(yi(r3)); + for (let n4 = 0; n4 < 40; n4 += 2) + i2[n4 >> 1] >> 4 >= 8 && (t2[n4] = t2[n4].toUpperCase()), (i2[n4 >> 1] & 15) >= 8 && (t2[n4 + 1] = t2[n4 + 1].toUpperCase()); + return "0x" + t2.join(""); +} +const es$2 = 9007199254740991; +function rs$2(e2) { + return Math.log10 ? Math.log10(e2) : Math.log(e2) / Math.LN10; +} +const Ni = {}; +for (let e2 = 0; e2 < 10; e2++) + Ni[String(e2)] = String(e2); +for (let e2 = 0; e2 < 26; e2++) + Ni[String.fromCharCode(65 + e2)] = String(10 + e2); +const sf = Math.floor(rs$2(es$2)); +function is$2(e2) { + e2 = e2.toUpperCase(), e2 = e2.substring(4) + e2.substring(0, 2) + "00"; + let t2 = e2.split("").map((i2) => Ni[i2]).join(""); + for (; t2.length >= sf; ) { + let i2 = t2.substring(0, sf); + t2 = parseInt(i2, 10) % 97 + t2.substring(i2.length); + } + let r3 = String(98 - parseInt(t2, 10) % 97); + for (; r3.length < 2; ) + r3 = "0" + r3; + return r3; +} +function ns$1(e2) { + let t2 = null; + if (typeof e2 != "string" && Ar$1.throwArgumentError("invalid address", "address", e2), e2.match(/^(0x)?[0-9a-fA-F]{40}$/)) + e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), t2 = of(e2), e2.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && t2 !== e2 && Ar$1.throwArgumentError("bad address checksum", "address", e2); + else if (e2.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + for (e2.substring(2, 4) !== is$2(e2) && Ar$1.throwArgumentError("bad icap checksum", "address", e2), t2 = R0(e2.substring(4)); t2.length < 40; ) + t2 = "0" + t2; + t2 = of("0x" + t2); + } else + Ar$1.throwArgumentError("invalid address", "address", e2); + return t2; +} +function br$1(e2, t2, r3) { + Object.defineProperty(e2, t2, { enumerable: true, value: r3, writable: false }); +} +const os$2 = new Uint8Array(32); +os$2.fill(0), V$2.from(-1); +const ss$3 = V$2.from(0), as$2 = V$2.from(1); +V$2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe$1(as$2.toHexString(), 32), oe$1(ss$3.toHexString(), 32); +var se$2 = {}, Q$2 = {}, yr$2 = af$1; +function af$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +af$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var Ii$1 = { exports: {} }; +typeof Object.create == "function" ? Ii$1.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); +} : Ii$1.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; + } +}; +var us$2 = yr$2, hs$2 = Ii$1.exports; +Q$2.inherits = hs$2; +function cs$2(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; +} +function ls$2(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o2 = e2.charCodeAt(n4); + o2 < 128 ? r3[i2++] = o2 : o2 < 2048 ? (r3[i2++] = o2 >> 6 | 192, r3[i2++] = o2 & 63 | 128) : cs$2(e2, n4) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o2 >> 18 | 240, r3[i2++] = o2 >> 12 & 63 | 128, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128) : (r3[i2++] = o2 >> 12 | 224, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128); + } + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; +} +Q$2.toArray = ls$2; +function ds$2(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf$1(e2[r3].toString(16)); + return t2; +} +Q$2.toHex = ds$2; +function uf$1(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; +} +Q$2.htonl = uf$1; +function ps$2(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf$1(n4)), r3 += cf$1(n4.toString(16)); + } + return r3; +} +Q$2.toHex32 = ps$2; +function hf$1(e2) { + return e2.length === 1 ? "0" + e2 : e2; +} +Q$2.zero2 = hf$1; +function cf$1(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; +} +Q$2.zero8 = cf$1; +function vs$2(e2, t2, r3, i2) { + var n4 = r3 - t2; + us$2(n4 % 4 === 0); + for (var o2 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o2.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h4] = b3 >>> 0; + } + return o2; +} +Q$2.join32 = vs$2; +function ms$3(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r3[n4] = o2 >>> 24, r3[n4 + 1] = o2 >>> 16 & 255, r3[n4 + 2] = o2 >>> 8 & 255, r3[n4 + 3] = o2 & 255) : (r3[n4 + 3] = o2 >>> 24, r3[n4 + 2] = o2 >>> 16 & 255, r3[n4 + 1] = o2 >>> 8 & 255, r3[n4] = o2 & 255); + } + return r3; +} +Q$2.split32 = ms$3; +function gs$2(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; +} +Q$2.rotr32 = gs$2; +function As$2(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; +} +Q$2.rotl32 = As$2; +function bs$2(e2, t2) { + return e2 + t2 >>> 0; +} +Q$2.sum32 = bs$2; +function ys$2(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; +} +Q$2.sum32_3 = ys$2; +function ws$2(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; +} +Q$2.sum32_4 = ws$2; +function xs$2(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; +} +Q$2.sum32_5 = xs$2; +function Ms$2(e2, t2, r3, i2) { + var n4 = e2[t2], o2 = e2[t2 + 1], h4 = i2 + o2 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; +} +Q$2.sum64 = Ms$2; +function Es$2(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o2 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o2 >>> 0; +} +Q$2.sum64_hi = Es$2; +function Ss$2(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; +} +Q$2.sum64_lo = Ss$2; +function Ns$2(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o2 >>> 0, b3 += m3 < o2 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; +} +Q$2.sum64_4_hi = Ns$2; +function Is$2(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = t2 + i2 + o2 + p2; + return b3 >>> 0; +} +Q$2.sum64_4_lo = Is$2; +function _s$2(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o2 >>> 0, w3 += y3 < o2 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; +} +Q$2.sum64_5_hi = _s$2; +function Bs$2(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = t2 + i2 + o2 + p2 + m3; + return w3 >>> 0; +} +Q$2.sum64_5_lo = Bs$2; +function Cs$2(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; +} +Q$2.rotr64_hi = Cs$2; +function Rs$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q$2.rotr64_lo = Rs$2; +function Os$2(e2, t2, r3) { + return e2 >>> r3; +} +Q$2.shr64_hi = Os$2; +function Ps$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q$2.shr64_lo = Ps$2; +var fr$1 = {}, lf$1 = Q$2, Ds$2 = yr$2; +function Fr$2() { + 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; +} +fr$1.BlockHash = Fr$2, Fr$2.prototype.update = function(t2, r3) { + if (t2 = lf$1.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf$1.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; +}, Fr$2.prototype.digest = function(t2) { + return this.update(this._pad()), Ds$2(this.pending === null), this._digest(t2); +}, Fr$2.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n4[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 & 255; + } else + for (n4[o2++] = t2 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + return n4; +}; +var or$2 = {}, ae$1 = {}, Fs$2 = Q$2, ue$1 = Fs$2.rotr32; +function Ts$2(e2, t2, r3, i2) { + if (e2 === 0) + return df$1(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf$1(t2, r3, i2); + if (e2 === 2) + return pf$1(t2, r3, i2); +} +ae$1.ft_1 = Ts$2; +function df$1(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; +} +ae$1.ch32 = df$1; +function pf$1(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; +} +ae$1.maj32 = pf$1; +function vf$1(e2, t2, r3) { + return e2 ^ t2 ^ r3; +} +ae$1.p32 = vf$1; +function Us$2(e2) { + return ue$1(e2, 2) ^ ue$1(e2, 13) ^ ue$1(e2, 22); +} +ae$1.s0_256 = Us$2; +function ks$2(e2) { + return ue$1(e2, 6) ^ ue$1(e2, 11) ^ ue$1(e2, 25); +} +ae$1.s1_256 = ks$2; +function qs$2(e2) { + return ue$1(e2, 7) ^ ue$1(e2, 18) ^ e2 >>> 3; +} +ae$1.g0_256 = qs$2; +function Ks$2(e2) { + return ue$1(e2, 17) ^ ue$1(e2, 19) ^ e2 >>> 10; +} +ae$1.g1_256 = Ks$2; +var sr$2 = Q$2, Hs$2 = fr$1, zs$2 = ae$1, _i$1 = sr$2.rotl32, wr$1 = sr$2.sum32, Ls$2 = sr$2.sum32_5, js$2 = zs$2.ft_1, mf$1 = Hs$2.BlockHash, Qs$2 = [1518500249, 1859775393, 2400959708, 3395469782]; +function he$1() { + if (!(this instanceof he$1)) + return new he$1(); + mf$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); +} +sr$2.inherits(he$1, mf$1); +var Js$2 = he$1; +he$1.blockSize = 512, he$1.outSize = 160, he$1.hmacStrength = 80, he$1.padLength = 64, he$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i$1(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls$2(_i$1(o2, 5), js$2(w3, h4, p2, b3), m3, i2[n4], Qs$2[w3]); + m3 = b3, b3 = p2, p2 = _i$1(h4, 30), h4 = o2, o2 = y3; + } + this.h[0] = wr$1(this.h[0], o2), this.h[1] = wr$1(this.h[1], h4), this.h[2] = wr$1(this.h[2], p2), this.h[3] = wr$1(this.h[3], b3), this.h[4] = wr$1(this.h[4], m3); +}, he$1.prototype._digest = function(t2) { + return t2 === "hex" ? sr$2.toHex32(this.h, "big") : sr$2.split32(this.h, "big"); +}; +var ar$2 = Q$2, Gs$2 = fr$1, ur$2 = ae$1, Ys$2 = yr$2, ie$3 = ar$2.sum32, Vs$2 = ar$2.sum32_4, Ws$2 = ar$2.sum32_5, Xs$2 = ur$2.ch32, Zs$2 = ur$2.maj32, $s$2 = ur$2.s0_256, ta$1 = ur$2.s1_256, ea$1 = ur$2.g0_256, ra$1 = ur$2.g1_256, gf$1 = Gs$2.BlockHash, ia$1 = [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 ce$1() { + if (!(this instanceof ce$1)) + return new ce$1(); + gf$1.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia$1, this.W = new Array(64); +} +ar$2.inherits(ce$1, gf$1); +var Af$1 = ce$1; +ce$1.blockSize = 512, ce$1.outSize = 256, ce$1.hmacStrength = 192, ce$1.padLength = 64, ce$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs$2(ra$1(i2[n4 - 2]), i2[n4 - 7], ea$1(i2[n4 - 15]), i2[n4 - 16]); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys$2(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws$2(S2, ta$1(m3), Xs$2(m3, w3, y3), this.k[n4], i2[n4]), N2 = ie$3($s$2(o2), Zs$2(o2, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie$3(b3, I2), b3 = p2, p2 = h4, h4 = o2, o2 = ie$3(I2, N2); + } + this.h[0] = ie$3(this.h[0], o2), this.h[1] = ie$3(this.h[1], h4), this.h[2] = ie$3(this.h[2], p2), this.h[3] = ie$3(this.h[3], b3), this.h[4] = ie$3(this.h[4], m3), this.h[5] = ie$3(this.h[5], w3), this.h[6] = ie$3(this.h[6], y3), this.h[7] = ie$3(this.h[7], S2); +}, ce$1.prototype._digest = function(t2) { + return t2 === "hex" ? ar$2.toHex32(this.h, "big") : ar$2.split32(this.h, "big"); +}; +var Bi$1 = Q$2, bf$1 = Af$1; +function ye$2() { + if (!(this instanceof ye$2)) + return new ye$2(); + bf$1.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; +} +Bi$1.inherits(ye$2, bf$1); +var na$1 = ye$2; +ye$2.blockSize = 512, ye$2.outSize = 224, ye$2.hmacStrength = 192, ye$2.padLength = 64, ye$2.prototype._digest = function(t2) { + return t2 === "hex" ? Bi$1.toHex32(this.h.slice(0, 7), "big") : Bi$1.split32(this.h.slice(0, 7), "big"); +}; +var jt$2 = Q$2, fa$1 = fr$1, oa$1 = yr$2, le$1 = jt$2.rotr64_hi, de$2 = jt$2.rotr64_lo, yf$1 = jt$2.shr64_hi, wf$1 = jt$2.shr64_lo, Be$3 = jt$2.sum64, Ci$1 = jt$2.sum64_hi, Ri$1 = jt$2.sum64_lo, sa$1 = jt$2.sum64_4_hi, aa$1 = jt$2.sum64_4_lo, ua$1 = jt$2.sum64_5_hi, ha$1 = jt$2.sum64_5_lo, xf$1 = fa$1.BlockHash, ca$1 = [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 ne$2() { + if (!(this instanceof ne$2)) + return new ne$2(); + xf$1.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca$1, this.W = new Array(160); +} +jt$2.inherits(ne$2, xf$1); +var Mf$1 = ne$2; +ne$2.blockSize = 1024, ne$2.outSize = 512, ne$2.hmacStrength = 192, ne$2.padLength = 128, ne$2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o2 = xa$1(i2[n4 - 4], i2[n4 - 3]), h4 = Ma$1(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya$1(i2[n4 - 30], i2[n4 - 29]), w3 = wa$1(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa$1(o2, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa$1(o2, h4, p2, b3, m3, w3, y3, S2); + } +}, ne$2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o2 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa$1(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa$1(S2, I2), W2 = ba$1(S2, I2), Rt2 = la$1(S2, I2, N2, C2, F2), Yt3 = da$1(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua$1(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha$1(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H2 = ma$1(n4, o2), z2 = ga$1(n4, o2), Pt2 = pa$1(n4, o2, h4, p2, b3), W2 = va$1(n4, o2, h4, p2, b3, m3); + var d5 = Ci$1(H2, z2, Pt2, W2), g3 = Ri$1(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci$1(w3, y3, a3, c2), I2 = Ri$1(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o2, n4 = Ci$1(a3, c2, d5, g3), o2 = Ri$1(a3, c2, d5, g3); + } + Be$3(this.h, 0, n4, o2), Be$3(this.h, 2, h4, p2), Be$3(this.h, 4, b3, m3), Be$3(this.h, 6, w3, y3), Be$3(this.h, 8, S2, I2), Be$3(this.h, 10, N2, C2), Be$3(this.h, 12, F2, U2), Be$3(this.h, 14, J2, Bt2); +}, ne$2.prototype._digest = function(t2) { + return t2 === "hex" ? jt$2.toHex32(this.h, "big") : jt$2.split32(this.h, "big"); +}; +function la$1(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ ~e2 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function da$1(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ ~t2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function pa$1(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function va$1(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function ma$1(e2, t2) { + var r3 = le$1(e2, t2, 28), i2 = le$1(t2, e2, 2), n4 = le$1(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ga$1(e2, t2) { + var r3 = de$2(e2, t2, 28), i2 = de$2(t2, e2, 2), n4 = de$2(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Aa$1(e2, t2) { + var r3 = le$1(e2, t2, 14), i2 = le$1(e2, t2, 18), n4 = le$1(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ba$1(e2, t2) { + var r3 = de$2(e2, t2, 14), i2 = de$2(e2, t2, 18), n4 = de$2(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ya$1(e2, t2) { + var r3 = le$1(e2, t2, 1), i2 = le$1(e2, t2, 8), n4 = yf$1(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function wa$1(e2, t2) { + var r3 = de$2(e2, t2, 1), i2 = de$2(e2, t2, 8), n4 = wf$1(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function xa$1(e2, t2) { + var r3 = le$1(e2, t2, 19), i2 = le$1(t2, e2, 29), n4 = yf$1(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Ma$1(e2, t2) { + var r3 = de$2(e2, t2, 19), i2 = de$2(t2, e2, 29), n4 = wf$1(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +var Oi$1 = Q$2, Ef$1 = Mf$1; +function we$1() { + if (!(this instanceof we$1)) + return new we$1(); + Ef$1.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; +} +Oi$1.inherits(we$1, Ef$1); +var Ea$1 = we$1; +we$1.blockSize = 1024, we$1.outSize = 384, we$1.hmacStrength = 192, we$1.padLength = 128, we$1.prototype._digest = function(t2) { + return t2 === "hex" ? Oi$1.toHex32(this.h.slice(0, 12), "big") : Oi$1.split32(this.h.slice(0, 12), "big"); +}, or$2.sha1 = Js$2, or$2.sha224 = na$1, or$2.sha256 = Af$1, or$2.sha384 = Ea$1, or$2.sha512 = Mf$1; +var Sf$1 = {}, Xe$3 = Q$2, Sa$1 = fr$1, Tr$2 = Xe$3.rotl32, Nf$1 = Xe$3.sum32, xr$2 = Xe$3.sum32_3, If$1 = Xe$3.sum32_4, _f$1 = Sa$1.BlockHash; +function pe$2() { + if (!(this instanceof pe$2)) + return new pe$2(); + _f$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; +} +Xe$3.inherits(pe$2, _f$1), Sf$1.ripemd160 = pe$2, pe$2.blockSize = 512, pe$2.outSize = 160, pe$2.hmacStrength = 192, pe$2.padLength = 64, pe$2.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o2 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o2, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf$1(Tr$2(If$1(i2, Bf$1(I2, n4, o2, h4), t2[_a$1[I2] + r3], Na$1(I2)), Ca$1[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr$2(o2, 10), o2 = n4, n4 = N2, N2 = Nf$1(Tr$2(If$1(b3, Bf$1(79 - I2, m3, w3, y3), t2[Ba$1[I2] + r3], Ia$1(I2)), Ra$1[I2]), S2), b3 = S2, S2 = y3, y3 = Tr$2(w3, 10), w3 = m3, m3 = N2; + } + N2 = xr$2(this.h[1], o2, y3), this.h[1] = xr$2(this.h[2], h4, S2), this.h[2] = xr$2(this.h[3], p2, b3), this.h[3] = xr$2(this.h[4], i2, m3), this.h[4] = xr$2(this.h[0], n4, w3), this.h[0] = N2; +}, pe$2.prototype._digest = function(t2) { + return t2 === "hex" ? Xe$3.toHex32(this.h, "little") : Xe$3.split32(this.h, "little"); +}; +function Bf$1(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); +} +function Na$1(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; +} +function Ia$1(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; +} +var _a$1 = [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], Ba$1 = [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], Ca$1 = [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], Ra$1 = [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], Oa$1 = Q$2, Pa$1 = yr$2; +function hr$2(e2, t2, r3) { + if (!(this instanceof hr$2)) + return new hr$2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa$1.toArray(t2, r3)); +} +var Da$1 = hr$2; +hr$2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa$1(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); +}, hr$2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; +}, hr$2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); +}, function(e2) { + var t2 = e2; + t2.utils = Q$2, t2.common = fr$1, t2.sha = or$2, t2.ripemd = Sf$1, t2.hmac = Da$1, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; +}(se$2); +function cr$2(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa$1(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; +} +function Fa$1() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var Pi$1 = Cf$1; +function Cf$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +Cf$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var fe$2 = cr$2(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); + } + return b3; + } + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; + } + r3.zero2 = n4; + function o2(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o2, r3.encode = function(p2, b3) { + return b3 === "hex" ? o2(p2) : p2; + }; +}), Jt$3 = cr$2(function(e2, t2) { + var r3 = t2; + r3.assert = Pi$1, r3.toArray = fe$2.toArray, r3.zero2 = fe$2.zero2, r3.toHex = fe$2.toHex, r3.encode = fe$2.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N2 = 0; N2 < y3.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N2] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N2 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o2(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o2; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K$2(b3, "hex", "le"); + } + r3.intFromLE = p2; +}), Ur$2 = Jt$3.getNAF, Ta$1 = Jt$3.getJSF, kr$2 = Jt$3.assert; +function Ce$1(e2, t2) { + this.type = e2, this.p = new K$2(t2.p, 16), this.red = t2.prime ? K$2.red(t2.prime) : K$2.mont(this.p), this.zero = new K$2(0).toRed(this.red), this.one = new K$2(1).toRed(this.red), this.two = new K$2(2).toRed(this.red), this.n = t2.n && new K$2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); +} +var Ze$2 = Ce$1; +Ce$1.prototype.point = function() { + throw new Error("Not implemented"); +}, Ce$1.prototype.validate = function() { + throw new Error("Not implemented"); +}, Ce$1.prototype._fixedNafMul = function(t2, r3) { + kr$2(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur$2(r3, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); +}, Ce$1.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o2 = n4.points, h4 = Ur$2(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr$2(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o2[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o2[w3 - 1 >> 1]) : p2 = p2.add(o2[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; +}, Ce$1.prototype._wnafMulAdd = function(t2, r3, i2, n4, o2) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N2 = w3 - 1, C2 = w3; + if (h4[N2] !== 1 || h4[C2] !== 1) { + b3[N2] = Ur$2(i2[N2], h4[N2], this._bitLength), b3[C2] = Ur$2(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N2].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; + } + var F2 = [r3[N2], null, null, r3[C2]]; + r3[N2].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N2].add(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())) : r3[N2].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].add(r3[C2].neg())) : (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta$1(i2[N2], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N2] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N2][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; + } + if (w3 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o2 ? H2 : H2.toP(); +}; +function Xt$3(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; +} +Ce$1.BasePoint = Xt$3, Xt$3.prototype.eq = function() { + throw new Error("Not implemented"); +}, Xt$3.prototype.validate = function() { + return this.curve.validate(this); +}, Ce$1.prototype.decodePoint = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr$2(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr$2(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); +}, Xt$3.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); +}, Xt$3.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); +}, Xt$3.prototype.encode = function(t2, r3) { + return Jt$3.encode(this._encode(r3), t2); +}, Xt$3.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; +}, Xt$3.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; +}, Xt$3.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o2 = 0; o2 < r3; o2 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; +}, Xt$3.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r3[o2] = r3[o2 - 1].add(n4); + return { wnd: t2, points: r3 }; +}, Xt$3.prototype._getBeta = function() { + return null; +}, Xt$3.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; +}; +var Di$1 = cr$2(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; +}), Ua$1 = Jt$3.assert; +function Zt$2(e2) { + Ze$2.call(this, "short", e2), this.a = new K$2(e2.a, 16).toRed(this.red), this.b = new K$2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +Di$1(Zt$2, Ze$2); +var ka$1 = Zt$2; +Zt$2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K$2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K$2(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua$1(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K$2(p2.a, 16), b: new K$2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } +}, Zt$2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K$2.mont(t2), i2 = new K$2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o2 = new K$2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o2).fromRed(), p2 = n4.redSub(o2).fromRed(); + return [h4, p2]; +}, Zt$2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o2 = new K$2(1), h4 = new K$2(0), p2 = new K$2(0), b3 = new K$2(1), m3, w3, y3, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o2, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o2, o2 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m3, N2 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y3, b: S2 }, { a: I2, b: N2 }]; +}, Zt$2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o2 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b3 = h4.mul(n4.a), m3 = o2.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; +}, Zt$2.prototype.pointFromX = function(t2, r3) { + t2 = new K$2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n4.fromRed().isOdd(); + return (r3 && !o2 || !r3 && o2) && (n4 = n4.redNeg()), this.point(t2, n4); +}, Zt$2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o2 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; +}, Zt$2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o2 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o2[h4 * 2] = p2.k1, o2[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o2, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o2[y3] = null; + return w3; +}; +function Ft$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); +} +Di$1(Ft$2, Ze$2.BasePoint), Zt$2.prototype.point = function(t2, r3, i2) { + return new Ft$2(this, t2, r3, i2); +}, Zt$2.prototype.pointFromJSON = function(t2, r3) { + return Ft$2.fromJSON(this, t2, r3); +}, Ft$2.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } +}, Ft$2.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; +}, Ft$2.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o2)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o2)) } }, n4; +}, Ft$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Ft$2.prototype.isInfinity = function() { + return this.inf; +}, Ft$2.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); +}, Ft$2.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); +}, Ft$2.prototype.getX = function() { + return this.x.fromRed(); +}, Ft$2.prototype.getY = function() { + return this.y.fromRed(); +}, Ft$2.prototype.mul = function(t2) { + return t2 = new K$2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); +}, Ft$2.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2) : this.curve._wnafMulAdd(1, n4, o2, 2); +}, Ft$2.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2, true) : this.curve._wnafMulAdd(1, n4, o2, 2, true); +}, Ft$2.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); +}, Ft$2.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o2) { + return o2.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; +}, Ft$2.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; +}; +function Tt$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K$2(0)) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), this.z = new K$2(i2, 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; +} +Di$1(Tt$2, Ze$2.BasePoint), Zt$2.prototype.jpoint = function(t2, r3, i2) { + return new Tt$2(this, t2, r3, i2); +}, Tt$2.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); +}, Tt$2.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}, Tt$2.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o2 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o2), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N2 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N2, C2); +}, Tt$2.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o2 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o2.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o2.redMul(w3)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); +}, Tt$2.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o2 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N2 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o2), b3); +}, Tt$2.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}, Tt$2.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r3 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt$2.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt$2.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o2 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o2)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N2, C2); +}, Tt$2.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h4 = o2.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o2.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N2); +}, Tt$2.prototype.mul = function(t2, r3) { + return t2 = new K$2(t2, r3), this.curve._wnafMul(this, t2); +}, Tt$2.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n4)).cmpn(0) === 0; +}, Tt$2.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o2 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } +}, Tt$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Tt$2.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var qr$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.base = Ze$2, r3.short = ka$1, r3.mont = null, r3.edwards = null; +}), Kr$1 = cr$2(function(e2, t2) { + var r3 = t2, i2 = Jt$3.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr$1.short(p2) : p2.type === "edwards" ? this.curve = new qr$1.edwards(p2) : this.curve = new qr$1.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o2(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o2("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: se$2.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se$2.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se$2.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se$2.sha384, gRed: false, 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"] }), o2("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: se$2.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se$2.sha256, gRed: false, g: ["9"] }), o2("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: se$2.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o2("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: se$2.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); +}); +function Re$2(e2) { + if (!(this instanceof Re$2)) + return new Re$2(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe$2.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe$2.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe$2.toArray(e2.pers, e2.persEnc || "hex"); + Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); +} +var Rf$1 = Re$2; +Re$2.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; +}, Re$2.prototype._hmac = function() { + return new se$2.hmac(this.hash, this.K); +}, Re$2.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); +}, Re$2.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe$2.toArray(t2, r3), i2 = fe$2.toArray(i2, n4), Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; +}, Re$2.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe$2.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h4 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe$2.encode(h4, r3); +}; +var Fi$1 = Jt$3.assert; +function kt$2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); +} +var Ti$1 = kt$2; +kt$2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { pub: r3, pubEnc: i2 }); +}, kt$2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { priv: r3, privEnc: i2 }); +}, kt$2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; +}, kt$2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; +}, kt$2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; +}, kt$2.prototype._importPrivate = function(t2, r3) { + this.priv = new K$2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); +}, kt$2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi$1(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi$1(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); +}, kt$2.prototype.derive = function(t2) { + return t2.validate() || Fi$1(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); +}, kt$2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); +}, kt$2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); +}, kt$2.prototype.inspect = function() { + return ""; +}; +var qa$1 = Jt$3.assert; +function Hr$1(e2, t2) { + if (e2 instanceof Hr$1) + return e2; + this._importDER(e2, t2) || (qa$1(e2.r && e2.s, "Signature without r or s"), this.r = new K$2(e2.r, 16), this.s = new K$2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); +} +var zr$2 = Hr$1; +function Ka$1() { + this.place = 0; +} +function Ui$1(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o2 = 0, h4 = t2.place; o2 < i2; o2++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); +} +function Of$1(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); +} +Hr$1.prototype._importDER = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = new Ka$1(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui$1(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui$1(t2, i2); + if (o2 === false) + return false; + var h4 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui$1(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K$2(h4), this.s = new K$2(b3), this.recoveryParam = null, true; +}; +function ki$1(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); +} +Hr$1.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of$1(r3), i2 = Of$1(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki$1(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki$1(n4, i2.length); + var o2 = n4.concat(i2), h4 = [48]; + return ki$1(h4, o2.length), h4 = h4.concat(o2), Jt$3.encode(h4, t2); +}; +var Ha$1 = function() { + throw new Error("unsupported"); +}, Pf$1 = Jt$3.assert; +function $t$2(e2) { + if (!(this instanceof $t$2)) + return new $t$2(e2); + typeof e2 == "string" && (Pf$1(Object.prototype.hasOwnProperty.call(Kr$1, e2), "Unknown curve " + e2), e2 = Kr$1[e2]), e2 instanceof Kr$1.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; +} +var za$1 = $t$2; +$t$2.prototype.keyPair = function(t2) { + return new Ti$1(this, t2); +}, $t$2.prototype.keyFromPrivate = function(t2, r3) { + return Ti$1.fromPrivate(this, t2, r3); +}, $t$2.prototype.keyFromPublic = function(t2, r3) { + return Ti$1.fromPublic(this, t2, r3); +}, $t$2.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf$1({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha$1(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K$2(2)); ; ) { + var o2 = new K$2(r3.generate(i2)); + if (!(o2.cmp(n4) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } +}, $t$2.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; +}, $t$2.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K$2(t2, 16)); + for (var o2 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b3 = new Rf$1({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K$2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K$2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N2.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr$2({ r: N2, s: C2, recoveryParam: F2 }); + } + } + } + } + } +}, $t$2.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K$2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr$2(r3, "hex"); + var o2 = r3.r, h4 = r3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o2).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o2)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o2) === 0); +}, $t$2.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf$1((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr$2(t2, i2); + var n4 = this.n, o2 = new K$2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o2).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); +}, $t$2.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr$2(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; + } + if (o2.eq(r3)) + return n4; + } + throw new Error("Unable to find valid recovery factor"); +}; +var La$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt$3, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr$1, r3.curves = Kr$1, r3.ec = za$1, r3.eddsa = null; +}), ja = La$1.ec; +const Qa = "signing-key/5.7.0", qi = new L$3(Qa); +let Ki = null; +function ve() { + return Ki || (Ki = new ja("secp256k1")), Ki; +} +class Ja { + constructor(t2) { + br$1(this, "curve", "secp256k1"), br$1(this, "privateKey", Kt$2(t2)), N0(this.privateKey) !== 32 && qi.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)); + br$1(this, "publicKey", "0x" + r3.getPublic(false, "hex")), br$1(this, "compressedPublicKey", "0x" + r3.getPublic(true, "hex")), br$1(this, "_isSigningKey", true); + } + _addPoint(t2) { + const r3 = ve().keyFromPublic(Ot$2(this.publicKey)), i2 = ve().keyFromPublic(Ot$2(t2)); + return "0x" + r3.pub.add(i2.pub).encodeCompressed("hex"); + } + signDigest(t2) { + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)), i2 = Ot$2(t2); + i2.length !== 32 && qi.throwArgumentError("bad digest length", "digest", t2); + const n4 = r3.sign(i2, { canonical: true }); + return zn({ recoveryParam: n4.recoveryParam, r: oe$1("0x" + n4.r.toString(16), 32), s: oe$1("0x" + n4.s.toString(16), 32) }); + } + computeSharedSecret(t2) { + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)), i2 = ve().keyFromPublic(Ot$2(Df(t2))); + return oe$1("0x" + r3.derive(i2.getPublic()).toString(16), 32); + } + static isSigningKey(t2) { + return !!(t2 && t2._isSigningKey); + } +} +function Ga(e2, t2) { + const r3 = zn(t2), i2 = { r: Ot$2(r3.r), s: Ot$2(r3.s) }; + return "0x" + ve().recoverPubKey(Ot$2(e2), i2, r3.recoveryParam).encode("hex", false); +} +function Df(e2, t2) { + const r3 = Ot$2(e2); + if (r3.length === 32) { + const i2 = new Ja(r3); + return i2.publicKey; + } else { + if (r3.length === 33) + return "0x" + ve().keyFromPublic(r3).getPublic(false, "hex"); + if (r3.length === 65) + return Kt$2(r3); + } + return qi.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} +var Ff$1; +(function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; +})(Ff$1 || (Ff$1 = {})); +function Va(e2) { + const t2 = Df(e2); + return ns$1(Hn(yi(Hn(t2, 1)), 12)); +} +function Wa(e2, t2) { + return Va(Ga(Ot$2(e2), t2)); +} +const Xa = "https://rpc.walletconnect.com/v1"; +async function Tf(e2, t2, r3, i2, n4, o2) { + switch (r3.t) { + case "eip191": + return Uf(e2, t2, r3.s); + case "eip1271": + return await kf(e2, t2, r3.s, i2, n4, o2); + default: + throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r3.t}`); + } +} +function Uf(e2, t2, r3) { + return Wa(ff(t2), r3).toLowerCase() === e2.toLowerCase(); +} +async function kf(e2, t2, r3, i2, n4, o2) { + try { + const h4 = "0x1626ba7e", p2 = "0000000000000000000000000000000000000000000000000000000000000040", b3 = "0000000000000000000000000000000000000000000000000000000000000041", m3 = r3.substring(2), w3 = ff(t2).substring(2), y3 = h4 + w3 + p2 + b3 + m3, S2 = await fetch(`${o2 || Xa}/?chainId=${i2}&projectId=${n4}`, { method: "POST", body: JSON.stringify({ id: Za(), jsonrpc: "2.0", method: "eth_call", params: [{ to: e2, data: y3 }, "latest"] }) }), { result: I2 } = await S2.json(); + return I2 ? I2.slice(0, h4.length).toLowerCase() === h4.toLowerCase() : false; + } catch (h4) { + return console.error("isValidEip1271Signature: ", h4), false; + } +} +function Za() { + return Date.now() + Math.floor(Math.random() * 1e3); +} +var $a = Object.defineProperty, tu = Object.defineProperties, eu = Object.getOwnPropertyDescriptors, qf = Object.getOwnPropertySymbols, ru = Object.prototype.hasOwnProperty, iu = Object.prototype.propertyIsEnumerable, Kf = (e2, t2, r3) => t2 in e2 ? $a(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, Hi$1 = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + ru.call(t2, r3) && Kf(e2, r3, t2[r3]); + if (qf) + for (var r3 of qf(t2)) + iu.call(t2, r3) && Kf(e2, r3, t2[r3]); + return e2; +}, Hf = (e2, t2) => tu(e2, eu(t2)); +const nu = "did:pkh:", Lr$1 = (e2) => e2 == null ? void 0 : e2.split(":"), zi = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return e2.includes(nu) ? t2[3] : t2[1]; +}, fu = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2[2] + ":" + t2[3]; +}, Li = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2.pop(); +}; +async function ou(e2) { + const { cacao: t2, projectId: r3 } = e2, { s: i2, p: n4 } = t2, o2 = zf(n4, n4.iss), h4 = Li(n4.iss); + return await Tf(h4, o2, i2, zi(n4.iss), r3); +} +const zf = (e2, t2) => { + const r3 = `${e2.domain} wants you to sign in with your Ethereum account:`, i2 = Li(t2); + if (!e2.aud && !e2.uri) + throw new Error("Either `aud` or `uri` is required to construct the message"); + let n4 = e2.statement || void 0; + const o2 = `URI: ${e2.aud || e2.uri}`, h4 = `Version: ${e2.version}`, p2 = `Chain ID: ${zi(t2)}`, b3 = `Nonce: ${e2.nonce}`, m3 = `Issued At: ${e2.iat}`, w3 = e2.resources ? `Resources:${e2.resources.map((S2) => ` +- ${S2}`).join("")}` : void 0, y3 = Qr(e2.resources); + if (y3) { + const S2 = Oe(y3); + n4 = Ji$1(n4, S2); + } + return [r3, i2, "", n4, "", o2, h4, p2, b3, m3, w3].filter((S2) => S2 != null).join(` +`); +}; +function Jf(e2) { + return Buffer.from(JSON.stringify(e2)).toString("base64"); +} +function Gf(e2) { + return JSON.parse(Buffer.from(e2, "base64").toString("utf-8")); +} +function me$1(e2) { + if (!e2) + throw new Error("No recap provided, value is undefined"); + if (!e2.att) + throw new Error("No `att` property found"); + const t2 = Object.keys(e2.att); + if (!(t2 != null && t2.length)) + throw new Error("No resources found in `att` property"); + t2.forEach((r3) => { + const i2 = e2.att[r3]; + if (Array.isArray(i2)) + throw new Error(`Resource must be an object: ${r3}`); + if (typeof i2 != "object") + throw new Error(`Resource must be an object: ${r3}`); + if (!Object.keys(i2).length) + throw new Error(`Resource object is empty: ${r3}`); + Object.keys(i2).forEach((n4) => { + const o2 = i2[n4]; + if (!Array.isArray(o2)) + throw new Error(`Ability limits ${n4} must be an array of objects, found: ${o2}`); + if (!o2.length) + throw new Error(`Value of ${n4} is empty array, must be an array with objects`); + o2.forEach((h4) => { + if (typeof h4 != "object") + throw new Error(`Ability limits (${n4}) must be an array of objects, found: ${h4}`); + }); + }); + }); +} +function Yf(e2, t2, r3, i2 = {}) { + return r3 == null ? void 0 : r3.sort((n4, o2) => n4.localeCompare(o2)), { att: { [e2]: ji(t2, r3, i2) } }; +} +function ji(e2, t2, r3 = {}) { + t2 = t2 == null ? void 0 : t2.sort((n4, o2) => n4.localeCompare(o2)); + const i2 = t2.map((n4) => ({ [`${e2}/${n4}`]: [r3] })); + return Object.assign({}, ...i2); +} +function jr(e2) { + return me$1(e2), `urn:recap:${Jf(e2).replace(/=/g, "")}`; +} +function Oe(e2) { + const t2 = Gf(e2.replace("urn:recap:", "")); + return me$1(t2), t2; +} +function cu(e2, t2, r3) { + const i2 = Yf(e2, t2, r3); + return jr(i2); +} +function Qi$1(e2) { + return e2 && e2.includes("urn:recap:"); +} +function lu(e2, t2) { + const r3 = Oe(e2), i2 = Oe(t2), n4 = Wf(r3, i2); + return jr(n4); +} +function Wf(e2, t2) { + me$1(e2), me$1(t2); + const r3 = Object.keys(e2.att).concat(Object.keys(t2.att)).sort((n4, o2) => n4.localeCompare(o2)), i2 = { att: {} }; + return r3.forEach((n4) => { + var o2, h4; + Object.keys(((o2 = e2.att) == null ? void 0 : o2[n4]) || {}).concat(Object.keys(((h4 = t2.att) == null ? void 0 : h4[n4]) || {})).sort((p2, b3) => p2.localeCompare(b3)).forEach((p2) => { + var b3, m3; + i2.att[n4] = Hf(Hi$1({}, i2.att[n4]), { [p2]: ((b3 = e2.att[n4]) == null ? void 0 : b3[p2]) || ((m3 = t2.att[n4]) == null ? void 0 : m3[p2]) }); + }); + }), i2; +} +function Ji$1(e2 = "", t2) { + me$1(t2); + const r3 = "I further authorize the stated URI to perform the following actions on my behalf: "; + if (e2.includes(r3)) + return e2; + const i2 = []; + let n4 = 0; + Object.keys(t2.att).forEach((p2) => { + const b3 = Object.keys(t2.att[p2]).map((y3) => ({ ability: y3.split("/")[0], action: y3.split("/")[1] })); + b3.sort((y3, S2) => y3.action.localeCompare(S2.action)); + const m3 = {}; + b3.forEach((y3) => { + m3[y3.ability] || (m3[y3.ability] = []), m3[y3.ability].push(y3.action); + }); + const w3 = Object.keys(m3).map((y3) => (n4++, `(${n4}) '${y3}': '${m3[y3].join("', '")}' for '${p2}'.`)); + i2.push(w3.join(", ").replace(".,", ".")); + }); + const o2 = i2.join(" "), h4 = `${r3}${o2}`; + return `${e2 ? e2 + " " : ""}${h4}`; +} +function du(e2) { + var t2; + const r3 = Oe(e2); + me$1(r3); + const i2 = (t2 = r3.att) == null ? void 0 : t2.eip155; + return i2 ? Object.keys(i2).map((n4) => n4.split("/")[1]) : []; +} +function pu(e2) { + const t2 = Oe(e2); + me$1(t2); + const r3 = []; + return Object.values(t2.att).forEach((i2) => { + Object.values(i2).forEach((n4) => { + var o2; + (o2 = n4 == null ? void 0 : n4[0]) != null && o2.chains && r3.push(n4[0].chains); + }); + }), [...new Set(r3.flat())]; +} +function Qr(e2) { + if (!e2) + return; + const t2 = e2 == null ? void 0 : e2[e2.length - 1]; + return Qi$1(t2) ? t2 : void 0; +} +const Gi = "base10", zt$1 = "base16", Jr = "base64pad", Gr = "utf8", Yi$1 = 0, lr$1 = 1, vu = 0, Zf = 1, Vi = 12, Wi$1 = 32; +function mu() { + const e2 = x25519.generateKeyPair(); + return { privateKey: toString(e2.secretKey, zt$1), publicKey: toString(e2.publicKey, zt$1) }; +} +function gu() { + const e2 = random.randomBytes(Wi$1); + return toString(e2, zt$1); +} +function Au(e2, t2) { + const r3 = x25519.sharedKey(fromString(e2, zt$1), fromString(t2, zt$1), true), i2 = new HKDF_1(sha256.SHA256, r3).expand(Wi$1); + return toString(i2, zt$1); +} +function bu(e2) { + const t2 = sha256.hash(fromString(e2, zt$1)); + return toString(t2, zt$1); +} +function yu(e2) { + const t2 = sha256.hash(fromString(e2, Gr)); + return toString(t2, zt$1); +} +function $f(e2) { + return fromString(`${e2}`, Gi); +} +function Mr(e2) { + return Number(toString(e2, Gi)); +} +function wu(e2) { + const t2 = $f(typeof e2.type < "u" ? e2.type : Yi$1); + if (Mr(t2) === lr$1 && typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + const r3 = typeof e2.senderPublicKey < "u" ? fromString(e2.senderPublicKey, zt$1) : void 0, i2 = typeof e2.iv < "u" ? fromString(e2.iv, zt$1) : random.randomBytes(Vi), n4 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)).seal(i2, fromString(e2.message, Gr)); + return to({ type: t2, sealed: n4, iv: i2, senderPublicKey: r3 }); +} +function xu(e2) { + const t2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)), { sealed: r3, iv: i2 } = Xi$1(e2.encoded), n4 = t2.open(i2, r3); + if (n4 === null) + throw new Error("Failed to decrypt"); + return toString(n4, Gr); +} +function to(e2) { + if (Mr(e2.type) === lr$1) { + if (typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + return toString(concat([e2.type, e2.senderPublicKey, e2.iv, e2.sealed]), Jr); + } + return toString(concat([e2.type, e2.iv, e2.sealed]), Jr); +} +function Xi$1(e2) { + const t2 = fromString(e2, Jr), r3 = t2.slice(vu, Zf), i2 = Zf; + if (Mr(r3) === lr$1) { + const p2 = i2 + Wi$1, b3 = p2 + Vi, m3 = t2.slice(i2, p2), w3 = t2.slice(p2, b3), y3 = t2.slice(b3); + return { type: r3, sealed: y3, iv: w3, senderPublicKey: m3 }; + } + const n4 = i2 + Vi, o2 = t2.slice(i2, n4), h4 = t2.slice(n4); + return { type: r3, sealed: h4, iv: o2 }; +} +function Mu(e2, t2) { + const r3 = Xi$1(e2); + return eo({ type: Mr(r3.type), senderPublicKey: typeof r3.senderPublicKey < "u" ? toString(r3.senderPublicKey, zt$1) : void 0, receiverPublicKey: t2 == null ? void 0 : t2.receiverPublicKey }); +} +function eo(e2) { + const t2 = (e2 == null ? void 0 : e2.type) || Yi$1; + if (t2 === lr$1) { + if (typeof (e2 == null ? void 0 : e2.senderPublicKey) > "u") + throw new Error("missing sender public key"); + if (typeof (e2 == null ? void 0 : e2.receiverPublicKey) > "u") + throw new Error("missing receiver public key"); + } + return { type: t2, senderPublicKey: e2 == null ? void 0 : e2.senderPublicKey, receiverPublicKey: e2 == null ? void 0 : e2.receiverPublicKey }; +} +function Eu(e2) { + return e2.type === lr$1 && typeof e2.senderPublicKey == "string" && typeof e2.receiverPublicKey == "string"; +} +const ro = "irn"; +function Su(e2) { + return (e2 == null ? void 0 : e2.relay) || { protocol: ro }; +} +function Nu(e2) { + const t2 = C$1[e2]; + if (typeof t2 > "u") + throw new Error(`Relay Protocol not supported: ${e2}`); + return t2; +} +var Iu = Object.defineProperty, _u = Object.defineProperties, Bu = Object.getOwnPropertyDescriptors, io = Object.getOwnPropertySymbols, Cu = Object.prototype.hasOwnProperty, Ru = Object.prototype.propertyIsEnumerable, no = (e2, t2, r3) => t2 in e2 ? Iu(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, fo = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Cu.call(t2, r3) && no(e2, r3, t2[r3]); + if (io) + for (var r3 of io(t2)) + Ru.call(t2, r3) && no(e2, r3, t2[r3]); + return e2; +}, Ou = (e2, t2) => _u(e2, Bu(t2)); +function oo(e2, t2 = "-") { + const r3 = {}, i2 = "relay" + t2; + return Object.keys(e2).forEach((n4) => { + if (n4.startsWith(i2)) { + const o2 = n4.replace(i2, ""), h4 = e2[n4]; + r3[o2] = h4; + } + }), r3; +} +function Pu(e2) { + e2 = e2.includes("wc://") ? e2.replace("wc://", "") : e2, e2 = e2.includes("wc:") ? e2.replace("wc:", "") : e2; + const t2 = e2.indexOf(":"), r3 = e2.indexOf("?") !== -1 ? e2.indexOf("?") : void 0, i2 = e2.substring(0, t2), n4 = e2.substring(t2 + 1, r3).split("@"), o2 = typeof r3 < "u" ? e2.substring(r3) : "", h4 = queryString.parse(o2), p2 = typeof h4.methods == "string" ? h4.methods.split(",") : void 0; + return { protocol: i2, topic: so(n4[0]), version: parseInt(n4[1], 10), symKey: h4.symKey, relay: oo(h4), methods: p2, expiryTimestamp: h4.expiryTimestamp ? parseInt(h4.expiryTimestamp, 10) : void 0 }; +} +function so(e2) { + return e2.startsWith("//") ? e2.substring(2) : e2; +} +function ao(e2, t2 = "-") { + const r3 = "relay", i2 = {}; + return Object.keys(e2).forEach((n4) => { + const o2 = r3 + t2 + n4; + e2[n4] && (i2[o2] = e2[n4]); + }), i2; +} +function Du(e2) { + return `${e2.protocol}:${e2.topic}@${e2.version}?` + queryString.stringify(fo(Ou(fo({ symKey: e2.symKey }, ao(e2.relay)), { expiryTimestamp: e2.expiryTimestamp }), e2.methods ? { methods: e2.methods.join(",") } : {})); +} +function $e$1(e2) { + const t2 = []; + return e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2.push(`${i2}:${n4}`); + }), t2; +} +function co(e2) { + const t2 = []; + return Object.values(e2).forEach((r3) => { + t2.push(...$e$1(r3.accounts)); + }), t2; +} +function lo(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.methods); + }), r3; +} +function po(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.events); + }), r3; +} +function mo(e2) { + const t2 = {}; + return e2 == null ? void 0 : e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2[i2] || (t2[i2] = { accounts: [], chains: [], events: [] }), t2[i2].accounts.push(r3), t2[i2].chains.push(`${i2}:${n4}`); + }), t2; +} +function ju(e2, t2) { + t2 = t2.map((i2) => i2.replace("did:pkh:", "")); + const r3 = mo(t2); + for (const [i2, n4] of Object.entries(r3)) + n4.methods ? n4.methods = ge$1(n4.methods, e2) : n4.methods = e2, n4.events = ["chainChanged", "accountsChanged"]; + return r3; +} +const go$1 = { 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 } }, Ao = { 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 xe(e2, t2) { + const { message: r3, code: i2 } = Ao[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; +} +function tr$2(e2, t2) { + const { message: r3, code: i2 } = go$1[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; +} +function Er(e2, t2) { + return Array.isArray(e2) ? true : false; +} +function Yr(e2) { + return Object.getPrototypeOf(e2) === Object.prototype && Object.keys(e2).length; +} +function Pe(e2) { + return typeof e2 > "u"; +} +function Gt$1(e2, t2) { + return t2 && Pe(e2) ? true : typeof e2 == "string" && !!e2.trim().length; +} +function Vr(e2, t2) { + return typeof e2 == "number" && !isNaN(e2); +} +function Qu(e2, t2) { + const { requiredNamespaces: r3 } = t2, i2 = Object.keys(e2.namespaces), n4 = Object.keys(r3); + let o2 = true; + return _e$1(n4, i2) ? (i2.forEach((h4) => { + const { accounts: p2, methods: b3, events: m3 } = e2.namespaces[h4], w3 = $e$1(p2), y3 = r3[h4]; + (!_e$1(_r$1(h4, y3), w3) || !_e$1(y3.methods, b3) || !_e$1(y3.events, m3)) && (o2 = false); + }), o2) : false; +} +function Sr$1(e2) { + return Gt$1(e2, false) && e2.includes(":") ? e2.split(":").length === 2 : false; +} +function bo(e2) { + if (Gt$1(e2, false) && e2.includes(":")) { + const t2 = e2.split(":"); + if (t2.length === 3) { + const r3 = t2[0] + ":" + t2[1]; + return !!t2[2] && Sr$1(r3); + } + } + return false; +} +function Ju(e2) { + if (Gt$1(e2, false)) + try { + return typeof new URL(e2) < "u"; + } catch { + return false; + } + return false; +} +function Gu(e2) { + var t2; + return (t2 = e2 == null ? void 0 : e2.proposer) == null ? void 0 : t2.publicKey; +} +function Yu(e2) { + return e2 == null ? void 0 : e2.topic; +} +function Vu(e2, t2) { + let r3 = null; + return Gt$1(e2 == null ? void 0 : e2.publicKey, false) || (r3 = xe("MISSING_OR_INVALID", `${t2} controller public key should be a string`)), r3; +} +function tn(e2) { + let t2 = true; + return Er(e2) ? e2.length && (t2 = e2.every((r3) => Gt$1(r3, false))) : t2 = false, t2; +} +function yo(e2, t2, r3) { + let i2 = null; + return Er(t2) && t2.length ? t2.forEach((n4) => { + i2 || Sr$1(n4) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, chain ${n4} should be a string and conform to "namespace:chainId" format`)); + }) : Sr$1(e2) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, 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"] }`)), i2; +} +function wo(e2, t2, r3) { + let i2 = null; + return Object.entries(e2).forEach(([n4, o2]) => { + if (i2) + return; + const h4 = yo(n4, _r$1(n4, o2), `${t2} ${r3}`); + h4 && (i2 = h4); + }), i2; +} +function xo(e2, t2) { + let r3 = null; + return Er(e2) ? e2.forEach((i2) => { + r3 || bo(i2) || (r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, account ${i2} should be a string and conform to "namespace:chainId:address" format`)); + }) : r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), r3; +} +function Mo(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = xo(i2 == null ? void 0 : i2.accounts, `${t2} namespace`); + n4 && (r3 = n4); + }), r3; +} +function Eo(e2, t2) { + let r3 = null; + return tn(e2 == null ? void 0 : e2.methods) ? tn(e2 == null ? void 0 : e2.events) || (r3 = tr$2("UNSUPPORTED_EVENTS", `${t2}, events should be an array of strings or empty array for no events`)) : r3 = tr$2("UNSUPPORTED_METHODS", `${t2}, methods should be an array of strings or empty array for no methods`), r3; +} +function en(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = Eo(i2, `${t2}, namespace`); + n4 && (r3 = n4); + }), r3; +} +function Wu(e2, t2, r3) { + let i2 = null; + if (e2 && Yr(e2)) { + const n4 = en(e2, t2); + n4 && (i2 = n4); + const o2 = wo(e2, t2, r3); + o2 && (i2 = o2); + } else + i2 = xe("MISSING_OR_INVALID", `${t2}, ${r3} should be an object with data`); + return i2; +} +function So(e2, t2) { + let r3 = null; + if (e2 && Yr(e2)) { + const i2 = en(e2, t2); + i2 && (r3 = i2); + const n4 = Mo(e2, t2); + n4 && (r3 = n4); + } else + r3 = xe("MISSING_OR_INVALID", `${t2}, namespaces should be an object with data`); + return r3; +} +function No(e2) { + return Gt$1(e2.protocol, true); +} +function Xu(e2, t2) { + let r3 = false; + return !e2 ? r3 = true : e2 && Er(e2) && e2.length && e2.forEach((i2) => { + r3 = No(i2); + }), r3; +} +function Zu(e2) { + return typeof e2 == "number"; +} +function $u(e2) { + return typeof e2 < "u" && typeof e2 !== null; +} +function th(e2) { + return !(!e2 || typeof e2 != "object" || !e2.code || !Vr(e2.code) || !e2.message || !Gt$1(e2.message, false)); +} +function eh(e2) { + return !(Pe(e2) || !Gt$1(e2.method, false)); +} +function rh(e2) { + return !(Pe(e2) || Pe(e2.result) && Pe(e2.error) || !Vr(e2.id) || !Gt$1(e2.jsonrpc, false)); +} +function ih(e2) { + return !(Pe(e2) || !Gt$1(e2.name, false)); +} +function nh(e2, t2) { + return !(!Sr$1(t2) || !co(e2).includes(t2)); +} +function fh(e2, t2, r3) { + return Gt$1(r3, false) ? lo(e2, t2).includes(r3) : false; +} +function oh(e2, t2, r3) { + return Gt$1(r3, false) ? po(e2, t2).includes(r3) : false; +} +function Io(e2, t2, r3) { + let i2 = null; + const n4 = sh(e2), o2 = ah(t2), h4 = Object.keys(n4), p2 = Object.keys(o2), b3 = _o(Object.keys(e2)), m3 = _o(Object.keys(t2)), w3 = b3.filter((y3) => !m3.includes(y3)); + return w3.length && (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces keys don't satisfy requiredNamespaces. + Required: ${w3.toString()} + Received: ${Object.keys(t2).toString()}`)), _e$1(h4, p2) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces chains don't satisfy required namespaces. + Required: ${h4.toString()} + Approved: ${p2.toString()}`)), Object.keys(t2).forEach((y3) => { + if (!y3.includes(":") || i2) + return; + const S2 = $e$1(t2[y3].accounts); + S2.includes(y3) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces accounts don't satisfy namespace accounts for ${y3} + Required: ${y3} + Approved: ${S2.toString()}`)); + }), h4.forEach((y3) => { + i2 || (_e$1(n4[y3].methods, o2[y3].methods) ? _e$1(n4[y3].events, o2[y3].events) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces events don't satisfy namespace events for ${y3}`)) : i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces methods don't satisfy namespace methods for ${y3}`)); + }), i2; +} +function sh(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + var i2; + r3.includes(":") ? t2[r3] = e2[r3] : (i2 = e2[r3].chains) == null || i2.forEach((n4) => { + t2[n4] = { methods: e2[r3].methods, events: e2[r3].events }; + }); + }), t2; +} +function _o(e2) { + return [...new Set(e2.map((t2) => t2.includes(":") ? t2.split(":")[0] : t2))]; +} +function ah(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + if (r3.includes(":")) + t2[r3] = e2[r3]; + else { + const i2 = $e$1(e2[r3].accounts); + i2 == null ? void 0 : i2.forEach((n4) => { + t2[n4] = { accounts: e2[r3].accounts.filter((o2) => o2.includes(`${n4}:`)), methods: e2[r3].methods, events: e2[r3].events }; + }); + } + }), t2; +} +function uh(e2, t2) { + return Vr(e2) && e2 <= t2.max && e2 >= t2.min; +} +function hh() { + const e2 = We$2(); + return new Promise((t2) => { + switch (e2) { + case qt$1.browser: + t2(Bo()); + break; + case qt$1.reactNative: + t2(Co()); + break; + case qt$1.node: + t2(Ro()); + break; + default: + t2(true); + } + }); +} +function Bo() { + return pr$1() && (navigator == null ? void 0 : navigator.onLine); +} +async function Co() { + if (er$1() && typeof global < "u" && global != null && global.NetInfo) { + const e2 = await (global == null ? void 0 : global.NetInfo.fetch()); + return e2 == null ? void 0 : e2.isConnected; + } + return true; +} +function Ro() { + return true; +} +function ch(e2) { + switch (We$2()) { + case qt$1.browser: + Oo(e2); + break; + case qt$1.reactNative: + Po(e2); + break; + } +} +function Oo(e2) { + !er$1() && pr$1() && (window.addEventListener("online", () => e2(true)), window.addEventListener("offline", () => e2(false))); +} +function Po(e2) { + er$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((t2) => e2(t2 == null ? void 0 : t2.isConnected))); +} +const rn = {}; +class lh { + static get(t2) { + return rn[t2]; + } + static set(t2, r3) { + rn[t2] = r3; + } + static delete(t2) { + delete rn[t2]; + } +} +const PARSE_ERROR = "PARSE_ERROR"; +const INVALID_REQUEST = "INVALID_REQUEST"; +const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; +const INVALID_PARAMS = "INVALID_PARAMS"; +const INTERNAL_ERROR = "INTERNAL_ERROR"; +const SERVER_ERROR = "SERVER_ERROR"; +const RESERVED_ERROR_CODES = [-32700, -32600, -32601, -32602, -32603]; +const STANDARD_ERROR_MAP = { + [PARSE_ERROR]: { code: -32700, message: "Parse error" }, + [INVALID_REQUEST]: { code: -32600, message: "Invalid Request" }, + [METHOD_NOT_FOUND]: { code: -32601, message: "Method not found" }, + [INVALID_PARAMS]: { code: -32602, message: "Invalid params" }, + [INTERNAL_ERROR]: { code: -32603, message: "Internal error" }, + [SERVER_ERROR]: { code: -32e3, message: "Server error" } +}; +const DEFAULT_ERROR = SERVER_ERROR; +function isReservedErrorCode(code) { + return RESERVED_ERROR_CODES.includes(code); +} +function getError(type2) { + if (!Object.keys(STANDARD_ERROR_MAP).includes(type2)) { + return STANDARD_ERROR_MAP[DEFAULT_ERROR]; + } + return STANDARD_ERROR_MAP[type2]; +} +function getErrorByCode(code) { + const match = Object.values(STANDARD_ERROR_MAP).find((e2) => e2.code === code); + if (!match) { + return STANDARD_ERROR_MAP[DEFAULT_ERROR]; + } + return match; +} +function parseConnectionError(e2, url, type2) { + return e2.message.includes("getaddrinfo ENOTFOUND") || e2.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${type2} RPC url at ${url}`) : e2; +} +var cjs = {}; +var crypto$1 = {}; +var hasRequiredCrypto; +function requireCrypto() { + if (hasRequiredCrypto) + return crypto$1; + hasRequiredCrypto = 1; + Object.defineProperty(crypto$1, "__esModule", { value: true }); + crypto$1.isBrowserCryptoAvailable = crypto$1.getSubtleCrypto = crypto$1.getBrowerCrypto = void 0; + function getBrowerCrypto() { + return (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.crypto) || (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.msCrypto) || {}; + } + crypto$1.getBrowerCrypto = getBrowerCrypto; + function getSubtleCrypto() { + const browserCrypto = getBrowerCrypto(); + return browserCrypto.subtle || browserCrypto.webkitSubtle; + } + crypto$1.getSubtleCrypto = getSubtleCrypto; + function isBrowserCryptoAvailable() { + return !!getBrowerCrypto() && !!getSubtleCrypto(); + } + crypto$1.isBrowserCryptoAvailable = isBrowserCryptoAvailable; + return crypto$1; +} +var env = {}; +var hasRequiredEnv; +function requireEnv() { + if (hasRequiredEnv) + return env; + hasRequiredEnv = 1; + Object.defineProperty(env, "__esModule", { value: true }); + env.isBrowser = env.isNode = env.isReactNative = void 0; + function isReactNative() { + return typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative"; + } + env.isReactNative = isReactNative; + function isNode() { + return typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined"; + } + env.isNode = isNode; + function isBrowser() { + return !isReactNative() && !isNode(); + } + env.isBrowser = isBrowser; + return env; +} +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + const tslib_1 = require$$0$2; + tslib_1.__exportStar(requireCrypto(), exports2); + tslib_1.__exportStar(requireEnv(), exports2); +})(cjs); +function payloadId(entropy = 3) { + const date = Date.now() * Math.pow(10, entropy); + const extra = Math.floor(Math.random() * Math.pow(10, entropy)); + return date + extra; +} +function getBigIntRpcId(entropy = 6) { + return BigInt(payloadId(entropy)); +} +function formatJsonRpcRequest(method, params, id) { + return { + id: id || payloadId(), + jsonrpc: "2.0", + method, + params + }; +} +function formatJsonRpcResult(id, result) { + return { + id, + jsonrpc: "2.0", + result + }; +} +function formatJsonRpcError(id, error, data) { + return { + id, + jsonrpc: "2.0", + error: formatErrorMessage(error) + }; +} +function formatErrorMessage(error, data) { + if (typeof error === "undefined") { + return getError(INTERNAL_ERROR); + } + if (typeof error === "string") { + error = Object.assign(Object.assign({}, getError(SERVER_ERROR)), { message: error }); + } + if (isReservedErrorCode(error.code)) { + error = getErrorByCode(error.code); + } + return error; +} +class e { +} +let n$1 = class n2 extends e { + constructor() { + super(); + } +}; +let r$1 = class r extends n$1 { + constructor(c2) { + super(); + } +}; +const WS_REGEX = "^wss?:"; +function getUrlProtocol(url) { + const matches = url.match(new RegExp(/^\w+:/, "gi")); + if (!matches || !matches.length) + return; + return matches[0]; +} +function matchRegexProtocol(url, regex) { + const protocol = getUrlProtocol(url); + if (typeof protocol === "undefined") + return false; + return new RegExp(regex).test(protocol); +} +function isWsUrl(url) { + return matchRegexProtocol(url, WS_REGEX); +} +function isLocalhostUrl(url) { + return new RegExp("wss?://localhost(:d{2,5})?").test(url); +} +function isJsonRpcPayload(payload) { + return typeof payload === "object" && "id" in payload && "jsonrpc" in payload && payload.jsonrpc === "2.0"; +} +function isJsonRpcRequest(payload) { + return isJsonRpcPayload(payload) && "method" in payload; +} +function isJsonRpcResponse(payload) { + return isJsonRpcPayload(payload) && (isJsonRpcResult(payload) || isJsonRpcError(payload)); +} +function isJsonRpcResult(payload) { + return "result" in payload; +} +function isJsonRpcError(payload) { + return "error" in payload; +} +class JsonRpcProvider extends r$1 { + constructor(connection) { + super(connection); + this.events = new eventsExports.EventEmitter(); + this.hasRegisteredEventListeners = false; + this.connection = this.setConnection(connection); + if (this.connection.connected) { + this.registerEventListeners(); + } + } + async connect(connection = this.connection) { + await this.open(connection); + } + async disconnect() { + await this.close(); + } + on(event, listener) { + this.events.on(event, listener); + } + once(event, listener) { + this.events.once(event, listener); + } + off(event, listener) { + this.events.off(event, listener); + } + removeListener(event, listener) { + this.events.removeListener(event, listener); + } + async request(request, context) { + return this.requestStrict(formatJsonRpcRequest(request.method, request.params || [], request.id || getBigIntRpcId().toString()), context); + } + async requestStrict(request, context) { + return new Promise(async (resolve, reject) => { + if (!this.connection.connected) { + try { + await this.open(); + } catch (e2) { + reject(e2); + } + } + this.events.on(`${request.id}`, (response) => { + if (isJsonRpcError(response)) { + reject(response.error); + } else { + resolve(response.result); + } + }); + try { + await this.connection.send(request, context); + } catch (e2) { + reject(e2); + } + }); + } + setConnection(connection = this.connection) { + return connection; + } + onPayload(payload) { + this.events.emit("payload", payload); + if (isJsonRpcResponse(payload)) { + this.events.emit(`${payload.id}`, payload); + } else { + this.events.emit("message", { + type: payload.method, + data: payload.params + }); + } + } + onClose(event) { + if (event && event.code === 3e3) { + this.events.emit("error", new Error(`WebSocket connection closed abnormally with code: ${event.code} ${event.reason ? `(${event.reason})` : ""}`)); + } + this.events.emit("disconnect"); + } + async open(connection = this.connection) { + if (this.connection === connection && this.connection.connected) + return; + if (this.connection.connected) + this.close(); + if (typeof connection === "string") { + await this.connection.open(connection); + connection = this.connection; + } + this.connection = this.setConnection(connection); + await this.connection.open(); + this.registerEventListeners(); + this.events.emit("connect"); + } + async close() { + await this.connection.close(); + } + registerEventListeners() { + if (this.hasRegisteredEventListeners) + return; + this.connection.on("payload", (payload) => this.onPayload(payload)); + this.connection.on("close", (event) => this.onClose(event)); + this.connection.on("error", (error) => this.events.emit("error", error)); + this.connection.on("register_error", (error) => this.onClose()); + this.hasRegisteredEventListeners = true; + } +} +const w$1 = () => 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 : (() => {try { return require("ws") } catch (e) { } })(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a2 = (c2) => c2.split("?")[0], h3 = 10, S$2 = w$1(); +let f$2 = class f { + constructor(e2) { + if (this.url = e2, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(e2)) + throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); + this.url = e2; + } + get connected() { + return typeof this.socket < "u"; + } + get connecting() { + return this.registering; + } + on(e2, t2) { + this.events.on(e2, t2); + } + once(e2, t2) { + this.events.once(e2, t2); + } + off(e2, t2) { + this.events.off(e2, t2); + } + removeListener(e2, t2) { + this.events.removeListener(e2, t2); + } + async open(e2 = this.url) { + await this.register(e2); + } + async close() { + return new Promise((e2, t2) => { + if (typeof this.socket > "u") { + t2(new Error("Connection already closed")); + return; + } + this.socket.onclose = (n4) => { + this.onClose(n4), e2(); + }, this.socket.close(); + }); + } + async send(e2) { + typeof this.socket > "u" && (this.socket = await this.register()); + try { + this.socket.send(safeJsonStringify(e2)); + } catch (t2) { + this.onError(e2.id, t2); + } + } + register(e2 = this.url) { + if (!isWsUrl(e2)) + throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); + if (this.registering) { + const t2 = this.events.getMaxListeners(); + return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n4, o2) => { + this.events.once("register_error", (s2) => { + this.resetMaxListeners(), o2(s2); + }), this.events.once("open", () => { + if (this.resetMaxListeners(), typeof this.socket > "u") + return o2(new Error("WebSocket connection is missing or invalid")); + n4(this.socket); + }); + }); + } + return this.url = e2, this.registering = true, new Promise((t2, n4) => { + const o2 = new URLSearchParams(e2).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e2) }, i2 = new S$2(e2, [], s2); + b2() ? i2.onerror = (r3) => { + const l2 = r3; + n4(this.emitError(l2.error)); + } : i2.on("error", (r3) => { + n4(this.emitError(r3)); + }), i2.onopen = () => { + this.onOpen(i2), t2(i2); + }; + }); + } + onOpen(e2) { + e2.onmessage = (t2) => this.onPayload(t2), e2.onclose = (t2) => this.onClose(t2), this.socket = e2, this.registering = false, this.events.emit("open"); + } + onClose(e2) { + this.socket = void 0, this.registering = false, this.events.emit("close", e2); + } + onPayload(e2) { + if (typeof e2.data > "u") + return; + const t2 = typeof e2.data == "string" ? safeJsonParse(e2.data) : e2.data; + this.events.emit("payload", t2); + } + onError(e2, t2) { + const n4 = this.parseError(t2), o2 = n4.message || n4.toString(), s2 = formatJsonRpcError(e2, o2); + this.events.emit("payload", s2); + } + parseError(e2, t2 = this.url) { + return parseConnectionError(e2, a2(t2), "WS"); + } + resetMaxListeners() { + this.events.getMaxListeners() > h3 && this.events.setMaxListeners(h3); + } + emitError(e2) { + const t2 = this.parseError(new Error((e2 == null ? void 0 : e2.message) || `WebSocket connection failed for host: ${a2(this.url)}`)); + return this.events.emit("register_error", t2), t2; + } +}; +var lodash_isequal = { exports: {} }; +lodash_isequal.exports; +(function(module2, exports2) { + var LARGE_ARRAY_SIZE = 200; + var HASH_UNDEFINED = "__lodash_hash_undefined__"; + var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; + var MAX_SAFE_INTEGER = 9007199254740991; + var argsTag = "[object Arguments]", arrayTag = "[object Array]", asyncTag = "[object AsyncFunction]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", nullTag = "[object Null]", objectTag = "[object Object]", promiseTag = "[object Promise]", proxyTag = "[object Proxy]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", undefinedTag = "[object Undefined]", weakMapTag = "[object WeakMap]"; + var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; + var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + var reIsHostCtor = /^\[object .+?Constructor\]$/; + var reIsUint = /^(?:0|[1-9]\d*)$/; + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; + var freeSelf = typeof self == "object" && self && self.Object === Object && self; + var root = freeGlobal || freeSelf || Function("return this")(); + var freeExports = exports2 && !exports2.nodeType && exports2; + var freeModule = freeExports && true && module2 && !module2.nodeType && module2; + var moduleExports = freeModule && freeModule.exports === freeExports; + var freeProcess = moduleExports && freeGlobal.process; + var nodeUtil = function() { + try { + return freeProcess && freeProcess.binding && freeProcess.binding("util"); + } catch (e2) { + } + }(); + var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + function arrayFilter(array, predicate) { + var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; + } + function arrayPush(array, values) { + var index = -1, length = values.length, offset = array.length; + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + function arraySome(array, predicate) { + var index = -1, length = array == null ? 0 : array.length; + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; + } + function baseTimes(n4, iteratee) { + var index = -1, result = Array(n4); + while (++index < n4) { + result[index] = iteratee(index); + } + return result; + } + function baseUnary(func) { + return function(value) { + return func(value); + }; + } + function cacheHas(cache, key) { + return cache.has(key); + } + function getValue(object, key) { + return object == null ? void 0 : object[key]; + } + function mapToArray(map) { + var index = -1, result = Array(map.size); + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; + } + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } + function setToArray(set2) { + var index = -1, result = Array(set2.size); + set2.forEach(function(value) { + result[++index] = value; + }); + return result; + } + var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype; + var coreJsData = root["__core-js_shared__"]; + var funcToString = funcProto.toString; + var hasOwnProperty = objectProto.hasOwnProperty; + var maskSrcKey = function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); + return uid ? "Symbol(src)_1." + uid : ""; + }(); + var nativeObjectToString = objectProto.toString; + var reIsNative = RegExp( + "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" + ); + var Buffer2 = moduleExports ? root.Buffer : void 0, Symbol2 = root.Symbol, Uint8Array2 = root.Uint8Array, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0; + var nativeGetSymbols = Object.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0, nativeKeys = overArg(Object.keys, Object); + var DataView2 = getNative(root, "DataView"), Map2 = getNative(root, "Map"), Promise2 = getNative(root, "Promise"), Set2 = getNative(root, "Set"), WeakMap2 = getNative(root, "WeakMap"), nativeCreate = getNative(Object, "create"); + var dataViewCtorString = toSource(DataView2), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2); + var symbolProto = Symbol2 ? Symbol2.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0; + function Hash(entries) { + var index = -1, length = entries == null ? 0 : entries.length; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; + } + function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; + } + function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? void 0 : result; + } + return hasOwnProperty.call(data, key) ? data[key] : void 0; + } + function hashHas(key) { + var data = this.__data__; + return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key); + } + function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value; + return this; + } + Hash.prototype.clear = hashClear; + Hash.prototype["delete"] = hashDelete; + Hash.prototype.get = hashGet; + Hash.prototype.has = hashHas; + Hash.prototype.set = hashSet; + function ListCache(entries) { + var index = -1, length = entries == null ? 0 : entries.length; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + function listCacheClear() { + this.__data__ = []; + this.size = 0; + } + function listCacheDelete(key) { + var data = this.__data__, index = assocIndexOf(data, key); + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; + } + function listCacheGet(key) { + var data = this.__data__, index = assocIndexOf(data, key); + return index < 0 ? void 0 : data[index][1]; + } + function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; + } + function listCacheSet(key, value) { + var data = this.__data__, index = assocIndexOf(data, key); + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; + } + ListCache.prototype.clear = listCacheClear; + ListCache.prototype["delete"] = listCacheDelete; + ListCache.prototype.get = listCacheGet; + ListCache.prototype.has = listCacheHas; + ListCache.prototype.set = listCacheSet; + function MapCache(entries) { + var index = -1, length = entries == null ? 0 : entries.length; + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + function mapCacheClear() { + this.size = 0; + this.__data__ = { + "hash": new Hash(), + "map": new (Map2 || ListCache)(), + "string": new Hash() + }; + } + function mapCacheDelete(key) { + var result = getMapData(this, key)["delete"](key); + this.size -= result ? 1 : 0; + return result; + } + function mapCacheGet(key) { + return getMapData(this, key).get(key); + } + function mapCacheHas(key) { + return getMapData(this, key).has(key); + } + function mapCacheSet(key, value) { + var data = getMapData(this, key), size = data.size; + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; + } + MapCache.prototype.clear = mapCacheClear; + MapCache.prototype["delete"] = mapCacheDelete; + MapCache.prototype.get = mapCacheGet; + MapCache.prototype.has = mapCacheHas; + MapCache.prototype.set = mapCacheSet; + function SetCache(values) { + var index = -1, length = values == null ? 0 : values.length; + this.__data__ = new MapCache(); + while (++index < length) { + this.add(values[index]); + } + } + function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; + } + function setCacheHas(value) { + return this.__data__.has(value); + } + SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; + SetCache.prototype.has = setCacheHas; + function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; + } + function stackClear() { + this.__data__ = new ListCache(); + this.size = 0; + } + function stackDelete(key) { + var data = this.__data__, result = data["delete"](key); + this.size = data.size; + return result; + } + function stackGet(key) { + return this.__data__.get(key); + } + function stackHas(key) { + return this.__data__.has(key); + } + function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; + } + Stack.prototype.clear = stackClear; + Stack.prototype["delete"] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; + function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; + for (var key in value) { + if (hasOwnProperty.call(value, key) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. + (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. + isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. + isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. + isIndex(key, length)))) { + result.push(key); + } + } + return result; + } + function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; + } + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); + } + function baseGetTag(value) { + if (value == null) { + return value === void 0 ? undefinedTag : nullTag; + } + return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); + } + function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; + } + function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); + } + function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other); + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack()); + return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__"); + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; + stack || (stack = new Stack()); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack()); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); + } + function baseIsNative(value) { + if (!isObject2(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); + } + function baseIsTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; + } + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != "constructor") { + result.push(key); + } + } + return result; + } + function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; + } + var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : void 0; + stack.set(array, other); + stack.set(other, array); + while (++index < arrLength) { + var arrValue = array[index], othValue = other[index]; + if (customizer) { + var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== void 0) { + if (compared) { + continue; + } + result = false; + break; + } + if (seen) { + if (!arraySome(other, function(othValue2, othIndex) { + if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + result = false; + break; + } + } + stack["delete"](array); + stack["delete"](other); + return result; + } + function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { + return false; + } + object = object.buffer; + other = other.buffer; + case arrayBufferTag: + if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) { + return false; + } + return true; + case boolTag: + case dateTag: + case numberTag: + return eq(+object, +other); + case errorTag: + return object.name == other.name && object.message == other.message; + case regexpTag: + case stringTag: + return object == other + ""; + case mapTag: + var convert2 = mapToArray; + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert2 || (convert2 = setToArray); + if (object.size != other.size && !isPartial) { + return false; + } + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; + stack.set(object, other); + var result = equalArrays(convert2(object), convert2(other), bitmask, customizer, equalFunc, stack); + stack["delete"](object); + return result; + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; + } + function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], othValue = other[key]; + if (customizer) { + var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); + } + if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { + result = false; + break; + } + skipCtor || (skipCtor = key == "constructor"); + } + if (result && !skipCtor) { + var objCtor = object.constructor, othCtor = other.constructor; + if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { + result = false; + } + } + stack["delete"](object); + stack["delete"](other); + return result; + } + function getAllKeys(object) { + return baseGetAllKeys(object, keys2, getSymbols); + } + function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; + } + function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : void 0; + } + function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; + try { + value[symToStringTag] = void 0; + var unmasked = true; + } catch (e2) { + } + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; + } + var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); + }; + var getTag = baseGetTag; + if (DataView2 && getTag(new DataView2(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) { + getTag = function(value) { + var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : ""; + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: + return dataViewTag; + case mapCtorString: + return mapTag; + case promiseCtorString: + return promiseTag; + case setCtorString: + return setTag; + case weakMapCtorString: + return weakMapTag; + } + } + return result; + }; + } + function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); + } + function isKeyable(value) { + var type2 = typeof value; + return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null; + } + function isMasked(func) { + return !!maskSrcKey && maskSrcKey in func; + } + function isPrototype(value) { + var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto; + return value === proto; + } + function objectToString(value) { + return nativeObjectToString.call(value); + } + function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e2) { + } + try { + return func + ""; + } catch (e2) { + } + } + return ""; + } + function eq(value, other) { + return value === other || value !== value && other !== other; + } + var isArguments = baseIsArguments(/* @__PURE__ */ function() { + return arguments; + }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); + }; + var isArray = Array.isArray; + function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); + } + var isBuffer = nativeIsBuffer || stubFalse; + function isEqual(value, other) { + return baseIsEqual(value, other); + } + function isFunction(value) { + if (!isObject2(value)) { + return false; + } + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; + } + function isLength(value) { + return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + function isObject2(value) { + var type2 = typeof value; + return value != null && (type2 == "object" || type2 == "function"); + } + function isObjectLike(value) { + return value != null && typeof value == "object"; + } + var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + function keys2(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + } + function stubArray() { + return []; + } + function stubFalse() { + return false; + } + module2.exports = isEqual; +})(lodash_isequal, lodash_isequal.exports); +var lodash_isequalExports = lodash_isequal.exports; +const Yi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); +function unfetch_module(e2, n4) { + return n4 = n4 || {}, new Promise(function(t2, r3) { + var s2 = new XMLHttpRequest(), o2 = [], u3 = [], i2 = {}, a3 = function() { + return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() { + return Promise.resolve(s2.responseText); + }, json: function() { + return Promise.resolve(s2.responseText).then(JSON.parse); + }, blob: function() { + return Promise.resolve(new Blob([s2.response])); + }, clone: a3, headers: { keys: function() { + return o2; + }, entries: function() { + return u3; + }, get: function(e3) { + return i2[e3.toLowerCase()]; + }, has: function(e3) { + return e3.toLowerCase() in i2; + } } }; + }; + for (var l2 in s2.open(n4.method || "get", e2, true), s2.onload = function() { + s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e3, n5, t3) { + o2.push(n5 = n5.toLowerCase()), u3.push([n5, t3]), i2[n5] = i2[n5] ? i2[n5] + "," + t3 : t3; + }), t2(a3()); + }, s2.onerror = r3, s2.withCredentials = "include" == n4.credentials, n4.headers) + s2.setRequestHeader(l2, n4.headers[l2]); + s2.send(n4.body || null); + }); +} +const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + default: unfetch_module +}, Symbol.toStringTag, { value: "Module" })); +const require$$0 = /* @__PURE__ */ getAugmentedNamespace(unfetch_module$1); +var browser$2 = fetch || (self.fetch = require$$0.default || require$$0); +const Hi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); +function Ji(n4, e2) { + if (n4.length >= 255) + throw new TypeError("Alphabet too long"); + for (var t2 = new Uint8Array(256), i2 = 0; i2 < t2.length; i2++) + t2[i2] = 255; + for (var s2 = 0; s2 < n4.length; s2++) { + var r3 = n4.charAt(s2), o2 = r3.charCodeAt(0); + if (t2[o2] !== 255) + throw new TypeError(r3 + " is ambiguous"); + t2[o2] = s2; + } + var a3 = n4.length, h4 = n4.charAt(0), l2 = Math.log(a3) / Math.log(256), d5 = Math.log(256) / Math.log(a3); + function g3(u3) { + if (u3 instanceof Uint8Array || (ArrayBuffer.isView(u3) ? u3 = new Uint8Array(u3.buffer, u3.byteOffset, u3.byteLength) : Array.isArray(u3) && (u3 = Uint8Array.from(u3))), !(u3 instanceof Uint8Array)) + throw new TypeError("Expected Uint8Array"); + if (u3.length === 0) + return ""; + for (var p2 = 0, _3 = 0, D2 = 0, P2 = u3.length; D2 !== P2 && u3[D2] === 0; ) + D2++, p2++; + for (var x2 = (P2 - D2) * d5 + 1 >>> 0, E2 = new Uint8Array(x2); D2 !== P2; ) { + for (var O3 = u3[D2], N2 = 0, R2 = x2 - 1; (O3 !== 0 || N2 < _3) && R2 !== -1; R2--, N2++) + O3 += 256 * E2[R2] >>> 0, E2[R2] = O3 % a3 >>> 0, O3 = O3 / a3 >>> 0; + if (O3 !== 0) + throw new Error("Non-zero carry"); + _3 = N2, D2++; + } + for (var A2 = x2 - _3; A2 !== x2 && E2[A2] === 0; ) + A2++; + for (var j2 = h4.repeat(p2); A2 < x2; ++A2) + j2 += n4.charAt(E2[A2]); + return j2; + } + function m3(u3) { + if (typeof u3 != "string") + throw new TypeError("Expected String"); + if (u3.length === 0) + return new Uint8Array(); + var p2 = 0; + if (u3[p2] !== " ") { + for (var _3 = 0, D2 = 0; u3[p2] === h4; ) + _3++, p2++; + for (var P2 = (u3.length - p2) * l2 + 1 >>> 0, x2 = new Uint8Array(P2); u3[p2]; ) { + var E2 = t2[u3.charCodeAt(p2)]; + if (E2 === 255) + return; + for (var O3 = 0, N2 = P2 - 1; (E2 !== 0 || O3 < D2) && N2 !== -1; N2--, O3++) + E2 += a3 * x2[N2] >>> 0, x2[N2] = E2 % 256 >>> 0, E2 = E2 / 256 >>> 0; + if (E2 !== 0) + throw new Error("Non-zero carry"); + D2 = O3, p2++; + } + if (u3[p2] !== " ") { + for (var R2 = P2 - D2; R2 !== P2 && x2[R2] === 0; ) + R2++; + for (var A2 = new Uint8Array(_3 + (P2 - R2)), j2 = _3; R2 !== P2; ) + A2[j2++] = x2[R2++]; + return A2; + } + } + } + function L4(u3) { + var p2 = m3(u3); + if (p2) + return p2; + throw new Error(`Non-${e2} character`); + } + return { encode: g3, decodeUnsafe: m3, decode: L4 }; +} +var Xi = Ji, Wi = Xi; +const Ue$1 = (n4) => { + if (n4 instanceof Uint8Array && n4.constructor.name === "Uint8Array") + return n4; + if (n4 instanceof ArrayBuffer) + return new Uint8Array(n4); + if (ArrayBuffer.isView(n4)) + return new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength); + throw new Error("Unknown type, must be binary type"); +}, Qi = (n4) => new TextEncoder().encode(n4), Zi = (n4) => new TextDecoder().decode(n4); +let es$1 = class es { + constructor(e2, t2, i2) { + this.name = e2, this.prefix = t2, this.baseEncode = i2; + } + encode(e2) { + if (e2 instanceof Uint8Array) + return `${this.prefix}${this.baseEncode(e2)}`; + throw Error("Unknown type, must be binary type"); + } +}; +let ts$1 = class ts { + constructor(e2, t2, i2) { + if (this.name = e2, this.prefix = t2, t2.codePointAt(0) === void 0) + throw new Error("Invalid prefix character"); + this.prefixCodePoint = t2.codePointAt(0), this.baseDecode = i2; + } + decode(e2) { + if (typeof e2 == "string") { + if (e2.codePointAt(0) !== this.prefixCodePoint) + throw Error(`Unable to decode multibase string ${JSON.stringify(e2)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); + return this.baseDecode(e2.slice(this.prefix.length)); + } else + throw Error("Can only multibase decode strings"); + } + or(e2) { + return $e(this, e2); + } +}; +let is$1 = class is { + constructor(e2) { + this.decoders = e2; + } + or(e2) { + return $e(this, e2); + } + decode(e2) { + const t2 = e2[0], i2 = this.decoders[t2]; + if (i2) + return i2.decode(e2); + throw RangeError(`Unable to decode multibase string ${JSON.stringify(e2)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + } +}; +const $e = (n4, e2) => new is$1({ ...n4.decoders || { [n4.prefix]: n4 }, ...e2.decoders || { [e2.prefix]: e2 } }); +let ss$2 = class ss { + constructor(e2, t2, i2, s2) { + this.name = e2, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new es$1(e2, t2, i2), this.decoder = new ts$1(e2, t2, s2); + } + encode(e2) { + return this.encoder.encode(e2); + } + decode(e2) { + return this.decoder.decode(e2); + } +}; +const Q$1 = ({ name: n4, prefix: e2, encode: t2, decode: i2 }) => new ss$2(n4, e2, t2, i2), K$1 = ({ prefix: n4, name: e2, alphabet: t2 }) => { + const { encode: i2, decode: s2 } = Wi(t2, e2); + return Q$1({ prefix: n4, name: e2, encode: i2, decode: (r3) => Ue$1(s2(r3)) }); +}, rs$1 = (n4, e2, t2, i2) => { + const s2 = {}; + for (let d5 = 0; d5 < e2.length; ++d5) + s2[e2[d5]] = d5; + let r3 = n4.length; + for (; n4[r3 - 1] === "="; ) + --r3; + const o2 = new Uint8Array(r3 * t2 / 8 | 0); + let a3 = 0, h4 = 0, l2 = 0; + for (let d5 = 0; d5 < r3; ++d5) { + const g3 = s2[n4[d5]]; + if (g3 === void 0) + throw new SyntaxError(`Non-${i2} character`); + h4 = h4 << t2 | g3, a3 += t2, a3 >= 8 && (a3 -= 8, o2[l2++] = 255 & h4 >> a3); + } + if (a3 >= t2 || 255 & h4 << 8 - a3) + throw new SyntaxError("Unexpected end of data"); + return o2; +}, ns = (n4, e2, t2) => { + const i2 = e2[e2.length - 1] === "=", s2 = (1 << t2) - 1; + let r3 = "", o2 = 0, a3 = 0; + for (let h4 = 0; h4 < n4.length; ++h4) + for (a3 = a3 << 8 | n4[h4], o2 += 8; o2 > t2; ) + o2 -= t2, r3 += e2[s2 & a3 >> o2]; + if (o2 && (r3 += e2[s2 & a3 << t2 - o2]), i2) + for (; r3.length * t2 & 7; ) + r3 += "="; + return r3; +}, y2 = ({ name: n4, prefix: e2, bitsPerChar: t2, alphabet: i2 }) => Q$1({ prefix: e2, name: n4, encode(s2) { + return ns(s2, i2, t2); +}, decode(s2) { + return rs$1(s2, i2, t2, n4); +} }), os$1 = Q$1({ prefix: "\0", name: "identity", encode: (n4) => Zi(n4), decode: (n4) => Qi(n4) }); +var as$1 = Object.freeze({ __proto__: null, identity: os$1 }); +const hs$1 = y2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); +var cs$1 = Object.freeze({ __proto__: null, base2: hs$1 }); +const ls$1 = y2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); +var us$1 = Object.freeze({ __proto__: null, base8: ls$1 }); +const ds$1 = K$1({ prefix: "9", name: "base10", alphabet: "0123456789" }); +var gs$1 = Object.freeze({ __proto__: null, base10: ds$1 }); +const ps$1 = y2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), Ds$1 = y2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); +var ys$1 = Object.freeze({ __proto__: null, base16: ps$1, base16upper: Ds$1 }); +const ms$2 = y2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), bs$1 = y2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), fs = y2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), Es$1 = y2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), ws$1 = y2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), vs$1 = y2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), Is$1 = y2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Cs$1 = y2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), _s$1 = y2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); +var Rs$1 = Object.freeze({ __proto__: null, base32: ms$2, base32upper: bs$1, base32pad: fs, base32padupper: Es$1, base32hex: ws$1, base32hexupper: vs$1, base32hexpad: Is$1, base32hexpadupper: Cs$1, base32z: _s$1 }); +const Ts$1 = K$1({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ss$1 = K$1({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); +var Ps$1 = Object.freeze({ __proto__: null, base36: Ts$1, base36upper: Ss$1 }); +const xs$1 = K$1({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), Os$1 = K$1({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); +var As$1 = Object.freeze({ __proto__: null, base58btc: xs$1, base58flickr: Os$1 }); +const zs$1 = y2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), Ns$1 = y2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ls$1 = y2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us$1 = y2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); +var $s$1 = Object.freeze({ __proto__: null, base64: zs$1, base64pad: Ns$1, base64url: Ls$1, base64urlpad: Us$1 }); +const Fe$1 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), Fs$1 = Fe$1.reduce((n4, e2, t2) => (n4[t2] = e2, n4), []), ks$1 = Fe$1.reduce((n4, e2, t2) => (n4[e2.codePointAt(0)] = t2, n4), []); +function Bs$1(n4) { + return n4.reduce((e2, t2) => (e2 += Fs$1[t2], e2), ""); +} +function Ms$1(n4) { + const e2 = []; + for (const t2 of n4) { + const i2 = ks$1[t2.codePointAt(0)]; + if (i2 === void 0) + throw new Error(`Non-base256emoji character: ${t2}`); + e2.push(i2); + } + return new Uint8Array(e2); +} +const Ks$1 = Q$1({ prefix: "🚀", name: "base256emoji", encode: Bs$1, decode: Ms$1 }); +var Vs$1 = Object.freeze({ __proto__: null, base256emoji: Ks$1 }), qs$1 = Be$2, ke$1 = 128, js$1 = 127, Gs$1 = ~js$1, Ys$1 = Math.pow(2, 31); +function Be$2(n4, e2, t2) { + e2 = e2 || [], t2 = t2 || 0; + for (var i2 = t2; n4 >= Ys$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 /= 128; + for (; n4 & Gs$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 >>>= 7; + return e2[t2] = n4 | 0, Be$2.bytes = t2 - i2 + 1, e2; +} +var Hs$1 = de$1, Js$1 = 128, Me = 127; +function de$1(n4, i2) { + var t2 = 0, i2 = i2 || 0, s2 = 0, r3 = i2, o2, a3 = n4.length; + do { + if (r3 >= a3) + throw de$1.bytes = 0, new RangeError("Could not decode varint"); + o2 = n4[r3++], t2 += s2 < 28 ? (o2 & Me) << s2 : (o2 & Me) * Math.pow(2, s2), s2 += 7; + } while (o2 >= Js$1); + return de$1.bytes = r3 - i2, t2; +} +var Xs$1 = Math.pow(2, 7), Ws$1 = Math.pow(2, 14), Qs$1 = Math.pow(2, 21), Zs$1 = Math.pow(2, 28), er = Math.pow(2, 35), tr$1 = Math.pow(2, 42), ir$1 = Math.pow(2, 49), sr$1 = Math.pow(2, 56), rr$1 = Math.pow(2, 63), nr$1 = function(n4) { + return n4 < Xs$1 ? 1 : n4 < Ws$1 ? 2 : n4 < Qs$1 ? 3 : n4 < Zs$1 ? 4 : n4 < er ? 5 : n4 < tr$1 ? 6 : n4 < ir$1 ? 7 : n4 < sr$1 ? 8 : n4 < rr$1 ? 9 : 10; +}, or$1 = { encode: qs$1, decode: Hs$1, encodingLength: nr$1 }, Ke$1 = or$1; +const Ve = (n4, e2, t2 = 0) => (Ke$1.encode(n4, e2, t2), e2), qe = (n4) => Ke$1.encodingLength(n4), ge = (n4, e2) => { + const t2 = e2.byteLength, i2 = qe(n4), s2 = i2 + qe(t2), r3 = new Uint8Array(s2 + t2); + return Ve(n4, r3, 0), Ve(t2, r3, i2), r3.set(e2, s2), new ar$1(n4, t2, e2, r3); +}; +let ar$1 = class ar { + constructor(e2, t2, i2, s2) { + this.code = e2, this.size = t2, this.digest = i2, this.bytes = s2; + } +}; +const je$1 = ({ name: n4, code: e2, encode: t2 }) => new hr$1(n4, e2, t2); +let hr$1 = class hr { + constructor(e2, t2, i2) { + this.name = e2, this.code = t2, this.encode = i2; + } + digest(e2) { + if (e2 instanceof Uint8Array) { + const t2 = this.encode(e2); + return t2 instanceof Uint8Array ? ge(this.code, t2) : t2.then((i2) => ge(this.code, i2)); + } else + throw Error("Unknown type, must be binary type"); + } +}; +const Ge$1 = (n4) => async (e2) => new Uint8Array(await crypto.subtle.digest(n4, e2)), cr$1 = je$1({ name: "sha2-256", code: 18, encode: Ge$1("SHA-256") }), lr = je$1({ name: "sha2-512", code: 19, encode: Ge$1("SHA-512") }); +var ur$1 = Object.freeze({ __proto__: null, sha256: cr$1, sha512: lr }); +const Ye$1 = 0, dr$1 = "identity", He$1 = Ue$1, gr$1 = (n4) => ge(Ye$1, He$1(n4)), pr = { code: Ye$1, name: dr$1, encode: He$1, digest: gr$1 }; +var Dr$1 = Object.freeze({ __proto__: null, identity: pr }); +new TextEncoder(), new TextDecoder(); +const Je$1 = { ...as$1, ...cs$1, ...us$1, ...gs$1, ...ys$1, ...Rs$1, ...Ps$1, ...As$1, ...$s$1, ...Vs$1 }; +({ ...ur$1, ...Dr$1 }); +function Xe$2(n4) { + return globalThis.Buffer != null ? new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength) : n4; +} +function yr$1(n4 = 0) { + return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? Xe$2(globalThis.Buffer.allocUnsafe(n4)) : new Uint8Array(n4); +} +function We$1(n4, e2, t2, i2) { + return { name: n4, prefix: e2, encoder: { name: n4, prefix: e2, encode: t2 }, decoder: { decode: i2 } }; +} +const Qe$1 = We$1("utf8", "u", (n4) => "u" + new TextDecoder("utf8").decode(n4), (n4) => new TextEncoder().encode(n4.substring(1))), pe$1 = We$1("ascii", "a", (n4) => { + let e2 = "a"; + for (let t2 = 0; t2 < n4.length; t2++) + e2 += String.fromCharCode(n4[t2]); + return e2; +}, (n4) => { + n4 = n4.substring(1); + const e2 = yr$1(n4.length); + for (let t2 = 0; t2 < n4.length; t2++) + e2[t2] = n4.charCodeAt(t2); + return e2; +}), mr$1 = { utf8: Qe$1, "utf-8": Qe$1, hex: Je$1.base16, latin1: pe$1, ascii: pe$1, binary: pe$1, ...Je$1 }; +function br(n4, e2 = "utf8") { + const t2 = mr$1[e2]; + if (!t2) + throw new Error(`Unsupported encoding "${e2}"`); + return (e2 === "utf8" || e2 === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? Xe$2(globalThis.Buffer.from(n4, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n4}`); +} +const De = "wc", Ze$1 = 2, Z = "core", z$1 = `${De}@2:${Z}:`, et = { name: Z, logger: "error" }, tt = { database: ":memory:" }, it = "crypto", ye$1 = "client_ed25519_seed", st = cjs$3.ONE_DAY, rt = "keychain", nt = "0.3", ot = "messages", at = "0.3", ht = cjs$3.SIX_HOURS, ct = "publisher", lt = "irn", ut = "error", me = "wss://relay.walletconnect.com", be$1 = "wss://relay.walletconnect.org", dt = "relayer", v2 = { 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" }, gt = "_subscription", f$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, pt = cjs$3.ONE_SECOND, Dt$1 = "2.12.2", yt = 1e4, mt = "0.3", bt = "WALLETCONNECT_CLIENT_ID", S$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, ft = "subscription", Et = "0.3", wt = cjs$3.FIVE_SECONDS * 1e3, vt = "pairing", It = "0.3", F$1 = { wc_pairingDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 } } }, V$1 = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, I$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, Ct = "history", _t = "0.3", Rt = "expirer", C = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Tt$1 = "0.3", ee = "verify-api", k$1 = "https://verify.walletconnect.com", te = "https://verify.walletconnect.org", St = [k$1, te], Pt = "echo", xt = "https://echo.walletconnect.com"; +let Ot$1 = class Ot { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = rt, this.version = nt, this.initialized = false, this.storagePrefix = z$1, this.init = async () => { + if (!this.initialized) { + const i2 = await this.getKeyChain(); + typeof i2 < "u" && (this.keychain = i2), this.initialized = true; + } + }, this.has = (i2) => (this.isInitialized(), this.keychain.has(i2)), this.set = async (i2, s2) => { + this.isInitialized(), this.keychain.set(i2, s2), await this.persist(); + }, this.get = (i2) => { + this.isInitialized(); + const s2 = this.keychain.get(i2); + if (typeof s2 > "u") { + const { message: r3 } = xe("NO_MATCHING_KEY", `${this.name}: ${i2}`); + throw new Error(r3); + } + return s2; + }, this.del = async (i2) => { + this.isInitialized(), this.keychain.delete(i2), await this.persist(); + }, this.core = e2, this.logger = E$1(t2, this.name); + } + get context() { + return y$2(this.logger); + } + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; + } + async setKeyChain(e2) { + await this.core.storage.setItem(this.storageKey, i0(e2)); + } + async getKeyChain() { + const e2 = await this.core.storage.getItem(this.storageKey); + return typeof e2 < "u" ? n0(e2) : void 0; + } + async persist() { + await this.setKeyChain(this.keychain); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +}; +class At { + constructor(e2, t2, i2) { + this.core = e2, this.logger = t2, this.name = it, this.initialized = false, this.init = async () => { + this.initialized || (await this.keychain.init(), this.initialized = true); + }, this.hasKeys = (s2) => (this.isInitialized(), this.keychain.has(s2)), this.getClientId = async () => { + this.isInitialized(); + const s2 = await this.getClientSeed(), r3 = generateKeyPair(s2); + return encodeIss(r3.publicKey); + }, this.generateKeyPair = () => { + this.isInitialized(); + const s2 = mu(); + return this.setPrivateKey(s2.publicKey, s2.privateKey); + }, this.signJWT = async (s2) => { + this.isInitialized(); + const r3 = await this.getClientSeed(), o2 = generateKeyPair(r3), a3 = gu(), h4 = st; + return await signJWT(a3, s2, h4, o2); + }, this.generateSharedKey = (s2, r3, o2) => { + this.isInitialized(); + const a3 = this.getPrivateKey(s2), h4 = Au(a3, r3); + return this.setSymKey(h4, o2); + }, this.setSymKey = async (s2, r3) => { + this.isInitialized(); + const o2 = r3 || bu(s2); + return await this.keychain.set(o2, s2), o2; + }, this.deleteKeyPair = async (s2) => { + this.isInitialized(), await this.keychain.del(s2); + }, this.deleteSymKey = async (s2) => { + this.isInitialized(), await this.keychain.del(s2); + }, this.encode = async (s2, r3, o2) => { + this.isInitialized(); + const a3 = eo(o2), h4 = safeJsonStringify(r3); + if (Eu(a3)) { + const m3 = a3.senderPublicKey, L4 = a3.receiverPublicKey; + s2 = await this.generateSharedKey(m3, L4); + } + const l2 = this.getSymKey(s2), { type: d5, senderPublicKey: g3 } = a3; + return wu({ type: d5, symKey: l2, message: h4, senderPublicKey: g3 }); + }, this.decode = async (s2, r3, o2) => { + this.isInitialized(); + const a3 = Mu(r3, o2); + if (Eu(a3)) { + const h4 = a3.receiverPublicKey, l2 = a3.senderPublicKey; + s2 = await this.generateSharedKey(h4, l2); + } + try { + const h4 = this.getSymKey(s2), l2 = xu({ symKey: h4, encoded: r3 }); + return safeJsonParse(l2); + } catch (h4) { + this.logger.error(`Failed to decode message from topic: '${s2}', clientId: '${await this.getClientId()}'`), this.logger.error(h4); + } + }, this.getPayloadType = (s2) => { + const r3 = Xi$1(s2); + return Mr(r3.type); + }, this.getPayloadSenderPublicKey = (s2) => { + const r3 = Xi$1(s2); + return r3.senderPublicKey ? toString(r3.senderPublicKey, zt$1) : void 0; + }, this.core = e2, this.logger = E$1(t2, this.name), this.keychain = i2 || new Ot$1(this.core, this.logger); + } + get context() { + return y$2(this.logger); + } + async setPrivateKey(e2, t2) { + return await this.keychain.set(e2, t2), e2; + } + getPrivateKey(e2) { + return this.keychain.get(e2); + } + async getClientSeed() { + let e2 = ""; + try { + e2 = this.keychain.get(ye$1); + } catch { + e2 = gu(), await this.keychain.set(ye$1, e2); + } + return br(e2, "base16"); + } + getSymKey(e2) { + return this.keychain.get(e2); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +} +class zt extends a$1 { + constructor(e2, t2) { + super(e2, t2), this.logger = e2, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = ot, this.version = at, this.initialized = false, this.storagePrefix = z$1, this.init = async () => { + if (!this.initialized) { + this.logger.trace("Initialized"); + try { + const i2 = await this.getRelayerMessages(); + typeof i2 < "u" && (this.messages = i2), this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", size: this.messages.size }); + } catch (i2) { + this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(i2); + } finally { + this.initialized = true; + } + } + }, this.set = async (i2, s2) => { + this.isInitialized(); + const r3 = yu(s2); + let o2 = this.messages.get(i2); + return typeof o2 > "u" && (o2 = {}), typeof o2[r3] < "u" || (o2[r3] = s2, this.messages.set(i2, o2), await this.persist()), r3; + }, this.get = (i2) => { + this.isInitialized(); + let s2 = this.messages.get(i2); + return typeof s2 > "u" && (s2 = {}), s2; + }, this.has = (i2, s2) => { + this.isInitialized(); + const r3 = this.get(i2), o2 = yu(s2); + return typeof r3[o2] < "u"; + }, this.del = async (i2) => { + this.isInitialized(), this.messages.delete(i2), await this.persist(); + }, this.logger = E$1(e2, this.name), this.core = t2; + } + get context() { + return y$2(this.logger); + } + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; + } + async setRelayerMessages(e2) { + await this.core.storage.setItem(this.storageKey, i0(e2)); + } + async getRelayerMessages() { + const e2 = await this.core.storage.getItem(this.storageKey); + return typeof e2 < "u" ? n0(e2) : void 0; + } + async persist() { + await this.setRelayerMessages(this.messages); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +} +class Ir extends u$1 { + constructor(e2, t2) { + super(e2, t2), this.relayer = e2, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = ct, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.failedPublishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_SECOND), this.needsTransportRestart = false, this.publish = async (i2, s2, r3) => { + var o2; + this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r3 } }); + const a3 = (r3 == null ? void 0 : r3.ttl) || ht, h4 = Su(r3), l2 = (r3 == null ? void 0 : r3.prompt) || false, d5 = (r3 == null ? void 0 : r3.tag) || 0, g3 = (r3 == null ? void 0 : r3.id) || getBigIntRpcId().toString(), m3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d5, id: g3 } }, L4 = `Failed to publish payload, please try again. id:${g3} tag:${d5}`, u3 = Date.now(); + let p2, _3 = 1; + try { + for (; p2 === void 0; ) { + if (Date.now() - u3 > this.publishTimeout) + throw new Error(L4); + this.logger.trace({ id: g3, attempts: _3 }, `publisher.publish - attempt ${_3}`), p2 = await await u0(this.rpcPublish(i2, s2, a3, h4, l2, d5, g3).catch((D2) => this.logger.warn(D2)), this.publishTimeout, L4), _3++, p2 || await new Promise((D2) => setTimeout(D2, this.failedPublishTimeout)); + } + this.relayer.events.emit(v2.publish, m3), this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { id: g3, topic: i2, message: s2, opts: r3 } }); + } catch (D2) { + if (this.logger.debug("Failed to Publish Payload"), this.logger.error(D2), (o2 = r3 == null ? void 0 : r3.internal) != null && o2.throwOnFailedPublish) + throw D2; + this.queue.set(g3, m3); + } + }, this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.registerEventListeners(); + } + get context() { + return y$2(this.logger); + } + rpcPublish(e2, t2, i2, s2, r3, o2, a3) { + var h4, l2, d5, g3; + const m3 = { method: Nu(s2.protocol).publish, params: { topic: e2, message: t2, ttl: i2, prompt: r3, tag: o2 }, id: a3 }; + return Pe((h4 = m3.params) == null ? void 0 : h4.prompt) && ((l2 = m3.params) == null || delete l2.prompt), Pe((d5 = m3.params) == null ? void 0 : d5.tag) && ((g3 = m3.params) == null || delete g3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: m3 }), this.relayer.request(m3); + } + removeRequestFromQueue(e2) { + this.queue.delete(e2); + } + checkQueue() { + this.queue.forEach(async (e2) => { + const { topic: t2, message: i2, opts: s2 } = e2; + await this.publish(t2, i2, s2); + }); + } + registerEventListeners() { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { + if (this.needsTransportRestart) { + this.needsTransportRestart = false, this.relayer.events.emit(v2.connection_stalled); + return; + } + this.checkQueue(); + }), this.relayer.on(v2.message_ack, (e2) => { + this.removeRequestFromQueue(e2.id.toString()); + }); + } +} +let Cr$1 = class Cr { + constructor() { + this.map = /* @__PURE__ */ new Map(), this.set = (e2, t2) => { + const i2 = this.get(e2); + this.exists(e2, t2) || this.map.set(e2, [...i2, t2]); + }, this.get = (e2) => this.map.get(e2) || [], this.exists = (e2, t2) => this.get(e2).includes(t2), this.delete = (e2, t2) => { + if (typeof t2 > "u") { + this.map.delete(e2); + return; + } + if (!this.map.has(e2)) + return; + const i2 = this.get(e2); + if (!this.exists(e2, t2)) + return; + const s2 = i2.filter((r3) => r3 !== t2); + if (!s2.length) { + this.map.delete(e2); + return; + } + this.map.set(e2, s2); + }, this.clear = () => { + this.map.clear(); + }; + } + get topics() { + return Array.from(this.map.keys()); + } +}; +var _r = Object.defineProperty, Rr$1 = Object.defineProperties, Tr$1 = Object.getOwnPropertyDescriptors, Nt = Object.getOwnPropertySymbols, Sr = Object.prototype.hasOwnProperty, Pr$1 = Object.prototype.propertyIsEnumerable, Lt$1 = (n4, e2, t2) => e2 in n4 ? _r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, q$2 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Sr.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + if (Nt) + for (var t2 of Nt(e2)) + Pr$1.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + return n4; +}, fe$1 = (n4, e2) => Rr$1(n4, Tr$1(e2)); +let Ut$1 = class Ut2 extends d$1 { + constructor(e2, t2) { + super(e2, t2), this.relayer = e2, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Cr$1(), this.events = new eventsExports.EventEmitter(), this.name = ft, this.version = Et, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = z$1, this.subscribeTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), this.clientId = await this.relayer.core.crypto.getClientId()); + }, this.subscribe = async (i2, s2) => { + await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }); + try { + const r3 = Su(s2), o2 = { topic: i2, relay: r3 }; + this.pending.set(i2, o2); + const a3 = await this.rpcSubscribe(i2, r3); + return typeof a3 == "string" && (this.onSubscribe(a3, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } })), a3; + } catch (r3) { + throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r3), r3; + } + }, this.unsubscribe = async (i2, s2) => { + await this.restartToComplete(), this.isInitialized(), typeof (s2 == null ? void 0 : s2.id) < "u" ? await this.unsubscribeById(i2, s2.id, s2) : await this.unsubscribeByTopic(i2, s2); + }, this.isSubscribed = async (i2) => { + if (this.topics.includes(i2)) + return true; + const s2 = `${this.pendingSubscriptionWatchLabel}_${i2}`; + return await new Promise((r3, o2) => { + const a3 = new cjs$3.Watch(); + a3.start(s2); + const h4 = setInterval(() => { + !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r3(true)), a3.elapsed(s2) >= wt && (clearInterval(h4), a3.stop(s2), o2(new Error("Subscription resolution timeout"))); + }, this.pollingInterval); + }).catch(() => false); + }, this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.start = async () => { + await this.onConnect(); + }, this.stop = async () => { + await this.onDisconnect(); + }, this.restart = async () => { + this.restartInProgress = true, await this.restore(), await this.reset(), this.restartInProgress = false; + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.clientId = ""; + } + get context() { + return y$2(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(e2, t2) { + let i2 = false; + try { + i2 = this.getSubscription(e2).topic === t2; + } catch { + } + return i2; + } + onEnable() { + this.cached = [], this.initialized = true; + } + onDisable() { + this.cached = this.values, this.subscriptions.clear(), this.topicMap.clear(); + } + async unsubscribeByTopic(e2, t2) { + const i2 = this.topicMap.get(e2); + await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e2, s2, t2))); + } + async unsubscribeById(e2, t2, i2) { + this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); + try { + const s2 = Su(i2); + await this.rpcUnsubscribe(e2, t2, s2); + const r3 = tr$2("USER_DISCONNECTED", `${this.name}, ${e2}`); + await this.onUnsubscribe(e2, t2, r3), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); + } catch (s2) { + throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s2), s2; + } + } + async rpcSubscribe(e2, t2) { + const i2 = { method: Nu(t2.protocol).subscribe, params: { topic: e2 } }; + this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); + try { + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout) ? yu(e2 + this.clientId) : null; + } catch { + this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(v2.connection_stalled); + } + return null; + } + async rpcBatchSubscribe(e2) { + if (!e2.length) + return; + const t2 = e2[0].relay, i2 = { method: Nu(t2.protocol).batchSubscribe, params: { topics: e2.map((s2) => s2.topic) } }; + this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); + try { + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout); + } catch { + this.relayer.events.emit(v2.connection_stalled); + } + } + rpcUnsubscribe(e2, t2, i2) { + const s2 = { method: Nu(i2.protocol).unsubscribe, params: { topic: e2, id: t2 } }; + return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s2 }), this.relayer.request(s2); + } + onSubscribe(e2, t2) { + this.setSubscription(e2, fe$1(q$2({}, t2), { id: e2 })), this.pending.delete(t2.topic); + } + onBatchSubscribe(e2) { + e2.length && e2.forEach((t2) => { + this.setSubscription(t2.id, q$2({}, t2)), this.pending.delete(t2.topic); + }); + } + async onUnsubscribe(e2, t2, i2) { + this.events.removeAllListeners(t2), this.hasSubscription(t2, e2) && this.deleteSubscription(t2, i2), await this.relayer.messages.del(e2); + } + async setRelayerSubscriptions(e2) { + await this.relayer.core.storage.setItem(this.storageKey, e2); + } + async getRelayerSubscriptions() { + return await this.relayer.core.storage.getItem(this.storageKey); + } + setSubscription(e2, t2) { + this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e2, subscription: t2 }), this.addSubscription(e2, t2); + } + addSubscription(e2, t2) { + this.subscriptions.set(e2, q$2({}, t2)), this.topicMap.set(t2.topic, e2), this.events.emit(S$1.created, t2); + } + getSubscription(e2) { + this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e2 }); + const t2 = this.subscriptions.get(e2); + if (!t2) { + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw new Error(i2); + } + return t2; + } + deleteSubscription(e2, t2) { + this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e2, reason: t2 }); + const i2 = this.getSubscription(e2); + this.subscriptions.delete(e2), this.topicMap.delete(i2.topic, e2), this.events.emit(S$1.deleted, fe$1(q$2({}, i2), { reason: t2 })); + } + async persist() { + await this.setRelayerSubscriptions(this.values), this.events.emit(S$1.sync); + } + async reset() { + if (this.cached.length) { + const e2 = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); + for (let t2 = 0; t2 < e2; t2++) { + const i2 = this.cached.splice(0, this.batchSubscribeTopicsLimit); + await this.batchSubscribe(i2); + } + } + this.events.emit(S$1.resubscribed); + } + async restore() { + try { + const e2 = await this.getRelayerSubscriptions(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.subscriptions.size) { + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored subscriptions for ${this.name}`), this.logger.trace({ type: "method", method: "restore", subscriptions: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore subscriptions for ${this.name}`), this.logger.error(e2); + } + } + async batchSubscribe(e2) { + if (!e2.length) + return; + const t2 = await this.rpcBatchSubscribe(e2); + Er(t2) && this.onBatchSubscribe(t2.map((i2, s2) => fe$1(q$2({}, e2[s2]), { id: i2 }))); + } + async onConnect() { + await this.restart(), this.onEnable(); + } + onDisconnect() { + this.onDisable(); + } + async checkPending() { + if (!this.initialized || !this.relayer.connected) + return; + const e2 = []; + this.pending.forEach((t2) => { + e2.push(t2); + }), await this.batchSubscribe(e2); + } + registerEventListeners() { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, async () => { + await this.checkPending(); + }), this.events.on(S$1.created, async (e2) => { + const t2 = S$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); + }), this.events.on(S$1.deleted, async (e2) => { + const t2 = S$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); + }); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } + async restartToComplete() { + this.restartInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.restartInProgress || (clearInterval(t2), e2()); + }, this.pollingInterval); + }); + } +}; +var xr$1 = Object.defineProperty, $t$1 = Object.getOwnPropertySymbols, Or$1 = Object.prototype.hasOwnProperty, Ar = Object.prototype.propertyIsEnumerable, Ft$1 = (n4, e2, t2) => e2 in n4 ? xr$1(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, zr$1 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Or$1.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + if ($t$1) + for (var t2 of $t$1(e2)) + Ar.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + return n4; +}; +let kt$1 = class kt extends g$1 { + constructor(e2) { + super(e2), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = dt, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled", "interrupted"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.heartBeatTimeout = cjs$3.toMiliseconds(cjs$3.THIRTY_SECONDS + cjs$3.ONE_SECOND), this.request = async (t2) => { + var i2, s2; + this.logger.debug("Publishing Request Payload"); + const r3 = t2.id || getBigIntRpcId().toString(); + await this.toEstablishConnection(); + try { + const o2 = this.provider.request(t2); + this.requestsInFlight.set(r3, { promise: o2, request: t2 }), this.logger.trace({ id: r3, method: t2.method, topic: (i2 = t2.params) == null ? void 0 : i2.topic }, "relayer.request - attempt to publish..."); + const a3 = await new Promise(async (h4, l2) => { + const d5 = () => { + l2(new Error(`relayer.request - publish interrupted, id: ${r3}`)); + }; + this.provider.on(f$1.disconnect, d5); + const g3 = await o2; + this.provider.off(f$1.disconnect, d5), h4(g3); + }); + return this.logger.trace({ id: r3, method: t2.method, topic: (s2 = t2.params) == null ? void 0 : s2.topic }, "relayer.request - published"), a3; + } catch (o2) { + throw this.logger.debug(`Failed to Publish Request: ${r3}`), o2; + } finally { + this.requestsInFlight.delete(r3); + } + }, this.resetPingTimeout = () => { + if (pi()) + try { + clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => { + var t2, i2, s2; + (s2 = (i2 = (t2 = this.provider) == null ? void 0 : t2.connection) == null ? void 0 : i2.socket) == null || s2.terminate(); + }, this.heartBeatTimeout); + } catch (t2) { + this.logger.warn(t2); + } + }, this.onPayloadHandler = (t2) => { + this.onProviderPayload(t2), this.resetPingTimeout(); + }, this.onConnectHandler = () => { + this.startPingTimeout(), this.events.emit(v2.connect); + }, this.onDisconnectHandler = () => { + this.onProviderDisconnect(); + }, this.onProviderErrorHandler = (t2) => { + this.logger.error(t2), this.events.emit(v2.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); + }, this.registerProviderListeners = () => { + this.provider.on(f$1.payload, this.onPayloadHandler), this.provider.on(f$1.connect, this.onConnectHandler), this.provider.on(f$1.disconnect, this.onDisconnectHandler), this.provider.on(f$1.error, this.onProviderErrorHandler); + }, this.core = e2.core, this.logger = typeof e2.logger < "u" && typeof e2.logger != "string" ? E$1(e2.logger, this.name) : nt$1(k$2({ level: e2.logger || ut })), this.messages = new zt(this.logger, e2.core), this.subscriber = new Ut$1(this, this.logger), this.publisher = new Ir(this, this.logger), this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me, this.projectId = e2.projectId, this.bundleId = Wo(), this.provider = {}; + } + async init() { + this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); + try { + await this.transportOpen(); + } catch { + this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${be$1}...`), await this.restartTransport(be$1); + } + this.initialized = true, setTimeout(async () => { + this.subscriber.topics.length === 0 && this.subscriber.pending.size === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); + }, yt); + } + get context() { + return y$2(this.logger); + } + get connected() { + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 1; + } + get connecting() { + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 0; + } + async publish(e2, t2, i2) { + this.isInitialized(), await this.publisher.publish(e2, t2, i2), await this.recordMessageEvent({ topic: e2, message: t2, publishedAt: Date.now() }); + } + async subscribe(e2, t2) { + var i2; + this.isInitialized(); + let s2 = ((i2 = this.subscriber.topicMap.get(e2)) == null ? void 0 : i2[0]) || "", r3; + const o2 = (a3) => { + a3.topic === e2 && (this.subscriber.off(S$1.created, o2), r3()); + }; + return await Promise.all([new Promise((a3) => { + r3 = a3, this.subscriber.on(S$1.created, o2); + }), new Promise(async (a3) => { + s2 = await this.subscriber.subscribe(e2, t2) || s2, a3(); + })]), s2; + } + async unsubscribe(e2, t2) { + this.isInitialized(), await this.subscriber.unsubscribe(e2, t2); + } + on(e2, t2) { + this.events.on(e2, t2); + } + once(e2, t2) { + this.events.once(e2, t2); + } + off(e2, t2) { + this.events.off(e2, t2); + } + removeListener(e2, t2) { + this.events.removeListener(e2, t2); + } + async transportDisconnect() { + if (!this.hasExperiencedNetworkDisruption && this.connected && this.requestsInFlight.size > 0) + try { + await Promise.all(Array.from(this.requestsInFlight.values()).map((e2) => e2.promise)); + } catch (e2) { + this.logger.warn(e2); + } + this.hasExperiencedNetworkDisruption || this.connected ? await u0(this.provider.disconnect(), 2e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.onProviderDisconnect(); + } + async transportClose() { + this.transportExplicitlyClosed = true, await this.transportDisconnect(); + } + async transportOpen(e2) { + await this.confirmOnlineStateOrThrow(), e2 && e2 !== this.relayUrl && (this.relayUrl = e2, await this.transportDisconnect(), await this.createProvider()), this.connectionAttemptInProgress = true, this.transportExplicitlyClosed = false; + try { + await new Promise(async (t2, i2) => { + const s2 = () => { + this.provider.off(f$1.disconnect, s2), i2(new Error("Connection interrupted while trying to subscribe")); + }; + this.provider.on(f$1.disconnect, s2), await u0(this.provider.connect(), cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), `Socket stalled when trying to connect to ${this.relayUrl}`).catch((r3) => { + i2(r3); + }), await this.subscriber.start(), this.hasExperiencedNetworkDisruption = false, t2(); + }); + } catch (t2) { + this.logger.error(t2); + const i2 = t2; + if (!this.isConnectionStalled(i2.message)) + throw t2; + } finally { + this.connectionAttemptInProgress = false; + } + } + async restartTransport(e2) { + this.connectionAttemptInProgress || (this.relayUrl = e2 || this.relayUrl, await this.confirmOnlineStateOrThrow(), await this.transportClose(), await this.createProvider(), await this.transportOpen()); + } + async confirmOnlineStateOrThrow() { + if (!await hh()) + throw new Error("No internet connection detected. Please restart your network and try again."); + } + startPingTimeout() { + var e2, t2, i2, s2, r3; + if (pi()) + try { + (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) != null && t2.socket && ((r3 = (s2 = (i2 = this.provider) == null ? void 0 : i2.connection) == null ? void 0 : s2.socket) == null || r3.once("ping", () => { + this.resetPingTimeout(); + })), this.resetPingTimeout(); + } catch (o2) { + this.logger.warn(o2); + } + } + isConnectionStalled(e2) { + return this.staleConnectionErrors.some((t2) => e2.includes(t2)); + } + async createProvider() { + this.provider.connection && this.unregisterProviderListeners(); + const e2 = await this.core.crypto.signJWT(this.relayUrl); + this.provider = new JsonRpcProvider(new f$2($o({ sdkVersion: Dt$1, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e2, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); + } + async recordMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; + await this.messages.set(t2, i2); + } + async shouldIgnoreMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; + if (!i2 || i2.length === 0) + return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; + if (!await this.subscriber.isSubscribed(t2)) + return this.logger.debug(`Ignoring message for non-subscribed topic ${t2}`), true; + const s2 = this.messages.has(t2, i2); + return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; + } + async onProviderPayload(e2) { + if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e2 }), isJsonRpcRequest(e2)) { + if (!e2.method.endsWith(gt)) + return; + const t2 = e2.params, { topic: i2, message: s2, publishedAt: r3 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r3 }; + this.logger.debug("Emitting Relayer Payload"), this.logger.trace(zr$1({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e2), await this.onMessageEvent(o2); + } else + isJsonRpcResponse(e2) && this.events.emit(v2.message_ack, e2); + } + async onMessageEvent(e2) { + await this.shouldIgnoreMessageEvent(e2) || (this.events.emit(v2.message, e2), await this.recordMessageEvent(e2)); + } + async acknowledgePayload(e2) { + const t2 = formatJsonRpcResult(e2.id, true); + await this.provider.connection.send(t2); + } + unregisterProviderListeners() { + this.provider.off(f$1.payload, this.onPayloadHandler), this.provider.off(f$1.connect, this.onConnectHandler), this.provider.off(f$1.disconnect, this.onDisconnectHandler), this.provider.off(f$1.error, this.onProviderErrorHandler); + } + async registerEventListeners() { + let e2 = await hh(); + ch(async (t2) => { + e2 !== t2 && (e2 = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportDisconnect(), this.transportExplicitlyClosed = false)); + }); + } + async onProviderDisconnect() { + await this.subscriber.stop(), this.events.emit(v2.disconnect), this.connectionAttemptInProgress = false, !this.transportExplicitlyClosed && setTimeout(async () => { + await this.transportOpen().catch((e2) => this.logger.error(e2)); + }, cjs$3.toMiliseconds(pt)); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } + async toEstablishConnection() { + await this.confirmOnlineStateOrThrow(), !this.connected && (this.connectionAttemptInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.connected && (clearInterval(t2), e2()); + }, this.connectionStatusPollingInterval); + }), await this.transportOpen()); + } +}; +var Nr = Object.defineProperty, Bt$1 = Object.getOwnPropertySymbols, Lr = Object.prototype.hasOwnProperty, Ur$1 = Object.prototype.propertyIsEnumerable, Mt = (n4, e2, t2) => e2 in n4 ? Nr(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Kt$1 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Lr.call(e2, t2) && Mt(n4, t2, e2[t2]); + if (Bt$1) + for (var t2 of Bt$1(e2)) + Ur$1.call(e2, t2) && Mt(n4, t2, e2[t2]); + return n4; +}; +class Vt extends p { + constructor(e2, t2, i2, s2 = z$1, r3 = void 0) { + super(e2, t2, i2, s2), this.core = e2, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = mt, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.recentlyDeleted = [], this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o2) => { + this.getKey && o2 !== null && !Pe(o2) ? this.map.set(this.getKey(o2), o2) : Gu(o2) ? this.map.set(o2.id, o2) : Yu(o2) && this.map.set(o2.topic, o2); + }), this.cached = [], this.initialized = true); + }, this.set = async (o2, a3) => { + this.isInitialized(), this.map.has(o2) ? await this.update(o2, a3) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o2, value: a3 }), this.map.set(o2, a3), await this.persist()); + }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a3) => Object.keys(o2).every((h4) => Yi(a3[h4], o2[h4]))) : this.values), this.update = async (o2, a3) => { + this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o2, update: a3 }); + const h4 = Kt$1(Kt$1({}, this.getData(o2)), a3); + this.map.set(o2, h4), await this.persist(); + }, this.delete = async (o2, a3) => { + this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a3 }), this.map.delete(o2), this.addToRecentlyDeleted(o2), await this.persist()); + }, this.logger = E$1(t2, this.name), this.storagePrefix = s2, this.getKey = r3; + } + get context() { + return y$2(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(e2) { + this.recentlyDeleted.push(e2), this.recentlyDeleted.length >= this.recentlyDeletedLimit && this.recentlyDeleted.splice(0, this.recentlyDeletedLimit / 2); + } + async setDataStore(e2) { + await this.core.storage.setItem(this.storageKey, e2); + } + async getDataStore() { + return await this.core.storage.getItem(this.storageKey); + } + getData(e2) { + const t2 = this.map.get(e2); + if (!t2) { + if (this.recentlyDeleted.includes(e2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e2}`); + throw this.logger.error(s2), new Error(s2); + } + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.error(i2), new Error(i2); + } + return t2; + } + async persist() { + await this.setDataStore(this.values); + } + async restore() { + try { + const e2 = await this.getDataStore(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.map.size) { + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored value for ${this.name}`), this.logger.trace({ type: "method", method: "restore", value: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore value for ${this.name}`), this.logger.error(e2); + } + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +} +class qt { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.name = vt, this.version = It, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = z$1, this.ignoredPayloadTypes = [lr$1], this.registeredMethods = [], this.init = async () => { + this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); + }, this.register = ({ methods: i2 }) => { + this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; + }, this.create = async (i2) => { + this.isInitialized(); + const s2 = gu(), r3 = await this.core.crypto.setSymKey(s2), o2 = d0(cjs$3.FIVE_MINUTES), a3 = { protocol: lt }, h4 = { topic: r3, expiry: o2, relay: a3, active: false }, l2 = Du({ protocol: this.core.protocol, version: this.core.version, topic: r3, symKey: s2, relay: a3, expiryTimestamp: o2, methods: i2 == null ? void 0 : i2.methods }); + return await this.pairings.set(r3, h4), await this.core.relayer.subscribe(r3), this.core.expirer.set(r3, o2), { topic: r3, uri: l2 }; + }, this.pair = async (i2) => { + this.isInitialized(), this.isValidPair(i2); + const { topic: s2, symKey: r3, relay: o2, expiryTimestamp: a3, methods: h4 } = Pu(i2.uri); + let l2; + if (this.pairings.keys.includes(s2) && (l2 = this.pairings.get(s2), l2.active)) + throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); + const d5 = a3 || d0(cjs$3.FIVE_MINUTES), g3 = { topic: s2, relay: o2, expiry: d5, active: false, methods: h4 }; + return await this.pairings.set(s2, g3), this.core.expirer.set(s2, d5), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V$1.create, g3), this.core.crypto.keychain.has(s2) || await this.core.crypto.setSymKey(r3, s2), await this.core.relayer.subscribe(s2, { relay: o2 }), g3; + }, this.activate = async ({ topic: i2 }) => { + this.isInitialized(); + const s2 = d0(cjs$3.THIRTY_DAYS); + await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); + }, this.ping = async (i2) => { + this.isInitialized(), await this.isValidPing(i2); + const { topic: s2 } = i2; + if (this.pairings.keys.includes(s2)) { + const r3 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a3, reject: h4 } = a0(); + this.events.once(v0("pairing_ping", r3), ({ error: l2 }) => { + l2 ? h4(l2) : a3(); + }), await o2(); + } + }, this.updateExpiry = async ({ topic: i2, expiry: s2 }) => { + this.isInitialized(), await this.pairings.update(i2, { expiry: s2 }); + }, this.updateMetadata = async ({ topic: i2, metadata: s2 }) => { + this.isInitialized(), await this.pairings.update(i2, { peerMetadata: s2 }); + }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { + this.isInitialized(), await this.isValidDisconnect(i2); + const { topic: s2 } = i2; + this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", tr$2("USER_DISCONNECTED")), await this.deletePairing(s2)); + }, this.sendRequest = async (i2, s2, r3) => { + const o2 = formatJsonRpcRequest(s2, r3), a3 = await this.core.crypto.encode(i2, o2), h4 = F$1[s2].req; + return this.core.history.set(i2, o2), this.core.relayer.publish(i2, a3, h4), o2.id; + }, this.sendResult = async (i2, s2, r3) => { + const o2 = formatJsonRpcResult(i2, r3), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = F$1[h4.request.method].res; + await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); + }, this.sendError = async (i2, s2, r3) => { + const o2 = formatJsonRpcError(i2, r3), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = F$1[h4.request.method] ? F$1[h4.request.method].res : F$1.unregistered_method.res; + await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); + }, this.deletePairing = async (i2, s2) => { + await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, tr$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); + }, this.cleanup = async () => { + const i2 = this.pairings.getAll().filter((s2) => p0(s2.expiry)); + await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); + }, this.onRelayEventRequest = (i2) => { + const { topic: s2, payload: r3 } = i2; + switch (r3.method) { + case "wc_pairingPing": + return this.onPairingPingRequest(s2, r3); + case "wc_pairingDelete": + return this.onPairingDeleteRequest(s2, r3); + default: + return this.onUnknownRpcMethodRequest(s2, r3); + } + }, this.onRelayEventResponse = async (i2) => { + const { topic: s2, payload: r3 } = i2, o2 = (await this.core.history.get(s2, r3.id)).request.method; + switch (o2) { + case "wc_pairingPing": + return this.onPairingPingResponse(s2, r3); + default: + return this.onUnknownRpcMethodResponse(o2); + } + }, this.onPairingPingRequest = async (i2, s2) => { + const { id: r3 } = s2; + try { + this.isValidPing({ topic: i2 }), await this.sendResult(r3, i2, true), this.events.emit(V$1.ping, { id: r3, topic: i2 }); + } catch (o2) { + await this.sendError(r3, i2, o2), this.logger.error(o2); + } + }, this.onPairingPingResponse = (i2, s2) => { + const { id: r3 } = s2; + setTimeout(() => { + isJsonRpcResult(s2) ? this.events.emit(v0("pairing_ping", r3), {}) : isJsonRpcError(s2) && this.events.emit(v0("pairing_ping", r3), { error: s2.error }); + }, 500); + }, this.onPairingDeleteRequest = async (i2, s2) => { + const { id: r3 } = s2; + try { + this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V$1.delete, { id: r3, topic: i2 }); + } catch (o2) { + await this.sendError(r3, i2, o2), this.logger.error(o2); + } + }, this.onUnknownRpcMethodRequest = async (i2, s2) => { + const { id: r3, method: o2 } = s2; + try { + if (this.registeredMethods.includes(o2)) + return; + const a3 = tr$2("WC_METHOD_UNSUPPORTED", o2); + await this.sendError(r3, i2, a3), this.logger.error(a3); + } catch (a3) { + await this.sendError(r3, i2, a3), this.logger.error(a3); + } + }, this.onUnknownRpcMethodResponse = (i2) => { + this.registeredMethods.includes(i2) || this.logger.error(tr$2("WC_METHOD_UNSUPPORTED", i2)); + }, this.isValidPair = (i2) => { + var s2; + if (!$u(i2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `pair() params: ${i2}`); + throw new Error(o2); + } + if (!Ju(i2.uri)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); + throw new Error(o2); + } + const r3 = Pu(i2.uri); + if (!((s2 = r3 == null ? void 0 : r3.relay) != null && s2.protocol)) { + const { message: o2 } = xe("MISSING_OR_INVALID", "pair() uri#relay-protocol"); + throw new Error(o2); + } + if (!(r3 != null && r3.symKey)) { + const { message: o2 } = xe("MISSING_OR_INVALID", "pair() uri#symKey"); + throw new Error(o2); + } + if (r3 != null && r3.expiryTimestamp && cjs$3.toMiliseconds(r3 == null ? void 0 : r3.expiryTimestamp) < Date.now()) { + const { message: o2 } = xe("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); + throw new Error(o2); + } + }, this.isValidPing = async (i2) => { + if (!$u(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `ping() params: ${i2}`); + throw new Error(r3); + } + const { topic: s2 } = i2; + await this.isValidPairingTopic(s2); + }, this.isValidDisconnect = async (i2) => { + if (!$u(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `disconnect() params: ${i2}`); + throw new Error(r3); + } + const { topic: s2 } = i2; + await this.isValidPairingTopic(s2); + }, this.isValidPairingTopic = async (i2) => { + if (!Gt$1(i2, false)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); + throw new Error(s2); + } + if (!this.pairings.keys.includes(i2)) { + const { message: s2 } = xe("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); + throw new Error(s2); + } + if (p0(this.pairings.get(i2).expiry)) { + await this.deletePairing(i2); + const { message: s2 } = xe("EXPIRED", `pairing topic: ${i2}`); + throw new Error(s2); + } + }, this.core = e2, this.logger = E$1(t2, this.name), this.pairings = new Vt(this.core, this.logger, this.name, this.storagePrefix); + } + get context() { + return y$2(this.logger); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } + registerRelayerEvents() { + this.core.relayer.on(v2.message, async (e2) => { + const { topic: t2, message: i2 } = e2; + if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) + return; + const s2 = await this.core.crypto.decode(t2, i2); + try { + isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); + } catch (r3) { + this.logger.error(r3); + } + }); + } + registerExpirerEvents() { + this.core.expirer.on(C.expired, async (e2) => { + const { topic: t2 } = l0(e2.target); + t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V$1.expire, { topic: t2 })); + }); + } +} +let jt$1 = class jt extends h$1 { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = _t, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); + }, this.set = (i2, s2, r3) => { + if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r3 }), this.records.has(s2.id)) + return; + const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r3, expiry: d0(cjs$3.THIRTY_DAYS) }; + this.records.set(o2.id, o2), this.persist(), this.events.emit(I$1.created, o2); + }, this.resolve = async (i2) => { + if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) + return; + const s2 = await this.getRecord(i2.id); + typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.persist(), this.events.emit(I$1.updated, s2)); + }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { + this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r3) => { + if (r3.topic === i2) { + if (typeof s2 < "u" && r3.id !== s2) + return; + this.records.delete(r3.id), this.events.emit(I$1.deleted, r3); + } + }), this.persist(); + }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.logger = E$1(t2, this.name); + } + get context() { + return y$2(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() { + const e2 = []; + return this.values.forEach((t2) => { + if (typeof t2.response < "u") + return; + const i2 = { topic: t2.topic, request: formatJsonRpcRequest(t2.request.method, t2.request.params, t2.id), chainId: t2.chainId }; + return e2.push(i2); + }), e2; + } + async setJsonRpcRecords(e2) { + await this.core.storage.setItem(this.storageKey, e2); + } + async getJsonRpcRecords() { + return await this.core.storage.getItem(this.storageKey); + } + getRecord(e2) { + this.isInitialized(); + const t2 = this.records.get(e2); + if (!t2) { + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw new Error(i2); + } + return t2; + } + async persist() { + await this.setJsonRpcRecords(this.values), this.events.emit(I$1.sync); + } + async restore() { + try { + const e2 = await this.getJsonRpcRecords(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.records.size) { + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", records: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(e2); + } + } + registerEventListeners() { + this.events.on(I$1.created, (e2) => { + const t2 = I$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.updated, (e2) => { + const t2 = I$1.updated; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.deleted, (e2) => { + const t2 = I$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { + this.cleanup(); + }); + } + cleanup() { + try { + this.isInitialized(); + let e2 = false; + this.records.forEach((t2) => { + cjs$3.toMiliseconds(t2.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${t2.id}`), this.records.delete(t2.id), this.events.emit(I$1.deleted, t2, false), e2 = true); + }), e2 && this.persist(); + } catch (e2) { + this.logger.warn(e2); + } + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +}; +class Gt extends E { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Rt, this.version = Tt$1, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); + }, this.has = (i2) => { + try { + const s2 = this.formatTarget(i2); + return typeof this.getExpiration(s2) < "u"; + } catch { + return false; + } + }, this.set = (i2, s2) => { + this.isInitialized(); + const r3 = this.formatTarget(i2), o2 = { target: r3, expiry: s2 }; + this.expirations.set(r3, o2), this.checkExpiry(r3, o2), this.events.emit(C.created, { target: r3, expiration: o2 }); + }, this.get = (i2) => { + this.isInitialized(); + const s2 = this.formatTarget(i2); + return this.getExpiration(s2); + }, this.del = (i2) => { + if (this.isInitialized(), this.has(i2)) { + const s2 = this.formatTarget(i2), r3 = this.getExpiration(s2); + this.expirations.delete(s2), this.events.emit(C.deleted, { target: s2, expiration: r3 }); + } + }, this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.logger = E$1(t2, this.name); + } + get context() { + return y$2(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(e2) { + if (typeof e2 == "string") + return h0(e2); + if (typeof e2 == "number") + return c0(e2); + const { message: t2 } = xe("UNKNOWN_TYPE", `Target type: ${typeof e2}`); + throw new Error(t2); + } + async setExpirations(e2) { + await this.core.storage.setItem(this.storageKey, e2); + } + async getExpirations() { + return await this.core.storage.getItem(this.storageKey); + } + async persist() { + await this.setExpirations(this.values), this.events.emit(C.sync); + } + async restore() { + try { + const e2 = await this.getExpirations(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.expirations.size) { + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored expirations for ${this.name}`), this.logger.trace({ type: "method", method: "restore", expirations: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore expirations for ${this.name}`), this.logger.error(e2); + } + } + getExpiration(e2) { + const t2 = this.expirations.get(e2); + if (!t2) { + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.warn(i2), new Error(i2); + } + return t2; + } + checkExpiry(e2, t2) { + const { expiry: i2 } = t2; + cjs$3.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e2, t2); + } + expire(e2, t2) { + this.expirations.delete(e2), this.events.emit(C.expired, { target: e2, expiration: t2 }); + } + checkExpirations() { + this.core.relayer.connected && this.expirations.forEach((e2, t2) => this.checkExpiry(t2, e2)); + } + registerEventListeners() { + this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(C.created, (e2) => { + const t2 = C.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C.expired, (e2) => { + const t2 = C.expired; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C.deleted, (e2) => { + const t2 = C.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }); + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } +} +let Yt$1 = class Yt extends y$1 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.name = ee, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { + if (this.verifyDisabled || er$1() || !pr$1()) + return; + const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); + this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; + try { + await this.createIframe(); + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3); + } + if (!this.initialized) { + this.removeIframe(), this.verifyUrl = te; + try { + await this.createIframe(); + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3), this.verifyDisabled = true; + } + } + }, this.register = async (i2) => { + this.initialized ? this.sendPost(i2.attestationId) : (this.addToQueue(i2.attestationId), await this.init()); + }, this.resolve = async (i2) => { + if (this.isDevEnv) + return ""; + const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); + let r3; + try { + r3 = await this.fetchAttestation(i2.attestationId, s2); + } catch (o2) { + this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r3 = await this.fetchAttestation(i2.attestationId, te); + } + return r3; + }, this.fetchAttestation = async (i2, s2) => { + this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); + const r3 = this.startAbortTimer(cjs$3.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); + return clearTimeout(r3), o2.status === 200 ? await o2.json() : void 0; + }, this.addToQueue = (i2) => { + this.queue.push(i2); + }, this.processQueue = () => { + this.queue.length !== 0 && (this.queue.forEach((i2) => this.sendPost(i2)), this.queue = []); + }, this.sendPost = (i2) => { + var s2; + try { + if (!this.iframe) + return; + (s2 = this.iframe.contentWindow) == null || s2.postMessage(i2, "*"), this.logger.info(`postMessage sent: ${i2} ${this.verifyUrl}`); + } catch { + } + }, this.createIframe = async () => { + let i2; + const s2 = (r3) => { + r3.data === "verify_ready" && (this.onInit(), window.removeEventListener("message", s2), i2()); + }; + await Promise.race([new Promise((r3) => { + const o2 = document.getElementById(ee); + if (o2) + return this.iframe = o2, this.onInit(), r3(); + window.addEventListener("message", s2); + const a3 = document.createElement("iframe"); + a3.id = ee, a3.src = `${this.verifyUrl}/${this.projectId}`, a3.style.display = "none", document.body.append(a3), this.iframe = a3, i2 = r3; + }), new Promise((r3, o2) => setTimeout(() => { + window.removeEventListener("message", s2), o2("verify iframe load timeout"); + }, cjs$3.toMiliseconds(cjs$3.FIVE_SECONDS)))]); + }, this.onInit = () => { + this.initialized = true, this.processQueue(); + }, this.removeIframe = () => { + this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); + }, this.getVerifyUrl = (i2) => { + let s2 = i2 || k$1; + return St.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${k$1}`), s2 = k$1), s2; + }, this.logger = E$1(t2, this.name), this.verifyUrl = k$1, this.abortController = new AbortController(), this.isDevEnv = pi() && process.env.IS_VITEST; + } + get context() { + return y$2(this.logger); + } + startAbortTimer(e2) { + return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$3.toMiliseconds(e2)); + } +}; +let Ht$2 = class Ht extends v$1 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.context = Pt, this.registerDeviceToken = async (i2) => { + const { clientId: s2, token: r3, notificationType: o2, enableEncrypted: a3 = false } = i2, h4 = `${xt}/${this.projectId}/clients`; + await Hi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r3, always_raw: a3 }) }); + }, this.logger = E$1(t2, this.context); + } +}; +var $r = Object.defineProperty, Jt$2 = Object.getOwnPropertySymbols, Fr$1 = Object.prototype.hasOwnProperty, kr$1 = Object.prototype.propertyIsEnumerable, Xt$2 = (n4, e2, t2) => e2 in n4 ? $r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Wt$2 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Fr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + if (Jt$2) + for (var t2 of Jt$2(e2)) + kr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + return n4; +}; +let ie$2 = class ie extends n$2 { + constructor(e2) { + var t2; + super(e2), this.protocol = De, this.version = Ze$1, this.name = Z, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (o2, a3) => this.events.on(o2, a3), this.once = (o2, a3) => this.events.once(o2, a3), this.off = (o2, a3) => this.events.off(o2, a3), this.removeListener = (o2, a3) => this.events.removeListener(o2, a3), this.projectId = e2 == null ? void 0 : e2.projectId, this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me, this.customStoragePrefix = e2 != null && e2.customStoragePrefix ? `:${e2.customStoragePrefix}` : ""; + const i2 = k$2({ level: typeof (e2 == null ? void 0 : e2.logger) == "string" && e2.logger ? e2.logger : et.logger }), { logger: s2, chunkLoggerController: r3 } = A$2({ opts: i2, maxSizeInBytes: e2 == null ? void 0 : e2.maxLogBlobSizeInBytes, loggerOverride: e2 == null ? void 0 : e2.logger }); + this.logChunkController = r3, (t2 = this.logChunkController) != null && t2.downloadLogsBlobInBrowser && (window.downloadLogsBlobInBrowser = async () => { + var o2, a3; + (o2 = this.logChunkController) != null && o2.downloadLogsBlobInBrowser && ((a3 = this.logChunkController) == null || a3.downloadLogsBlobInBrowser({ clientId: await this.crypto.getClientId() })); + }), this.logger = E$1(s2, this.name), this.heartbeat = new cjs$4.HeartBeat(), this.crypto = new At(this, this.logger, e2 == null ? void 0 : e2.keychain), this.history = new jt$1(this, this.logger), this.expirer = new Gt(this, this.logger), this.storage = e2 != null && e2.storage ? e2.storage : new h$2(Wt$2(Wt$2({}, tt), e2 == null ? void 0 : e2.storageOptions)), this.relayer = new kt$1({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new qt(this, this.logger), this.verify = new Yt$1(this.projectId || "", this.logger), this.echoClient = new Ht$2(this.projectId || "", this.logger); + } + static async init(e2) { + const t2 = new ie(e2); + await t2.initialize(); + const i2 = await t2.crypto.getClientId(); + return await t2.storage.setItem(bt, i2), t2; + } + get context() { + return y$2(this.logger); + } + async start() { + this.initialized || await this.initialize(); + } + async getLogsBlob() { + var e2; + return (e2 = this.logChunkController) == null ? void 0 : e2.logsToBlob({ clientId: await this.crypto.getClientId() }); + } + 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.initialized = true, this.logger.info("Core Initialization Success"); + } catch (e2) { + throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`, e2), this.logger.error(e2.message), e2; + } + } +}; +const Br = ie$2; +const Se = "wc", Ee = 2, _e = "client", se$1 = `${Se}@${Ee}:${_e}:`, ie$1 = { name: _e, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, Re$1 = "WALLETCONNECT_DEEPLINK_CHOICE", Ke = "proposal", Ue = "Proposal expired", Ge = "session", L$2 = cjs$3.SEVEN_DAYS, ke = "engine", q$1 = { wc_sessionPropose: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1114 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1115 } }, wc_sessionAuthenticate: { req: { ttl: cjs$3.ONE_HOUR, prompt: true, tag: 1116 }, res: { ttl: cjs$3.ONE_HOUR, prompt: false, tag: 1117 } } }, re$1 = { min: cjs$3.FIVE_MINUTES, max: cjs$3.SEVEN_DAYS }, A$1 = { idle: "IDLE", active: "ACTIVE" }, Fe = "request", je = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"], Qe = "wc", ze = "auth", He = "authKeys", Ye = "pairingTopics", Xe$1 = "requests", X = `${Qe}@${1.5}:${ze}:`, J = `${X}:PUB_KEY`; +var Ht$1 = Object.defineProperty, Yt2 = Object.defineProperties, Xt$1 = Object.getOwnPropertyDescriptors, Je = Object.getOwnPropertySymbols, Jt$1 = Object.prototype.hasOwnProperty, Bt = Object.prototype.propertyIsEnumerable, Be$1 = (S2, n4, t2) => n4 in S2 ? Ht$1(S2, n4, { enumerable: true, configurable: true, writable: true, value: t2 }) : S2[n4] = t2, m2 = (S2, n4) => { + for (var t2 in n4 || (n4 = {})) + Jt$1.call(n4, t2) && Be$1(S2, t2, n4[t2]); + if (Je) + for (var t2 of Je(n4)) + Bt.call(n4, t2) && Be$1(S2, t2, n4[t2]); + return S2; +}, F = (S2, n4) => Yt2(S2, Xt$1(n4)); +let Wt$1 = class Wt extends w$2 { + constructor(n4) { + super(n4), this.name = ke, this.events = new EventEmitter$1(), this.initialized = false, this.requestQueue = { state: A$1.idle, queue: [] }, this.sessionRequestQueue = { state: A$1.idle, queue: [] }, this.requestQueueDelay = cjs$3.ONE_SECOND, this.expectedPairingMethodMap = /* @__PURE__ */ new Map(), this.recentlyDeletedMap = /* @__PURE__ */ new Map(), this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(q$1) }), this.initialized = true, setTimeout(() => { + this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay))); + }, this.connect = async (t2) => { + await this.isInitialized(); + const e2 = F(m2({}, t2), { requiredNamespaces: t2.requiredNamespaces || {}, optionalNamespaces: t2.optionalNamespaces || {} }); + await this.isValidConnect(e2); + const { pairingTopic: s2, requiredNamespaces: i2, optionalNamespaces: r3, sessionProperties: o2, relays: a3 } = e2; + let c2 = s2, d5, p2 = false; + try { + c2 && (p2 = this.client.core.pairing.pairings.get(c2).active); + } catch (f3) { + throw this.client.logger.error(`connect() -> pairing.get(${c2}) failed`), f3; + } + if (!c2 || !p2) { + const { topic: f3, uri: v3 } = await this.client.core.pairing.create(); + c2 = f3, d5 = v3; + } + if (!c2) { + const { message: f3 } = xe("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); + throw new Error(f3); + } + const g3 = await this.client.core.crypto.generateKeyPair(), h4 = q$1.wc_sessionPropose.req.ttl || cjs$3.FIVE_MINUTES, y3 = d0(h4), w3 = m2({ requiredNamespaces: i2, optionalNamespaces: r3, relays: a3 ?? [{ protocol: lt }], proposer: { publicKey: g3, metadata: this.client.metadata }, expiryTimestamp: y3 }, o2 && { sessionProperties: o2 }), { reject: I2, resolve: D2, done: E2 } = a0(h4, Ue); + this.events.once(v0("session_connect"), async ({ error: f3, session: v3 }) => { + if (f3) + I2(f3); + else if (v3) { + v3.self.publicKey = g3; + const j2 = F(m2({}, v3), { requiredNamespaces: w3.requiredNamespaces, optionalNamespaces: w3.optionalNamespaces }); + await this.client.session.set(v3.topic, j2), await this.setExpiry(v3.topic, v3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: v3.peer.metadata }), D2(j2); + } + }); + const P2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: w3, throwOnFailedPublish: true }); + return await this.setProposal(P2, m2({ id: P2 }, w3)), { uri: d5, approval: E2 }; + }, this.pair = async (t2) => { + await this.isInitialized(); + try { + return await this.client.core.pairing.pair(t2); + } catch (e2) { + throw this.client.logger.error("pair() failed"), e2; + } + }, this.approve = async (t2) => { + await this.isInitialized(); + try { + await this.isValidApprove(t2); + } catch (E2) { + throw this.client.logger.error("approve() -> isValidApprove() failed"), E2; + } + const { id: e2, relayProtocol: s2, namespaces: i2, sessionProperties: r3, sessionConfig: o2 } = t2; + let a3; + try { + a3 = this.client.proposal.get(e2); + } catch (E2) { + throw this.client.logger.error(`approve() -> proposal.get(${e2}) failed`), E2; + } + let { pairingTopic: c2, proposer: d5, requiredNamespaces: p2, optionalNamespaces: g3 } = a3; + c2 = c2 || ""; + const h4 = await this.client.core.crypto.generateKeyPair(), y3 = d5.publicKey, w3 = await this.client.core.crypto.generateSharedKey(h4, y3), I2 = m2(m2({ relay: { protocol: s2 ?? "irn" }, namespaces: i2, pairingTopic: c2, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: d0(L$2) }, r3 && { sessionProperties: r3 }), o2 && { sessionConfig: o2 }); + await this.client.core.relayer.subscribe(w3); + const D2 = F(m2({}, I2), { topic: w3, requiredNamespaces: p2, optionalNamespaces: g3, pairingTopic: c2, acknowledged: false, self: I2.controller, peer: { publicKey: d5.publicKey, metadata: d5.metadata }, controller: h4 }); + await this.client.session.set(w3, D2); + try { + await this.sendResult({ id: e2, topic: c2, result: { relay: { protocol: s2 ?? "irn" }, responderPublicKey: h4 }, throwOnFailedPublish: true }), await this.sendRequest({ topic: w3, method: "wc_sessionSettle", params: I2, throwOnFailedPublish: true }); + } catch (E2) { + throw this.client.logger.error(E2), this.client.session.delete(w3, tr$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(w3), E2; + } + return await this.client.core.pairing.updateMetadata({ topic: c2, metadata: d5.metadata }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: c2 }), await this.setExpiry(w3, d0(L$2)), { topic: w3, acknowledged: () => new Promise((E2) => setTimeout(() => E2(this.client.session.get(w3)), 500)) }; + }, this.reject = async (t2) => { + await this.isInitialized(); + try { + await this.isValidReject(t2); + } catch (r3) { + throw this.client.logger.error("reject() -> isValidReject() failed"), r3; + } + const { id: e2, reason: s2 } = t2; + let i2; + try { + i2 = this.client.proposal.get(e2).pairingTopic; + } catch (r3) { + throw this.client.logger.error(`reject() -> proposal.get(${e2}) failed`), r3; + } + i2 && (await this.sendError({ id: e2, topic: i2, error: s2 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED"))); + }, this.update = async (t2) => { + await this.isInitialized(); + try { + await this.isValidUpdate(t2); + } catch (p2) { + throw this.client.logger.error("update() -> isValidUpdate() failed"), p2; + } + const { topic: e2, namespaces: s2 } = t2, { done: i2, resolve: r3, reject: o2 } = a0(), a3 = payloadId(), c2 = getBigIntRpcId().toString(), d5 = this.client.session.get(e2).namespaces; + return this.events.once(v0("session_update", a3), ({ error: p2 }) => { + p2 ? o2(p2) : r3(); + }), await this.client.session.update(e2, { namespaces: s2 }), this.sendRequest({ topic: e2, method: "wc_sessionUpdate", params: { namespaces: s2 }, throwOnFailedPublish: true, clientRpcId: a3, relayRpcId: c2 }).catch((p2) => { + this.client.logger.error(p2), this.client.session.update(e2, { namespaces: d5 }), o2(p2); + }), { acknowledged: i2 }; + }, this.extend = async (t2) => { + await this.isInitialized(); + try { + await this.isValidExtend(t2); + } catch (a3) { + throw this.client.logger.error("extend() -> isValidExtend() failed"), a3; + } + const { topic: e2 } = t2, s2 = payloadId(), { done: i2, resolve: r3, reject: o2 } = a0(); + return this.events.once(v0("session_extend", s2), ({ error: a3 }) => { + a3 ? o2(a3) : r3(); + }), await this.setExpiry(e2, d0(L$2)), this.sendRequest({ topic: e2, method: "wc_sessionExtend", params: {}, clientRpcId: s2, throwOnFailedPublish: true }).catch((a3) => { + o2(a3); + }), { acknowledged: i2 }; + }, this.request = async (t2) => { + await this.isInitialized(); + try { + await this.isValidRequest(t2); + } catch (h4) { + throw this.client.logger.error("request() -> isValidRequest() failed"), h4; + } + const { chainId: e2, request: s2, topic: i2, expiry: r3 = q$1.wc_sessionRequest.req.ttl } = t2, o2 = this.client.session.get(i2), a3 = payloadId(), c2 = getBigIntRpcId().toString(), { done: d5, resolve: p2, reject: g3 } = a0(r3, "Request expired. Please try again."); + return this.events.once(v0("session_request", a3), ({ error: h4, result: y3 }) => { + h4 ? g3(h4) : p2(y3); + }), await Promise.all([new Promise(async (h4) => { + await this.sendRequest({ clientRpcId: a3, relayRpcId: c2, topic: i2, method: "wc_sessionRequest", params: { request: F(m2({}, s2), { expiryTimestamp: d0(r3) }), chainId: e2 }, expiry: r3, throwOnFailedPublish: true }).catch((y3) => g3(y3)), this.client.events.emit("session_request_sent", { topic: i2, request: s2, chainId: e2, id: a3 }), h4(); + }), new Promise(async (h4) => { + var y3; + if (!((y3 = o2.sessionConfig) != null && y3.disableDeepLink)) { + const w3 = await g0(this.client.core.storage, Re$1); + m0({ id: a3, topic: i2, wcDeepLink: w3 }); + } + h4(); + }), d5()]).then((h4) => h4[2]); + }, this.respond = async (t2) => { + await this.isInitialized(), await this.isValidRespond(t2); + const { topic: e2, response: s2 } = t2, { id: i2 } = s2; + isJsonRpcResult(s2) ? await this.sendResult({ id: i2, topic: e2, result: s2.result, throwOnFailedPublish: true }) : isJsonRpcError(s2) && await this.sendError({ id: i2, topic: e2, error: s2.error }), this.cleanupAfterResponse(t2); + }, this.ping = async (t2) => { + await this.isInitialized(); + try { + await this.isValidPing(t2); + } catch (s2) { + throw this.client.logger.error("ping() -> isValidPing() failed"), s2; + } + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) { + const s2 = payloadId(), i2 = getBigIntRpcId().toString(), { done: r3, resolve: o2, reject: a3 } = a0(); + this.events.once(v0("session_ping", s2), ({ error: c2 }) => { + c2 ? a3(c2) : o2(); + }), await Promise.all([this.sendRequest({ topic: e2, method: "wc_sessionPing", params: {}, throwOnFailedPublish: true, clientRpcId: s2, relayRpcId: i2 }), r3()]); + } else + this.client.core.pairing.pairings.keys.includes(e2) && await this.client.core.pairing.ping({ topic: e2 }); + }, this.emit = async (t2) => { + await this.isInitialized(), await this.isValidEmit(t2); + const { topic: e2, event: s2, chainId: i2 } = t2, r3 = getBigIntRpcId().toString(); + await this.sendRequest({ topic: e2, method: "wc_sessionEvent", params: { event: s2, chainId: i2 }, throwOnFailedPublish: true, relayRpcId: r3 }); + }, this.disconnect = async (t2) => { + await this.isInitialized(), await this.isValidDisconnect(t2); + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) + await this.sendRequest({ topic: e2, method: "wc_sessionDelete", params: tr$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: e2, emitEvent: false }); + else if (this.client.core.pairing.pairings.keys.includes(e2)) + await this.client.core.pairing.disconnect({ topic: e2 }); + else { + const { message: s2 } = xe("MISMATCHED_TOPIC", `Session or pairing topic not found: ${e2}`); + throw new Error(s2); + } + }, this.find = (t2) => (this.isInitialized(), this.client.session.getAll().filter((e2) => Qu(e2, t2))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (t2) => { + this.isInitialized(), this.isValidAuthenticate(t2); + const { chains: e2, statement: s2 = "", uri: i2, domain: r3, nonce: o2, type: a3, exp: c2, nbf: d5, methods: p2 = [] } = t2, g3 = [...t2.resources || []], { topic: h4, uri: y3 } = await this.client.core.pairing.create({ methods: ["wc_sessionAuthenticate"] }); + this.client.logger.info({ message: "Generated new pairing", pairing: { topic: h4, uri: y3 } }); + const w3 = await this.client.core.crypto.generateKeyPair(), I2 = bu(w3); + if (await Promise.all([this.client.auth.authKeys.set(J, { responseTopic: I2, publicKey: w3 }), this.client.auth.pairingTopics.set(I2, { topic: I2, pairingTopic: h4 })]), await this.client.core.relayer.subscribe(I2), this.client.logger.info(`sending request to new pairing topic: ${h4}`), p2.length > 0) { + const { namespace: O3 } = dn(e2[0]); + let _3 = cu(O3, "request", p2); + Qr(g3) && (_3 = lu(_3, g3.pop())), g3.push(_3); + } + const D2 = d0(q$1.wc_sessionPropose.req.ttl), E2 = { authPayload: { type: a3 ?? "caip122", chains: e2, statement: s2, aud: i2, domain: r3, version: "1", nonce: o2, iat: (/* @__PURE__ */ new Date()).toISOString(), exp: c2, nbf: d5, resources: g3 }, requester: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, P2 = { eip155: { chains: e2, methods: [.../* @__PURE__ */ new Set(["personal_sign", ...p2])], events: ["chainChanged", "accountsChanged"] } }, f3 = { requiredNamespaces: {}, optionalNamespaces: P2, relays: [{ protocol: "irn" }], proposer: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, { done: v3, resolve: j2, reject: oe2 } = a0(q$1.wc_sessionAuthenticate.req.ttl, "Request expired"), B2 = async ({ error: O3, session: _3 }) => { + if (this.events.off(v0("session_request", M2), ae2), O3) + oe2(O3); + else if (_3) { + _3.self.publicKey = w3, await this.client.session.set(_3.topic, _3), await this.setExpiry(_3.topic, _3.expiry), h4 && await this.client.core.pairing.updateMetadata({ topic: h4, metadata: _3.peer.metadata }); + const Q2 = this.client.session.get(_3.topic); + j2({ session: Q2 }); + } + }, ae2 = async (O3) => { + if (O3.error) { + const z2 = tr$2("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate"); + return O3.error.code === z2.code ? void 0 : (this.events.off(v0("session_connect"), B2), oe2(O3.error.message)); + } + this.events.off(v0("session_connect"), B2); + const { cacaos: _3, responder: Q2 } = O3.result, le2 = [], Ie = []; + for (const z2 of _3) { + await ou({ cacao: z2, projectId: this.client.core.projectId }) || (this.client.logger.error(z2, "Signature verification failed"), oe2(tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"))); + const { p: he2 } = z2, pe2 = Qr(he2.resources), fe2 = [fu(he2.iss)], Ze2 = Li(he2.iss); + if (pe2) { + const de2 = du(pe2), et2 = pu(pe2); + le2.push(...de2), fe2.push(...et2); + } + for (const de2 of fe2) + Ie.push(`${de2}:${Ze2}`); + } + const W2 = await this.client.core.crypto.generateSharedKey(w3, Q2.publicKey); + let Z2; + le2.length > 0 && (Z2 = { topic: W2, acknowledged: true, self: { publicKey: w3, metadata: this.client.metadata }, peer: Q2, controller: Q2.publicKey, expiry: d0(L$2), requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: h4, namespaces: ju([...new Set(le2)], [...new Set(Ie)]) }, await this.client.core.relayer.subscribe(W2), await this.client.session.set(W2, Z2), Z2 = this.client.session.get(W2)), j2({ auths: _3, session: Z2 }); + }, M2 = payloadId(), ce2 = payloadId(); + this.events.once(v0("session_connect"), B2), this.events.once(v0("session_request", M2), ae2); + try { + await Promise.all([this.sendRequest({ topic: h4, method: "wc_sessionAuthenticate", params: E2, expiry: t2.expiry, throwOnFailedPublish: true, clientRpcId: M2 }), this.sendRequest({ topic: h4, method: "wc_sessionPropose", params: f3, expiry: q$1.wc_sessionPropose.req.ttl, throwOnFailedPublish: true, clientRpcId: ce2 })]); + } catch (O3) { + throw this.events.off(v0("session_connect"), B2), this.events.off(v0("session_request", M2), ae2), O3; + } + return await this.setProposal(ce2, m2({ id: ce2 }, f3)), await this.client.auth.requests.set(M2, { authPayload: E2.authPayload, requester: E2.requester, expiryTimestamp: D2, id: M2, pairingTopic: h4, verifyContext: {} }), { uri: y3, response: v3 }; + }, this.approveSessionAuthenticate = async (t2) => { + this.isInitialized(); + const { id: e2, auths: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o2 }, d5 = [], p2 = []; + for (const y3 of s2) { + if (!await ou({ cacao: y3, projectId: this.client.core.projectId })) { + const P2 = tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"); + throw await this.sendError({ id: e2, topic: a3, error: P2, encodeOpts: c2 }), new Error(P2.message); + } + const { p: w3 } = y3, I2 = Qr(w3.resources), D2 = [fu(w3.iss)], E2 = Li(w3.iss); + if (I2) { + const P2 = du(I2), f3 = pu(I2); + d5.push(...P2), D2.push(...f3); + } + for (const P2 of D2) + p2.push(`${P2}:${E2}`); + } + const g3 = await this.client.core.crypto.generateSharedKey(o2, r3); + let h4; + return (d5 == null ? void 0 : d5.length) > 0 && (h4 = { topic: g3, acknowledged: true, self: { publicKey: o2, metadata: this.client.metadata }, peer: { publicKey: r3, metadata: i2.requester.metadata }, controller: r3, expiry: d0(L$2), authentication: s2, requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: "", namespaces: ju([...new Set(d5)], [...new Set(p2)]) }, await this.client.core.relayer.subscribe(g3), await this.client.session.set(g3, h4)), await this.sendResult({ topic: a3, id: e2, result: { cacaos: s2, responder: { publicKey: o2, metadata: this.client.metadata } }, encodeOpts: c2, throwOnFailedPublish: true }), await this.client.auth.requests.delete(e2, { message: "fullfilled", code: 0 }), await this.client.core.pairing.activate({ topic: i2.pairingTopic }), { session: h4 }; + }, this.rejectSessionAuthenticate = async (t2) => { + await this.isInitialized(); + const { id: e2, reason: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o2 }; + await this.sendError({ id: e2, topic: a3, error: s2, encodeOpts: c2 }), await this.client.auth.requests.delete(e2, { message: "rejected", code: 0 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")); + }, this.formatAuthMessage = (t2) => { + this.isInitialized(); + const { request: e2, iss: s2 } = t2; + return zf(e2, s2); + }, this.cleanupDuplicatePairings = async (t2) => { + if (t2.pairingTopic) + try { + const e2 = this.client.core.pairing.pairings.get(t2.pairingTopic), s2 = this.client.core.pairing.pairings.getAll().filter((i2) => { + var r3, o2; + return ((r3 = i2.peerMetadata) == null ? void 0 : r3.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === t2.peer.metadata.url && i2.topic && i2.topic !== e2.topic; + }); + if (s2.length === 0) + return; + this.client.logger.info(`Cleaning up ${s2.length} duplicate pairing(s)`), await Promise.all(s2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.deleteSession = async (t2) => { + const { topic: e2, expirerHasDeleted: s2 = false, emitEvent: i2 = true, id: r3 = 0 } = t2, { self: o2 } = this.client.session.get(e2); + await this.client.core.relayer.unsubscribe(e2), await this.client.session.delete(e2, tr$2("USER_DISCONNECTED")), this.addToRecentlyDeleted(e2, "session"), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(e2) && await this.client.core.crypto.deleteSymKey(e2), s2 || this.client.core.expirer.del(e2), this.client.core.storage.removeItem(Re$1).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { + a3.topic === e2 && this.deletePendingSessionRequest(a3.id, tr$2("USER_DISCONNECTED")); + }), i2 && this.client.events.emit("session_delete", { id: r3, topic: e2 }); + }, this.deleteProposal = async (t2, e2) => { + await Promise.all([this.client.proposal.delete(t2, tr$2("USER_DISCONNECTED")), e2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "proposal"); + }, this.deletePendingSessionRequest = async (t2, e2, s2 = false) => { + await Promise.all([this.client.pendingRequest.delete(t2, e2), s2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== t2), s2 && (this.sessionRequestQueue.state = A$1.idle, this.client.events.emit("session_request_expire", { id: t2 })); + }, this.setExpiry = async (t2, e2) => { + this.client.session.keys.includes(t2) && await this.client.session.update(t2, { expiry: e2 }), this.client.core.expirer.set(t2, e2); + }, this.setProposal = async (t2, e2) => { + await this.client.proposal.set(t2, e2), this.client.core.expirer.set(t2, d0(q$1.wc_sessionPropose.req.ttl)); + }, this.setPendingSessionRequest = async (t2) => { + const { id: e2, topic: s2, params: i2, verifyContext: r3 } = t2, o2 = i2.request.expiryTimestamp || d0(q$1.wc_sessionRequest.req.ttl); + await this.client.pendingRequest.set(e2, { id: e2, topic: s2, params: i2, verifyContext: r3 }), o2 && this.client.core.expirer.set(e2, o2); + }, this.sendRequest = async (t2) => { + const { topic: e2, method: s2, params: i2, expiry: r3, relayRpcId: o2, clientRpcId: a3, throwOnFailedPublish: c2 } = t2, d5 = formatJsonRpcRequest(s2, i2, a3); + if (pr$1() && je.includes(s2)) { + const h4 = yu(JSON.stringify(d5)); + this.client.core.verify.register({ attestationId: h4 }); + } + let p2; + try { + p2 = await this.client.core.crypto.encode(e2, d5); + } catch (h4) { + throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e2} failed`), h4; + } + const g3 = q$1[s2].req; + return r3 && (g3.ttl = r3), o2 && (g3.id = o2), this.client.core.history.set(e2, d5), c2 ? (g3.internal = F(m2({}, g3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(e2, p2, g3)) : this.client.core.relayer.publish(e2, p2, g3).catch((h4) => this.client.logger.error(h4)), d5.id; + }, this.sendResult = async (t2) => { + const { id: e2, topic: s2, result: i2, throwOnFailedPublish: r3, encodeOpts: o2 } = t2, a3 = formatJsonRpcResult(e2, i2); + let c2; + try { + c2 = await this.client.core.crypto.encode(s2, a3, o2); + } catch (g3) { + throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s2} failed`), g3; + } + let d5; + try { + d5 = await this.client.core.history.get(s2, e2); + } catch (g3) { + throw this.client.logger.error(`sendResult() -> history.get(${s2}, ${e2}) failed`), g3; + } + const p2 = q$1[d5.request.method].res; + r3 ? (p2.internal = F(m2({}, p2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, c2, p2)) : this.client.core.relayer.publish(s2, c2, p2).catch((g3) => this.client.logger.error(g3)), await this.client.core.history.resolve(a3); + }, this.sendError = async (t2) => { + const { id: e2, topic: s2, error: i2, encodeOpts: r3 } = t2, o2 = formatJsonRpcError(e2, i2); + let a3; + try { + a3 = await this.client.core.crypto.encode(s2, o2, r3); + } catch (p2) { + throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s2} failed`), p2; + } + let c2; + try { + c2 = await this.client.core.history.get(s2, e2); + } catch (p2) { + throw this.client.logger.error(`sendError() -> history.get(${s2}, ${e2}) failed`), p2; + } + const d5 = q$1[c2.request.method].res; + this.client.core.relayer.publish(s2, a3, d5), await this.client.core.history.resolve(o2); + }, this.cleanup = async () => { + const t2 = [], e2 = []; + this.client.session.getAll().forEach((s2) => { + let i2 = false; + p0(s2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(s2.topic) || (i2 = true), i2 && t2.push(s2.topic); + }), this.client.proposal.getAll().forEach((s2) => { + p0(s2.expiryTimestamp) && e2.push(s2.id); + }), await Promise.all([...t2.map((s2) => this.deleteSession({ topic: s2 })), ...e2.map((s2) => this.deleteProposal(s2))]); + }, this.onRelayEventRequest = async (t2) => { + this.requestQueue.queue.push(t2), await this.processRequestsQueue(); + }, this.processRequestsQueue = async () => { + if (this.requestQueue.state === A$1.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 = A$1.active; + const t2 = this.requestQueue.queue.shift(); + if (t2) + try { + this.processRequest(t2), await new Promise((e2) => setTimeout(e2, 300)); + } catch (e2) { + this.client.logger.warn(e2); + } + } + this.requestQueue.state = A$1.idle; + }, this.processRequest = (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = s2.method; + if (!this.shouldIgnorePairingRequest({ topic: e2, requestMethod: i2 })) + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeRequest(e2, s2); + case "wc_sessionSettle": + return this.onSessionSettleRequest(e2, s2); + case "wc_sessionUpdate": + return this.onSessionUpdateRequest(e2, s2); + case "wc_sessionExtend": + return this.onSessionExtendRequest(e2, s2); + case "wc_sessionPing": + return this.onSessionPingRequest(e2, s2); + case "wc_sessionDelete": + return this.onSessionDeleteRequest(e2, s2); + case "wc_sessionRequest": + return this.onSessionRequest(e2, s2); + case "wc_sessionEvent": + return this.onSessionEventRequest(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateRequest(e2, s2); + default: + return this.client.logger.info(`Unsupported request method ${i2}`); + } + }, this.onRelayEventResponse = async (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = (await this.client.core.history.get(e2, s2.id)).request.method; + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeResponse(e2, s2); + case "wc_sessionSettle": + return this.onSessionSettleResponse(e2, s2); + case "wc_sessionUpdate": + return this.onSessionUpdateResponse(e2, s2); + case "wc_sessionExtend": + return this.onSessionExtendResponse(e2, s2); + case "wc_sessionPing": + return this.onSessionPingResponse(e2, s2); + case "wc_sessionRequest": + return this.onSessionRequestResponse(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateResponse(e2, s2); + default: + return this.client.logger.info(`Unsupported response method ${i2}`); + } + }, this.onRelayEventUnknownPayload = (t2) => { + const { topic: e2 } = t2, { message: s2 } = xe("MISSING_OR_INVALID", `Decoded payload on topic ${e2} is not identifiable as a JSON-RPC request or a response.`); + throw new Error(s2); + }, this.shouldIgnorePairingRequest = (t2) => { + const { topic: e2, requestMethod: s2 } = t2, i2 = this.expectedPairingMethodMap.get(e2); + return !i2 || i2.includes(s2) ? false : !!(i2.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0); + }, this.onSessionProposeRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; + try { + this.isValidConnect(m2({}, e2.params)); + const r3 = s2.expiryTimestamp || d0(q$1.wc_sessionPropose.req.ttl), o2 = m2({ id: i2, pairingTopic: t2, expiryTimestamp: r3 }, s2); + await this.setProposal(i2, o2); + const a3 = yu(JSON.stringify(e2)), c2 = await this.getVerifyContext(a3, o2.proposer.metadata); + this.client.events.emit("session_proposal", { id: i2, params: o2, verifyContext: c2 }); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionProposeResponse = async (t2, e2) => { + const { id: s2 } = e2; + if (isJsonRpcResult(e2)) { + const { result: i2 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); + const r3 = this.client.proposal.get(s2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: r3 }); + const o2 = r3.proposer.publicKey; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o2 }); + const a3 = i2.responderPublicKey; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a3 }); + const c2 = await this.client.core.crypto.generateSharedKey(o2, a3); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); + const d5 = await this.client.core.relayer.subscribe(c2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: d5 }), await this.client.core.pairing.activate({ topic: t2 }); + } else if (isJsonRpcError(e2)) { + await this.client.proposal.delete(s2, tr$2("USER_DISCONNECTED")); + const i2 = v0("session_connect"); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners, 954`); + this.events.emit(v0("session_connect"), { error: e2.error }); + } + }, this.onSessionSettleRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + this.isValidSessionSettleRequest(i2); + const { relay: r3, controller: o2, expiry: a3, namespaces: c2, sessionProperties: d5, pairingTopic: p2, sessionConfig: g3 } = e2.params, h4 = m2(m2({ topic: t2, relay: r3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: p2, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, d5 && { sessionProperties: d5 }), g3 && { sessionConfig: g3 }); + await this.sendResult({ id: e2.id, topic: t2, result: true, throwOnFailedPublish: true }); + const y3 = v0("session_connect"); + if (this.events.listenerCount(y3) === 0) + throw new Error(`emitting ${y3} without any listeners 997`); + this.events.emit(v0("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionSettleResponse = async (t2, e2) => { + const { id: s2 } = e2; + isJsonRpcResult(e2) ? (await this.client.session.update(t2, { acknowledged: true }), this.events.emit(v0("session_approve", s2), {})) : isJsonRpcError(e2) && (await this.client.session.delete(t2, tr$2("USER_DISCONNECTED")), this.events.emit(v0("session_approve", s2), { error: e2.error })); + }, this.onSessionUpdateRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; + try { + const r3 = `${t2}_session_update`, o2 = lh.get(r3); + if (o2 && this.isRequestOutOfSync(o2, i2)) { + this.client.logger.info(`Discarding out of sync request - ${i2}`), this.sendError({ id: i2, topic: t2, error: tr$2("INVALID_UPDATE_REQUEST") }); + return; + } + this.isValidUpdate(m2({ topic: t2 }, s2)); + try { + lh.set(r3, i2), await this.client.session.update(t2, { namespaces: s2.namespaces }), await this.sendResult({ id: i2, topic: t2, result: true, throwOnFailedPublish: true }); + } catch (a3) { + throw lh.delete(r3), a3; + } + this.client.events.emit("session_update", { id: i2, topic: t2, params: s2 }); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.isRequestOutOfSync = (t2, e2) => parseInt(e2.toString().slice(0, -3)) <= parseInt(t2.toString().slice(0, -3)), this.onSessionUpdateResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_update", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_update", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_update", s2), { error: e2.error }); + }, this.onSessionExtendRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidExtend({ topic: t2 }), await this.setExpiry(t2, d0(L$2)), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_extend", { id: s2, topic: t2 }); + } catch (i2) { + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionExtendResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_extend", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_extend", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_extend", s2), { error: e2.error }); + }, this.onSessionPingRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidPing({ topic: t2 }), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_ping", { id: s2, topic: t2 }); + } catch (i2) { + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionPingResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_ping", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + setTimeout(() => { + isJsonRpcResult(e2) ? this.events.emit(v0("session_ping", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_ping", s2), { error: e2.error }); + }, 500); + }, this.onSessionDeleteRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidDisconnect({ topic: t2, reason: e2.params }), await Promise.all([new Promise((i2) => { + this.client.core.relayer.once(v2.publish, async () => { + i2(await this.deleteSession({ topic: t2, id: s2 })); + }); + }), this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.cleanupPendingSentRequestsForTopic({ topic: t2, error: tr$2("USER_DISCONNECTED") })]); + } catch (i2) { + this.client.logger.error(i2); + } + }, this.onSessionRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + await this.isValidRequest(m2({ topic: t2 }, i2)); + const r3 = yu(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, s2))), o2 = this.client.session.get(t2), a3 = await this.getVerifyContext(r3, o2.peer.metadata), c2 = { id: s2, topic: t2, params: i2, verifyContext: a3 }; + await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionRequestResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_request", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionEventRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + const r3 = `${t2}_session_event_${i2.event.name}`, o2 = lh.get(r3); + if (o2 && this.isRequestOutOfSync(o2, s2)) { + this.client.logger.info(`Discarding out of sync request - ${s2}`); + return; + } + this.isValidEmit(m2({ topic: t2 }, i2)), this.client.events.emit("session_event", { id: s2, topic: t2, params: i2 }), lh.set(r3, s2); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionAuthenticateResponse = (t2, e2) => { + const { id: s2 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionAuthenticateResponse", topic: t2, payload: e2 }), isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionAuthenticateRequest = async (t2, e2) => { + const { requester: s2, authPayload: i2, expiryTimestamp: r3 } = e2.params, o2 = yu(JSON.stringify(e2)), a3 = await this.getVerifyContext(o2, this.client.metadata), c2 = { requester: s2, pairingTopic: t2, id: e2.id, authPayload: i2, verifyContext: a3, expiryTimestamp: r3 }; + await this.client.auth.requests.set(e2.id, c2), this.client.events.emit("session_authenticate", { topic: t2, params: e2.params, id: e2.id }); + }, this.addSessionRequestToSessionRequestQueue = (t2) => { + this.sessionRequestQueue.queue.push(t2); + }, this.cleanupAfterResponse = (t2) => { + this.deletePendingSessionRequest(t2.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { + this.sessionRequestQueue.state = A$1.idle, this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay)); + }, this.cleanupPendingSentRequestsForTopic = ({ topic: t2, error: e2 }) => { + const s2 = this.client.core.history.pending; + s2.length > 0 && s2.filter((i2) => i2.topic === t2 && i2.request.method === "wc_sessionRequest").forEach((i2) => { + const r3 = i2.request.id, o2 = v0("session_request", r3); + if (this.events.listenerCount(o2) === 0) + throw new Error(`emitting ${o2} without any listeners`); + this.events.emit(v0("session_request", i2.request.id), { error: e2 }); + }); + }, this.processSessionRequestQueue = () => { + if (this.sessionRequestQueue.state === A$1.active) { + this.client.logger.info("session request queue is already active."); + return; + } + const t2 = this.sessionRequestQueue.queue[0]; + if (!t2) { + this.client.logger.info("session request queue is empty."); + return; + } + try { + this.sessionRequestQueue.state = A$1.active, this.client.events.emit("session_request", t2); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.onPairingCreated = (t2) => { + if (t2.methods && this.expectedPairingMethodMap.set(t2.topic, t2.methods), t2.active) + return; + const e2 = this.client.proposal.getAll().find((s2) => s2.pairingTopic === t2.topic); + e2 && this.onSessionProposeRequest(t2.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: e2.requiredNamespaces, optionalNamespaces: e2.optionalNamespaces, relays: e2.relays, proposer: e2.proposer, sessionProperties: e2.sessionProperties }, e2.id)); + }, this.isValidConnect = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(t2)}`); + throw new Error(a3); + } + const { pairingTopic: e2, requiredNamespaces: s2, optionalNamespaces: i2, sessionProperties: r3, relays: o2 } = t2; + if (Pe(e2) || await this.isValidPairingTopic(e2), !Xu(o2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `connect() relays: ${o2}`); + throw new Error(a3); + } + !Pe(s2) && Yr(s2) !== 0 && this.validateNamespaces(s2, "requiredNamespaces"), !Pe(i2) && Yr(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), Pe(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.validateNamespaces = (t2, e2) => { + const s2 = Wu(t2, "connect()", e2); + if (s2) + throw new Error(s2.message); + }, this.isValidApprove = async (t2) => { + if (!$u(t2)) + throw new Error(xe("MISSING_OR_INVALID", `approve() params: ${t2}`).message); + const { id: e2, namespaces: s2, relayProtocol: i2, sessionProperties: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2); + const o2 = this.client.proposal.get(e2), a3 = So(s2, "approve()"); + if (a3) + throw new Error(a3.message); + const c2 = Io(o2.requiredNamespaces, s2, "approve()"); + if (c2) + throw new Error(c2.message); + if (!Gt$1(i2, true)) { + const { message: d5 } = xe("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); + throw new Error(d5); + } + Pe(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.isValidReject = async (t2) => { + if (!$u(t2)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `reject() params: ${t2}`); + throw new Error(i2); + } + const { id: e2, reason: s2 } = t2; + if (this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2), !th(s2)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(s2)}`); + throw new Error(i2); + } + }, this.isValidSessionSettleRequest = (t2) => { + if (!$u(t2)) { + const { message: c2 } = xe("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${t2}`); + throw new Error(c2); + } + const { relay: e2, controller: s2, namespaces: i2, expiry: r3 } = t2; + if (!No(e2)) { + const { message: c2 } = xe("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); + throw new Error(c2); + } + const o2 = Vu(s2, "onSessionSettleRequest()"); + if (o2) + throw new Error(o2.message); + const a3 = So(i2, "onSessionSettleRequest()"); + if (a3) + throw new Error(a3.message); + if (p0(r3)) { + const { message: c2 } = xe("EXPIRED", "onSessionSettleRequest()"); + throw new Error(c2); + } + }, this.isValidUpdate = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `update() params: ${t2}`); + throw new Error(a3); + } + const { topic: e2, namespaces: s2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const i2 = this.client.session.get(e2), r3 = So(s2, "update()"); + if (r3) + throw new Error(r3.message); + const o2 = Io(i2.requiredNamespaces, s2, "update()"); + if (o2) + throw new Error(o2.message); + }, this.isValidExtend = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `extend() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + }, this.isValidRequest = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() params: ${t2}`); + throw new Error(a3); + } + const { topic: e2, request: s2, chainId: i2, expiry: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const { namespaces: o2 } = this.client.session.get(e2); + if (!nh(o2, i2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() chainId: ${i2}`); + throw new Error(a3); + } + if (!eh(s2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() ${JSON.stringify(s2)}`); + throw new Error(a3); + } + if (!fh(o2, i2, s2.method)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() method: ${s2.method}`); + throw new Error(a3); + } + if (r3 && !uh(r3, re$1)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() expiry: ${r3}. Expiry must be a number (in seconds) between ${re$1.min} and ${re$1.max}`); + throw new Error(a3); + } + }, this.isValidRespond = async (t2) => { + var e2; + if (!$u(t2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `respond() params: ${t2}`); + throw new Error(r3); + } + const { topic: s2, response: i2 } = t2; + try { + await this.isValidSessionTopic(s2); + } catch (r3) { + throw (e2 = t2 == null ? void 0 : t2.response) != null && e2.id && this.cleanupAfterResponse(t2), r3; + } + if (!rh(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); + throw new Error(r3); + } + }, this.isValidPing = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `ping() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidEmit = async (t2) => { + if (!$u(t2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() params: ${t2}`); + throw new Error(o2); + } + const { topic: e2, event: s2, chainId: i2 } = t2; + await this.isValidSessionTopic(e2); + const { namespaces: r3 } = this.client.session.get(e2); + if (!nh(r3, i2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() chainId: ${i2}`); + throw new Error(o2); + } + if (!ih(s2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); + throw new Error(o2); + } + if (!oh(r3, i2, s2.name)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); + throw new Error(o2); + } + }, this.isValidDisconnect = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `disconnect() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidAuthenticate = (t2) => { + const { chains: e2, uri: s2, domain: i2, nonce: r3 } = t2; + if (!Array.isArray(e2) || e2.length === 0) + throw new Error("chains is required and must be a non-empty array"); + if (!Gt$1(s2, false)) + throw new Error("uri is required parameter"); + if (!Gt$1(i2, false)) + throw new Error("domain is required parameter"); + if (!Gt$1(r3, false)) + throw new Error("nonce is required parameter"); + if ([...new Set(e2.map((a3) => dn(a3).namespace))].length > 1) + throw new Error("Multi-namespace requests are not supported. Please request single namespace only."); + const { namespace: o2 } = dn(e2[0]); + if (o2 !== "eip155") + throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains."); + }, this.getVerifyContext = async (t2, e2) => { + const s2 = { verified: { verifyUrl: e2.verifyUrl || k$1, validation: "UNKNOWN", origin: e2.url || "" } }; + try { + const i2 = await this.client.core.verify.resolve({ attestationId: t2, verifyUrl: e2.verifyUrl }); + i2 && (s2.verified.origin = i2.origin, s2.verified.isScam = i2.isScam, s2.verified.validation = i2.origin === new URL(e2.url).origin ? "VALID" : "INVALID"); + } catch (i2) { + this.client.logger.info(i2); + } + return this.client.logger.info(`Verify context: ${JSON.stringify(s2)}`), s2; + }, this.validateSessionProps = (t2, e2) => { + Object.values(t2).forEach((s2) => { + if (!Gt$1(s2, false)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `${e2} must be in Record format. Received: ${JSON.stringify(s2)}`); + throw new Error(i2); + } + }); + }, this.getPendingAuthRequest = (t2) => { + const e2 = this.client.auth.requests.get(t2); + return typeof e2 == "object" ? e2 : void 0; + }, this.addToRecentlyDeleted = (t2, e2) => { + if (this.recentlyDeletedMap.set(t2, e2), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) { + let s2 = 0; + const i2 = this.recentlyDeletedLimit / 2; + for (const r3 of this.recentlyDeletedMap.keys()) { + if (s2++ >= i2) + break; + this.recentlyDeletedMap.delete(r3); + } + } + }, this.checkRecentlyDeleted = (t2) => { + const e2 = this.recentlyDeletedMap.get(t2); + if (e2) { + const { message: s2 } = xe("MISSING_OR_INVALID", `Record was recently deleted - ${e2}: ${t2}`); + throw new Error(s2); + } + }; + } + async isInitialized() { + if (!this.initialized) { + const { message: n4 } = xe("NOT_INITIALIZED", this.name); + throw new Error(n4); + } + await this.client.core.relayer.confirmOnlineStateOrThrow(); + } + registerRelayerEvents() { + this.client.core.relayer.on(v2.message, async (n4) => { + const { topic: t2, message: e2 } = n4, { publicKey: s2 } = this.client.auth.authKeys.keys.includes(J) ? this.client.auth.authKeys.get(J) : { responseTopic: void 0, publicKey: void 0 }, i2 = await this.client.core.crypto.decode(t2, e2, { receiverPublicKey: s2 }); + try { + isJsonRpcRequest(i2) ? (this.client.core.history.set(t2, i2), this.onRelayEventRequest({ topic: t2, payload: i2 })) : isJsonRpcResponse(i2) ? (await this.client.core.history.resolve(i2), await this.onRelayEventResponse({ topic: t2, payload: i2 }), this.client.core.history.delete(t2, i2.id)) : this.onRelayEventUnknownPayload({ topic: t2, payload: i2 }); + } catch (r3) { + this.client.logger.error(r3); + } + }); + } + registerExpirerEvents() { + this.client.core.expirer.on(C.expired, async (n4) => { + const { topic: t2, id: e2 } = l0(n4.target); + if (e2 && this.client.pendingRequest.keys.includes(e2)) + return await this.deletePendingSessionRequest(e2, xe("EXPIRED"), true); + t2 ? this.client.session.keys.includes(t2) && (await this.deleteSession({ topic: t2, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: t2 })) : e2 && (await this.deleteProposal(e2, true), this.client.events.emit("proposal_expire", { id: e2 })); + }); + } + registerPairingEvents() { + this.client.core.pairing.events.on(V$1.create, (n4) => this.onPairingCreated(n4)), this.client.core.pairing.events.on(V$1.delete, (n4) => { + this.addToRecentlyDeleted(n4.topic, "pairing"); + }); + } + isValidPairingTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `pairing topic should be a string: ${n4}`); + throw new Error(t2); + } + if (!this.client.core.pairing.pairings.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `pairing topic doesn't exist: ${n4}`); + throw new Error(t2); + } + if (p0(this.client.core.pairing.pairings.get(n4).expiry)) { + const { message: t2 } = xe("EXPIRED", `pairing topic: ${n4}`); + throw new Error(t2); + } + } + async isValidSessionTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `session topic should be a string: ${n4}`); + throw new Error(t2); + } + if (this.checkRecentlyDeleted(n4), !this.client.session.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `session topic doesn't exist: ${n4}`); + throw new Error(t2); + } + if (p0(this.client.session.get(n4).expiry)) { + await this.deleteSession({ topic: n4 }); + const { message: t2 } = xe("EXPIRED", `session topic: ${n4}`); + throw new Error(t2); + } + if (!this.client.core.crypto.keychain.has(n4)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `session topic does not exist in keychain: ${n4}`); + throw await this.deleteSession({ topic: n4 }), new Error(t2); + } + } + async isValidSessionOrPairingTopic(n4) { + if (this.checkRecentlyDeleted(n4), this.client.session.keys.includes(n4)) + await this.isValidSessionTopic(n4); + else if (this.client.core.pairing.pairings.keys.includes(n4)) + this.isValidPairingTopic(n4); + else if (Gt$1(n4, false)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${n4}`); + throw new Error(t2); + } else { + const { message: t2 } = xe("MISSING_OR_INVALID", `session or pairing topic should be a string: ${n4}`); + throw new Error(t2); + } + } + async isValidProposalId(n4) { + if (!Zu(n4)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `proposal id should be a number: ${n4}`); + throw new Error(t2); + } + if (!this.client.proposal.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `proposal id doesn't exist: ${n4}`); + throw new Error(t2); + } + if (p0(this.client.proposal.get(n4).expiryTimestamp)) { + await this.deleteProposal(n4); + const { message: t2 } = xe("EXPIRED", `proposal id: ${n4}`); + throw new Error(t2); + } + } +}; +let Zt$1 = class Zt extends Vt { + constructor(n4, t2) { + super(n4, t2, Ke, se$1), this.core = n4, this.logger = t2; + } +}; +class We extends Vt { + constructor(n4, t2) { + super(n4, t2, Ge, se$1), this.core = n4, this.logger = t2; + } +} +class es2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Fe, se$1, (e2) => e2.id), this.core = n4, this.logger = t2; + } +} +class ts2 extends Vt { + constructor(n4, t2) { + super(n4, t2, He, X, () => J), this.core = n4, this.logger = t2; + } +} +let ss$1 = class ss2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Ye, X), this.core = n4, this.logger = t2; + } +}; +class is2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Xe$1, X, (e2) => e2.id), this.core = n4, this.logger = t2; + } +} +class rs { + constructor(n4, t2) { + this.core = n4, this.logger = t2, this.authKeys = new ts2(this.core, this.logger), this.pairingTopics = new ss$1(this.core, this.logger), this.requests = new is2(this.core, this.logger); + } + async init() { + await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init(); + } +} +let ne$1 = class ne extends b$1 { + constructor(n4) { + super(n4), this.protocol = Se, this.version = Ee, this.name = ie$1.name, this.events = new eventsExports.EventEmitter(), this.on = (e2, s2) => this.events.on(e2, s2), this.once = (e2, s2) => this.events.once(e2, s2), this.off = (e2, s2) => this.events.off(e2, s2), this.removeListener = (e2, s2) => this.events.removeListener(e2, s2), this.removeAllListeners = (e2) => this.events.removeAllListeners(e2), this.connect = async (e2) => { + try { + return await this.engine.connect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.pair = async (e2) => { + try { + return await this.engine.pair(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approve = async (e2) => { + try { + return await this.engine.approve(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.reject = async (e2) => { + try { + return await this.engine.reject(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.update = async (e2) => { + try { + return await this.engine.update(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.extend = async (e2) => { + try { + return await this.engine.extend(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.request = async (e2) => { + try { + return await this.engine.request(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.respond = async (e2) => { + try { + return await this.engine.respond(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.ping = async (e2) => { + try { + return await this.engine.ping(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.emit = async (e2) => { + try { + return await this.engine.emit(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.disconnect = async (e2) => { + try { + return await this.engine.disconnect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.find = (e2) => { + try { + return this.engine.find(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.getPendingSessionRequests = () => { + try { + return this.engine.getPendingSessionRequests(); + } catch (e2) { + throw this.logger.error(e2.message), e2; + } + }, this.authenticate = async (e2) => { + try { + return await this.engine.authenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.formatAuthMessage = (e2) => { + try { + return this.engine.formatAuthMessage(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approveSessionAuthenticate = async (e2) => { + try { + return await this.engine.approveSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.rejectSessionAuthenticate = async (e2) => { + try { + return await this.engine.rejectSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.name = (n4 == null ? void 0 : n4.name) || ie$1.name, this.metadata = (n4 == null ? void 0 : n4.metadata) || Xo(); + const t2 = typeof (n4 == null ? void 0 : n4.logger) < "u" && typeof (n4 == null ? void 0 : n4.logger) != "string" ? n4.logger : nt$1(k$2({ level: (n4 == null ? void 0 : n4.logger) || ie$1.logger })); + this.core = (n4 == null ? void 0 : n4.core) || new Br(n4), this.logger = E$1(t2, this.name), this.session = new We(this.core, this.logger), this.proposal = new Zt$1(this.core, this.logger), this.pendingRequest = new es2(this.core, this.logger), this.engine = new Wt$1(this), this.auth = new rs(this.core, this.logger); + } + static async init(n4) { + const t2 = new ne(n4); + return await t2.initialize(), t2; + } + get context() { + return y$2(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.engine.init(), await this.auth.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); + } catch (n4) { + throw this.logger.info("SignClient Initialization Failure"), this.logger.error(n4.message), n4; + } + } +}; +var N = Object.defineProperty, T = Object.defineProperties, U = Object.getOwnPropertyDescriptors, I = Object.getOwnPropertySymbols, A = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable, M = (e2, t2, a3) => t2 in e2 ? N(e2, t2, { enumerable: true, configurable: true, writable: true, value: a3 }) : e2[t2] = a3, q = (e2, t2) => { + for (var a3 in t2 || (t2 = {})) + A.call(t2, a3) && M(e2, a3, t2[a3]); + if (I) + for (var a3 of I(t2)) + D.call(t2, a3) && M(e2, a3, t2[a3]); + return e2; +}, L$1 = (e2, t2) => T(e2, U(t2)), g2 = (e2, t2, a3) => { + if (!t2.has(e2)) + throw TypeError("Cannot " + a3); +}, s = (e2, t2, a3) => (g2(e2, t2, "read from private field"), a3 ? a3.call(e2) : t2.get(e2)), d4 = (e2, t2, a3) => { + if (t2.has(e2)) + throw TypeError("Cannot add the same private member more than once"); + t2 instanceof WeakSet ? t2.add(e2) : t2.set(e2, a3); +}, S = (e2, t2, a3, h4) => (g2(e2, t2, "write to private field"), t2.set(e2, a3), a3), n3 = (e2, t2, a3) => (g2(e2, t2, "access private method"), a3), w2, f2, u2, o, O2, k, r2, c, j$1, P; +class G { + constructor(t2) { + d4(this, O2), d4(this, r2), d4(this, j$1), d4(this, w2, void 0), d4(this, f2, void 0), d4(this, u2, void 0), d4(this, o, void 0), S(this, w2, t2), S(this, f2, n3(this, O2, k).call(this)), n3(this, r2, c).call(this); + } + async connect(t2, a3 = true) { + const { requiredNamespaces: h4, optionalNamespaces: y3 } = t2; + return new Promise(async (W2, E2) => { + var _3, C2; + if (await n3(this, r2, c).call(this), a3) { + const p2 = s(this, f2).subscribeModal((i2) => { + i2.open || (p2(), E2(new Error("Modal closed"))); + }), { uri: v3, approval: m3 } = await s(this, o).connect(t2); + if (v3) { + const i2 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), y3 && Object.values(y3).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), await s(this, f2).openModal({ uri: v3, chains: Array.from(i2) }); + } + try { + const i2 = await m3(); + W2(i2); + } catch (i2) { + E2(i2); + } finally { + p2(), s(this, f2).closeModal(); + } + } else { + const { uri: p2, approval: v3 } = await s(this, o).connect(t2); + if (p2) { + const m3 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }), y3 && Object.values(y3).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }); + try { + if ((_3 = window == null ? void 0 : window.aleo) != null && _3.connectPuzzle) { + (C2 = window == null ? void 0 : window.aleo) == null || C2.connectPuzzle({ wc: { uri: p2 } }); + const i2 = await v3(); + W2(i2); + } else + throw new Error("window.aleo.connectPuzzle is undefined! Set showModal to true."); + } catch (i2) { + console.error(i2), E2(i2); + } + } + } + }); + } + async disconnect(t2) { + await n3(this, r2, c).call(this), await s(this, o).disconnect(t2); + } + async request(t2) { + return await n3(this, r2, c).call(this), await s(this, o).request(t2); + } + async getSessions() { + return await n3(this, r2, c).call(this), s(this, o).session.getAll(); + } + async getSession() { + return await n3(this, r2, c).call(this), s(this, o).session.getAll().at(-1); + } + async onSessionEvent(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_event", t2); + } + async offSessionEvent(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_event", t2); + } + async onSessionUpdate(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_update", t2); + } + async offSessionUpdate(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_update", t2); + } + async onSessionDelete(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_delete", t2); + } + async offSessionDelete(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_delete", t2); + } + async onSessionExpire(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_expire", t2); + } + async offSessionExpire(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_expire", t2); + } +} +w2 = /* @__PURE__ */ new WeakMap(), f2 = /* @__PURE__ */ new WeakMap(), u2 = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), O2 = /* @__PURE__ */ new WeakSet(), k = function() { + const { modalOptions: e2, projectId: t2 } = s(this, w2); + return new d$3(L$1(q({}, e2), { projectId: t2 })); +}, r2 = /* @__PURE__ */ new WeakSet(), c = async function() { + return s(this, o) ? true : (!s(this, u2) && typeof window < "u" && S(this, u2, n3(this, j$1, P).call(this)), s(this, u2)); +}, j$1 = /* @__PURE__ */ new WeakSet(), P = async function() { + S(this, o, await ne$1.init({ metadata: s(this, w2).metadata, projectId: s(this, w2).projectId, relayUrl: s(this, w2).relayUrl })); + const e2 = await s(this, o).core.crypto.getClientId(); + try { + localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e2); + } catch { + console.info("Unable to set client id"); + } +}; +var util; +(function(util2) { + util2.assertEqual = (val) => val; + function assertIs(_arg) { + } + util2.assertIs = assertIs; + function assertNever(_x) { + throw new Error(); + } + util2.assertNever = assertNever; + util2.arrayToEnum = (items) => { + const obj = {}; + for (const item of items) { + obj[item] = item; + } + return obj; + }; + util2.getValidEnumValues = (obj) => { + const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number"); + const filtered = {}; + for (const k2 of validKeys) { + filtered[k2] = obj[k2]; + } + return util2.objectValues(filtered); + }; + util2.objectValues = (obj) => { + return util2.objectKeys(obj).map(function(e2) { + return obj[e2]; + }); + }; + util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { + const keys2 = []; + for (const key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + keys2.push(key); + } + } + return keys2; + }; + util2.find = (arr, checker) => { + for (const item of arr) { + if (checker(item)) + return item; + } + return void 0; + }; + util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val; + function joinValues(array, separator = " | ") { + return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator); + } + util2.joinValues = joinValues; + util2.jsonStringifyReplacer = (_3, value) => { + if (typeof value === "bigint") { + return value.toString(); + } + return value; + }; +})(util || (util = {})); +var objectUtil; +(function(objectUtil2) { + objectUtil2.mergeShapes = (first, second) => { + return { + ...first, + ...second + // second overwrites first + }; + }; +})(objectUtil || (objectUtil = {})); +const ZodParsedType = util.arrayToEnum([ + "string", + "nan", + "number", + "integer", + "float", + "boolean", + "date", + "bigint", + "symbol", + "function", + "undefined", + "null", + "array", + "object", + "unknown", + "promise", + "void", + "never", + "map", + "set" +]); +const getParsedType = (data) => { + const t2 = typeof data; + switch (t2) { + case "undefined": + return ZodParsedType.undefined; + case "string": + return ZodParsedType.string; + case "number": + return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number; + case "boolean": + return ZodParsedType.boolean; + case "function": + return ZodParsedType.function; + case "bigint": + return ZodParsedType.bigint; + case "symbol": + return ZodParsedType.symbol; + case "object": + if (Array.isArray(data)) { + return ZodParsedType.array; + } + if (data === null) { + return ZodParsedType.null; + } + if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { + return ZodParsedType.promise; + } + if (typeof Map !== "undefined" && data instanceof Map) { + return ZodParsedType.map; + } + if (typeof Set !== "undefined" && data instanceof Set) { + return ZodParsedType.set; + } + if (typeof Date !== "undefined" && data instanceof Date) { + return ZodParsedType.date; + } + return ZodParsedType.object; + default: + return ZodParsedType.unknown; + } +}; +const ZodIssueCode = util.arrayToEnum([ + "invalid_type", + "invalid_literal", + "custom", + "invalid_union", + "invalid_union_discriminator", + "invalid_enum_value", + "unrecognized_keys", + "invalid_arguments", + "invalid_return_type", + "invalid_date", + "invalid_string", + "too_small", + "too_big", + "invalid_intersection_types", + "not_multiple_of", + "not_finite" +]); +const quotelessJson = (obj) => { + const json = JSON.stringify(obj, null, 2); + return json.replace(/"([^"]+)":/g, "$1:"); +}; +class ZodError extends Error { + constructor(issues) { + super(); + this.issues = []; + this.addIssue = (sub) => { + this.issues = [...this.issues, sub]; + }; + this.addIssues = (subs = []) => { + this.issues = [...this.issues, ...subs]; + }; + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } else { + this.__proto__ = actualProto; + } + this.name = "ZodError"; + this.issues = issues; + } + get errors() { + return this.issues; + } + format(_mapper) { + const mapper = _mapper || function(issue) { + return issue.message; + }; + const fieldErrors = { _errors: [] }; + const processError = (error) => { + for (const issue of error.issues) { + if (issue.code === "invalid_union") { + issue.unionErrors.map(processError); + } else if (issue.code === "invalid_return_type") { + processError(issue.returnTypeError); + } else if (issue.code === "invalid_arguments") { + processError(issue.argumentsError); + } else if (issue.path.length === 0) { + fieldErrors._errors.push(mapper(issue)); + } else { + let curr = fieldErrors; + let i2 = 0; + while (i2 < issue.path.length) { + const el = issue.path[i2]; + const terminal = i2 === issue.path.length - 1; + if (!terminal) { + curr[el] = curr[el] || { _errors: [] }; + } else { + curr[el] = curr[el] || { _errors: [] }; + curr[el]._errors.push(mapper(issue)); + } + curr = curr[el]; + i2++; + } + } + } + }; + processError(this); + return fieldErrors; + } + toString() { + return this.message; + } + get message() { + return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2); + } + get isEmpty() { + return this.issues.length === 0; + } + flatten(mapper = (issue) => issue.message) { + const fieldErrors = {}; + const formErrors = []; + for (const sub of this.issues) { + if (sub.path.length > 0) { + fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; + fieldErrors[sub.path[0]].push(mapper(sub)); + } else { + formErrors.push(mapper(sub)); + } + } + return { formErrors, fieldErrors }; + } + get formErrors() { + return this.flatten(); + } +} +ZodError.create = (issues) => { + const error = new ZodError(issues); + return error; +}; +const errorMap = (issue, _ctx) => { + let message; + switch (issue.code) { + case ZodIssueCode.invalid_type: + if (issue.received === ZodParsedType.undefined) { + message = "Required"; + } else { + message = `Expected ${issue.expected}, received ${issue.received}`; + } + break; + case ZodIssueCode.invalid_literal: + message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`; + break; + case ZodIssueCode.unrecognized_keys: + message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`; + break; + case ZodIssueCode.invalid_union: + message = `Invalid input`; + break; + case ZodIssueCode.invalid_union_discriminator: + message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`; + break; + case ZodIssueCode.invalid_enum_value: + message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`; + break; + case ZodIssueCode.invalid_arguments: + message = `Invalid function arguments`; + break; + case ZodIssueCode.invalid_return_type: + message = `Invalid function return type`; + break; + case ZodIssueCode.invalid_date: + message = `Invalid date`; + break; + case ZodIssueCode.invalid_string: + if (typeof issue.validation === "object") { + if ("includes" in issue.validation) { + message = `Invalid input: must include "${issue.validation.includes}"`; + if (typeof issue.validation.position === "number") { + message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; + } + } else if ("startsWith" in issue.validation) { + message = `Invalid input: must start with "${issue.validation.startsWith}"`; + } else if ("endsWith" in issue.validation) { + message = `Invalid input: must end with "${issue.validation.endsWith}"`; + } else { + util.assertNever(issue.validation); + } + } else if (issue.validation !== "regex") { + message = `Invalid ${issue.validation}`; + } else { + message = "Invalid"; + } + break; + case ZodIssueCode.too_small: + if (issue.type === "array") + message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`; + else if (issue.type === "string") + message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`; + else if (issue.type === "number") + message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`; + else if (issue.type === "date") + message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`; + else + message = "Invalid input"; + break; + case ZodIssueCode.too_big: + if (issue.type === "array") + message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`; + else if (issue.type === "string") + message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`; + else if (issue.type === "number") + message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; + else if (issue.type === "bigint") + message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; + else if (issue.type === "date") + message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`; + else + message = "Invalid input"; + break; + case ZodIssueCode.custom: + message = `Invalid input`; + break; + case ZodIssueCode.invalid_intersection_types: + message = `Intersection results could not be merged`; + break; + case ZodIssueCode.not_multiple_of: + message = `Number must be a multiple of ${issue.multipleOf}`; + break; + case ZodIssueCode.not_finite: + message = "Number must be finite"; + break; + default: + message = _ctx.defaultError; + util.assertNever(issue); + } + return { message }; +}; +let overrideErrorMap = errorMap; +function setErrorMap(map) { + overrideErrorMap = map; +} +function getErrorMap() { + return overrideErrorMap; +} +const makeIssue = (params) => { + const { data, path, errorMaps, issueData } = params; + const fullPath = [...path, ...issueData.path || []]; + const fullIssue = { + ...issueData, + path: fullPath + }; + let errorMessage = ""; + const maps = errorMaps.filter((m3) => !!m3).slice().reverse(); + for (const map of maps) { + errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; + } + return { + ...issueData, + path: fullPath, + message: issueData.message || errorMessage + }; +}; +const EMPTY_PATH = []; +function addIssueToContext(ctx, issueData) { + const issue = makeIssue({ + issueData, + data: ctx.data, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + // then global default map + ].filter((x2) => !!x2) + }); + ctx.common.issues.push(issue); +} +class ParseStatus { + constructor() { + this.value = "valid"; + } + dirty() { + if (this.value === "valid") + this.value = "dirty"; + } + abort() { + if (this.value !== "aborted") + this.value = "aborted"; + } + static mergeArray(status, results) { + const arrayValue = []; + for (const s2 of results) { + if (s2.status === "aborted") + return INVALID; + if (s2.status === "dirty") + status.dirty(); + arrayValue.push(s2.value); + } + return { status: status.value, value: arrayValue }; + } + static async mergeObjectAsync(status, pairs) { + const syncPairs = []; + for (const pair of pairs) { + syncPairs.push({ + key: await pair.key, + value: await pair.value + }); + } + return ParseStatus.mergeObjectSync(status, syncPairs); + } + static mergeObjectSync(status, pairs) { + const finalObject = {}; + for (const pair of pairs) { + const { key, value } = pair; + if (key.status === "aborted") + return INVALID; + if (value.status === "aborted") + return INVALID; + if (key.status === "dirty") + status.dirty(); + if (value.status === "dirty") + status.dirty(); + if (typeof value.value !== "undefined" || pair.alwaysSet) { + finalObject[key.value] = value.value; + } + } + return { status: status.value, value: finalObject }; + } +} +const INVALID = Object.freeze({ + status: "aborted" +}); +const DIRTY = (value) => ({ status: "dirty", value }); +const OK = (value) => ({ status: "valid", value }); +const isAborted = (x2) => x2.status === "aborted"; +const isDirty = (x2) => x2.status === "dirty"; +const isValid = (x2) => x2.status === "valid"; +const isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise; +var errorUtil; +(function(errorUtil2) { + errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {}; + errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; +})(errorUtil || (errorUtil = {})); +class ParseInputLazyPath { + constructor(parent, value, path, key) { + this._cachedPath = []; + this.parent = parent; + this.data = value; + this._path = path; + this._key = key; + } + get path() { + if (!this._cachedPath.length) { + if (this._key instanceof Array) { + this._cachedPath.push(...this._path, ...this._key); + } else { + this._cachedPath.push(...this._path, this._key); + } + } + return this._cachedPath; + } +} +const handleResult = (ctx, result) => { + if (isValid(result)) { + return { success: true, data: result.value }; + } else { + if (!ctx.common.issues.length) { + throw new Error("Validation failed but no issues detected."); + } + return { + success: false, + get error() { + if (this._error) + return this._error; + const error = new ZodError(ctx.common.issues); + this._error = error; + return this._error; + } + }; + } +}; +function processCreateParams(params) { + if (!params) + return {}; + const { errorMap: errorMap2, invalid_type_error, required_error, description: description2 } = params; + if (errorMap2 && (invalid_type_error || required_error)) { + throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); + } + if (errorMap2) + return { errorMap: errorMap2, description: description2 }; + const customMap = (iss, ctx) => { + if (iss.code !== "invalid_type") + return { message: ctx.defaultError }; + if (typeof ctx.data === "undefined") { + return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError }; + } + return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError }; + }; + return { errorMap: customMap, description: description2 }; +} +class ZodType { + constructor(def) { + this.spa = this.safeParseAsync; + this._def = def; + this.parse = this.parse.bind(this); + this.safeParse = this.safeParse.bind(this); + this.parseAsync = this.parseAsync.bind(this); + this.safeParseAsync = this.safeParseAsync.bind(this); + this.spa = this.spa.bind(this); + this.refine = this.refine.bind(this); + this.refinement = this.refinement.bind(this); + this.superRefine = this.superRefine.bind(this); + this.optional = this.optional.bind(this); + this.nullable = this.nullable.bind(this); + this.nullish = this.nullish.bind(this); + this.array = this.array.bind(this); + this.promise = this.promise.bind(this); + this.or = this.or.bind(this); + this.and = this.and.bind(this); + this.transform = this.transform.bind(this); + this.brand = this.brand.bind(this); + this.default = this.default.bind(this); + this.catch = this.catch.bind(this); + this.describe = this.describe.bind(this); + this.pipe = this.pipe.bind(this); + this.isNullable = this.isNullable.bind(this); + this.isOptional = this.isOptional.bind(this); + } + get description() { + return this._def.description; + } + _getType(input) { + return getParsedType(input.data); + } + _getOrReturnCtx(input, ctx) { + return ctx || { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + }; + } + _processInputParams(input) { + return { + status: new ParseStatus(), + ctx: { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + } + }; + } + _parseSync(input) { + const result = this._parse(input); + if (isAsync(result)) { + throw new Error("Synchronous parse encountered promise."); + } + return result; + } + _parseAsync(input) { + const result = this._parse(input); + return Promise.resolve(result); + } + parse(data, params) { + const result = this.safeParse(data, params); + if (result.success) + return result.data; + throw result.error; + } + safeParse(data, params) { + var _a2; + const ctx = { + common: { + issues: [], + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, + contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap + }, + path: (params === null || params === void 0 ? void 0 : params.path) || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }; + const result = this._parseSync({ data, path: ctx.path, parent: ctx }); + return handleResult(ctx, result); + } + async parseAsync(data, params) { + const result = await this.safeParseAsync(data, params); + if (result.success) + return result.data; + throw result.error; + } + async safeParseAsync(data, params) { + const ctx = { + common: { + issues: [], + contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap, + async: true + }, + path: (params === null || params === void 0 ? void 0 : params.path) || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }; + const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }); + const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); + return handleResult(ctx, result); + } + refine(check, message) { + const getIssueProperties = (val) => { + if (typeof message === "string" || typeof message === "undefined") { + return { message }; + } else if (typeof message === "function") { + return message(val); + } else { + return message; + } + }; + return this._refinement((val, ctx) => { + const result = check(val); + const setError = () => ctx.addIssue({ + code: ZodIssueCode.custom, + ...getIssueProperties(val) + }); + if (typeof Promise !== "undefined" && result instanceof Promise) { + return result.then((data) => { + if (!data) { + setError(); + return false; + } else { + return true; + } + }); + } + if (!result) { + setError(); + return false; + } else { + return true; + } + }); + } + refinement(check, refinementData) { + return this._refinement((val, ctx) => { + if (!check(val)) { + ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData); + return false; + } else { + return true; + } + }); + } + _refinement(refinement) { + return new ZodEffects({ + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "refinement", refinement } + }); + } + superRefine(refinement) { + return this._refinement(refinement); + } + optional() { + return ZodOptional.create(this, this._def); + } + nullable() { + return ZodNullable.create(this, this._def); + } + nullish() { + return this.nullable().optional(); + } + array() { + return ZodArray.create(this, this._def); + } + promise() { + return ZodPromise.create(this, this._def); + } + or(option) { + return ZodUnion.create([this, option], this._def); + } + and(incoming) { + return ZodIntersection.create(this, incoming, this._def); + } + transform(transform) { + return new ZodEffects({ + ...processCreateParams(this._def), + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "transform", transform } + }); + } + default(def) { + const defaultValueFunc = typeof def === "function" ? def : () => def; + return new ZodDefault({ + ...processCreateParams(this._def), + innerType: this, + defaultValue: defaultValueFunc, + typeName: ZodFirstPartyTypeKind.ZodDefault + }); + } + brand() { + return new ZodBranded({ + typeName: ZodFirstPartyTypeKind.ZodBranded, + type: this, + ...processCreateParams(this._def) + }); + } + catch(def) { + const catchValueFunc = typeof def === "function" ? def : () => def; + return new ZodCatch({ + ...processCreateParams(this._def), + innerType: this, + catchValue: catchValueFunc, + typeName: ZodFirstPartyTypeKind.ZodCatch + }); + } + describe(description2) { + const This = this.constructor; + return new This({ + ...this._def, + description: description2 + }); + } + pipe(target) { + return ZodPipeline.create(this, target); + } + isOptional() { + return this.safeParse(void 0).success; + } + isNullable() { + return this.safeParse(null).success; + } +} +const cuidRegex = /^c[^\s-]{8,}$/i; +const cuid2Regex = /^[a-z][a-z0-9]*$/; +const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/; +const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; +const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/; +const emojiRegex = new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u"); +const ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; +const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/; +const datetimeRegex = (args) => { + if (args.precision) { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`); + } + } else if (args.precision === 0) { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`); + } + } else { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`); + } + } +}; +function isValidIP(ip, version2) { + if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) { + return true; + } + if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) { + return true; + } + return false; +} +class ZodString extends ZodType { + constructor() { + super(...arguments); + this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), { + validation, + code: ZodIssueCode.invalid_string, + ...errorUtil.errToObj(message) + }); + this.nonempty = (message) => this.min(1, errorUtil.errToObj(message)); + this.trim = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "trim" }] + }); + this.toLowerCase = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toLowerCase" }] + }); + this.toUpperCase = () => new ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toUpperCase" }] + }); + } + _parse(input) { + if (this._def.coerce) { + input.data = String(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.string) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext( + ctx2, + { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.string, + received: ctx2.parsedType + } + // + ); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.length < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: true, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.length > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: true, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "length") { + const tooBig = input.data.length > check.value; + const tooSmall = input.data.length < check.value; + if (tooBig || tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + if (tooBig) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: true, + exact: true, + message: check.message + }); + } else if (tooSmall) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: true, + exact: true, + message: check.message + }); + } + status.dirty(); + } + } else if (check.kind === "email") { + if (!emailRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "email", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "emoji") { + if (!emojiRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "emoji", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "uuid") { + if (!uuidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "uuid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "cuid") { + if (!cuidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "cuid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "cuid2") { + if (!cuid2Regex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "cuid2", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "ulid") { + if (!ulidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "ulid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "url") { + try { + new URL(input.data); + } catch (_a2) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "url", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "regex") { + check.regex.lastIndex = 0; + const testResult = check.regex.test(input.data); + if (!testResult) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "regex", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "trim") { + input.data = input.data.trim(); + } else if (check.kind === "includes") { + if (!input.data.includes(check.value, check.position)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { includes: check.value, position: check.position }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "toLowerCase") { + input.data = input.data.toLowerCase(); + } else if (check.kind === "toUpperCase") { + input.data = input.data.toUpperCase(); + } else if (check.kind === "startsWith") { + if (!input.data.startsWith(check.value)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { startsWith: check.value }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "endsWith") { + if (!input.data.endsWith(check.value)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { endsWith: check.value }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "datetime") { + const regex = datetimeRegex(check); + if (!regex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: "datetime", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "ip") { + if (!isValidIP(input.data, check.version)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "ip", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + _addCheck(check) { + return new ZodString({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + email(message) { + return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) }); + } + url(message) { + return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) }); + } + emoji(message) { + return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) }); + } + uuid(message) { + return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) }); + } + cuid(message) { + return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) }); + } + cuid2(message) { + return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) }); + } + ulid(message) { + return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) }); + } + ip(options) { + return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); + } + datetime(options) { + var _a2; + if (typeof options === "string") { + return this._addCheck({ + kind: "datetime", + precision: null, + offset: false, + message: options + }); + } + return this._addCheck({ + kind: "datetime", + precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, + ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) + }); + } + regex(regex, message) { + return this._addCheck({ + kind: "regex", + regex, + ...errorUtil.errToObj(message) + }); + } + includes(value, options) { + return this._addCheck({ + kind: "includes", + value, + position: options === null || options === void 0 ? void 0 : options.position, + ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) + }); + } + startsWith(value, message) { + return this._addCheck({ + kind: "startsWith", + value, + ...errorUtil.errToObj(message) + }); + } + endsWith(value, message) { + return this._addCheck({ + kind: "endsWith", + value, + ...errorUtil.errToObj(message) + }); + } + min(minLength, message) { + return this._addCheck({ + kind: "min", + value: minLength, + ...errorUtil.errToObj(message) + }); + } + max(maxLength, message) { + return this._addCheck({ + kind: "max", + value: maxLength, + ...errorUtil.errToObj(message) + }); + } + length(len, message) { + return this._addCheck({ + kind: "length", + value: len, + ...errorUtil.errToObj(message) + }); + } + get isDatetime() { + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); + } + get isEmail() { + return !!this._def.checks.find((ch2) => ch2.kind === "email"); + } + get isURL() { + return !!this._def.checks.find((ch2) => ch2.kind === "url"); + } + get isEmoji() { + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); + } + get isUUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); + } + get isCUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); + } + get isCUID2() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); + } + get isULID() { + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); + } + get isIP() { + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); + } + get minLength() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxLength() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } +} +ZodString.create = (params) => { + var _a2; + return new ZodString({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodString, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams(params) + }); +}; +function floatSafeRemainder(val, step) { + const valDecCount = (val.toString().split(".")[1] || "").length; + const stepDecCount = (step.toString().split(".")[1] || "").length; + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; + const valInt = parseInt(val.toFixed(decCount).replace(".", "")); + const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); + return valInt % stepInt / Math.pow(10, decCount); +} +class ZodNumber extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + this.step = this.multipleOf; + } + _parse(input) { + if (this._def.coerce) { + input.data = Number(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.number) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.number, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "int") { + if (!util.isInteger(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: "integer", + received: "float", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (floatSafeRemainder(input.data, check.value) !== 0) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "finite") { + if (!Number.isFinite(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_finite, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodNumber({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodNumber({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + int(message) { + return this._addCheck({ + kind: "int", + message: errorUtil.toString(message) + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: false, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: false, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: true, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: true, + message: errorUtil.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + finite(message) { + return this._addCheck({ + kind: "finite", + message: errorUtil.toString(message) + }); + } + safe(message) { + return this._addCheck({ + kind: "min", + inclusive: true, + value: Number.MIN_SAFE_INTEGER, + message: errorUtil.toString(message) + })._addCheck({ + kind: "max", + inclusive: true, + value: Number.MAX_SAFE_INTEGER, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } + get isInt() { + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util.isInteger(ch2.value)); + } + get isFinite() { + let max = null, min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { + return true; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return Number.isFinite(min) && Number.isFinite(max); + } +} +ZodNumber.create = (params) => { + return new ZodNumber({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodNumber, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); +}; +class ZodBigInt extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + } + _parse(input) { + if (this._def.coerce) { + input.data = BigInt(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.bigint) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.bigint, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + type: "bigint", + minimum: check.value, + inclusive: check.inclusive, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + type: "bigint", + maximum: check.value, + inclusive: check.inclusive, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (input.data % check.value !== BigInt(0)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodBigInt({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodBigInt({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: false, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: false, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } +} +ZodBigInt.create = (params) => { + var _a2; + return new ZodBigInt({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodBigInt, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams(params) + }); +}; +class ZodBoolean extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = Boolean(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.boolean) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.boolean, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodBoolean.create = (params) => { + return new ZodBoolean({ + typeName: ZodFirstPartyTypeKind.ZodBoolean, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); +}; +class ZodDate extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = new Date(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.date) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.date, + received: ctx2.parsedType + }); + return INVALID; + } + if (isNaN(input.data.getTime())) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_date + }); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.getTime() < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + message: check.message, + inclusive: true, + exact: false, + minimum: check.value, + type: "date" + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.getTime() > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + message: check.message, + inclusive: true, + exact: false, + maximum: check.value, + type: "date" + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { + status: status.value, + value: new Date(input.data.getTime()) + }; + } + _addCheck(check) { + return new ZodDate({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + min(minDate, message) { + return this._addCheck({ + kind: "min", + value: minDate.getTime(), + message: errorUtil.toString(message) + }); + } + max(maxDate, message) { + return this._addCheck({ + kind: "max", + value: maxDate.getTime(), + message: errorUtil.toString(message) + }); + } + get minDate() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min != null ? new Date(min) : null; + } + get maxDate() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max != null ? new Date(max) : null; + } +} +ZodDate.create = (params) => { + return new ZodDate({ + checks: [], + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + typeName: ZodFirstPartyTypeKind.ZodDate, + ...processCreateParams(params) + }); +}; +class ZodSymbol extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.symbol) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.symbol, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodSymbol.create = (params) => { + return new ZodSymbol({ + typeName: ZodFirstPartyTypeKind.ZodSymbol, + ...processCreateParams(params) + }); +}; +class ZodUndefined extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.undefined, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodUndefined.create = (params) => { + return new ZodUndefined({ + typeName: ZodFirstPartyTypeKind.ZodUndefined, + ...processCreateParams(params) + }); +}; +class ZodNull extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.null) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.null, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodNull.create = (params) => { + return new ZodNull({ + typeName: ZodFirstPartyTypeKind.ZodNull, + ...processCreateParams(params) + }); +}; +class ZodAny extends ZodType { + constructor() { + super(...arguments); + this._any = true; + } + _parse(input) { + return OK(input.data); + } +} +ZodAny.create = (params) => { + return new ZodAny({ + typeName: ZodFirstPartyTypeKind.ZodAny, + ...processCreateParams(params) + }); +}; +class ZodUnknown extends ZodType { + constructor() { + super(...arguments); + this._unknown = true; + } + _parse(input) { + return OK(input.data); + } +} +ZodUnknown.create = (params) => { + return new ZodUnknown({ + typeName: ZodFirstPartyTypeKind.ZodUnknown, + ...processCreateParams(params) + }); +}; +class ZodNever extends ZodType { + _parse(input) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.never, + received: ctx.parsedType + }); + return INVALID; + } +} +ZodNever.create = (params) => { + return new ZodNever({ + typeName: ZodFirstPartyTypeKind.ZodNever, + ...processCreateParams(params) + }); +}; +class ZodVoid extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.void, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +} +ZodVoid.create = (params) => { + return new ZodVoid({ + typeName: ZodFirstPartyTypeKind.ZodVoid, + ...processCreateParams(params) + }); +}; +class ZodArray extends ZodType { + _parse(input) { + const { ctx, status } = this._processInputParams(input); + const def = this._def; + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (def.exactLength !== null) { + const tooBig = ctx.data.length > def.exactLength.value; + const tooSmall = ctx.data.length < def.exactLength.value; + if (tooBig || tooSmall) { + addIssueToContext(ctx, { + code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, + minimum: tooSmall ? def.exactLength.value : void 0, + maximum: tooBig ? def.exactLength.value : void 0, + type: "array", + inclusive: true, + exact: true, + message: def.exactLength.message + }); + status.dirty(); + } + } + if (def.minLength !== null) { + if (ctx.data.length < def.minLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.minLength.message + }); + status.dirty(); + } + } + if (def.maxLength !== null) { + if (ctx.data.length > def.maxLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.maxLength.message + }); + status.dirty(); + } + } + if (ctx.common.async) { + return Promise.all([...ctx.data].map((item, i2) => { + return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); + })).then((result2) => { + return ParseStatus.mergeArray(status, result2); + }); + } + const result = [...ctx.data].map((item, i2) => { + return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); + }); + return ParseStatus.mergeArray(status, result); + } + get element() { + return this._def.type; + } + min(minLength, message) { + return new ZodArray({ + ...this._def, + minLength: { value: minLength, message: errorUtil.toString(message) } + }); + } + max(maxLength, message) { + return new ZodArray({ + ...this._def, + maxLength: { value: maxLength, message: errorUtil.toString(message) } + }); + } + length(len, message) { + return new ZodArray({ + ...this._def, + exactLength: { value: len, message: errorUtil.toString(message) } + }); + } + nonempty(message) { + return this.min(1, message); + } +} +ZodArray.create = (schema, params) => { + return new ZodArray({ + type: schema, + minLength: null, + maxLength: null, + exactLength: null, + typeName: ZodFirstPartyTypeKind.ZodArray, + ...processCreateParams(params) + }); +}; +function deepPartialify(schema) { + if (schema instanceof ZodObject) { + const newShape = {}; + for (const key in schema.shape) { + const fieldSchema = schema.shape[key]; + newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); + } + return new ZodObject({ + ...schema._def, + shape: () => newShape + }); + } else if (schema instanceof ZodArray) { + return new ZodArray({ + ...schema._def, + type: deepPartialify(schema.element) + }); + } else if (schema instanceof ZodOptional) { + return ZodOptional.create(deepPartialify(schema.unwrap())); + } else if (schema instanceof ZodNullable) { + return ZodNullable.create(deepPartialify(schema.unwrap())); + } else if (schema instanceof ZodTuple) { + return ZodTuple.create(schema.items.map((item) => deepPartialify(item))); + } else { + return schema; + } +} +class ZodObject extends ZodType { + constructor() { + super(...arguments); + this._cached = null; + this.nonstrict = this.passthrough; + this.augment = this.extend; + } + _getCached() { + if (this._cached !== null) + return this._cached; + const shape = this._def.shape(); + const keys2 = util.objectKeys(shape); + return this._cached = { shape, keys: keys2 }; + } + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.object) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx2.parsedType + }); + return INVALID; + } + const { status, ctx } = this._processInputParams(input); + const { shape, keys: shapeKeys } = this._getCached(); + const extraKeys = []; + if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); + } + } + } + const pairs = []; + for (const key of shapeKeys) { + const keyValidator = shape[key]; + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), + alwaysSet: key in ctx.data + }); + } + if (this._def.catchall instanceof ZodNever) { + const unknownKeys = this._def.unknownKeys; + if (unknownKeys === "passthrough") { + for (const key of extraKeys) { + pairs.push({ + key: { status: "valid", value: key }, + value: { status: "valid", value: ctx.data[key] } + }); + } + } else if (unknownKeys === "strict") { + if (extraKeys.length > 0) { + addIssueToContext(ctx, { + code: ZodIssueCode.unrecognized_keys, + keys: extraKeys + }); + status.dirty(); + } + } else if (unknownKeys === "strip") + ; + else { + throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); + } + } else { + const catchall = this._def.catchall; + for (const key of extraKeys) { + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: catchall._parse( + new ParseInputLazyPath(ctx, value, ctx.path, key) + //, ctx.child(key), value, getParsedType(value) + ), + alwaysSet: key in ctx.data + }); + } + } + if (ctx.common.async) { + return Promise.resolve().then(async () => { + const syncPairs = []; + for (const pair of pairs) { + const key = await pair.key; + syncPairs.push({ + key, + value: await pair.value, + alwaysSet: pair.alwaysSet + }); + } + return syncPairs; + }).then((syncPairs) => { + return ParseStatus.mergeObjectSync(status, syncPairs); + }); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } + } + get shape() { + return this._def.shape(); + } + strict(message) { + errorUtil.errToObj; + return new ZodObject({ + ...this._def, + unknownKeys: "strict", + ...message !== void 0 ? { + errorMap: (issue, ctx) => { + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + if (issue.code === "unrecognized_keys") + return { + message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError + }; + return { + message: defaultError + }; + } + } : {} + }); + } + strip() { + return new ZodObject({ + ...this._def, + unknownKeys: "strip" + }); + } + passthrough() { + return new ZodObject({ + ...this._def, + unknownKeys: "passthrough" + }); + } + // const AugmentFactory = + // (def: Def) => + // ( + // augmentation: Augmentation + // ): ZodObject< + // extendShape, Augmentation>, + // Def["unknownKeys"], + // Def["catchall"] + // > => { + // return new ZodObject({ + // ...def, + // shape: () => ({ + // ...def.shape(), + // ...augmentation, + // }), + // }) as any; + // }; + extend(augmentation) { + return new ZodObject({ + ...this._def, + shape: () => ({ + ...this._def.shape(), + ...augmentation + }) + }); + } + /** + * Prior to zod@1.0.12 there was a bug in the + * inferred type of merged objects. Please + * upgrade if you are experiencing issues. + */ + merge(merging) { + const merged = new ZodObject({ + unknownKeys: merging._def.unknownKeys, + catchall: merging._def.catchall, + shape: () => ({ + ...this._def.shape(), + ...merging._def.shape() + }), + typeName: ZodFirstPartyTypeKind.ZodObject + }); + return merged; + } + // merge< + // Incoming extends AnyZodObject, + // Augmentation extends Incoming["shape"], + // NewOutput extends { + // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation + // ? Augmentation[k]["_output"] + // : k extends keyof Output + // ? Output[k] + // : never; + // }, + // NewInput extends { + // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation + // ? Augmentation[k]["_input"] + // : k extends keyof Input + // ? Input[k] + // : never; + // } + // >( + // merging: Incoming + // ): ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"], + // NewOutput, + // NewInput + // > { + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + setKey(key, schema) { + return this.augment({ [key]: schema }); + } + // merge( + // merging: Incoming + // ): //ZodObject = (merging) => { + // ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"] + // > { + // // const mergedShape = objectUtil.mergeShapes( + // // this._def.shape(), + // // merging._def.shape() + // // ); + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + catchall(index) { + return new ZodObject({ + ...this._def, + catchall: index + }); + } + pick(mask) { + const shape = {}; + util.objectKeys(mask).forEach((key) => { + if (mask[key] && this.shape[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ + ...this._def, + shape: () => shape + }); + } + omit(mask) { + const shape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (!mask[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ + ...this._def, + shape: () => shape + }); + } + /** + * @deprecated + */ + deepPartial() { + return deepPartialify(this); + } + partial(mask) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + const fieldSchema = this.shape[key]; + if (mask && !mask[key]) { + newShape[key] = fieldSchema; + } else { + newShape[key] = fieldSchema.optional(); + } + }); + return new ZodObject({ + ...this._def, + shape: () => newShape + }); + } + required(mask) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (mask && !mask[key]) { + newShape[key] = this.shape[key]; + } else { + const fieldSchema = this.shape[key]; + let newField = fieldSchema; + while (newField instanceof ZodOptional) { + newField = newField._def.innerType; + } + newShape[key] = newField; + } + }); + return new ZodObject({ + ...this._def, + shape: () => newShape + }); + } + keyof() { + return createZodEnum(util.objectKeys(this.shape)); + } +} +ZodObject.create = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +ZodObject.strictCreate = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strict", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +ZodObject.lazycreate = (shape, params) => { + return new ZodObject({ + shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +class ZodUnion extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const options = this._def.options; + function handleResults(results) { + for (const result of results) { + if (result.result.status === "valid") { + return result.result; + } + } + for (const result of results) { + if (result.result.status === "dirty") { + ctx.common.issues.push(...result.ctx.common.issues); + return result.result; + } + } + const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + if (ctx.common.async) { + return Promise.all(options.map(async (option) => { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + return { + result: await option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }), + ctx: childCtx + }; + })).then(handleResults); + } else { + let dirty = void 0; + const issues = []; + for (const option of options) { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + const result = option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }); + if (result.status === "valid") { + return result; + } else if (result.status === "dirty" && !dirty) { + dirty = { result, ctx: childCtx }; + } + if (childCtx.common.issues.length) { + issues.push(childCtx.common.issues); + } + } + if (dirty) { + ctx.common.issues.push(...dirty.ctx.common.issues); + return dirty.result; + } + const unionErrors = issues.map((issues2) => new ZodError(issues2)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + } + get options() { + return this._def.options; + } +} +ZodUnion.create = (types2, params) => { + return new ZodUnion({ + options: types2, + typeName: ZodFirstPartyTypeKind.ZodUnion, + ...processCreateParams(params) + }); +}; +const getDiscriminator = (type2) => { + if (type2 instanceof ZodLazy) { + return getDiscriminator(type2.schema); + } else if (type2 instanceof ZodEffects) { + return getDiscriminator(type2.innerType()); + } else if (type2 instanceof ZodLiteral) { + return [type2.value]; + } else if (type2 instanceof ZodEnum) { + return type2.options; + } else if (type2 instanceof ZodNativeEnum) { + return Object.keys(type2.enum); + } else if (type2 instanceof ZodDefault) { + return getDiscriminator(type2._def.innerType); + } else if (type2 instanceof ZodUndefined) { + return [void 0]; + } else if (type2 instanceof ZodNull) { + return [null]; + } else { + return null; + } +}; +class ZodDiscriminatedUnion extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }); + return INVALID; + } + const discriminator = this.discriminator; + const discriminatorValue = ctx.data[discriminator]; + const option = this.optionsMap.get(discriminatorValue); + if (!option) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union_discriminator, + options: Array.from(this.optionsMap.keys()), + path: [discriminator] + }); + return INVALID; + } + if (ctx.common.async) { + return option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } else { + return option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } + } + get discriminator() { + return this._def.discriminator; + } + get options() { + return this._def.options; + } + get optionsMap() { + return this._def.optionsMap; + } + /** + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must + * have a different value for each object in the union. + * @param discriminator the name of the discriminator property + * @param types an array of object schemas + * @param params + */ + static create(discriminator, options, params) { + const optionsMap = /* @__PURE__ */ new Map(); + for (const type2 of options) { + const discriminatorValues = getDiscriminator(type2.shape[discriminator]); + if (!discriminatorValues) { + throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); + } + for (const value of discriminatorValues) { + if (optionsMap.has(value)) { + throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); + } + optionsMap.set(value, type2); + } + } + return new ZodDiscriminatedUnion({ + typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, + discriminator, + options, + optionsMap, + ...processCreateParams(params) + }); + } +} +function mergeValues(a3, b3) { + const aType = getParsedType(a3); + const bType = getParsedType(b3); + if (a3 === b3) { + return { valid: true, data: a3 }; + } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) { + const bKeys = util.objectKeys(b3); + const sharedKeys = util.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1); + const newObj = { ...a3, ...b3 }; + for (const key of sharedKeys) { + const sharedValue = mergeValues(a3[key], b3[key]); + if (!sharedValue.valid) { + return { valid: false }; + } + newObj[key] = sharedValue.data; + } + return { valid: true, data: newObj }; + } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { + if (a3.length !== b3.length) { + return { valid: false }; + } + const newArray = []; + for (let index = 0; index < a3.length; index++) { + const itemA = a3[index]; + const itemB = b3[index]; + const sharedValue = mergeValues(itemA, itemB); + if (!sharedValue.valid) { + return { valid: false }; + } + newArray.push(sharedValue.data); + } + return { valid: true, data: newArray }; + } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a3 === +b3) { + return { valid: true, data: a3 }; + } else { + return { valid: false }; + } +} +class ZodIntersection extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const handleParsed = (parsedLeft, parsedRight) => { + if (isAborted(parsedLeft) || isAborted(parsedRight)) { + return INVALID; + } + const merged = mergeValues(parsedLeft.value, parsedRight.value); + if (!merged.valid) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_intersection_types + }); + return INVALID; + } + if (isDirty(parsedLeft) || isDirty(parsedRight)) { + status.dirty(); + } + return { status: status.value, value: merged.data }; + }; + if (ctx.common.async) { + return Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)); + } else { + return handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); + } + } +} +ZodIntersection.create = (left, right, params) => { + return new ZodIntersection({ + left, + right, + typeName: ZodFirstPartyTypeKind.ZodIntersection, + ...processCreateParams(params) + }); +}; +class ZodTuple extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (ctx.data.length < this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + return INVALID; + } + const rest = this._def.rest; + if (!rest && ctx.data.length > this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + status.dirty(); + } + const items = [...ctx.data].map((item, itemIndex) => { + const schema = this._def.items[itemIndex] || this._def.rest; + if (!schema) + return null; + return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)); + }).filter((x2) => !!x2); + if (ctx.common.async) { + return Promise.all(items).then((results) => { + return ParseStatus.mergeArray(status, results); + }); + } else { + return ParseStatus.mergeArray(status, items); + } + } + get items() { + return this._def.items; + } + rest(rest) { + return new ZodTuple({ + ...this._def, + rest + }); + } +} +ZodTuple.create = (schemas, params) => { + if (!Array.isArray(schemas)) { + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + } + return new ZodTuple({ + items: schemas, + typeName: ZodFirstPartyTypeKind.ZodTuple, + rest: null, + ...processCreateParams(params) + }); +}; +class ZodRecord extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }); + return INVALID; + } + const pairs = []; + const keyType = this._def.keyType; + const valueType = this._def.valueType; + for (const key in ctx.data) { + pairs.push({ + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) + }); + } + if (ctx.common.async) { + return ParseStatus.mergeObjectAsync(status, pairs); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } + } + get element() { + return this._def.valueType; + } + static create(first, second, third) { + if (second instanceof ZodType) { + return new ZodRecord({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(third) + }); + } + return new ZodRecord({ + keyType: ZodString.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(second) + }); + } +} +class ZodMap extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.map) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.map, + received: ctx.parsedType + }); + return INVALID; + } + const keyType = this._def.keyType; + const valueType = this._def.valueType; + const pairs = [...ctx.data.entries()].map(([key, value], index) => { + return { + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])), + value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"])) + }; + }); + if (ctx.common.async) { + const finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (const pair of pairs) { + const key = await pair.key; + const value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + const finalMap = /* @__PURE__ */ new Map(); + for (const pair of pairs) { + const key = pair.key; + const value = pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } + } +} +ZodMap.create = (keyType, valueType, params) => { + return new ZodMap({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind.ZodMap, + ...processCreateParams(params) + }); +}; +class ZodSet extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.set) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.set, + received: ctx.parsedType + }); + return INVALID; + } + const def = this._def; + if (def.minSize !== null) { + if (ctx.data.size < def.minSize.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.minSize.message + }); + status.dirty(); + } + } + if (def.maxSize !== null) { + if (ctx.data.size > def.maxSize.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.maxSize.message + }); + status.dirty(); + } + } + const valueType = this._def.valueType; + function finalizeSet(elements2) { + const parsedSet = /* @__PURE__ */ new Set(); + for (const element of elements2) { + if (element.status === "aborted") + return INVALID; + if (element.status === "dirty") + status.dirty(); + parsedSet.add(element.value); + } + return { status: status.value, value: parsedSet }; + } + const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2))); + if (ctx.common.async) { + return Promise.all(elements).then((elements2) => finalizeSet(elements2)); + } else { + return finalizeSet(elements); + } + } + min(minSize, message) { + return new ZodSet({ + ...this._def, + minSize: { value: minSize, message: errorUtil.toString(message) } + }); + } + max(maxSize, message) { + return new ZodSet({ + ...this._def, + maxSize: { value: maxSize, message: errorUtil.toString(message) } + }); + } + size(size, message) { + return this.min(size, message).max(size, message); + } + nonempty(message) { + return this.min(1, message); + } +} +ZodSet.create = (valueType, params) => { + return new ZodSet({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind.ZodSet, + ...processCreateParams(params) + }); +}; +class ZodFunction extends ZodType { + constructor() { + super(...arguments); + this.validate = this.implement; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.function) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.function, + received: ctx.parsedType + }); + return INVALID; + } + function makeArgsIssue(args, error) { + return makeIssue({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode.invalid_arguments, + argumentsError: error + } + }); + } + function makeReturnsIssue(returns, error) { + return makeIssue({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode.invalid_return_type, + returnTypeError: error + } + }); + } + const params = { errorMap: ctx.common.contextualErrorMap }; + const fn = ctx.data; + if (this._def.returns instanceof ZodPromise) { + return OK(async (...args) => { + const error = new ZodError([]); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { + error.addIssue(makeArgsIssue(args, e2)); + throw error; + }); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { + error.addIssue(makeReturnsIssue(result, e2)); + throw error; + }); + return parsedReturns; + }); + } else { + return OK((...args) => { + const parsedArgs = this._def.args.safeParse(args, params); + if (!parsedArgs.success) { + throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); + } + const result = fn(...parsedArgs.data); + const parsedReturns = this._def.returns.safeParse(result, params); + if (!parsedReturns.success) { + throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); + } + return parsedReturns.data; + }); + } + } + parameters() { + return this._def.args; + } + returnType() { + return this._def.returns; + } + args(...items) { + return new ZodFunction({ + ...this._def, + args: ZodTuple.create(items).rest(ZodUnknown.create()) + }); + } + returns(returnType) { + return new ZodFunction({ + ...this._def, + returns: returnType + }); + } + implement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + strictImplement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + static create(args, returns, params) { + return new ZodFunction({ + args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()), + returns: returns || ZodUnknown.create(), + typeName: ZodFirstPartyTypeKind.ZodFunction, + ...processCreateParams(params) + }); + } +} +class ZodLazy extends ZodType { + get schema() { + return this._def.getter(); + } + _parse(input) { + const { ctx } = this._processInputParams(input); + const lazySchema = this._def.getter(); + return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + } +} +ZodLazy.create = (getter, params) => { + return new ZodLazy({ + getter, + typeName: ZodFirstPartyTypeKind.ZodLazy, + ...processCreateParams(params) + }); +}; +class ZodLiteral extends ZodType { + _parse(input) { + if (input.data !== this._def.value) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_literal, + expected: this._def.value + }); + return INVALID; + } + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } +} +ZodLiteral.create = (value, params) => { + return new ZodLiteral({ + value, + typeName: ZodFirstPartyTypeKind.ZodLiteral, + ...processCreateParams(params) + }); +}; +function createZodEnum(values, params) { + return new ZodEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodEnum, + ...processCreateParams(params) + }); +} +class ZodEnum extends ZodType { + _parse(input) { + if (typeof input.data !== "string") { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (this._def.values.indexOf(input.data) === -1) { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); + } + get options() { + return this._def.values; + } + get enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Values() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + extract(values) { + return ZodEnum.create(values); + } + exclude(values) { + return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + } +} +ZodEnum.create = createZodEnum; +class ZodNativeEnum extends ZodType { + _parse(input) { + const nativeEnumValues = util.getValidEnumValues(this._def.values); + const ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (nativeEnumValues.indexOf(input.data) === -1) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); + } + get enum() { + return this._def.values; + } +} +ZodNativeEnum.create = (values, params) => { + return new ZodNativeEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodNativeEnum, + ...processCreateParams(params) + }); +}; +class ZodPromise extends ZodType { + unwrap() { + return this._def.type; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.promise, + received: ctx.parsedType + }); + return INVALID; + } + const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); + return OK(promisified.then((data) => { + return this._def.type.parseAsync(data, { + path: ctx.path, + errorMap: ctx.common.contextualErrorMap + }); + })); + } +} +ZodPromise.create = (schema, params) => { + return new ZodPromise({ + type: schema, + typeName: ZodFirstPartyTypeKind.ZodPromise, + ...processCreateParams(params) + }); +}; +class ZodEffects extends ZodType { + innerType() { + return this._def.schema; + } + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const effect = this._def.effect || null; + if (effect.type === "preprocess") { + const processed = effect.transform(ctx.data); + if (ctx.common.async) { + return Promise.resolve(processed).then((processed2) => { + return this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + }); + }); + } else { + return this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx + }); + } + } + const checkCtx = { + addIssue: (arg) => { + addIssueToContext(ctx, arg); + if (arg.fatal) { + status.abort(); + } else { + status.dirty(); + } + }, + get path() { + return ctx.path; + } + }; + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); + if (effect.type === "refinement") { + const executeRefinement = (acc) => { + const result = effect.refinement(acc, checkCtx); + if (ctx.common.async) { + return Promise.resolve(result); + } + if (result instanceof Promise) { + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + } + return acc; + }; + if (ctx.common.async === false) { + const inner = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + executeRefinement(inner.value); + return { status: status.value, value: inner.value }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + return executeRefinement(inner.value).then(() => { + return { status: status.value, value: inner.value }; + }); + }); + } + } + if (effect.type === "transform") { + if (ctx.common.async === false) { + const base3 = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (!isValid(base3)) + return base3; + const result = effect.transform(base3.value, checkCtx); + if (result instanceof Promise) { + throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + } + return { status: status.value, value: result }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { + if (!isValid(base3)) + return base3; + return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); + }); + } + } + util.assertNever(effect); + } +} +ZodEffects.create = (schema, effect, params) => { + return new ZodEffects({ + schema, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect, + ...processCreateParams(params) + }); +}; +ZodEffects.createWithPreprocess = (preprocess, schema, params) => { + return new ZodEffects({ + schema, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind.ZodEffects, + ...processCreateParams(params) + }); +}; +class ZodOptional extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.undefined) { + return OK(void 0); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } +} +ZodOptional.create = (type2, params) => { + return new ZodOptional({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodOptional, + ...processCreateParams(params) + }); +}; +class ZodNullable extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.null) { + return OK(null); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } +} +ZodNullable.create = (type2, params) => { + return new ZodNullable({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodNullable, + ...processCreateParams(params) + }); +}; +class ZodDefault extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + let data = ctx.data; + if (ctx.parsedType === ZodParsedType.undefined) { + data = this._def.defaultValue(); + } + return this._def.innerType._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + removeDefault() { + return this._def.innerType; + } +} +ZodDefault.create = (type2, params) => { + return new ZodDefault({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodDefault, + defaultValue: typeof params.default === "function" ? params.default : () => params.default, + ...processCreateParams(params) + }); +}; +class ZodCatch extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + } + }; + const result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx + } + }); + if (isAsync(result)) { + return result.then((result2) => { + return { + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + } + }) + }; + }); + } else { + return { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + } + }) + }; + } + } + removeCatch() { + return this._def.innerType; + } +} +ZodCatch.create = (type2, params) => { + return new ZodCatch({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodCatch, + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, + ...processCreateParams(params) + }); +}; +class ZodNaN extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.nan) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.nan, + received: ctx.parsedType + }); + return INVALID; + } + return { status: "valid", value: input.data }; + } +} +ZodNaN.create = (params) => { + return new ZodNaN({ + typeName: ZodFirstPartyTypeKind.ZodNaN, + ...processCreateParams(params) + }); +}; +const BRAND = Symbol("zod_brand"); +class ZodBranded extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const data = ctx.data; + return this._def.type._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + unwrap() { + return this._def.type; + } +} +class ZodPipeline extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.common.async) { + const handleAsync = async () => { + const inResult = await this._def.in._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return DIRTY(inResult.value); + } else { + return this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + }; + return handleAsync(); + } else { + const inResult = this._def.in._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return { + status: "dirty", + value: inResult.value + }; + } else { + return this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + } + } + static create(a3, b3) { + return new ZodPipeline({ + in: a3, + out: b3, + typeName: ZodFirstPartyTypeKind.ZodPipeline + }); + } +} +const custom = (check, params = {}, fatal) => { + if (check) + return ZodAny.create().superRefine((data, ctx) => { + var _a2, _b; + if (!check(data)) { + const p2 = typeof params === "function" ? params(data) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; + ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); + } + }); + return ZodAny.create(); +}; +const late = { + object: ZodObject.lazycreate +}; +var ZodFirstPartyTypeKind; +(function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; + ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; + ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; + ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; + ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; + ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; + ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; + ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; + ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; + ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; + ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; + ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; + ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; + ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; + ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; + ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; + ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; + ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; + ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; + ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; + ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; + ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; + ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; + ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; + ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; + ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; + ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; + ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; + ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; + ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; + ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; + ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; + ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; + ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; + ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; +})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); +const instanceOfType = (cls, params = { + message: `Input not instance of ${cls.name}` +}) => custom((data) => data instanceof cls, params); +const stringType = ZodString.create; +const numberType = ZodNumber.create; +const nanType = ZodNaN.create; +const bigIntType = ZodBigInt.create; +const booleanType = ZodBoolean.create; +const dateType = ZodDate.create; +const symbolType = ZodSymbol.create; +const undefinedType = ZodUndefined.create; +const nullType = ZodNull.create; +const anyType = ZodAny.create; +const unknownType = ZodUnknown.create; +const neverType = ZodNever.create; +const voidType = ZodVoid.create; +const arrayType = ZodArray.create; +const objectType = ZodObject.create; +const strictObjectType = ZodObject.strictCreate; +const unionType = ZodUnion.create; +const discriminatedUnionType = ZodDiscriminatedUnion.create; +const intersectionType = ZodIntersection.create; +const tupleType = ZodTuple.create; +const recordType = ZodRecord.create; +const mapType = ZodMap.create; +const setType = ZodSet.create; +const functionType = ZodFunction.create; +const lazyType = ZodLazy.create; +const literalType = ZodLiteral.create; +const enumType = ZodEnum.create; +const nativeEnumType = ZodNativeEnum.create; +const promiseType = ZodPromise.create; +const effectsType = ZodEffects.create; +const optionalType = ZodOptional.create; +const nullableType = ZodNullable.create; +const preprocessType = ZodEffects.createWithPreprocess; +const pipelineType = ZodPipeline.create; +const ostring = () => stringType().optional(); +const onumber = () => numberType().optional(); +const oboolean = () => booleanType().optional(); +const coerce = { + string: (arg) => ZodString.create({ ...arg, coerce: true }), + number: (arg) => ZodNumber.create({ ...arg, coerce: true }), + boolean: (arg) => ZodBoolean.create({ + ...arg, + coerce: true + }), + bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }), + date: (arg) => ZodDate.create({ ...arg, coerce: true }) +}; +const NEVER = INVALID; +var z = /* @__PURE__ */ Object.freeze({ + __proto__: null, + defaultErrorMap: errorMap, + setErrorMap, + getErrorMap, + makeIssue, + EMPTY_PATH, + addIssueToContext, + ParseStatus, + INVALID, + DIRTY, + OK, + isAborted, + isDirty, + isValid, + isAsync, + get util() { + return util; + }, + get objectUtil() { + return objectUtil; + }, + ZodParsedType, + getParsedType, + ZodType, + ZodString, + ZodNumber, + ZodBigInt, + ZodBoolean, + ZodDate, + ZodSymbol, + ZodUndefined, + ZodNull, + ZodAny, + ZodUnknown, + ZodNever, + ZodVoid, + ZodArray, + ZodObject, + ZodUnion, + ZodDiscriminatedUnion, + ZodIntersection, + ZodTuple, + ZodRecord, + ZodMap, + ZodSet, + ZodFunction, + ZodLazy, + ZodLiteral, + ZodEnum, + ZodNativeEnum, + ZodPromise, + ZodEffects, + ZodTransformer: ZodEffects, + ZodOptional, + ZodNullable, + ZodDefault, + ZodCatch, + ZodNaN, + BRAND, + ZodBranded, + ZodPipeline, + custom, + Schema: ZodType, + ZodSchema: ZodType, + late, + get ZodFirstPartyTypeKind() { + return ZodFirstPartyTypeKind; + }, + coerce, + any: anyType, + array: arrayType, + bigint: bigIntType, + boolean: booleanType, + date: dateType, + discriminatedUnion: discriminatedUnionType, + effect: effectsType, + "enum": enumType, + "function": functionType, + "instanceof": instanceOfType, + intersection: intersectionType, + lazy: lazyType, + literal: literalType, + map: mapType, + nan: nanType, + nativeEnum: nativeEnumType, + never: neverType, + "null": nullType, + nullable: nullableType, + number: numberType, + object: objectType, + oboolean, + onumber, + optional: optionalType, + ostring, + pipeline: pipelineType, + preprocess: preprocessType, + promise: promiseType, + record: recordType, + set: setType, + strictObject: strictObjectType, + string: stringType, + symbol: symbolType, + transformer: effectsType, + tuple: tupleType, + "undefined": undefinedType, + union: unionType, + unknown: unknownType, + "void": voidType, + NEVER, + ZodIssueCode, + quotelessJson, + ZodError +}); +const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; +const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; +const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; +const aleoTransitionIdRegex = /^au1[a-z0-9]{58}$/i; +const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; +const aleoFieldRegex = /^\d+field$/; +const aleoU32 = /^\d+u32$/; +const aleoU64 = /^\d+u64$/; +const zodAddress = z.string().regex(aleoAddressRegex); +const zodViewKey = z.string().regex(aleoViewKeyRegex); +const zodPrivateKey = z.string().regex(aleoPrivateKeyRegex); +z.string().regex(aleoTransitionIdRegex); +const zodTransactionId = z.string().regex(aleoTransactionIdRegex); +const zodField = z.string().regex(aleoFieldRegex); +const zodU32 = z.string().regex(aleoU32); +const zodU64 = z.string().regex(aleoU64); +var InputOutputType; +(function(InputOutputType2) { + InputOutputType2["Record"] = "record"; + InputOutputType2["OutputRecord"] = "outputRecord"; + InputOutputType2["Public"] = "public"; + InputOutputType2["Private"] = "private"; + InputOutputType2["Constant"] = "constant"; + InputOutputType2["Future"] = "future"; + InputOutputType2["ExternalRecord"] = "external_record"; +})(InputOutputType || (InputOutputType = {})); +exports.EventType = void 0; +(function(EventType) { + EventType["Deploy"] = "Deploy"; + EventType["Execute"] = "Execute"; + EventType["Send"] = "Send"; + EventType["Receive"] = "Receive"; + EventType["Join"] = "Join"; + EventType["Split"] = "Split"; + EventType["Shield"] = "Shield"; + EventType["Unshield"] = "Unshield"; + EventType["Referral"] = "Referral"; + EventType["Points"] = "Points"; + EventType["Raffle"] = "Raffle"; +})(exports.EventType || (exports.EventType = {})); +exports.EventStatus = void 0; +(function(EventStatus) { + EventStatus["Creating"] = "Creating"; + EventStatus["Pending"] = "Pending"; + EventStatus["Settled"] = "Settled"; + EventStatus["Failed"] = "Failed"; +})(exports.EventStatus || (exports.EventStatus = {})); +exports.Visibility = void 0; +(function(Visibility) { + Visibility["Private"] = "Private"; + Visibility["Public"] = "Public"; +})(exports.Visibility || (exports.Visibility = {})); +exports.Network = void 0; +(function(Network) { + Network["AleoTestnet"] = "AleoTestnet"; + Network["AleoCanarynet"] = "AleoCanarynet"; + Network["AleoMainnet"] = "AleoMainnet"; +})(exports.Network || (exports.Network = {})); +const zodEventType = z.nativeEnum(exports.EventType); +const zodEventStatus = z.nativeEnum(exports.EventStatus); +const zodNetwork = z.nativeEnum(exports.Network); +const zodVisibility = z.nativeEnum(exports.Visibility); +const wc_aleo_methods = [ + "decrypt", + "disconnect", + "getSelectedAccount", + "getBalance", + "getRecords", + "requestCreateEvent", + "getEvent", + "getEvents", + "createSharedState", + "importSharedState", + "requestSignature" +]; +const wc_required_aleo_chains = ["aleo:1"]; +const wc_optional_aleo_chains = [ + "aleo:0" + // for eventual mainnet +]; +const wc_aleo_chains = [ + ...wc_required_aleo_chains, + ...wc_optional_aleo_chains +]; +const wc_events = [ + "chainChanged", + "accountSelected", + "selectedAccountSynced", + "sharedAccountSynced" +]; +const projectId = "f0aaeffe71b636da453fce042d79d723"; +function isAndroid() { + if (typeof navigator === "undefined") { + return false; + } + return /Android/i.test(navigator.userAgent); +} +const web3modal_puzzle_props_android = { + projectId, + chains: wc_aleo_chains, + enableExplorer: true, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png" + } +}; +const web3modal_puzzle_props_default = { + projectId, + chains: wc_aleo_chains, + enableExplorer: false, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + desktopWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "", + universal: "https://walletconnect.puzzle.online/" + } + }, + { + id: "avail", + name: "Avail Wallet", + links: { + native: "avail://", + universal: "https://avail.global" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png", + avail: "https://i.imgur.com/GxNn8BO.png" + } +}; +const web3modal_puzzle_props = isAndroid() ? web3modal_puzzle_props_android : web3modal_puzzle_props_default; +const signClient_puzzleProps = { + requiredNamespaces: { + aleo: { + methods: wc_aleo_methods, + chains: web3modal_puzzle_props.chains, + events: wc_events + } + } +}; +const networkToChainId = (network, includePrefix = true) => { + let chain; + switch (network) { + case exports.Network.AleoMainnet: + chain = "aleo:0"; + break; + case exports.Network.AleoCanarynet: + chain = "aleo:0"; + break; + case exports.Network.AleoTestnet: + chain = "aleo:1"; + break; + } + return includePrefix ? chain : chain.replace("aleo:", ""); +}; +const chainIdToNetwork = (chainId) => { + switch (chainId) { + case "aleo:0": + return exports.Network.AleoCanarynet; + case "aleo:1": + return exports.Network.AleoTestnet; + } +}; +const name = "@puzzlehq/sdk-core"; +const displayName = "Puzzle SDK"; +const version = "0.4.0"; +const description = "Your portal to privacy"; +const main = "./dist/puzzle.cjs.js"; +const module$1 = "./dist/puzzle.es.js"; +const browser$1 = "./dist/puzzle.umd.js"; +const types = "./dist/types/src/index.d.ts"; +const exports$1 = { + ".": { + "import": "./dist/puzzle.es.js", + require: "./dist/puzzle.cjs.js", + browser: "./dist/puzzle.umd.js", + types: "./dist/types/src/index.d.ts" + } +}; +const type = "module"; +const scripts = { + "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", + "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, + build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", + "type-check": "tsc --noEmit" +}; +const repository = { + type: "git", + url: "git+https://github.com/puzzlehq/puzzle-sdk.git" +}; +const dependencies = { + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", + "@walletconnect/types": "^2.11.2", + "@walletconnect/utils": "^2.11.2", + debug: "^4.3.4", + events: "^3.3.0", + ws: "^8.16.0" +}; +const peerDependencies = { + buffer: "^6.0.3" +}; +const keywords = [ + "puzzle", + "cryptocurrency wallet", + "privacy", + "aleo", + "web3", + "crypto", + "typescript" +]; +const author = "Puzzle"; +const license = "ISC"; +const bugs = { + url: "https://github.com/puzzlehq/puzzle-sdk/issues" +}; +const homepage = "https://github.com/puzzlehq/puzzle-sdk#readme"; +const pkg = { + name, + displayName, + version, + description, + main, + module: module$1, + browser: browser$1, + types, + "private": false, + exports: exports$1, + type, + scripts, + repository, + dependencies, + peerDependencies, + keywords, + author, + license, + bugs, + homepage +}; +var On = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function A0(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; +} +var Pn = { exports: {} }; +/** +* [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 +*/ +(function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On : o2 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s2(u3, E2, u3).update(B2)[_3](); + }; + }, H2 = function(u3, E2, _3) { + return function(B2, R2) { + return new s2(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s2(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H2(u3, E2, "hex"); + return _3.create = function(B2) { + return new s2(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H2, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s2(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s2(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N2[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; + } + return this; + }, s2.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s2.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s2.call(this, u3, E2, _3); + } + v3.prototype = new s2(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne, Ie; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z2 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z2 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _3 = D2 ^ (Z2 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne = u3[42] << 2 | u3[43] >>> 30, Ie = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne, u3[45] = Me2 ^ ~Se2 & Ie, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne & St2, u3[47] = Se2 ^ ~Ie & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne ^ ~St2 & Ve2, u3[49] = Ie ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); +})(Pn); +const y0 = "logger/5.7.0"; +let Dn = false, Fn = false; +const Cr2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let Tn = Cr2.default, gi = null; +function w0() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; + } + return null; +} +const Un = w0(); +var Ai; +(function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; +})(Ai || (Ai = {})); +var re; +(function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; +})(re || (re = {})); +const kn = "0123456789abcdef"; +class L3 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); + } + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn > Cr2[i2]) && console.log.apply(console, r3); + } + debug(...t2) { + this._log(L3.levels.DEBUG, t2); + } + info(...t2) { + this._log(L3.levels.INFO, t2); + } + warn(...t2) { + this._log(L3.levels.WARNING, t2); + } + makeError(t2, r3, i2) { + if (Fn) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L3.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn[m3[y3] >> 4], w3 += kn[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o2 = t2; + let h4 = ""; + switch (r3) { + case re.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; + } + case re.CALL_EXCEPTION: + case re.INSUFFICIENT_FUNDS: + case re.MISSING_NEW: + case re.NONCE_EXPIRED: + case re.REPLACEMENT_UNDERPRICED: + case re.TRANSACTION_REPLACED: + case re.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; + } + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; + } + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); + } + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L3.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); + } + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); + } + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); + } + checkNormalize(t2) { + Un && this.throwError("platform missing String.prototype.normalize", L3.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un }); + } + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); + } + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L3.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L3.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); + } + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); + } + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L3.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); + } + static globalLogger() { + return gi || (gi = new L3(y0)), gi; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); + } + Fn = !!t2, Dn = !!r3; + } + static setLogLevel(t2) { + const r3 = Cr2[t2.toLowerCase()]; + if (r3 == null) { + L3.globalLogger().warn("invalid log level - " + t2); + return; + } + Tn = r3; + } + static from(t2) { + return new L3(t2); + } +} +L3.errors = re, L3.levels = Ai; +const x0 = "bytes/5.7.0", Dt = new L3(x0); +function qn(e2) { + return !!e2.toHexString; +} +function rr(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; +} +function Kn(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; +} +function ir(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; +} +function Ot2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2) && (e2 = e2.toHexString()), Qt(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr(new Uint8Array(i2)); + } + return ir(e2) ? rr(new Uint8Array(e2)) : Dt.throwArgumentError("invalid arrayify value", "value", e2); +} +function Qt(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2); +} +const bi = "0123456789abcdef"; +function Kt(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2)) + return e2.toHexString(); + if (Qt(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi[(n4 & 240) >> 4] + bi[n4 & 15]; + } + return r3; + } + return Dt.throwArgumentError("invalid hexlify value", "value", e2); +} +function oe(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt(e2) : Qt(e2) || Dt.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; +} +var Ln = { exports: {} }, I0 = {}, _0 = Object.freeze({ __proto__: null, default: I0 }), B0 = A0(_0); +(function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; + } + function o2(A2, f3, a3) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r3.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0.Buffer; + } catch { + } + o2.isBN = function(f3) { + return f3 instanceof o2 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o2.wordSize && Array.isArray(f3.words); + }, o2.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o2.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o2.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o2.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o2.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + } + this._strip(); + }; + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o2.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v3 = c2; v3 < l2; v3 += d5) + s2 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o2.prototype._move = function(f3) { + w3(f3, this); + }, o2.prototype.clone = function() { + var f3 = new o2(null); + return this.copy(f3), f3; + }, o2.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o2.prototype.inspect = y3; + } + else + o2.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s2 = I2[f3], v3 = N2[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s2 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o2.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o2.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o2.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o2.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o2.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o2.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; + } + return f3; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o2.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o2.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o2.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o2.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o2.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o2.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o2.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o2.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o2.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o2.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o2.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o2.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o2.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o2.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o2.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s2, f3.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s2 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s2] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s2] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s2, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te = d5[6] | 0, et2 = Te & 8191, rt2 = Te >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le = g3[3] | 0, vt2 = Le & 8191, mt2 = Le >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s2 = Math.imul(u3, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s2 = s2 + Math.imul(u3, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s2 = s2 + Math.imul(u3, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s2 = s2 + Math.imul(u3, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ne >>> 26) | 0, Ne &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v3 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s2 = s2 + Math.imul(u3, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v3 = v3 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s2 = s2 + Math.imul(u3, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v3 = v3 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s2 = s2 + Math.imul(u3, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v3 = v3 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s2 = s2 + Math.imul(u3, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v3 = v3 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s2 = s2 + Math.imul(u3, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v3 = v3 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s2 = s2 + Math.imul(u3, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v3 = v3 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v3 = v3 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v3 = v3 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v3 = v3 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v3 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne, x2[4] = Ie, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s2 = Math.max(0, g3 - A2.length + 1); s2 <= l2; s2++) { + var v3 = g3 - s2, k2 = A2.words[v3] | 0, u3 = f3.words[s2] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o2.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o2.prototype.mul = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o2.prototype.mulf = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o2.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o2.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o2.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o2(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o2.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o2.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v3 !== 0 || s2 >= d5); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o2.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o2.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o2.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o2.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o2.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o2.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o2.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o2.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o2.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o2.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o2.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s2; + if (a3 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v3 = 0; v3 < s2.length; v3++) + s2.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s2 && (s2.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s2 && (s2.words[u3] = E2); + } + return s2 && s2._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s2 || null, mod: d5 }; + }, o2.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o2(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o2(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o2(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o2.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o2.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o2.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o2.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o2.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o2.prototype.modn = function(f3) { + return this.modrn(f3); + }, o2.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o2.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o2.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s2), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s2 = 0, v3 = 1; !(c2.words[0] & v3) && s2 < 26; ++s2, v3 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o2.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o2.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o2.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o2.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; + } + } + return a3; + }, o2.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o2.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o2.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o2.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o2.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o2.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o2.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o2.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o2.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o2.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o2.red = function(f3) { + return new Y2(f3); + }, o2.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o2.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o2.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o2.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o2.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o2.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o2.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o2.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o2.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o2(f3, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o2(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o2._prime = function(f3) { + if (H2[f3]) + return H2[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H2[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o2._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v3 = this.pow(s2, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o2(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o2(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s2 = a3.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s2 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o2.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o2(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On); +})(Ln); +var K2 = Ln.exports; +const jn = "bignumber/5.7.0"; +var Rr = K2.BN; +const Ae = new L3(jn), wi = {}, Qn = 9007199254740991; +function C0(e2) { + return e2 != null && (V2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt(e2) || typeof e2 == "bigint" || ir(e2)); +} +let Jn = false; +class V2 { + constructor(t2, r3) { + t2 !== wi && Ae.throwError("cannot call constructor directly; use BigNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); + } + fromTwos(t2) { + return Lt(j(this).fromTwos(t2)); + } + toTwos(t2) { + return Lt(j(this).toTwos(t2)); + } + abs() { + return this._hex[0] === "-" ? V2.from(this._hex.substring(1)) : this; + } + add(t2) { + return Lt(j(this).add(j(t2))); + } + sub(t2) { + return Lt(j(this).sub(j(t2))); + } + div(t2) { + return V2.from(t2).isZero() && Wt2("division-by-zero", "div"), Lt(j(this).div(j(t2))); + } + mul(t2) { + return Lt(j(this).mul(j(t2))); + } + mod(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("division-by-zero", "mod"), Lt(j(this).umod(r3)); + } + pow(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("negative-power", "pow"), Lt(j(this).pow(r3)); + } + and(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "and"), Lt(j(this).and(r3)); + } + or(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "or"), Lt(j(this).or(r3)); + } + xor(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "xor"), Lt(j(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "mask"), Lt(j(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shl"), Lt(j(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shr"), Lt(j(this).shrn(t2)); + } + eq(t2) { + return j(this).eq(j(t2)); + } + lt(t2) { + return j(this).lt(j(t2)); + } + lte(t2) { + return j(this).lte(j(t2)); + } + gt(t2) { + return j(this).gt(j(t2)); + } + gte(t2) { + return j(this).gte(j(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j(this).isZero(); + } + toNumber() { + try { + return j(this).toNumber(); + } catch { + Wt2("overflow", "toNumber", this.toString()); + } + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { + } + return Ae.throwError("this platform does not support BigInt", L3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn || (Jn = true, Ae.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L3.errors.UNEXPECTED_ARGUMENT, {}) : Ae.throwError("BigNumber.toString does not accept parameters", L3.errors.UNEXPECTED_ARGUMENT, {})), j(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V2) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V2(wi, vr(t2)) : t2.match(/^-?[0-9]+$/) ? new V2(wi, vr(new Rr(t2))) : Ae.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt2("underflow", "BigNumber.from", t2), (t2 >= Qn || t2 <= -Qn) && Wt2("overflow", "BigNumber.from", t2), V2.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V2.from(r3.toString()); + if (ir(r3)) + return V2.from(Kt(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V2.from(i2); + } else { + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt(i2) || i2[0] === "-" && Qt(i2.substring(1)))) + return V2.from(i2); + } + return Ae.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } +} +function vr(e2) { + if (typeof e2 != "string") + return vr(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae.throwArgumentError("invalid hex", "value", e2), e2 = vr(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; +} +function Lt(e2) { + return V2.from(vr(e2)); +} +function j(e2) { + const t2 = V2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr("-" + t2.substring(3), 16) : new Rr(t2.substring(2), 16); +} +function Wt2(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae.throwError(e2, L3.errors.NUMERIC_FAULT, i2); +} +const Ht2 = new L3(jn), mr = {}, Gn = V2.from(0), Yn = V2.from(-1); +function Vn(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht2.throwError(e2, L3.errors.NUMERIC_FAULT, n4); +} +let gr = "0"; +for (; gr.length < 256; ) + gr += gr; +function xi(e2) { + if (typeof e2 != "number") + try { + e2 = V2.from(e2).toNumber(); + } catch { + } + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr.substring(0, e2) : Ht2.throwArgumentError("invalid decimal size", "decimals", e2); +} +function Mi(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + e2 = V2.from(e2); + const i2 = e2.lt(Gn); + i2 && (e2 = e2.mul(Yn)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o2 : e2 = o2 + "." + n4, i2 && (e2 = "-" + e2), e2; +} +function be(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht2.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht2.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht2.throwArgumentError("too many decimal points", "value", e2); + let o2 = n4[0], h4 = n4[1]; + for (o2 || (o2 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V2.from(o2), b3 = V2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn)), m3; +} +class dr2 { + constructor(t2, r3, i2, n4) { + t2 !== mr && Ht2.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr2) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht2.throwArgumentError("invalid fixed format", "format", t2), r3 = o2[1] !== "u", i2 = parseInt(o2[2]), n4 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht2.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o2("signed", "boolean", r3), i2 = o2("width", "number", i2), n4 = o2("decimals", "number", n4); + } + return i2 % 8 && Ht2.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht2.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr2(mr, r3, i2, n4); + } +} +class Ut3 { + constructor(t2, r3, i2, n4) { + t2 !== mr && Ht2.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht2.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht2.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut3.from("1" + gr.substring(0, t2), this.format), n4 = O0.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); + } + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht2.throwArgumentError("invalid byte width", "width", t2); + const r3 = V2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut3.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut3.fromString(Mi(t2, r3), dr2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3), n4 = be(t2, i2.decimals); + !i2.signed && n4.lt(Gn) && Vn("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n4.toTwos(i2.width).toHexString() : (o2 = n4.toHexString(), o2 = oe(o2, i2.width / 8)); + const h4 = Mi(n4, i2.decimals); + return new Ut3(mr, o2, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3); + if (Ot2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o2 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi(n4, i2.decimals); + return new Ut3(mr, o2, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut3.fromString(t2, r3); + if (ir(t2)) + return Ut3.fromBytes(t2, r3); + try { + return Ut3.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht2.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } +} +const Wn = Ut3.from(1), O0 = Ut3.from("0.5"); +var Or; +(function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; +})(Or || (Or = {})); +var nr; +(function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; +})(nr || (nr = {})); +function T0(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; +} +function Si(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; + }); + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o2 = n4.split(":"); + r3 += parseInt(o2[0], 16), i2[r3] = t2(o2[1]); + }), i2; +} +function $n(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); +} +$n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0), $n("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function U0(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot2(t2); +} +function ef(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o2, h4) { + i2.call(o2, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); + }); + }; + return n4(e2, t2), r3; +} +function k0(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; +} +function q0(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y3; H2++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H2 < o2[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; + } + }); +} +function K0(e2) { + let t2 = 0; + return () => e2[t2++]; +} +function H0(e2) { + return K0(q0(e2)); +} +function z0(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; +} +function L0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; +} +function rf(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; +} +function j0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0(t2()); + return r3; +} +function Pr(e2, t2) { + let r3 = rf(e2(), e2), i2 = e2(), n4 = rf(i2, e2), o2 = L0(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o2[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; +} +function Q0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0(r3, e2)); + } + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0(r3, e2)); + } + return k0(ef(t2)); +} +function J0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); + } + return t2; +} +function nf(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0(e2, r3).forEach((o2, h4) => i2[h4].push(o2)); + return i2; +} +function G0(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0(t2), o2 = nf(n4.length, 1 + e2, t2); + return ef(o2.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; + }); + })); +} +function Y0(e2, t2) { + let r3 = 1 + t2(); + return nf(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); +} +function V0(e2) { + let t2 = Pr(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o2 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o2, fe0f: h4, save: p2, check: b3 }; + } +} +function W0() { + return H0(U0("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); +} +const Dr = W0(); +new Set(Pr(Dr)), new Set(Pr(Dr)), Q0(Dr), V0(Dr); +const X0 = new Uint8Array(32); +X0.fill(0); +const os = new Uint8Array(32); +os.fill(0), V2.from(-1); +const ss3 = V2.from(0), as = V2.from(1); +V2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe(as.toHexString(), 32), oe(ss3.toHexString(), 32); +var se = {}, Q = {}, yr = af; +function af(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +af.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var Ii = { exports: {} }; +typeof Object.create == "function" ? Ii.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); +} : Ii.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; + } +}; +var us = yr, hs = Ii.exports; +Q.inherits = hs; +function cs(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; +} +function ls(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o2 = e2.charCodeAt(n4); + o2 < 128 ? r3[i2++] = o2 : o2 < 2048 ? (r3[i2++] = o2 >> 6 | 192, r3[i2++] = o2 & 63 | 128) : cs(e2, n4) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o2 >> 18 | 240, r3[i2++] = o2 >> 12 & 63 | 128, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128) : (r3[i2++] = o2 >> 12 | 224, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128); + } + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; +} +Q.toArray = ls; +function ds(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf(e2[r3].toString(16)); + return t2; +} +Q.toHex = ds; +function uf(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; +} +Q.htonl = uf; +function ps(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf(n4)), r3 += cf(n4.toString(16)); + } + return r3; +} +Q.toHex32 = ps; +function hf(e2) { + return e2.length === 1 ? "0" + e2 : e2; +} +Q.zero2 = hf; +function cf(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; +} +Q.zero8 = cf; +function vs(e2, t2, r3, i2) { + var n4 = r3 - t2; + us(n4 % 4 === 0); + for (var o2 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o2.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h4] = b3 >>> 0; + } + return o2; +} +Q.join32 = vs; +function ms$1(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r3[n4] = o2 >>> 24, r3[n4 + 1] = o2 >>> 16 & 255, r3[n4 + 2] = o2 >>> 8 & 255, r3[n4 + 3] = o2 & 255) : (r3[n4 + 3] = o2 >>> 24, r3[n4 + 2] = o2 >>> 16 & 255, r3[n4 + 1] = o2 >>> 8 & 255, r3[n4] = o2 & 255); + } + return r3; +} +Q.split32 = ms$1; +function gs(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; +} +Q.rotr32 = gs; +function As(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; +} +Q.rotl32 = As; +function bs(e2, t2) { + return e2 + t2 >>> 0; +} +Q.sum32 = bs; +function ys(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; +} +Q.sum32_3 = ys; +function ws(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; +} +Q.sum32_4 = ws; +function xs(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; +} +Q.sum32_5 = xs; +function Ms(e2, t2, r3, i2) { + var n4 = e2[t2], o2 = e2[t2 + 1], h4 = i2 + o2 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; +} +Q.sum64 = Ms; +function Es(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o2 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o2 >>> 0; +} +Q.sum64_hi = Es; +function Ss(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; +} +Q.sum64_lo = Ss; +function Ns(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o2 >>> 0, b3 += m3 < o2 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; +} +Q.sum64_4_hi = Ns; +function Is(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = t2 + i2 + o2 + p2; + return b3 >>> 0; +} +Q.sum64_4_lo = Is; +function _s(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o2 >>> 0, w3 += y3 < o2 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; +} +Q.sum64_5_hi = _s; +function Bs(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = t2 + i2 + o2 + p2 + m3; + return w3 >>> 0; +} +Q.sum64_5_lo = Bs; +function Cs(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; +} +Q.rotr64_hi = Cs; +function Rs(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q.rotr64_lo = Rs; +function Os(e2, t2, r3) { + return e2 >>> r3; +} +Q.shr64_hi = Os; +function Ps(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q.shr64_lo = Ps; +var fr = {}, lf = Q, Ds = yr; +function Fr() { + 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; +} +fr.BlockHash = Fr, Fr.prototype.update = function(t2, r3) { + if (t2 = lf.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; +}, Fr.prototype.digest = function(t2) { + return this.update(this._pad()), Ds(this.pending === null), this._digest(t2); +}, Fr.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n4[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 & 255; + } else + for (n4[o2++] = t2 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + return n4; +}; +var or = {}, ae = {}, Fs = Q, ue = Fs.rotr32; +function Ts(e2, t2, r3, i2) { + if (e2 === 0) + return df(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf(t2, r3, i2); + if (e2 === 2) + return pf(t2, r3, i2); +} +ae.ft_1 = Ts; +function df(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; +} +ae.ch32 = df; +function pf(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; +} +ae.maj32 = pf; +function vf(e2, t2, r3) { + return e2 ^ t2 ^ r3; +} +ae.p32 = vf; +function Us(e2) { + return ue(e2, 2) ^ ue(e2, 13) ^ ue(e2, 22); +} +ae.s0_256 = Us; +function ks(e2) { + return ue(e2, 6) ^ ue(e2, 11) ^ ue(e2, 25); +} +ae.s1_256 = ks; +function qs(e2) { + return ue(e2, 7) ^ ue(e2, 18) ^ e2 >>> 3; +} +ae.g0_256 = qs; +function Ks(e2) { + return ue(e2, 17) ^ ue(e2, 19) ^ e2 >>> 10; +} +ae.g1_256 = Ks; +var sr = Q, Hs = fr, zs = ae, _i = sr.rotl32, wr = sr.sum32, Ls = sr.sum32_5, js = zs.ft_1, mf = Hs.BlockHash, Qs = [1518500249, 1859775393, 2400959708, 3395469782]; +function he() { + if (!(this instanceof he)) + return new he(); + mf.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); +} +sr.inherits(he, mf); +var Js = he; +he.blockSize = 512, he.outSize = 160, he.hmacStrength = 80, he.padLength = 64, he.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls(_i(o2, 5), js(w3, h4, p2, b3), m3, i2[n4], Qs[w3]); + m3 = b3, b3 = p2, p2 = _i(h4, 30), h4 = o2, o2 = y3; + } + this.h[0] = wr(this.h[0], o2), this.h[1] = wr(this.h[1], h4), this.h[2] = wr(this.h[2], p2), this.h[3] = wr(this.h[3], b3), this.h[4] = wr(this.h[4], m3); +}, he.prototype._digest = function(t2) { + return t2 === "hex" ? sr.toHex32(this.h, "big") : sr.split32(this.h, "big"); +}; +var ar2 = Q, Gs = fr, ur = ae, Ys = yr, ie2 = ar2.sum32, Vs = ar2.sum32_4, Ws = ar2.sum32_5, Xs = ur.ch32, Zs = ur.maj32, $s = ur.s0_256, ta = ur.s1_256, ea = ur.g0_256, ra = ur.g1_256, gf = Gs.BlockHash, ia = [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 ce() { + if (!(this instanceof ce)) + return new ce(); + gf.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia, this.W = new Array(64); +} +ar2.inherits(ce, gf); +var Af = ce; +ce.blockSize = 512, ce.outSize = 256, ce.hmacStrength = 192, ce.padLength = 64, ce.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs(ra(i2[n4 - 2]), i2[n4 - 7], ea(i2[n4 - 15]), i2[n4 - 16]); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws(S2, ta(m3), Xs(m3, w3, y3), this.k[n4], i2[n4]), N2 = ie2($s(o2), Zs(o2, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie2(b3, I2), b3 = p2, p2 = h4, h4 = o2, o2 = ie2(I2, N2); + } + this.h[0] = ie2(this.h[0], o2), this.h[1] = ie2(this.h[1], h4), this.h[2] = ie2(this.h[2], p2), this.h[3] = ie2(this.h[3], b3), this.h[4] = ie2(this.h[4], m3), this.h[5] = ie2(this.h[5], w3), this.h[6] = ie2(this.h[6], y3), this.h[7] = ie2(this.h[7], S2); +}, ce.prototype._digest = function(t2) { + return t2 === "hex" ? ar2.toHex32(this.h, "big") : ar2.split32(this.h, "big"); +}; +var Bi = Q, bf = Af; +function ye() { + if (!(this instanceof ye)) + return new ye(); + bf.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; +} +Bi.inherits(ye, bf); +var na = ye; +ye.blockSize = 512, ye.outSize = 224, ye.hmacStrength = 192, ye.padLength = 64, ye.prototype._digest = function(t2) { + return t2 === "hex" ? Bi.toHex32(this.h.slice(0, 7), "big") : Bi.split32(this.h.slice(0, 7), "big"); +}; +var jt2 = Q, fa = fr, oa = yr, le = jt2.rotr64_hi, de = jt2.rotr64_lo, yf = jt2.shr64_hi, wf = jt2.shr64_lo, Be = jt2.sum64, Ci = jt2.sum64_hi, Ri = jt2.sum64_lo, sa = jt2.sum64_4_hi, aa = jt2.sum64_4_lo, ua = jt2.sum64_5_hi, ha = jt2.sum64_5_lo, xf = fa.BlockHash, ca = [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 ne2() { + if (!(this instanceof ne2)) + return new ne2(); + xf.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca, this.W = new Array(160); +} +jt2.inherits(ne2, xf); +var Mf = ne2; +ne2.blockSize = 1024, ne2.outSize = 512, ne2.hmacStrength = 192, ne2.padLength = 128, ne2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o2 = xa(i2[n4 - 4], i2[n4 - 3]), h4 = Ma(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya(i2[n4 - 30], i2[n4 - 29]), w3 = wa(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa(o2, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa(o2, h4, p2, b3, m3, w3, y3, S2); + } +}, ne2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o2 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa(S2, I2), W2 = ba(S2, I2), Rt2 = la(S2, I2, N2, C2, F2), Yt3 = da(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H2 = ma(n4, o2), z2 = ga(n4, o2), Pt2 = pa(n4, o2, h4, p2, b3), W2 = va(n4, o2, h4, p2, b3, m3); + var d5 = Ci(H2, z2, Pt2, W2), g3 = Ri(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci(w3, y3, a3, c2), I2 = Ri(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o2, n4 = Ci(a3, c2, d5, g3), o2 = Ri(a3, c2, d5, g3); + } + Be(this.h, 0, n4, o2), Be(this.h, 2, h4, p2), Be(this.h, 4, b3, m3), Be(this.h, 6, w3, y3), Be(this.h, 8, S2, I2), Be(this.h, 10, N2, C2), Be(this.h, 12, F2, U2), Be(this.h, 14, J2, Bt2); +}, ne2.prototype._digest = function(t2) { + return t2 === "hex" ? jt2.toHex32(this.h, "big") : jt2.split32(this.h, "big"); +}; +function la(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ ~e2 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function da(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ ~t2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function pa(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function va(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function ma(e2, t2) { + var r3 = le(e2, t2, 28), i2 = le(t2, e2, 2), n4 = le(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ga(e2, t2) { + var r3 = de(e2, t2, 28), i2 = de(t2, e2, 2), n4 = de(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Aa(e2, t2) { + var r3 = le(e2, t2, 14), i2 = le(e2, t2, 18), n4 = le(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ba(e2, t2) { + var r3 = de(e2, t2, 14), i2 = de(e2, t2, 18), n4 = de(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ya(e2, t2) { + var r3 = le(e2, t2, 1), i2 = le(e2, t2, 8), n4 = yf(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function wa(e2, t2) { + var r3 = de(e2, t2, 1), i2 = de(e2, t2, 8), n4 = wf(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function xa(e2, t2) { + var r3 = le(e2, t2, 19), i2 = le(t2, e2, 29), n4 = yf(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Ma(e2, t2) { + var r3 = de(e2, t2, 19), i2 = de(t2, e2, 29), n4 = wf(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +var Oi = Q, Ef = Mf; +function we() { + if (!(this instanceof we)) + return new we(); + Ef.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; +} +Oi.inherits(we, Ef); +var Ea = we; +we.blockSize = 1024, we.outSize = 384, we.hmacStrength = 192, we.padLength = 128, we.prototype._digest = function(t2) { + return t2 === "hex" ? Oi.toHex32(this.h.slice(0, 12), "big") : Oi.split32(this.h.slice(0, 12), "big"); +}, or.sha1 = Js, or.sha224 = na, or.sha256 = Af, or.sha384 = Ea, or.sha512 = Mf; +var Sf = {}, Xe = Q, Sa = fr, Tr = Xe.rotl32, Nf = Xe.sum32, xr = Xe.sum32_3, If = Xe.sum32_4, _f = Sa.BlockHash; +function pe() { + if (!(this instanceof pe)) + return new pe(); + _f.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; +} +Xe.inherits(pe, _f), Sf.ripemd160 = pe, pe.blockSize = 512, pe.outSize = 160, pe.hmacStrength = 192, pe.padLength = 64, pe.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o2 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o2, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf(Tr(If(i2, Bf(I2, n4, o2, h4), t2[_a[I2] + r3], Na(I2)), Ca[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr(o2, 10), o2 = n4, n4 = N2, N2 = Nf(Tr(If(b3, Bf(79 - I2, m3, w3, y3), t2[Ba[I2] + r3], Ia(I2)), Ra[I2]), S2), b3 = S2, S2 = y3, y3 = Tr(w3, 10), w3 = m3, m3 = N2; + } + N2 = xr(this.h[1], o2, y3), this.h[1] = xr(this.h[2], h4, S2), this.h[2] = xr(this.h[3], p2, b3), this.h[3] = xr(this.h[4], i2, m3), this.h[4] = xr(this.h[0], n4, w3), this.h[0] = N2; +}, pe.prototype._digest = function(t2) { + return t2 === "hex" ? Xe.toHex32(this.h, "little") : Xe.split32(this.h, "little"); +}; +function Bf(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); +} +function Na(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; +} +function Ia(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; +} +var _a = [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], Ba = [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], Ca = [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], Ra = [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], Oa = Q, Pa = yr; +function hr2(e2, t2, r3) { + if (!(this instanceof hr2)) + return new hr2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa.toArray(t2, r3)); +} +var Da = hr2; +hr2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); +}, hr2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; +}, hr2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); +}, function(e2) { + var t2 = e2; + t2.utils = Q, t2.common = fr, t2.sha = or, t2.ripemd = Sf, t2.hmac = Da, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; +}(se); +function cr(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; +} +function Fa() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var Pi = Cf; +function Cf(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +Cf.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var fe = cr(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); + } + return b3; + } + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; + } + r3.zero2 = n4; + function o2(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o2, r3.encode = function(p2, b3) { + return b3 === "hex" ? o2(p2) : p2; + }; +}), Jt = cr(function(e2, t2) { + var r3 = t2; + r3.assert = Pi, r3.toArray = fe.toArray, r3.zero2 = fe.zero2, r3.toHex = fe.toHex, r3.encode = fe.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N2 = 0; N2 < y3.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N2] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N2 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o2(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o2; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K2(b3, "hex", "le"); + } + r3.intFromLE = p2; +}), Ur = Jt.getNAF, Ta = Jt.getJSF, kr = Jt.assert; +function Ce(e2, t2) { + this.type = e2, this.p = new K2(t2.p, 16), this.red = t2.prime ? K2.red(t2.prime) : K2.mont(this.p), this.zero = new K2(0).toRed(this.red), this.one = new K2(1).toRed(this.red), this.two = new K2(2).toRed(this.red), this.n = t2.n && new K2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); +} +var Ze = Ce; +Ce.prototype.point = function() { + throw new Error("Not implemented"); +}, Ce.prototype.validate = function() { + throw new Error("Not implemented"); +}, Ce.prototype._fixedNafMul = function(t2, r3) { + kr(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur(r3, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); +}, Ce.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o2 = n4.points, h4 = Ur(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o2[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o2[w3 - 1 >> 1]) : p2 = p2.add(o2[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; +}, Ce.prototype._wnafMulAdd = function(t2, r3, i2, n4, o2) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N2 = w3 - 1, C2 = w3; + if (h4[N2] !== 1 || h4[C2] !== 1) { + b3[N2] = Ur(i2[N2], h4[N2], this._bitLength), b3[C2] = Ur(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N2].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; + } + var F2 = [r3[N2], null, null, r3[C2]]; + r3[N2].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N2].add(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())) : r3[N2].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].add(r3[C2].neg())) : (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta(i2[N2], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N2] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N2][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; + } + if (w3 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o2 ? H2 : H2.toP(); +}; +function Xt(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; +} +Ce.BasePoint = Xt, Xt.prototype.eq = function() { + throw new Error("Not implemented"); +}, Xt.prototype.validate = function() { + return this.curve.validate(this); +}, Ce.prototype.decodePoint = function(t2, r3) { + t2 = Jt.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); +}, Xt.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); +}, Xt.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); +}, Xt.prototype.encode = function(t2, r3) { + return Jt.encode(this._encode(r3), t2); +}, Xt.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; +}, Xt.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; +}, Xt.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o2 = 0; o2 < r3; o2 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; +}, Xt.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r3[o2] = r3[o2 - 1].add(n4); + return { wnd: t2, points: r3 }; +}, Xt.prototype._getBeta = function() { + return null; +}, Xt.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; +}; +var Di = cr(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; +}), Ua = Jt.assert; +function Zt2(e2) { + Ze.call(this, "short", e2), this.a = new K2(e2.a, 16).toRed(this.red), this.b = new K2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +Di(Zt2, Ze); +var ka = Zt2; +Zt2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K2(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K2(p2.a, 16), b: new K2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } +}, Zt2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K2.mont(t2), i2 = new K2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o2 = new K2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o2).fromRed(), p2 = n4.redSub(o2).fromRed(); + return [h4, p2]; +}, Zt2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o2 = new K2(1), h4 = new K2(0), p2 = new K2(0), b3 = new K2(1), m3, w3, y3, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o2, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o2, o2 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m3, N2 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y3, b: S2 }, { a: I2, b: N2 }]; +}, Zt2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o2 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b3 = h4.mul(n4.a), m3 = o2.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; +}, Zt2.prototype.pointFromX = function(t2, r3) { + t2 = new K2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n4.fromRed().isOdd(); + return (r3 && !o2 || !r3 && o2) && (n4 = n4.redNeg()), this.point(t2, n4); +}, Zt2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o2 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; +}, Zt2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o2 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o2[h4 * 2] = p2.k1, o2[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o2, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o2[y3] = null; + return w3; +}; +function Ft(e2, t2, r3, i2) { + Ze.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); +} +Di(Ft, Ze.BasePoint), Zt2.prototype.point = function(t2, r3, i2) { + return new Ft(this, t2, r3, i2); +}, Zt2.prototype.pointFromJSON = function(t2, r3) { + return Ft.fromJSON(this, t2, r3); +}, Ft.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } +}, Ft.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; +}, Ft.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o2)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o2)) } }, n4; +}, Ft.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Ft.prototype.isInfinity = function() { + return this.inf; +}, Ft.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); +}, Ft.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); +}, Ft.prototype.getX = function() { + return this.x.fromRed(); +}, Ft.prototype.getY = function() { + return this.y.fromRed(); +}, Ft.prototype.mul = function(t2) { + return t2 = new K2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); +}, Ft.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2) : this.curve._wnafMulAdd(1, n4, o2, 2); +}, Ft.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2, true) : this.curve._wnafMulAdd(1, n4, o2, 2, true); +}, Ft.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); +}, Ft.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o2) { + return o2.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; +}, Ft.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; +}; +function Tt(e2, t2, r3, i2) { + Ze.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K2(0)) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), this.z = new K2(i2, 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; +} +Di(Tt, Ze.BasePoint), Zt2.prototype.jpoint = function(t2, r3, i2) { + return new Tt(this, t2, r3, i2); +}, Tt.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); +}, Tt.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}, Tt.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o2 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o2), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N2 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N2, C2); +}, Tt.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o2 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o2.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o2.redMul(w3)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); +}, Tt.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o2 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N2 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o2), b3); +}, Tt.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}, Tt.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r3 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o2 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o2)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N2, C2); +}, Tt.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h4 = o2.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o2.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N2); +}, Tt.prototype.mul = function(t2, r3) { + return t2 = new K2(t2, r3), this.curve._wnafMul(this, t2); +}, Tt.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n4)).cmpn(0) === 0; +}, Tt.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o2 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } +}, Tt.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Tt.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var qr = cr(function(e2, t2) { + var r3 = t2; + r3.base = Ze, r3.short = ka, r3.mont = null, r3.edwards = null; +}), Kr = cr(function(e2, t2) { + var r3 = t2, i2 = Jt.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr.short(p2) : p2.type === "edwards" ? this.curve = new qr.edwards(p2) : this.curve = new qr.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o2(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o2("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: se.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se.sha384, gRed: false, 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"] }), o2("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: se.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se.sha256, gRed: false, g: ["9"] }), o2("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: se.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o2("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: se.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); +}); +function Re(e2) { + if (!(this instanceof Re)) + return new Re(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe.toArray(e2.pers, e2.persEnc || "hex"); + Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); +} +var Rf = Re; +Re.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; +}, Re.prototype._hmac = function() { + return new se.hmac(this.hash, this.K); +}, Re.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); +}, Re.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe.toArray(t2, r3), i2 = fe.toArray(i2, n4), Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; +}, Re.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h4 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe.encode(h4, r3); +}; +var Fi = Jt.assert; +function kt2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); +} +var Ti = kt2; +kt2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { pub: r3, pubEnc: i2 }); +}, kt2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { priv: r3, privEnc: i2 }); +}, kt2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; +}, kt2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; +}, kt2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; +}, kt2.prototype._importPrivate = function(t2, r3) { + this.priv = new K2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); +}, kt2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); +}, kt2.prototype.derive = function(t2) { + return t2.validate() || Fi(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); +}, kt2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); +}, kt2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); +}, kt2.prototype.inspect = function() { + return ""; +}; +var qa = Jt.assert; +function Hr(e2, t2) { + if (e2 instanceof Hr) + return e2; + this._importDER(e2, t2) || (qa(e2.r && e2.s, "Signature without r or s"), this.r = new K2(e2.r, 16), this.s = new K2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); +} +var zr = Hr; +function Ka() { + this.place = 0; +} +function Ui(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o2 = 0, h4 = t2.place; o2 < i2; o2++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); +} +function Of(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); +} +Hr.prototype._importDER = function(t2, r3) { + t2 = Jt.toArray(t2, r3); + var i2 = new Ka(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui(t2, i2); + if (o2 === false) + return false; + var h4 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K2(h4), this.s = new K2(b3), this.recoveryParam = null, true; +}; +function ki(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); +} +Hr.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of(r3), i2 = Of(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki(n4, i2.length); + var o2 = n4.concat(i2), h4 = [48]; + return ki(h4, o2.length), h4 = h4.concat(o2), Jt.encode(h4, t2); +}; +var Ha = function() { + throw new Error("unsupported"); +}, Pf = Jt.assert; +function $t(e2) { + if (!(this instanceof $t)) + return new $t(e2); + typeof e2 == "string" && (Pf(Object.prototype.hasOwnProperty.call(Kr, e2), "Unknown curve " + e2), e2 = Kr[e2]), e2 instanceof Kr.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; +} +var za = $t; +$t.prototype.keyPair = function(t2) { + return new Ti(this, t2); +}, $t.prototype.keyFromPrivate = function(t2, r3) { + return Ti.fromPrivate(this, t2, r3); +}, $t.prototype.keyFromPublic = function(t2, r3) { + return Ti.fromPublic(this, t2, r3); +}, $t.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K2(2)); ; ) { + var o2 = new K2(r3.generate(i2)); + if (!(o2.cmp(n4) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } +}, $t.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; +}, $t.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K2(t2, 16)); + for (var o2 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b3 = new Rf({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N2.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr({ r: N2, s: C2, recoveryParam: F2 }); + } + } + } + } + } +}, $t.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr(r3, "hex"); + var o2 = r3.r, h4 = r3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o2).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o2)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o2) === 0); +}, $t.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr(t2, i2); + var n4 = this.n, o2 = new K2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o2).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); +}, $t.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; + } + if (o2.eq(r3)) + return n4; + } + throw new Error("Unable to find valid recovery factor"); +}; +var La = cr(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr, r3.curves = Kr, r3.ec = za, r3.eddsa = null; +}); +La.ec; +var Ff; +(function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; +})(Ff || (Ff = {})); +const go = { 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 } }; +function tr(e2, t2) { + const { message: r3, code: i2 } = go[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; +} +const emitter = new EventEmitter$1(); +exports.connection = void 0; +async function configureConnection(options) { + let disconnectSessions = false; + const thisVersion = pkg.version; + const prevVersion = localStorage.getItem("puzzle_sdk_version"); + if (thisVersion !== prevVersion) { + console.log( + `${pkg.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" + ); + localStorage.setItem("puzzle_sdk_version", thisVersion); + disconnectSessions = true; + } + exports.connection = new G({ + projectId: options.projectId ?? projectId, + metadata: { + name: options.dAppName, + description: options.dAppDescription, + url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", + icons: [options.dAppIconURL] + }, + modalOptions: { ...web3modal_puzzle_props } + }); + if (disconnectSessions) { + localStorage.removeItem("puzzle-hasInjectedConnection"); + try { + disconnectOnVersionChange(exports.connection, options.onDisconnect); + } catch (e2) { + console.error(e2); + } + } + exports.connection.onSessionDelete(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + exports.connection.onSessionExpire(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + if (typeof window !== "undefined") { + window.puzzleSdkConnection = exports.connection; + } + return exports.connection; +} +async function disconnectOnVersionChange(connection2, onDisconnect) { + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (session) { + console.log("Disconnecting session", session); + onDisconnect && onDisconnect(); + connection2.disconnect({ + topic: session.topic, + reason: tr("USER_DISCONNECTED") + }); + } +} +async function getWalletConnectModalSignClient() { + return new Promise((resolve) => { + if (exports.connection) { + resolve(exports.connection); + } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { + resolve(window.puzzleSdkConnection); + } else { + const interval = setInterval(() => { + if (exports.connection) { + clearInterval(interval); + resolve(exports.connection); + } + }, 200); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + }); +} +const checkForDesktopConnection = async (sessionTopic) => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + try { + const res = await window.aleo.puzzleWalletClient.isConnected.query( + { sessionTopic } + ); + if (res) { + localStorage.setItem("puzzle-hasInjectedConnection", "true"); + return true; + } else { + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + } catch (e2) { + console.warn(e2); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } +}; +const hasInjectedConnection = () => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + return false; + } + const puzzleHasDesktopConnection = localStorage.getItem( + "puzzle-hasInjectedConnection" + ); + return puzzleHasDesktopConnection === "true"; +}; +const getAccount = async (network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await connection.getSession(); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getSelectedAccount" + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getSelectedAccount.query(query); + return response; + } catch (e2) { + console.error("getAccount error", e2); + return { error: e2.message }; + } + } + try { + const response = await connection.request(query); + return response; + } catch (e2) { + console.error("getAccount error", e2); + const error = e2.message; + return { error }; + } +}; +const getBalance = async ({ + address, + network +}) => { + const connection = await getWalletConnectModalSignClient(); + const session = await connection.getSession(); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getBalance", + params: { + address + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getBalance.query(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); + return { error }; + } + } + try { + const response = await connection.request(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); + return { error }; + } +}; +const connect = async (showModal = true) => { + const connection = await getWalletConnectModalSignClient(); + if (!connection) { + throw new Error("call configureConnection() first!"); + } + const existingSession = await connection.getSession(); + if (existingSession) { + console.log("Already connected!", existingSession); + return existingSession; + } + try { + const newSession = await connection.connect({ + requiredNamespaces: { + aleo: { + methods: wc_aleo_methods, + chains: wc_required_aleo_chains, + events: wc_events + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains, + methods: wc_aleo_methods, + events: wc_events + } + } + }, showModal); + emitter.emit("session_change"); + if (newSession) { + await checkForDesktopConnection(newSession.topic); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + return newSession; + } catch (e2) { + console.error("connect error", e2); + } +}; +const requestCreateEvent = async (requestData, network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { + if (typeof input === "string") { + return input; + } + return input.plaintext; + }); + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + try { + const response = await connection.request({ + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "requestCreateEvent", + params: { + ...requestData, + inputs + } + } + }); + return response; + } catch (e2) { + console.error("createEvent error", e2); + const error = e2.message; + return { error }; + } +}; +const createSharedState = async (network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "createSharedState", + params: {} + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.createSharedState.mutate(query); + return response; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; + return { error }; + } + } + try { + const response = await connection.request(query); + return response; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; + return { error }; + } +}; +const decrypt = async (ciphertexts, network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "decrypt", + params: { + ciphertexts + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.decrypt.query(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("decrypt error", e2); + return { error }; + } + } + try { + const response = await connection.request(query); + return response; + } catch (e2) { + console.error("decrypt error", e2); + return { error: e2.message }; + } +}; +const disconnect = async () => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + try { + try { + await connection.disconnect({ + reason: tr("USER_DISCONNECTED"), + topic: session.topic + }); + localStorage.removeItem("puzzle-hasInjectedConnection"); + emitter.emit("session_change"); + } catch (e2) { + console.warn(e2); + } + return {}; + } catch (e2) { + console.error("error disconnecting", e2); + const error = e2.message; + return { error }; + } +}; +const getEvent = async ({ + id, + address, + network +}) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { event: void 0, error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getEvent", + params: { + id, + address + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getEvent.query(query); + return response; + } catch (e2) { + console.error("getEvent error", e2); + const error = e2.message; + return { error }; + } + } + const fetchEvent = async () => { + const response = await connection.request(query); + return response; + }; + try { + const response = await fetchEvent(); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } +}; +const getEvents = async (filter, network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { events: void 0, error: "no session or connection" }; + } + if ((filter == null ? void 0 : filter.programId) === "") { + filter.programId = void 0; + } + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getEvents", + params: { + filter, + page: 0 + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getEvents.query(query); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } + } + const fetchPage = async (page = 0) => { + const response = await connection.request(query); + return response; + }; + try { + const response = await fetchPage(); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } +}; +const importSharedState = async (seed, network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "importSharedState", + params: { + seed + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.importSharedState.mutate(query); + return response; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; + return { error }; + } + } + try { + const response = await connection.request(query); + return response; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; + return { error }; + } +}; +const getRecords = async ({ + address, + filter, + page = 0, + network +}) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getRecords", + params: { + address, + filter, + page + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getRecords.query(query); + return response; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; + return { error }; + } + } + const fetchPage = async (page2 = 0) => { + const response = await connection.request(query); + return response; + }; + try { + const response = await fetchPage(); + return response; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; + return { error }; + } +}; +const requestSignature = async ({ + message, + address, + network, + method +}) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + try { + const response = await connection.request({ + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "requestSignature", + params: { + message, + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method + } + } + }); + return response; + } catch (e2) { + console.error("signature error", e2); + const error = e2.message; + return { error }; + } +}; +const PAGE_SIZE = 20; +var browser = { exports: {} }; +var ms; +var hasRequiredMs; +function requireMs() { + if (hasRequiredMs) + return ms; + hasRequiredMs = 1; + var s2 = 1e3; + var m3 = s2 * 60; + var h4 = m3 * 60; + var d5 = h4 * 24; + var w3 = d5 * 7; + var y3 = d5 * 365.25; + ms = function(val, options) { + options = options || {}; + var type2 = typeof val; + if (type2 === "string" && val.length > 0) { + return parse(val); + } else if (type2 === "number" && isFinite(val)) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + "val is not a non-empty string or a valid number. val=" + JSON.stringify(val) + ); + }; + function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n4 = parseFloat(match[1]); + var type2 = (match[2] || "ms").toLowerCase(); + switch (type2) { + case "years": + case "year": + case "yrs": + case "yr": + case "y": + return n4 * y3; + case "weeks": + case "week": + case "w": + return n4 * w3; + case "days": + case "day": + case "d": + return n4 * d5; + case "hours": + case "hour": + case "hrs": + case "hr": + case "h": + return n4 * h4; + case "minutes": + case "minute": + case "mins": + case "min": + case "m": + return n4 * m3; + case "seconds": + case "second": + case "secs": + case "sec": + case "s": + return n4 * s2; + case "milliseconds": + case "millisecond": + case "msecs": + case "msec": + case "ms": + return n4; + default: + return void 0; + } + } + function fmtShort(ms2) { + var msAbs = Math.abs(ms2); + if (msAbs >= d5) { + return Math.round(ms2 / d5) + "d"; + } + if (msAbs >= h4) { + return Math.round(ms2 / h4) + "h"; + } + if (msAbs >= m3) { + return Math.round(ms2 / m3) + "m"; + } + if (msAbs >= s2) { + return Math.round(ms2 / s2) + "s"; + } + return ms2 + "ms"; + } + function fmtLong(ms2) { + var msAbs = Math.abs(ms2); + if (msAbs >= d5) { + return plural(ms2, msAbs, d5, "day"); + } + if (msAbs >= h4) { + return plural(ms2, msAbs, h4, "hour"); + } + if (msAbs >= m3) { + return plural(ms2, msAbs, m3, "minute"); + } + if (msAbs >= s2) { + return plural(ms2, msAbs, s2, "second"); + } + return ms2 + " ms"; + } + function plural(ms2, msAbs, n4, name2) { + var isPlural = msAbs >= n4 * 1.5; + return Math.round(ms2 / n4) + " " + name2 + (isPlural ? "s" : ""); + } + return ms; +} +function setup(env2) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce2; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = requireMs(); + createDebug.destroy = destroy; + Object.keys(env2).forEach((key) => { + createDebug[key] = env2[key]; + }); + createDebug.names = []; + createDebug.skips = []; + createDebug.formatters = {}; + function selectColor(namespace) { + let hash2 = 0; + for (let i2 = 0; i2 < namespace.length; i2++) { + hash2 = (hash2 << 5) - hash2 + namespace.charCodeAt(i2); + hash2 |= 0; + } + return createDebug.colors[Math.abs(hash2) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; + function debug2(...args) { + if (!debug2.enabled) { + return; + } + const self2 = debug2; + const curr = Number(/* @__PURE__ */ new Date()); + const ms2 = curr - (prevTime || curr); + self2.diff = ms2; + self2.prev = prevTime; + self2.curr = curr; + prevTime = curr; + args[0] = createDebug.coerce(args[0]); + if (typeof args[0] !== "string") { + args.unshift("%O"); + } + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => { + if (match === "%%") { + return "%"; + } + index++; + const formatter = createDebug.formatters[format2]; + if (typeof formatter === "function") { + const val = args[index]; + match = formatter.call(self2, val); + args.splice(index, 1); + index--; + } + return match; + }); + createDebug.formatArgs.call(self2, args); + const logFn = self2.log || createDebug.log; + logFn.apply(self2, args); + } + debug2.namespace = namespace; + debug2.useColors = createDebug.useColors(); + debug2.color = createDebug.selectColor(namespace); + debug2.extend = extend; + debug2.destroy = createDebug.destroy; + Object.defineProperty(debug2, "enabled", { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + return enabledCache; + }, + set: (v3) => { + enableOverride = v3; + } + }); + if (typeof createDebug.init === "function") { + createDebug.init(debug2); + } + return debug2; + } + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; + createDebug.names = []; + createDebug.skips = []; + let i2; + const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); + const len = split.length; + for (i2 = 0; i2 < len; i2++) { + if (!split[i2]) { + continue; + } + namespaces = split[i2].replace(/\*/g, ".*?"); + if (namespaces[0] === "-") { + createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")); + } else { + createDebug.names.push(new RegExp("^" + namespaces + "$")); + } + } + } + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace) + ].join(","); + createDebug.enable(""); + return namespaces; + } + function enabled(name2) { + if (name2[name2.length - 1] === "*") { + return true; + } + let i2; + let len; + for (i2 = 0, len = createDebug.skips.length; i2 < len; i2++) { + if (createDebug.skips[i2].test(name2)) { + return false; + } + } + for (i2 = 0, len = createDebug.names.length; i2 < len; i2++) { + if (createDebug.names[i2].test(name2)) { + return true; + } + } + return false; + } + function toNamespace(regexp) { + return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*"); + } + function coerce2(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } + function destroy() { + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + createDebug.enable(createDebug.load()); + return createDebug; +} +var common = setup; +(function(module2, exports2) { + exports2.formatArgs = formatArgs; + exports2.save = save; + exports2.load = load; + exports2.useColors = useColors; + exports2.storage = localstorage(); + exports2.destroy = /* @__PURE__ */ (() => { + let warned = false; + return () => { + if (!warned) { + warned = true; + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + }; + })(); + exports2.colors = [ + "#0000CC", + "#0000FF", + "#0033CC", + "#0033FF", + "#0066CC", + "#0066FF", + "#0099CC", + "#0099FF", + "#00CC00", + "#00CC33", + "#00CC66", + "#00CC99", + "#00CCCC", + "#00CCFF", + "#3300CC", + "#3300FF", + "#3333CC", + "#3333FF", + "#3366CC", + "#3366FF", + "#3399CC", + "#3399FF", + "#33CC00", + "#33CC33", + "#33CC66", + "#33CC99", + "#33CCCC", + "#33CCFF", + "#6600CC", + "#6600FF", + "#6633CC", + "#6633FF", + "#66CC00", + "#66CC33", + "#9900CC", + "#9900FF", + "#9933CC", + "#9933FF", + "#99CC00", + "#99CC33", + "#CC0000", + "#CC0033", + "#CC0066", + "#CC0099", + "#CC00CC", + "#CC00FF", + "#CC3300", + "#CC3333", + "#CC3366", + "#CC3399", + "#CC33CC", + "#CC33FF", + "#CC6600", + "#CC6633", + "#CC9900", + "#CC9933", + "#CCCC00", + "#CCCC33", + "#FF0000", + "#FF0033", + "#FF0066", + "#FF0099", + "#FF00CC", + "#FF00FF", + "#FF3300", + "#FF3333", + "#FF3366", + "#FF3399", + "#FF33CC", + "#FF33FF", + "#FF6600", + "#FF6633", + "#FF9900", + "#FF9933", + "#FFCC00", + "#FFCC33" + ]; + function useColors() { + if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) { + return true; + } + if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 + typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker + typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); + } + function formatArgs(args) { + args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff); + if (!this.useColors) { + return; + } + const c2 = "color: " + this.color; + args.splice(1, 0, c2, "color: inherit"); + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, (match) => { + if (match === "%%") { + return; + } + index++; + if (match === "%c") { + lastC = index; + } + }); + args.splice(lastC, 0, c2); + } + exports2.log = console.debug || console.log || (() => { + }); + function save(namespaces) { + try { + if (namespaces) { + exports2.storage.setItem("debug", namespaces); + } else { + exports2.storage.removeItem("debug"); + } + } catch (error) { + } + } + function load() { + let r3; + try { + r3 = exports2.storage.getItem("debug"); + } catch (error) { + } + if (!r3 && typeof process !== "undefined" && "env" in process) { + r3 = process.env.DEBUG; + } + return r3; + } + function localstorage() { + try { + return localStorage; + } catch (error) { + } + } + module2.exports = common(exports2); + const { formatters } = module2.exports; + formatters.j = function(v3) { + try { + return JSON.stringify(v3); + } catch (error) { + return "[UnexpectedJSONParseError]: " + error.message; + } + }; +})(browser, browser.exports); +var browserExports = browser.exports; +const debug = /* @__PURE__ */ getDefaultExportFromCjs(browserExports); +const log_sdk = debug("wallet:sdk"); +log_sdk.enabled = true; +exports.PAGE_SIZE = PAGE_SIZE; +exports.R = R$1; +exports.T = T$2; +exports.aleoAddressRegex = aleoAddressRegex; +exports.aleoFieldRegex = aleoFieldRegex; +exports.aleoPrivateKeyRegex = aleoPrivateKeyRegex; +exports.aleoTransactionIdRegex = aleoTransactionIdRegex; +exports.aleoU32 = aleoU32; +exports.aleoU64 = aleoU64; +exports.aleoViewKeyRegex = aleoViewKeyRegex; +exports.chainIdToNetwork = chainIdToNetwork; +exports.checkForDesktopConnection = checkForDesktopConnection; +exports.configureConnection = configureConnection; +exports.connect = connect; +exports.createSharedState = createSharedState; +exports.decrypt = decrypt; +exports.disconnect = disconnect; +exports.emitter = emitter; +exports.getAccount = getAccount; +exports.getBalance = getBalance; +exports.getEvent = getEvent; +exports.getEvents = getEvents; +exports.getRecords = getRecords; +exports.getWalletConnectModalSignClient = getWalletConnectModalSignClient; +exports.hasInjectedConnection = hasInjectedConnection; +exports.i = i$1; +exports.importSharedState = importSharedState; +exports.log_sdk = log_sdk; +exports.ne = ne$3; +exports.networkToChainId = networkToChainId; +exports.oe = oe$2; +exports.p = p$2; +exports.projectId = projectId; +exports.requestCreateEvent = requestCreateEvent; +exports.requestSignature = requestSignature; +exports.se = se$3; +exports.signClient_puzzleProps = signClient_puzzleProps; +exports.te = te$1; +exports.wc_aleo_chains = wc_aleo_chains; +exports.wc_aleo_methods = wc_aleo_methods; +exports.wc_events = wc_events; +exports.wc_optional_aleo_chains = wc_optional_aleo_chains; +exports.wc_required_aleo_chains = wc_required_aleo_chains; +exports.web3modal_puzzle_props = web3modal_puzzle_props; +exports.web3modal_puzzle_props_android = web3modal_puzzle_props_android; +exports.web3modal_puzzle_props_default = web3modal_puzzle_props_default; +exports.y = y$4; +exports.zodAddress = zodAddress; +exports.zodEventStatus = zodEventStatus; +exports.zodEventType = zodEventType; +exports.zodField = zodField; +exports.zodNetwork = zodNetwork; +exports.zodPrivateKey = zodPrivateKey; +exports.zodTransactionId = zodTransactionId; +exports.zodU32 = zodU32; +exports.zodU64 = zodU64; +exports.zodViewKey = zodViewKey; +exports.zodVisibility = zodVisibility; diff --git a/packages/react/dist/index-B2etef5O-C677xVYO.js b/packages/core/dist/index-f3LbIFb5.js similarity index 63% rename from packages/react/dist/index-B2etef5O-C677xVYO.js rename to packages/core/dist/index-f3LbIFb5.js index 9ec97f16..fa9908b0 100644 --- a/packages/react/dist/index-B2etef5O-C677xVYO.js +++ b/packages/core/dist/index-f3LbIFb5.js @@ -1,22 +1,22 @@ -import { n as ne$1, s as se$1, T as T$1$1, o as oe$1, R as R$4, a as a$3, t as te$2, p as p$3, y as y$3 } from "./index-BqFuGgVn.js"; +import { n as ne$1, s as se$1, T as T$1, o as oe, R as R$1, i as i$4, t as te, p as p$1, y as y$1 } from "./index-CB32TCFB.js"; /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$3 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); +const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$4 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); let o$4 = class o { constructor(t2, e2, n2) { - if (this._$cssResult$ = true, n2 !== s$3) + if (this._$cssResult$ = true, n2 !== s$4) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t2, this.t = e2; } get styleSheet() { let t2 = this.o; - const s2 = this.t; + const s3 = this.t; if (e$5 && void 0 === t2) { - const e2 = void 0 !== s2 && 1 === s2.length; - e2 && (t2 = n$5.get(s2)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s2, t2)); + const e2 = void 0 !== s3 && 1 === s3.length; + e2 && (t2 = n$5.get(s3)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s3, t2)); } return t2; } @@ -24,24 +24,24 @@ let o$4 = class o { return this.cssText; } }; -const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), i$3 = (t2, ...e2) => { - const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s2, n3) => e3 + ((t3) => { +const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$4), i$3 = (t2, ...e2) => { + const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s3, n3) => e3 + ((t3) => { if (true === t3._$cssResult$) return t3.cssText; if ("number" == typeof t3) return t3; throw Error("Value passed to 'css' function must be a 'css' function result: " + t3 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); - })(s2) + t2[n3 + 1], t2[0]); - return new o$4(n2, t2, s$3); -}, S$2 = (s2, n2) => { - e$5 ? s2.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { + })(s3) + t2[n3 + 1], t2[0]); + return new o$4(n2, t2, s$4); +}, S$2 = (s3, n2) => { + e$5 ? s3.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { const n3 = document.createElement("style"), o3 = t$3.litNonce; - void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s2.appendChild(n3); + void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s3.appendChild(n3); }); -}, c$2 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { +}, c$1 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { let e2 = ""; - for (const s2 of t3.cssRules) - e2 += s2.cssText; + for (const s3 of t3.cssRules) + e2 += s3.cssText; return r$2(e2); })(t2) : t2; /** @@ -49,7 +49,7 @@ const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -var s$2; +var s$3; const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$3 = e$4.reactiveElementPolyfillSupport, n$4 = { toAttribute(t2, i2) { switch (i2) { case Boolean: @@ -61,23 +61,23 @@ const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$ } return t2; }, fromAttribute(t2, i2) { - let s2 = t2; + let s3 = t2; switch (i2) { case Boolean: - s2 = null !== t2; + s3 = null !== t2; break; case Number: - s2 = null === t2 ? null : Number(t2); + s3 = null === t2 ? null : Number(t2); break; case Object: case Array: try { - s2 = JSON.parse(t2); + s3 = JSON.parse(t2); } catch (t3) { - s2 = null; + s3 = null; } } - return s2; + return s3; } }, a$1 = (t2, i2) => i2 !== t2 && (i2 == i2 || t2 == t2), l$3 = { attribute: true, type: String, converter: n$4, reflect: false, hasChanged: a$1 }, d$1 = "finalized"; let u$1 = class u extends HTMLElement { constructor() { @@ -90,23 +90,23 @@ let u$1 = class u extends HTMLElement { static get observedAttributes() { this.finalize(); const t2 = []; - return this.elementProperties.forEach((i2, s2) => { - const e2 = this._$Ep(s2, i2); - void 0 !== e2 && (this._$Ev.set(e2, s2), t2.push(e2)); + return this.elementProperties.forEach((i2, s3) => { + const e2 = this._$Ep(s3, i2); + void 0 !== e2 && (this._$Ev.set(e2, s3), t2.push(e2)); }), t2; } static createProperty(t2, i2 = l$3) { if (i2.state && (i2.attribute = false), this.finalize(), this.elementProperties.set(t2, i2), !i2.noAccessor && !this.prototype.hasOwnProperty(t2)) { - const s2 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s2, i2); + const s3 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s3, i2); void 0 !== e2 && Object.defineProperty(this.prototype, t2, e2); } } - static getPropertyDescriptor(t2, i2, s2) { + static getPropertyDescriptor(t2, i2, s3) { return { get() { return this[i2]; }, set(e2) { const r2 = this[t2]; - this[i2] = e2, this.requestUpdate(t2, r2, s2); + this[i2] = e2, this.requestUpdate(t2, r2, s3); }, configurable: true, enumerable: true }; } static getPropertyOptions(t2) { @@ -119,32 +119,32 @@ let u$1 = class u extends HTMLElement { const t2 = Object.getPrototypeOf(this); if (t2.finalize(), void 0 !== t2.h && (this.h = [...t2.h]), this.elementProperties = new Map(t2.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { const t3 = this.properties, i2 = [...Object.getOwnPropertyNames(t3), ...Object.getOwnPropertySymbols(t3)]; - for (const s2 of i2) - this.createProperty(s2, t3[s2]); + for (const s3 of i2) + this.createProperty(s3, t3[s3]); } return this.elementStyles = this.finalizeStyles(this.styles), true; } static finalizeStyles(i2) { - const s2 = []; + const s3 = []; if (Array.isArray(i2)) { const e2 = new Set(i2.flat(1 / 0).reverse()); for (const i3 of e2) - s2.unshift(c$2(i3)); + s3.unshift(c$1(i3)); } else - void 0 !== i2 && s2.push(c$2(i2)); - return s2; + void 0 !== i2 && s3.push(c$1(i2)); + return s3; } static _$Ep(t2, i2) { - const s2 = i2.attribute; - return false === s2 ? void 0 : "string" == typeof s2 ? s2 : "string" == typeof t2 ? t2.toLowerCase() : void 0; + const s3 = i2.attribute; + return false === s3 ? void 0 : "string" == typeof s3 ? s3 : "string" == typeof t2 ? t2.toLowerCase() : void 0; } _$Eu() { var t2; this._$E_ = new Promise((t3) => this.enableUpdating = t3), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t2 = this.constructor.h) || void 0 === t2 || t2.forEach((t3) => t3(this)); } addController(t2) { - var i2, s2; - (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s2 = t2.hostConnected) || void 0 === s2 || s2.call(t2)); + var i2, s3; + (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s3 = t2.hostConnected) || void 0 === s3 || s3.call(t2)); } removeController(t2) { var i2; @@ -157,8 +157,8 @@ let u$1 = class u extends HTMLElement { } createRenderRoot() { var t2; - const s2 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); - return S$2(s2, this.constructor.elementStyles), s2; + const s3 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); + return S$2(s3, this.constructor.elementStyles), s3; } connectedCallback() { var t2; @@ -176,28 +176,28 @@ let u$1 = class u extends HTMLElement { return null === (i2 = t3.hostDisconnected) || void 0 === i2 ? void 0 : i2.call(t3); }); } - attributeChangedCallback(t2, i2, s2) { - this._$AK(t2, s2); + attributeChangedCallback(t2, i2, s3) { + this._$AK(t2, s3); } - _$EO(t2, i2, s2 = l$3) { + _$EO(t2, i2, s3 = l$3) { var e2; - const r2 = this.constructor._$Ep(t2, s2); - if (void 0 !== r2 && true === s2.reflect) { - const h2 = (void 0 !== (null === (e2 = s2.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s2.converter : n$4).toAttribute(i2, s2.type); + const r2 = this.constructor._$Ep(t2, s3); + if (void 0 !== r2 && true === s3.reflect) { + const h2 = (void 0 !== (null === (e2 = s3.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s3.converter : n$4).toAttribute(i2, s3.type); this._$El = t2, null == h2 ? this.removeAttribute(r2) : this.setAttribute(r2, h2), this._$El = null; } } _$AK(t2, i2) { - var s2; + var s3; const e2 = this.constructor, r2 = e2._$Ev.get(t2); if (void 0 !== r2 && this._$El !== r2) { - const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s2 = t3.converter) || void 0 === s2 ? void 0 : s2.fromAttribute) ? t3.converter : n$4; + const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s3 = t3.converter) || void 0 === s3 ? void 0 : s3.fromAttribute) ? t3.converter : n$4; this._$El = r2, this[r2] = h2.fromAttribute(i2, t3.type), this._$El = null; } } - requestUpdate(t2, i2, s2) { + requestUpdate(t2, i2, s3) { let e2 = true; - void 0 !== t2 && (((s2 = s2 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s2.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s2))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); + void 0 !== t2 && (((s3 = s3 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s3.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s3))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); } async _$Ej() { this.isUpdatePending = true; @@ -218,16 +218,16 @@ let u$1 = class u extends HTMLElement { return; this.hasUpdated, this._$Ei && (this._$Ei.forEach((t3, i3) => this[i3] = t3), this._$Ei = void 0); let i2 = false; - const s2 = this._$AL; + const s3 = this._$AL; try { - i2 = this.shouldUpdate(s2), i2 ? (this.willUpdate(s2), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { + i2 = this.shouldUpdate(s3), i2 ? (this.willUpdate(s3), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { var i3; return null === (i3 = t3.hostUpdate) || void 0 === i3 ? void 0 : i3.call(t3); - }), this.update(s2)) : this._$Ek(); + }), this.update(s3)) : this._$Ek(); } catch (t3) { throw i2 = false, this._$Ek(), t3; } - i2 && this._$AE(s2); + i2 && this._$AE(s3); } willUpdate(t2) { } @@ -258,34 +258,34 @@ let u$1 = class u extends HTMLElement { firstUpdated(t2) { } }; -u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$2 = e$4.reactiveElementVersions) && void 0 !== s$2 ? s$2 : e$4.reactiveElementVersions = []).push("1.6.3"); +u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$3 = e$4.reactiveElementVersions) && void 0 !== s$3 ? s$3 : e$4.reactiveElementVersions = []).push("1.6.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var t$2; -const i$2 = window, s$1 = i$2.trustedTypes, e$3 = s$1 ? s$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c$1 = Array.isArray, v$1 = (t2) => c$1(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), b = w(2), T$1 = Symbol.for("lit-noChange"), A$1 = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); -function P(t2, i2) { +const i$2 = window, s$2 = i$2.trustedTypes, e$3 = s$2 ? s$2.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s3) => ({ _$litType$: t2, strings: i2, values: s3 }), x = w(1), b$1 = w(2), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); +function P$1(t2, i2) { if (!Array.isArray(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array"); return void 0 !== e$3 ? e$3.createHTML(i2) : i2; } const V = (t2, i2) => { - const s2 = t2.length - 1, e2 = []; + const s3 = t2.length - 1, e2 = []; let l2, r2 = 2 === i2 ? "" : "", u3 = f; - for (let i3 = 0; i3 < s2; i3++) { - const s3 = t2[i3]; + for (let i3 = 0; i3 < s3; i3++) { + const s4 = t2[i3]; let d2, c2, v2 = -1, a2 = 0; - for (; a2 < s3.length && (u3.lastIndex = a2, c2 = u3.exec(s3), null !== c2); ) + for (; a2 < s4.length && (u3.lastIndex = a2, c2 = u3.exec(s4), null !== c2); ) a2 = u3.lastIndex, u3 === f ? "!--" === c2[1] ? u3 = _$1 : void 0 !== c2[1] ? u3 = m : void 0 !== c2[2] ? (y.test(c2[2]) && (l2 = RegExp("" === c2[0] ? (u3 = null != l2 ? l2 : f, v2 = -1) : void 0 === c2[1] ? v2 = -2 : (v2 = u3.lastIndex - c2[2].length, d2 = c2[1], u3 = void 0 === c2[3] ? p : '"' === c2[3] ? $ : g) : u3 === $ || u3 === g ? u3 = p : u3 === _$1 || u3 === m ? u3 = f : (u3 = p, l2 = void 0); const w2 = u3 === p && t2[i3 + 1].startsWith("/>") ? " " : ""; - r2 += u3 === f ? s3 + h$1 : v2 >= 0 ? (e2.push(d2), s3.slice(0, v2) + o$2 + s3.slice(v2) + n$3 + w2) : s3 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); + r2 += u3 === f ? s4 + h$1 : v2 >= 0 ? (e2.push(d2), s4.slice(0, v2) + o$2 + s4.slice(v2) + n$3 + w2) : s4 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); } - return [P(t2, r2 + (t2[s2] || "") + (2 === i2 ? "" : "")), e2]; + return [P$1(t2, r2 + (t2[s3] || "") + (2 === i2 ? "" : "")), e2]; }; -class N { +let N$1 = class N { constructor({ strings: t2, _$litType$: i2 }, e2) { let h2; this.parts = []; @@ -301,10 +301,10 @@ class N { const t3 = []; for (const i3 of h2.getAttributeNames()) if (i3.endsWith(o$2) || i3.startsWith(n$3)) { - const s2 = f2[d2++]; - if (t3.push(i3), void 0 !== s2) { - const t4 = h2.getAttribute(s2.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s2); - v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); + const s3 = f2[d2++]; + if (t3.push(i3), void 0 !== s3) { + const t4 = h2.getAttribute(s3.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s3); + v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H$1 : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); } else v2.push({ type: 6, index: r2 }); } @@ -314,9 +314,9 @@ class N { if (y.test(h2.tagName)) { const t3 = h2.textContent.split(n$3), i3 = t3.length - 1; if (i3 > 0) { - h2.textContent = s$1 ? s$1.emptyScript : ""; - for (let s2 = 0; s2 < i3; s2++) - h2.append(t3[s2], u2()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); + h2.textContent = s$2 ? s$2.emptyScript : ""; + for (let s3 = 0; s3 < i3; s3++) + h2.append(t3[s3], u2()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); h2.append(t3[i3], u2()); } } @@ -332,17 +332,17 @@ class N { } } static createElement(t2, i2) { - const s2 = r.createElement("template"); - return s2.innerHTML = t2, s2; + const s3 = r.createElement("template"); + return s3.innerHTML = t2, s3; } -} -function S$1(t2, i2, s2 = t2, e2) { +}; +function S$1(t2, i2, s3 = t2, e2) { var o3, n2, l2, h2; - if (i2 === T$1) + if (i2 === T) return i2; - let r2 = void 0 !== e2 ? null === (o3 = s2._$Co) || void 0 === o3 ? void 0 : o3[e2] : s2._$Cl; + let r2 = void 0 !== e2 ? null === (o3 = s3._$Co) || void 0 === o3 ? void 0 : o3[e2] : s3._$Cl; const u3 = d(i2) ? void 0 : i2._$litDirective$; - return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s2, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s2)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s2._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; + return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s3, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s3)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s3._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; } class M { constructor(t2, i2) { @@ -356,7 +356,7 @@ class M { } u(t2) { var i2; - const { el: { content: s2 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s2, true); + const { el: { content: s3 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s3, true); C.currentNode = o3; let n2 = C.nextNode(), l2 = 0, h2 = 0, u3 = e2[0]; for (; void 0 !== u3; ) { @@ -370,14 +370,14 @@ class M { } v(t2) { let i2 = 0; - for (const s2 of this._$AV) - void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++; + for (const s3 of this._$AV) + void 0 !== s3 && (void 0 !== s3.strings ? (s3._$AI(t2, s3, i2), i2 += s3.strings.length - 2) : s3._$AI(t2[i2])), i2++; } } class R { - constructor(t2, i2, s2, e2) { + constructor(t2, i2, s3, e2) { var o3; - this.type = 2, this._$AH = A$1, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; + this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s3, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; } get _$AU() { var t2, i2; @@ -395,7 +395,7 @@ class R { return this._$AB; } _$AI(t2, i2 = this) { - t2 = S$1(this, t2, i2), d(t2) ? t2 === A$1 || null == t2 || "" === t2 ? (this._$AH !== A$1 && this._$AR(), this._$AH = A$1) : t2 !== this._$AH && t2 !== T$1 && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v$1(t2) ? this.T(t2) : this._(t2); + t2 = S$1(this, t2, i2), d(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v(t2) ? this.T(t2) : this._(t2); } k(t2) { return this._$AA.parentNode.insertBefore(t2, this._$AB); @@ -404,33 +404,33 @@ class R { this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2)); } _(t2) { - this._$AH !== A$1 && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; + this._$AH !== A && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; } g(t2) { var i2; - const { values: s2, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N.createElement(P(e2.h, e2.h[0]), this.options)), e2); + const { values: s3, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N$1.createElement(P$1(e2.h, e2.h[0]), this.options)), e2); if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o3) - this._$AH.v(s2); + this._$AH.v(s3); else { const t3 = new M(o3, this), i3 = t3.u(this.options); - t3.v(s2), this.$(i3), this._$AH = t3; + t3.v(s3), this.$(i3), this._$AH = t3; } } _$AC(t2) { let i2 = E.get(t2.strings); - return void 0 === i2 && E.set(t2.strings, i2 = new N(t2)), i2; + return void 0 === i2 && E.set(t2.strings, i2 = new N$1(t2)), i2; } T(t2) { - c$1(this._$AH) || (this._$AH = [], this._$AR()); + c(this._$AH) || (this._$AH = [], this._$AR()); const i2 = this._$AH; - let s2, e2 = 0; + let s3, e2 = 0; for (const o3 of t2) - e2 === i2.length ? i2.push(s2 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s2 = i2[e2], s2._$AI(o3), e2++; - e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2); + e2 === i2.length ? i2.push(s3 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s3 = i2[e2], s3._$AI(o3), e2++; + e2 < i2.length && (this._$AR(s3 && s3._$AB.nextSibling, e2), i2.length = e2); } _$AR(t2 = this._$AA.nextSibling, i2) { - var s2; - for (null === (s2 = this._$AP) || void 0 === s2 || s2.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { + var s3; + for (null === (s3 = this._$AP) || void 0 === s3 || s3.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { const i3 = t2.nextSibling; t2.remove(), t2 = i3; } @@ -441,8 +441,8 @@ class R { } } class k { - constructor(t2, i2, s2, e2, o3) { - this.type = 1, this._$AH = A$1, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = A$1; + constructor(t2, i2, s3, e2, o3) { + this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s3.length > 2 || "" !== s3[0] || "" !== s3[1] ? (this._$AH = Array(s3.length - 1).fill(new String()), this.strings = s3) : this._$AH = A; } get tagName() { return this.element.tagName; @@ -450,59 +450,59 @@ class k { get _$AU() { return this._$AM._$AU; } - _$AI(t2, i2 = this, s2, e2) { + _$AI(t2, i2 = this, s3, e2) { const o3 = this.strings; let n2 = false; if (void 0 === o3) - t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T$1, n2 && (this._$AH = t2); + t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T, n2 && (this._$AH = t2); else { const e3 = t2; let l2, h2; for (t2 = o3[0], l2 = 0; l2 < o3.length - 1; l2++) - h2 = S$1(this, e3[s2 + l2], i2, l2), h2 === T$1 && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A$1 ? t2 = A$1 : t2 !== A$1 && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; + h2 = S$1(this, e3[s3 + l2], i2, l2), h2 === T && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A ? t2 = A : t2 !== A && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; } n2 && !e2 && this.j(t2); } j(t2) { - t2 === A$1 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); + t2 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); } } -class H extends k { +let H$1 = class H extends k { constructor() { super(...arguments), this.type = 3; } j(t2) { - this.element[this.name] = t2 === A$1 ? void 0 : t2; + this.element[this.name] = t2 === A ? void 0 : t2; } -} -const I = s$1 ? s$1.emptyScript : ""; +}; +const I = s$2 ? s$2.emptyScript : ""; let L$1 = class L extends k { constructor() { super(...arguments), this.type = 4; } j(t2) { - t2 && t2 !== A$1 ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); + t2 && t2 !== A ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); } }; class z extends k { - constructor(t2, i2, s2, e2, o3) { - super(t2, i2, s2, e2, o3), this.type = 5; + constructor(t2, i2, s3, e2, o3) { + super(t2, i2, s3, e2, o3), this.type = 5; } _$AI(t2, i2 = this) { - var s2; - if ((t2 = null !== (s2 = S$1(this, t2, i2, 0)) && void 0 !== s2 ? s2 : A$1) === T$1) + var s3; + if ((t2 = null !== (s3 = S$1(this, t2, i2, 0)) && void 0 !== s3 ? s3 : A) === T) return; - const e2 = this._$AH, o3 = t2 === A$1 && e2 !== A$1 || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A$1 && (e2 === A$1 || o3); + const e2 = this._$AH, o3 = t2 === A && e2 !== A || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A && (e2 === A || o3); o3 && this.element.removeEventListener(this.name, this, e2), n2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2; } handleEvent(t2) { - var i2, s2; - "function" == typeof this._$AH ? this._$AH.call(null !== (s2 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s2 ? s2 : this.element, t2) : this._$AH.handleEvent(t2); + var i2, s3; + "function" == typeof this._$AH ? this._$AH.call(null !== (s3 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s3 ? s3 : this.element, t2) : this._$AH.handleEvent(t2); } } let Z$1 = class Z { - constructor(t2, i2, s2) { - this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s2; + constructor(t2, i2, s3) { + this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s3; } get _$AU() { return this._$AM._$AU; @@ -512,14 +512,14 @@ let Z$1 = class Z { } }; const B$1 = i$2.litHtmlPolyfillSupport; -null == B$1 || B$1(N, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); -const D$1 = (t2, i2, s2) => { +null == B$1 || B$1(N$1, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); +const D$1 = (t2, i2, s3) => { var e2, o3; - const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2; + const n2 = null !== (e2 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== e2 ? e2 : i2; let l2 = n2._$litPart$; if (void 0 === l2) { - const t3 = null !== (o3 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== o3 ? o3 : null; - n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s2 ? s2 : {}); + const t3 = null !== (o3 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== o3 ? o3 : null; + n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s3 ? s3 : {}); } return l2._$AI(t2), l2; }; @@ -529,7 +529,7 @@ const D$1 = (t2, i2, s2) => { * SPDX-License-Identifier: BSD-3-Clause */ var l$1, o$1; -class s extends u$1 { +let s$1 = class s extends u$1 { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } @@ -551,12 +551,12 @@ class s extends u$1 { super.disconnectedCallback(), null === (t2 = this._$Do) || void 0 === t2 || t2.setConnected(false); } render() { - return T$1; + return T; } -} -s.finalized = true, s._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s }); +}; +s$1.finalized = true, s$1._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s$1 }); const n$2 = globalThis.litElementPolyfillSupport; -null == n$2 || n$2({ LitElement: s }); +null == n$2 || n$2({ LitElement: s$1 }); (null !== (o$1 = globalThis.litElementVersions) && void 0 !== o$1 ? o$1 : globalThis.litElementVersions = []).push("3.3.3"); /** * @license @@ -564,8 +564,8 @@ null == n$2 || n$2({ LitElement: s }); * SPDX-License-Identifier: BSD-3-Clause */ const e$2 = (e2) => (n2) => "function" == typeof n2 ? ((e3, n3) => (customElements.define(e3, n3), n3))(e2, n2) : ((e3, n3) => { - const { kind: t2, elements: s2 } = n3; - return { kind: t2, elements: s2, finisher(n4) { + const { kind: t2, elements: s3 } = n3; + return { kind: t2, elements: s3, finisher(n4) { customElements.define(e3, n4); } }; })(e2, n2); @@ -637,23 +637,23 @@ const o2 = e(class extends i { render(t2) { return " " + Object.keys(t2).filter((i2) => t2[i2]).join(" ") + " "; } - update(i2, [s2]) { + update(i2, [s3]) { var r2, o3; if (void 0 === this.it) { this.it = /* @__PURE__ */ new Set(), void 0 !== i2.strings && (this.nt = new Set(i2.strings.join(" ").split(/\s/).filter((t2) => "" !== t2))); - for (const t2 in s2) - s2[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); - return this.render(s2); + for (const t2 in s3) + s3[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); + return this.render(s3); } const e2 = i2.element.classList; this.it.forEach((t2) => { - t2 in s2 || (e2.remove(t2), this.it.delete(t2)); + t2 in s3 || (e2.remove(t2), this.it.delete(t2)); }); - for (const t2 in s2) { - const i3 = !!s2[t2]; + for (const t2 in s3) { + const i3 = !!s3[t2]; i3 === this.it.has(t2) || (null === (o3 = this.nt) || void 0 === o3 ? void 0 : o3.has(t2)) || (i3 ? (e2.add(t2), this.it.add(t2)) : (e2.remove(t2), this.it.delete(t2))); } - return T$1; + return T; } }); function addUniqueItem(array, item) { @@ -1213,12 +1213,8 @@ const getOptions = (options, key) => ( options[key] ? Object.assign(Object.assign({}, options), options[key]) : Object.assign({}, options) ); function resolveElements(elements, selectorCache) { - var _a; if (typeof elements === "string") { - if (selectorCache) { - (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : selectorCache[elements] = document.querySelectorAll(elements); - elements = selectorCache[elements]; - } else { + { elements = document.querySelectorAll(elements); } } else if (elements instanceof Element) { @@ -1332,7 +1328,7 @@ function animate(target, keyframesOrOptions, options) { * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const l = (l2) => null != l2 ? l2 : A$1; +const l = (l2) => null != l2 ? l2 : A; var browser = {}; var canPromise$1 = function() { return typeof Promise === "function" && Promise.prototype && Promise.prototype.then; @@ -1530,13 +1526,13 @@ var alignmentPattern = {}; const pos = exports.getRowColCoords(version2); const posLength = pos.length; for (let i2 = 0; i2 < posLength; i2++) { - for (let j2 = 0; j2 < posLength; j2++) { - if (i2 === 0 && j2 === 0 || // top-left - i2 === 0 && j2 === posLength - 1 || // bottom-left - i2 === posLength - 1 && j2 === 0) { + for (let j = 0; j < posLength; j++) { + if (i2 === 0 && j === 0 || // top-left + i2 === 0 && j === posLength - 1 || // bottom-left + i2 === posLength - 1 && j === 0) { continue; } - coords.push([pos[i2], pos[j2]]); + coords.push([pos[i2], pos[j]]); } } return coords; @@ -1655,24 +1651,24 @@ var maskPattern = {}; const k2 = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10); return k2 * PenaltyScores.N4; }; - function getMaskAt(maskPattern2, i2, j2) { + function getMaskAt(maskPattern2, i2, j) { switch (maskPattern2) { case exports.Patterns.PATTERN000: - return (i2 + j2) % 2 === 0; + return (i2 + j) % 2 === 0; case exports.Patterns.PATTERN001: return i2 % 2 === 0; case exports.Patterns.PATTERN010: - return j2 % 3 === 0; + return j % 3 === 0; case exports.Patterns.PATTERN011: - return (i2 + j2) % 3 === 0; + return (i2 + j) % 3 === 0; case exports.Patterns.PATTERN100: - return (Math.floor(i2 / 2) + Math.floor(j2 / 3)) % 2 === 0; + return (Math.floor(i2 / 2) + Math.floor(j / 3)) % 2 === 0; case exports.Patterns.PATTERN101: - return i2 * j2 % 2 + i2 * j2 % 3 === 0; + return i2 * j % 2 + i2 * j % 3 === 0; case exports.Patterns.PATTERN110: - return (i2 * j2 % 2 + i2 * j2 % 3) % 2 === 0; + return (i2 * j % 2 + i2 * j % 3) % 2 === 0; case exports.Patterns.PATTERN111: - return (i2 * j2 % 3 + (i2 + j2) % 2) % 2 === 0; + return (i2 * j % 3 + (i2 + j) % 2) % 2 === 0; default: throw new Error("bad maskPattern:" + maskPattern2); } @@ -2096,8 +2092,8 @@ galoisField.mul = function mul(x2, y2) { exports.mul = function mul2(p1, p2) { const coeff = new Uint8Array(p1.length + p2.length - 1); for (let i2 = 0; i2 < p1.length; i2++) { - for (let j2 = 0; j2 < p2.length; j2++) { - coeff[i2 + j2] ^= GF.mul(p1[i2], p2[j2]); + for (let j = 0; j < p2.length; j++) { + coeff[i2 + j] ^= GF.mul(p1[i2], p2[j]); } } return coeff; @@ -2572,12 +2568,12 @@ var kanjiData = KanjiData; var dijkstra = { exports: {} }; (function(module) { var dijkstra2 = { - single_source_shortest_paths: function(graph, s2, d2) { + single_source_shortest_paths: function(graph, s3, d2) { var predecessors = {}; var costs = {}; - costs[s2] = 0; + costs[s3] = 0; var open = dijkstra2.PriorityQueue.make(); - open.push(s2, 0); + open.push(s3, 0); var closest, u3, v2, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; while (!open.empty()) { closest = open.pop(); @@ -2599,7 +2595,7 @@ var dijkstra = { exports: {} }; } } if (typeof d2 !== "undefined" && typeof costs[d2] === "undefined") { - var msg = ["Could not find a path from ", s2, " to ", d2, "."].join(""); + var msg = ["Could not find a path from ", s3, " to ", d2, "."].join(""); throw new Error(msg); } return predecessors; @@ -2615,8 +2611,8 @@ var dijkstra = { exports: {} }; nodes.reverse(); return nodes; }, - find_path: function(graph, s2, d2) { - var predecessors = dijkstra2.single_source_shortest_paths(graph, s2, d2); + find_path: function(graph, s3, d2) { + var predecessors = dijkstra2.single_source_shortest_paths(graph, s3, d2); return dijkstra2.extract_shortest_path_from_predecessor_list( predecessors, d2 @@ -2704,8 +2700,8 @@ var dijkstraExports = dijkstra.exports; kanjiSegs = []; } const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs); - return segs.sort(function(s1, s2) { - return s1.index - s2.index; + return segs.sort(function(s1, s22) { + return s1.index - s22.index; }).map(function(obj) { return { data: obj.data, @@ -2776,9 +2772,9 @@ var dijkstraExports = dijkstra.exports; for (let i2 = 0; i2 < nodes.length; i2++) { const nodeGroup = nodes[i2]; const currentNodeIds = []; - for (let j2 = 0; j2 < nodeGroup.length; j2++) { - const node = nodeGroup[j2]; - const key = "" + i2 + j2; + for (let j = 0; j < nodeGroup.length; j++) { + const node = nodeGroup[j]; + const key = "" + i2 + j; currentNodeIds.push(key); table[key] = { node, lastCount: 0 }; graph[key] = {}; @@ -3172,12 +3168,12 @@ var utils = {}; const scaledMargin = opts.margin * scale; const palette = [opts.color.light, opts.color.dark]; for (let i2 = 0; i2 < symbolSize; i2++) { - for (let j2 = 0; j2 < symbolSize; j2++) { - let posDst = (i2 * symbolSize + j2) * 4; + for (let j = 0; j < symbolSize; j++) { + let posDst = (i2 * symbolSize + j) * 4; let pxColor = opts.color.light; - if (i2 >= scaledMargin && j2 >= scaledMargin && i2 < symbolSize - scaledMargin && j2 < symbolSize - scaledMargin) { + if (i2 >= scaledMargin && j >= scaledMargin && i2 < symbolSize - scaledMargin && j < symbolSize - scaledMargin) { const iSrc = Math.floor((i2 - scaledMargin) / scale); - const jSrc = Math.floor((j2 - scaledMargin) / scale); + const jSrc = Math.floor((j - scaledMargin) / scale); pxColor = palette[data2[iSrc * size + jSrc] ? 1 : 0]; } imgData[posDst++] = pxColor.r; @@ -3358,150 +3354,54 @@ browser.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL); browser.toString = renderCanvas.bind(null, function(data2, _2, opts) { return SvgRenderer.render(data2, opts); }); -var et = Object.defineProperty, Be = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Ue = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, ve = (e2, o3) => { +var et = Object.defineProperty, Se = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Be = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, fe = (e2, o3) => { for (var r2 in o3 || (o3 = {})) - tt.call(o3, r2) && Ue(e2, r2, o3[r2]); - if (Be) - for (var r2 of Be(o3)) - ot.call(o3, r2) && Ue(e2, r2, o3[r2]); + tt.call(o3, r2) && Be(e2, r2, o3[r2]); + if (Se) + for (var r2 of Se(o3)) + ot.call(o3, r2) && Be(e2, r2, o3[r2]); return e2; }; function rt() { var e2; - const o3 = (e2 = ne$1.state.themeMode) != null ? e2 : "dark", r2 = { - light: { - foreground: { - 1: "rgb(20,20,20)", - 2: "rgb(121,134,134)", - 3: "rgb(158,169,169)" - }, - background: { - 1: "rgb(255,255,255)", - 2: "rgb(241,243,243)", - 3: "rgb(228,231,231)" - }, - overlay: "rgba(0,0,0,0.1)" - }, - dark: { - foreground: { - 1: "rgb(228,231,231)", - 2: "rgb(148,158,158)", - 3: "rgb(110,119,119)" - }, - background: { - 1: "rgb(20,20,20)", - 2: "rgb(39,42,42)", - 3: "rgb(59,64,64)" - }, - overlay: "rgba(255,255,255,0.1)" - } - }[o3]; - return { - "--wcm-color-fg-1": r2.foreground[1], - "--wcm-color-fg-2": r2.foreground[2], - "--wcm-color-fg-3": r2.foreground[3], - "--wcm-color-bg-1": r2.background[1], - "--wcm-color-bg-2": r2.background[2], - "--wcm-color-bg-3": r2.background[3], - "--wcm-color-overlay": r2.overlay - }; + const o3 = (e2 = ne$1.state.themeMode) != null ? e2 : "dark", r2 = { light: { foreground: { 1: "rgb(20,20,20)", 2: "rgb(121,134,134)", 3: "rgb(158,169,169)" }, background: { 1: "rgb(255,255,255)", 2: "rgb(241,243,243)", 3: "rgb(228,231,231)" }, overlay: "rgba(0,0,0,0.1)" }, dark: { foreground: { 1: "rgb(228,231,231)", 2: "rgb(148,158,158)", 3: "rgb(110,119,119)" }, background: { 1: "rgb(20,20,20)", 2: "rgb(39,42,42)", 3: "rgb(59,64,64)" }, overlay: "rgba(255,255,255,0.1)" } }[o3]; + return { "--wcm-color-fg-1": r2.foreground[1], "--wcm-color-fg-2": r2.foreground[2], "--wcm-color-fg-3": r2.foreground[3], "--wcm-color-bg-1": r2.background[1], "--wcm-color-bg-2": r2.background[2], "--wcm-color-bg-3": r2.background[3], "--wcm-color-overlay": r2.overlay }; } -function He() { - return { - "--wcm-accent-color": "#3396FF", - "--wcm-accent-fill-color": "#FFFFFF", - "--wcm-z-index": "89", - "--wcm-background-color": "#3396FF", - "--wcm-background-border-radius": "8px", - "--wcm-container-border-radius": "30px", - "--wcm-wallet-icon-border-radius": "15px", - "--wcm-wallet-icon-large-border-radius": "30px", - "--wcm-wallet-icon-small-border-radius": "7px", - "--wcm-input-border-radius": "28px", - "--wcm-button-border-radius": "10px", - "--wcm-notification-border-radius": "36px", - "--wcm-secondary-button-border-radius": "28px", - "--wcm-icon-button-border-radius": "50%", - "--wcm-button-hover-highlight-border-radius": "10px", - "--wcm-text-big-bold-size": "20px", - "--wcm-text-big-bold-weight": "600", - "--wcm-text-big-bold-line-height": "24px", - "--wcm-text-big-bold-letter-spacing": "-0.03em", - "--wcm-text-big-bold-text-transform": "none", - "--wcm-text-xsmall-bold-size": "10px", - "--wcm-text-xsmall-bold-weight": "700", - "--wcm-text-xsmall-bold-line-height": "12px", - "--wcm-text-xsmall-bold-letter-spacing": "0.02em", - "--wcm-text-xsmall-bold-text-transform": "uppercase", - "--wcm-text-xsmall-regular-size": "12px", - "--wcm-text-xsmall-regular-weight": "600", - "--wcm-text-xsmall-regular-line-height": "14px", - "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", - "--wcm-text-xsmall-regular-text-transform": "none", - "--wcm-text-small-thin-size": "14px", - "--wcm-text-small-thin-weight": "500", - "--wcm-text-small-thin-line-height": "16px", - "--wcm-text-small-thin-letter-spacing": "-0.03em", - "--wcm-text-small-thin-text-transform": "none", - "--wcm-text-small-regular-size": "14px", - "--wcm-text-small-regular-weight": "600", - "--wcm-text-small-regular-line-height": "16px", - "--wcm-text-small-regular-letter-spacing": "-0.03em", - "--wcm-text-small-regular-text-transform": "none", - "--wcm-text-medium-regular-size": "16px", - "--wcm-text-medium-regular-weight": "600", - "--wcm-text-medium-regular-line-height": "20px", - "--wcm-text-medium-regular-letter-spacing": "-0.03em", - "--wcm-text-medium-regular-text-transform": "none", - "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", - "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", - "--wcm-success-color": "rgb(38,181,98)", - "--wcm-error-color": "rgb(242, 90, 103)", - "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", - "--wcm-overlay-backdrop-filter": "none" - }; +function Ue() { + return { "--wcm-accent-color": "#3396FF", "--wcm-accent-fill-color": "#FFFFFF", "--wcm-z-index": "89", "--wcm-background-color": "#3396FF", "--wcm-background-border-radius": "8px", "--wcm-container-border-radius": "30px", "--wcm-wallet-icon-border-radius": "15px", "--wcm-wallet-icon-large-border-radius": "30px", "--wcm-wallet-icon-small-border-radius": "7px", "--wcm-input-border-radius": "28px", "--wcm-button-border-radius": "10px", "--wcm-notification-border-radius": "36px", "--wcm-secondary-button-border-radius": "28px", "--wcm-icon-button-border-radius": "50%", "--wcm-button-hover-highlight-border-radius": "10px", "--wcm-text-big-bold-size": "20px", "--wcm-text-big-bold-weight": "600", "--wcm-text-big-bold-line-height": "24px", "--wcm-text-big-bold-letter-spacing": "-0.03em", "--wcm-text-big-bold-text-transform": "none", "--wcm-text-xsmall-bold-size": "10px", "--wcm-text-xsmall-bold-weight": "700", "--wcm-text-xsmall-bold-line-height": "12px", "--wcm-text-xsmall-bold-letter-spacing": "0.02em", "--wcm-text-xsmall-bold-text-transform": "uppercase", "--wcm-text-xsmall-regular-size": "12px", "--wcm-text-xsmall-regular-weight": "600", "--wcm-text-xsmall-regular-line-height": "14px", "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", "--wcm-text-xsmall-regular-text-transform": "none", "--wcm-text-small-thin-size": "14px", "--wcm-text-small-thin-weight": "500", "--wcm-text-small-thin-line-height": "16px", "--wcm-text-small-thin-letter-spacing": "-0.03em", "--wcm-text-small-thin-text-transform": "none", "--wcm-text-small-regular-size": "14px", "--wcm-text-small-regular-weight": "600", "--wcm-text-small-regular-line-height": "16px", "--wcm-text-small-regular-letter-spacing": "-0.03em", "--wcm-text-small-regular-text-transform": "none", "--wcm-text-medium-regular-size": "16px", "--wcm-text-medium-regular-weight": "600", "--wcm-text-medium-regular-line-height": "20px", "--wcm-text-medium-regular-letter-spacing": "-0.03em", "--wcm-text-medium-regular-text-transform": "none", "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", "--wcm-success-color": "rgb(38,181,98)", "--wcm-error-color": "rgb(242, 90, 103)", "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", "--wcm-overlay-backdrop-filter": "none" }; } -const h = { - getPreset(e2) { - return He()[e2]; - }, - setTheme() { - const e2 = document.querySelector(":root"), { themeVariables: o3 } = ne$1.state; - if (e2) { - const r2 = ve(ve(ve({}, rt()), He()), o3); - Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); - } - }, - globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` -}, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; -var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, F = (e2, o3, r2, a2) => { +const h = { getPreset(e2) { + return Ue()[e2]; +}, setTheme() { + const e2 = document.querySelector(":root"), { themeVariables: o3 } = ne$1.state; + if (e2) { + const r2 = fe(fe(fe({}, rt()), Ue()), o3); + Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); + } +}, globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` }, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; +var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? it(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && lt(o3, r2, t2), t2; }; -let T = class extends s { +let _ = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.iconLeft = void 0, this.iconRight = void 0, this.onClick = () => null, this.variant = "default"; } render() { - const e2 = { - "wcm-icon-left": this.iconLeft !== void 0, - "wcm-icon-right": this.iconRight !== void 0, - "wcm-ghost": this.variant === "ghost", - "wcm-outline": this.variant === "outline" - }; + const e2 = { "wcm-icon-left": this.iconLeft !== void 0, "wcm-icon-right": this.iconRight !== void 0, "wcm-ghost": this.variant === "ghost", "wcm-outline": this.variant === "outline" }; let o$12 = "inverse"; return this.variant === "ghost" && (o$12 = "secondary"), this.variant === "outline" && (o$12 = "accent"), x``; } }; -T.styles = [h.globalCss, at], F([n$1({ type: Boolean })], T.prototype, "disabled", 2), F([n$1()], T.prototype, "iconLeft", 2), F([n$1()], T.prototype, "iconRight", 2), F([n$1()], T.prototype, "onClick", 2), F([n$1()], T.prototype, "variant", 2), T = F([e$2("wcm-button")], T); +_.styles = [h.globalCss, at], K([n$1({ type: Boolean })], _.prototype, "disabled", 2), K([n$1()], _.prototype, "iconLeft", 2), K([n$1()], _.prototype, "iconRight", 2), K([n$1()], _.prototype, "onClick", 2), K([n$1()], _.prototype, "variant", 2), _ = K([e$2("wcm-button")], _); const nt = i$3`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`; -var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, ue = (e2, o3, r2, a2) => { +var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, xe = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? st(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && ct(o3, r2, t2), t2; }; -let ee = class extends s { +let re = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.variant = "primary"; } @@ -3510,203 +3410,159 @@ let ee = class extends s { return x``; } }; -ee.styles = [h.globalCss, nt], ue([n$1({ type: Boolean })], ee.prototype, "disabled", 2), ue([n$1()], ee.prototype, "variant", 2), ee = ue([e$2("wcm-button-big")], ee); +re.styles = [h.globalCss, nt], xe([n$1({ type: Boolean })], re.prototype, "disabled", 2), xe([n$1()], re.prototype, "variant", 2), re = xe([e$2("wcm-button-big")], re); const dt = i$3`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`; -var mt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, wt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && mt(o3, r2, t2), t2; +var ht = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let be = class extends s { +let ye = class extends s$1 { render() { return x`
`; } }; -be.styles = [h.globalCss, dt], be = wt([e$2("wcm-info-footer")], be); -const v = { - CROSS_ICON: b``, - WALLET_CONNECT_LOGO: b``, - WALLET_CONNECT_ICON: b``, - WALLET_CONNECT_ICON_COLORED: b``, - BACK_ICON: b``, - COPY_ICON: b``, - RETRY_ICON: b``, - DESKTOP_ICON: b``, - MOBILE_ICON: b``, - ARROW_DOWN_ICON: b``, - ARROW_UP_RIGHT_ICON: b``, - ARROW_RIGHT_ICON: b``, - QRCODE_ICON: b``, - SCAN_ICON: b``, - CHECKMARK_ICON: b``, - SEARCH_ICON: b``, - WALLET_PLACEHOLDER: b``, - GLOBE_ICON: b`` -}, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; -var gt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, ut = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? vt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && gt(o3, r2, t2), t2; +ye.styles = [h.globalCss, dt], ye = ht([e$2("wcm-info-footer")], ye); +const b = { CROSS_ICON: b$1``, WALLET_CONNECT_LOGO: b$1``, WALLET_CONNECT_ICON: b$1``, WALLET_CONNECT_ICON_COLORED: b$1``, BACK_ICON: b$1``, COPY_ICON: b$1``, RETRY_ICON: b$1``, DESKTOP_ICON: b$1``, MOBILE_ICON: b$1``, ARROW_DOWN_ICON: b$1``, ARROW_UP_RIGHT_ICON: b$1``, ARROW_RIGHT_ICON: b$1``, QRCODE_ICON: b$1``, SCAN_ICON: b$1``, CHECKMARK_ICON: b$1``, SEARCH_ICON: b$1``, WALLET_PLACEHOLDER: b$1``, GLOBE_ICON: b$1`` }, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; +var ut = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let fe = class extends s { +let $e = class extends s$1 { render() { - return x`
${v.WALLET_CONNECT_LOGO}
`; + return x`
${b.WALLET_CONNECT_LOGO}
`; } }; -fe.styles = [h.globalCss, pt], fe = ut([e$2("wcm-modal-backcard")], fe); +$e.styles = [h.globalCss, pt], $e = ut([e$2("wcm-modal-backcard")], $e); const bt = i$3`main{padding:20px;padding-top:0;width:100%}`; -var ft = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, yt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? xt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ft(o3, r2, t2), t2; +var yt = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let xe = class extends s { +let Ce = class extends s$1 { render() { return x`
`; } }; -xe.styles = [h.globalCss, bt], xe = yt([e$2("wcm-modal-content")], xe); +Ce.styles = [h.globalCss, bt], Ce = yt([e$2("wcm-modal-content")], Ce); const $t = i$3`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`; -var Ct = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, Ot = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? kt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ct(o3, r2, t2), t2; +var Ot = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let ye = class extends s { +let ke = class extends s$1 { render() { return x`
`; } }; -ye.styles = [h.globalCss, $t], ye = Ot([e$2("wcm-modal-footer")], ye); -const Wt = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; -var It = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, te = (e2, o3, r2, a2) => { +ke.styles = [h.globalCss, $t], ke = Ot([e$2("wcm-modal-footer")], ke); +const It = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; +var Wt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, ae = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Et(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && It(o3, r2, t2), t2; + return a2 && t2 && Wt(o3, r2, t2), t2; }; -let S = class extends s { +let B = class extends s$1 { constructor() { super(...arguments), this.title = "", this.onAction = void 0, this.actionIcon = void 0, this.border = false; } backBtnTemplate() { - return x``; + return x``; } actionBtnTemplate() { return x``; } render() { - const e2 = { "wcm-border": this.border }, o$12 = T$1$1.state.history.length > 1, r2 = this.title ? x`${this.title}` : x``; + const e2 = { "wcm-border": this.border }, o$12 = T$1.state.history.length > 1, r2 = this.title ? x`${this.title}` : x``; return x`
${o$12 ? this.backBtnTemplate() : null} ${r2} ${this.onAction ? this.actionBtnTemplate() : null}
`; } }; -S.styles = [h.globalCss, Wt], te([n$1()], S.prototype, "title", 2), te([n$1()], S.prototype, "onAction", 2), te([n$1()], S.prototype, "actionIcon", 2), te([n$1({ type: Boolean })], S.prototype, "border", 2), S = te([e$2("wcm-modal-header")], S); -const c = { - MOBILE_BREAKPOINT: 600, - WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", - EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", - getShadowRootElement(e2, o3) { - const r2 = e2.renderRoot.querySelector(o3); - if (!r2) - throw new Error(`${o3} not found`); - return r2; - }, - getWalletIcon({ id: e2, image_id: o3 }) { - const { walletImages: r2 } = y$3.state; - return r2 != null && r2[e2] ? r2[e2] : o3 ? te$2.getWalletImageUrl(o3) : ""; - }, - getWalletName(e2, o3 = false) { - return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; - }, - isMobileAnimation() { - return window.innerWidth <= c.MOBILE_BREAKPOINT; - }, - async preloadImage(e2) { - const o3 = new Promise((r2, a2) => { - const t2 = new Image(); - t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; - }); - return Promise.race([o3, a$3.wait(3e3)]); - }, - getErrorMessage(e2) { - return e2 instanceof Error ? e2.message : "Unknown Error"; - }, - debounce(e2, o3 = 500) { - let r2; - return (...a2) => { - function t2() { - e2(...a2); - } - r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); - }; - }, - handleMobileLinking(e2) { - const { walletConnectUri: o3 } = p$3.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - c.setRecentWallet(e2); - function i2(s2) { - let $2 = ""; - t2 ? $2 = a$3.formatUniversalUrl(t2, s2, a2) : l2 && ($2 = a$3.formatNativeUrl(l2, s2, a2)), a$3.openHref($2, "_self"); - } - o3 && i2(o3); - }, - async handleUriCopy() { - const { walletConnectUri: e2 } = p$3.state; - if (e2) - try { - await navigator.clipboard.writeText(e2), oe$1.openToast("Link copied", "success"); - } catch { - oe$1.openToast("Failed to copy", "error"); - } - }, - getCustomImageUrls() { - const { walletImages: e2 } = y$3.state, o3 = Object.values(e2 ?? {}); - return Object.values(o3); - }, - truncate(e2, o3 = 8) { - return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; - }, - setRecentWallet(e2) { - try { - localStorage.setItem(c.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); - } catch { - console.info("Unable to set recent wallet"); +B.styles = [h.globalCss, It], ae([n$1()], B.prototype, "title", 2), ae([n$1()], B.prototype, "onAction", 2), ae([n$1()], B.prototype, "actionIcon", 2), ae([n$1({ type: Boolean })], B.prototype, "border", 2), B = ae([e$2("wcm-modal-header")], B); +const s2 = { MOBILE_BREAKPOINT: 600, WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", getShadowRootElement(e2, o3) { + const r2 = e2.renderRoot.querySelector(o3); + if (!r2) + throw new Error(`${o3} not found`); + return r2; +}, getWalletIcon({ id: e2, image_id: o3 }) { + const { walletImages: r2 } = y$1.state; + return r2 != null && r2[e2] ? r2[e2] : o3 ? te.getWalletImageUrl(o3) : ""; +}, getWalletName(e2, o3 = false) { + return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; +}, isMobileAnimation() { + return window.innerWidth <= s2.MOBILE_BREAKPOINT; +}, async preloadImage(e2) { + const o3 = new Promise((r2, a2) => { + const t2 = new Image(); + t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; + }); + return Promise.race([o3, i$4.wait(3e3)]); +}, getErrorMessage(e2) { + return e2 instanceof Error ? e2.message : "Unknown Error"; +}, debounce(e2, o3 = 500) { + let r2; + return (...a2) => { + function t2() { + e2(...a2); } - }, - getRecentWallet() { + r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); + }; +}, handleMobileLinking(e2) { + const { walletConnectUri: o3 } = p$1.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; + s2.setRecentWallet(e2); + function i2(c2) { + let u3 = ""; + t2 ? u3 = i$4.formatUniversalUrl(t2, c2, a2) : l2 && (u3 = i$4.formatNativeUrl(l2, c2, a2)), i$4.openHref(u3, "_self"); + } + o3 && i2(o3); +}, async handleUriCopy() { + const { walletConnectUri: e2 } = p$1.state; + if (e2) try { - const e2 = localStorage.getItem(c.WCM_RECENT_WALLET_DATA); - return e2 ? JSON.parse(e2) : void 0; + await navigator.clipboard.writeText(e2), oe.openToast("Link copied", "success"); } catch { - console.info("Unable to get recent wallet"); + oe.openToast("Failed to copy", "error"); } - }, - caseSafeIncludes(e2, o3) { - return e2.toUpperCase().includes(o3.toUpperCase()); - }, - openWalletExplorerUrl() { - a$3.openHref(c.EXPLORER_WALLET_URL, "_blank"); - }, - getCachedRouterWalletPlatforms() { - const { desktop: e2, mobile: o3 } = a$3.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); - return { isDesktop: r2, isMobile: t2, isWeb: a2 }; - }, - goToConnectingView(e2) { - T$1$1.setData({ Wallet: e2 }); - const o3 = a$3.isMobile(), { - isDesktop: r2, - isWeb: a2, - isMobile: t2 - } = c.getCachedRouterWalletPlatforms(); - o3 ? t2 ? T$1$1.push("MobileConnecting") : a2 ? T$1$1.push("WebConnecting") : T$1$1.push("InstallWallet") : r2 ? T$1$1.push("DesktopConnecting") : a2 ? T$1$1.push("WebConnecting") : t2 ? T$1$1.push("MobileQrcodeConnecting") : T$1$1.push("InstallWallet"); - } -}, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; -var Lt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, $e = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Rt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +}, getCustomImageUrls() { + const { walletImages: e2 } = y$1.state, o3 = Object.values(e2 ?? {}); + return Object.values(o3); +}, truncate(e2, o3 = 8) { + return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; +}, setRecentWallet(e2) { + try { + localStorage.setItem(s2.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); + } catch { + console.info("Unable to set recent wallet"); + } +}, getRecentWallet() { + try { + const e2 = localStorage.getItem(s2.WCM_RECENT_WALLET_DATA); + return e2 ? JSON.parse(e2) : void 0; + } catch { + console.info("Unable to get recent wallet"); + } +}, caseSafeIncludes(e2, o3) { + return e2.toUpperCase().includes(o3.toUpperCase()); +}, openWalletExplorerUrl() { + i$4.openHref(s2.EXPLORER_WALLET_URL, "_blank"); +}, getCachedRouterWalletPlatforms() { + const { desktop: e2, mobile: o3 } = i$4.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); + return { isDesktop: r2, isMobile: t2, isWeb: a2 }; +}, goToConnectingView(e2) { + T$1.setData({ Wallet: e2 }); + const o3 = i$4.isMobile(), { isDesktop: r2, isWeb: a2, isMobile: t2 } = s2.getCachedRouterWalletPlatforms(); + o3 ? t2 ? T$1.push("MobileConnecting") : a2 ? T$1.push("WebConnecting") : T$1.push("InstallWallet") : r2 ? T$1.push("DesktopConnecting") : a2 ? T$1.push("WebConnecting") : t2 ? T$1.push("MobileQrcodeConnecting") : T$1.push("InstallWallet"); +} }, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; +var Pt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Lt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Lt(o3, r2, t2), t2; + return a2 && t2 && Pt(o3, r2, t2), t2; }; -let oe = class extends s { +let le = class extends s$1 { constructor() { - super(), this.view = T$1$1.state.view, this.prevView = T$1$1.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = T$1$1.subscribe((e2) => { + super(), this.view = T$1.state.view, this.prevView = T$1.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = T$1.subscribe((e2) => { this.view !== e2.view && this.onChangeRoute(); }); } @@ -3721,10 +3577,10 @@ let oe = class extends s { (e2 = this.unsubscribe) == null || e2.call(this), (o3 = this.resizeObserver) == null || o3.disconnect(); } get routerEl() { - return c.getShadowRootElement(this, ".wcm-router"); + return s2.getShadowRootElement(this, ".wcm-router"); } get contentEl() { - return c.getShadowRootElement(this, ".wcm-content"); + return s2.getShadowRootElement(this, ".wcm-content"); } viewTemplate() { switch (this.view) { @@ -3749,196 +3605,157 @@ let oe = class extends s { } } async onChangeRoute() { - await animate( - this.routerEl, - { opacity: [1, 0], scale: [1, 1.02] }, - { duration: 0.15, delay: 0.1 } - ).finished, this.view = T$1$1.state.view, animate( - this.routerEl, - { opacity: [0, 1], scale: [0.99, 1] }, - { duration: 0.37, delay: 0.05 } - ); + await animate(this.routerEl, { opacity: [1, 0], scale: [1, 1.02] }, { duration: 0.15, delay: 0.1 }).finished, this.view = T$1.state.view, animate(this.routerEl, { opacity: [0, 1], scale: [0.99, 1] }, { duration: 0.37, delay: 0.05 }); } render() { return x`
${this.viewTemplate()}
`; } }; -oe.styles = [h.globalCss, Mt], $e([t$1()], oe.prototype, "view", 2), $e([t$1()], oe.prototype, "prevView", 2), oe = $e([e$2("wcm-modal-router")], oe); -const At = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; -var Pt = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, ze = (e2, o3, r2, a2) => { +le.styles = [h.globalCss, Mt], Oe([t$1()], le.prototype, "view", 2), Oe([t$1()], le.prototype, "prevView", 2), le = Oe([e$2("wcm-modal-router")], le); +const Rt = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; +var At = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, He = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Tt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Pt(o3, r2, t2), t2; + return a2 && t2 && At(o3, r2, t2), t2; }; -let ne = class extends s { +let de = class extends s$1 { constructor() { - super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = oe$1.subscribe((e2) => { - e2.open ? (this.open = true, this.timeout = setTimeout(() => oe$1.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); + super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = oe.subscribe((e2) => { + e2.open ? (this.open = true, this.timeout = setTimeout(() => oe.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); }); } disconnectedCallback() { var e2; - (e2 = this.unsubscribe) == null || e2.call(this), clearTimeout(this.timeout), oe$1.closeToast(); + (e2 = this.unsubscribe) == null || e2.call(this), clearTimeout(this.timeout), oe.closeToast(); } render() { - const { message: e2, variant: o$12 } = oe$1.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; - return this.open ? x`
${o$12 === "success" ? v.CHECKMARK_ICON : null} ${o$12 === "error" ? v.CROSS_ICON : null}${e2}
` : null; + const { message: e2, variant: o$12 } = oe.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; + return this.open ? x`
${o$12 === "success" ? b.CHECKMARK_ICON : null} ${o$12 === "error" ? b.CROSS_ICON : null}${e2}
` : null; } }; -ne.styles = [h.globalCss, At], ze([t$1()], ne.prototype, "open", 2), ne = ze([e$2("wcm-modal-toast")], ne); -const jt = 0.1, Ve = 2.5, A = 7; -function Ce(e2, o3, r2) { +de.styles = [h.globalCss, Rt], He([t$1()], de.prototype, "open", 2), de = He([e$2("wcm-modal-toast")], de); +const jt = 0.1, Ve = 2.5, L2 = 7; +function Ie(e2, o3, r2) { return e2 === o3 ? false : (e2 - o3 < 0 ? o3 - e2 : e2 - o3) <= r2 + jt; } function _t(e2, o3) { - const r2 = Array.prototype.slice.call( - browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, - 0 - ), a2 = Math.sqrt(r2.length); - return r2.reduce( - (t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, - [] - ); + const r2 = Array.prototype.slice.call(browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, 0), a2 = Math.sqrt(r2.length); + return r2.reduce((t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, []); } -const Dt = { - generate(e2, o3, r2) { - const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), s2 = o3 / i2.length, $2 = [ - { x: 0, y: 0 }, - { x: 1, y: 0 }, - { x: 0, y: 1 } - ]; - $2.forEach(({ x: y2, y: u3 }) => { - const O = (i2.length - A) * s2 * y2, b$1 = (i2.length - A) * s2 * u3, E2 = 0.45; - for (let M2 = 0; M2 < $2.length; M2 += 1) { - const V2 = s2 * (A - M2 * 2); - l2.push( - b`` - ); +const Dt = { generate(e2, o3, r2) { + const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), c2 = o3 / i2.length, u3 = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }]; + u3.forEach(({ x: $2, y: f2 }) => { + const O = (i2.length - L2) * c2 * $2, x2 = (i2.length - L2) * c2 * f2, E2 = 0.45; + for (let M2 = 0; M2 < u3.length; M2 += 1) { + const Q = c2 * (L2 - M2 * 2); + l2.push(b$1``); + } + }); + const w2 = Math.floor((r2 + 25) / c2), F = i2.length / 2 - w2 / 2, T2 = i2.length / 2 + w2 / 2 - 1, j = []; + i2.forEach(($2, f2) => { + $2.forEach((O, x2) => { + if (i2[f2][x2] && !(f2 < L2 && x2 < L2 || f2 > i2.length - (L2 + 1) && x2 < L2 || f2 < L2 && x2 > i2.length - (L2 + 1)) && !(f2 > F && f2 < T2 && x2 > F && x2 < T2)) { + const E2 = f2 * c2 + c2 / 2, M2 = x2 * c2 + c2 / 2; + j.push([E2, M2]); } }); - const f2 = Math.floor((r2 + 25) / s2), Ne = i2.length / 2 - f2 / 2, Ze = i2.length / 2 + f2 / 2 - 1, Se = []; - i2.forEach((y2, u3) => { - y2.forEach((O, b2) => { - if (i2[u3][b2] && !(u3 < A && b2 < A || u3 > i2.length - (A + 1) && b2 < A || u3 < A && b2 > i2.length - (A + 1)) && !(u3 > Ne && u3 < Ze && b2 > Ne && b2 < Ze)) { - const E2 = u3 * s2 + s2 / 2, M2 = b2 * s2 + s2 / 2; - Se.push([E2, M2]); - } - }); + }); + const oe2 = {}; + return j.forEach(([$2, f2]) => { + oe2[$2] ? oe2[$2].push(f2) : oe2[$2] = [f2]; + }), Object.entries(oe2).map(([$2, f2]) => { + const O = f2.filter((x2) => f2.every((E2) => !Ie(x2, E2, c2))); + return [Number($2), O]; + }).forEach(([$2, f2]) => { + f2.forEach((O) => { + l2.push(b$1``); }); - const J = {}; - return Se.forEach(([y2, u3]) => { - J[y2] ? J[y2].push(u3) : J[y2] = [u3]; - }), Object.entries(J).map(([y2, u3]) => { - const O = u3.filter((b2) => u3.every((E2) => !Ce(b2, E2, s2))); - return [Number(y2), O]; - }).forEach(([y2, u3]) => { - u3.forEach((O) => { - l2.push( - b`` - ); - }); - }), Object.entries(J).filter(([y2, u3]) => u3.length > 1).map(([y2, u3]) => { - const O = u3.filter((b2) => u3.some((E2) => Ce(b2, E2, s2))); - return [Number(y2), O]; - }).map(([y2, u3]) => { - u3.sort((b2, E2) => b2 < E2 ? -1 : 1); - const O = []; - for (const b2 of u3) { - const E2 = O.find((M2) => M2.some((V2) => Ce(b2, V2, s2))); - E2 ? E2.push(b2) : O.push([b2]); - } - return [y2, O.map((b2) => [b2[0], b2[b2.length - 1]])]; - }).forEach(([y2, u3]) => { - u3.forEach(([O, b$1]) => { - l2.push( - b`` - ); - }); - }), l2; - } -}, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; -var Zt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, q = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? St(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + }), Object.entries(oe2).filter(([$2, f2]) => f2.length > 1).map(([$2, f2]) => { + const O = f2.filter((x2) => f2.some((E2) => Ie(x2, E2, c2))); + return [Number($2), O]; + }).map(([$2, f2]) => { + f2.sort((x2, E2) => x2 < E2 ? -1 : 1); + const O = []; + for (const x2 of f2) { + const E2 = O.find((M2) => M2.some((Q) => Ie(x2, Q, c2))); + E2 ? E2.push(x2) : O.push([x2]); + } + return [$2, O.map((x2) => [x2[0], x2[x2.length - 1]])]; + }).forEach(([$2, f2]) => { + f2.forEach(([O, x2]) => { + l2.push(b$1``); + }); + }), l2; +} }, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; +var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Y = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zt(o3, r2, t2), t2; }; -let j = class extends s { +let D = class extends s$1 { constructor() { super(...arguments), this.uri = "", this.size = 0, this.imageId = void 0, this.walletId = void 0, this.imageUrl = void 0; } svgTemplate() { const e2 = ne$1.state.themeMode === "light" ? this.size : this.size - 36; - return b`${Dt.generate(this.uri, e2, e2 / 4)}`; + return b$1`${Dt.generate(this.uri, e2, e2 / 4)}`; } render() { const e2 = { "wcm-dark": ne$1.state.themeMode === "dark" }; - return x`
${this.walletId || this.imageUrl ? x`` : v.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; + return x`
${this.walletId || this.imageUrl ? x`` : b.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; } }; -j.styles = [h.globalCss, Nt], q([n$1()], j.prototype, "uri", 2), q([n$1({ type: Number })], j.prototype, "size", 2), q([n$1()], j.prototype, "imageId", 2), q([n$1()], j.prototype, "walletId", 2), q([n$1()], j.prototype, "imageUrl", 2), j = q([e$2("wcm-qrcode")], j); -const Bt = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; -var Ut = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +D.styles = [h.globalCss, Nt], Y([n$1()], D.prototype, "uri", 2), Y([n$1({ type: Number })], D.prototype, "size", 2), Y([n$1()], D.prototype, "imageId", 2), Y([n$1()], D.prototype, "walletId", 2), Y([n$1()], D.prototype, "imageUrl", 2), D = Y([e$2("wcm-qrcode")], D); +const St = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; +var Bt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ut(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ut(o3, r2, t2), t2; + return a2 && t2 && Bt(o3, r2, t2), t2; }; -let ce = class extends s { +let me = class extends s$1 { constructor() { super(...arguments), this.onChange = () => null; } render() { - return x` ${v.SEARCH_ICON}`; + return x` ${b.SEARCH_ICON}`; } }; -ce.styles = [h.globalCss, Bt], Fe([n$1()], ce.prototype, "onChange", 2), ce = Fe([e$2("wcm-search-input")], ce); -const zt = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; -var Vt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, qt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ft(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Vt(o3, r2, t2), t2; +me.styles = [h.globalCss, St], qe([n$1()], me.prototype, "onChange", 2), me = qe([e$2("wcm-search-input")], me); +const Ht = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; +var Ft = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let ke = class extends s { +let We = class extends s$1 { render() { return x``; } }; -ke.styles = [h.globalCss, zt], ke = qt([e$2("wcm-spinner")], ke); +We.styles = [h.globalCss, Ht], We = Ft([e$2("wcm-spinner")], We); const Qt = i$3`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`; -var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a2) => { +var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Ee = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Yt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Kt(o3, r2, t2), t2; }; -let re = class extends s { +let ie = class extends s$1 { constructor() { super(...arguments), this.variant = "medium-regular", this.color = "primary"; } render() { - const e2 = { - "wcm-big-bold": this.variant === "big-bold", - "wcm-medium-regular": this.variant === "medium-regular", - "wcm-small-regular": this.variant === "small-regular", - "wcm-small-thin": this.variant === "small-thin", - "wcm-xsmall-regular": this.variant === "xsmall-regular", - "wcm-xsmall-bold": this.variant === "xsmall-bold", - "wcm-color-primary": this.color === "primary", - "wcm-color-secondary": this.color === "secondary", - "wcm-color-tertiary": this.color === "tertiary", - "wcm-color-inverse": this.color === "inverse", - "wcm-color-accnt": this.color === "accent", - "wcm-color-error": this.color === "error" - }; + const e2 = { "wcm-big-bold": this.variant === "big-bold", "wcm-medium-regular": this.variant === "medium-regular", "wcm-small-regular": this.variant === "small-regular", "wcm-small-thin": this.variant === "small-thin", "wcm-xsmall-regular": this.variant === "xsmall-regular", "wcm-xsmall-bold": this.variant === "xsmall-bold", "wcm-color-primary": this.color === "primary", "wcm-color-secondary": this.color === "secondary", "wcm-color-tertiary": this.color === "tertiary", "wcm-color-inverse": this.color === "inverse", "wcm-color-accnt": this.color === "accent", "wcm-color-error": this.color === "error" }; return x``; } }; -re.styles = [h.globalCss, Qt], Oe([n$1()], re.prototype, "variant", 2), Oe([n$1()], re.prototype, "color", 2), re = Oe([e$2("wcm-text")], re); +ie.styles = [h.globalCss, Qt], Ee([n$1()], ie.prototype, "variant", 2), Ee([n$1()], ie.prototype, "color", 2), ie = Ee([e$2("wcm-text")], ie); const Gt = i$3`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`; -var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, _ = (e2, o3, r2, a2) => { +var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, N2 = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xt(o3, r2, t2), t2; }; -let L2 = class extends s { +let P = class extends s$1 { constructor() { super(...arguments), this.onClick = () => null, this.name = "", this.walletId = "", this.label = void 0, this.imageId = void 0, this.installed = false, this.recent = false; } @@ -3946,77 +3763,74 @@ let L2 = class extends s { return this.recent ? x`RECENT` : this.installed ? x`INSTALLED` : null; } handleClick() { - R$4.click({ name: "WALLET_BUTTON", walletId: this.walletId }), this.onClick(); + R$1.click({ name: "WALLET_BUTTON", walletId: this.walletId }), this.onClick(); } render() { var e2; - return x``; + return x``; } }; -L2.styles = [h.globalCss, Gt], _([n$1()], L2.prototype, "onClick", 2), _([n$1()], L2.prototype, "name", 2), _([n$1()], L2.prototype, "walletId", 2), _([n$1()], L2.prototype, "label", 2), _([n$1()], L2.prototype, "imageId", 2), _([n$1({ type: Boolean })], L2.prototype, "installed", 2), _([n$1({ type: Boolean })], L2.prototype, "recent", 2), L2 = _([e$2("wcm-wallet-button")], L2); +P.styles = [h.globalCss, Gt], N2([n$1()], P.prototype, "onClick", 2), N2([n$1()], P.prototype, "name", 2), N2([n$1()], P.prototype, "walletId", 2), N2([n$1()], P.prototype, "label", 2), N2([n$1()], P.prototype, "imageId", 2), N2([n$1({ type: Boolean })], P.prototype, "installed", 2), N2([n$1({ type: Boolean })], P.prototype, "recent", 2), P = N2([e$2("wcm-wallet-button")], P); const eo = i$3`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a2) => { +var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, we = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? oo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && to(o3, r2, t2), t2; }; -let Q = class extends s { +let G = class extends s$1 { constructor() { super(...arguments), this.walletId = "", this.imageId = void 0, this.imageUrl = void 0; } render() { var e2; - const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : c.getWalletIcon({ id: this.walletId, image_id: this.imageId }); - return x`${o3.length ? x`
${this.id}
` : v.WALLET_PLACEHOLDER}`; + const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : s2.getWalletIcon({ id: this.walletId, image_id: this.imageId }); + return x`${o3.length ? x`
${this.id}
` : b.WALLET_PLACEHOLDER}`; } }; -Q.styles = [h.globalCss, eo], se([n$1()], Q.prototype, "walletId", 2), se([n$1()], Q.prototype, "imageId", 2), se([n$1()], Q.prototype, "imageUrl", 2), Q = se([e$2("wcm-wallet-image")], Q); -var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a2) => { +G.styles = [h.globalCss, eo], we([n$1()], G.prototype, "walletId", 2), we([n$1()], G.prototype, "imageId", 2), we([n$1()], G.prototype, "imageUrl", 2), G = we([e$2("wcm-wallet-image")], G); +var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && ro(o3, r2, t2), t2; }; -let We = class extends s { +let Me = class extends s$1 { constructor() { super(), this.preload = true, this.preloadData(); } async loadImages(e2) { try { - e2 != null && e2.length && await Promise.all(e2.map(async (o3) => c.preloadImage(o3))); + e2 != null && e2.length && await Promise.all(e2.map(async (o3) => s2.preloadImage(o3))); } catch { console.info("Unsuccessful attempt at preloading some images", e2); } } async preloadListings() { - if (y$3.state.enableExplorer) { - await te$2.getRecomendedWallets(), p$3.setIsDataLoaded(true); - const { recomendedWallets: e2 } = te$2.state, o3 = e2.map((r2) => c.getWalletIcon(r2)); + if (y$1.state.enableExplorer) { + await te.getRecomendedWallets(), p$1.setIsDataLoaded(true); + const { recomendedWallets: e2 } = te.state, o3 = e2.map((r2) => s2.getWalletIcon(r2)); await this.loadImages(o3); } else - p$3.setIsDataLoaded(true); + p$1.setIsDataLoaded(true); } async preloadCustomImages() { - const e2 = c.getCustomImageUrls(); + const e2 = s2.getCustomImageUrls(); await this.loadImages(e2); } async preloadData() { try { - this.preload && (this.preload = false, await Promise.all([ - this.preloadListings(), - this.preloadCustomImages() - ])); + this.preload && (this.preload = false, await Promise.all([this.preloadListings(), this.preloadCustomImages()])); } catch (e2) { - console.error(e2), oe$1.openToast("Failed preloading", "error"); + console.error(e2), oe.openToast("Failed preloading", "error"); } } }; -qe([t$1()], We.prototype, "preload", 2), We = qe([e$2("wcm-explorer-context")], We); -var lo = Object.defineProperty, io = Object.getOwnPropertyDescriptor, no = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? io(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && lo(o3, r2, t2), t2; +Fe([t$1()], Me.prototype, "preload", 2), Me = Fe([e$2("wcm-explorer-context")], Me); +var no = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Qe = class extends s { +let Qe = class extends s$1 { constructor() { super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = ne$1.subscribe(h.setTheme); } @@ -4027,36 +3841,34 @@ let Qe = class extends s { }; Qe = no([e$2("wcm-theme-context")], Qe); const co = i$3`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var so = Object.defineProperty, mo = Object.getOwnPropertyDescriptor, ho = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? mo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && so(o3, r2, t2), t2; +var wo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ie = class extends s { +let Pe = class extends s$1 { onConnect(e2) { - a$3.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + i$4.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onGoToQrcode() { - T$1$1.push("Qrcode"); + T$1.push("Qrcode"); } render() { - const { recomendedWallets: e2 } = te$2.state, o3 = [...e2, ...e2], r2 = a$3.RECOMMENDED_WALLET_AMOUNT * 2; - return x`
${v.MOBILE_ICON}WalletConnect
${[ - ...Array(r2) - ].map((a2, t2) => { + const { recomendedWallets: e2 } = te.state, o3 = [...e2, ...e2], r2 = i$4.RECOMMENDED_WALLET_AMOUNT * 2; + return x`
${b.MOBILE_ICON}WalletConnect
${[...Array(r2)].map((a2, t2) => { const l2 = o3[t2 % o3.length]; - return l2 ? x`` : v.WALLET_PLACEHOLDER; + return l2 ? x`` : b.WALLET_PLACEHOLDER; })}
Select Wallet
Choose WalletConnect to see supported apps on your device`; } }; -Ie.styles = [h.globalCss, co], Ie = ho([e$2("wcm-android-wallet-selection")], Ie); -const wo = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; -var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a2) => { +Pe.styles = [h.globalCss, co], Pe = wo([e$2("wcm-android-wallet-selection")], Pe); +const ho = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; +var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, X = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? go(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && po(o3, r2, t2), t2; }; -let D = class extends s { +let Z2 = class extends s$1 { constructor() { super(...arguments), this.walletId = void 0, this.imageId = void 0, this.isError = false, this.isStale = false, this.label = ""; } @@ -4073,111 +3885,88 @@ let D = class extends s { return x`
${this.svgLoaderTemplate()}
${this.isError ? "Connection declined" : this.label}`; } }; -D.styles = [h.globalCss, wo], K([n$1()], D.prototype, "walletId", 2), K([n$1()], D.prototype, "imageId", 2), K([n$1({ type: Boolean })], D.prototype, "isError", 2), K([n$1({ type: Boolean })], D.prototype, "isStale", 2), K([n$1()], D.prototype, "label", 2), D = K([e$2("wcm-connector-waiting")], D); -const G = { - manualWallets() { - var e2, o3; - const { mobileWallets: r2, desktopWallets: a2 } = y$3.state, t2 = (e2 = G.recentWallet()) == null ? void 0 : e2.id, l2 = a$3.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((s2) => t2 !== s2.id); - return (o3 = a$3.isMobile() ? i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - mobile: f2, - links: f2 - })) : i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - desktop: f2, - links: f2 - }))) != null ? o3 : []; - }, - recentWallet() { - return c.getRecentWallet(); - }, - recomendedWallets(e2 = false) { - var o3; - const r2 = e2 || (o3 = G.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a2 } = te$2.state; - return a2.filter((t2) => r2 !== t2.id); - } -}, Z2 = { - onConnecting(e2) { - c.goToConnectingView(e2); - }, - manualWalletsTemplate() { - return G.manualWallets().map( - (e2) => x`` - ); - }, - recomendedWalletsTemplate(e2 = false) { - return G.recomendedWallets(e2).map( - (o3) => x`` - ); - }, - recentWalletTemplate() { - const e2 = G.recentWallet(); - if (e2) - return x``; - } -}, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; -var uo = Object.defineProperty, bo = Object.getOwnPropertyDescriptor, fo = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? bo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && uo(o3, r2, t2), t2; +Z2.styles = [h.globalCss, ho], X([n$1()], Z2.prototype, "walletId", 2), X([n$1()], Z2.prototype, "imageId", 2), X([n$1({ type: Boolean })], Z2.prototype, "isError", 2), X([n$1({ type: Boolean })], Z2.prototype, "isStale", 2), X([n$1()], Z2.prototype, "label", 2), Z2 = X([e$2("wcm-connector-waiting")], Z2); +const ee = { manualWallets() { + var e2, o3; + const { mobileWallets: r2, desktopWallets: a2 } = y$1.state, t2 = (e2 = ee.recentWallet()) == null ? void 0 : e2.id, l2 = i$4.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((c2) => t2 !== c2.id); + return (o3 = i$4.isMobile() ? i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w2 }) => ({ id: c2, name: u3, mobile: w2, links: w2 })) : i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w2 }) => ({ id: c2, name: u3, desktop: w2, links: w2 }))) != null ? o3 : []; +}, recentWallet() { + return s2.getRecentWallet(); +}, recomendedWallets(e2 = false) { + var o3; + const r2 = e2 || (o3 = ee.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a2 } = te.state; + return a2.filter((t2) => r2 !== t2.id); +} }, S = { onConnecting(e2) { + s2.goToConnectingView(e2); +}, manualWalletsTemplate() { + return ee.manualWallets().map((e2) => x``); +}, recomendedWalletsTemplate(e2 = false) { + return ee.recomendedWallets(e2).map((o3) => x``); +}, recentWalletTemplate() { + const e2 = ee.recentWallet(); + if (e2) + return x``; +} }, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; +var fo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ee = class extends s { +let Le = class extends s$1 { render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$3.state, r2 = e2 !== "ALL" && o3, a2 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$1.state, r2 = e2 !== "ALL" && o3, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 4 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 3) : s2 = l2; - const $2 = Boolean(s2.length); - return x`
${v.MOBILE_ICON}Mobile
${v.SCAN_ICON}Scan with your wallet
${$2 ? x`
${v.DESKTOP_ICON}Desktop
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 3) : c2 = l2; + const u3 = Boolean(c2.length); + return x`
${b.MOBILE_ICON}Mobile
${b.SCAN_ICON}Scan with your wallet
${u3 ? x`
${b.DESKTOP_ICON}Desktop
${c2} ${i2 ? x`` : null}
` : null}`; } }; -Ee.styles = [h.globalCss, vo], Ee = fo([e$2("wcm-desktop-wallet-selection")], Ee); +Le.styles = [h.globalCss, vo], Le = fo([e$2("wcm-desktop-wallet-selection")], Le); const xo = i$3`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`; -var yo = Object.defineProperty, $o = Object.getOwnPropertyDescriptor, Co = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? $o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && yo(o3, r2, t2), t2; +var Co = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Me = class extends s { +let Re = class extends s$1 { render() { - const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = y$3.state; + const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = y$1.state; return e2 ?? o3 ? x`
By connecting your wallet to this app, you agree to the app's ${e2 ? x`Terms of Service` : null} ${e2 && o3 ? "and" : null} ${o3 ? x`Privacy Policy` : null}
` : null; } }; -Me.styles = [h.globalCss, xo], Me = Co([e$2("wcm-legal-notice")], Me); +Re.styles = [h.globalCss, xo], Re = Co([e$2("wcm-legal-notice")], Re); const ko = i$3`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`; -var Oo = Object.defineProperty, Wo = Object.getOwnPropertyDescriptor, Io = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Wo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Oo(o3, r2, t2), t2; +var Wo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Le = class extends s { +let Ae = class extends s$1 { onQrcode() { - T$1$1.push("Qrcode"); + T$1.push("Qrcode"); } render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$3.state, r2 = e2 !== "ALL" && o3, a2 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$1.state, r2 = e2 !== "ALL" && o3, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 8 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 7) : s2 = l2; - const $2 = Boolean(s2.length); - return x`${$2 ? x`
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 7) : c2 = l2; + const u3 = Boolean(c2.length); + return x`${u3 ? x`
${c2} ${i2 ? x`` : null}
` : null}`; } }; -Le.styles = [h.globalCss, ko], Le = Io([e$2("wcm-mobile-wallet-selection")], Le); +Ae.styles = [h.globalCss, ko], Ae = Wo([e$2("wcm-mobile-wallet-selection")], Ae); const Eo = i$3`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`; -var Mo = Object.defineProperty, Lo = Object.getOwnPropertyDescriptor, Re = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Lo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var Mo = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, Te = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Mo(o3, r2, t2), t2; }; -let ae = class extends s { +let ne = class extends s$1 { constructor() { super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = se$1.subscribe((e2) => { e2.open ? this.onOpenModalEvent() : this.onCloseModalEvent(); @@ -4188,10 +3977,10 @@ let ae = class extends s { (e2 = this.unsubscribeModal) == null || e2.call(this); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-overlay"); + return s2.getShadowRootElement(this, ".wcm-overlay"); } get containerEl() { - return c.getShadowRootElement(this, ".wcm-container"); + return s2.getShadowRootElement(this, ".wcm-container"); } toggleBodyScroll(e2) { if (document.querySelector("body")) @@ -4199,40 +3988,27 @@ let ae = class extends s { const o3 = document.getElementById("wcm-styles"); o3 == null ? void 0 : o3.remove(); } else - document.head.insertAdjacentHTML( - "beforeend", - '' - ); + document.head.insertAdjacentHTML("beforeend", ''); } onCloseModal(e2) { e2.target === e2.currentTarget && se$1.close(); } onOpenModalEvent() { this.toggleBodyScroll(false), this.addKeyboardEvents(), this.open = true, setTimeout(async () => { - const e2 = c.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, - animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished - ]), this.active = true; + const e2 = s2.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished]), this.active = true; }, 0); } async onCloseModalEvent() { this.toggleBodyScroll(true), this.removeKeyboardEvents(); - const e2 = c.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, - animate(this.containerEl, e2, { duration: o3 }).finished - ]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; + const e2 = s2.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, animate(this.containerEl, e2, { duration: o3 }).finished]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; } addKeyboardEvents() { - this.abortController = new AbortController(), window.addEventListener( - "keydown", - (e2) => { - var o3; - e2.key === "Escape" ? se$1.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); - }, - this.abortController - ), this.containerEl.focus(); + this.abortController = new AbortController(), window.addEventListener("keydown", (e2) => { + var o3; + e2.key === "Escape" ? se$1.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); + }, this.abortController), this.containerEl.focus(); } removeKeyboardEvents() { var e2; @@ -4243,212 +4019,213 @@ let ae = class extends s { return x`
${this.open ? x`
` : null}
`; } }; -ae.styles = [h.globalCss, Eo], Re([t$1()], ae.prototype, "open", 2), Re([t$1()], ae.prototype, "active", 2), ae = Re([e$2("wcm-modal")], ae); -const Ro = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; -var Ao = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, le = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +ne.styles = [h.globalCss, Eo], Te([t$1()], ne.prototype, "open", 2), Te([t$1()], ne.prototype, "active", 2), ne = Te([e$2("wcm-modal")], ne); +const Lo = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; +var Ro = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, ce = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ao(o3, r2, t2), t2; + return a2 && t2 && Ro(o3, r2, t2), t2; }; -let B = class extends s { +let U = class extends s$1 { constructor() { super(...arguments), this.isMobile = false, this.isDesktop = false, this.isWeb = false, this.isRetry = false; } onMobile() { - a$3.isMobile() ? T$1$1.replace("MobileConnecting") : T$1$1.replace("MobileQrcodeConnecting"); + i$4.isMobile() ? T$1.replace("MobileConnecting") : T$1.replace("MobileQrcodeConnecting"); } onDesktop() { - T$1$1.replace("DesktopConnecting"); + T$1.replace("DesktopConnecting"); } onWeb() { - T$1$1.replace("WebConnecting"); + T$1.replace("WebConnecting"); } render() { - return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; + return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; } }; -B.styles = [h.globalCss, Ro], le([n$1({ type: Boolean })], B.prototype, "isMobile", 2), le([n$1({ type: Boolean })], B.prototype, "isDesktop", 2), le([n$1({ type: Boolean })], B.prototype, "isWeb", 2), le([n$1({ type: Boolean })], B.prototype, "isRetry", 2), B = le([e$2("wcm-platform-selection")], B); +U.styles = [h.globalCss, Lo], ce([n$1({ type: Boolean })], U.prototype, "isMobile", 2), ce([n$1({ type: Boolean })], U.prototype, "isDesktop", 2), ce([n$1({ type: Boolean })], U.prototype, "isWeb", 2), ce([n$1({ type: Boolean })], U.prototype, "isRetry", 2), U = ce([e$2("wcm-platform-selection")], U); const To = i$3`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var jo = Object.defineProperty, _o = Object.getOwnPropertyDescriptor, Do = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? _o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && jo(o3, r2, t2), t2; +var Do = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ae = class extends s { +let je = class extends s$1 { onClick() { - T$1$1.push("WalletExplorer"); + T$1.push("WalletExplorer"); } render() { - const { recomendedWallets: e2 } = te$2.state, o3 = G.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); - return x``; + const { recomendedWallets: e2 } = te.state, o3 = ee.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); + return x``; } }; -Ae.styles = [h.globalCss, To], Ae = Do([e$2("wcm-view-all-wallets-button")], Ae); +je.styles = [h.globalCss, To], je = Do([e$2("wcm-view-all-wallets-button")], je); const No = i$3`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`; -var Zo = Object.defineProperty, So = Object.getOwnPropertyDescriptor, de = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? So(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var Zo = Object.defineProperty, zo = Object.getOwnPropertyDescriptor, he = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zo(o3, r2, t2), t2; }; -let Y = class extends s { +let J = class extends s$1 { constructor() { super(), this.walletId = "", this.imageId = "", this.uri = "", setTimeout(() => { - const { walletConnectUri: e2 } = p$3.state; + const { walletConnectUri: e2 } = p$1.state; this.uri = e2; }, 0); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-qr-container"); + return s2.getShadowRootElement(this, ".wcm-qr-container"); } render() { return x`
${this.uri ? x`` : x``}
`; } }; -Y.styles = [h.globalCss, No], de([n$1()], Y.prototype, "walletId", 2), de([n$1()], Y.prototype, "imageId", 2), de([t$1()], Y.prototype, "uri", 2), Y = de([e$2("wcm-walletconnect-qr")], Y); -var Bo = Object.defineProperty, Uo = Object.getOwnPropertyDescriptor, Ho = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Uo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Bo(o3, r2, t2), t2; +J.styles = [h.globalCss, No], he([n$1()], J.prototype, "walletId", 2), he([n$1()], J.prototype, "imageId", 2), he([t$1()], J.prototype, "uri", 2), J = he([e$2("wcm-walletconnect-qr")], J); +var Uo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Pe = class extends s { +let _e = class extends s$1 { viewTemplate() { - return a$3.isAndroid() ? x`` : a$3.isMobile() ? x`` : x``; + return i$4.isAndroid() ? x`` : i$4.isMobile() ? x`` : x``; } render() { return x`${this.viewTemplate()}`; } }; -Pe.styles = [h.globalCss], Pe = Ho([e$2("wcm-connect-wallet-view")], Pe); -const zo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var Vo = Object.defineProperty, Fo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Fo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +_e.styles = [h.globalCss], _e = Uo([e$2("wcm-connect-wallet-view")], _e); +const Ho = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; +var Vo = Object.defineProperty, qo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? qo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Vo(o3, r2, t2), t2; }; -let me = class extends s { +let pe = class extends s$1 { constructor() { super(), this.isError = false, this.openDesktopApp(); } onFormatAndRedirect(e2) { - const { desktop: o3, name: r2 } = a$3.getWalletRouterData(), a2 = o3 == null ? void 0 : o3.native; - if (a2) { - const t2 = a$3.formatNativeUrl(a2, e2, r2); - a$3.openHref(t2, "_self"); + var o3; + const { desktop: r2, name: a2 } = i$4.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native; + if (t2) { + const l2 = i$4.formatNativeUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + i$4.openHref(l2, "_self"); } } openDesktopApp() { - const { walletConnectUri: e2 } = p$3.state, o3 = a$3.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = p$1.state, o3 = i$4.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = a$3.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; + const { name: e2, id: o3, image_id: r2 } = i$4.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; } }; -me.styles = [h.globalCss, zo], Ke([t$1()], me.prototype, "isError", 2), me = Ke([e$2("wcm-desktop-connecting-view")], me); -const qo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; -var Qo = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, Yo = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ko(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Qo(o3, r2, t2), t2; +pe.styles = [h.globalCss, Ho], Ke([t$1()], pe.prototype, "isError", 2), pe = Ke([e$2("wcm-desktop-connecting-view")], pe); +const Fo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; +var Yo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Te = class extends s { +let De = class extends s$1 { onInstall(e2) { - e2 && a$3.openHref(e2, "_blank"); + e2 && i$4.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - homepage: a2 - } = a$3.getWalletRouterData(); - return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; + const { name: e2, id: o3, image_id: r2, homepage: a2 } = i$4.getWalletRouterData(); + return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; } }; -Te.styles = [h.globalCss, qo], Te = Yo([e$2("wcm-install-wallet-view")], Te); +De.styles = [h.globalCss, Fo], De = Yo([e$2("wcm-install-wallet-view")], De); const Go = i$3`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`; var Xo = Object.defineProperty, Jo = Object.getOwnPropertyDescriptor, Ye = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xo(o3, r2, t2), t2; }; -let he = class extends s { +let ge = class extends s$1 { constructor() { super(), this.isError = false, this.openMobileApp(); } onFormatAndRedirect(e2, o3 = false) { - const { mobile: r2, name: a2 } = a$3.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - if (t2 && !o3) { - const i2 = a$3.formatNativeUrl(t2, e2, a2); - a$3.openHref(i2, "_self"); - } else if (l2) { - const i2 = a$3.formatUniversalUrl(l2, e2, a2); - a$3.openHref(i2, "_self"); + var r2, a2; + const { mobile: t2, name: l2 } = i$4.getWalletRouterData(), i2 = t2 == null ? void 0 : t2.native, c2 = t2 == null ? void 0 : t2.universal; + if (i2 && !o3) { + const u3 = i$4.formatNativeUrl(i2, e2, l2); + if (l2 === "Puzzle Wallet" && (r2 = window == null ? void 0 : window.aleo) != null && r2.connectPuzzle) { + const w2 = new URL(u3).searchParams, F = w2.get("uri"), T2 = w2.get("requestId"), j = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F, requestId: T2 ?? void 0, sessionTopic: j ?? void 0 } }); + } else + i$4.openHref(u3, "_self"); + } else if (c2) { + const u3 = i$4.formatUniversalUrl(c2, e2, l2); + if (l2 === "Puzzle Wallet" && (a2 = window == null ? void 0 : window.aleo) != null && a2.connectPuzzle) { + const w2 = new URL(u3).searchParams, F = w2.get("uri"), T2 = w2.get("requestId"), j = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F, requestId: T2 ?? void 0, sessionTopic: j ?? void 0 } }); + } else + i$4.openHref(u3, "_self"); } } openMobileApp(e2 = false) { - const { walletConnectUri: o3 } = p$3.state, r2 = a$3.getWalletRouterData(); - c.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); + const { walletConnectUri: o3 } = p$1.state, r2 = i$4.getWalletRouterData(); + s2.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); } onGoToAppStore(e2) { - e2 && a$3.openHref(e2, "_blank"); + e2 && i$4.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - app: a2, - mobile: t2 - } = a$3.getWalletRouterData(), { isWeb: l$12 } = c.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, s2 = t2 == null ? void 0 : t2.universal; - return x`Retry${s2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; + const { name: e2, id: o3, image_id: r2, app: a2, mobile: t2 } = i$4.getWalletRouterData(), { isWeb: l$12 } = s2.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, c2 = t2 == null ? void 0 : t2.universal; + return x`Retry${c2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; } }; -he.styles = [h.globalCss, Go], Ye([t$1()], he.prototype, "isError", 2), he = Ye([e$2("wcm-mobile-connecting-view")], he); +ge.styles = [h.globalCss, Go], Ye([t$1()], ge.prototype, "isError", 2), ge = Ye([e$2("wcm-mobile-connecting-view")], ge); const er = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var tr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, rr = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? or(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && tr(o3, r2, t2), t2; +var rr = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let je = class extends s { +let Ne = class extends s$1 { render() { - const { name: e2, id: o3, image_id: r2 } = a$3.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; + const { name: e2, id: o3, image_id: r2 } = i$4.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; } }; -je.styles = [h.globalCss, er], je = rr([e$2("wcm-mobile-qr-connecting-view")], je); -var ar = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, ir = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? lr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ar(o3, r2, t2), t2; +Ne.styles = [h.globalCss, er], Ne = rr([e$2("wcm-mobile-qr-connecting-view")], Ne); +var ir = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let _e = class extends s { +let Ze = class extends s$1 { render() { - return x``; + return x``; } }; -_e.styles = [h.globalCss], _e = ir([e$2("wcm-qrcode-view")], _e); +Ze.styles = [h.globalCss], Ze = ir([e$2("wcm-qrcode-view")], Ze); const nr = i$3`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`; -var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, ie = (e2, o3, r2, a2) => { +var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? sr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && cr(o3, r2, t2), t2; }; -const De = 40; -let U = class extends s { +const ze = 40; +let H2 = class extends s$1 { constructor() { - super(...arguments), this.loading = !te$2.state.wallets.listings.length, this.firstFetch = !te$2.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = c.debounce((e2) => { - e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, te$2.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), te$2.resetSearch()); + super(...arguments), this.loading = !te.state.wallets.listings.length, this.firstFetch = !te.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = s2.debounce((e2) => { + e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, te.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), te.resetSearch()); }); } firstUpdated() { @@ -4459,7 +4236,7 @@ let U = class extends s { (e2 = this.intersectionObserver) == null || e2.disconnect(); } get placeholderEl() { - return c.getShadowRootElement(this, ".wcm-placeholder-block"); + return s2.getShadowRootElement(this, ".wcm-placeholder-block"); } createPaginationObserver() { this.intersectionObserver = new IntersectionObserver(([e2]) => { @@ -4467,96 +4244,72 @@ let U = class extends s { }), this.intersectionObserver.observe(this.placeholderEl); } isLastPage() { - const { wallets: e2, search: o3 } = te$2.state, { listings: r2, total: a2 } = this.search ? o3 : e2; - return a2 <= De || r2.length >= a2; + const { wallets: e2, search: o3 } = te.state, { listings: r2, total: a2 } = this.search ? o3 : e2; + return a2 <= ze || r2.length >= a2; } async fetchWallets() { var e2; - const { wallets: o3, search: r2 } = te$2.state, { listings: a2, total: t2, page: l2 } = this.search ? r2 : o3; - if (!this.endReached && (this.firstFetch || t2 > De && a2.length < t2)) + const { wallets: o3, search: r2 } = te.state, { listings: a2, total: t2, page: l2 } = this.search ? r2 : o3; + if (!this.endReached && (this.firstFetch || t2 > ze && a2.length < t2)) try { this.loading = true; - const i2 = (e2 = p$3.state.chains) == null ? void 0 : e2.join(","), { listings: s2 } = await te$2.getWallets({ - page: this.firstFetch ? 1 : l2 + 1, - entries: De, - search: this.search, - version: 2, - chains: i2 - }), $2 = s2.map((f2) => c.getWalletIcon(f2)); - await Promise.all([ - ...$2.map(async (f2) => c.preloadImage(f2)), - a$3.wait(300) - ]), this.endReached = this.isLastPage(); + const i2 = (e2 = p$1.state.chains) == null ? void 0 : e2.join(","), { listings: c2 } = await te.getWallets({ page: this.firstFetch ? 1 : l2 + 1, entries: ze, search: this.search, version: 2, chains: i2 }), u3 = c2.map((w2) => s2.getWalletIcon(w2)); + await Promise.all([...u3.map(async (w2) => s2.preloadImage(w2)), i$4.wait(300)]), this.endReached = this.isLastPage(); } catch (i2) { - console.error(i2), oe$1.openToast(c.getErrorMessage(i2), "error"); + console.error(i2), oe.openToast(s2.getErrorMessage(i2), "error"); } finally { this.loading = false, this.firstFetch = false; } } onConnect(e2) { - a$3.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + i$4.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onSearchChange(e2) { const { value: o3 } = e2.target; this.searchDebounce(o3); } render() { - const { wallets: e2, search: o$12 } = te$2.state, { listings: r2 } = this.search ? o$12 : e2, a2 = this.loading && !r2.length, t2 = this.search.length >= 3; - let l2 = Z2.manualWalletsTemplate(), i2 = Z2.recomendedWalletsTemplate(true); - t2 && (l2 = l2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search)), i2 = i2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search))); - const s2 = !this.loading && !r2.length && !i2.length, $2 = { - "wcm-loading": a2, - "wcm-end-reached": this.endReached || !this.loading, - "wcm-empty": s2 - }; - return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((f2) => x`${f2 ? x`` : null}`)}
${s2 ? x`No results found` : null} ${!s2 && this.loading ? x`` : null}
`; + const { wallets: e2, search: o$12 } = te.state, { listings: r2 } = this.search ? o$12 : e2, a2 = this.loading && !r2.length, t2 = this.search.length >= 3; + let l2 = S.manualWalletsTemplate(), i2 = S.recomendedWalletsTemplate(true); + t2 && (l2 = l2.filter(({ values: w2 }) => s2.caseSafeIncludes(w2[0], this.search)), i2 = i2.filter(({ values: w2 }) => s2.caseSafeIncludes(w2[0], this.search))); + const c2 = !this.loading && !r2.length && !i2.length, u3 = { "wcm-loading": a2, "wcm-end-reached": this.endReached || !this.loading, "wcm-empty": c2 }; + return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((w2) => x`${w2 ? x`` : null}`)}
${c2 ? x`No results found` : null} ${!c2 && this.loading ? x`` : null}
`; } }; -U.styles = [h.globalCss, nr], ie([t$1()], U.prototype, "loading", 2), ie([t$1()], U.prototype, "firstFetch", 2), ie([t$1()], U.prototype, "search", 2), ie([t$1()], U.prototype, "endReached", 2), U = ie([e$2("wcm-wallet-explorer-view")], U); +H2.styles = [h.globalCss, nr], se([t$1()], H2.prototype, "loading", 2), se([t$1()], H2.prototype, "firstFetch", 2), se([t$1()], H2.prototype, "search", 2), se([t$1()], H2.prototype, "endReached", 2), H2 = se([e$2("wcm-wallet-explorer-view")], H2); const dr = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var mr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? hr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var mr = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? wr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && mr(o3, r2, t2), t2; }; -let we = class extends s { +let ve = class extends s$1 { constructor() { super(), this.isError = false, this.openWebWallet(); } onFormatAndRedirect(e2) { - var _a; - const { desktop: o3, name: r2 } = a$3.getWalletRouterData(), a2 = o3 == null ? void 0 : o3.universal; - if (a2) { - const t2 = a$3.formatUniversalUrl(a2, e2, r2); - if (r2 === "Puzzle Wallet" && window && ((_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient)) { - const url = new URL(t2); - const params = url.searchParams; - const wcUri = params.get("uri"); - const requestId = params.get("requestId"); - const sessionTopic = params.get("sessionTopic"); - void window.aleo.connectPuzzle({ - wc: { - uri: wcUri, - requestId: requestId ?? void 0, - sessionTopic: sessionTopic ?? void 0 - } - }); - } else { - a$3.openHref(t2, "_blank"); - } + var o3; + const { desktop: r2, name: a2 } = i$4.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.universal; + if (t2) { + const l2 = i$4.formatUniversalUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + i$4.openHref(l2, "_blank"); } } openWebWallet() { - const { walletConnectUri: e2 } = p$3.state, o3 = a$3.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = p$1.state, o3 = i$4.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = a$3.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = c.getCachedRouterWalletPlatforms(), l$12 = a$3.isMobile(); - return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; + const { name: e2, id: o3, image_id: r2 } = i$4.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = s2.getCachedRouterWalletPlatforms(), l$12 = i$4.isMobile(); + return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; } }; -we.styles = [h.globalCss, dr], Ge([t$1()], we.prototype, "isError", 2), we = Ge([e$2("wcm-web-connecting-view")], we); +ve.styles = [h.globalCss, dr], Ge([t$1()], ve.prototype, "isError", 2), ve = Ge([e$2("wcm-web-connecting-view")], ve); export { - ae as WcmModal, - j as WcmQrCode + ne as WcmModal, + D as WcmQrCode }; diff --git a/packages/core/dist/index-rLSm9-3e.cjs b/packages/core/dist/index-rLSm9-3e.cjs deleted file mode 100644 index 2c367882..00000000 --- a/packages/core/dist/index-rLSm9-3e.cjs +++ /dev/null @@ -1,17509 +0,0 @@ -"use strict"; -const t = Symbol(); -const s = Object.getPrototypeOf, c$2 = /* @__PURE__ */ new WeakMap(), l$2 = (e) => e && (c$2.has(e) ? c$2.get(e) : s(e) === Object.prototype || s(e) === Array.prototype), y$4 = (e) => l$2(e) && e[t] || null, h$4 = (e, t2 = true) => { - c$2.set(e, t2); -}; -var define_import_meta_env_default = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false }; -const isObject = (x2) => typeof x2 === "object" && x2 !== null; -const proxyStateMap = /* @__PURE__ */ new WeakMap(); -const refSet = /* @__PURE__ */ new WeakSet(); -const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x2) => isObject(x2) && !refSet.has(x2) && (Array.isArray(x2) || !(Symbol.iterator in x2)) && !(x2 instanceof WeakMap) && !(x2 instanceof WeakSet) && !(x2 instanceof Error) && !(x2 instanceof Number) && !(x2 instanceof Date) && !(x2 instanceof String) && !(x2 instanceof RegExp) && !(x2 instanceof ArrayBuffer), defaultHandlePromise = (promise) => { - switch (promise.status) { - case "fulfilled": - return promise.value; - case "rejected": - throw promise.reason; - default: - throw promise; - } -}, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version2, handlePromise = defaultHandlePromise) => { - const cache = snapCache.get(target); - if ((cache == null ? void 0 : cache[0]) === version2) { - return cache[1]; - } - const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); - h$4(snap, true); - snapCache.set(target, [version2, snap]); - Reflect.ownKeys(target).forEach((key) => { - if (Object.getOwnPropertyDescriptor(snap, key)) { - return; - } - const value = Reflect.get(target, key); - const desc = { - value, - enumerable: true, - // This is intentional to avoid copying with proxy-compare. - // It's still non-writable, so it avoids assigning a value. - configurable: true - }; - if (refSet.has(value)) { - h$4(value, false); - } else if (value instanceof Promise) { - delete desc.value; - desc.get = () => handlePromise(value); - } else if (proxyStateMap.has(value)) { - const [target2, ensureVersion] = proxyStateMap.get( - value - ); - desc.value = createSnapshot( - target2, - ensureVersion(), - handlePromise - ); - } - Object.defineProperty(snap, key, desc); - }); - return Object.preventExtensions(snap); -}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { - if (!isObject(initialObject)) { - throw new Error("object required"); - } - const found = proxyCache.get(initialObject); - if (found) { - return found; - } - let version2 = versionHolder[0]; - const listeners2 = /* @__PURE__ */ new Set(); - const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => { - if (version2 !== nextVersion) { - version2 = nextVersion; - listeners2.forEach((listener) => listener(op, nextVersion)); - } - }; - let checkVersion = versionHolder[1]; - const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => { - if (checkVersion !== nextCheckVersion && !listeners2.size) { - checkVersion = nextCheckVersion; - propProxyStates.forEach(([propProxyState]) => { - const propVersion = propProxyState[1](nextCheckVersion); - if (propVersion > version2) { - version2 = propVersion; - } - }); - } - return version2; - }; - const createPropListener = (prop) => (op, nextVersion) => { - const newOp = [...op]; - newOp[1] = [prop, ...newOp[1]]; - notifyUpdate(newOp, nextVersion); - }; - const propProxyStates = /* @__PURE__ */ new Map(); - const addPropListener = (prop, propProxyState) => { - if ((define_import_meta_env_default ? "production" : void 0) !== "production" && propProxyStates.has(prop)) { - throw new Error("prop listener already exists"); - } - if (listeners2.size) { - const remove = propProxyState[3](createPropListener(prop)); - propProxyStates.set(prop, [propProxyState, remove]); - } else { - propProxyStates.set(prop, [propProxyState]); - } - }; - const removePropListener = (prop) => { - var _a; - const entry = propProxyStates.get(prop); - if (entry) { - propProxyStates.delete(prop); - (_a = entry[1]) == null ? void 0 : _a.call(entry); - } - }; - const addListener2 = (listener) => { - listeners2.add(listener); - if (listeners2.size === 1) { - propProxyStates.forEach(([propProxyState, prevRemove], prop) => { - if ((define_import_meta_env_default ? "production" : void 0) !== "production" && prevRemove) { - throw new Error("remove already exists"); - } - const remove = propProxyState[3](createPropListener(prop)); - propProxyStates.set(prop, [propProxyState, remove]); - }); - } - const removeListener2 = () => { - listeners2.delete(listener); - if (listeners2.size === 0) { - propProxyStates.forEach(([propProxyState, remove], prop) => { - if (remove) { - remove(); - propProxyStates.set(prop, [propProxyState]); - } - }); - } - }; - return removeListener2; - }; - const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); - const handler = { - deleteProperty(target, prop) { - const prevValue = Reflect.get(target, prop); - removePropListener(prop); - const deleted = Reflect.deleteProperty(target, prop); - if (deleted) { - notifyUpdate(["delete", [prop], prevValue]); - } - return deleted; - }, - set(target, prop, value, receiver) { - const hasPrevValue = Reflect.has(target, prop); - const prevValue = Reflect.get(target, prop, receiver); - if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { - return true; - } - removePropListener(prop); - if (isObject(value)) { - value = y$4(value) || value; - } - let nextValue = value; - if (value instanceof Promise) { - value.then((v3) => { - value.status = "fulfilled"; - value.value = v3; - notifyUpdate(["resolve", [prop], v3]); - }).catch((e) => { - value.status = "rejected"; - value.reason = e; - notifyUpdate(["reject", [prop], e]); - }); - } else { - if (!proxyStateMap.has(value) && canProxy(value)) { - nextValue = proxyFunction(value); - } - const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); - if (childProxyState) { - addPropListener(prop, childProxyState); - } - } - Reflect.set(target, prop, nextValue, receiver); - notifyUpdate(["set", [prop], value, prevValue]); - return true; - } - }; - const proxyObject = newProxy(baseObject, handler); - proxyCache.set(initialObject, proxyObject); - const proxyState = [ - baseObject, - ensureVersion, - createSnapshot, - addListener2 - ]; - proxyStateMap.set(proxyObject, proxyState); - Reflect.ownKeys(initialObject).forEach((key) => { - const desc = Object.getOwnPropertyDescriptor( - initialObject, - key - ); - if ("value" in desc) { - proxyObject[key] = initialObject[key]; - delete desc.value; - delete desc.writable; - } - Object.defineProperty(baseObject, key, desc); - }); - return proxyObject; -}) => [ - // public functions - proxyFunction, - // shared state - proxyStateMap, - refSet, - // internal things - objectIs, - newProxy, - canProxy, - defaultHandlePromise, - snapCache, - createSnapshot, - proxyCache, - versionHolder -]; -const [defaultProxyFunction] = buildProxyFunction(); -function proxy(initialObject = {}) { - return defaultProxyFunction(initialObject); -} -function subscribe(proxyObject, callback, notifyInSync) { - const proxyState = proxyStateMap.get(proxyObject); - if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !proxyState) { - console.warn("Please use proxy object"); - } - let promise; - const ops = []; - const addListener2 = proxyState[3]; - let isListenerActive = false; - const listener = (op) => { - ops.push(op); - if (notifyInSync) { - callback(ops.splice(0)); - return; - } - if (!promise) { - promise = Promise.resolve().then(() => { - promise = void 0; - if (isListenerActive) { - callback(ops.splice(0)); - } - }); - } - }; - const removeListener2 = addListener2(listener); - isListenerActive = true; - return () => { - isListenerActive = false; - removeListener2(); - }; -} -function snapshot(proxyObject, handlePromise) { - const proxyState = proxyStateMap.get(proxyObject); - if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !proxyState) { - console.warn("Please use proxy object"); - } - const [target, ensureVersion, createSnapshot] = proxyState; - return createSnapshot(target, ensureVersion(), handlePromise); -} -const o$1 = proxy({ - history: ["ConnectWallet"], - view: "ConnectWallet", - data: void 0 -}), T$1 = { - state: o$1, - subscribe(e) { - return subscribe(o$1, () => e(o$1)); - }, - push(e, t2) { - e !== o$1.view && (o$1.view = e, t2 && (o$1.data = t2), o$1.history.push(e)); - }, - reset(e) { - o$1.view = e, o$1.history = [e]; - }, - replace(e) { - o$1.history.length > 1 && (o$1.history[o$1.history.length - 1] = e, o$1.view = e); - }, - goBack() { - if (o$1.history.length > 1) { - o$1.history.pop(); - const [e] = o$1.history.slice(-1); - o$1.view = e; - } - }, - setData(e) { - o$1.data = e; - } -}, a$3 = { - WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", - WCM_VERSION: "WCM_VERSION", - RECOMMENDED_WALLET_AMOUNT: 9, - isMobile() { - return typeof window < "u" ? Boolean( - window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test( - navigator.userAgent - ) - ) : false; - }, - isAndroid() { - return a$3.isMobile() && navigator.userAgent.toLowerCase().includes("android"); - }, - isIos() { - const e = navigator.userAgent.toLowerCase(); - return a$3.isMobile() && (e.includes("iphone") || e.includes("ipad")); - }, - isHttpUrl(e) { - return e.startsWith("http://") || e.startsWith("https://"); - }, - isArray(e) { - return Array.isArray(e) && e.length > 0; - }, - formatNativeUrl(e, t2, s2) { - if (a$3.isHttpUrl(e)) - return this.formatUniversalUrl(e, t2, s2); - let n3 = e; - n3.includes("://") || (n3 = e.replaceAll("/", "").replaceAll(":", ""), n3 = `${n3}://`), n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - formatUniversalUrl(e, t2, s2) { - if (!a$3.isHttpUrl(e)) - return this.formatNativeUrl(e, t2, s2); - let n3 = e; - n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - async wait(e) { - return new Promise((t2) => { - setTimeout(t2, e); - }); - }, - openHref(e, t2) { - window.open(e, t2, "noreferrer noopener"); - }, - setWalletConnectDeepLink(e, t2) { - try { - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: e, name: t2 }) - ); - } catch { - console.info("Unable to set WalletConnect deep link"); - } - }, - setWalletConnectAndroidDeepLink(e) { - try { - const [t2] = e.split("?"); - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: t2, name: "Android" }) - ); - } catch { - console.info("Unable to set WalletConnect android deep link"); - } - }, - removeWalletConnectDeepLink() { - try { - localStorage.removeItem(a$3.WALLETCONNECT_DEEPLINK_CHOICE); - } catch { - console.info("Unable to remove WalletConnect deep link"); - } - }, - setModalVersionInStorage() { - try { - typeof localStorage < "u" && localStorage.setItem(a$3.WCM_VERSION, "2.6.2"); - } catch { - console.info("Unable to set Web3Modal version in storage"); - } - }, - getWalletRouterData() { - var e; - const t2 = (e = T$1.state.data) == null ? void 0 : e.Wallet; - if (!t2) - throw new Error('Missing "Wallet" view data'); - return t2; - } -}, _$3 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), r$1 = proxy({ - enabled: _$3, - userSessionId: "", - events: [], - connectedWalletId: void 0 -}), R$4 = { - state: r$1, - subscribe(e) { - return subscribe(r$1.events, () => e(snapshot(r$1.events[r$1.events.length - 1]))); - }, - initialize() { - r$1.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (r$1.userSessionId = crypto.randomUUID()); - }, - setConnectedWalletId(e) { - r$1.connectedWalletId = e; - }, - click(e) { - if (r$1.enabled) { - const t2 = { - type: "CLICK", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - }, - track(e) { - if (r$1.enabled) { - const t2 = { - type: "TRACK", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - }, - view(e) { - if (r$1.enabled) { - const t2 = { - type: "VIEW", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - } -}, c$1 = proxy({ - chains: void 0, - walletConnectUri: void 0, - isAuth: false, - isCustomDesktop: false, - isCustomMobile: false, - isDataLoaded: false, - isUiLoaded: false -}), p$3 = { - state: c$1, - subscribe(e) { - return subscribe(c$1, () => e(c$1)); - }, - setChains(e) { - c$1.chains = e; - }, - setWalletConnectUri(e) { - c$1.walletConnectUri = e; - }, - setIsCustomDesktop(e) { - c$1.isCustomDesktop = e; - }, - setIsCustomMobile(e) { - c$1.isCustomMobile = e; - }, - setIsDataLoaded(e) { - c$1.isDataLoaded = e; - }, - setIsUiLoaded(e) { - c$1.isUiLoaded = e; - }, - setIsAuth(e) { - c$1.isAuth = e; - } -}, W$2 = proxy({ - projectId: "", - mobileWallets: void 0, - desktopWallets: void 0, - walletImages: void 0, - chains: void 0, - enableAuthMode: false, - enableExplorer: true, - explorerExcludedWalletIds: void 0, - explorerRecommendedWalletIds: void 0, - termsOfServiceUrl: void 0, - privacyPolicyUrl: void 0 -}), y$3 = { - state: W$2, - subscribe(e) { - return subscribe(W$2, () => e(W$2)); - }, - setConfig(e) { - var t2, s2; - R$4.initialize(), p$3.setChains(e.chains), p$3.setIsAuth(Boolean(e.enableAuthMode)), p$3.setIsCustomMobile( - Boolean((t2 = e.mobileWallets) == null ? void 0 : t2.length) - ), p$3.setIsCustomDesktop( - Boolean((s2 = e.desktopWallets) == null ? void 0 : s2.length) - ), a$3.setModalVersionInStorage(), Object.assign(W$2, e); - } -}; -var V$2 = Object.defineProperty, D$4 = Object.getOwnPropertySymbols, H$2 = Object.prototype.hasOwnProperty, B$2 = Object.prototype.propertyIsEnumerable, M$1 = (e, t2, s2) => t2 in e ? V$2(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, K$1 = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - H$2.call(t2, s2) && M$1(e, s2, t2[s2]); - if (D$4) - for (var s2 of D$4(t2)) - B$2.call(t2, s2) && M$1(e, s2, t2[s2]); - return e; -}; -const L$2 = "https://explorer-api.walletconnect.com", E$2 = "wcm", O$3 = "js-2.6.2"; -async function w$5(e, t2) { - const s2 = K$1({ sdkType: E$2, sdkVersion: O$3 }, t2), n3 = new URL(e, L$2); - return n3.searchParams.append("projectId", y$3.state.projectId), Object.entries(s2).forEach(([i2, l2]) => { - l2 && n3.searchParams.append(i2, String(l2)); - }), (await fetch(n3)).json(); -} -const m$2 = { - async getDesktopListings(e) { - return w$5("/w3m/v1/getDesktopListings", e); - }, - async getMobileListings(e) { - return w$5("/w3m/v1/getMobileListings", e); - }, - async getInjectedListings(e) { - return w$5("/w3m/v1/getInjectedListings", e); - }, - async getAllListings(e) { - return w$5("/w3m/v1/getAllListings", e); - }, - getWalletImageUrl(e) { - return `${L$2}/w3m/v1/getWalletImage/${e}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; - }, - getAssetImageUrl(e) { - return `${L$2}/w3m/v1/getAssetImage/${e}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; - } -}; -var z$3 = Object.defineProperty, j$3 = Object.getOwnPropertySymbols, J$2 = Object.prototype.hasOwnProperty, q$2 = Object.prototype.propertyIsEnumerable, k$2 = (e, t2, s2) => t2 in e ? z$3(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, F$3 = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - J$2.call(t2, s2) && k$2(e, s2, t2[s2]); - if (j$3) - for (var s2 of j$3(t2)) - q$2.call(t2, s2) && k$2(e, s2, t2[s2]); - return e; -}; -const N$3 = a$3.isMobile(), d$2 = proxy({ - wallets: { listings: [], total: 0, page: 1 }, - search: { listings: [], total: 0, page: 1 }, - recomendedWallets: [] -}), te$2 = { - state: d$2, - async getRecomendedWallets() { - const { explorerRecommendedWalletIds: e, explorerExcludedWalletIds: t2 } = y$3.state; - if (e === "NONE" || t2 === "ALL" && !e) - return d$2.recomendedWallets; - if (a$3.isArray(e)) { - const s2 = { recommendedIds: e.join(",") }, { listings: n3 } = await m$2.getAllListings(s2), i2 = Object.values(n3); - i2.sort && i2.sort((l2, v3) => { - const b3 = e.indexOf(l2.id), f2 = e.indexOf(v3.id); - return b3 - f2; - }), d$2.recomendedWallets = i2; - } else { - const { chains: s2, isAuth: n3 } = p$3.state, i2 = s2 == null ? void 0 : s2.join(","), l2 = a$3.isArray(t2), v3 = { - page: 1, - sdks: n3 ? "auth_v1" : void 0, - entries: a$3.RECOMMENDED_WALLET_AMOUNT, - chains: i2, - version: 2, - excludedIds: l2 ? t2.join(",") : void 0 - }, { listings: b3 } = N$3 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); - d$2.recomendedWallets = Object.values(b3); - } - return d$2.recomendedWallets; - }, - async getWallets(e) { - const t2 = F$3({}, e), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n3 } = y$3.state, { recomendedWallets: i2 } = d$2; - if (n3 === "ALL") - return d$2.wallets; - i2.length ? t2.excludedIds = i2.map((x2) => x2.id).join(",") : a$3.isArray(s2) && (t2.excludedIds = s2.join(",")), a$3.isArray(n3) && (t2.excludedIds = [t2.excludedIds, n3].filter(Boolean).join(",")), p$3.state.isAuth && (t2.sdks = "auth_v1"); - const { page: l2, search: v3 } = e, { listings: b3, total: f2 } = N$3 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; - return d$2[U2] = { listings: [...d$2[U2].listings, ...A2], total: f2, page: l2 ?? 1 }, { listings: A2, total: f2 }; - }, - getWalletImageUrl(e) { - return m$2.getWalletImageUrl(e); - }, - getAssetImageUrl(e) { - return m$2.getAssetImageUrl(e); - }, - resetSearch() { - d$2.search = { listings: [], total: 0, page: 1 }; - } -}, I$1 = proxy({ open: false }), se = { - state: I$1, - subscribe(e) { - return subscribe(I$1, () => e(I$1)); - }, - async open(e) { - return new Promise((t2) => { - const { isUiLoaded: s2, isDataLoaded: n3 } = p$3.state; - if (a$3.removeWalletConnectDeepLink(), p$3.setWalletConnectUri(e == null ? void 0 : e.uri), p$3.setChains(e == null ? void 0 : e.chains), T$1.reset("ConnectWallet"), s2 && n3) - I$1.open = true, t2(); - else { - const i2 = setInterval(() => { - const l2 = p$3.state; - l2.isUiLoaded && l2.isDataLoaded && (clearInterval(i2), I$1.open = true, t2()); - }, 200); - } - }); - }, - close() { - I$1.open = false; - } -}; -var G$2 = Object.defineProperty, $$2 = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$2 = Object.prototype.propertyIsEnumerable, S$2 = (e, t2, s2) => t2 in e ? G$2(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, Y = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - Q$3.call(t2, s2) && S$2(e, s2, t2[s2]); - if ($$2) - for (var s2 of $$2(t2)) - X$2.call(t2, s2) && S$2(e, s2, t2[s2]); - return e; -}; -function Z$2() { - return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; -} -const C = proxy({ themeMode: Z$2() ? "dark" : "light" }), ne = { - state: C, - subscribe(e) { - return subscribe(C, () => e(C)); - }, - setThemeConfig(e) { - const { themeMode: t2, themeVariables: s2 } = e; - t2 && (C.themeMode = t2), s2 && (C.themeVariables = Y({}, s2)); - } -}, g$5 = proxy({ open: false, message: "", variant: "success" }), oe$1 = { - state: g$5, - subscribe(e) { - return subscribe(g$5, () => e(g$5)); - }, - openToast(e, t2) { - g$5.open = true, g$5.message = e, g$5.variant = t2; - }, - closeToast() { - g$5.open = false; - } -}; -let d$1 = class d { - constructor(e) { - this.openModal = se.open, this.closeModal = se.close, this.subscribeModal = se.subscribe, this.setTheme = ne.setThemeConfig, ne.setThemeConfig(e), y$3.setConfig(e), this.initUi(); - } - async initUi() { - if (typeof window < "u") { - await Promise.resolve().then(() => require("./index-DeMTjw2J.cjs")); - const e = document.createElement("wcm-modal"); - document.body.insertAdjacentElement("beforeend", e), p$3.setIsUiLoaded(true); - } - } -}; -var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; -function getDefaultExportFromCjs(x2) { - return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; -} -function getAugmentedNamespace(n3) { - if (n3.__esModule) - return n3; - var f2 = n3.default; - if (typeof f2 == "function") { - var a3 = function a4() { - if (this instanceof a4) { - return Reflect.construct(f2, arguments, this.constructor); - } - return f2.apply(this, arguments); - }; - a3.prototype = f2.prototype; - } else - a3 = {}; - Object.defineProperty(a3, "__esModule", { value: true }); - Object.keys(n3).forEach(function(k2) { - var d3 = Object.getOwnPropertyDescriptor(n3, k2); - Object.defineProperty(a3, k2, d3.get ? d3 : { - enumerable: true, - get: function() { - return n3[k2]; - } - }); - }); - return a3; -} -var events = { exports: {} }; -var R$3 = typeof Reflect === "object" ? Reflect : null; -var ReflectApply = R$3 && typeof R$3.apply === "function" ? R$3.apply : function ReflectApply2(target, receiver, args) { - return Function.prototype.apply.call(target, receiver, args); -}; -var ReflectOwnKeys; -if (R$3 && typeof R$3.ownKeys === "function") { - ReflectOwnKeys = R$3.ownKeys; -} else if (Object.getOwnPropertySymbols) { - ReflectOwnKeys = function ReflectOwnKeys2(target) { - return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); - }; -} else { - ReflectOwnKeys = function ReflectOwnKeys2(target) { - return Object.getOwnPropertyNames(target); - }; -} -function ProcessEmitWarning(warning) { - if (console && console.warn) - console.warn(warning); -} -var NumberIsNaN = Number.isNaN || function NumberIsNaN2(value) { - return value !== value; -}; -function EventEmitter() { - EventEmitter.init.call(this); -} -events.exports = EventEmitter; -events.exports.once = once2; -EventEmitter.EventEmitter = EventEmitter; -EventEmitter.prototype._events = void 0; -EventEmitter.prototype._eventsCount = 0; -EventEmitter.prototype._maxListeners = void 0; -var defaultMaxListeners = 10; -function checkListener(listener) { - if (typeof listener !== "function") { - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); - } -} -Object.defineProperty(EventEmitter, "defaultMaxListeners", { - enumerable: true, - get: function() { - return defaultMaxListeners; - }, - set: function(arg) { - if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) { - throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + "."); - } - defaultMaxListeners = arg; - } -}); -EventEmitter.init = function() { - if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) { - this._events = /* @__PURE__ */ Object.create(null); - this._eventsCount = 0; - } - this._maxListeners = this._maxListeners || void 0; -}; -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n3) { - if (typeof n3 !== "number" || n3 < 0 || NumberIsNaN(n3)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n3 + "."); - } - this._maxListeners = n3; - return this; -}; -function _getMaxListeners(that) { - if (that._maxListeners === void 0) - return EventEmitter.defaultMaxListeners; - return that._maxListeners; -} -EventEmitter.prototype.getMaxListeners = function getMaxListeners() { - return _getMaxListeners(this); -}; -EventEmitter.prototype.emit = function emit(type2) { - var args = []; - for (var i2 = 1; i2 < arguments.length; i2++) - args.push(arguments[i2]); - var doError = type2 === "error"; - var events2 = this._events; - if (events2 !== void 0) - doError = doError && events2.error === void 0; - else if (!doError) - return false; - if (doError) { - var er2; - if (args.length > 0) - er2 = args[0]; - if (er2 instanceof Error) { - throw er2; - } - var err = new Error("Unhandled error." + (er2 ? " (" + er2.message + ")" : "")); - err.context = er2; - throw err; - } - var handler = events2[type2]; - if (handler === void 0) - return false; - if (typeof handler === "function") { - ReflectApply(handler, this, args); - } else { - var len = handler.length; - var listeners2 = arrayClone(handler, len); - for (var i2 = 0; i2 < len; ++i2) - ReflectApply(listeners2[i2], this, args); - } - return true; -}; -function _addListener(target, type2, listener, prepend) { - var m2; - var events2; - var existing; - checkListener(listener); - events2 = target._events; - if (events2 === void 0) { - events2 = target._events = /* @__PURE__ */ Object.create(null); - target._eventsCount = 0; - } else { - if (events2.newListener !== void 0) { - target.emit( - "newListener", - type2, - listener.listener ? listener.listener : listener - ); - events2 = target._events; - } - existing = events2[type2]; - } - if (existing === void 0) { - existing = events2[type2] = listener; - ++target._eventsCount; - } else { - if (typeof existing === "function") { - existing = events2[type2] = prepend ? [listener, existing] : [existing, listener]; - } else if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } - m2 = _getMaxListeners(target); - if (m2 > 0 && existing.length > m2 && !existing.warned) { - existing.warned = true; - var w3 = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type2) + " listeners added. Use emitter.setMaxListeners() to increase limit"); - w3.name = "MaxListenersExceededWarning"; - w3.emitter = target; - w3.type = type2; - w3.count = existing.length; - ProcessEmitWarning(w3); - } - } - return target; -} -EventEmitter.prototype.addListener = function addListener(type2, listener) { - return _addListener(this, type2, listener, false); -}; -EventEmitter.prototype.on = EventEmitter.prototype.addListener; -EventEmitter.prototype.prependListener = function prependListener(type2, listener) { - return _addListener(this, type2, listener, true); -}; -function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - if (arguments.length === 0) - return this.listener.call(this.target); - return this.listener.apply(this.target, arguments); - } -} -function _onceWrap(target, type2, listener) { - var state = { fired: false, wrapFn: void 0, target, type: type2, listener }; - var wrapped = onceWrapper.bind(state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; -} -EventEmitter.prototype.once = function once(type2, listener) { - checkListener(listener); - this.on(type2, _onceWrap(this, type2, listener)); - return this; -}; -EventEmitter.prototype.prependOnceListener = function prependOnceListener(type2, listener) { - checkListener(listener); - this.prependListener(type2, _onceWrap(this, type2, listener)); - return this; -}; -EventEmitter.prototype.removeListener = function removeListener(type2, listener) { - var list, events2, position, i2, originalListener; - checkListener(listener); - events2 = this._events; - if (events2 === void 0) - return this; - list = events2[type2]; - if (list === void 0) - return this; - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) - this._events = /* @__PURE__ */ Object.create(null); - else { - delete events2[type2]; - if (events2.removeListener) - this.emit("removeListener", type2, list.listener || listener); - } - } else if (typeof list !== "function") { - position = -1; - for (i2 = list.length - 1; i2 >= 0; i2--) { - if (list[i2] === listener || list[i2].listener === listener) { - originalListener = list[i2].listener; - position = i2; - break; - } - } - if (position < 0) - return this; - if (position === 0) - list.shift(); - else { - spliceOne(list, position); - } - if (list.length === 1) - events2[type2] = list[0]; - if (events2.removeListener !== void 0) - this.emit("removeListener", type2, originalListener || listener); - } - return this; -}; -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; -EventEmitter.prototype.removeAllListeners = function removeAllListeners(type2) { - var listeners2, events2, i2; - events2 = this._events; - if (events2 === void 0) - return this; - if (events2.removeListener === void 0) { - if (arguments.length === 0) { - this._events = /* @__PURE__ */ Object.create(null); - this._eventsCount = 0; - } else if (events2[type2] !== void 0) { - if (--this._eventsCount === 0) - this._events = /* @__PURE__ */ Object.create(null); - else - delete events2[type2]; - } - return this; - } - if (arguments.length === 0) { - var keys2 = Object.keys(events2); - var key; - for (i2 = 0; i2 < keys2.length; ++i2) { - key = keys2[i2]; - if (key === "removeListener") - continue; - this.removeAllListeners(key); - } - this.removeAllListeners("removeListener"); - this._events = /* @__PURE__ */ Object.create(null); - this._eventsCount = 0; - return this; - } - listeners2 = events2[type2]; - if (typeof listeners2 === "function") { - this.removeListener(type2, listeners2); - } else if (listeners2 !== void 0) { - for (i2 = listeners2.length - 1; i2 >= 0; i2--) { - this.removeListener(type2, listeners2[i2]); - } - } - return this; -}; -function _listeners(target, type2, unwrap) { - var events2 = target._events; - if (events2 === void 0) - return []; - var evlistener = events2[type2]; - if (evlistener === void 0) - return []; - if (typeof evlistener === "function") - return unwrap ? [evlistener.listener || evlistener] : [evlistener]; - return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); -} -EventEmitter.prototype.listeners = function listeners(type2) { - return _listeners(this, type2, true); -}; -EventEmitter.prototype.rawListeners = function rawListeners(type2) { - return _listeners(this, type2, false); -}; -EventEmitter.listenerCount = function(emitter2, type2) { - if (typeof emitter2.listenerCount === "function") { - return emitter2.listenerCount(type2); - } else { - return listenerCount.call(emitter2, type2); - } -}; -EventEmitter.prototype.listenerCount = listenerCount; -function listenerCount(type2) { - var events2 = this._events; - if (events2 !== void 0) { - var evlistener = events2[type2]; - if (typeof evlistener === "function") { - return 1; - } else if (evlistener !== void 0) { - return evlistener.length; - } - } - return 0; -} -EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; -}; -function arrayClone(arr, n3) { - var copy = new Array(n3); - for (var i2 = 0; i2 < n3; ++i2) - copy[i2] = arr[i2]; - return copy; -} -function spliceOne(list, index) { - for (; index + 1 < list.length; index++) - list[index] = list[index + 1]; - list.pop(); -} -function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i2 = 0; i2 < ret.length; ++i2) { - ret[i2] = arr[i2].listener || arr[i2]; - } - return ret; -} -function once2(emitter2, name2) { - return new Promise(function(resolve, reject) { - function errorListener(err) { - emitter2.removeListener(name2, resolver); - reject(err); - } - function resolver() { - if (typeof emitter2.removeListener === "function") { - emitter2.removeListener("error", errorListener); - } - resolve([].slice.call(arguments)); - } - eventTargetAgnosticAddListener(emitter2, name2, resolver, { once: true }); - if (name2 !== "error") { - addErrorHandlerIfEventEmitter(emitter2, errorListener, { once: true }); - } - }); -} -function addErrorHandlerIfEventEmitter(emitter2, handler, flags) { - if (typeof emitter2.on === "function") { - eventTargetAgnosticAddListener(emitter2, "error", handler, flags); - } -} -function eventTargetAgnosticAddListener(emitter2, name2, listener, flags) { - if (typeof emitter2.on === "function") { - if (flags.once) { - emitter2.once(name2, listener); - } else { - emitter2.on(name2, listener); - } - } else if (typeof emitter2.addEventListener === "function") { - emitter2.addEventListener(name2, function wrapListener(arg) { - if (flags.once) { - emitter2.removeEventListener(name2, wrapListener); - } - listener(arg); - }); - } else { - throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter2); - } -} -var eventsExports = events.exports; -const EventEmitter$1 = /* @__PURE__ */ getDefaultExportFromCjs(eventsExports); -const suspectProtoRx = /"(?:_|\\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*:/; -const suspectConstructorRx = /"(?: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*:/; -const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/; -function jsonParseTransform(key, value) { - if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) { - warnKeyDropped(key); - return; - } - return value; -} -function warnKeyDropped(key) { - console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`); -} -function destr(value, options = {}) { - if (typeof value !== "string") { - return value; - } - const _value = value.trim(); - if ( - // eslint-disable-next-line unicorn/prefer-at - value[0] === '"' && value.endsWith('"') && !value.includes("\\") - ) { - return _value.slice(1, -1); - } - if (_value.length <= 9) { - const _lval = _value.toLowerCase(); - if (_lval === "true") { - return true; - } - if (_lval === "false") { - return false; - } - if (_lval === "undefined") { - return void 0; - } - if (_lval === "null") { - return null; - } - if (_lval === "nan") { - return Number.NaN; - } - if (_lval === "infinity") { - return Number.POSITIVE_INFINITY; - } - if (_lval === "-infinity") { - return Number.NEGATIVE_INFINITY; - } - } - if (!JsonSigRx.test(value)) { - if (options.strict) { - throw new SyntaxError("[destr] Invalid JSON"); - } - return value; - } - try { - if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) { - if (options.strict) { - throw new Error("[destr] Possible prototype pollution"); - } - return JSON.parse(value, jsonParseTransform); - } - return JSON.parse(value); - } catch (error) { - if (options.strict) { - throw error; - } - return value; - } -} -function wrapToPromise(value) { - if (!value || typeof value.then !== "function") { - return Promise.resolve(value); - } - return value; -} -function asyncCall(function_, ...arguments_) { - try { - return wrapToPromise(function_(...arguments_)); - } catch (error) { - return Promise.reject(error); - } -} -function isPrimitive(value) { - const type2 = typeof value; - return value === null || type2 !== "object" && type2 !== "function"; -} -function isPureObject(value) { - const proto = Object.getPrototypeOf(value); - return !proto || proto.isPrototypeOf(Object); -} -function stringify(value) { - if (isPrimitive(value)) { - return String(value); - } - if (isPureObject(value) || Array.isArray(value)) { - return JSON.stringify(value); - } - if (typeof value.toJSON === "function") { - return stringify(value.toJSON()); - } - throw new Error("[unstorage] Cannot stringify value!"); -} -function checkBufferSupport() { - if (typeof Buffer === void 0) { - throw new TypeError("[unstorage] Buffer is not supported!"); - } -} -const BASE64_PREFIX = "base64:"; -function serializeRaw(value) { - if (typeof value === "string") { - return value; - } - checkBufferSupport(); - const base642 = Buffer.from(value).toString("base64"); - return BASE64_PREFIX + base642; -} -function deserializeRaw(value) { - if (typeof value !== "string") { - return value; - } - if (!value.startsWith(BASE64_PREFIX)) { - return value; - } - checkBufferSupport(); - return Buffer.from(value.slice(BASE64_PREFIX.length), "base64"); -} -function normalizeKey(key) { - if (!key) { - return ""; - } - return key.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, ""); -} -function joinKeys(...keys2) { - return normalizeKey(keys2.join(":")); -} -function normalizeBaseKey(base3) { - base3 = normalizeKey(base3); - return base3 ? base3 + ":" : ""; -} -function defineDriver(factory) { - return factory; -} -const DRIVER_NAME = "memory"; -const memory = defineDriver(() => { - const data = /* @__PURE__ */ new Map(); - return { - name: DRIVER_NAME, - options: {}, - hasItem(key) { - return data.has(key); - }, - getItem(key) { - return data.get(key) ?? null; - }, - getItemRaw(key) { - return data.get(key) ?? null; - }, - setItem(key, value) { - data.set(key, value); - }, - setItemRaw(key, value) { - data.set(key, value); - }, - removeItem(key) { - data.delete(key); - }, - getKeys() { - return Array.from(data.keys()); - }, - clear() { - data.clear(); - }, - dispose() { - data.clear(); - } - }; -}); -function createStorage(options = {}) { - const context = { - mounts: { "": options.driver || memory() }, - mountpoints: [""], - watching: false, - watchListeners: [], - unwatch: {} - }; - const getMount = (key) => { - for (const base3 of context.mountpoints) { - if (key.startsWith(base3)) { - return { - base: base3, - relativeKey: key.slice(base3.length), - driver: context.mounts[base3] - }; - } - } - return { - base: "", - relativeKey: key, - driver: context.mounts[""] - }; - }; - const getMounts = (base3, includeParent) => { - return context.mountpoints.filter( - (mountpoint) => mountpoint.startsWith(base3) || includeParent && base3.startsWith(mountpoint) - ).map((mountpoint) => ({ - relativeBase: base3.length > mountpoint.length ? base3.slice(mountpoint.length) : void 0, - mountpoint, - driver: context.mounts[mountpoint] - })); - }; - const onChange = (event, key) => { - if (!context.watching) { - return; - } - key = normalizeKey(key); - for (const listener of context.watchListeners) { - listener(event, key); - } - }; - const startWatch = async () => { - if (context.watching) { - return; - } - context.watching = true; - for (const mountpoint in context.mounts) { - context.unwatch[mountpoint] = await watch$2( - context.mounts[mountpoint], - onChange, - mountpoint - ); - } - }; - const stopWatch = async () => { - if (!context.watching) { - return; - } - for (const mountpoint in context.unwatch) { - await context.unwatch[mountpoint](); - } - context.unwatch = {}; - context.watching = false; - }; - const runBatch = (items, commonOptions, cb) => { - const batches = /* @__PURE__ */ new Map(); - const getBatch = (mount) => { - let batch = batches.get(mount.base); - if (!batch) { - batch = { - driver: mount.driver, - base: mount.base, - items: [] - }; - batches.set(mount.base, batch); - } - return batch; - }; - for (const item of items) { - const isStringItem = typeof item === "string"; - const key = normalizeKey(isStringItem ? item : item.key); - const value = isStringItem ? void 0 : item.value; - const options2 = isStringItem || !item.options ? commonOptions : { ...commonOptions, ...item.options }; - const mount = getMount(key); - getBatch(mount).items.push({ - key, - value, - relativeKey: mount.relativeKey, - options: options2 - }); - } - return Promise.all([...batches.values()].map((batch) => cb(batch))).then( - (r2) => r2.flat() - ); - }; - const storage = { - // Item - hasItem(key, opts = {}) { - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - return asyncCall(driver.hasItem, relativeKey, opts); - }, - getItem(key, opts = {}) { - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - return asyncCall(driver.getItem, relativeKey, opts).then( - (value) => destr(value) - ); - }, - getItems(items, commonOptions) { - return runBatch(items, commonOptions, (batch) => { - if (batch.driver.getItems) { - return asyncCall( - batch.driver.getItems, - batch.items.map((item) => ({ - key: item.relativeKey, - options: item.options - })), - commonOptions - ).then( - (r2) => r2.map((item) => ({ - key: joinKeys(batch.base, item.key), - value: destr(item.value) - })) - ); - } - return Promise.all( - batch.items.map((item) => { - return asyncCall( - batch.driver.getItem, - item.relativeKey, - item.options - ).then((value) => ({ - key: item.key, - value: destr(value) - })); - }) - ); - }); - }, - getItemRaw(key, opts = {}) { - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - if (driver.getItemRaw) { - return asyncCall(driver.getItemRaw, relativeKey, opts); - } - return asyncCall(driver.getItem, relativeKey, opts).then( - (value) => deserializeRaw(value) - ); - }, - async setItem(key, value, opts = {}) { - if (value === void 0) { - return storage.removeItem(key); - } - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - if (!driver.setItem) { - return; - } - await asyncCall(driver.setItem, relativeKey, stringify(value), opts); - if (!driver.watch) { - onChange("update", key); - } - }, - async setItems(items, commonOptions) { - await runBatch(items, commonOptions, async (batch) => { - if (batch.driver.setItems) { - await asyncCall( - batch.driver.setItems, - batch.items.map((item) => ({ - key: item.relativeKey, - value: stringify(item.value), - options: item.options - })), - commonOptions - ); - } - if (!batch.driver.setItem) { - return; - } - await Promise.all( - batch.items.map((item) => { - return asyncCall( - batch.driver.setItem, - item.relativeKey, - stringify(item.value), - item.options - ); - }) - ); - }); - }, - async setItemRaw(key, value, opts = {}) { - if (value === void 0) { - return storage.removeItem(key, opts); - } - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - if (driver.setItemRaw) { - await asyncCall(driver.setItemRaw, relativeKey, value, opts); - } else if (driver.setItem) { - await asyncCall(driver.setItem, relativeKey, serializeRaw(value), opts); - } else { - return; - } - if (!driver.watch) { - onChange("update", key); - } - }, - async removeItem(key, opts = {}) { - if (typeof opts === "boolean") { - opts = { removeMeta: opts }; - } - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - if (!driver.removeItem) { - return; - } - await asyncCall(driver.removeItem, relativeKey, opts); - if (opts.removeMeta || opts.removeMata) { - await asyncCall(driver.removeItem, relativeKey + "$", opts); - } - if (!driver.watch) { - onChange("remove", key); - } - }, - // Meta - async getMeta(key, opts = {}) { - if (typeof opts === "boolean") { - opts = { nativeOnly: opts }; - } - key = normalizeKey(key); - const { relativeKey, driver } = getMount(key); - const meta = /* @__PURE__ */ Object.create(null); - if (driver.getMeta) { - Object.assign(meta, await asyncCall(driver.getMeta, relativeKey, opts)); - } - if (!opts.nativeOnly) { - const value = await asyncCall( - driver.getItem, - relativeKey + "$", - opts - ).then((value_) => destr(value_)); - if (value && typeof value === "object") { - if (typeof value.atime === "string") { - value.atime = new Date(value.atime); - } - if (typeof value.mtime === "string") { - value.mtime = new Date(value.mtime); - } - Object.assign(meta, value); - } - } - return meta; - }, - setMeta(key, value, opts = {}) { - return this.setItem(key + "$", value, opts); - }, - removeMeta(key, opts = {}) { - return this.removeItem(key + "$", opts); - }, - // Keys - async getKeys(base3, opts = {}) { - base3 = normalizeBaseKey(base3); - const mounts = getMounts(base3, true); - let maskedMounts = []; - const allKeys = []; - for (const mount of mounts) { - const rawKeys = await asyncCall( - mount.driver.getKeys, - mount.relativeBase, - opts - ); - const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p3) => key.startsWith(p3))); - allKeys.push(...keys2); - maskedMounts = [ - mount.mountpoint, - ...maskedMounts.filter((p3) => !p3.startsWith(mount.mountpoint)) - ]; - } - return base3 ? allKeys.filter((key) => key.startsWith(base3) && !key.endsWith("$")) : allKeys.filter((key) => !key.endsWith("$")); - }, - // Utils - async clear(base3, opts = {}) { - base3 = normalizeBaseKey(base3); - await Promise.all( - getMounts(base3, false).map(async (m2) => { - if (m2.driver.clear) { - return asyncCall(m2.driver.clear, m2.relativeBase, opts); - } - if (m2.driver.removeItem) { - const keys2 = await m2.driver.getKeys(m2.relativeBase || "", opts); - return Promise.all( - keys2.map((key) => m2.driver.removeItem(key, opts)) - ); - } - }) - ); - }, - async dispose() { - await Promise.all( - Object.values(context.mounts).map((driver) => dispose(driver)) - ); - }, - async watch(callback) { - await startWatch(); - context.watchListeners.push(callback); - return async () => { - context.watchListeners = context.watchListeners.filter( - (listener) => listener !== callback - ); - if (context.watchListeners.length === 0) { - await stopWatch(); - } - }; - }, - async unwatch() { - context.watchListeners = []; - await stopWatch(); - }, - // Mount - mount(base3, driver) { - base3 = normalizeBaseKey(base3); - if (base3 && context.mounts[base3]) { - throw new Error(`already mounted at ${base3}`); - } - if (base3) { - context.mountpoints.push(base3); - context.mountpoints.sort((a3, b3) => b3.length - a3.length); - } - context.mounts[base3] = driver; - if (context.watching) { - Promise.resolve(watch$2(driver, onChange, base3)).then((unwatcher) => { - context.unwatch[base3] = unwatcher; - }).catch(console.error); - } - return storage; - }, - async unmount(base3, _dispose = true) { - base3 = normalizeBaseKey(base3); - if (!base3 || !context.mounts[base3]) { - return; - } - if (context.watching && base3 in context.unwatch) { - context.unwatch[base3](); - delete context.unwatch[base3]; - } - if (_dispose) { - await dispose(context.mounts[base3]); - } - context.mountpoints = context.mountpoints.filter((key) => key !== base3); - delete context.mounts[base3]; - }, - getMount(key = "") { - key = normalizeKey(key) + ":"; - const m2 = getMount(key); - return { - driver: m2.driver, - base: m2.base - }; - }, - getMounts(base3 = "", opts = {}) { - base3 = normalizeKey(base3); - const mounts = getMounts(base3, opts.parents); - return mounts.map((m2) => ({ - driver: m2.driver, - base: m2.mountpoint - })); - } - }; - return storage; -} -function watch$2(driver, onChange, base3) { - return driver.watch ? driver.watch((event, key) => onChange(event, base3 + key)) : () => { - }; -} -async function dispose(driver) { - if (typeof driver.dispose === "function") { - await asyncCall(driver.dispose); - } -} -function promisifyRequest(request) { - return new Promise((resolve, reject) => { - request.oncomplete = request.onsuccess = () => resolve(request.result); - request.onabort = request.onerror = () => reject(request.error); - }); -} -function createStore(dbName, storeName) { - const request = indexedDB.open(dbName); - request.onupgradeneeded = () => request.result.createObjectStore(storeName); - const dbp = promisifyRequest(request); - return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName))); -} -let defaultGetStoreFunc; -function defaultGetStore() { - if (!defaultGetStoreFunc) { - defaultGetStoreFunc = createStore("keyval-store", "keyval"); - } - return defaultGetStoreFunc; -} -function get(key, customStore = defaultGetStore()) { - return customStore("readonly", (store) => promisifyRequest(store.get(key))); -} -function set(key, value, customStore = defaultGetStore()) { - return customStore("readwrite", (store) => { - store.put(value, key); - return promisifyRequest(store.transaction); - }); -} -function del(key, customStore = defaultGetStore()) { - return customStore("readwrite", (store) => { - store.delete(key); - return promisifyRequest(store.transaction); - }); -} -function clear(customStore = defaultGetStore()) { - return customStore("readwrite", (store) => { - store.clear(); - return promisifyRequest(store.transaction); - }); -} -function eachCursor(store, callback) { - store.openCursor().onsuccess = function() { - if (!this.result) - return; - callback(this.result); - this.result.continue(); - }; - return promisifyRequest(store.transaction); -} -function keys(customStore = defaultGetStore()) { - return customStore("readonly", (store) => { - if (store.getAllKeys) { - return promisifyRequest(store.getAllKeys()); - } - const items = []; - return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items); - }); -} -const JSONStringify = (data) => JSON.stringify(data, (_3, value) => typeof value === "bigint" ? value.toString() + "n" : value); -const JSONParse = (json) => { - const numbersBiggerThanMaxInt = /([\[:])?(\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; - const serializedData = json.replace(numbersBiggerThanMaxInt, '$1"$2n"$3'); - return JSON.parse(serializedData, (_3, value) => { - const isCustomFormatBigInt = typeof value === "string" && value.match(/^\d+n$/); - if (isCustomFormatBigInt) - return BigInt(value.substring(0, value.length - 1)); - return value; - }); -}; -function safeJsonParse(value) { - if (typeof value !== "string") { - throw new Error(`Cannot safe json parse value of type ${typeof value}`); - } - try { - return JSONParse(value); - } catch (_a) { - return value; - } -} -function safeJsonStringify(value) { - return typeof value === "string" ? value : JSONStringify(value) || ""; -} -const x$1 = "idb-keyval"; -var z$2 = (i2 = {}) => { - const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e = (s2) => t2 + s2; - let n3; - return i2.dbName && i2.storeName && (n3 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { - return !(typeof await get(e(s2), n3) > "u"); - }, async getItem(s2) { - return await get(e(s2), n3) ?? null; - }, setItem(s2, a3) { - return set(e(s2), a3, n3); - }, removeItem(s2) { - return del(e(s2), n3); - }, getKeys() { - return keys(n3); - }, clear() { - return clear(n3); - } }; -}; -const D$3 = "WALLET_CONNECT_V2_INDEXED_DB", E$1 = "keyvaluestorage"; -let _$2 = class _ { - constructor() { - this.indexedDb = createStorage({ driver: z$2({ dbName: D$3, storeName: E$1 }) }); - } - async getKeys() { - return this.indexedDb.getKeys(); - } - async getEntries() { - return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((t2) => [t2.key, t2.value]); - } - async getItem(t2) { - const e = await this.indexedDb.getItem(t2); - if (e !== null) - return e; - } - async setItem(t2, e) { - await this.indexedDb.setItem(t2, safeJsonStringify(e)); - } - async removeItem(t2) { - await this.indexedDb.removeItem(t2); - } -}; -var l$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c = { exports: {} }; -(function() { - let i2; - function t2() { - } - i2 = t2, i2.prototype.getItem = function(e) { - return this.hasOwnProperty(e) ? String(this[e]) : null; - }, i2.prototype.setItem = function(e, n3) { - this[e] = String(n3); - }, i2.prototype.removeItem = function(e) { - delete this[e]; - }, i2.prototype.clear = function() { - const e = this; - Object.keys(e).forEach(function(n3) { - e[n3] = void 0, delete e[n3]; - }); - }, i2.prototype.key = function(e) { - return e = e || 0, Object.keys(this)[e]; - }, i2.prototype.__defineGetter__("length", function() { - return Object.keys(this).length; - }), typeof l$1 < "u" && l$1.localStorage ? c.exports = l$1.localStorage : typeof window < "u" && window.localStorage ? c.exports = window.localStorage : c.exports = new t2(); -})(); -function k$1(i2) { - var t2; - return [i2[0], safeJsonParse((t2 = i2[1]) != null ? t2 : "")]; -} -class K { - constructor() { - this.localStorage = c.exports; - } - async getKeys() { - return Object.keys(this.localStorage); - } - async getEntries() { - return Object.entries(this.localStorage).map(k$1); - } - async getItem(t2) { - const e = this.localStorage.getItem(t2); - if (e !== null) - return safeJsonParse(e); - } - async setItem(t2, e) { - this.localStorage.setItem(t2, safeJsonStringify(e)); - } - async removeItem(t2) { - this.localStorage.removeItem(t2); - } -} -const N$2 = "wc_storage_version", y$2 = 1, O$2 = async (i2, t2, e) => { - const n3 = N$2, s2 = await t2.getItem(n3); - if (s2 && s2 >= y$2) { - e(t2); - return; - } - const a3 = await i2.getKeys(); - if (!a3.length) { - e(t2); - return; - } - const m2 = []; - for (; a3.length; ) { - const r2 = a3.shift(); - if (!r2) - continue; - const o2 = r2.toLowerCase(); - if (o2.includes("wc@") || o2.includes("walletconnect") || o2.includes("wc_") || o2.includes("wallet_connect")) { - const f2 = await i2.getItem(r2); - await t2.setItem(r2, f2), m2.push(r2); - } - } - await t2.setItem(n3, y$2), e(t2), j$2(i2, m2); -}, j$2 = async (i2, t2) => { - t2.length && t2.forEach(async (e) => { - await i2.removeItem(e); - }); -}; -let h$3 = class h { - constructor() { - this.initialized = false, this.setInitialized = (e) => { - this.storage = e, this.initialized = true; - }; - const t2 = new K(); - this.storage = t2; - try { - const e = new _$2(); - O$2(t2, e, this.setInitialized); - } catch { - this.initialized = true; - } - } - async getKeys() { - return await this.initialize(), this.storage.getKeys(); - } - async getEntries() { - return await this.initialize(), this.storage.getEntries(); - } - async getItem(t2) { - return await this.initialize(), this.storage.getItem(t2); - } - async setItem(t2, e) { - return await this.initialize(), this.storage.setItem(t2, e); - } - async removeItem(t2) { - return await this.initialize(), this.storage.removeItem(t2); - } - async initialize() { - this.initialized || await new Promise((t2) => { - const e = setInterval(() => { - this.initialized && (clearInterval(e), t2()); - }, 20); - }); - } -}; -var cjs$5 = {}; -/*! ***************************************************************************** -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. -***************************************************************************** */ -var extendStatics = function(d3, b3) { - extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { - d4.__proto__ = b4; - } || function(d4, b4) { - for (var p3 in b4) - if (b4.hasOwnProperty(p3)) - d4[p3] = b4[p3]; - }; - return extendStatics(d3, b3); -}; -function __extends(d3, b3) { - extendStatics(d3, b3); - function __() { - this.constructor = d3; - } - d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); -} -var __assign = function() { - __assign = Object.assign || function __assign2(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { - s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; - } - return t2; - }; - return __assign.apply(this, arguments); -}; -function __rest(s2, e) { - var t2 = {}; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3) && e.indexOf(p3) < 0) - t2[p3] = s2[p3]; - if (s2 != null && typeof Object.getOwnPropertySymbols === "function") - for (var i2 = 0, p3 = Object.getOwnPropertySymbols(s2); i2 < p3.length; i2++) { - if (e.indexOf(p3[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p3[i2])) - t2[p3[i2]] = s2[p3[i2]]; - } - return t2; -} -function __decorate(decorators, target, key, desc) { - var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r2 = Reflect.decorate(decorators, target, key, desc); - else - for (var i2 = decorators.length - 1; i2 >= 0; i2--) - if (d3 = decorators[i2]) - r2 = (c2 < 3 ? d3(r2) : c2 > 3 ? d3(target, key, r2) : d3(target, key)) || r2; - return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2; -} -function __param(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; -} -function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") - return Reflect.metadata(metadataKey, metadataValue); -} -function __awaiter(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve) { - resolve(value); - }); - } - return new (P2 || (P2 = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} -function __generator(thisArg, body) { - var _3 = { label: 0, sent: function() { - if (t2[0] & 1) - throw t2[1]; - return t2[1]; - }, trys: [], ops: [] }, f2, y3, t2, g3; - return g3 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() { - return this; - }), g3; - function verb(n3) { - return function(v3) { - return step([n3, v3]); - }; - } - function step(op) { - if (f2) - throw new TypeError("Generator is already executing."); - while (_3) - try { - if (f2 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) - return t2; - if (y3 = 0, t2) - op = [op[0] & 2, t2.value]; - switch (op[0]) { - case 0: - case 1: - t2 = op; - break; - case 4: - _3.label++; - return { value: op[1], done: false }; - case 5: - _3.label++; - y3 = op[1]; - op = [0]; - continue; - case 7: - op = _3.ops.pop(); - _3.trys.pop(); - continue; - default: - if (!(t2 = _3.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _3 = 0; - continue; - } - if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) { - _3.label = op[1]; - break; - } - if (op[0] === 6 && _3.label < t2[1]) { - _3.label = t2[1]; - t2 = op; - break; - } - if (t2 && _3.label < t2[2]) { - _3.label = t2[2]; - _3.ops.push(op); - break; - } - if (t2[2]) - _3.ops.pop(); - _3.trys.pop(); - continue; - } - op = body.call(thisArg, _3); - } catch (e) { - op = [6, e]; - y3 = 0; - } finally { - f2 = t2 = 0; - } - if (op[0] & 5) - throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } -} -function __createBinding(o2, m2, k2, k22) { - if (k22 === void 0) - k22 = k2; - o2[k22] = m2[k2]; -} -function __exportStar(m2, exports2) { - for (var p3 in m2) - if (p3 !== "default" && !exports2.hasOwnProperty(p3)) - exports2[p3] = m2[p3]; -} -function __values(o2) { - var s2 = typeof Symbol === "function" && Symbol.iterator, m2 = s2 && o2[s2], i2 = 0; - if (m2) - return m2.call(o2); - if (o2 && typeof o2.length === "number") - return { - next: function() { - if (o2 && i2 >= o2.length) - o2 = void 0; - return { value: o2 && o2[i2++], done: !o2 }; - } - }; - throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined."); -} -function __read(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) - return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; - try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); - } catch (error) { - e = { error }; - } finally { - try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); - } finally { - if (e) - throw e.error; - } - } - return ar2; -} -function __spread() { - for (var ar2 = [], i2 = 0; i2 < arguments.length; i2++) - ar2 = ar2.concat(__read(arguments[i2])); - return ar2; -} -function __spreadArrays() { - for (var s2 = 0, i2 = 0, il = arguments.length; i2 < il; i2++) - s2 += arguments[i2].length; - for (var r2 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) - for (var a3 = arguments[i2], j2 = 0, jl = a3.length; j2 < jl; j2++, k2++) - r2[k2] = a3[j2]; - return r2; -} -function __await(v3) { - return this instanceof __await ? (this.v = v3, this) : new __await(v3); -} -function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var g3 = generator.apply(thisArg, _arguments || []), i2, q2 = []; - return i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { - return this; - }, i2; - function verb(n3) { - if (g3[n3]) - i2[n3] = function(v3) { - return new Promise(function(a3, b3) { - q2.push([n3, v3, a3, b3]) > 1 || resume(n3, v3); - }); - }; - } - function resume(n3, v3) { - try { - step(g3[n3](v3)); - } catch (e) { - settle(q2[0][3], e); - } - } - function step(r2) { - r2.value instanceof __await ? Promise.resolve(r2.value.v).then(fulfill, reject) : settle(q2[0][2], r2); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f2, v3) { - if (f2(v3), q2.shift(), q2.length) - resume(q2[0][0], q2[0][1]); - } -} -function __asyncDelegator(o2) { - var i2, p3; - return i2 = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i2[Symbol.iterator] = function() { - return this; - }, i2; - function verb(n3, f2) { - i2[n3] = o2[n3] ? function(v3) { - return (p3 = !p3) ? { value: __await(o2[n3](v3)), done: n3 === "return" } : f2 ? f2(v3) : v3; - } : f2; - } -} -function __asyncValues(o2) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var m2 = o2[Symbol.asyncIterator], i2; - return m2 ? m2.call(o2) : (o2 = typeof __values === "function" ? __values(o2) : o2[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { - return this; - }, i2); - function verb(n3) { - i2[n3] = o2[n3] && function(v3) { - return new Promise(function(resolve, reject) { - v3 = o2[n3](v3), settle(resolve, reject, v3.done, v3.value); - }); - }; - } - function settle(resolve, reject, d3, v3) { - Promise.resolve(v3).then(function(v4) { - resolve({ value: v4, done: d3 }); - }, reject); - } -} -function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { - Object.defineProperty(cooked, "raw", { value: raw }); - } else { - cooked.raw = raw; - } - return cooked; -} -function __importStar(mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) { - for (var k2 in mod) - if (Object.hasOwnProperty.call(mod, k2)) - result[k2] = mod[k2]; - } - result.default = mod; - return result; -} -function __importDefault(mod) { - return mod && mod.__esModule ? mod : { default: mod }; -} -function __classPrivateFieldGet(receiver, privateMap) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to get private field on non-instance"); - } - return privateMap.get(receiver); -} -function __classPrivateFieldSet(receiver, privateMap, value) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to set private field on non-instance"); - } - privateMap.set(receiver, value); - return value; -} -const tslib_es6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - get __assign() { - return __assign; - }, - __asyncDelegator, - __asyncGenerator, - __asyncValues, - __await, - __awaiter, - __classPrivateFieldGet, - __classPrivateFieldSet, - __createBinding, - __decorate, - __exportStar, - __extends, - __generator, - __importDefault, - __importStar, - __makeTemplateObject, - __metadata, - __param, - __read, - __rest, - __spread, - __spreadArrays, - __values -}, Symbol.toStringTag, { value: "Module" })); -const require$$0$2 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6); -var heartbeat$2 = {}; -var cjs$4 = {}; -var utils$1 = {}; -var delay = {}; -var hasRequiredDelay; -function requireDelay() { - if (hasRequiredDelay) - return delay; - hasRequiredDelay = 1; - Object.defineProperty(delay, "__esModule", { value: true }); - delay.delay = void 0; - function delay$1(timeout) { - return new Promise((resolve) => { - setTimeout(() => { - resolve(true); - }, timeout); - }); - } - delay.delay = delay$1; - return delay; -} -var convert = {}; -var constants$2 = {}; -var misc = {}; -var hasRequiredMisc; -function requireMisc() { - if (hasRequiredMisc) - return misc; - hasRequiredMisc = 1; - Object.defineProperty(misc, "__esModule", { value: true }); - misc.ONE_THOUSAND = misc.ONE_HUNDRED = void 0; - misc.ONE_HUNDRED = 100; - misc.ONE_THOUSAND = 1e3; - return misc; -} -var time = {}; -var hasRequiredTime; -function requireTime() { - if (hasRequiredTime) - return time; - hasRequiredTime = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.ONE_YEAR = exports2.FOUR_WEEKS = exports2.THREE_WEEKS = exports2.TWO_WEEKS = exports2.ONE_WEEK = exports2.THIRTY_DAYS = exports2.SEVEN_DAYS = exports2.FIVE_DAYS = exports2.THREE_DAYS = exports2.ONE_DAY = exports2.TWENTY_FOUR_HOURS = exports2.TWELVE_HOURS = exports2.SIX_HOURS = exports2.THREE_HOURS = exports2.ONE_HOUR = exports2.SIXTY_MINUTES = exports2.THIRTY_MINUTES = exports2.TEN_MINUTES = exports2.FIVE_MINUTES = exports2.ONE_MINUTE = exports2.SIXTY_SECONDS = exports2.THIRTY_SECONDS = exports2.TEN_SECONDS = exports2.FIVE_SECONDS = exports2.ONE_SECOND = void 0; - exports2.ONE_SECOND = 1; - exports2.FIVE_SECONDS = 5; - exports2.TEN_SECONDS = 10; - exports2.THIRTY_SECONDS = 30; - exports2.SIXTY_SECONDS = 60; - exports2.ONE_MINUTE = exports2.SIXTY_SECONDS; - exports2.FIVE_MINUTES = exports2.ONE_MINUTE * 5; - exports2.TEN_MINUTES = exports2.ONE_MINUTE * 10; - exports2.THIRTY_MINUTES = exports2.ONE_MINUTE * 30; - exports2.SIXTY_MINUTES = exports2.ONE_MINUTE * 60; - exports2.ONE_HOUR = exports2.SIXTY_MINUTES; - exports2.THREE_HOURS = exports2.ONE_HOUR * 3; - exports2.SIX_HOURS = exports2.ONE_HOUR * 6; - exports2.TWELVE_HOURS = exports2.ONE_HOUR * 12; - exports2.TWENTY_FOUR_HOURS = exports2.ONE_HOUR * 24; - exports2.ONE_DAY = exports2.TWENTY_FOUR_HOURS; - exports2.THREE_DAYS = exports2.ONE_DAY * 3; - exports2.FIVE_DAYS = exports2.ONE_DAY * 5; - exports2.SEVEN_DAYS = exports2.ONE_DAY * 7; - exports2.THIRTY_DAYS = exports2.ONE_DAY * 30; - exports2.ONE_WEEK = exports2.SEVEN_DAYS; - exports2.TWO_WEEKS = exports2.ONE_WEEK * 2; - exports2.THREE_WEEKS = exports2.ONE_WEEK * 3; - exports2.FOUR_WEEKS = exports2.ONE_WEEK * 4; - exports2.ONE_YEAR = exports2.ONE_DAY * 365; - })(time); - return time; -} -var hasRequiredConstants$2; -function requireConstants$2() { - if (hasRequiredConstants$2) - return constants$2; - hasRequiredConstants$2 = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireMisc(), exports2); - tslib_1.__exportStar(requireTime(), exports2); - })(constants$2); - return constants$2; -} -var hasRequiredConvert; -function requireConvert() { - if (hasRequiredConvert) - return convert; - hasRequiredConvert = 1; - Object.defineProperty(convert, "__esModule", { value: true }); - convert.fromMiliseconds = convert.toMiliseconds = void 0; - const constants_1 = requireConstants$2(); - function toMiliseconds(seconds) { - return seconds * constants_1.ONE_THOUSAND; - } - convert.toMiliseconds = toMiliseconds; - function fromMiliseconds(miliseconds) { - return Math.floor(miliseconds / constants_1.ONE_THOUSAND); - } - convert.fromMiliseconds = fromMiliseconds; - return convert; -} -var hasRequiredUtils$1; -function requireUtils$1() { - if (hasRequiredUtils$1) - return utils$1; - hasRequiredUtils$1 = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireDelay(), exports2); - tslib_1.__exportStar(requireConvert(), exports2); - })(utils$1); - return utils$1; -} -var watch$1 = {}; -var hasRequiredWatch$1; -function requireWatch$1() { - if (hasRequiredWatch$1) - return watch$1; - hasRequiredWatch$1 = 1; - Object.defineProperty(watch$1, "__esModule", { value: true }); - watch$1.Watch = void 0; - class Watch { - constructor() { - this.timestamps = /* @__PURE__ */ new Map(); - } - start(label) { - if (this.timestamps.has(label)) { - throw new Error(`Watch already started for label: ${label}`); - } - this.timestamps.set(label, { started: Date.now() }); - } - stop(label) { - const timestamp = this.get(label); - if (typeof timestamp.elapsed !== "undefined") { - throw new Error(`Watch already stopped for label: ${label}`); - } - const elapsed = Date.now() - timestamp.started; - this.timestamps.set(label, { started: timestamp.started, elapsed }); - } - get(label) { - const timestamp = this.timestamps.get(label); - if (typeof timestamp === "undefined") { - throw new Error(`No timestamp found for label: ${label}`); - } - return timestamp; - } - elapsed(label) { - const timestamp = this.get(label); - const elapsed = timestamp.elapsed || Date.now() - timestamp.started; - return elapsed; - } - } - watch$1.Watch = Watch; - watch$1.default = Watch; - return watch$1; -} -var types$2 = {}; -var watch = {}; -var hasRequiredWatch; -function requireWatch() { - if (hasRequiredWatch) - return watch; - hasRequiredWatch = 1; - Object.defineProperty(watch, "__esModule", { value: true }); - watch.IWatch = void 0; - class IWatch { - } - watch.IWatch = IWatch; - return watch; -} -var hasRequiredTypes$1; -function requireTypes$1() { - if (hasRequiredTypes$1) - return types$2; - hasRequiredTypes$1 = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireWatch(), exports2); - })(types$2); - return types$2; -} -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireUtils$1(), exports2); - tslib_1.__exportStar(requireWatch$1(), exports2); - tslib_1.__exportStar(requireTypes$1(), exports2); - tslib_1.__exportStar(requireConstants$2(), exports2); -})(cjs$4); -var types$1 = {}; -var heartbeat$1 = {}; -let IEvents$1 = class IEvents { -}; -const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - IEvents: IEvents$1 -}, Symbol.toStringTag, { value: "Module" })); -const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(esm); -var hasRequiredHeartbeat$2; -function requireHeartbeat$2() { - if (hasRequiredHeartbeat$2) - return heartbeat$1; - hasRequiredHeartbeat$2 = 1; - Object.defineProperty(heartbeat$1, "__esModule", { value: true }); - heartbeat$1.IHeartBeat = void 0; - const events_1 = require$$0$1; - class IHeartBeat extends events_1.IEvents { - constructor(opts) { - super(); - } - } - heartbeat$1.IHeartBeat = IHeartBeat; - return heartbeat$1; -} -var hasRequiredTypes; -function requireTypes() { - if (hasRequiredTypes) - return types$1; - hasRequiredTypes = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireHeartbeat$2(), exports2); - })(types$1); - return types$1; -} -var constants$1 = {}; -var heartbeat = {}; -var hasRequiredHeartbeat$1; -function requireHeartbeat$1() { - if (hasRequiredHeartbeat$1) - return heartbeat; - hasRequiredHeartbeat$1 = 1; - Object.defineProperty(heartbeat, "__esModule", { value: true }); - heartbeat.HEARTBEAT_EVENTS = heartbeat.HEARTBEAT_INTERVAL = void 0; - const time_1 = cjs$4; - heartbeat.HEARTBEAT_INTERVAL = time_1.FIVE_SECONDS; - heartbeat.HEARTBEAT_EVENTS = { - pulse: "heartbeat_pulse" - }; - return heartbeat; -} -var hasRequiredConstants$1; -function requireConstants$1() { - if (hasRequiredConstants$1) - return constants$1; - hasRequiredConstants$1 = 1; - (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireHeartbeat$1(), exports2); - })(constants$1); - return constants$1; -} -var hasRequiredHeartbeat; -function requireHeartbeat() { - if (hasRequiredHeartbeat) - return heartbeat$2; - hasRequiredHeartbeat = 1; - Object.defineProperty(heartbeat$2, "__esModule", { value: true }); - heartbeat$2.HeartBeat = void 0; - const tslib_1 = require$$0$2; - const events_1 = eventsExports; - const time_1 = cjs$4; - const types_1 = requireTypes(); - const constants_1 = requireConstants$1(); - class HeartBeat extends types_1.IHeartBeat { - constructor(opts) { - super(opts); - this.events = new events_1.EventEmitter(); - this.interval = constants_1.HEARTBEAT_INTERVAL; - this.interval = (opts === null || opts === void 0 ? void 0 : opts.interval) || constants_1.HEARTBEAT_INTERVAL; - } - static init(opts) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const heartbeat2 = new HeartBeat(opts); - yield heartbeat2.init(); - return heartbeat2; - }); - } - init() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - yield this.initialize(); - }); - } - stop() { - clearInterval(this.intervalRef); - } - on(event, listener) { - this.events.on(event, listener); - } - once(event, listener) { - this.events.once(event, listener); - } - off(event, listener) { - this.events.off(event, listener); - } - removeListener(event, listener) { - this.events.removeListener(event, listener); - } - initialize() { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - this.intervalRef = setInterval(() => this.pulse(), time_1.toMiliseconds(this.interval)); - }); - } - pulse() { - this.events.emit(constants_1.HEARTBEAT_EVENTS.pulse); - } - } - heartbeat$2.HeartBeat = HeartBeat; - return heartbeat$2; -} -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireHeartbeat(), exports2); - tslib_1.__exportStar(requireTypes(), exports2); - tslib_1.__exportStar(requireConstants$1(), exports2); -})(cjs$5); -var cjs$3 = {}; -var quickFormatUnescaped; -var hasRequiredQuickFormatUnescaped; -function requireQuickFormatUnescaped() { - if (hasRequiredQuickFormatUnescaped) - return quickFormatUnescaped; - hasRequiredQuickFormatUnescaped = 1; - function tryStringify(o2) { - try { - return JSON.stringify(o2); - } catch (e) { - return '"[Circular]"'; - } - } - quickFormatUnescaped = format; - function format(f2, args, opts) { - var ss2 = opts && opts.stringify || tryStringify; - var offset = 1; - if (typeof f2 === "object" && f2 !== null) { - var len = args.length + offset; - if (len === 1) - return f2; - var objects = new Array(len); - objects[0] = ss2(f2); - for (var index = 1; index < len; index++) { - objects[index] = ss2(args[index]); - } - return objects.join(" "); - } - if (typeof f2 !== "string") { - return f2; - } - var argLen = args.length; - if (argLen === 0) - return f2; - var str = ""; - var a3 = 1 - offset; - var lastPos = -1; - var flen = f2 && f2.length || 0; - for (var i2 = 0; i2 < flen; ) { - if (f2.charCodeAt(i2) === 37 && i2 + 1 < flen) { - lastPos = lastPos > -1 ? lastPos : 0; - switch (f2.charCodeAt(i2 + 1)) { - case 100: - case 102: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Number(args[a3]); - lastPos = i2 + 2; - i2++; - break; - case 105: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Math.floor(Number(args[a3])); - lastPos = i2 + 2; - i2++; - break; - case 79: - case 111: - case 106: - if (a3 >= argLen) - break; - if (args[a3] === void 0) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - var type2 = typeof args[a3]; - if (type2 === "string") { - str += "'" + args[a3] + "'"; - lastPos = i2 + 2; - i2++; - break; - } - if (type2 === "function") { - str += args[a3].name || ""; - lastPos = i2 + 2; - i2++; - break; - } - str += ss2(args[a3]); - lastPos = i2 + 2; - i2++; - break; - case 115: - if (a3 >= argLen) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += String(args[a3]); - lastPos = i2 + 2; - i2++; - break; - case 37: - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += "%"; - lastPos = i2 + 2; - i2++; - a3--; - break; - } - ++a3; - } - ++i2; - } - if (lastPos === -1) - return f2; - else if (lastPos < flen) { - str += f2.slice(lastPos); - } - return str; - } - return quickFormatUnescaped; -} -var browser$4; -var hasRequiredBrowser; -function requireBrowser() { - if (hasRequiredBrowser) - return browser$4; - hasRequiredBrowser = 1; - const format = requireQuickFormatUnescaped(); - browser$4 = pino; - const _console = pfGlobalThisOrFallback().console || {}; - const stdSerializers = { - mapHttpRequest: mock, - mapHttpResponse: mock, - wrapRequestSerializer: passthrough, - wrapResponseSerializer: passthrough, - wrapErrorSerializer: passthrough, - req: mock, - res: mock, - err: asErrValue - }; - function shouldSerialize(serialize, serializers) { - if (Array.isArray(serialize)) { - const hasToFilter = serialize.filter(function(k2) { - return k2 !== "!stdSerializers.err"; - }); - return hasToFilter; - } else if (serialize === true) { - return Object.keys(serializers); - } - return false; - } - function pino(opts) { - opts = opts || {}; - opts.browser = opts.browser || {}; - const transmit2 = opts.browser.transmit; - if (transmit2 && typeof transmit2.send !== "function") { - throw Error("pino: transmit option must have a send function"); - } - const proto = opts.browser.write || _console; - if (opts.browser.write) - opts.browser.asObject = true; - const serializers = opts.serializers || {}; - const serialize = shouldSerialize(opts.browser.serialize, serializers); - let stdErrSerialize = opts.browser.serialize; - if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) - stdErrSerialize = false; - const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; - if (typeof proto === "function") { - proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; - } - if (opts.enabled === false) - opts.level = "silent"; - const level = opts.level || "info"; - const logger = Object.create(proto); - if (!logger.log) - logger.log = noop; - Object.defineProperty(logger, "levelVal", { - get: getLevelVal - }); - Object.defineProperty(logger, "level", { - get: getLevel, - set: setLevel - }); - const setOpts = { - transmit: transmit2, - serialize, - asObject: opts.browser.asObject, - levels, - timestamp: getTimeFunction(opts) - }; - logger.levels = pino.levels; - logger.level = level; - logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop; - logger.serializers = serializers; - logger._serialize = serialize; - logger._stdErrSerialize = stdErrSerialize; - logger.child = child; - if (transmit2) - logger._logEvent = createLogEventShape(); - function getLevelVal() { - return this.level === "silent" ? Infinity : this.levels.values[this.level]; - } - function getLevel() { - return this._level; - } - function setLevel(level2) { - if (level2 !== "silent" && !this.levels.values[level2]) { - throw Error("unknown level " + level2); - } - this._level = level2; - set2(setOpts, logger, "error", "log"); - set2(setOpts, logger, "fatal", "error"); - set2(setOpts, logger, "warn", "error"); - set2(setOpts, logger, "info", "log"); - set2(setOpts, logger, "debug", "log"); - set2(setOpts, logger, "trace", "log"); - } - function child(bindings, childOptions) { - if (!bindings) { - throw new Error("missing bindings for child Pino"); - } - childOptions = childOptions || {}; - if (serialize && bindings.serializers) { - childOptions.serializers = bindings.serializers; - } - const childOptionsSerializers = childOptions.serializers; - if (serialize && childOptionsSerializers) { - var childSerializers = Object.assign({}, serializers, childOptionsSerializers); - var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; - delete bindings.serializers; - applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); - } - function Child(parent) { - this._childLevel = (parent._childLevel | 0) + 1; - this.error = bind(parent, bindings, "error"); - this.fatal = bind(parent, bindings, "fatal"); - this.warn = bind(parent, bindings, "warn"); - this.info = bind(parent, bindings, "info"); - this.debug = bind(parent, bindings, "debug"); - this.trace = bind(parent, bindings, "trace"); - if (childSerializers) { - this.serializers = childSerializers; - this._serialize = childSerialize; - } - if (transmit2) { - this._logEvent = createLogEventShape( - [].concat(parent._logEvent.bindings, bindings) - ); - } - } - Child.prototype = this; - return new Child(this); - } - return logger; - } - pino.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" - } - }; - pino.stdSerializers = stdSerializers; - pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); - function set2(opts, logger, level, fallback) { - const proto = Object.getPrototypeOf(logger); - logger[level] = logger.levelVal > logger.levels.values[level] ? noop : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop; - wrap(opts, logger, level); - } - function wrap(opts, logger, level) { - if (!opts.transmit && logger[level] === noop) - return; - logger[level] = /* @__PURE__ */ function(write) { - return function LOG() { - const ts2 = opts.timestamp(); - const args = new Array(arguments.length); - const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; - for (var i2 = 0; i2 < args.length; i2++) - args[i2] = arguments[i2]; - if (opts.serialize && !opts.asObject) { - applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); - } - if (opts.asObject) - write.call(proto, asObject(this, level, args, ts2)); - else - write.apply(proto, args); - if (opts.transmit) { - const transmitLevel = opts.transmit.level || logger.level; - const transmitValue = pino.levels.values[transmitLevel]; - const methodValue = pino.levels.values[level]; - if (methodValue < transmitValue) - return; - transmit(this, { - ts: ts2, - methodLevel: level, - methodValue, - transmitLevel, - transmitValue: pino.levels.values[opts.transmit.level || logger.level], - send: opts.transmit.send, - val: logger.levelVal - }, args); - } - }; - }(logger[level]); - } - function asObject(logger, level, args, ts2) { - if (logger._serialize) - applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); - const argsCloned = args.slice(); - let msg = argsCloned[0]; - const o2 = {}; - if (ts2) { - o2.time = ts2; - } - o2.level = pino.levels.values[level]; - let lvl = (logger._childLevel | 0) + 1; - if (lvl < 1) - lvl = 1; - if (msg !== null && typeof msg === "object") { - while (lvl-- && typeof argsCloned[0] === "object") { - Object.assign(o2, argsCloned.shift()); - } - msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; - } else if (typeof msg === "string") - msg = format(argsCloned.shift(), argsCloned); - if (msg !== void 0) - o2.msg = msg; - return o2; - } - function applySerializers(args, serialize, serializers, stdErrSerialize) { - for (const i2 in args) { - if (stdErrSerialize && args[i2] instanceof Error) { - args[i2] = pino.stdSerializers.err(args[i2]); - } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { - for (const k2 in args[i2]) { - if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { - args[i2][k2] = serializers[k2](args[i2][k2]); - } - } - } - } - } - function bind(parent, bindings, level) { - return function() { - const args = new Array(1 + arguments.length); - args[0] = bindings; - for (var i2 = 1; i2 < args.length; i2++) { - args[i2] = arguments[i2 - 1]; - } - return parent[level].apply(this, args); - }; - } - function transmit(logger, opts, args) { - const send = opts.send; - const ts2 = opts.ts; - const methodLevel = opts.methodLevel; - const methodValue = opts.methodValue; - const val = opts.val; - const bindings = logger._logEvent.bindings; - applySerializers( - args, - logger._serialize || Object.keys(logger.serializers), - logger.serializers, - logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize - ); - logger._logEvent.ts = ts2; - logger._logEvent.messages = args.filter(function(arg) { - return bindings.indexOf(arg) === -1; - }); - logger._logEvent.level.label = methodLevel; - logger._logEvent.level.value = methodValue; - send(methodLevel, logger._logEvent, val); - logger._logEvent = createLogEventShape(bindings); - } - function createLogEventShape(bindings) { - return { - ts: 0, - messages: [], - bindings: bindings || [], - level: { label: "", value: 0 } - }; - } - function asErrValue(err) { - const obj = { - type: err.constructor.name, - msg: err.message, - stack: err.stack - }; - for (const key in err) { - if (obj[key] === void 0) { - obj[key] = err[key]; - } - } - return obj; - } - function getTimeFunction(opts) { - if (typeof opts.timestamp === "function") { - return opts.timestamp; - } - if (opts.timestamp === false) { - return nullTime; - } - return epochTime; - } - function mock() { - return {}; - } - function passthrough(a3) { - return a3; - } - function noop() { - } - function nullTime() { - return false; - } - function epochTime() { - return Date.now(); - } - function unixTime() { - return Math.round(Date.now() / 1e3); - } - function isoTime() { - return new Date(Date.now()).toISOString(); - } - function pfGlobalThisOrFallback() { - function defd(o2) { - return typeof o2 !== "undefined" && o2; - } - try { - if (typeof globalThis !== "undefined") - return globalThis; - Object.defineProperty(Object.prototype, "globalThis", { - get: function() { - delete Object.prototype.globalThis; - return this.globalThis = this; - }, - configurable: true - }); - return globalThis; - } catch (e) { - return defd(self) || defd(window) || defd(this) || {}; - } - } - return browser$4; -} -var constants = {}; -var hasRequiredConstants; -function requireConstants() { - if (hasRequiredConstants) - return constants; - hasRequiredConstants = 1; - Object.defineProperty(constants, "__esModule", { value: true }); - constants.PINO_CUSTOM_CONTEXT_KEY = constants.PINO_LOGGER_DEFAULTS = void 0; - constants.PINO_LOGGER_DEFAULTS = { - level: "info" - }; - constants.PINO_CUSTOM_CONTEXT_KEY = "custom_context"; - return constants; -} -var utils = {}; -var hasRequiredUtils; -function requireUtils() { - if (hasRequiredUtils) - return utils; - hasRequiredUtils = 1; - Object.defineProperty(utils, "__esModule", { value: true }); - utils.generateChildLogger = utils.formatChildLoggerContext = utils.getLoggerContext = utils.setBrowserLoggerContext = utils.getBrowserLoggerContext = utils.getDefaultLoggerOptions = void 0; - const constants_1 = requireConstants(); - function getDefaultLoggerOptions(opts) { - return Object.assign(Object.assign({}, opts), { level: (opts === null || opts === void 0 ? void 0 : opts.level) || constants_1.PINO_LOGGER_DEFAULTS.level }); - } - utils.getDefaultLoggerOptions = getDefaultLoggerOptions; - function getBrowserLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - return logger[customContextKey] || ""; - } - utils.getBrowserLoggerContext = getBrowserLoggerContext; - function setBrowserLoggerContext(logger, context, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - logger[customContextKey] = context; - return logger; - } - utils.setBrowserLoggerContext = setBrowserLoggerContext; - function getLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - let context = ""; - if (typeof logger.bindings === "undefined") { - context = getBrowserLoggerContext(logger, customContextKey); - } else { - context = logger.bindings().context || ""; - } - return context; - } - utils.getLoggerContext = getLoggerContext; - function formatChildLoggerContext(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const parentContext = getLoggerContext(logger, customContextKey); - const context = parentContext.trim() ? `${parentContext}/${childContext}` : childContext; - return context; - } - utils.formatChildLoggerContext = formatChildLoggerContext; - function generateChildLogger(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const context = formatChildLoggerContext(logger, childContext, customContextKey); - const child = logger.child({ context }); - return setBrowserLoggerContext(child, context, customContextKey); - } - utils.generateChildLogger = generateChildLogger; - return utils; -} -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.pino = void 0; - const tslib_1 = require$$0$2; - const pino_1 = tslib_1.__importDefault(requireBrowser()); - Object.defineProperty(exports2, "pino", { enumerable: true, get: function() { - return pino_1.default; - } }); - tslib_1.__exportStar(requireConstants(), exports2); - tslib_1.__exportStar(requireUtils(), exports2); -})(cjs$3); -let n$1 = class n extends IEvents$1 { - constructor(s2) { - super(), this.opts = s2, this.protocol = "wc", this.version = 2; - } -}; -let h$2 = class h2 extends IEvents$1 { - constructor(s2, t2) { - super(), this.core = s2, this.logger = t2, this.records = /* @__PURE__ */ new Map(); - } -}; -let a$2 = class a { - constructor(s2, t2) { - this.logger = s2, this.core = t2; - } -}; -let u$1 = class u extends IEvents$1 { - constructor(s2, t2) { - super(), this.relayer = s2, this.logger = t2; - } -}; -let g$4 = class g extends IEvents$1 { - constructor(s2) { - super(); - } -}; -let p$2 = class p { - constructor(s2, t2, o2, M2) { - this.core = s2, this.logger = t2, this.name = o2; - } -}; -class d2 extends IEvents$1 { - constructor(s2, t2) { - super(), this.relayer = s2, this.logger = t2; - } -} -class E extends IEvents$1 { - constructor(s2, t2) { - super(), this.core = s2, this.logger = t2; - } -} -let y$1 = class y { - constructor(s2, t2) { - this.projectId = s2, this.logger = t2; - } -}; -let v$1 = class v { - constructor(s2, t2) { - this.projectId = s2, this.logger = t2; - } -}; -let b$1 = class b { - constructor(s2) { - this.opts = s2, this.protocol = "wc", this.version = 2; - } -}; -let w$4 = class w { - constructor(s2) { - this.client = s2; - } -}; -var ed25519 = {}; -var random = {}; -var system = {}; -var browser$3 = {}; -Object.defineProperty(browser$3, "__esModule", { value: true }); -browser$3.BrowserRandomSource = void 0; -const QUOTA = 65536; -class BrowserRandomSource { - constructor() { - this.isAvailable = false; - this.isInstantiated = false; - const browserCrypto = typeof self !== "undefined" ? self.crypto || self.msCrypto : null; - if (browserCrypto && browserCrypto.getRandomValues !== void 0) { - this._crypto = browserCrypto; - this.isAvailable = true; - this.isInstantiated = true; - } - } - randomBytes(length) { - if (!this.isAvailable || !this._crypto) { - throw new Error("Browser random byte generator is not available."); - } - const out = new Uint8Array(length); - for (let i2 = 0; i2 < out.length; i2 += QUOTA) { - this._crypto.getRandomValues(out.subarray(i2, i2 + Math.min(out.length - i2, QUOTA))); - } - return out; - } -} -browser$3.BrowserRandomSource = BrowserRandomSource; -function commonjsRequire(path) { - throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); -} -var node = {}; -var wipe$1 = {}; -Object.defineProperty(wipe$1, "__esModule", { value: true }); -function wipe(array) { - for (var i2 = 0; i2 < array.length; i2++) { - array[i2] = 0; - } - return array; -} -wipe$1.wipe = wipe; -const __viteBrowserExternal = {}; -const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: __viteBrowserExternal -}, Symbol.toStringTag, { value: "Module" })); -const require$$1 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1); -Object.defineProperty(node, "__esModule", { value: true }); -node.NodeRandomSource = void 0; -const wipe_1$3 = wipe$1; -class NodeRandomSource { - constructor() { - this.isAvailable = false; - this.isInstantiated = false; - if (typeof commonjsRequire !== "undefined") { - const nodeCrypto = require$$1; - if (nodeCrypto && nodeCrypto.randomBytes) { - this._crypto = nodeCrypto; - this.isAvailable = true; - this.isInstantiated = true; - } - } - } - randomBytes(length) { - if (!this.isAvailable || !this._crypto) { - throw new Error("Node.js random byte generator is not available."); - } - let buffer = this._crypto.randomBytes(length); - if (buffer.length !== length) { - throw new Error("NodeRandomSource: got fewer bytes than requested"); - } - const out = new Uint8Array(length); - for (let i2 = 0; i2 < out.length; i2++) { - out[i2] = buffer[i2]; - } - (0, wipe_1$3.wipe)(buffer); - return out; - } -} -node.NodeRandomSource = NodeRandomSource; -Object.defineProperty(system, "__esModule", { value: true }); -system.SystemRandomSource = void 0; -const browser_1 = browser$3; -const node_1 = node; -class SystemRandomSource { - constructor() { - this.isAvailable = false; - this.name = ""; - this._source = new browser_1.BrowserRandomSource(); - if (this._source.isAvailable) { - this.isAvailable = true; - this.name = "Browser"; - return; - } - this._source = new node_1.NodeRandomSource(); - if (this._source.isAvailable) { - this.isAvailable = true; - this.name = "Node"; - return; - } - } - randomBytes(length) { - if (!this.isAvailable) { - throw new Error("System random byte generator is not available."); - } - return this._source.randomBytes(length); - } -} -system.SystemRandomSource = SystemRandomSource; -var binary = {}; -var int = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - function imulShim(a3, b3) { - var ah = a3 >>> 16 & 65535, al = a3 & 65535; - var bh = b3 >>> 16 & 65535, bl = b3 & 65535; - return al * bl + (ah * bl + al * bh << 16 >>> 0) | 0; - } - exports2.mul = Math.imul || imulShim; - function add(a3, b3) { - return a3 + b3 | 0; - } - exports2.add = add; - function sub(a3, b3) { - return a3 - b3 | 0; - } - exports2.sub = sub; - function rotl(x2, n3) { - return x2 << n3 | x2 >>> 32 - n3; - } - exports2.rotl = rotl; - function rotr(x2, n3) { - return x2 << 32 - n3 | x2 >>> n3; - } - exports2.rotr = rotr; - function isIntegerShim(n3) { - return typeof n3 === "number" && isFinite(n3) && Math.floor(n3) === n3; - } - exports2.isInteger = Number.isInteger || isIntegerShim; - exports2.MAX_SAFE_INTEGER = 9007199254740991; - exports2.isSafeInteger = function(n3) { - return exports2.isInteger(n3) && (n3 >= -exports2.MAX_SAFE_INTEGER && n3 <= exports2.MAX_SAFE_INTEGER); - }; -})(int); -Object.defineProperty(binary, "__esModule", { value: true }); -var int_1 = int; -function readInt16BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 0] << 8 | array[offset + 1]) << 16 >> 16; -} -binary.readInt16BE = readInt16BE; -function readUint16BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 0] << 8 | array[offset + 1]) >>> 0; -} -binary.readUint16BE = readUint16BE; -function readInt16LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 1] << 8 | array[offset]) << 16 >> 16; -} -binary.readInt16LE = readInt16LE; -function readUint16LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 1] << 8 | array[offset]) >>> 0; -} -binary.readUint16LE = readUint16LE; -function writeUint16BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(2); - } - if (offset === void 0) { - offset = 0; - } - out[offset + 0] = value >>> 8; - out[offset + 1] = value >>> 0; - return out; -} -binary.writeUint16BE = writeUint16BE; -binary.writeInt16BE = writeUint16BE; -function writeUint16LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(2); - } - if (offset === void 0) { - offset = 0; - } - out[offset + 0] = value >>> 0; - out[offset + 1] = value >>> 8; - return out; -} -binary.writeUint16LE = writeUint16LE; -binary.writeInt16LE = writeUint16LE; -function readInt32BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3]; -} -binary.readInt32BE = readInt32BE; -function readUint32BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset] << 24 | array[offset + 1] << 16 | array[offset + 2] << 8 | array[offset + 3]) >>> 0; -} -binary.readUint32BE = readUint32BE; -function readInt32LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return array[offset + 3] << 24 | array[offset + 2] << 16 | array[offset + 1] << 8 | array[offset]; -} -binary.readInt32LE = readInt32LE; -function readUint32LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - return (array[offset + 3] << 24 | array[offset + 2] << 16 | array[offset + 1] << 8 | array[offset]) >>> 0; -} -binary.readUint32LE = readUint32LE; -function writeUint32BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(4); - } - if (offset === void 0) { - offset = 0; - } - out[offset + 0] = value >>> 24; - out[offset + 1] = value >>> 16; - out[offset + 2] = value >>> 8; - out[offset + 3] = value >>> 0; - return out; -} -binary.writeUint32BE = writeUint32BE; -binary.writeInt32BE = writeUint32BE; -function writeUint32LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(4); - } - if (offset === void 0) { - offset = 0; - } - out[offset + 0] = value >>> 0; - out[offset + 1] = value >>> 8; - out[offset + 2] = value >>> 16; - out[offset + 3] = value >>> 24; - return out; -} -binary.writeUint32LE = writeUint32LE; -binary.writeInt32LE = writeUint32LE; -function readInt64BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var hi = readInt32BE(array, offset); - var lo = readInt32BE(array, offset + 4); - return hi * 4294967296 + lo - (lo >> 31) * 4294967296; -} -binary.readInt64BE = readInt64BE; -function readUint64BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var hi = readUint32BE(array, offset); - var lo = readUint32BE(array, offset + 4); - return hi * 4294967296 + lo; -} -binary.readUint64BE = readUint64BE; -function readInt64LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var lo = readInt32LE(array, offset); - var hi = readInt32LE(array, offset + 4); - return hi * 4294967296 + lo - (lo >> 31) * 4294967296; -} -binary.readInt64LE = readInt64LE; -function readUint64LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var lo = readUint32LE(array, offset); - var hi = readUint32LE(array, offset + 4); - return hi * 4294967296 + lo; -} -binary.readUint64LE = readUint64LE; -function writeUint64BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(8); - } - if (offset === void 0) { - offset = 0; - } - writeUint32BE(value / 4294967296 >>> 0, out, offset); - writeUint32BE(value >>> 0, out, offset + 4); - return out; -} -binary.writeUint64BE = writeUint64BE; -binary.writeInt64BE = writeUint64BE; -function writeUint64LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(8); - } - if (offset === void 0) { - offset = 0; - } - writeUint32LE(value >>> 0, out, offset); - writeUint32LE(value / 4294967296 >>> 0, out, offset + 4); - return out; -} -binary.writeUint64LE = writeUint64LE; -binary.writeInt64LE = writeUint64LE; -function readUintBE(bitLength, array, offset) { - if (offset === void 0) { - offset = 0; - } - if (bitLength % 8 !== 0) { - throw new Error("readUintBE supports only bitLengths divisible by 8"); - } - if (bitLength / 8 > array.length - offset) { - throw new Error("readUintBE: array is too short for the given bitLength"); - } - var result = 0; - var mul = 1; - for (var i2 = bitLength / 8 + offset - 1; i2 >= offset; i2--) { - result += array[i2] * mul; - mul *= 256; - } - return result; -} -binary.readUintBE = readUintBE; -function readUintLE(bitLength, array, offset) { - if (offset === void 0) { - offset = 0; - } - if (bitLength % 8 !== 0) { - throw new Error("readUintLE supports only bitLengths divisible by 8"); - } - if (bitLength / 8 > array.length - offset) { - throw new Error("readUintLE: array is too short for the given bitLength"); - } - var result = 0; - var mul = 1; - for (var i2 = offset; i2 < offset + bitLength / 8; i2++) { - result += array[i2] * mul; - mul *= 256; - } - return result; -} -binary.readUintLE = readUintLE; -function writeUintBE(bitLength, value, out, offset) { - if (out === void 0) { - out = new Uint8Array(bitLength / 8); - } - if (offset === void 0) { - offset = 0; - } - if (bitLength % 8 !== 0) { - throw new Error("writeUintBE supports only bitLengths divisible by 8"); - } - if (!int_1.isSafeInteger(value)) { - throw new Error("writeUintBE value must be an integer"); - } - var div = 1; - for (var i2 = bitLength / 8 + offset - 1; i2 >= offset; i2--) { - out[i2] = value / div & 255; - div *= 256; - } - return out; -} -binary.writeUintBE = writeUintBE; -function writeUintLE(bitLength, value, out, offset) { - if (out === void 0) { - out = new Uint8Array(bitLength / 8); - } - if (offset === void 0) { - offset = 0; - } - if (bitLength % 8 !== 0) { - throw new Error("writeUintLE supports only bitLengths divisible by 8"); - } - if (!int_1.isSafeInteger(value)) { - throw new Error("writeUintLE value must be an integer"); - } - var div = 1; - for (var i2 = offset; i2 < offset + bitLength / 8; i2++) { - out[i2] = value / div & 255; - div *= 256; - } - return out; -} -binary.writeUintLE = writeUintLE; -function readFloat32BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var view = new DataView(array.buffer, array.byteOffset, array.byteLength); - return view.getFloat32(offset); -} -binary.readFloat32BE = readFloat32BE; -function readFloat32LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var view = new DataView(array.buffer, array.byteOffset, array.byteLength); - return view.getFloat32(offset, true); -} -binary.readFloat32LE = readFloat32LE; -function readFloat64BE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var view = new DataView(array.buffer, array.byteOffset, array.byteLength); - return view.getFloat64(offset); -} -binary.readFloat64BE = readFloat64BE; -function readFloat64LE(array, offset) { - if (offset === void 0) { - offset = 0; - } - var view = new DataView(array.buffer, array.byteOffset, array.byteLength); - return view.getFloat64(offset, true); -} -binary.readFloat64LE = readFloat64LE; -function writeFloat32BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(4); - } - if (offset === void 0) { - offset = 0; - } - var view = new DataView(out.buffer, out.byteOffset, out.byteLength); - view.setFloat32(offset, value); - return out; -} -binary.writeFloat32BE = writeFloat32BE; -function writeFloat32LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(4); - } - if (offset === void 0) { - offset = 0; - } - var view = new DataView(out.buffer, out.byteOffset, out.byteLength); - view.setFloat32(offset, value, true); - return out; -} -binary.writeFloat32LE = writeFloat32LE; -function writeFloat64BE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(8); - } - if (offset === void 0) { - offset = 0; - } - var view = new DataView(out.buffer, out.byteOffset, out.byteLength); - view.setFloat64(offset, value); - return out; -} -binary.writeFloat64BE = writeFloat64BE; -function writeFloat64LE(value, out, offset) { - if (out === void 0) { - out = new Uint8Array(8); - } - if (offset === void 0) { - offset = 0; - } - var view = new DataView(out.buffer, out.byteOffset, out.byteLength); - view.setFloat64(offset, value, true); - return out; -} -binary.writeFloat64LE = writeFloat64LE; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.randomStringForEntropy = exports2.randomString = exports2.randomUint32 = exports2.randomBytes = exports2.defaultRandomSource = void 0; - const system_1 = system; - const binary_12 = binary; - const wipe_12 = wipe$1; - exports2.defaultRandomSource = new system_1.SystemRandomSource(); - function randomBytes(length, prng = exports2.defaultRandomSource) { - return prng.randomBytes(length); - } - exports2.randomBytes = randomBytes; - function randomUint32(prng = exports2.defaultRandomSource) { - const buf = randomBytes(4, prng); - const result = (0, binary_12.readUint32LE)(buf); - (0, wipe_12.wipe)(buf); - return result; - } - exports2.randomUint32 = randomUint32; - const ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - function randomString(length, charset = ALPHANUMERIC, prng = exports2.defaultRandomSource) { - if (charset.length < 2) { - throw new Error("randomString charset is too short"); - } - if (charset.length > 256) { - throw new Error("randomString charset is too long"); - } - let out = ""; - const charsLen = charset.length; - const maxByte = 256 - 256 % charsLen; - while (length > 0) { - const buf = randomBytes(Math.ceil(length * 256 / maxByte), prng); - for (let i2 = 0; i2 < buf.length && length > 0; i2++) { - const randomByte = buf[i2]; - if (randomByte < maxByte) { - out += charset.charAt(randomByte % charsLen); - length--; - } - } - (0, wipe_12.wipe)(buf); - } - return out; - } - exports2.randomString = randomString; - function randomStringForEntropy(bits, charset = ALPHANUMERIC, prng = exports2.defaultRandomSource) { - const length = Math.ceil(bits / (Math.log(charset.length) / Math.LN2)); - return randomString(length, charset, prng); - } - exports2.randomStringForEntropy = randomStringForEntropy; -})(random); -var sha512 = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var binary_12 = binary; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 64; - exports2.BLOCK_SIZE = 128; - var SHA512 = ( - /** @class */ - function() { - function SHA5122() { - this.digestLength = exports2.DIGEST_LENGTH; - this.blockSize = exports2.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 = false; - this.reset(); - } - SHA5122.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; - }; - SHA5122.prototype.reset = function() { - this._initState(); - this._bufferLength = 0; - this._bytesHashed = 0; - this._finished = false; - return this; - }; - SHA5122.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._tempHi); - wipe_12.wipe(this._tempLo); - this.reset(); - }; - SHA5122.prototype.update = function(data, dataLength) { - if (dataLength === void 0) { - dataLength = data.length; - } - if (this._finished) { - throw new Error("SHA512: can't update because hash was finished."); - } - var dataPos = 0; - this._bytesHashed += dataLength; - if (this._bufferLength > 0) { - while (this._bufferLength < exports2.BLOCK_SIZE && dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - if (this._bufferLength === this.blockSize) { - hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, this.blockSize); - this._bufferLength = 0; - } - } - if (dataLength >= this.blockSize) { - dataPos = hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, data, dataPos, dataLength); - dataLength %= this.blockSize; - } - while (dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - return this; - }; - SHA5122.prototype.finish = function(out) { - if (!this._finished) { - var bytesHashed = this._bytesHashed; - var left = this._bufferLength; - var bitLenHi = bytesHashed / 536870912 | 0; - var bitLenLo = bytesHashed << 3; - var padLength = bytesHashed % 128 < 112 ? 128 : 256; - this._buffer[left] = 128; - for (var i2 = left + 1; i2 < padLength - 8; i2++) { - this._buffer[i2] = 0; - } - binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); - binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); - hashBlocks(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, padLength); - this._finished = true; - } - for (var i2 = 0; i2 < this.digestLength / 8; i2++) { - binary_12.writeUint32BE(this._stateHi[i2], out, i2 * 8); - binary_12.writeUint32BE(this._stateLo[i2], out, i2 * 8 + 4); - } - return this; - }; - SHA5122.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - SHA5122.prototype.saveState = function() { - if (this._finished) { - throw new Error("SHA256: cannot save finished state"); - } - return { - stateHi: new Int32Array(this._stateHi), - stateLo: new Int32Array(this._stateLo), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed - }; - }; - SHA5122.prototype.restoreState = function(savedState) { - this._stateHi.set(savedState.stateHi); - this._stateLo.set(savedState.stateLo); - this._bufferLength = savedState.bufferLength; - if (savedState.buffer) { - this._buffer.set(savedState.buffer); - } - this._bytesHashed = savedState.bytesHashed; - this._finished = false; - return this; - }; - SHA5122.prototype.cleanSavedState = function(savedState) { - wipe_12.wipe(savedState.stateHi); - wipe_12.wipe(savedState.stateLo); - if (savedState.buffer) { - wipe_12.wipe(savedState.buffer); - } - savedState.bufferLength = 0; - savedState.bytesHashed = 0; - }; - return SHA5122; - }() - ); - exports2.SHA512 = SHA512; - var K2 = 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 hashBlocks(wh, wl, hh, hl, m2, pos, len) { - var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; - var h4, l2; - var th, tl; - var a3, b3, c2, d3; - while (len >= 128) { - for (var i2 = 0; i2 < 16; i2++) { - var j2 = 8 * i2 + pos; - wh[i2] = binary_12.readUint32BE(m2, j2); - wl[i2] = binary_12.readUint32BE(m2, j2 + 4); - } - for (var i2 = 0; i2 < 80; i2++) { - var bh0 = ah0; - var bh1 = ah1; - var bh2 = ah2; - var bh3 = ah3; - var bh4 = ah4; - var bh5 = ah5; - var bh6 = ah6; - var bh7 = ah7; - var bl0 = al0; - var bl1 = al1; - var bl2 = al2; - var bl3 = al3; - var bl4 = al4; - var bl5 = al5; - var bl6 = al6; - var bl7 = al7; - h4 = ah7; - l2 = al7; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32)); - l2 = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32)); - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = ah4 & ah5 ^ ~ah4 & ah6; - l2 = al4 & al5 ^ ~al4 & al6; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = K2[i2 * 2]; - l2 = K2[i2 * 2 + 1]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = wh[i2 % 16]; - l2 = wl[i2 % 16]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - th = c2 & 65535 | d3 << 16; - tl = a3 & 65535 | b3 << 16; - h4 = th; - l2 = tl; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32)); - l2 = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32)); - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2; - l2 = al0 & al1 ^ al0 & al2 ^ al1 & al2; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh7 = c2 & 65535 | d3 << 16; - bl7 = a3 & 65535 | b3 << 16; - h4 = bh3; - l2 = bl3; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = th; - l2 = tl; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh3 = c2 & 65535 | d3 << 16; - bl3 = a3 & 65535 | b3 << 16; - ah1 = bh0; - ah2 = bh1; - ah3 = bh2; - ah4 = bh3; - ah5 = bh4; - ah6 = bh5; - ah7 = bh6; - ah0 = bh7; - al1 = bl0; - al2 = bl1; - al3 = bl2; - al4 = bl3; - al5 = bl4; - al6 = bl5; - al7 = bl6; - al0 = bl7; - if (i2 % 16 === 15) { - for (var j2 = 0; j2 < 16; j2++) { - h4 = wh[j2]; - l2 = wl[j2]; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = wh[(j2 + 9) % 16]; - l2 = wl[(j2 + 9) % 16]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 1) % 16]; - tl = wl[(j2 + 1) % 16]; - h4 = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7; - l2 = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7); - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 14) % 16]; - tl = wl[(j2 + 14) % 16]; - h4 = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6; - l2 = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6); - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - wh[j2] = c2 & 65535 | d3 << 16; - wl[j2] = a3 & 65535 | b3 << 16; - } - } - } - h4 = ah0; - l2 = al0; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[0]; - l2 = hl[0]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[0] = ah0 = c2 & 65535 | d3 << 16; - hl[0] = al0 = a3 & 65535 | b3 << 16; - h4 = ah1; - l2 = al1; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[1]; - l2 = hl[1]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[1] = ah1 = c2 & 65535 | d3 << 16; - hl[1] = al1 = a3 & 65535 | b3 << 16; - h4 = ah2; - l2 = al2; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[2]; - l2 = hl[2]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[2] = ah2 = c2 & 65535 | d3 << 16; - hl[2] = al2 = a3 & 65535 | b3 << 16; - h4 = ah3; - l2 = al3; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[3]; - l2 = hl[3]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[3] = ah3 = c2 & 65535 | d3 << 16; - hl[3] = al3 = a3 & 65535 | b3 << 16; - h4 = ah4; - l2 = al4; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[4]; - l2 = hl[4]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[4] = ah4 = c2 & 65535 | d3 << 16; - hl[4] = al4 = a3 & 65535 | b3 << 16; - h4 = ah5; - l2 = al5; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[5]; - l2 = hl[5]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[5] = ah5 = c2 & 65535 | d3 << 16; - hl[5] = al5 = a3 & 65535 | b3 << 16; - h4 = ah6; - l2 = al6; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[6]; - l2 = hl[6]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[6] = ah6 = c2 & 65535 | d3 << 16; - hl[6] = al6 = a3 & 65535 | b3 << 16; - h4 = ah7; - l2 = al7; - a3 = l2 & 65535; - b3 = l2 >>> 16; - c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[7]; - l2 = hl[7]; - a3 += l2 & 65535; - b3 += l2 >>> 16; - c2 += h4 & 65535; - d3 += h4 >>> 16; - b3 += a3 >>> 16; - c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[7] = ah7 = c2 & 65535 | d3 << 16; - hl[7] = al7 = a3 & 65535 | b3 << 16; - pos += 128; - len -= 128; - } - return pos; - } - function hash2(data) { - var h4 = new SHA512(); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; - } - exports2.hash = hash2; -})(sha512); -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.convertSecretKeyToX25519 = exports2.convertPublicKeyToX25519 = exports2.verify = exports2.sign = exports2.extractPublicKeyFromSecretKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.SEED_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = exports2.SIGNATURE_LENGTH = void 0; - const random_1 = random; - const sha512_1 = sha512; - const wipe_12 = wipe$1; - exports2.SIGNATURE_LENGTH = 64; - exports2.PUBLIC_KEY_LENGTH = 32; - exports2.SECRET_KEY_LENGTH = 64; - exports2.SEED_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); - if (init) { - for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; - } - } - return r2; - } - const _9 = new Uint8Array(32); - _9[0] = 9; - const gf0 = gf(); - const gf1 = gf([1]); - const D2 = gf([ - 30883, - 4953, - 19914, - 30187, - 55467, - 16705, - 2637, - 112, - 59544, - 30585, - 16505, - 36039, - 65139, - 11119, - 27886, - 20995 - ]); - const D22 = gf([ - 61785, - 9906, - 39828, - 60374, - 45398, - 33411, - 5274, - 224, - 53552, - 61171, - 33010, - 6542, - 64743, - 22239, - 55772, - 9222 - ]); - const X2 = gf([ - 54554, - 36645, - 11616, - 51542, - 42930, - 38181, - 51040, - 26924, - 56412, - 64982, - 57905, - 49316, - 21502, - 52590, - 14035, - 8553 - ]); - const Y2 = gf([ - 26200, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214 - ]); - const I2 = gf([ - 41136, - 18958, - 6951, - 50414, - 58488, - 44335, - 6150, - 12099, - 55207, - 15867, - 153, - 11085, - 57099, - 20417, - 9344, - 11139 - ]); - function set25519(r2, a3) { - for (let i2 = 0; i2 < 16; i2++) { - r2[i2] = a3[i2] | 0; - } - } - function car25519(o2) { - let c2 = 1; - for (let i2 = 0; i2 < 16; i2++) { - let v3 = o2[i2] + c2 + 65535; - c2 = Math.floor(v3 / 65536); - o2[i2] = v3 - c2 * 65536; - } - o2[0] += c2 - 1 + 37 * (c2 - 1); - } - function sel25519(p3, q2, b3) { - const c2 = ~(b3 - 1); - for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; - q2[i2] ^= t2; - } - } - function pack25519(o2, n3) { - const m2 = gf(); - const t2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; - } - car25519(t2); - car25519(t2); - car25519(t2); - for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; - for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; - } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); - } - for (let i2 = 0; i2 < 16; i2++) { - o2[2 * i2] = t2[i2] & 255; - o2[2 * i2 + 1] = t2[i2] >> 8; - } - } - function verify32(x2, y3) { - let d3 = 0; - for (let i2 = 0; i2 < 32; i2++) { - d3 |= x2[i2] ^ y3[i2]; - } - return (1 & d3 - 1 >>> 8) - 1; - } - function neq25519(a3, b3) { - const c2 = new Uint8Array(32); - const d3 = new Uint8Array(32); - pack25519(c2, a3); - pack25519(d3, b3); - return verify32(c2, d3); - } - function par25519(a3) { - const d3 = new Uint8Array(32); - pack25519(d3, a3); - return d3[0] & 1; - } - function unpack25519(o2, n3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); - } - o2[15] &= 32767; - } - function add(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] + b3[i2]; - } - } - function sub(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] - b3[i2]; - } - } - function mul(o2, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; - v3 = a3[0]; - t0 += v3 * b0; - t1 += v3 * b1; - t2 += v3 * b22; - t3 += v3 * b32; - t4 += v3 * b4; - t5 += v3 * b5; - t6 += v3 * b6; - t7 += v3 * b7; - t8 += v3 * b8; - t9 += v3 * b9; - t10 += v3 * b10; - t11 += v3 * b11; - t12 += v3 * b12; - t13 += v3 * b13; - t14 += v3 * b14; - t15 += v3 * b15; - v3 = a3[1]; - t1 += v3 * b0; - t2 += v3 * b1; - t3 += v3 * b22; - t4 += v3 * b32; - t5 += v3 * b4; - t6 += v3 * b5; - t7 += v3 * b6; - t8 += v3 * b7; - t9 += v3 * b8; - t10 += v3 * b9; - t11 += v3 * b10; - t12 += v3 * b11; - t13 += v3 * b12; - t14 += v3 * b13; - t15 += v3 * b14; - t16 += v3 * b15; - v3 = a3[2]; - t2 += v3 * b0; - t3 += v3 * b1; - t4 += v3 * b22; - t5 += v3 * b32; - t6 += v3 * b4; - t7 += v3 * b5; - t8 += v3 * b6; - t9 += v3 * b7; - t10 += v3 * b8; - t11 += v3 * b9; - t12 += v3 * b10; - t13 += v3 * b11; - t14 += v3 * b12; - t15 += v3 * b13; - t16 += v3 * b14; - t17 += v3 * b15; - v3 = a3[3]; - t3 += v3 * b0; - t4 += v3 * b1; - t5 += v3 * b22; - t6 += v3 * b32; - t7 += v3 * b4; - t8 += v3 * b5; - t9 += v3 * b6; - t10 += v3 * b7; - t11 += v3 * b8; - t12 += v3 * b9; - t13 += v3 * b10; - t14 += v3 * b11; - t15 += v3 * b12; - t16 += v3 * b13; - t17 += v3 * b14; - t18 += v3 * b15; - v3 = a3[4]; - t4 += v3 * b0; - t5 += v3 * b1; - t6 += v3 * b22; - t7 += v3 * b32; - t8 += v3 * b4; - t9 += v3 * b5; - t10 += v3 * b6; - t11 += v3 * b7; - t12 += v3 * b8; - t13 += v3 * b9; - t14 += v3 * b10; - t15 += v3 * b11; - t16 += v3 * b12; - t17 += v3 * b13; - t18 += v3 * b14; - t19 += v3 * b15; - v3 = a3[5]; - t5 += v3 * b0; - t6 += v3 * b1; - t7 += v3 * b22; - t8 += v3 * b32; - t9 += v3 * b4; - t10 += v3 * b5; - t11 += v3 * b6; - t12 += v3 * b7; - t13 += v3 * b8; - t14 += v3 * b9; - t15 += v3 * b10; - t16 += v3 * b11; - t17 += v3 * b12; - t18 += v3 * b13; - t19 += v3 * b14; - t20 += v3 * b15; - v3 = a3[6]; - t6 += v3 * b0; - t7 += v3 * b1; - t8 += v3 * b22; - t9 += v3 * b32; - t10 += v3 * b4; - t11 += v3 * b5; - t12 += v3 * b6; - t13 += v3 * b7; - t14 += v3 * b8; - t15 += v3 * b9; - t16 += v3 * b10; - t17 += v3 * b11; - t18 += v3 * b12; - t19 += v3 * b13; - t20 += v3 * b14; - t21 += v3 * b15; - v3 = a3[7]; - t7 += v3 * b0; - t8 += v3 * b1; - t9 += v3 * b22; - t10 += v3 * b32; - t11 += v3 * b4; - t12 += v3 * b5; - t13 += v3 * b6; - t14 += v3 * b7; - t15 += v3 * b8; - t16 += v3 * b9; - t17 += v3 * b10; - t18 += v3 * b11; - t19 += v3 * b12; - t20 += v3 * b13; - t21 += v3 * b14; - t22 += v3 * b15; - v3 = a3[8]; - t8 += v3 * b0; - t9 += v3 * b1; - t10 += v3 * b22; - t11 += v3 * b32; - t12 += v3 * b4; - t13 += v3 * b5; - t14 += v3 * b6; - t15 += v3 * b7; - t16 += v3 * b8; - t17 += v3 * b9; - t18 += v3 * b10; - t19 += v3 * b11; - t20 += v3 * b12; - t21 += v3 * b13; - t22 += v3 * b14; - t23 += v3 * b15; - v3 = a3[9]; - t9 += v3 * b0; - t10 += v3 * b1; - t11 += v3 * b22; - t12 += v3 * b32; - t13 += v3 * b4; - t14 += v3 * b5; - t15 += v3 * b6; - t16 += v3 * b7; - t17 += v3 * b8; - t18 += v3 * b9; - t19 += v3 * b10; - t20 += v3 * b11; - t21 += v3 * b12; - t22 += v3 * b13; - t23 += v3 * b14; - t24 += v3 * b15; - v3 = a3[10]; - t10 += v3 * b0; - t11 += v3 * b1; - t12 += v3 * b22; - t13 += v3 * b32; - t14 += v3 * b4; - t15 += v3 * b5; - t16 += v3 * b6; - t17 += v3 * b7; - t18 += v3 * b8; - t19 += v3 * b9; - t20 += v3 * b10; - t21 += v3 * b11; - t22 += v3 * b12; - t23 += v3 * b13; - t24 += v3 * b14; - t25 += v3 * b15; - v3 = a3[11]; - t11 += v3 * b0; - t12 += v3 * b1; - t13 += v3 * b22; - t14 += v3 * b32; - t15 += v3 * b4; - t16 += v3 * b5; - t17 += v3 * b6; - t18 += v3 * b7; - t19 += v3 * b8; - t20 += v3 * b9; - t21 += v3 * b10; - t22 += v3 * b11; - t23 += v3 * b12; - t24 += v3 * b13; - t25 += v3 * b14; - t26 += v3 * b15; - v3 = a3[12]; - t12 += v3 * b0; - t13 += v3 * b1; - t14 += v3 * b22; - t15 += v3 * b32; - t16 += v3 * b4; - t17 += v3 * b5; - t18 += v3 * b6; - t19 += v3 * b7; - t20 += v3 * b8; - t21 += v3 * b9; - t22 += v3 * b10; - t23 += v3 * b11; - t24 += v3 * b12; - t25 += v3 * b13; - t26 += v3 * b14; - t27 += v3 * b15; - v3 = a3[13]; - t13 += v3 * b0; - t14 += v3 * b1; - t15 += v3 * b22; - t16 += v3 * b32; - t17 += v3 * b4; - t18 += v3 * b5; - t19 += v3 * b6; - t20 += v3 * b7; - t21 += v3 * b8; - t22 += v3 * b9; - t23 += v3 * b10; - t24 += v3 * b11; - t25 += v3 * b12; - t26 += v3 * b13; - t27 += v3 * b14; - t28 += v3 * b15; - v3 = a3[14]; - t14 += v3 * b0; - t15 += v3 * b1; - t16 += v3 * b22; - t17 += v3 * b32; - t18 += v3 * b4; - t19 += v3 * b5; - t20 += v3 * b6; - t21 += v3 * b7; - t22 += v3 * b8; - t23 += v3 * b9; - t24 += v3 * b10; - t25 += v3 * b11; - t26 += v3 * b12; - t27 += v3 * b13; - t28 += v3 * b14; - t29 += v3 * b15; - v3 = a3[15]; - t15 += v3 * b0; - t16 += v3 * b1; - t17 += v3 * b22; - t18 += v3 * b32; - t19 += v3 * b4; - t20 += v3 * b5; - t21 += v3 * b6; - t22 += v3 * b7; - t23 += v3 * b8; - t24 += v3 * b9; - t25 += v3 * b10; - t26 += v3 * b11; - t27 += v3 * b12; - t28 += v3 * b13; - t29 += v3 * b14; - t30 += v3 * b15; - t0 += 38 * t16; - t1 += 38 * t17; - t2 += 38 * t18; - t3 += 38 * t19; - t4 += 38 * t20; - t5 += 38 * t21; - t6 += 38 * t22; - t7 += 38 * t23; - t8 += 38 * t24; - t9 += 38 * t25; - t10 += 38 * t26; - t11 += 38 * t27; - t12 += 38 * t28; - t13 += 38 * t29; - t14 += 38 * t30; - c2 = 1; - v3 = t0 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t0 = v3 - c2 * 65536; - v3 = t1 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t1 = v3 - c2 * 65536; - v3 = t2 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t2 = v3 - c2 * 65536; - v3 = t3 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t3 = v3 - c2 * 65536; - v3 = t4 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t4 = v3 - c2 * 65536; - v3 = t5 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t5 = v3 - c2 * 65536; - v3 = t6 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t6 = v3 - c2 * 65536; - v3 = t7 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t7 = v3 - c2 * 65536; - v3 = t8 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t8 = v3 - c2 * 65536; - v3 = t9 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t9 = v3 - c2 * 65536; - v3 = t10 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t10 = v3 - c2 * 65536; - v3 = t11 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t11 = v3 - c2 * 65536; - v3 = t12 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t12 = v3 - c2 * 65536; - v3 = t13 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t13 = v3 - c2 * 65536; - v3 = t14 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t14 = v3 - c2 * 65536; - v3 = t15 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t15 = v3 - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - c2 = 1; - v3 = t0 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t0 = v3 - c2 * 65536; - v3 = t1 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t1 = v3 - c2 * 65536; - v3 = t2 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t2 = v3 - c2 * 65536; - v3 = t3 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t3 = v3 - c2 * 65536; - v3 = t4 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t4 = v3 - c2 * 65536; - v3 = t5 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t5 = v3 - c2 * 65536; - v3 = t6 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t6 = v3 - c2 * 65536; - v3 = t7 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t7 = v3 - c2 * 65536; - v3 = t8 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t8 = v3 - c2 * 65536; - v3 = t9 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t9 = v3 - c2 * 65536; - v3 = t10 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t10 = v3 - c2 * 65536; - v3 = t11 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t11 = v3 - c2 * 65536; - v3 = t12 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t12 = v3 - c2 * 65536; - v3 = t13 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t13 = v3 - c2 * 65536; - v3 = t14 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t14 = v3 - c2 * 65536; - v3 = t15 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t15 = v3 - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - o2[0] = t0; - o2[1] = t1; - o2[2] = t2; - o2[3] = t3; - o2[4] = t4; - o2[5] = t5; - o2[6] = t6; - o2[7] = t7; - o2[8] = t8; - o2[9] = t9; - o2[10] = t10; - o2[11] = t11; - o2[12] = t12; - o2[13] = t13; - o2[14] = t14; - o2[15] = t15; - } - function square(o2, a3) { - mul(o2, a3, a3); - } - function inv25519(o2, i2) { - const c2 = gf(); - let a3; - for (a3 = 0; a3 < 16; a3++) { - c2[a3] = i2[a3]; - } - for (a3 = 253; a3 >= 0; a3--) { - square(c2, c2); - if (a3 !== 2 && a3 !== 4) { - mul(c2, c2, i2); - } - } - for (a3 = 0; a3 < 16; a3++) { - o2[a3] = c2[a3]; - } - } - function pow2523(o2, i2) { - const c2 = gf(); - let a3; - for (a3 = 0; a3 < 16; a3++) { - c2[a3] = i2[a3]; - } - for (a3 = 250; a3 >= 0; a3--) { - square(c2, c2); - if (a3 !== 1) { - mul(c2, c2, i2); - } - } - for (a3 = 0; a3 < 16; a3++) { - o2[a3] = c2[a3]; - } - } - function edadd(p3, q2) { - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e = gf(), f2 = gf(), g3 = gf(), h4 = gf(), t2 = gf(); - sub(a3, p3[1], p3[0]); - sub(t2, q2[1], q2[0]); - mul(a3, a3, t2); - add(b3, p3[0], p3[1]); - add(t2, q2[0], q2[1]); - mul(b3, b3, t2); - mul(c2, p3[3], q2[3]); - mul(c2, c2, D22); - mul(d3, p3[2], q2[2]); - add(d3, d3, d3); - sub(e, b3, a3); - sub(f2, d3, c2); - add(g3, d3, c2); - add(h4, b3, a3); - mul(p3[0], e, f2); - mul(p3[1], h4, g3); - mul(p3[2], g3, f2); - mul(p3[3], e, h4); - } - function cswap(p3, q2, b3) { - for (let i2 = 0; i2 < 4; i2++) { - sel25519(p3[i2], q2[i2], b3); - } - } - function pack(r2, p3) { - const tx = gf(), ty = gf(), zi = gf(); - inv25519(zi, p3[2]); - mul(tx, p3[0], zi); - mul(ty, p3[1], zi); - pack25519(r2, ty); - r2[31] ^= par25519(tx) << 7; - } - function scalarmult(p3, q2, s2) { - set25519(p3[0], gf0); - set25519(p3[1], gf1); - set25519(p3[2], gf1); - set25519(p3[3], gf0); - for (let i2 = 255; i2 >= 0; --i2) { - const b3 = s2[i2 / 8 | 0] >> (i2 & 7) & 1; - cswap(p3, q2, b3); - edadd(q2, p3); - edadd(p3, p3); - cswap(p3, q2, b3); - } - } - function scalarbase(p3, s2) { - const q2 = [gf(), gf(), gf(), gf()]; - set25519(q2[0], X2); - set25519(q2[1], Y2); - set25519(q2[2], gf1); - mul(q2[3], X2, Y2); - scalarmult(p3, q2, s2); - } - function generateKeyPairFromSeed(seed) { - if (seed.length !== exports2.SEED_LENGTH) { - throw new Error(`ed25519: seed must be ${exports2.SEED_LENGTH} bytes`); - } - const d3 = (0, sha512_1.hash)(seed); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const publicKey = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - scalarbase(p3, d3); - pack(publicKey, p3); - const secretKey = new Uint8Array(64); - secretKey.set(seed); - secretKey.set(publicKey, 32); - return { - publicKey, - secretKey - }; - } - exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; - function generateKeyPair2(prng) { - const seed = (0, random_1.randomBytes)(32, prng); - const result = generateKeyPairFromSeed(seed); - (0, wipe_12.wipe)(seed); - return result; - } - exports2.generateKeyPair = generateKeyPair2; - function extractPublicKeyFromSecretKey(secretKey) { - if (secretKey.length !== exports2.SECRET_KEY_LENGTH) { - throw new Error(`ed25519: secret key must be ${exports2.SECRET_KEY_LENGTH} bytes`); - } - return new Uint8Array(secretKey.subarray(32)); - } - exports2.extractPublicKeyFromSecretKey = extractPublicKeyFromSecretKey; - const L2 = 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 modL(r2, x2) { - let carry; - let i2; - let j2; - let k2; - for (i2 = 63; i2 >= 32; --i2) { - carry = 0; - for (j2 = i2 - 32, k2 = i2 - 12; j2 < k2; ++j2) { - x2[j2] += carry - 16 * x2[i2] * L2[j2 - (i2 - 32)]; - carry = Math.floor((x2[j2] + 128) / 256); - x2[j2] -= carry * 256; - } - x2[j2] += carry; - x2[i2] = 0; - } - carry = 0; - for (j2 = 0; j2 < 32; j2++) { - x2[j2] += carry - (x2[31] >> 4) * L2[j2]; - carry = x2[j2] >> 8; - x2[j2] &= 255; - } - for (j2 = 0; j2 < 32; j2++) { - x2[j2] -= carry * L2[j2]; - } - for (i2 = 0; i2 < 32; i2++) { - x2[i2 + 1] += x2[i2] >> 8; - r2[i2] = x2[i2] & 255; - } - } - function reduce(r2) { - const x2 = new Float64Array(64); - for (let i2 = 0; i2 < 64; i2++) { - x2[i2] = r2[i2]; - } - for (let i2 = 0; i2 < 64; i2++) { - r2[i2] = 0; - } - modL(r2, x2); - } - function sign(secretKey, message) { - const x2 = new Float64Array(64); - const p3 = [gf(), gf(), gf(), gf()]; - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const signature = new Uint8Array(64); - signature.set(d3.subarray(32), 32); - const hs2 = new sha512_1.SHA512(); - hs2.update(signature.subarray(32)); - hs2.update(message); - const r2 = hs2.digest(); - hs2.clean(); - reduce(r2); - scalarbase(p3, r2); - pack(signature, p3); - hs2.reset(); - hs2.update(signature.subarray(0, 32)); - hs2.update(secretKey.subarray(32)); - hs2.update(message); - const h4 = hs2.digest(); - reduce(h4); - for (let i2 = 0; i2 < 32; i2++) { - x2[i2] = r2[i2]; - } - for (let i2 = 0; i2 < 32; i2++) { - for (let j2 = 0; j2 < 32; j2++) { - x2[i2 + j2] += h4[i2] * d3[j2]; - } - } - modL(signature.subarray(32), x2); - return signature; - } - exports2.sign = sign; - function unpackneg(r2, p3) { - const t2 = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf(); - set25519(r2[2], gf1); - unpack25519(r2[1], p3); - square(num, r2[1]); - mul(den, num, D2); - sub(num, num, r2[2]); - add(den, r2[2], den); - square(den2, den); - square(den4, den2); - mul(den6, den4, den2); - mul(t2, den6, num); - mul(t2, t2, den); - pow2523(t2, t2); - mul(t2, t2, num); - mul(t2, t2, den); - mul(t2, t2, den); - mul(r2[0], t2, den); - square(chk, r2[0]); - mul(chk, chk, den); - if (neq25519(chk, num)) { - mul(r2[0], r2[0], I2); - } - square(chk, r2[0]); - mul(chk, chk, den); - if (neq25519(chk, num)) { - return -1; - } - if (par25519(r2[0]) === p3[31] >> 7) { - sub(r2[0], gf0, r2[0]); - } - mul(r2[3], r2[0], r2[1]); - return 0; - } - function verify(publicKey, message, signature) { - const t2 = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - const q2 = [gf(), gf(), gf(), gf()]; - if (signature.length !== exports2.SIGNATURE_LENGTH) { - throw new Error(`ed25519: signature must be ${exports2.SIGNATURE_LENGTH} bytes`); - } - if (unpackneg(q2, publicKey)) { - return false; - } - const hs2 = new sha512_1.SHA512(); - hs2.update(signature.subarray(0, 32)); - hs2.update(publicKey); - hs2.update(message); - const h4 = hs2.digest(); - reduce(h4); - scalarmult(p3, q2, h4); - scalarbase(q2, signature.subarray(32)); - edadd(p3, q2); - pack(t2, p3); - if (verify32(signature, t2)) { - return false; - } - return true; - } - exports2.verify = verify; - function convertPublicKeyToX25519(publicKey) { - let q2 = [gf(), gf(), gf(), gf()]; - if (unpackneg(q2, publicKey)) { - throw new Error("Ed25519: invalid public key"); - } - let a3 = gf(); - let b3 = gf(); - let y3 = q2[1]; - add(a3, gf1, y3); - sub(b3, gf1, y3); - inv25519(b3, b3); - mul(a3, a3, b3); - let z3 = new Uint8Array(32); - pack25519(z3, a3); - return z3; - } - exports2.convertPublicKeyToX25519 = convertPublicKeyToX25519; - function convertSecretKeyToX25519(secretKey) { - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const o2 = new Uint8Array(d3.subarray(0, 32)); - (0, wipe_12.wipe)(d3); - return o2; - } - exports2.convertSecretKeyToX25519 = convertSecretKeyToX25519; -})(ed25519); -const JWT_IRIDIUM_ALG = "EdDSA"; -const JWT_IRIDIUM_TYP = "JWT"; -const JWT_DELIMITER = "."; -const JWT_ENCODING = "base64url"; -const JSON_ENCODING = "utf8"; -const DATA_ENCODING = "utf8"; -const DID_DELIMITER = ":"; -const DID_PREFIX = "did"; -const DID_METHOD = "key"; -const MULTICODEC_ED25519_ENCODING = "base58btc"; -const MULTICODEC_ED25519_BASE = "z"; -const MULTICODEC_ED25519_HEADER = "K36"; -const KEY_PAIR_SEED_LENGTH = 32; -function asUint8Array(buf) { - if (globalThis.Buffer != null) { - return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength); - } - return buf; -} -function allocUnsafe(size = 0) { - if (globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null) { - return asUint8Array(globalThis.Buffer.allocUnsafe(size)); - } - return new Uint8Array(size); -} -function concat(arrays, length) { - if (!length) { - length = arrays.reduce((acc, curr) => acc + curr.length, 0); - } - const output = allocUnsafe(length); - let offset = 0; - for (const arr of arrays) { - output.set(arr, offset); - offset += arr.length; - } - return asUint8Array(output); -} -function base(ALPHABET, name2) { - if (ALPHABET.length >= 255) { - throw new TypeError("Alphabet too long"); - } - var BASE_MAP = new Uint8Array(256); - for (var j2 = 0; j2 < BASE_MAP.length; j2++) { - BASE_MAP[j2] = 255; - } - for (var i2 = 0; i2 < ALPHABET.length; i2++) { - var x2 = ALPHABET.charAt(i2); - var xc = x2.charCodeAt(0); - if (BASE_MAP[xc] !== 255) { - throw new TypeError(x2 + " is ambiguous"); - } - BASE_MAP[xc] = i2; - } - var BASE = ALPHABET.length; - var LEADER = ALPHABET.charAt(0); - var FACTOR = Math.log(BASE) / Math.log(256); - var iFACTOR = Math.log(256) / Math.log(BASE); - function encode2(source) { - if (source instanceof Uint8Array) - ; - else if (ArrayBuffer.isView(source)) { - source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength); - } else if (Array.isArray(source)) { - source = Uint8Array.from(source); - } - if (!(source instanceof Uint8Array)) { - throw new TypeError("Expected Uint8Array"); - } - if (source.length === 0) { - return ""; - } - var zeroes = 0; - var length = 0; - var pbegin = 0; - var pend = source.length; - while (pbegin !== pend && source[pbegin] === 0) { - pbegin++; - zeroes++; - } - var size = (pend - pbegin) * iFACTOR + 1 >>> 0; - var b58 = new Uint8Array(size); - while (pbegin !== pend) { - var carry = source[pbegin]; - var i3 = 0; - for (var it1 = size - 1; (carry !== 0 || i3 < length) && it1 !== -1; it1--, i3++) { - carry += 256 * b58[it1] >>> 0; - b58[it1] = carry % BASE >>> 0; - carry = carry / BASE >>> 0; - } - if (carry !== 0) { - throw new Error("Non-zero carry"); - } - length = i3; - pbegin++; - } - var it2 = size - length; - while (it2 !== size && b58[it2] === 0) { - it2++; - } - var str = LEADER.repeat(zeroes); - for (; it2 < size; ++it2) { - str += ALPHABET.charAt(b58[it2]); - } - return str; - } - function decodeUnsafe(source) { - if (typeof source !== "string") { - throw new TypeError("Expected String"); - } - if (source.length === 0) { - return new Uint8Array(); - } - var psz = 0; - if (source[psz] === " ") { - return; - } - var zeroes = 0; - var length = 0; - while (source[psz] === LEADER) { - zeroes++; - psz++; - } - var size = (source.length - psz) * FACTOR + 1 >>> 0; - var b256 = new Uint8Array(size); - while (source[psz]) { - var carry = BASE_MAP[source.charCodeAt(psz)]; - if (carry === 255) { - return; - } - var i3 = 0; - for (var it3 = size - 1; (carry !== 0 || i3 < length) && it3 !== -1; it3--, i3++) { - carry += BASE * b256[it3] >>> 0; - b256[it3] = carry % 256 >>> 0; - carry = carry / 256 >>> 0; - } - if (carry !== 0) { - throw new Error("Non-zero carry"); - } - length = i3; - psz++; - } - if (source[psz] === " ") { - return; - } - var it4 = size - length; - while (it4 !== size && b256[it4] === 0) { - it4++; - } - var vch = new Uint8Array(zeroes + (size - it4)); - var j3 = zeroes; - while (it4 !== size) { - vch[j3++] = b256[it4++]; - } - return vch; - } - function decode2(string2) { - var buffer = decodeUnsafe(string2); - if (buffer) { - return buffer; - } - throw new Error(`Non-${name2} character`); - } - return { - encode: encode2, - decodeUnsafe, - decode: decode2 - }; -} -var src = base; -var _brrp__multiformats_scope_baseX = src; -const coerce$1 = (o2) => { - if (o2 instanceof Uint8Array && o2.constructor.name === "Uint8Array") - return o2; - if (o2 instanceof ArrayBuffer) - return new Uint8Array(o2); - if (ArrayBuffer.isView(o2)) { - return new Uint8Array(o2.buffer, o2.byteOffset, o2.byteLength); - } - throw new Error("Unknown type, must be binary type"); -}; -const fromString$1 = (str) => new TextEncoder().encode(str); -const toString$1 = (b3) => new TextDecoder().decode(b3); -class Encoder { - constructor(name2, prefix, baseEncode) { - this.name = name2; - this.prefix = prefix; - this.baseEncode = baseEncode; - } - encode(bytes) { - if (bytes instanceof Uint8Array) { - return `${this.prefix}${this.baseEncode(bytes)}`; - } else { - throw Error("Unknown type, must be binary type"); - } - } -} -class Decoder { - constructor(name2, prefix, baseDecode) { - this.name = name2; - this.prefix = prefix; - if (prefix.codePointAt(0) === void 0) { - throw new Error("Invalid prefix character"); - } - this.prefixCodePoint = prefix.codePointAt(0); - this.baseDecode = baseDecode; - } - decode(text) { - if (typeof text === "string") { - if (text.codePointAt(0) !== this.prefixCodePoint) { - throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); - } - return this.baseDecode(text.slice(this.prefix.length)); - } else { - throw Error("Can only multibase decode strings"); - } - } - or(decoder) { - return or$2(this, decoder); - } -} -class ComposedDecoder { - constructor(decoders) { - this.decoders = decoders; - } - or(decoder) { - return or$2(this, decoder); - } - decode(input) { - const prefix = input[0]; - const decoder = this.decoders[prefix]; - if (decoder) { - return decoder.decode(input); - } else { - throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); - } - } -} -const or$2 = (left, right) => new ComposedDecoder({ - ...left.decoders || { [left.prefix]: left }, - ...right.decoders || { [right.prefix]: right } -}); -class Codec { - constructor(name2, prefix, baseEncode, baseDecode) { - this.name = name2; - this.prefix = prefix; - this.baseEncode = baseEncode; - this.baseDecode = baseDecode; - this.encoder = new Encoder(name2, prefix, baseEncode); - this.decoder = new Decoder(name2, prefix, baseDecode); - } - encode(input) { - return this.encoder.encode(input); - } - decode(input) { - return this.decoder.decode(input); - } -} -const from = ({ name: name2, prefix, encode: encode2, decode: decode2 }) => new Codec(name2, prefix, encode2, decode2); -const baseX = ({ prefix, name: name2, alphabet: alphabet2 }) => { - const { encode: encode2, decode: decode2 } = _brrp__multiformats_scope_baseX(alphabet2, name2); - return from({ - prefix, - name: name2, - encode: encode2, - decode: (text) => coerce$1(decode2(text)) - }); -}; -const decode$2 = (string2, alphabet2, bitsPerChar, name2) => { - const codes = {}; - for (let i2 = 0; i2 < alphabet2.length; ++i2) { - codes[alphabet2[i2]] = i2; - } - let end = string2.length; - while (string2[end - 1] === "=") { - --end; - } - const out = new Uint8Array(end * bitsPerChar / 8 | 0); - let bits = 0; - let buffer = 0; - let written = 0; - for (let i2 = 0; i2 < end; ++i2) { - const value = codes[string2[i2]]; - if (value === void 0) { - throw new SyntaxError(`Non-${name2} character`); - } - buffer = buffer << bitsPerChar | value; - bits += bitsPerChar; - if (bits >= 8) { - bits -= 8; - out[written++] = 255 & buffer >> bits; - } - } - if (bits >= bitsPerChar || 255 & buffer << 8 - bits) { - throw new SyntaxError("Unexpected end of data"); - } - return out; -}; -const encode$1 = (data, alphabet2, bitsPerChar) => { - const pad = alphabet2[alphabet2.length - 1] === "="; - const mask = (1 << bitsPerChar) - 1; - let out = ""; - let bits = 0; - let buffer = 0; - for (let i2 = 0; i2 < data.length; ++i2) { - buffer = buffer << 8 | data[i2]; - bits += 8; - while (bits > bitsPerChar) { - bits -= bitsPerChar; - out += alphabet2[mask & buffer >> bits]; - } - } - if (bits) { - out += alphabet2[mask & buffer << bitsPerChar - bits]; - } - if (pad) { - while (out.length * bitsPerChar & 7) { - out += "="; - } - } - return out; -}; -const rfc4648 = ({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) => { - return from({ - prefix, - name: name2, - encode(input) { - return encode$1(input, alphabet2, bitsPerChar); - }, - decode(input) { - return decode$2(input, alphabet2, bitsPerChar, name2); - } - }); -}; -const identity = from({ - prefix: "\0", - name: "identity", - encode: (buf) => toString$1(buf), - decode: (str) => fromString$1(str) -}); -const identityBase = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - identity -}, Symbol.toStringTag, { value: "Module" })); -const base2 = rfc4648({ - prefix: "0", - name: "base2", - alphabet: "01", - bitsPerChar: 1 -}); -const base2$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base2 -}, Symbol.toStringTag, { value: "Module" })); -const base8 = rfc4648({ - prefix: "7", - name: "base8", - alphabet: "01234567", - bitsPerChar: 3 -}); -const base8$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base8 -}, Symbol.toStringTag, { value: "Module" })); -const base10 = baseX({ - prefix: "9", - name: "base10", - alphabet: "0123456789" -}); -const base10$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base10 -}, Symbol.toStringTag, { value: "Module" })); -const base16 = rfc4648({ - prefix: "f", - name: "base16", - alphabet: "0123456789abcdef", - bitsPerChar: 4 -}); -const base16upper = rfc4648({ - prefix: "F", - name: "base16upper", - alphabet: "0123456789ABCDEF", - bitsPerChar: 4 -}); -const base16$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base16, - base16upper -}, Symbol.toStringTag, { value: "Module" })); -const base32 = rfc4648({ - prefix: "b", - name: "base32", - alphabet: "abcdefghijklmnopqrstuvwxyz234567", - bitsPerChar: 5 -}); -const base32upper = rfc4648({ - prefix: "B", - name: "base32upper", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", - bitsPerChar: 5 -}); -const base32pad = rfc4648({ - prefix: "c", - name: "base32pad", - alphabet: "abcdefghijklmnopqrstuvwxyz234567=", - bitsPerChar: 5 -}); -const base32padupper = rfc4648({ - prefix: "C", - name: "base32padupper", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", - bitsPerChar: 5 -}); -const base32hex = rfc4648({ - prefix: "v", - name: "base32hex", - alphabet: "0123456789abcdefghijklmnopqrstuv", - bitsPerChar: 5 -}); -const base32hexupper = rfc4648({ - prefix: "V", - name: "base32hexupper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", - bitsPerChar: 5 -}); -const base32hexpad = rfc4648({ - prefix: "t", - name: "base32hexpad", - alphabet: "0123456789abcdefghijklmnopqrstuv=", - bitsPerChar: 5 -}); -const base32hexpadupper = rfc4648({ - prefix: "T", - name: "base32hexpadupper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", - bitsPerChar: 5 -}); -const base32z = rfc4648({ - prefix: "h", - name: "base32z", - alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", - bitsPerChar: 5 -}); -const base32$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base32, - base32hex, - base32hexpad, - base32hexpadupper, - base32hexupper, - base32pad, - base32padupper, - base32upper, - base32z -}, Symbol.toStringTag, { value: "Module" })); -const base36 = baseX({ - prefix: "k", - name: "base36", - alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" -}); -const base36upper = baseX({ - prefix: "K", - name: "base36upper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" -}); -const base36$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base36, - base36upper -}, Symbol.toStringTag, { value: "Module" })); -const base58btc = baseX({ - name: "base58btc", - prefix: "z", - alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" -}); -const base58flickr = baseX({ - name: "base58flickr", - prefix: "Z", - alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" -}); -const base58 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base58btc, - base58flickr -}, Symbol.toStringTag, { value: "Module" })); -const base64 = rfc4648({ - prefix: "m", - name: "base64", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", - bitsPerChar: 6 -}); -const base64pad = rfc4648({ - prefix: "M", - name: "base64pad", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - bitsPerChar: 6 -}); -const base64url = rfc4648({ - prefix: "u", - name: "base64url", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", - bitsPerChar: 6 -}); -const base64urlpad = rfc4648({ - prefix: "U", - name: "base64urlpad", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", - bitsPerChar: 6 -}); -const base64$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base64, - base64pad, - base64url, - base64urlpad -}, Symbol.toStringTag, { value: "Module" })); -const alphabet = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"); -const alphabetBytesToChars = alphabet.reduce((p3, c2, i2) => { - p3[i2] = c2; - return p3; -}, []); -const alphabetCharsToBytes = alphabet.reduce((p3, c2, i2) => { - p3[c2.codePointAt(0)] = i2; - return p3; -}, []); -function encode(data) { - return data.reduce((p3, c2) => { - p3 += alphabetBytesToChars[c2]; - return p3; - }, ""); -} -function decode$1(str) { - const byts = []; - for (const char of str) { - const byt = alphabetCharsToBytes[char.codePointAt(0)]; - if (byt === void 0) { - throw new Error(`Non-base256emoji character: ${char}`); - } - byts.push(byt); - } - return new Uint8Array(byts); -} -const base256emoji = from({ - prefix: "🚀", - name: "base256emoji", - encode, - decode: decode$1 -}); -const base256emoji$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base256emoji -}, Symbol.toStringTag, { value: "Module" })); -new TextEncoder(); -new TextDecoder(); -const bases = { - ...identityBase, - ...base2$1, - ...base8$1, - ...base10$1, - ...base16$1, - ...base32$1, - ...base36$1, - ...base58, - ...base64$1, - ...base256emoji$1 -}; -function createCodec(name2, prefix, encode2, decode2) { - return { - name: name2, - prefix, - encoder: { - name: name2, - prefix, - encode: encode2 - }, - decoder: { decode: decode2 } - }; -} -const string = createCodec("utf8", "u", (buf) => { - const decoder = new TextDecoder("utf8"); - return "u" + decoder.decode(buf); -}, (str) => { - const encoder = new TextEncoder(); - return encoder.encode(str.substring(1)); -}); -const ascii = createCodec("ascii", "a", (buf) => { - let string2 = "a"; - for (let i2 = 0; i2 < buf.length; i2++) { - string2 += String.fromCharCode(buf[i2]); - } - return string2; -}, (str) => { - str = str.substring(1); - const buf = allocUnsafe(str.length); - for (let i2 = 0; i2 < str.length; i2++) { - buf[i2] = str.charCodeAt(i2); - } - return buf; -}); -const BASES = { - utf8: string, - "utf-8": string, - hex: bases.base16, - latin1: ascii, - ascii, - binary: ascii, - ...bases -}; -function toString(array, encoding = "utf8") { - const base3 = BASES[encoding]; - if (!base3) { - throw new Error(`Unsupported encoding "${encoding}"`); - } - if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { - return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString("utf8"); - } - return base3.encoder.encode(array).substring(1); -} -function fromString(string2, encoding = "utf8") { - const base3 = BASES[encoding]; - if (!base3) { - throw new Error(`Unsupported encoding "${encoding}"`); - } - if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { - return asUint8Array(globalThis.Buffer.from(string2, "utf-8")); - } - return base3.decoder.decode(`${base3.prefix}${string2}`); -} -function encodeJSON(val) { - return toString(fromString(safeJsonStringify(val), JSON_ENCODING), JWT_ENCODING); -} -function encodeIss(publicKey) { - const header = fromString(MULTICODEC_ED25519_HEADER, MULTICODEC_ED25519_ENCODING); - const multicodec = MULTICODEC_ED25519_BASE + toString(concat([header, publicKey]), MULTICODEC_ED25519_ENCODING); - return [DID_PREFIX, DID_METHOD, multicodec].join(DID_DELIMITER); -} -function encodeSig(bytes) { - return toString(bytes, JWT_ENCODING); -} -function encodeData(params) { - return fromString([encodeJSON(params.header), encodeJSON(params.payload)].join(JWT_DELIMITER), DATA_ENCODING); -} -function encodeJWT(params) { - return [ - encodeJSON(params.header), - encodeJSON(params.payload), - encodeSig(params.signature) - ].join(JWT_DELIMITER); -} -function generateKeyPair(seed = random.randomBytes(KEY_PAIR_SEED_LENGTH)) { - return ed25519.generateKeyPairFromSeed(seed); -} -async function signJWT(sub, aud, ttl, keyPair, iat = cjs$4.fromMiliseconds(Date.now())) { - const header = { alg: JWT_IRIDIUM_ALG, typ: JWT_IRIDIUM_TYP }; - const iss = encodeIss(keyPair.publicKey); - const exp = iat + ttl; - const payload = { iss, sub, aud, iat, exp }; - const data = encodeData({ header, payload }); - const signature = ed25519.sign(keyPair.secretKey, data); - return encodeJWT({ header, payload, signature }); -} -var chacha20poly1305 = {}; -var chacha = {}; -Object.defineProperty(chacha, "__esModule", { value: true }); -var binary_1 = binary; -var wipe_1$2 = wipe$1; -var ROUNDS = 20; -function core(out, input, key) { - var j0 = 1634760805; - var j1 = 857760878; - var j2 = 2036477234; - var j3 = 1797285236; - var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; - var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; - var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; - var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; - var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; - var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; - var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; - var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; - var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; - var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; - var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; - var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; - var x0 = j0; - var x1 = j1; - var x2 = j2; - var x3 = j3; - var x4 = j4; - var x5 = j5; - var x6 = j6; - var x7 = j7; - var x8 = j8; - var x9 = j9; - var x10 = j10; - var x11 = j11; - var x12 = j12; - var x13 = j13; - var x14 = j14; - var x15 = j15; - for (var i2 = 0; i2 < ROUNDS; i2 += 2) { - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 16 | x12 << 16; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 12 | x4 << 12; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 16 | x13 << 16; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 12 | x5 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 16 | x14 << 16; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 12 | x6 << 12; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 16 | x15 << 16; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 12 | x7 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 8 | x14 << 8; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 7 | x6 << 7; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 8 | x15 << 8; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 7 | x7 << 7; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 8 | x13 << 8; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 7 | x5 << 7; - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 8 | x12 << 8; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 7 | x4 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 16 | x15 << 16; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 12 | x5 << 12; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 16 | x12 << 16; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 12 | x6 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 16 | x13 << 16; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 12 | x7 << 12; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 16 | x14 << 16; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 12 | x4 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 8 | x13 << 8; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 7 | x7 << 7; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 8 | x14 << 8; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 7 | x4 << 7; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 8 | x12 << 8; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 7 | x6 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 8 | x15 << 8; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 7 | x5 << 7; - } - binary_1.writeUint32LE(x0 + j0 | 0, out, 0); - binary_1.writeUint32LE(x1 + j1 | 0, out, 4); - binary_1.writeUint32LE(x2 + j2 | 0, out, 8); - binary_1.writeUint32LE(x3 + j3 | 0, out, 12); - binary_1.writeUint32LE(x4 + j4 | 0, out, 16); - binary_1.writeUint32LE(x5 + j5 | 0, out, 20); - binary_1.writeUint32LE(x6 + j6 | 0, out, 24); - binary_1.writeUint32LE(x7 + j7 | 0, out, 28); - binary_1.writeUint32LE(x8 + j8 | 0, out, 32); - binary_1.writeUint32LE(x9 + j9 | 0, out, 36); - binary_1.writeUint32LE(x10 + j10 | 0, out, 40); - binary_1.writeUint32LE(x11 + j11 | 0, out, 44); - binary_1.writeUint32LE(x12 + j12 | 0, out, 48); - binary_1.writeUint32LE(x13 + j13 | 0, out, 52); - binary_1.writeUint32LE(x14 + j14 | 0, out, 56); - binary_1.writeUint32LE(x15 + j15 | 0, out, 60); -} -function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - if (key.length !== 32) { - throw new Error("ChaCha: key size must be 32 bytes"); - } - if (dst.length < src2.length) { - throw new Error("ChaCha: destination is shorter than source"); - } - var nc; - var counterLength; - if (nonceInplaceCounterLength === 0) { - if (nonce.length !== 8 && nonce.length !== 12) { - throw new Error("ChaCha nonce must be 8 or 12 bytes"); - } - nc = new Uint8Array(16); - counterLength = nc.length - nonce.length; - nc.set(nonce, counterLength); - } else { - if (nonce.length !== 16) { - throw new Error("ChaCha nonce with counter must be 16 bytes"); - } - nc = nonce; - counterLength = nonceInplaceCounterLength; - } - var block = new Uint8Array(64); - for (var i2 = 0; i2 < src2.length; i2 += 64) { - core(block, nc, key); - for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { - dst[j2] = src2[j2] ^ block[j2 - i2]; - } - incrementCounter(nc, 0, counterLength); - } - wipe_1$2.wipe(block); - if (nonceInplaceCounterLength === 0) { - wipe_1$2.wipe(nc); - } - return dst; -} -chacha.streamXOR = streamXOR; -function stream(key, nonce, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - wipe_1$2.wipe(dst); - return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); -} -chacha.stream = stream; -function incrementCounter(counter, pos, len) { - var carry = 1; - while (len--) { - carry = carry + (counter[pos] & 255) | 0; - counter[pos] = carry & 255; - carry >>>= 8; - pos++; - } - if (carry > 0) { - throw new Error("ChaCha: counter overflow"); - } -} -var poly1305 = {}; -var constantTime = {}; -Object.defineProperty(constantTime, "__esModule", { value: true }); -function select(subject, resultIfOne, resultIfZero) { - return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; -} -constantTime.select = select; -function lessOrEqual(a3, b3) { - return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; -} -constantTime.lessOrEqual = lessOrEqual; -function compare(a3, b3) { - if (a3.length !== b3.length) { - return 0; - } - var result = 0; - for (var i2 = 0; i2 < a3.length; i2++) { - result |= a3[i2] ^ b3[i2]; - } - return 1 & result - 1 >>> 8; -} -constantTime.compare = compare; -function equal(a3, b3) { - if (a3.length === 0 || b3.length === 0) { - return false; - } - return compare(a3, b3) !== 0; -} -constantTime.equal = equal; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var constant_time_12 = constantTime; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 16; - var Poly1305 = ( - /** @class */ - function() { - function Poly13052(key) { - this.digestLength = exports2.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 = false; - var t0 = key[0] | key[1] << 8; - this._r[0] = t0 & 8191; - var t1 = key[2] | key[3] << 8; - this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; - var t2 = key[4] | key[5] << 8; - this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; - var t3 = key[6] | key[7] << 8; - this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; - var t4 = key[8] | key[9] << 8; - this._r[4] = (t3 >>> 4 | t4 << 12) & 255; - this._r[5] = t4 >>> 1 & 8190; - var t5 = key[10] | key[11] << 8; - this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; - var t6 = key[12] | key[13] << 8; - this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; - var t7 = key[14] | key[15] << 8; - this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; - this._r[9] = t7 >>> 5 & 127; - this._pad[0] = key[16] | key[17] << 8; - this._pad[1] = key[18] | key[19] << 8; - this._pad[2] = key[20] | key[21] << 8; - this._pad[3] = key[22] | key[23] << 8; - this._pad[4] = key[24] | key[25] << 8; - this._pad[5] = key[26] | key[27] << 8; - this._pad[6] = key[28] | key[29] << 8; - this._pad[7] = key[30] | key[31] << 8; - } - Poly13052.prototype._blocks = function(m2, mpos, bytes) { - var hibit = this._fin ? 0 : 1 << 11; - var h0 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; - var r0 = this._r[0], r1 = this._r[1], r2 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; - while (bytes >= 16) { - var t0 = m2[mpos + 0] | m2[mpos + 1] << 8; - h0 += t0 & 8191; - var t1 = m2[mpos + 2] | m2[mpos + 3] << 8; - h1 += (t0 >>> 13 | t1 << 3) & 8191; - var t2 = m2[mpos + 4] | m2[mpos + 5] << 8; - h22 += (t1 >>> 10 | t2 << 6) & 8191; - var t3 = m2[mpos + 6] | m2[mpos + 7] << 8; - h32 += (t2 >>> 7 | t3 << 9) & 8191; - var t4 = m2[mpos + 8] | m2[mpos + 9] << 8; - h4 += (t3 >>> 4 | t4 << 12) & 8191; - h5 += t4 >>> 1 & 8191; - var t5 = m2[mpos + 10] | m2[mpos + 11] << 8; - h6 += (t4 >>> 14 | t5 << 2) & 8191; - var t6 = m2[mpos + 12] | m2[mpos + 13] << 8; - h7 += (t5 >>> 11 | t6 << 5) & 8191; - var t7 = m2[mpos + 14] | m2[mpos + 15] << 8; - h8 += (t6 >>> 8 | t7 << 8) & 8191; - h9 += t7 >>> 5 | hibit; - var c2 = 0; - var d0 = c2; - d0 += h0 * r0; - d0 += h1 * (5 * r9); - d0 += h22 * (5 * r8); - d0 += h32 * (5 * r7); - d0 += h4 * (5 * r6); - c2 = d0 >>> 13; - d0 &= 8191; - d0 += h5 * (5 * r5); - d0 += h6 * (5 * r4); - d0 += h7 * (5 * r3); - d0 += h8 * (5 * r2); - d0 += h9 * (5 * r1); - c2 += d0 >>> 13; - d0 &= 8191; - var d1 = c2; - d1 += h0 * r1; - d1 += h1 * r0; - d1 += h22 * (5 * r9); - d1 += h32 * (5 * r8); - d1 += h4 * (5 * r7); - c2 = d1 >>> 13; - d1 &= 8191; - d1 += h5 * (5 * r6); - d1 += h6 * (5 * r5); - d1 += h7 * (5 * r4); - d1 += h8 * (5 * r3); - d1 += h9 * (5 * r2); - c2 += d1 >>> 13; - d1 &= 8191; - var d22 = c2; - d22 += h0 * r2; - d22 += h1 * r1; - d22 += h22 * r0; - d22 += h32 * (5 * r9); - d22 += h4 * (5 * r8); - c2 = d22 >>> 13; - d22 &= 8191; - d22 += h5 * (5 * r7); - d22 += h6 * (5 * r6); - d22 += h7 * (5 * r5); - d22 += h8 * (5 * r4); - d22 += h9 * (5 * r3); - c2 += d22 >>> 13; - d22 &= 8191; - var d3 = c2; - d3 += h0 * r3; - d3 += h1 * r2; - d3 += h22 * r1; - d3 += h32 * r0; - d3 += h4 * (5 * r9); - c2 = d3 >>> 13; - d3 &= 8191; - d3 += h5 * (5 * r8); - d3 += h6 * (5 * r7); - d3 += h7 * (5 * r6); - d3 += h8 * (5 * r5); - d3 += h9 * (5 * r4); - c2 += d3 >>> 13; - d3 &= 8191; - var d4 = c2; - d4 += h0 * r4; - d4 += h1 * r3; - d4 += h22 * r2; - d4 += h32 * r1; - d4 += h4 * r0; - c2 = d4 >>> 13; - d4 &= 8191; - d4 += h5 * (5 * r9); - d4 += h6 * (5 * r8); - d4 += h7 * (5 * r7); - d4 += h8 * (5 * r6); - d4 += h9 * (5 * r5); - c2 += d4 >>> 13; - d4 &= 8191; - var d5 = c2; - d5 += h0 * r5; - d5 += h1 * r4; - d5 += h22 * r3; - d5 += h32 * r2; - d5 += h4 * r1; - c2 = d5 >>> 13; - d5 &= 8191; - d5 += h5 * r0; - d5 += h6 * (5 * r9); - d5 += h7 * (5 * r8); - d5 += h8 * (5 * r7); - d5 += h9 * (5 * r6); - c2 += d5 >>> 13; - d5 &= 8191; - var d6 = c2; - d6 += h0 * r6; - d6 += h1 * r5; - d6 += h22 * r4; - d6 += h32 * r3; - d6 += h4 * r2; - c2 = d6 >>> 13; - d6 &= 8191; - d6 += h5 * r1; - d6 += h6 * r0; - d6 += h7 * (5 * r9); - d6 += h8 * (5 * r8); - d6 += h9 * (5 * r7); - c2 += d6 >>> 13; - d6 &= 8191; - var d7 = c2; - d7 += h0 * r7; - d7 += h1 * r6; - d7 += h22 * r5; - d7 += h32 * r4; - d7 += h4 * r3; - c2 = d7 >>> 13; - d7 &= 8191; - d7 += h5 * r2; - d7 += h6 * r1; - d7 += h7 * r0; - d7 += h8 * (5 * r9); - d7 += h9 * (5 * r8); - c2 += d7 >>> 13; - d7 &= 8191; - var d8 = c2; - d8 += h0 * r8; - d8 += h1 * r7; - d8 += h22 * r6; - d8 += h32 * r5; - d8 += h4 * r4; - c2 = d8 >>> 13; - d8 &= 8191; - d8 += h5 * r3; - d8 += h6 * r2; - d8 += h7 * r1; - d8 += h8 * r0; - d8 += h9 * (5 * r9); - c2 += d8 >>> 13; - d8 &= 8191; - var d9 = c2; - d9 += h0 * r9; - d9 += h1 * r8; - d9 += h22 * r7; - d9 += h32 * r6; - d9 += h4 * r5; - c2 = d9 >>> 13; - d9 &= 8191; - d9 += h5 * r4; - d9 += h6 * r3; - d9 += h7 * r2; - d9 += h8 * r1; - d9 += h9 * r0; - c2 += d9 >>> 13; - d9 &= 8191; - c2 = (c2 << 2) + c2 | 0; - c2 = c2 + d0 | 0; - d0 = c2 & 8191; - c2 = c2 >>> 13; - d1 += c2; - h0 = d0; - h1 = d1; - h22 = d22; - h32 = d3; - h4 = d4; - h5 = d5; - h6 = d6; - h7 = d7; - h8 = d8; - h9 = d9; - mpos += 16; - bytes -= 16; - } - this._h[0] = h0; - this._h[1] = h1; - this._h[2] = h22; - this._h[3] = h32; - this._h[4] = h4; - this._h[5] = h5; - this._h[6] = h6; - this._h[7] = h7; - this._h[8] = h8; - this._h[9] = h9; - }; - Poly13052.prototype.finish = function(mac, macpos) { - if (macpos === void 0) { - macpos = 0; - } - var g3 = new Uint16Array(10); - var c2; - var mask; - var f2; - var i2; - if (this._leftover) { - i2 = this._leftover; - this._buffer[i2++] = 1; - for (; i2 < 16; i2++) { - this._buffer[i2] = 0; - } - this._fin = 1; - this._blocks(this._buffer, 0, 16); - } - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - for (i2 = 2; i2 < 10; i2++) { - this._h[i2] += c2; - c2 = this._h[i2] >>> 13; - this._h[i2] &= 8191; - } - this._h[0] += c2 * 5; - c2 = this._h[0] >>> 13; - this._h[0] &= 8191; - this._h[1] += c2; - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - this._h[2] += c2; - g3[0] = this._h[0] + 5; - c2 = g3[0] >>> 13; - g3[0] &= 8191; - for (i2 = 1; i2 < 10; i2++) { - g3[i2] = this._h[i2] + c2; - c2 = g3[i2] >>> 13; - g3[i2] &= 8191; - } - g3[9] -= 1 << 13; - mask = (c2 ^ 1) - 1; - for (i2 = 0; i2 < 10; i2++) { - g3[i2] &= mask; - } - mask = ~mask; - for (i2 = 0; i2 < 10; i2++) { - this._h[i2] = this._h[i2] & mask | g3[i2]; - } - 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; - f2 = this._h[0] + this._pad[0]; - this._h[0] = f2 & 65535; - for (i2 = 1; i2 < 8; i2++) { - f2 = (this._h[i2] + this._pad[i2] | 0) + (f2 >>> 16) | 0; - this._h[i2] = f2 & 65535; - } - mac[macpos + 0] = this._h[0] >>> 0; - mac[macpos + 1] = this._h[0] >>> 8; - mac[macpos + 2] = this._h[1] >>> 0; - mac[macpos + 3] = this._h[1] >>> 8; - mac[macpos + 4] = this._h[2] >>> 0; - mac[macpos + 5] = this._h[2] >>> 8; - mac[macpos + 6] = this._h[3] >>> 0; - mac[macpos + 7] = this._h[3] >>> 8; - mac[macpos + 8] = this._h[4] >>> 0; - mac[macpos + 9] = this._h[4] >>> 8; - mac[macpos + 10] = this._h[5] >>> 0; - mac[macpos + 11] = this._h[5] >>> 8; - mac[macpos + 12] = this._h[6] >>> 0; - mac[macpos + 13] = this._h[6] >>> 8; - mac[macpos + 14] = this._h[7] >>> 0; - mac[macpos + 15] = this._h[7] >>> 8; - this._finished = true; - return this; - }; - Poly13052.prototype.update = function(m2) { - var mpos = 0; - var bytes = m2.length; - var want; - if (this._leftover) { - want = 16 - this._leftover; - if (want > bytes) { - want = bytes; - } - for (var i2 = 0; i2 < want; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; - } - bytes -= want; - mpos += want; - this._leftover += want; - if (this._leftover < 16) { - return this; - } - this._blocks(this._buffer, 0, 16); - this._leftover = 0; - } - if (bytes >= 16) { - want = bytes - bytes % 16; - this._blocks(m2, mpos, want); - mpos += want; - bytes -= want; - } - if (bytes) { - for (var i2 = 0; i2 < bytes; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; - } - this._leftover += bytes; - } - return this; - }; - Poly13052.prototype.digest = function() { - if (this._finished) { - throw new Error("Poly1305 was finished"); - } - var mac = new Uint8Array(16); - this.finish(mac); - return mac; - }; - Poly13052.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._r); - wipe_12.wipe(this._h); - wipe_12.wipe(this._pad); - this._leftover = 0; - this._fin = 0; - this._finished = true; - return this; - }; - return Poly13052; - }() - ); - exports2.Poly1305 = Poly1305; - function oneTimeAuth(key, data) { - var h4 = new Poly1305(key); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; - } - exports2.oneTimeAuth = oneTimeAuth; - function equal2(a3, b3) { - if (a3.length !== exports2.DIGEST_LENGTH || b3.length !== exports2.DIGEST_LENGTH) { - return false; - } - return constant_time_12.equal(a3, b3); - } - exports2.equal = equal2; -})(poly1305); -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var chacha_1 = chacha; - var poly1305_1 = poly1305; - var wipe_12 = wipe$1; - var binary_12 = binary; - var constant_time_12 = constantTime; - exports2.KEY_LENGTH = 32; - exports2.NONCE_LENGTH = 12; - exports2.TAG_LENGTH = 16; - var ZEROS = new Uint8Array(16); - var ChaCha20Poly1305 = ( - /** @class */ - function() { - function ChaCha20Poly13052(key) { - this.nonceLength = exports2.NONCE_LENGTH; - this.tagLength = exports2.TAG_LENGTH; - if (key.length !== exports2.KEY_LENGTH) { - throw new Error("ChaCha20Poly1305 needs 32-byte key"); - } - this._key = new Uint8Array(key); - } - ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var resultLength = plaintext.length + this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); - } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, plaintext, result, 4); - this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - if (sealed.length < this.tagLength) { - return null; - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var calculatedTag = new Uint8Array(this.tagLength); - this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); - if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { - return null; - } - var resultLength = sealed.length - this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); - } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.clean = function() { - wipe_12.wipe(this._key); - return this; - }; - ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { - var h4 = new poly1305_1.Poly1305(authKey); - if (associatedData) { - h4.update(associatedData); - if (associatedData.length % 16 > 0) { - h4.update(ZEROS.subarray(associatedData.length % 16)); - } - } - h4.update(ciphertext); - if (ciphertext.length % 16 > 0) { - h4.update(ZEROS.subarray(ciphertext.length % 16)); - } - var length = new Uint8Array(8); - if (associatedData) { - binary_12.writeUint64LE(associatedData.length, length); - } - h4.update(length); - binary_12.writeUint64LE(ciphertext.length, length); - h4.update(length); - var tag = h4.digest(); - for (var i2 = 0; i2 < tag.length; i2++) { - tagOut[i2] = tag[i2]; - } - h4.clean(); - wipe_12.wipe(tag); - wipe_12.wipe(length); - }; - return ChaCha20Poly13052; - }() - ); - exports2.ChaCha20Poly1305 = ChaCha20Poly1305; -})(chacha20poly1305); -var hkdf = {}; -var hmac$1 = {}; -var hash = {}; -Object.defineProperty(hash, "__esModule", { value: true }); -function isSerializableHash(h4) { - return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; -} -hash.isSerializableHash = isSerializableHash; -Object.defineProperty(hmac$1, "__esModule", { value: true }); -var hash_1 = hash; -var constant_time_1 = constantTime; -var wipe_1$1 = wipe$1; -var HMAC = ( - /** @class */ - function() { - function HMAC2(hash2, key) { - this._finished = false; - this._inner = new hash2(); - this._outer = new hash2(); - this.blockSize = this._outer.blockSize; - this.digestLength = this._outer.digestLength; - var pad = new Uint8Array(this.blockSize); - if (key.length > this.blockSize) { - this._inner.update(key).finish(pad).clean(); - } else { - pad.set(key); - } - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54; - } - this._inner.update(pad); - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54 ^ 92; - } - this._outer.update(pad); - if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { - this._innerKeyedState = this._inner.saveState(); - this._outerKeyedState = this._outer.saveState(); - } - wipe_1$1.wipe(pad); - } - HMAC2.prototype.reset = function() { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); - } - this._inner.restoreState(this._innerKeyedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.clean = function() { - if (hash_1.isSerializableHash(this._inner)) { - this._inner.cleanSavedState(this._innerKeyedState); - } - if (hash_1.isSerializableHash(this._outer)) { - this._outer.cleanSavedState(this._outerKeyedState); - } - this._inner.clean(); - this._outer.clean(); - }; - HMAC2.prototype.update = function(data) { - this._inner.update(data); - return this; - }; - HMAC2.prototype.finish = function(out) { - if (this._finished) { - this._outer.finish(out); - return this; - } - this._inner.finish(out); - this._outer.update(out.subarray(0, this.digestLength)).finish(out); - this._finished = true; - return this; - }; - HMAC2.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - HMAC2.prototype.saveState = function() { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't saveState() because hash doesn't implement it"); - } - return this._inner.saveState(); - }; - HMAC2.prototype.restoreState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't restoreState() because hash doesn't implement it"); - } - this._inner.restoreState(savedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.cleanSavedState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); - } - this._inner.cleanSavedState(savedState); - }; - return HMAC2; - }() -); -hmac$1.HMAC = HMAC; -function hmac(hash2, key, data) { - var h4 = new HMAC(hash2, key); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; -} -hmac$1.hmac = hmac; -hmac$1.equal = constant_time_1.equal; -Object.defineProperty(hkdf, "__esModule", { value: true }); -var hmac_1 = hmac$1; -var wipe_1 = wipe$1; -var HKDF = ( - /** @class */ - function() { - function HKDF2(hash2, key, salt, info) { - if (salt === void 0) { - salt = new Uint8Array(0); - } - this._counter = new Uint8Array(1); - this._hash = hash2; - this._info = info; - var okm = hmac_1.hmac(this._hash, salt, key); - this._hmac = new hmac_1.HMAC(hash2, okm); - this._buffer = new Uint8Array(this._hmac.digestLength); - this._bufpos = this._buffer.length; - } - HKDF2.prototype._fillBuffer = function() { - this._counter[0]++; - var ctr = this._counter[0]; - if (ctr === 0) { - throw new Error("hkdf: cannot expand more"); - } - this._hmac.reset(); - if (ctr > 1) { - this._hmac.update(this._buffer); - } - if (this._info) { - this._hmac.update(this._info); - } - this._hmac.update(this._counter); - this._hmac.finish(this._buffer); - this._bufpos = 0; - }; - HKDF2.prototype.expand = function(length) { - var out = new Uint8Array(length); - for (var i2 = 0; i2 < out.length; i2++) { - if (this._bufpos === this._buffer.length) { - this._fillBuffer(); - } - out[i2] = this._buffer[this._bufpos++]; - } - return out; - }; - HKDF2.prototype.clean = function() { - this._hmac.clean(); - wipe_1.wipe(this._buffer); - wipe_1.wipe(this._counter); - this._bufpos = 0; - }; - return HKDF2; - }() -); -var HKDF_1 = hkdf.HKDF = HKDF; -var sha256 = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var binary_12 = binary; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 32; - exports2.BLOCK_SIZE = 64; - var SHA256 = ( - /** @class */ - function() { - function SHA2562() { - this.digestLength = exports2.DIGEST_LENGTH; - this.blockSize = exports2.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 = false; - this.reset(); - } - SHA2562.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; - }; - SHA2562.prototype.reset = function() { - this._initState(); - this._bufferLength = 0; - this._bytesHashed = 0; - this._finished = false; - return this; - }; - SHA2562.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._temp); - this.reset(); - }; - SHA2562.prototype.update = function(data, dataLength) { - if (dataLength === void 0) { - dataLength = data.length; - } - if (this._finished) { - throw new Error("SHA256: can't update because hash was finished."); - } - var dataPos = 0; - this._bytesHashed += dataLength; - if (this._bufferLength > 0) { - while (this._bufferLength < this.blockSize && dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - if (this._bufferLength === this.blockSize) { - hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); - this._bufferLength = 0; - } - } - if (dataLength >= this.blockSize) { - dataPos = hashBlocks(this._temp, this._state, data, dataPos, dataLength); - dataLength %= this.blockSize; - } - while (dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - return this; - }; - SHA2562.prototype.finish = function(out) { - if (!this._finished) { - var bytesHashed = this._bytesHashed; - var left = this._bufferLength; - var bitLenHi = bytesHashed / 536870912 | 0; - var bitLenLo = bytesHashed << 3; - var padLength = bytesHashed % 64 < 56 ? 64 : 128; - this._buffer[left] = 128; - for (var i2 = left + 1; i2 < padLength - 8; i2++) { - this._buffer[i2] = 0; - } - binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); - binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); - hashBlocks(this._temp, this._state, this._buffer, 0, padLength); - this._finished = true; - } - for (var i2 = 0; i2 < this.digestLength / 4; i2++) { - binary_12.writeUint32BE(this._state[i2], out, i2 * 4); - } - return this; - }; - SHA2562.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - SHA2562.prototype.saveState = function() { - if (this._finished) { - throw new Error("SHA256: cannot save finished state"); - } - return { - state: new Int32Array(this._state), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed - }; - }; - SHA2562.prototype.restoreState = function(savedState) { - this._state.set(savedState.state); - this._bufferLength = savedState.bufferLength; - if (savedState.buffer) { - this._buffer.set(savedState.buffer); - } - this._bytesHashed = savedState.bytesHashed; - this._finished = false; - return this; - }; - SHA2562.prototype.cleanSavedState = function(savedState) { - wipe_12.wipe(savedState.state); - if (savedState.buffer) { - wipe_12.wipe(savedState.buffer); - } - savedState.bufferLength = 0; - savedState.bytesHashed = 0; - }; - return SHA2562; - }() - ); - exports2.SHA256 = SHA256; - var K2 = 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 hashBlocks(w3, v3, p3, pos, len) { - while (len >= 64) { - var a3 = v3[0]; - var b3 = v3[1]; - var c2 = v3[2]; - var d3 = v3[3]; - var e = v3[4]; - var f2 = v3[5]; - var g3 = v3[6]; - var h4 = v3[7]; - for (var i2 = 0; i2 < 16; i2++) { - var j2 = pos + i2 * 4; - w3[i2] = binary_12.readUint32BE(p3, j2); - } - for (var i2 = 16; i2 < 64; i2++) { - var u3 = w3[i2 - 2]; - var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; - u3 = w3[i2 - 15]; - var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; - w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); - } - for (var i2 = 0; i2 < 64; i2++) { - var t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f2 ^ ~e & g3) | 0) + (h4 + (K2[i2] + w3[i2] | 0) | 0) | 0; - var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; - h4 = g3; - g3 = f2; - f2 = e; - e = d3 + t1 | 0; - d3 = c2; - c2 = b3; - b3 = a3; - a3 = t1 + t2 | 0; - } - v3[0] += a3; - v3[1] += b3; - v3[2] += c2; - v3[3] += d3; - v3[4] += e; - v3[5] += f2; - v3[6] += g3; - v3[7] += h4; - pos += 64; - len -= 64; - } - return pos; - } - function hash2(data) { - var h4 = new SHA256(); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; - } - exports2.hash = hash2; -})(sha256); -var x25519 = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.sharedKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.scalarMultBase = exports2.scalarMult = exports2.SHARED_KEY_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = void 0; - const random_1 = random; - const wipe_12 = wipe$1; - exports2.PUBLIC_KEY_LENGTH = 32; - exports2.SECRET_KEY_LENGTH = 32; - exports2.SHARED_KEY_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); - if (init) { - for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; - } - } - return r2; - } - const _9 = new Uint8Array(32); - _9[0] = 9; - const _121665 = gf([56129, 1]); - function car25519(o2) { - let c2 = 1; - for (let i2 = 0; i2 < 16; i2++) { - let v3 = o2[i2] + c2 + 65535; - c2 = Math.floor(v3 / 65536); - o2[i2] = v3 - c2 * 65536; - } - o2[0] += c2 - 1 + 37 * (c2 - 1); - } - function sel25519(p3, q2, b3) { - const c2 = ~(b3 - 1); - for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; - q2[i2] ^= t2; - } - } - function pack25519(o2, n3) { - const m2 = gf(); - const t2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; - } - car25519(t2); - car25519(t2); - car25519(t2); - for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; - for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; - } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); - } - for (let i2 = 0; i2 < 16; i2++) { - o2[2 * i2] = t2[i2] & 255; - o2[2 * i2 + 1] = t2[i2] >> 8; - } - } - function unpack25519(o2, n3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); - } - o2[15] &= 32767; - } - function add(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] + b3[i2]; - } - } - function sub(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] - b3[i2]; - } - } - function mul(o2, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; - v3 = a3[0]; - t0 += v3 * b0; - t1 += v3 * b1; - t2 += v3 * b22; - t3 += v3 * b32; - t4 += v3 * b4; - t5 += v3 * b5; - t6 += v3 * b6; - t7 += v3 * b7; - t8 += v3 * b8; - t9 += v3 * b9; - t10 += v3 * b10; - t11 += v3 * b11; - t12 += v3 * b12; - t13 += v3 * b13; - t14 += v3 * b14; - t15 += v3 * b15; - v3 = a3[1]; - t1 += v3 * b0; - t2 += v3 * b1; - t3 += v3 * b22; - t4 += v3 * b32; - t5 += v3 * b4; - t6 += v3 * b5; - t7 += v3 * b6; - t8 += v3 * b7; - t9 += v3 * b8; - t10 += v3 * b9; - t11 += v3 * b10; - t12 += v3 * b11; - t13 += v3 * b12; - t14 += v3 * b13; - t15 += v3 * b14; - t16 += v3 * b15; - v3 = a3[2]; - t2 += v3 * b0; - t3 += v3 * b1; - t4 += v3 * b22; - t5 += v3 * b32; - t6 += v3 * b4; - t7 += v3 * b5; - t8 += v3 * b6; - t9 += v3 * b7; - t10 += v3 * b8; - t11 += v3 * b9; - t12 += v3 * b10; - t13 += v3 * b11; - t14 += v3 * b12; - t15 += v3 * b13; - t16 += v3 * b14; - t17 += v3 * b15; - v3 = a3[3]; - t3 += v3 * b0; - t4 += v3 * b1; - t5 += v3 * b22; - t6 += v3 * b32; - t7 += v3 * b4; - t8 += v3 * b5; - t9 += v3 * b6; - t10 += v3 * b7; - t11 += v3 * b8; - t12 += v3 * b9; - t13 += v3 * b10; - t14 += v3 * b11; - t15 += v3 * b12; - t16 += v3 * b13; - t17 += v3 * b14; - t18 += v3 * b15; - v3 = a3[4]; - t4 += v3 * b0; - t5 += v3 * b1; - t6 += v3 * b22; - t7 += v3 * b32; - t8 += v3 * b4; - t9 += v3 * b5; - t10 += v3 * b6; - t11 += v3 * b7; - t12 += v3 * b8; - t13 += v3 * b9; - t14 += v3 * b10; - t15 += v3 * b11; - t16 += v3 * b12; - t17 += v3 * b13; - t18 += v3 * b14; - t19 += v3 * b15; - v3 = a3[5]; - t5 += v3 * b0; - t6 += v3 * b1; - t7 += v3 * b22; - t8 += v3 * b32; - t9 += v3 * b4; - t10 += v3 * b5; - t11 += v3 * b6; - t12 += v3 * b7; - t13 += v3 * b8; - t14 += v3 * b9; - t15 += v3 * b10; - t16 += v3 * b11; - t17 += v3 * b12; - t18 += v3 * b13; - t19 += v3 * b14; - t20 += v3 * b15; - v3 = a3[6]; - t6 += v3 * b0; - t7 += v3 * b1; - t8 += v3 * b22; - t9 += v3 * b32; - t10 += v3 * b4; - t11 += v3 * b5; - t12 += v3 * b6; - t13 += v3 * b7; - t14 += v3 * b8; - t15 += v3 * b9; - t16 += v3 * b10; - t17 += v3 * b11; - t18 += v3 * b12; - t19 += v3 * b13; - t20 += v3 * b14; - t21 += v3 * b15; - v3 = a3[7]; - t7 += v3 * b0; - t8 += v3 * b1; - t9 += v3 * b22; - t10 += v3 * b32; - t11 += v3 * b4; - t12 += v3 * b5; - t13 += v3 * b6; - t14 += v3 * b7; - t15 += v3 * b8; - t16 += v3 * b9; - t17 += v3 * b10; - t18 += v3 * b11; - t19 += v3 * b12; - t20 += v3 * b13; - t21 += v3 * b14; - t22 += v3 * b15; - v3 = a3[8]; - t8 += v3 * b0; - t9 += v3 * b1; - t10 += v3 * b22; - t11 += v3 * b32; - t12 += v3 * b4; - t13 += v3 * b5; - t14 += v3 * b6; - t15 += v3 * b7; - t16 += v3 * b8; - t17 += v3 * b9; - t18 += v3 * b10; - t19 += v3 * b11; - t20 += v3 * b12; - t21 += v3 * b13; - t22 += v3 * b14; - t23 += v3 * b15; - v3 = a3[9]; - t9 += v3 * b0; - t10 += v3 * b1; - t11 += v3 * b22; - t12 += v3 * b32; - t13 += v3 * b4; - t14 += v3 * b5; - t15 += v3 * b6; - t16 += v3 * b7; - t17 += v3 * b8; - t18 += v3 * b9; - t19 += v3 * b10; - t20 += v3 * b11; - t21 += v3 * b12; - t22 += v3 * b13; - t23 += v3 * b14; - t24 += v3 * b15; - v3 = a3[10]; - t10 += v3 * b0; - t11 += v3 * b1; - t12 += v3 * b22; - t13 += v3 * b32; - t14 += v3 * b4; - t15 += v3 * b5; - t16 += v3 * b6; - t17 += v3 * b7; - t18 += v3 * b8; - t19 += v3 * b9; - t20 += v3 * b10; - t21 += v3 * b11; - t22 += v3 * b12; - t23 += v3 * b13; - t24 += v3 * b14; - t25 += v3 * b15; - v3 = a3[11]; - t11 += v3 * b0; - t12 += v3 * b1; - t13 += v3 * b22; - t14 += v3 * b32; - t15 += v3 * b4; - t16 += v3 * b5; - t17 += v3 * b6; - t18 += v3 * b7; - t19 += v3 * b8; - t20 += v3 * b9; - t21 += v3 * b10; - t22 += v3 * b11; - t23 += v3 * b12; - t24 += v3 * b13; - t25 += v3 * b14; - t26 += v3 * b15; - v3 = a3[12]; - t12 += v3 * b0; - t13 += v3 * b1; - t14 += v3 * b22; - t15 += v3 * b32; - t16 += v3 * b4; - t17 += v3 * b5; - t18 += v3 * b6; - t19 += v3 * b7; - t20 += v3 * b8; - t21 += v3 * b9; - t22 += v3 * b10; - t23 += v3 * b11; - t24 += v3 * b12; - t25 += v3 * b13; - t26 += v3 * b14; - t27 += v3 * b15; - v3 = a3[13]; - t13 += v3 * b0; - t14 += v3 * b1; - t15 += v3 * b22; - t16 += v3 * b32; - t17 += v3 * b4; - t18 += v3 * b5; - t19 += v3 * b6; - t20 += v3 * b7; - t21 += v3 * b8; - t22 += v3 * b9; - t23 += v3 * b10; - t24 += v3 * b11; - t25 += v3 * b12; - t26 += v3 * b13; - t27 += v3 * b14; - t28 += v3 * b15; - v3 = a3[14]; - t14 += v3 * b0; - t15 += v3 * b1; - t16 += v3 * b22; - t17 += v3 * b32; - t18 += v3 * b4; - t19 += v3 * b5; - t20 += v3 * b6; - t21 += v3 * b7; - t22 += v3 * b8; - t23 += v3 * b9; - t24 += v3 * b10; - t25 += v3 * b11; - t26 += v3 * b12; - t27 += v3 * b13; - t28 += v3 * b14; - t29 += v3 * b15; - v3 = a3[15]; - t15 += v3 * b0; - t16 += v3 * b1; - t17 += v3 * b22; - t18 += v3 * b32; - t19 += v3 * b4; - t20 += v3 * b5; - t21 += v3 * b6; - t22 += v3 * b7; - t23 += v3 * b8; - t24 += v3 * b9; - t25 += v3 * b10; - t26 += v3 * b11; - t27 += v3 * b12; - t28 += v3 * b13; - t29 += v3 * b14; - t30 += v3 * b15; - t0 += 38 * t16; - t1 += 38 * t17; - t2 += 38 * t18; - t3 += 38 * t19; - t4 += 38 * t20; - t5 += 38 * t21; - t6 += 38 * t22; - t7 += 38 * t23; - t8 += 38 * t24; - t9 += 38 * t25; - t10 += 38 * t26; - t11 += 38 * t27; - t12 += 38 * t28; - t13 += 38 * t29; - t14 += 38 * t30; - c2 = 1; - v3 = t0 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t0 = v3 - c2 * 65536; - v3 = t1 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t1 = v3 - c2 * 65536; - v3 = t2 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t2 = v3 - c2 * 65536; - v3 = t3 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t3 = v3 - c2 * 65536; - v3 = t4 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t4 = v3 - c2 * 65536; - v3 = t5 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t5 = v3 - c2 * 65536; - v3 = t6 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t6 = v3 - c2 * 65536; - v3 = t7 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t7 = v3 - c2 * 65536; - v3 = t8 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t8 = v3 - c2 * 65536; - v3 = t9 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t9 = v3 - c2 * 65536; - v3 = t10 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t10 = v3 - c2 * 65536; - v3 = t11 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t11 = v3 - c2 * 65536; - v3 = t12 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t12 = v3 - c2 * 65536; - v3 = t13 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t13 = v3 - c2 * 65536; - v3 = t14 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t14 = v3 - c2 * 65536; - v3 = t15 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t15 = v3 - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - c2 = 1; - v3 = t0 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t0 = v3 - c2 * 65536; - v3 = t1 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t1 = v3 - c2 * 65536; - v3 = t2 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t2 = v3 - c2 * 65536; - v3 = t3 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t3 = v3 - c2 * 65536; - v3 = t4 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t4 = v3 - c2 * 65536; - v3 = t5 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t5 = v3 - c2 * 65536; - v3 = t6 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t6 = v3 - c2 * 65536; - v3 = t7 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t7 = v3 - c2 * 65536; - v3 = t8 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t8 = v3 - c2 * 65536; - v3 = t9 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t9 = v3 - c2 * 65536; - v3 = t10 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t10 = v3 - c2 * 65536; - v3 = t11 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t11 = v3 - c2 * 65536; - v3 = t12 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t12 = v3 - c2 * 65536; - v3 = t13 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t13 = v3 - c2 * 65536; - v3 = t14 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t14 = v3 - c2 * 65536; - v3 = t15 + c2 + 65535; - c2 = Math.floor(v3 / 65536); - t15 = v3 - c2 * 65536; - t0 += c2 - 1 + 37 * (c2 - 1); - o2[0] = t0; - o2[1] = t1; - o2[2] = t2; - o2[3] = t3; - o2[4] = t4; - o2[5] = t5; - o2[6] = t6; - o2[7] = t7; - o2[8] = t8; - o2[9] = t9; - o2[10] = t10; - o2[11] = t11; - o2[12] = t12; - o2[13] = t13; - o2[14] = t14; - o2[15] = t15; - } - function square(o2, a3) { - mul(o2, a3, a3); - } - function inv25519(o2, inp) { - const c2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - c2[i2] = inp[i2]; - } - for (let i2 = 253; i2 >= 0; i2--) { - square(c2, c2); - if (i2 !== 2 && i2 !== 4) { - mul(c2, c2, inp); - } - } - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = c2[i2]; - } - } - function scalarMult(n3, p3) { - const z3 = new Uint8Array(32); - const x2 = new Float64Array(80); - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e = gf(), f2 = gf(); - for (let i2 = 0; i2 < 31; i2++) { - z3[i2] = n3[i2]; - } - z3[31] = n3[31] & 127 | 64; - z3[0] &= 248; - unpack25519(x2, p3); - for (let i2 = 0; i2 < 16; i2++) { - b3[i2] = x2[i2]; - } - a3[0] = d3[0] = 1; - for (let i2 = 254; i2 >= 0; --i2) { - const r2 = z3[i2 >>> 3] >>> (i2 & 7) & 1; - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); - add(e, a3, c2); - sub(a3, a3, c2); - add(c2, b3, d3); - sub(b3, b3, d3); - square(d3, e); - square(f2, a3); - mul(a3, c2, a3); - mul(c2, b3, e); - add(e, a3, c2); - sub(a3, a3, c2); - square(b3, a3); - sub(c2, d3, f2); - mul(a3, c2, _121665); - add(a3, a3, d3); - mul(c2, c2, a3); - mul(a3, d3, f2); - mul(d3, b3, x2); - square(b3, e); - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); - } - for (let i2 = 0; i2 < 16; i2++) { - x2[i2 + 16] = a3[i2]; - x2[i2 + 32] = c2[i2]; - x2[i2 + 48] = b3[i2]; - x2[i2 + 64] = d3[i2]; - } - const x32 = x2.subarray(32); - const x16 = x2.subarray(16); - inv25519(x32, x32); - mul(x16, x16, x32); - const q2 = new Uint8Array(32); - pack25519(q2, x16); - return q2; - } - exports2.scalarMult = scalarMult; - function scalarMultBase(n3) { - return scalarMult(n3, _9); - } - exports2.scalarMultBase = scalarMultBase; - function generateKeyPairFromSeed(seed) { - if (seed.length !== exports2.SECRET_KEY_LENGTH) { - throw new Error(`x25519: seed must be ${exports2.SECRET_KEY_LENGTH} bytes`); - } - const secretKey = new Uint8Array(seed); - const publicKey = scalarMultBase(secretKey); - return { - publicKey, - secretKey - }; - } - exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; - function generateKeyPair2(prng) { - const seed = (0, random_1.randomBytes)(32, prng); - const result = generateKeyPairFromSeed(seed); - (0, wipe_12.wipe)(seed); - return result; - } - exports2.generateKeyPair = generateKeyPair2; - function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { - if (mySecretKey.length !== exports2.PUBLIC_KEY_LENGTH) { - throw new Error("X25519: incorrect secret key length"); - } - if (theirPublicKey.length !== exports2.PUBLIC_KEY_LENGTH) { - throw new Error("X25519: incorrect public key length"); - } - const result = scalarMult(mySecretKey, theirPublicKey); - if (rejectZero) { - let zeros = 0; - for (let i2 = 0; i2 < result.length; i2++) { - zeros |= result[i2]; - } - if (zeros === 0) { - throw new Error("X25519: invalid shared key"); - } - } - return result; - } - exports2.sharedKey = sharedKey; -})(x25519); -var __spreadArray = function(to, from2, pack) { - if (pack || arguments.length === 2) - for (var i2 = 0, l2 = from2.length, ar2; i2 < l2; i2++) { - if (ar2 || !(i2 in from2)) { - if (!ar2) - ar2 = Array.prototype.slice.call(from2, 0, i2); - ar2[i2] = from2[i2]; - } - } - return to.concat(ar2 || Array.prototype.slice.call(from2)); -}; -var BrowserInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BrowserInfo2(name2, version2, os2) { - this.name = name2; - this.version = version2; - this.os = os2; - this.type = "browser"; - } - return BrowserInfo2; - }() -); -var NodeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function NodeInfo2(version2) { - this.version = version2; - this.type = "node"; - this.name = "node"; - this.os = process.platform; - } - return NodeInfo2; - }() -); -var SearchBotDeviceInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function SearchBotDeviceInfo2(name2, version2, os2, bot) { - this.name = name2; - this.version = version2; - this.os = os2; - this.bot = bot; - this.type = "bot-device"; - } - return SearchBotDeviceInfo2; - }() -); -var BotInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BotInfo2() { - this.type = "bot"; - this.bot = true; - this.name = "bot"; - this.version = null; - this.os = null; - } - return BotInfo2; - }() -); -var ReactNativeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function ReactNativeInfo2() { - this.type = "react-native"; - this.name = "react-native"; - this.version = null; - this.os = null; - } - return ReactNativeInfo2; - }() -); -var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; -var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; -var REQUIRED_VERSION_PARTS = 3; -var userAgentRules = [ - ["aol", /AOLShield\/([0-9\._]+)/], - ["edge", /Edge\/([0-9\._]+)/], - ["edge-ios", /EdgiOS\/([0-9\._]+)/], - ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], - ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], - ["samsung", /SamsungBrowser\/([0-9\.]+)/], - ["silk", /\bSilk\/([0-9._-]+)\b/], - ["miui", /MiuiBrowser\/([0-9\.]+)$/], - ["beaker", /BeakerBrowser\/([0-9\.]+)/], - ["edge-chromium", /EdgA?\/([0-9\.]+)/], - [ - "chromium-webview", - /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ - ], - ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], - ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], - ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], - ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], - ["fxios", /FxiOS\/([0-9\.]+)/], - ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], - ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], - ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], - ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], - ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], - ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], - ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], - ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], - ["ie", /MSIE\s(7\.0)/], - ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], - ["android", /Android\s([0-9\.]+)/], - ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], - ["safari", /Version\/([0-9\._]+).*Safari/], - ["facebook", /FB[AS]V\/([0-9\.]+)/], - ["instagram", /Instagram\s([0-9\.]+)/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], - ["curl", /^curl\/([0-9\.]+)$/], - ["searchbot", SEARCHBOX_UA_REGEX] -]; -var operatingSystemRules = [ - ["iOS", /iP(hone|od|ad)/], - ["Android OS", /Android/], - ["BlackBerry OS", /BlackBerry|BB10/], - ["Windows Mobile", /IEMobile/], - ["Amazon OS", /Kindle/], - ["Windows 3.11", /Win16/], - ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], - ["Windows 98", /(Windows 98)|(Win98)/], - ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], - ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], - ["Windows Server 2003", /(Windows NT 5.2)/], - ["Windows Vista", /(Windows NT 6.0)/], - ["Windows 7", /(Windows NT 6.1)/], - ["Windows 8", /(Windows NT 6.2)/], - ["Windows 8.1", /(Windows NT 6.3)/], - ["Windows 10", /(Windows NT 10.0)/], - ["Windows ME", /Windows ME/], - ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], - ["Open BSD", /OpenBSD/], - ["Sun OS", /SunOS/], - ["Chrome OS", /CrOS/], - ["Linux", /(Linux)|(X11)/], - ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], - ["QNX", /QNX/], - ["BeOS", /BeOS/], - ["OS/2", /OS\/2/] -]; -function detect(userAgent) { - if (!!userAgent) { - return parseUserAgent(userAgent); - } - if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { - return new ReactNativeInfo(); - } - if (typeof navigator !== "undefined") { - return parseUserAgent(navigator.userAgent); - } - return getNodeVersion(); -} -function matchUserAgent(ua) { - return ua !== "" && userAgentRules.reduce(function(matched, _a) { - var browser2 = _a[0], regex = _a[1]; - if (matched) { - return matched; - } - var uaMatch = regex.exec(ua); - return !!uaMatch && [browser2, uaMatch]; - }, false); -} -function parseUserAgent(ua) { - var matchedRule = matchUserAgent(ua); - if (!matchedRule) { - return null; - } - var name2 = matchedRule[0], match = matchedRule[1]; - if (name2 === "searchbot") { - return new BotInfo(); - } - var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); - if (versionParts) { - if (versionParts.length < REQUIRED_VERSION_PARTS) { - versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); - } - } else { - versionParts = []; - } - var version2 = versionParts.join("."); - var os2 = detectOS(ua); - var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua); - if (searchBotMatch && searchBotMatch[1]) { - return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); - } - return new BrowserInfo(name2, version2, os2); -} -function detectOS(ua) { - for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { - var _a = operatingSystemRules[ii], os2 = _a[0], regex = _a[1]; - var match = regex.exec(ua); - if (match) { - return os2; - } - } - return null; -} -function getNodeVersion() { - var isNode = typeof process !== "undefined" && process.version; - return isNode ? new NodeInfo(process.version.slice(1)) : null; -} -function createVersionParts(count) { - var output = []; - for (var ii = 0; ii < count; ii++) { - output.push("0"); - } - return output; -} -var cjs$2 = {}; -Object.defineProperty(cjs$2, "__esModule", { value: true }); -cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; -function getFromWindow(name2) { - let res = void 0; - if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { - res = window[name2]; - } - return res; -} -cjs$2.getFromWindow = getFromWindow; -function getFromWindowOrThrow(name2) { - const res = getFromWindow(name2); - if (!res) { - throw new Error(`${name2} is not defined in Window`); - } - return res; -} -cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; -function getDocumentOrThrow() { - return getFromWindowOrThrow("document"); -} -cjs$2.getDocumentOrThrow = getDocumentOrThrow; -function getDocument() { - return getFromWindow("document"); -} -var getDocument_1 = cjs$2.getDocument = getDocument; -function getNavigatorOrThrow() { - return getFromWindowOrThrow("navigator"); -} -cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; -function getNavigator() { - return getFromWindow("navigator"); -} -var getNavigator_1 = cjs$2.getNavigator = getNavigator; -function getLocationOrThrow() { - return getFromWindowOrThrow("location"); -} -cjs$2.getLocationOrThrow = getLocationOrThrow; -function getLocation() { - return getFromWindow("location"); -} -var getLocation_1 = cjs$2.getLocation = getLocation; -function getCryptoOrThrow() { - return getFromWindowOrThrow("crypto"); -} -cjs$2.getCryptoOrThrow = getCryptoOrThrow; -function getCrypto() { - return getFromWindow("crypto"); -} -cjs$2.getCrypto = getCrypto; -function getLocalStorageOrThrow() { - return getFromWindowOrThrow("localStorage"); -} -cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; -function getLocalStorage() { - return getFromWindow("localStorage"); -} -cjs$2.getLocalStorage = getLocalStorage; -var cjs$1 = {}; -Object.defineProperty(cjs$1, "__esModule", { value: true }); -var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; -const window_getters_1 = cjs$2; -function getWindowMetadata() { - let doc; - let loc; - try { - doc = window_getters_1.getDocumentOrThrow(); - loc = window_getters_1.getLocationOrThrow(); - } catch (e) { - return null; - } - function getIcons() { - const links = doc.getElementsByTagName("link"); - const icons2 = []; - for (let i2 = 0; i2 < links.length; i2++) { - const link = links[i2]; - const rel = link.getAttribute("rel"); - if (rel) { - if (rel.toLowerCase().indexOf("icon") > -1) { - const href = link.getAttribute("href"); - if (href) { - if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { - let absoluteHref = loc.protocol + "//" + loc.host; - if (href.indexOf("/") === 0) { - absoluteHref += href; - } else { - const path = loc.pathname.split("/"); - path.pop(); - const finalPath = path.join("/"); - absoluteHref += finalPath + "/" + href; - } - icons2.push(absoluteHref); - } else if (href.indexOf("//") === 0) { - const absoluteUrl = loc.protocol + href; - icons2.push(absoluteUrl); - } else { - icons2.push(href); - } - } - } - } - } - return icons2; - } - function getWindowMetadataOfAny(...args) { - const metaTags = doc.getElementsByTagName("meta"); - for (let i2 = 0; i2 < metaTags.length; i2++) { - const tag = metaTags[i2]; - const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { - if (attr) { - return args.includes(attr); - } - return false; - }); - if (attributes.length && attributes) { - const content = tag.getAttribute("content"); - if (content) { - return content; - } - } - } - return ""; - } - function getName() { - let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); - if (!name3) { - name3 = doc.title; - } - return name3; - } - function getDescription() { - const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); - return description3; - } - const name2 = getName(); - const description2 = getDescription(); - const url = loc.origin; - const icons = getIcons(); - const meta = { - description: description2, - url, - icons, - name: name2 - }; - return meta; -} -getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; -var queryString = {}; -var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); -var token = "%[a-f0-9]{2}"; -var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); -var multiMatcher = new RegExp("(" + token + ")+", "gi"); -function decodeComponents(components, split) { - try { - return [decodeURIComponent(components.join(""))]; - } catch (err) { - } - if (components.length === 1) { - return components; - } - split = split || 1; - var left = components.slice(0, split); - var right = components.slice(split); - return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); -} -function decode(input) { - try { - return decodeURIComponent(input); - } catch (err) { - var tokens = input.match(singleMatcher) || []; - for (var i2 = 1; i2 < tokens.length; i2++) { - input = decodeComponents(tokens, i2).join(""); - tokens = input.match(singleMatcher) || []; - } - return input; - } -} -function customDecodeURIComponent(input) { - var replaceMap = { - "%FE%FF": "��", - "%FF%FE": "��" - }; - var match = multiMatcher.exec(input); - while (match) { - try { - replaceMap[match[0]] = decodeURIComponent(match[0]); - } catch (err) { - var result = decode(match[0]); - if (result !== match[0]) { - replaceMap[match[0]] = result; - } - } - match = multiMatcher.exec(input); - } - replaceMap["%C2"] = "�"; - var entries = Object.keys(replaceMap); - for (var i2 = 0; i2 < entries.length; i2++) { - var key = entries[i2]; - input = input.replace(new RegExp(key, "g"), replaceMap[key]); - } - return input; -} -var decodeUriComponent = function(encodedURI) { - if (typeof encodedURI !== "string") { - throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); - } - try { - encodedURI = encodedURI.replace(/\+/g, " "); - return decodeURIComponent(encodedURI); - } catch (err) { - return customDecodeURIComponent(encodedURI); - } -}; -var splitOnFirst = (string2, separator) => { - if (!(typeof string2 === "string" && typeof separator === "string")) { - throw new TypeError("Expected the arguments to be of type `string`"); - } - if (separator === "") { - return [string2]; - } - const separatorIndex = string2.indexOf(separator); - if (separatorIndex === -1) { - return [string2]; - } - return [ - string2.slice(0, separatorIndex), - string2.slice(separatorIndex + separator.length) - ]; -}; -var filterObj = function(obj, predicate) { - var ret = {}; - var keys2 = Object.keys(obj); - var isArr = Array.isArray(predicate); - for (var i2 = 0; i2 < keys2.length; i2++) { - var key = keys2[i2]; - var val = obj[key]; - if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { - ret[key] = val; - } - } - return ret; -}; -(function(exports2) { - const strictUriEncode$1 = strictUriEncode; - const decodeComponent = decodeUriComponent; - const splitOnFirst$1 = splitOnFirst; - const filterObject = filterObj; - const isNullOrUndefined = (value) => value === null || value === void 0; - const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); - function encoderForArrayFormat(options) { - switch (options.arrayFormat) { - case "index": - return (key) => (result, value) => { - const index = result.length; - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[", index, "]"].join("")]; - } - return [ - ...result, - [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") - ]; - }; - case "bracket": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[]"].join("")]; - } - return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; - }; - case "colon-list-separator": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), ":list="].join("")]; - } - return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; - }; - case "comma": - case "separator": - case "bracket-separator": { - const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - value = value === null ? "" : value; - if (result.length === 0) { - return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; - } - return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; - }; - } - default: - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, encode2(key, options)]; - } - return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; - }; - } - } - function parserForArrayFormat(options) { - let result; - switch (options.arrayFormat) { - case "index": - return (key, value, accumulator) => { - result = /\[(\d*)\]$/.exec(key); - key = key.replace(/\[\d*\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = {}; - } - accumulator[key][result[1]] = value; - }; - case "bracket": - return (key, value, accumulator) => { - result = /(\[\])$/.exec(key); - key = key.replace(/\[\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "colon-list-separator": - return (key, value, accumulator) => { - result = /(:list)$/.exec(key); - key = key.replace(/:list$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "comma": - case "separator": - return (key, value, accumulator) => { - const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator); - const isEncodedArray = typeof value === "string" && !isArray && decode2(value, options).includes(options.arrayFormatSeparator); - value = isEncodedArray ? decode2(value, options) : value; - const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); - accumulator[key] = newValue; - }; - case "bracket-separator": - return (key, value, accumulator) => { - const isArray = /(\[\])$/.test(key); - key = key.replace(/\[\]$/, ""); - if (!isArray) { - accumulator[key] = value ? decode2(value, options) : value; - return; - } - const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); - if (accumulator[key] === void 0) { - accumulator[key] = arrayValue; - return; - } - accumulator[key] = [].concat(accumulator[key], arrayValue); - }; - default: - return (key, value, accumulator) => { - if (accumulator[key] === void 0) { - accumulator[key] = value; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - } - } - function validateArrayFormatSeparator(value) { - if (typeof value !== "string" || value.length !== 1) { - throw new TypeError("arrayFormatSeparator must be single character string"); - } - } - function encode2(value, options) { - if (options.encode) { - return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); - } - return value; - } - function decode2(value, options) { - if (options.decode) { - return decodeComponent(value); - } - return value; - } - function keysSorter(input) { - if (Array.isArray(input)) { - return input.sort(); - } - if (typeof input === "object") { - return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); - } - return input; - } - function removeHash(input) { - const hashStart = input.indexOf("#"); - if (hashStart !== -1) { - input = input.slice(0, hashStart); - } - return input; - } - function getHash(url) { - let hash2 = ""; - const hashStart = url.indexOf("#"); - if (hashStart !== -1) { - hash2 = url.slice(hashStart); - } - return hash2; - } - function extract(input) { - input = removeHash(input); - const queryStart = input.indexOf("?"); - if (queryStart === -1) { - return ""; - } - return input.slice(queryStart + 1); - } - function parseValue(value, options) { - if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { - value = Number(value); - } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { - value = value.toLowerCase() === "true"; - } - return value; - } - function parse(query, options) { - options = Object.assign({ - decode: true, - sort: true, - arrayFormat: "none", - arrayFormatSeparator: ",", - parseNumbers: false, - parseBooleans: false - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const formatter = parserForArrayFormat(options); - const ret = /* @__PURE__ */ Object.create(null); - if (typeof query !== "string") { - return ret; - } - query = query.trim().replace(/^[?#&]/, ""); - if (!query) { - return ret; - } - for (const param of query.split("&")) { - if (param === "") { - continue; - } - let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); - value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); - formatter(decode2(key, options), value, ret); - } - for (const key of Object.keys(ret)) { - const value = ret[key]; - if (typeof value === "object" && value !== null) { - for (const k2 of Object.keys(value)) { - value[k2] = parseValue(value[k2], options); - } - } else { - ret[key] = parseValue(value, options); - } - } - if (options.sort === false) { - return ret; - } - return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { - const value = ret[key]; - if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { - result[key] = keysSorter(value); - } else { - result[key] = value; - } - return result; - }, /* @__PURE__ */ Object.create(null)); - } - exports2.extract = extract; - exports2.parse = parse; - exports2.stringify = (object, options) => { - if (!object) { - return ""; - } - options = Object.assign({ - encode: true, - strict: true, - arrayFormat: "none", - arrayFormatSeparator: "," - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; - const formatter = encoderForArrayFormat(options); - const objectCopy = {}; - for (const key of Object.keys(object)) { - if (!shouldFilter(key)) { - objectCopy[key] = object[key]; - } - } - const keys2 = Object.keys(objectCopy); - if (options.sort !== false) { - keys2.sort(options.sort); - } - return keys2.map((key) => { - const value = object[key]; - if (value === void 0) { - return ""; - } - if (value === null) { - return encode2(key, options); - } - if (Array.isArray(value)) { - if (value.length === 0 && options.arrayFormat === "bracket-separator") { - return encode2(key, options) + "[]"; - } - return value.reduce(formatter(key), []).join("&"); - } - return encode2(key, options) + "=" + encode2(value, options); - }).filter((x2) => x2.length > 0).join("&"); - }; - exports2.parseUrl = (url, options) => { - options = Object.assign({ - decode: true - }, options); - const [url_, hash2] = splitOnFirst$1(url, "#"); - return Object.assign( - { - url: url_.split("?")[0] || "", - query: parse(extract(url), options) - }, - options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} - ); - }; - exports2.stringifyUrl = (object, options) => { - options = Object.assign({ - encode: true, - strict: true, - [encodeFragmentIdentifier]: true - }, options); - const url = removeHash(object.url).split("?")[0] || ""; - const queryFromUrl = exports2.extract(object.url); - const parsedQueryFromUrl = exports2.parse(queryFromUrl, { sort: false }); - const query = Object.assign(parsedQueryFromUrl, object.query); - let queryString2 = exports2.stringify(query, options); - if (queryString2) { - queryString2 = `?${queryString2}`; - } - let hash2 = getHash(object.url); - if (object.fragmentIdentifier) { - hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; - } - return `${url}${queryString2}${hash2}`; - }; - exports2.pick = (input, filter, options) => { - options = Object.assign({ - parseFragmentIdentifier: true, - [encodeFragmentIdentifier]: false - }, options); - const { url, query, fragmentIdentifier } = exports2.parseUrl(input, options); - return exports2.stringifyUrl({ - url, - query: filterObject(query, filter), - fragmentIdentifier - }, options); - }; - exports2.exclude = (input, filter, options) => { - const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); - return exports2.pick(input, exclusionFilter, options); - }; -})(queryString); -const RELAY_JSONRPC = { - waku: { - publish: "waku_publish", - batchPublish: "waku_batchPublish", - subscribe: "waku_subscribe", - batchSubscribe: "waku_batchSubscribe", - subscription: "waku_subscription", - unsubscribe: "waku_unsubscribe", - batchUnsubscribe: "waku_batchUnsubscribe" - }, - irn: { - publish: "irn_publish", - batchPublish: "irn_batchPublish", - subscribe: "irn_subscribe", - batchSubscribe: "irn_batchSubscribe", - subscription: "irn_subscription", - unsubscribe: "irn_unsubscribe", - batchUnsubscribe: "irn_batchUnsubscribe" - }, - iridium: { - publish: "iridium_publish", - batchPublish: "iridium_batchPublish", - subscribe: "iridium_subscribe", - batchSubscribe: "iridium_batchSubscribe", - subscription: "iridium_subscription", - unsubscribe: "iridium_unsubscribe", - batchUnsubscribe: "iridium_batchUnsubscribe" - } -}; -function L$1(e, n3) { - return e.includes(":") ? [e] : n3.chains || []; -} -const J$1 = "base10", p$1 = "base16", F$2 = "base64pad", H$1 = "utf8", Q$2 = 0, _$1 = 1, Dn = 0, Te = 1, Z$1 = 12, X$1 = 32; -function kn() { - const e = x25519.generateKeyPair(); - return { privateKey: toString(e.secretKey, p$1), publicKey: toString(e.publicKey, p$1) }; -} -function Vn() { - const e = random.randomBytes(X$1); - return toString(e, p$1); -} -function Mn(e, n3) { - const t2 = x25519.sharedKey(fromString(e, p$1), fromString(n3, p$1), true), r2 = new HKDF_1(sha256.SHA256, t2).expand(X$1); - return toString(r2, p$1); -} -function Kn(e) { - const n3 = sha256.hash(fromString(e, p$1)); - return toString(n3, p$1); -} -function Ln(e) { - const n3 = sha256.hash(fromString(e, H$1)); - return toString(n3, p$1); -} -function Pe(e) { - return fromString(`${e}`, J$1); -} -function j$1(e) { - return Number(toString(e, J$1)); -} -function xn(e) { - const n3 = Pe(typeof e.type < "u" ? e.type : Q$2); - if (j$1(n3) === _$1 && typeof e.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - const t2 = typeof e.senderPublicKey < "u" ? fromString(e.senderPublicKey, p$1) : void 0, r2 = typeof e.iv < "u" ? fromString(e.iv, p$1) : random.randomBytes(Z$1), o2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e.symKey, p$1)).seal(r2, fromString(e.message, H$1)); - return Re({ type: n3, sealed: o2, iv: r2, senderPublicKey: t2 }); -} -function Fn(e) { - const n3 = new chacha20poly1305.ChaCha20Poly1305(fromString(e.symKey, p$1)), { sealed: t2, iv: r2 } = ee$1(e.encoded), o2 = n3.open(r2, t2); - if (o2 === null) - throw new Error("Failed to decrypt"); - return toString(o2, H$1); -} -function Re(e) { - if (j$1(e.type) === _$1) { - if (typeof e.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - return toString(concat([e.type, e.senderPublicKey, e.iv, e.sealed]), F$2); - } - return toString(concat([e.type, e.iv, e.sealed]), F$2); -} -function ee$1(e) { - const n3 = fromString(e, F$2), t2 = n3.slice(Dn, Te), r2 = Te; - if (j$1(t2) === _$1) { - const d3 = r2 + X$1, l2 = d3 + Z$1, c2 = n3.slice(r2, d3), u3 = n3.slice(d3, l2), a3 = n3.slice(l2); - return { type: t2, sealed: a3, iv: u3, senderPublicKey: c2 }; - } - const o2 = r2 + Z$1, s2 = n3.slice(r2, o2), i2 = n3.slice(o2); - return { type: t2, sealed: i2, iv: s2 }; -} -function Hn(e, n3) { - const t2 = ee$1(e); - return Ae({ type: j$1(t2.type), senderPublicKey: typeof t2.senderPublicKey < "u" ? toString(t2.senderPublicKey, p$1) : void 0, receiverPublicKey: n3 == null ? void 0 : n3.receiverPublicKey }); -} -function Ae(e) { - const n3 = (e == null ? void 0 : e.type) || Q$2; - if (n3 === _$1) { - if (typeof (e == null ? void 0 : e.senderPublicKey) > "u") - throw new Error("missing sender public key"); - if (typeof (e == null ? void 0 : e.receiverPublicKey) > "u") - throw new Error("missing receiver public key"); - } - return { type: n3, senderPublicKey: e == null ? void 0 : e.senderPublicKey, receiverPublicKey: e == null ? void 0 : e.receiverPublicKey }; -} -function qn(e) { - return e.type === _$1 && typeof e.senderPublicKey == "string" && typeof e.receiverPublicKey == "string"; -} -var Bn = Object.defineProperty, Ue$1 = Object.getOwnPropertySymbols, Gn = Object.prototype.hasOwnProperty, Wn = Object.prototype.propertyIsEnumerable, _e = (e, n3, t2) => n3 in e ? Bn(e, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[n3] = t2, $e$1 = (e, n3) => { - for (var t2 in n3 || (n3 = {})) - Gn.call(n3, t2) && _e(e, t2, n3[t2]); - if (Ue$1) - for (var t2 of Ue$1(n3)) - Wn.call(n3, t2) && _e(e, t2, n3[t2]); - return e; -}; -const Ce = "ReactNative", m$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, De$1 = "js"; -function te$1() { - return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; -} -function $$1() { - return !getDocument_1() && !!getNavigator_1() && navigator.product === Ce; -} -function D$2() { - return !te$1() && !!getNavigator_1() && !!getDocument_1(); -} -function R$2() { - return $$1() ? m$1.reactNative : te$1() ? m$1.node : D$2() ? m$1.browser : m$1.unknown; -} -function Jn() { - var e; - try { - return $$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e = global.Application) == null ? void 0 : e.applicationId : void 0; - } catch { - return; - } -} -function ke$1(e, n3) { - let t2 = queryString.parse(e); - return t2 = $e$1($e$1({}, t2), n3), e = queryString.stringify(t2), e; -} -function Qn() { - return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; -} -function Ve$1() { - if (R$2() === m$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { - const { OS: t2, Version: r2 } = global.Platform; - return [t2, r2].join("-"); - } - const e = detect(); - if (e === null) - return "unknown"; - const n3 = e.os ? e.os.replace(" ", "").toLowerCase() : "unknown"; - return e.type === "browser" ? [n3, e.name, e.version].join("-") : [n3, e.version].join("-"); -} -function Me$1() { - var e; - const n3 = R$2(); - return n3 === m$1.browser ? [n3, ((e = getLocation_1()) == null ? void 0 : e.host) || "unknown"].join(":") : n3; -} -function Ke$1(e, n3, t2) { - const r2 = Ve$1(), o2 = Me$1(); - return [[e, n3].join("-"), [De$1, t2].join("-"), r2, o2].join("/"); -} -function Xn({ protocol: e, version: n3, relayUrl: t2, sdkVersion: r2, auth: o2, projectId: s2, useOnCloseEvent: i2, bundleId: d3 }) { - const l2 = t2.split("?"), c2 = Ke$1(e, n3, r2), u3 = { auth: o2, ua: c2, projectId: s2, useOnCloseEvent: i2 || void 0, origin: d3 || void 0 }, a3 = ke$1(l2[1] || "", u3); - return l2[0] + "?" + a3; -} -function O$1(e, n3) { - return e.filter((t2) => n3.includes(t2)).length === e.length; -} -function rt$1(e) { - return Object.fromEntries(e.entries()); -} -function ot$1(e) { - return new Map(Object.entries(e)); -} -function at$1(e = cjs$4.FIVE_MINUTES, n3) { - const t2 = cjs$4.toMiliseconds(e || cjs$4.FIVE_MINUTES); - let r2, o2, s2; - return { resolve: (i2) => { - s2 && r2 && (clearTimeout(s2), r2(i2)); - }, reject: (i2) => { - s2 && o2 && (clearTimeout(s2), o2(i2)); - }, done: () => new Promise((i2, d3) => { - s2 = setTimeout(() => { - d3(new Error(n3)); - }, t2), r2 = i2, o2 = d3; - }) }; -} -function ut$1(e, n3, t2) { - return new Promise(async (r2, o2) => { - const s2 = setTimeout(() => o2(new Error(t2)), n3); - try { - const i2 = await e; - r2(i2); - } catch (i2) { - o2(i2); - } - clearTimeout(s2); - }); -} -function re(e, n3) { - if (typeof n3 == "string" && n3.startsWith(`${e}:`)) - return n3; - if (e.toLowerCase() === "topic") { - if (typeof n3 != "string") - throw new Error('Value must be "string" for expirer target type: topic'); - return `topic:${n3}`; - } else if (e.toLowerCase() === "id") { - if (typeof n3 != "number") - throw new Error('Value must be "number" for expirer target type: id'); - return `id:${n3}`; - } - throw new Error(`Unknown expirer target type: ${e}`); -} -function lt$1(e) { - return re("topic", e); -} -function dt$1(e) { - return re("id", e); -} -function ft$1(e) { - const [n3, t2] = e.split(":"), r2 = { id: void 0, topic: void 0 }; - if (n3 === "topic" && typeof t2 == "string") - r2.topic = t2; - else if (n3 === "id" && Number.isInteger(Number(t2))) - r2.id = Number(t2); - else - throw new Error(`Invalid target, expected id:number or topic:string, got ${n3}:${t2}`); - return r2; -} -function pt$1(e, n3) { - return cjs$4.fromMiliseconds((n3 || Date.now()) + cjs$4.toMiliseconds(e)); -} -function mt$1(e) { - return Date.now() >= cjs$4.toMiliseconds(e); -} -function yt$1(e, n3) { - return `${e}${n3 ? `:${n3}` : ""}`; -} -async function gt$1({ id: e, topic: n3, wcDeepLink: t2 }) { - try { - if (!t2) - return; - const r2 = typeof t2 == "string" ? JSON.parse(t2) : t2; - let o2 = r2 == null ? void 0 : r2.href; - if (typeof o2 != "string") - return; - o2.endsWith("/") && (o2 = o2.slice(0, -1)); - const s2 = `${o2}/wc?requestId=${e}&sessionTopic=${n3}`, i2 = R$2(); - i2 === m$1.browser ? s2.startsWith("https://") ? window.open(s2, "_blank", "noreferrer noopener") : window.open(s2, "_self", "noreferrer noopener") : i2 === m$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(s2); - } catch (r2) { - console.error(r2); - } -} -async function ht$1(e, n3) { - try { - return await e.getItem(n3) || (D$2() ? localStorage.getItem(n3) : void 0); - } catch (t2) { - console.error(t2); - } -} -const He$1 = "irn"; -function vt$1(e) { - return (e == null ? void 0 : e.relay) || { protocol: He$1 }; -} -function Et$1(e) { - const n3 = RELAY_JSONRPC[e]; - if (typeof n3 > "u") - throw new Error(`Relay Protocol not supported: ${e}`); - return n3; -} -var bt$1 = Object.defineProperty, Nt$1 = Object.defineProperties, Ot$1 = Object.getOwnPropertyDescriptors, qe$1 = Object.getOwnPropertySymbols, St$1 = Object.prototype.hasOwnProperty, wt$1 = Object.prototype.propertyIsEnumerable, Be$1 = (e, n3, t2) => n3 in e ? bt$1(e, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[n3] = t2, It$1 = (e, n3) => { - for (var t2 in n3 || (n3 = {})) - St$1.call(n3, t2) && Be$1(e, t2, n3[t2]); - if (qe$1) - for (var t2 of qe$1(n3)) - wt$1.call(n3, t2) && Be$1(e, t2, n3[t2]); - return e; -}, Tt$1 = (e, n3) => Nt$1(e, Ot$1(n3)); -function Ge$1(e, n3 = "-") { - const t2 = {}, r2 = "relay" + n3; - return Object.keys(e).forEach((o2) => { - if (o2.startsWith(r2)) { - const s2 = o2.replace(r2, ""), i2 = e[o2]; - t2[s2] = i2; - } - }), t2; -} -function Pt$1(e) { - e = e.includes("wc://") ? e.replace("wc://", "") : e, e = e.includes("wc:") ? e.replace("wc:", "") : e; - const n3 = e.indexOf(":"), t2 = e.indexOf("?") !== -1 ? e.indexOf("?") : void 0, r2 = e.substring(0, n3), o2 = e.substring(n3 + 1, t2).split("@"), s2 = typeof t2 < "u" ? e.substring(t2) : "", i2 = queryString.parse(s2); - return { protocol: r2, topic: We$1(o2[0]), version: parseInt(o2[1], 10), symKey: i2.symKey, relay: Ge$1(i2), expiryTimestamp: i2.expiryTimestamp ? parseInt(i2.expiryTimestamp, 10) : void 0 }; -} -function We$1(e) { - return e.startsWith("//") ? e.substring(2) : e; -} -function ze(e, n3 = "-") { - const t2 = "relay", r2 = {}; - return Object.keys(e).forEach((o2) => { - const s2 = t2 + n3 + o2; - e[o2] && (r2[s2] = e[o2]); - }), r2; -} -function Rt$1(e) { - return `${e.protocol}:${e.topic}@${e.version}?` + queryString.stringify(Tt$1(It$1({ symKey: e.symKey }, ze(e.relay)), { expiryTimestamp: e.expiryTimestamp })); -} -function A$1(e) { - const n3 = []; - return e.forEach((t2) => { - const [r2, o2] = t2.split(":"); - n3.push(`${r2}:${o2}`); - }), n3; -} -function Qe$1(e) { - const n3 = []; - return Object.values(e).forEach((t2) => { - n3.push(...A$1(t2.accounts)); - }), n3; -} -function Ze$1(e, n3) { - const t2 = []; - return Object.values(e).forEach((r2) => { - A$1(r2.accounts).includes(n3) && t2.push(...r2.methods); - }), t2; -} -function Xe$1(e, n3) { - const t2 = []; - return Object.values(e).forEach((r2) => { - A$1(r2.accounts).includes(n3) && t2.push(...r2.events); - }), t2; -} -const nn = { 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 } }, tn = { 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 N$1(e, n3) { - const { message: t2, code: r2 } = tn[e]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; -} -function U$2(e, n3) { - const { message: t2, code: r2 } = nn[e]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; -} -function k(e, n3) { - return Array.isArray(e) ? typeof n3 < "u" && e.length ? e.every(n3) : true : false; -} -function B$1(e) { - return Object.getPrototypeOf(e) === Object.prototype && Object.keys(e).length; -} -function w$3(e) { - return typeof e > "u"; -} -function g$3(e, n3) { - return n3 && w$3(e) ? true : typeof e == "string" && !!e.trim().length; -} -function G$1(e, n3) { - return n3 && w$3(e) ? true : typeof e == "number" && !isNaN(e); -} -function Mt$1(e, n3) { - const { requiredNamespaces: t2 } = n3, r2 = Object.keys(e.namespaces), o2 = Object.keys(t2); - let s2 = true; - return O$1(o2, r2) ? (r2.forEach((i2) => { - const { accounts: d3, methods: l2, events: c2 } = e.namespaces[i2], u3 = A$1(d3), a3 = t2[i2]; - (!O$1(L$1(i2, a3), u3) || !O$1(a3.methods, l2) || !O$1(a3.events, c2)) && (s2 = false); - }), s2) : false; -} -function V$1(e) { - return g$3(e, false) && e.includes(":") ? e.split(":").length === 2 : false; -} -function rn(e) { - if (g$3(e, false) && e.includes(":")) { - const n3 = e.split(":"); - if (n3.length === 3) { - const t2 = n3[0] + ":" + n3[1]; - return !!n3[2] && V$1(t2); - } - } - return false; -} -function Kt$1(e) { - if (g$3(e, false)) - try { - return typeof new URL(e) < "u"; - } catch { - return false; - } - return false; -} -function Lt$1(e) { - var n3; - return (n3 = e == null ? void 0 : e.proposer) == null ? void 0 : n3.publicKey; -} -function xt$1(e) { - return e == null ? void 0 : e.topic; -} -function Ft$1(e, n3) { - let t2 = null; - return g$3(e == null ? void 0 : e.publicKey, false) || (t2 = N$1("MISSING_OR_INVALID", `${n3} controller public key should be a string`)), t2; -} -function ie(e) { - let n3 = true; - return k(e) ? e.length && (n3 = e.every((t2) => g$3(t2, false))) : n3 = false, n3; -} -function on(e, n3, t2) { - let r2 = null; - return k(n3) && n3.length ? n3.forEach((o2) => { - r2 || V$1(o2) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, chain ${o2} should be a string and conform to "namespace:chainId" format`)); - }) : V$1(e) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, 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"] }`)), r2; -} -function sn(e, n3, t2) { - let r2 = null; - return Object.entries(e).forEach(([o2, s2]) => { - if (r2) - return; - const i2 = on(o2, L$1(o2, s2), `${n3} ${t2}`); - i2 && (r2 = i2); - }), r2; -} -function cn(e, n3) { - let t2 = null; - return k(e) ? e.forEach((r2) => { - t2 || rn(r2) || (t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, account ${r2} should be a string and conform to "namespace:chainId:address" format`)); - }) : t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), t2; -} -function an(e, n3) { - let t2 = null; - return Object.values(e).forEach((r2) => { - if (t2) - return; - const o2 = cn(r2 == null ? void 0 : r2.accounts, `${n3} namespace`); - o2 && (t2 = o2); - }), t2; -} -function un(e, n3) { - let t2 = null; - return ie(e == null ? void 0 : e.methods) ? ie(e == null ? void 0 : e.events) || (t2 = U$2("UNSUPPORTED_EVENTS", `${n3}, events should be an array of strings or empty array for no events`)) : t2 = U$2("UNSUPPORTED_METHODS", `${n3}, methods should be an array of strings or empty array for no methods`), t2; -} -function ce$2(e, n3) { - let t2 = null; - return Object.values(e).forEach((r2) => { - if (t2) - return; - const o2 = un(r2, `${n3}, namespace`); - o2 && (t2 = o2); - }), t2; -} -function Ht$1(e, n3, t2) { - let r2 = null; - if (e && B$1(e)) { - const o2 = ce$2(e, n3); - o2 && (r2 = o2); - const s2 = sn(e, n3, t2); - s2 && (r2 = s2); - } else - r2 = N$1("MISSING_OR_INVALID", `${n3}, ${t2} should be an object with data`); - return r2; -} -function ln(e, n3) { - let t2 = null; - if (e && B$1(e)) { - const r2 = ce$2(e, n3); - r2 && (t2 = r2); - const o2 = an(e, n3); - o2 && (t2 = o2); - } else - t2 = N$1("MISSING_OR_INVALID", `${n3}, namespaces should be an object with data`); - return t2; -} -function dn(e) { - return g$3(e.protocol, true); -} -function qt$1(e, n3) { - let t2 = false; - return n3 && !e ? t2 = true : e && k(e) && e.length && e.forEach((r2) => { - t2 = dn(r2); - }), t2; -} -function Bt$1(e) { - return typeof e == "number"; -} -function Gt$1(e) { - return typeof e < "u" && typeof e !== null; -} -function Wt(e) { - return !(!e || typeof e != "object" || !e.code || !G$1(e.code, false) || !e.message || !g$3(e.message, false)); -} -function zt$1(e) { - return !(w$3(e) || !g$3(e.method, false)); -} -function Yt$1(e) { - return !(w$3(e) || w$3(e.result) && w$3(e.error) || !G$1(e.id, false) || !g$3(e.jsonrpc, false)); -} -function Jt$1(e) { - return !(w$3(e) || !g$3(e.name, false)); -} -function Qt(e, n3) { - return !(!V$1(n3) || !Qe$1(e).includes(n3)); -} -function Zt(e, n3, t2) { - return g$3(t2, false) ? Ze$1(e, n3).includes(t2) : false; -} -function Xt(e, n3, t2) { - return g$3(t2, false) ? Xe$1(e, n3).includes(t2) : false; -} -function fn(e, n3, t2) { - let r2 = null; - const o2 = er$1(e), s2 = nr$1(n3), i2 = Object.keys(o2), d3 = Object.keys(s2), l2 = pn(Object.keys(e)), c2 = pn(Object.keys(n3)), u3 = l2.filter((a3) => !c2.includes(a3)); - return u3.length && (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces keys don't satisfy requiredNamespaces. - Required: ${u3.toString()} - Received: ${Object.keys(n3).toString()}`)), O$1(i2, d3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces chains don't satisfy required namespaces. - Required: ${i2.toString()} - Approved: ${d3.toString()}`)), Object.keys(n3).forEach((a3) => { - if (!a3.includes(":") || r2) - return; - const b3 = A$1(n3[a3].accounts); - b3.includes(a3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces accounts don't satisfy namespace accounts for ${a3} - Required: ${a3} - Approved: ${b3.toString()}`)); - }), i2.forEach((a3) => { - r2 || (O$1(o2[a3].methods, s2[a3].methods) ? O$1(o2[a3].events, s2[a3].events) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces events don't satisfy namespace events for ${a3}`)) : r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces methods don't satisfy namespace methods for ${a3}`)); - }), r2; -} -function er$1(e) { - const n3 = {}; - return Object.keys(e).forEach((t2) => { - var r2; - t2.includes(":") ? n3[t2] = e[t2] : (r2 = e[t2].chains) == null || r2.forEach((o2) => { - n3[o2] = { methods: e[t2].methods, events: e[t2].events }; - }); - }), n3; -} -function pn(e) { - return [...new Set(e.map((n3) => n3.includes(":") ? n3.split(":")[0] : n3))]; -} -function nr$1(e) { - const n3 = {}; - return Object.keys(e).forEach((t2) => { - if (t2.includes(":")) - n3[t2] = e[t2]; - else { - const r2 = A$1(e[t2].accounts); - r2 == null ? void 0 : r2.forEach((o2) => { - n3[o2] = { accounts: e[t2].accounts.filter((s2) => s2.includes(`${o2}:`)), methods: e[t2].methods, events: e[t2].events }; - }); - } - }), n3; -} -function tr$1(e, n3) { - return G$1(e, false) && e <= n3.max && e >= n3.min; -} -function rr$1() { - const e = R$2(); - return new Promise((n3) => { - switch (e) { - case m$1.browser: - n3(mn()); - break; - case m$1.reactNative: - n3(yn()); - break; - case m$1.node: - n3(gn()); - break; - default: - n3(true); - } - }); -} -function mn() { - return D$2() && (navigator == null ? void 0 : navigator.onLine); -} -async function yn() { - if ($$1() && typeof global < "u" && global != null && global.NetInfo) { - const e = await (global == null ? void 0 : global.NetInfo.fetch()); - return e == null ? void 0 : e.isConnected; - } - return true; -} -function gn() { - return true; -} -function or$1(e) { - switch (R$2()) { - case m$1.browser: - hn(e); - break; - case m$1.reactNative: - vn(e); - break; - } -} -function hn(e) { - !$$1() && D$2() && (window.addEventListener("online", () => e(true)), window.addEventListener("offline", () => e(false))); -} -function vn(e) { - $$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((n3) => e(n3 == null ? void 0 : n3.isConnected))); -} -const ae$1 = {}; -let sr$1 = class sr { - static get(n3) { - return ae$1[n3]; - } - static set(n3, t2) { - ae$1[n3] = t2; - } - static delete(n3) { - delete ae$1[n3]; - } -}; -const PARSE_ERROR = "PARSE_ERROR"; -const INVALID_REQUEST = "INVALID_REQUEST"; -const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; -const INVALID_PARAMS = "INVALID_PARAMS"; -const INTERNAL_ERROR = "INTERNAL_ERROR"; -const SERVER_ERROR = "SERVER_ERROR"; -const RESERVED_ERROR_CODES = [-32700, -32600, -32601, -32602, -32603]; -const STANDARD_ERROR_MAP = { - [PARSE_ERROR]: { code: -32700, message: "Parse error" }, - [INVALID_REQUEST]: { code: -32600, message: "Invalid Request" }, - [METHOD_NOT_FOUND]: { code: -32601, message: "Method not found" }, - [INVALID_PARAMS]: { code: -32602, message: "Invalid params" }, - [INTERNAL_ERROR]: { code: -32603, message: "Internal error" }, - [SERVER_ERROR]: { code: -32e3, message: "Server error" } -}; -const DEFAULT_ERROR = SERVER_ERROR; -function isReservedErrorCode(code) { - return RESERVED_ERROR_CODES.includes(code); -} -function getError(type2) { - if (!Object.keys(STANDARD_ERROR_MAP).includes(type2)) { - return STANDARD_ERROR_MAP[DEFAULT_ERROR]; - } - return STANDARD_ERROR_MAP[type2]; -} -function getErrorByCode(code) { - const match = Object.values(STANDARD_ERROR_MAP).find((e) => e.code === code); - if (!match) { - return STANDARD_ERROR_MAP[DEFAULT_ERROR]; - } - return match; -} -function parseConnectionError(e, url, type2) { - return e.message.includes("getaddrinfo ENOTFOUND") || e.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${type2} RPC url at ${url}`) : e; -} -var cjs = {}; -var crypto$1 = {}; -var hasRequiredCrypto; -function requireCrypto() { - if (hasRequiredCrypto) - return crypto$1; - hasRequiredCrypto = 1; - Object.defineProperty(crypto$1, "__esModule", { value: true }); - crypto$1.isBrowserCryptoAvailable = crypto$1.getSubtleCrypto = crypto$1.getBrowerCrypto = void 0; - function getBrowerCrypto() { - return (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.crypto) || (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.msCrypto) || {}; - } - crypto$1.getBrowerCrypto = getBrowerCrypto; - function getSubtleCrypto() { - const browserCrypto = getBrowerCrypto(); - return browserCrypto.subtle || browserCrypto.webkitSubtle; - } - crypto$1.getSubtleCrypto = getSubtleCrypto; - function isBrowserCryptoAvailable() { - return !!getBrowerCrypto() && !!getSubtleCrypto(); - } - crypto$1.isBrowserCryptoAvailable = isBrowserCryptoAvailable; - return crypto$1; -} -var env = {}; -var hasRequiredEnv; -function requireEnv() { - if (hasRequiredEnv) - return env; - hasRequiredEnv = 1; - Object.defineProperty(env, "__esModule", { value: true }); - env.isBrowser = env.isNode = env.isReactNative = void 0; - function isReactNative() { - return typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative"; - } - env.isReactNative = isReactNative; - function isNode() { - return typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined"; - } - env.isNode = isNode; - function isBrowser() { - return !isReactNative() && !isNode(); - } - env.isBrowser = isBrowser; - return env; -} -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireCrypto(), exports2); - tslib_1.__exportStar(requireEnv(), exports2); -})(cjs); -function payloadId(entropy = 3) { - const date = Date.now() * Math.pow(10, entropy); - const extra = Math.floor(Math.random() * Math.pow(10, entropy)); - return date + extra; -} -function getBigIntRpcId(entropy = 6) { - return BigInt(payloadId(entropy)); -} -function formatJsonRpcRequest(method, params, id) { - return { - id: id || payloadId(), - jsonrpc: "2.0", - method, - params - }; -} -function formatJsonRpcResult(id, result) { - return { - id, - jsonrpc: "2.0", - result - }; -} -function formatJsonRpcError(id, error, data) { - return { - id, - jsonrpc: "2.0", - error: formatErrorMessage(error, data) - }; -} -function formatErrorMessage(error, data) { - if (typeof error === "undefined") { - return getError(INTERNAL_ERROR); - } - if (typeof error === "string") { - error = Object.assign(Object.assign({}, getError(SERVER_ERROR)), { message: error }); - } - if (typeof data !== "undefined") { - error.data = data; - } - if (isReservedErrorCode(error.code)) { - error = getErrorByCode(error.code); - } - return error; -} -class IEvents2 { -} -class IBaseJsonRpcProvider extends IEvents2 { - constructor() { - super(); - } -} -class IJsonRpcProvider extends IBaseJsonRpcProvider { - constructor(connection) { - super(); - } -} -const WS_REGEX = "^wss?:"; -function getUrlProtocol(url) { - const matches = url.match(new RegExp(/^\w+:/, "gi")); - if (!matches || !matches.length) - return; - return matches[0]; -} -function matchRegexProtocol(url, regex) { - const protocol = getUrlProtocol(url); - if (typeof protocol === "undefined") - return false; - return new RegExp(regex).test(protocol); -} -function isWsUrl(url) { - return matchRegexProtocol(url, WS_REGEX); -} -function isLocalhostUrl(url) { - return new RegExp("wss?://localhost(:d{2,5})?").test(url); -} -function isJsonRpcPayload(payload) { - return typeof payload === "object" && "id" in payload && "jsonrpc" in payload && payload.jsonrpc === "2.0"; -} -function isJsonRpcRequest(payload) { - return isJsonRpcPayload(payload) && "method" in payload; -} -function isJsonRpcResponse(payload) { - return isJsonRpcPayload(payload) && (isJsonRpcResult(payload) || isJsonRpcError(payload)); -} -function isJsonRpcResult(payload) { - return "result" in payload; -} -function isJsonRpcError(payload) { - return "error" in payload; -} -class JsonRpcProvider extends IJsonRpcProvider { - constructor(connection) { - super(connection); - this.events = new eventsExports.EventEmitter(); - this.hasRegisteredEventListeners = false; - this.connection = this.setConnection(connection); - if (this.connection.connected) { - this.registerEventListeners(); - } - } - async connect(connection = this.connection) { - await this.open(connection); - } - async disconnect() { - await this.close(); - } - on(event, listener) { - this.events.on(event, listener); - } - once(event, listener) { - this.events.once(event, listener); - } - off(event, listener) { - this.events.off(event, listener); - } - removeListener(event, listener) { - this.events.removeListener(event, listener); - } - async request(request, context) { - return this.requestStrict(formatJsonRpcRequest(request.method, request.params || [], request.id || getBigIntRpcId().toString()), context); - } - async requestStrict(request, context) { - return new Promise(async (resolve, reject) => { - if (!this.connection.connected) { - try { - await this.open(); - } catch (e) { - reject(e); - } - } - this.events.on(`${request.id}`, (response) => { - if (isJsonRpcError(response)) { - reject(response.error); - } else { - resolve(response.result); - } - }); - try { - await this.connection.send(request, context); - } catch (e) { - reject(e); - } - }); - } - setConnection(connection = this.connection) { - return connection; - } - onPayload(payload) { - this.events.emit("payload", payload); - if (isJsonRpcResponse(payload)) { - this.events.emit(`${payload.id}`, payload); - } else { - this.events.emit("message", { - type: payload.method, - data: payload.params - }); - } - } - onClose(event) { - if (event && event.code === 3e3) { - this.events.emit("error", new Error(`WebSocket connection closed abnormally with code: ${event.code} ${event.reason ? `(${event.reason})` : ""}`)); - } - this.events.emit("disconnect"); - } - async open(connection = this.connection) { - if (this.connection === connection && this.connection.connected) - return; - if (this.connection.connected) - this.close(); - if (typeof connection === "string") { - await this.connection.open(connection); - connection = this.connection; - } - this.connection = this.setConnection(connection); - await this.connection.open(); - this.registerEventListeners(); - this.events.emit("connect"); - } - async close() { - await this.connection.close(); - } - registerEventListeners() { - if (this.hasRegisteredEventListeners) - return; - this.connection.on("payload", (payload) => this.onPayload(payload)); - this.connection.on("close", (event) => this.onClose(event)); - this.connection.on("error", (error) => this.events.emit("error", error)); - this.connection.on("register_error", (error) => this.onClose()); - this.hasRegisteredEventListeners = true; - } -} -const w$2 = () => 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 : (() => {try { return require("ws") } catch (e) { } })(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a$1 = (c2) => c2.split("?")[0], h$1 = 10, S$1 = w$2(); -class f { - constructor(e) { - if (this.url = e, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(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, t2) { - this.events.on(e, t2); - } - once(e, t2) { - this.events.once(e, t2); - } - off(e, t2) { - this.events.off(e, t2); - } - removeListener(e, t2) { - this.events.removeListener(e, t2); - } - async open(e = this.url) { - await this.register(e); - } - async close() { - return new Promise((e, t2) => { - if (typeof this.socket > "u") { - t2(new Error("Connection already closed")); - return; - } - this.socket.onclose = (n3) => { - this.onClose(n3), e(); - }, this.socket.close(); - }); - } - async send(e) { - typeof this.socket > "u" && (this.socket = await this.register()); - try { - this.socket.send(safeJsonStringify(e)); - } catch (t2) { - this.onError(e.id, t2); - } - } - register(e = this.url) { - if (!isWsUrl(e)) - throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`); - if (this.registering) { - const t2 = this.events.getMaxListeners(); - return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n3, o2) => { - this.events.once("register_error", (s2) => { - this.resetMaxListeners(), o2(s2); - }), this.events.once("open", () => { - if (this.resetMaxListeners(), typeof this.socket > "u") - return o2(new Error("WebSocket connection is missing or invalid")); - n3(this.socket); - }); - }); - } - return this.url = e, this.registering = true, new Promise((t2, n3) => { - const o2 = new URLSearchParams(e).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e) }, i2 = new S$1(e, [], s2); - b2() ? i2.onerror = (r2) => { - const l2 = r2; - n3(this.emitError(l2.error)); - } : i2.on("error", (r2) => { - n3(this.emitError(r2)); - }), i2.onopen = () => { - this.onOpen(i2), t2(i2); - }; - }); - } - onOpen(e) { - e.onmessage = (t2) => this.onPayload(t2), e.onclose = (t2) => this.onClose(t2), this.socket = e, this.registering = false, this.events.emit("open"); - } - onClose(e) { - this.socket = void 0, this.registering = false, this.events.emit("close", e); - } - onPayload(e) { - if (typeof e.data > "u") - return; - const t2 = typeof e.data == "string" ? safeJsonParse(e.data) : e.data; - this.events.emit("payload", t2); - } - onError(e, t2) { - const n3 = this.parseError(t2), o2 = n3.message || n3.toString(), s2 = formatJsonRpcError(e, o2); - this.events.emit("payload", s2); - } - parseError(e, t2 = this.url) { - return parseConnectionError(e, a$1(t2), "WS"); - } - resetMaxListeners() { - this.events.getMaxListeners() > h$1 && this.events.setMaxListeners(h$1); - } - emitError(e) { - const t2 = this.parseError(new Error((e == null ? void 0 : e.message) || `WebSocket connection failed for host: ${a$1(this.url)}`)); - return this.events.emit("register_error", t2), t2; - } -} -var lodash_isequal = { exports: {} }; -lodash_isequal.exports; -(function(module2, exports2) { - var LARGE_ARRAY_SIZE = 200; - var HASH_UNDEFINED = "__lodash_hash_undefined__"; - var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; - var MAX_SAFE_INTEGER = 9007199254740991; - var argsTag = "[object Arguments]", arrayTag = "[object Array]", asyncTag = "[object AsyncFunction]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", nullTag = "[object Null]", objectTag = "[object Object]", promiseTag = "[object Promise]", proxyTag = "[object Proxy]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", undefinedTag = "[object Undefined]", weakMapTag = "[object WeakMap]"; - var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]"; - var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - var reIsHostCtor = /^\[object .+?Constructor\]$/; - var reIsUint = /^(?:0|[1-9]\d*)$/; - var typedArrayTags = {}; - typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; - typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; - var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; - var freeSelf = typeof self == "object" && self && self.Object === Object && self; - var root = freeGlobal || freeSelf || Function("return this")(); - var freeExports = exports2 && !exports2.nodeType && exports2; - var freeModule = freeExports && true && module2 && !module2.nodeType && module2; - var moduleExports = freeModule && freeModule.exports === freeExports; - var freeProcess = moduleExports && freeGlobal.process; - var nodeUtil = function() { - try { - return freeProcess && freeProcess.binding && freeProcess.binding("util"); - } catch (e) { - } - }(); - var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - function arrayFilter(array, predicate) { - var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result[resIndex++] = value; - } - } - return result; - } - function arrayPush(array, values) { - var index = -1, length = values.length, offset = array.length; - while (++index < length) { - array[offset + index] = values[index]; - } - return array; - } - function arraySome(array, predicate) { - var index = -1, length = array == null ? 0 : array.length; - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; - } - function baseTimes(n3, iteratee) { - var index = -1, result = Array(n3); - while (++index < n3) { - result[index] = iteratee(index); - } - return result; - } - function baseUnary(func) { - return function(value) { - return func(value); - }; - } - function cacheHas(cache, key) { - return cache.has(key); - } - function getValue(object, key) { - return object == null ? void 0 : object[key]; - } - function mapToArray(map) { - var index = -1, result = Array(map.size); - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; - } - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - function setToArray(set2) { - var index = -1, result = Array(set2.size); - set2.forEach(function(value) { - result[++index] = value; - }); - return result; - } - var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype; - var coreJsData = root["__core-js_shared__"]; - var funcToString = funcProto.toString; - var hasOwnProperty = objectProto.hasOwnProperty; - var maskSrcKey = function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); - return uid ? "Symbol(src)_1." + uid : ""; - }(); - var nativeObjectToString = objectProto.toString; - var reIsNative = RegExp( - "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" - ); - var Buffer2 = moduleExports ? root.Buffer : void 0, Symbol2 = root.Symbol, Uint8Array2 = root.Uint8Array, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0; - var nativeGetSymbols = Object.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0, nativeKeys = overArg(Object.keys, Object); - var DataView2 = getNative(root, "DataView"), Map2 = getNative(root, "Map"), Promise2 = getNative(root, "Promise"), Set2 = getNative(root, "Set"), WeakMap2 = getNative(root, "WeakMap"), nativeCreate = getNative(Object, "create"); - var dataViewCtorString = toSource(DataView2), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2); - var symbolProto = Symbol2 ? Symbol2.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0; - function Hash(entries) { - var index = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; - this.size = 0; - } - function hashDelete(key) { - var result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; - return result; - } - function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? void 0 : result; - } - return hasOwnProperty.call(data, key) ? data[key] : void 0; - } - function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key); - } - function hashSet(key, value) { - var data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value; - return this; - } - Hash.prototype.clear = hashClear; - Hash.prototype["delete"] = hashDelete; - Hash.prototype.get = hashGet; - Hash.prototype.has = hashHas; - Hash.prototype.set = hashSet; - function ListCache(entries) { - var index = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - function listCacheClear() { - this.__data__ = []; - this.size = 0; - } - function listCacheDelete(key) { - var data = this.__data__, index = assocIndexOf(data, key); - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - --this.size; - return true; - } - function listCacheGet(key) { - var data = this.__data__, index = assocIndexOf(data, key); - return index < 0 ? void 0 : data[index][1]; - } - function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; - } - function listCacheSet(key, value) { - var data = this.__data__, index = assocIndexOf(data, key); - if (index < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; - } - ListCache.prototype.clear = listCacheClear; - ListCache.prototype["delete"] = listCacheDelete; - ListCache.prototype.get = listCacheGet; - ListCache.prototype.has = listCacheHas; - ListCache.prototype.set = listCacheSet; - function MapCache(entries) { - var index = -1, length = entries == null ? 0 : entries.length; - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } - } - function mapCacheClear() { - this.size = 0; - this.__data__ = { - "hash": new Hash(), - "map": new (Map2 || ListCache)(), - "string": new Hash() - }; - } - function mapCacheDelete(key) { - var result = getMapData(this, key)["delete"](key); - this.size -= result ? 1 : 0; - return result; - } - function mapCacheGet(key) { - return getMapData(this, key).get(key); - } - function mapCacheHas(key) { - return getMapData(this, key).has(key); - } - function mapCacheSet(key, value) { - var data = getMapData(this, key), size = data.size; - data.set(key, value); - this.size += data.size == size ? 0 : 1; - return this; - } - MapCache.prototype.clear = mapCacheClear; - MapCache.prototype["delete"] = mapCacheDelete; - MapCache.prototype.get = mapCacheGet; - MapCache.prototype.has = mapCacheHas; - MapCache.prototype.set = mapCacheSet; - function SetCache(values) { - var index = -1, length = values == null ? 0 : values.length; - this.__data__ = new MapCache(); - while (++index < length) { - this.add(values[index]); - } - } - function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; - } - function setCacheHas(value) { - return this.__data__.has(value); - } - SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; - SetCache.prototype.has = setCacheHas; - function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; - } - function stackClear() { - this.__data__ = new ListCache(); - this.size = 0; - } - function stackDelete(key) { - var data = this.__data__, result = data["delete"](key); - this.size = data.size; - return result; - } - function stackGet(key) { - return this.__data__.get(key); - } - function stackHas(key) { - return this.__data__.has(key); - } - function stackSet(key, value) { - var data = this.__data__; - if (data instanceof ListCache) { - var pairs = data.__data__; - if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); - } - data.set(key, value); - this.size = data.size; - return this; - } - Stack.prototype.clear = stackClear; - Stack.prototype["delete"] = stackDelete; - Stack.prototype.get = stackGet; - Stack.prototype.has = stackHas; - Stack.prototype.set = stackSet; - function arrayLikeKeys(value, inherited) { - var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. - (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. - isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. - isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. - isIndex(key, length)))) { - result.push(key); - } - } - return result; - } - function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; - } - function baseGetAllKeys(object, keysFunc, symbolsFunc) { - var result = keysFunc(object); - return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); - } - function baseGetTag(value) { - if (value == null) { - return value === void 0 ? undefinedTag : nullTag; - } - return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); - } - function baseIsArguments(value) { - return isObjectLike(value) && baseGetTag(value) == argsTag; - } - function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); - } - function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { - var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other); - objTag = objTag == argsTag ? objectTag : objTag; - othTag = othTag == argsTag ? objectTag : othTag; - var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; - if (isSameTag && isBuffer(object)) { - if (!isBuffer(other)) { - return false; - } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack || (stack = new Stack()); - return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__"); - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; - stack || (stack = new Stack()); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack()); - return equalObjects(object, other, bitmask, customizer, equalFunc, stack); - } - function baseIsNative(value) { - if (!isObject2(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); - } - function baseIsTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; - } - function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != "constructor") { - result.push(key); - } - } - return result; - } - function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : void 0; - stack.set(array, other); - stack.set(other, array); - while (++index < arrLength) { - var arrValue = array[index], othValue = other[index]; - if (customizer) { - var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== void 0) { - if (compared) { - continue; - } - result = false; - break; - } - if (seen) { - if (!arraySome(other, function(othValue2, othIndex) { - if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - result = false; - break; - } - } - stack["delete"](array); - stack["delete"](other); - return result; - } - function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { - case dataViewTag: - if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { - return false; - } - object = object.buffer; - other = other.buffer; - case arrayBufferTag: - if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) { - return false; - } - return true; - case boolTag: - case dateTag: - case numberTag: - return eq(+object, +other); - case errorTag: - return object.name == other.name && object.message == other.message; - case regexpTag: - case stringTag: - return object == other + ""; - case mapTag: - var convert2 = mapToArray; - case setTag: - var isPartial = bitmask & COMPARE_PARTIAL_FLAG; - convert2 || (convert2 = setToArray); - if (object.size != other.size && !isPartial) { - return false; - } - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG; - stack.set(object, other); - var result = equalArrays(convert2(object), convert2(other), bitmask, customizer, equalFunc, stack); - stack["delete"](object); - return result; - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; - } - function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - var result = true; - stack.set(object, other); - stack.set(other, object); - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], othValue = other[key]; - if (customizer) { - var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); - } - if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { - result = false; - break; - } - skipCtor || (skipCtor = key == "constructor"); - } - if (result && !skipCtor) { - var objCtor = object.constructor, othCtor = other.constructor; - if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) { - result = false; - } - } - stack["delete"](object); - stack["delete"](other); - return result; - } - function getAllKeys(object) { - return baseGetAllKeys(object, keys2, getSymbols); - } - function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; - } - function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : void 0; - } - function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; - try { - value[symToStringTag] = void 0; - var unmasked = true; - } catch (e) { - } - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; - } - var getSymbols = !nativeGetSymbols ? stubArray : function(object) { - if (object == null) { - return []; - } - object = Object(object); - return arrayFilter(nativeGetSymbols(object), function(symbol) { - return propertyIsEnumerable.call(object, symbol); - }); - }; - var getTag = baseGetTag; - if (DataView2 && getTag(new DataView2(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) { - getTag = function(value) { - var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : ""; - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: - return dataViewTag; - case mapCtorString: - return mapTag; - case promiseCtorString: - return promiseTag; - case setCtorString: - return setTag; - case weakMapCtorString: - return weakMapTag; - } - } - return result; - }; - } - function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); - } - function isKeyable(value) { - var type2 = typeof value; - return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null; - } - function isMasked(func) { - return !!maskSrcKey && maskSrcKey in func; - } - function isPrototype(value) { - var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto; - return value === proto; - } - function objectToString(value) { - return nativeObjectToString.call(value); - } - function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) { - } - try { - return func + ""; - } catch (e) { - } - } - return ""; - } - function eq(value, other) { - return value === other || value !== value && other !== other; - } - var isArguments = baseIsArguments(/* @__PURE__ */ function() { - return arguments; - }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee"); - }; - var isArray = Array.isArray; - function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); - } - var isBuffer = nativeIsBuffer || stubFalse; - function isEqual(value, other) { - return baseIsEqual(value, other); - } - function isFunction(value) { - if (!isObject2(value)) { - return false; - } - var tag = baseGetTag(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; - } - function isLength(value) { - return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - function isObject2(value) { - var type2 = typeof value; - return value != null && (type2 == "object" || type2 == "function"); - } - function isObjectLike(value) { - return value != null && typeof value == "object"; - } - var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - function keys2(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); - } - function stubArray() { - return []; - } - function stubFalse() { - return false; - } - module2.exports = isEqual; -})(lodash_isequal, lodash_isequal.exports); -var lodash_isequalExports = lodash_isequal.exports; -const Gi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); -function unfetch_module(e, n3) { - return n3 = n3 || {}, new Promise(function(t2, r2) { - var s2 = new XMLHttpRequest(), o2 = [], u3 = [], i2 = {}, a3 = function() { - return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() { - return Promise.resolve(s2.responseText); - }, json: function() { - return Promise.resolve(s2.responseText).then(JSON.parse); - }, blob: function() { - return Promise.resolve(new Blob([s2.response])); - }, clone: a3, headers: { keys: function() { - return o2; - }, entries: function() { - return u3; - }, get: function(e2) { - return i2[e2.toLowerCase()]; - }, has: function(e2) { - return e2.toLowerCase() in i2; - } } }; - }; - for (var l2 in s2.open(n3.method || "get", e, true), s2.onload = function() { - s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e2, n4, t3) { - o2.push(n4 = n4.toLowerCase()), u3.push([n4, t3]), i2[n4] = i2[n4] ? i2[n4] + "," + t3 : t3; - }), t2(a3()); - }, s2.onerror = r2, s2.withCredentials = "include" == n3.credentials, n3.headers) - s2.setRequestHeader(l2, n3.headers[l2]); - s2.send(n3.body || null); - }); -} -const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: unfetch_module -}, Symbol.toStringTag, { value: "Module" })); -const require$$0 = /* @__PURE__ */ getAugmentedNamespace(unfetch_module$1); -var browser$2 = fetch || (self.fetch = require$$0.default || require$$0); -const Yi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); -function Hi(n3, e) { - if (n3.length >= 255) - throw new TypeError("Alphabet too long"); - for (var t2 = new Uint8Array(256), i2 = 0; i2 < t2.length; i2++) - t2[i2] = 255; - for (var s2 = 0; s2 < n3.length; s2++) { - var r2 = n3.charAt(s2), o2 = r2.charCodeAt(0); - if (t2[o2] !== 255) - throw new TypeError(r2 + " is ambiguous"); - t2[o2] = s2; - } - var a3 = n3.length, h4 = n3.charAt(0), l2 = Math.log(a3) / Math.log(256), d3 = Math.log(256) / Math.log(a3); - function p3(u3) { - if (u3 instanceof Uint8Array || (ArrayBuffer.isView(u3) ? u3 = new Uint8Array(u3.buffer, u3.byteOffset, u3.byteLength) : Array.isArray(u3) && (u3 = Uint8Array.from(u3))), !(u3 instanceof Uint8Array)) - throw new TypeError("Expected Uint8Array"); - if (u3.length === 0) - return ""; - for (var m2 = 0, z3 = 0, I2 = 0, _3 = u3.length; I2 !== _3 && u3[I2] === 0; ) - I2++, m2++; - for (var T2 = (_3 - I2) * d3 + 1 >>> 0, f2 = new Uint8Array(T2); I2 !== _3; ) { - for (var S2 = u3[I2], A2 = 0, C2 = T2 - 1; (S2 !== 0 || A2 < z3) && C2 !== -1; C2--, A2++) - S2 += 256 * f2[C2] >>> 0, f2[C2] = S2 % a3 >>> 0, S2 = S2 / a3 >>> 0; - if (S2 !== 0) - throw new Error("Non-zero carry"); - z3 = A2, I2++; - } - for (var x2 = T2 - z3; x2 !== T2 && f2[x2] === 0; ) - x2++; - for (var j2 = h4.repeat(m2); x2 < T2; ++x2) - j2 += n3.charAt(f2[x2]); - return j2; - } - function y3(u3) { - if (typeof u3 != "string") - throw new TypeError("Expected String"); - if (u3.length === 0) - return new Uint8Array(); - var m2 = 0; - if (u3[m2] !== " ") { - for (var z3 = 0, I2 = 0; u3[m2] === h4; ) - z3++, m2++; - for (var _3 = (u3.length - m2) * l2 + 1 >>> 0, T2 = new Uint8Array(_3); u3[m2]; ) { - var f2 = t2[u3.charCodeAt(m2)]; - if (f2 === 255) - return; - for (var S2 = 0, A2 = _3 - 1; (f2 !== 0 || S2 < I2) && A2 !== -1; A2--, S2++) - f2 += a3 * T2[A2] >>> 0, T2[A2] = f2 % 256 >>> 0, f2 = f2 / 256 >>> 0; - if (f2 !== 0) - throw new Error("Non-zero carry"); - I2 = S2, m2++; - } - if (u3[m2] !== " ") { - for (var C2 = _3 - I2; C2 !== _3 && T2[C2] === 0; ) - C2++; - for (var x2 = new Uint8Array(z3 + (_3 - C2)), j2 = z3; C2 !== _3; ) - x2[j2++] = T2[C2++]; - return x2; - } - } - } - function M2(u3) { - var m2 = y3(u3); - if (m2) - return m2; - throw new Error(`Non-${e} character`); - } - return { encode: p3, decodeUnsafe: y3, decode: M2 }; -} -var Ji = Hi, Xi = Ji; -const Ne = (n3) => { - if (n3 instanceof Uint8Array && n3.constructor.name === "Uint8Array") - return n3; - if (n3 instanceof ArrayBuffer) - return new Uint8Array(n3); - if (ArrayBuffer.isView(n3)) - return new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength); - throw new Error("Unknown type, must be binary type"); -}, Wi = (n3) => new TextEncoder().encode(n3), Qi = (n3) => new TextDecoder().decode(n3); -class Zi { - constructor(e, t2, i2) { - this.name = e, this.prefix = t2, this.baseEncode = i2; - } - encode(e) { - if (e instanceof Uint8Array) - return `${this.prefix}${this.baseEncode(e)}`; - throw Error("Unknown type, must be binary type"); - } -} -class es { - constructor(e, t2, i2) { - if (this.name = e, this.prefix = t2, t2.codePointAt(0) === void 0) - throw new Error("Invalid prefix character"); - this.prefixCodePoint = t2.codePointAt(0), this.baseDecode = i2; - } - 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 Ue(this, e); - } -} -class ts { - constructor(e) { - this.decoders = e; - } - or(e) { - return Ue(this, e); - } - decode(e) { - const t2 = e[0], i2 = this.decoders[t2]; - if (i2) - return i2.decode(e); - throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); - } -} -const Ue = (n3, e) => new ts({ ...n3.decoders || { [n3.prefix]: n3 }, ...e.decoders || { [e.prefix]: e } }); -class is { - constructor(e, t2, i2, s2) { - this.name = e, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new Zi(e, t2, i2), this.decoder = new es(e, t2, s2); - } - encode(e) { - return this.encoder.encode(e); - } - decode(e) { - return this.decoder.decode(e); - } -} -const W$1 = ({ name: n3, prefix: e, encode: t2, decode: i2 }) => new is(n3, e, t2, i2), B = ({ prefix: n3, name: e, alphabet: t2 }) => { - const { encode: i2, decode: s2 } = Xi(t2, e); - return W$1({ prefix: n3, name: e, encode: i2, decode: (r2) => Ne(s2(r2)) }); -}, ss = (n3, e, t2, i2) => { - const s2 = {}; - for (let d3 = 0; d3 < e.length; ++d3) - s2[e[d3]] = d3; - let r2 = n3.length; - for (; n3[r2 - 1] === "="; ) - --r2; - const o2 = new Uint8Array(r2 * t2 / 8 | 0); - let a3 = 0, h4 = 0, l2 = 0; - for (let d3 = 0; d3 < r2; ++d3) { - const p3 = s2[n3[d3]]; - if (p3 === void 0) - throw new SyntaxError(`Non-${i2} character`); - h4 = h4 << t2 | p3, a3 += t2, a3 >= 8 && (a3 -= 8, o2[l2++] = 255 & h4 >> a3); - } - if (a3 >= t2 || 255 & h4 << 8 - a3) - throw new SyntaxError("Unexpected end of data"); - return o2; -}, rs = (n3, e, t2) => { - const i2 = e[e.length - 1] === "=", s2 = (1 << t2) - 1; - let r2 = "", o2 = 0, a3 = 0; - for (let h4 = 0; h4 < n3.length; ++h4) - for (a3 = a3 << 8 | n3[h4], o2 += 8; o2 > t2; ) - o2 -= t2, r2 += e[s2 & a3 >> o2]; - if (o2 && (r2 += e[s2 & a3 << t2 - o2]), i2) - for (; r2.length * t2 & 7; ) - r2 += "="; - return r2; -}, g$2 = ({ name: n3, prefix: e, bitsPerChar: t2, alphabet: i2 }) => W$1({ prefix: e, name: n3, encode(s2) { - return rs(s2, i2, t2); -}, decode(s2) { - return ss(s2, i2, t2, n3); -} }), ns = W$1({ prefix: "\0", name: "identity", encode: (n3) => Qi(n3), decode: (n3) => Wi(n3) }); -var os = Object.freeze({ __proto__: null, identity: ns }); -const as$1 = g$2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); -var hs$1 = Object.freeze({ __proto__: null, base2: as$1 }); -const cs$1 = g$2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); -var us$1 = Object.freeze({ __proto__: null, base8: cs$1 }); -const ls$1 = B({ prefix: "9", name: "base10", alphabet: "0123456789" }); -var ds$1 = Object.freeze({ __proto__: null, base10: ls$1 }); -const gs$1 = g$2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), ps$1 = g$2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); -var Ds = Object.freeze({ __proto__: null, base16: gs$1, base16upper: ps$1 }); -const ys = g$2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), ms$1 = g$2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), bs = g$2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), fs = g$2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), Es = g$2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), ws = g$2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), vs = g$2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Is = g$2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), Cs = g$2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); -var Rs = Object.freeze({ __proto__: null, base32: ys, base32upper: ms$1, base32pad: bs, base32padupper: fs, base32hex: Es, base32hexupper: ws, base32hexpad: vs, base32hexpadupper: Is, base32z: Cs }); -const _s = B({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ts = B({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); -var Ss = Object.freeze({ __proto__: null, base36: _s, base36upper: Ts }); -const Ps = B({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), xs = B({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); -var Os = Object.freeze({ __proto__: null, base58btc: Ps, base58flickr: xs }); -const As = g$2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), zs = g$2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ns = g$2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us = g$2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); -var Ls = Object.freeze({ __proto__: null, base64: As, base64pad: zs, base64url: Ns, base64urlpad: Us }); -const Le = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), $s = Le.reduce((n3, e, t2) => (n3[t2] = e, n3), []), Fs = Le.reduce((n3, e, t2) => (n3[e.codePointAt(0)] = t2, n3), []); -function Ms(n3) { - return n3.reduce((e, t2) => (e += $s[t2], e), ""); -} -function ks(n3) { - const e = []; - for (const t2 of n3) { - const i2 = Fs[t2.codePointAt(0)]; - if (i2 === void 0) - throw new Error(`Non-base256emoji character: ${t2}`); - e.push(i2); - } - return new Uint8Array(e); -} -const Ks = W$1({ prefix: "🚀", name: "base256emoji", encode: Ms, decode: ks }); -var Bs = Object.freeze({ __proto__: null, base256emoji: Ks }), Vs = Fe, $e = 128, qs = 127, js = ~qs, Gs = Math.pow(2, 31); -function Fe(n3, e, t2) { - e = e || [], t2 = t2 || 0; - for (var i2 = t2; n3 >= Gs; ) - e[t2++] = n3 & 255 | $e, n3 /= 128; - for (; n3 & js; ) - e[t2++] = n3 & 255 | $e, n3 >>>= 7; - return e[t2] = n3 | 0, Fe.bytes = t2 - i2 + 1, e; -} -var Ys = he$1, Hs = 128, Me = 127; -function he$1(n3, i2) { - var t2 = 0, i2 = i2 || 0, s2 = 0, r2 = i2, o2, a3 = n3.length; - do { - if (r2 >= a3) - throw he$1.bytes = 0, new RangeError("Could not decode varint"); - o2 = n3[r2++], t2 += s2 < 28 ? (o2 & Me) << s2 : (o2 & Me) * Math.pow(2, s2), s2 += 7; - } while (o2 >= Hs); - return he$1.bytes = r2 - i2, t2; -} -var Js = Math.pow(2, 7), Xs = Math.pow(2, 14), Ws = Math.pow(2, 21), Qs = Math.pow(2, 28), Zs = Math.pow(2, 35), er = Math.pow(2, 42), tr = Math.pow(2, 49), ir = Math.pow(2, 56), sr2 = Math.pow(2, 63), rr = function(n3) { - return n3 < Js ? 1 : n3 < Xs ? 2 : n3 < Ws ? 3 : n3 < Qs ? 4 : n3 < Zs ? 5 : n3 < er ? 6 : n3 < tr ? 7 : n3 < ir ? 8 : n3 < sr2 ? 9 : 10; -}, nr = { encode: Vs, decode: Ys, encodingLength: rr }, ke = nr; -const Ke = (n3, e, t2 = 0) => (ke.encode(n3, e, t2), e), Be = (n3) => ke.encodingLength(n3), ce$1 = (n3, e) => { - const t2 = e.byteLength, i2 = Be(n3), s2 = i2 + Be(t2), r2 = new Uint8Array(s2 + t2); - return Ke(n3, r2, 0), Ke(t2, r2, i2), r2.set(e, s2), new or(n3, t2, e, r2); -}; -class or { - constructor(e, t2, i2, s2) { - this.code = e, this.size = t2, this.digest = i2, this.bytes = s2; - } -} -const Ve = ({ name: n3, code: e, encode: t2 }) => new ar(n3, e, t2); -class ar { - constructor(e, t2, i2) { - this.name = e, this.code = t2, this.encode = i2; - } - digest(e) { - if (e instanceof Uint8Array) { - const t2 = this.encode(e); - return t2 instanceof Uint8Array ? ce$1(this.code, t2) : t2.then((i2) => ce$1(this.code, i2)); - } else - throw Error("Unknown type, must be binary type"); - } -} -const qe = (n3) => async (e) => new Uint8Array(await crypto.subtle.digest(n3, e)), hr = Ve({ name: "sha2-256", code: 18, encode: qe("SHA-256") }), cr = Ve({ name: "sha2-512", code: 19, encode: qe("SHA-512") }); -var ur = Object.freeze({ __proto__: null, sha256: hr, sha512: cr }); -const je = 0, lr = "identity", Ge = Ne, dr = (n3) => ce$1(je, Ge(n3)), gr = { code: je, name: lr, encode: Ge, digest: dr }; -var pr = Object.freeze({ __proto__: null, identity: gr }); -new TextEncoder(), new TextDecoder(); -const Ye = { ...os, ...hs$1, ...us$1, ...ds$1, ...Ds, ...Rs, ...Ss, ...Os, ...Ls, ...Bs }; -({ ...ur, ...pr }); -function He(n3) { - return globalThis.Buffer != null ? new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength) : n3; -} -function Dr(n3 = 0) { - return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? He(globalThis.Buffer.allocUnsafe(n3)) : new Uint8Array(n3); -} -function Je(n3, e, t2, i2) { - return { name: n3, prefix: e, encoder: { name: n3, prefix: e, encode: t2 }, decoder: { decode: i2 } }; -} -const Xe = Je("utf8", "u", (n3) => "u" + new TextDecoder("utf8").decode(n3), (n3) => new TextEncoder().encode(n3.substring(1))), ue$1 = Je("ascii", "a", (n3) => { - let e = "a"; - for (let t2 = 0; t2 < n3.length; t2++) - e += String.fromCharCode(n3[t2]); - return e; -}, (n3) => { - n3 = n3.substring(1); - const e = Dr(n3.length); - for (let t2 = 0; t2 < n3.length; t2++) - e[t2] = n3.charCodeAt(t2); - return e; -}), yr = { utf8: Xe, "utf-8": Xe, hex: Ye.base16, latin1: ue$1, ascii: ue$1, binary: ue$1, ...Ye }; -function mr(n3, e = "utf8") { - const t2 = yr[e]; - if (!t2) - throw new Error(`Unsupported encoding "${e}"`); - return (e === "utf8" || e === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? He(globalThis.Buffer.from(n3, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n3}`); -} -const le$1 = "wc", We = 2, Q$1 = "core", O = `${le$1}@2:${Q$1}:`, Qe = { name: Q$1, logger: "error" }, Ze = { database: ":memory:" }, et = "crypto", de$1 = "client_ed25519_seed", tt = cjs$4.ONE_DAY, it = "keychain", st = "0.3", rt = "messages", nt = "0.3", ot = cjs$4.SIX_HOURS, at = "publisher", ht = "irn", ct = "error", ge$1 = "wss://relay.walletconnect.com", pe$1 = "wss://relay.walletconnect.org", ut = "relayer", D$1 = { 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" }, lt = "_subscription", P$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, dt = cjs$4.ONE_SECOND, gt = "2.11.2", pt = 1e4, Dt = "0.3", yt = "WALLETCONNECT_CLIENT_ID", w$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, mt = "subscription", bt = "0.3", ft = cjs$4.FIVE_SECONDS * 1e3, Et = "pairing", wt = "0.3", $ = { wc_pairingDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 } } }, V = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, R$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, vt = "history", It = "0.3", Ct = "expirer", v2 = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Rt = "0.3", Z = "verify-api", F$1 = "https://verify.walletconnect.com", ee = "https://verify.walletconnect.org", _t = [F$1, ee], Tt = "echo", St = "https://echo.walletconnect.com"; -class Pt { - constructor(e, t2) { - this.core = e, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = it, this.version = st, this.initialized = false, this.storagePrefix = O, this.init = async () => { - if (!this.initialized) { - const i2 = await this.getKeyChain(); - typeof i2 < "u" && (this.keychain = i2), this.initialized = true; - } - }, this.has = (i2) => (this.isInitialized(), this.keychain.has(i2)), this.set = async (i2, s2) => { - this.isInitialized(), this.keychain.set(i2, s2), await this.persist(); - }, this.get = (i2) => { - this.isInitialized(); - const s2 = this.keychain.get(i2); - if (typeof s2 > "u") { - const { message: r2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${i2}`); - throw new Error(r2); - } - return s2; - }, this.del = async (i2) => { - this.isInitialized(), this.keychain.delete(i2), await this.persist(); - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - get storageKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; - } - async setKeyChain(e) { - await this.core.storage.setItem(this.storageKey, rt$1(e)); - } - async getKeyChain() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? ot$1(e) : void 0; - } - async persist() { - await this.setKeyChain(this.keychain); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class xt { - constructor(e, t2, i2) { - this.core = e, this.logger = t2, this.name = et, this.initialized = false, this.init = async () => { - this.initialized || (await this.keychain.init(), this.initialized = true); - }, this.hasKeys = (s2) => (this.isInitialized(), this.keychain.has(s2)), this.getClientId = async () => { - this.isInitialized(); - const s2 = await this.getClientSeed(), r2 = generateKeyPair(s2); - return encodeIss(r2.publicKey); - }, this.generateKeyPair = () => { - this.isInitialized(); - const s2 = kn(); - return this.setPrivateKey(s2.publicKey, s2.privateKey); - }, this.signJWT = async (s2) => { - this.isInitialized(); - const r2 = await this.getClientSeed(), o2 = generateKeyPair(r2), a3 = Vn(), h4 = tt; - return await signJWT(a3, s2, h4, o2); - }, this.generateSharedKey = (s2, r2, o2) => { - this.isInitialized(); - const a3 = this.getPrivateKey(s2), h4 = Mn(a3, r2); - return this.setSymKey(h4, o2); - }, this.setSymKey = async (s2, r2) => { - this.isInitialized(); - const o2 = r2 || Kn(s2); - return await this.keychain.set(o2, s2), o2; - }, this.deleteKeyPair = async (s2) => { - this.isInitialized(), await this.keychain.del(s2); - }, this.deleteSymKey = async (s2) => { - this.isInitialized(), await this.keychain.del(s2); - }, this.encode = async (s2, r2, o2) => { - this.isInitialized(); - const a3 = Ae(o2), h4 = safeJsonStringify(r2); - if (qn(a3)) { - const y3 = a3.senderPublicKey, M2 = a3.receiverPublicKey; - s2 = await this.generateSharedKey(y3, M2); - } - const l2 = this.getSymKey(s2), { type: d3, senderPublicKey: p3 } = a3; - return xn({ type: d3, symKey: l2, message: h4, senderPublicKey: p3 }); - }, this.decode = async (s2, r2, o2) => { - this.isInitialized(); - const a3 = Hn(r2, o2); - if (qn(a3)) { - const h4 = a3.receiverPublicKey, l2 = a3.senderPublicKey; - s2 = await this.generateSharedKey(h4, l2); - } - try { - const h4 = this.getSymKey(s2), l2 = Fn({ symKey: h4, encoded: r2 }); - return safeJsonParse(l2); - } catch (h4) { - this.logger.error(`Failed to decode message from topic: '${s2}', clientId: '${await this.getClientId()}'`), this.logger.error(h4); - } - }, this.getPayloadType = (s2) => { - const r2 = ee$1(s2); - return j$1(r2.type); - }, this.getPayloadSenderPublicKey = (s2) => { - const r2 = ee$1(s2); - return r2.senderPublicKey ? toString(r2.senderPublicKey, p$1) : void 0; - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.keychain = i2 || new Pt(this.core, this.logger); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - async setPrivateKey(e, t2) { - return await this.keychain.set(e, t2), e; - } - getPrivateKey(e) { - return this.keychain.get(e); - } - async getClientSeed() { - let e = ""; - try { - e = this.keychain.get(de$1); - } catch { - e = Vn(), await this.keychain.set(de$1, e); - } - return mr(e, "base16"); - } - getSymKey(e) { - return this.keychain.get(e); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class Ot extends a$2 { - constructor(e, t2) { - super(e, t2), this.logger = e, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = rt, this.version = nt, this.initialized = false, this.storagePrefix = O, this.init = async () => { - if (!this.initialized) { - this.logger.trace("Initialized"); - try { - const i2 = await this.getRelayerMessages(); - typeof i2 < "u" && (this.messages = i2), this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", size: this.messages.size }); - } catch (i2) { - this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(i2); - } finally { - this.initialized = true; - } - } - }, this.set = async (i2, s2) => { - this.isInitialized(); - const r2 = Ln(s2); - let o2 = this.messages.get(i2); - return typeof o2 > "u" && (o2 = {}), typeof o2[r2] < "u" || (o2[r2] = s2, this.messages.set(i2, o2), await this.persist()), r2; - }, this.get = (i2) => { - this.isInitialized(); - let s2 = this.messages.get(i2); - return typeof s2 > "u" && (s2 = {}), s2; - }, this.has = (i2, s2) => { - this.isInitialized(); - const r2 = this.get(i2), o2 = Ln(s2); - return typeof r2[o2] < "u"; - }, this.del = async (i2) => { - this.isInitialized(), this.messages.delete(i2), await this.persist(); - }, this.logger = cjs$3.generateChildLogger(e, this.name), this.core = t2; - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - get storageKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; - } - async setRelayerMessages(e) { - await this.core.storage.setItem(this.storageKey, rt$1(e)); - } - async getRelayerMessages() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? ot$1(e) : void 0; - } - async persist() { - await this.setRelayerMessages(this.messages); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class vr extends u$1 { - constructor(e, t2) { - super(e, t2), this.relayer = e, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = at, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$4.toMiliseconds(cjs$4.TEN_SECONDS * 2), this.needsTransportRestart = false, this.publish = async (i2, s2, r2) => { - var o2; - this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); - try { - const a3 = (r2 == null ? void 0 : r2.ttl) || ot, h4 = vt$1(r2), l2 = (r2 == null ? void 0 : r2.prompt) || false, d3 = (r2 == null ? void 0 : r2.tag) || 0, p3 = (r2 == null ? void 0 : r2.id) || getBigIntRpcId().toString(), y3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d3, id: p3 } }, M2 = setTimeout(() => this.queue.set(p3, y3), this.publishTimeout); - try { - await await ut$1(this.rpcPublish(i2, s2, a3, h4, l2, d3, p3), this.publishTimeout, `Failed to publish payload, please try again. id:${p3} tag:${d3}`), this.removeRequestFromQueue(p3), this.relayer.events.emit(D$1.publish, y3); - } catch (u3) { - if (this.logger.debug("Publishing Payload stalled"), this.needsTransportRestart = true, (o2 = r2 == null ? void 0 : r2.internal) != null && o2.throwOnFailedPublish) - throw this.removeRequestFromQueue(p3), u3; - return; - } finally { - clearTimeout(M2); - } - this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); - } catch (a3) { - throw this.logger.debug("Failed to Publish Payload"), this.logger.error(a3), a3; - } - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.relayer = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.registerEventListeners(); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - rpcPublish(e, t2, i2, s2, r2, o2, a3) { - var h4, l2, d3, p3; - const y3 = { method: Et$1(s2.protocol).publish, params: { topic: e, message: t2, ttl: i2, prompt: r2, tag: o2 }, id: a3 }; - return w$3((h4 = y3.params) == null ? void 0 : h4.prompt) && ((l2 = y3.params) == null || delete l2.prompt), w$3((d3 = y3.params) == null ? void 0 : d3.tag) && ((p3 = y3.params) == null || delete p3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: y3 }), this.relayer.request(y3); - } - removeRequestFromQueue(e) { - this.queue.delete(e); - } - checkQueue() { - this.queue.forEach(async (e) => { - const { topic: t2, message: i2, opts: s2 } = e; - await this.publish(t2, i2, s2); - }); - } - registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { - if (this.needsTransportRestart) { - this.needsTransportRestart = false, this.relayer.events.emit(D$1.connection_stalled); - return; - } - this.checkQueue(); - }), this.relayer.on(D$1.message_ack, (e) => { - this.removeRequestFromQueue(e.id.toString()); - }); - } -} -class Ir { - constructor() { - this.map = /* @__PURE__ */ new Map(), this.set = (e, t2) => { - const i2 = this.get(e); - this.exists(e, t2) || this.map.set(e, [...i2, t2]); - }, this.get = (e) => this.map.get(e) || [], this.exists = (e, t2) => this.get(e).includes(t2), this.delete = (e, t2) => { - if (typeof t2 > "u") { - this.map.delete(e); - return; - } - if (!this.map.has(e)) - return; - const i2 = this.get(e); - if (!this.exists(e, t2)) - return; - const s2 = i2.filter((r2) => r2 !== t2); - if (!s2.length) { - this.map.delete(e); - return; - } - this.map.set(e, s2); - }, this.clear = () => { - this.map.clear(); - }; - } - get topics() { - return Array.from(this.map.keys()); - } -} -var Cr = Object.defineProperty, Rr = Object.defineProperties, _r = Object.getOwnPropertyDescriptors, At = Object.getOwnPropertySymbols, Tr = Object.prototype.hasOwnProperty, Sr = Object.prototype.propertyIsEnumerable, zt = (n3, e, t2) => e in n3 ? Cr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, q$1 = (n3, e) => { - for (var t2 in e || (e = {})) - Tr.call(e, t2) && zt(n3, t2, e[t2]); - if (At) - for (var t2 of At(e)) - Sr.call(e, t2) && zt(n3, t2, e[t2]); - return n3; -}, De = (n3, e) => Rr(n3, _r(e)); -class Nt extends d2 { - constructor(e, t2) { - super(e, t2), this.relayer = e, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Ir(), this.events = new eventsExports.EventEmitter(), this.name = mt, this.version = bt, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = O, this.subscribeTimeout = 1e4, this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), this.clientId = await this.relayer.core.crypto.getClientId()); - }, this.subscribe = async (i2, s2) => { - await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }); - try { - const r2 = vt$1(s2), o2 = { topic: i2, relay: r2 }; - this.pending.set(i2, o2); - const a3 = await this.rpcSubscribe(i2, r2); - return this.onSubscribe(a3, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }), a3; - } catch (r2) { - throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r2), r2; - } - }, this.unsubscribe = async (i2, s2) => { - await this.restartToComplete(), this.isInitialized(), typeof (s2 == null ? void 0 : s2.id) < "u" ? await this.unsubscribeById(i2, s2.id, s2) : await this.unsubscribeByTopic(i2, s2); - }, this.isSubscribed = async (i2) => { - if (this.topics.includes(i2)) - return true; - const s2 = `${this.pendingSubscriptionWatchLabel}_${i2}`; - return await new Promise((r2, o2) => { - const a3 = new cjs$4.Watch(); - a3.start(s2); - const h4 = setInterval(() => { - !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r2(true)), a3.elapsed(s2) >= ft && (clearInterval(h4), a3.stop(s2), o2(new Error("Subscription resolution timeout"))); - }, this.pollingInterval); - }).catch(() => false); - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.restart = async () => { - this.restartInProgress = true, await this.restore(), await this.reset(), this.restartInProgress = false; - }, this.relayer = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.clientId = ""; - } - get context() { - return cjs$3.getLoggerContext(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, t2) { - let i2 = false; - try { - i2 = this.getSubscription(e).topic === t2; - } catch { - } - return i2; - } - onEnable() { - this.cached = [], this.initialized = true; - } - onDisable() { - this.cached = this.values, this.subscriptions.clear(), this.topicMap.clear(); - } - async unsubscribeByTopic(e, t2) { - const i2 = this.topicMap.get(e); - await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e, s2, t2))); - } - async unsubscribeById(e, t2, i2) { - this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: t2, opts: i2 } }); - try { - const s2 = vt$1(i2); - await this.rpcUnsubscribe(e, t2, s2); - const r2 = U$2("USER_DISCONNECTED", `${this.name}, ${e}`); - await this.onUnsubscribe(e, t2, r2), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: t2, opts: i2 } }); - } catch (s2) { - throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s2), s2; - } - } - async rpcSubscribe(e, t2) { - const i2 = { method: Et$1(t2.protocol).subscribe, params: { topic: e } }; - this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); - try { - await await ut$1(this.relayer.request(i2), this.subscribeTimeout); - } catch { - this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(D$1.connection_stalled); - } - return Ln(e + this.clientId); - } - async rpcBatchSubscribe(e) { - if (!e.length) - return; - const t2 = e[0].relay, i2 = { method: Et$1(t2.protocol).batchSubscribe, params: { topics: e.map((s2) => s2.topic) } }; - this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); - try { - return await await ut$1(this.relayer.request(i2), this.subscribeTimeout); - } catch { - this.logger.debug("Outgoing Relay Payload stalled"), this.relayer.events.emit(D$1.connection_stalled); - } - } - rpcUnsubscribe(e, t2, i2) { - const s2 = { method: Et$1(i2.protocol).unsubscribe, params: { topic: e, id: t2 } }; - return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s2 }), this.relayer.request(s2); - } - onSubscribe(e, t2) { - this.setSubscription(e, De(q$1({}, t2), { id: e })), this.pending.delete(t2.topic); - } - onBatchSubscribe(e) { - e.length && e.forEach((t2) => { - this.setSubscription(t2.id, q$1({}, t2)), this.pending.delete(t2.topic); - }); - } - async onUnsubscribe(e, t2, i2) { - this.events.removeAllListeners(t2), this.hasSubscription(t2, e) && this.deleteSubscription(t2, i2), 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, t2) { - this.subscriptions.has(e) || (this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e, subscription: t2 }), this.addSubscription(e, t2)); - } - addSubscription(e, t2) { - this.subscriptions.set(e, q$1({}, t2)), this.topicMap.set(t2.topic, e), this.events.emit(w$1.created, t2); - } - getSubscription(e) { - this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e }); - const t2 = this.subscriptions.get(e); - if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw new Error(i2); - } - return t2; - } - deleteSubscription(e, t2) { - this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e, reason: t2 }); - const i2 = this.getSubscription(e); - this.subscriptions.delete(e), this.topicMap.delete(i2.topic, e), this.events.emit(w$1.deleted, De(q$1({}, i2), { reason: t2 })); - } - async persist() { - await this.setRelayerSubscriptions(this.values), this.events.emit(w$1.sync); - } - async reset() { - if (this.cached.length) { - const e = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); - for (let t2 = 0; t2 < e; t2++) { - const i2 = this.cached.splice(0, this.batchSubscribeTopicsLimit); - await this.batchSubscribe(i2); - } - } - this.events.emit(w$1.resubscribed); - } - async restore() { - try { - const e = await this.getRelayerSubscriptions(); - if (typeof e > "u" || !e.length) - return; - if (this.subscriptions.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); - } - 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; - const t2 = await this.rpcBatchSubscribe(e); - k(t2) && this.onBatchSubscribe(t2.map((i2, s2) => De(q$1({}, e[s2]), { id: i2 }))); - } - async onConnect() { - this.restartInProgress || (await this.restart(), this.onEnable()); - } - onDisconnect() { - this.onDisable(); - } - async checkPending() { - if (!this.initialized || this.relayer.transportExplicitlyClosed) - return; - const e = []; - this.pending.forEach((t2) => { - e.push(t2); - }), await this.batchSubscribe(e); - } - registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, async () => { - await this.checkPending(); - }), this.relayer.on(D$1.connect, async () => { - await this.onConnect(); - }), this.relayer.on(D$1.disconnect, () => { - this.onDisconnect(); - }), this.events.on(w$1.created, async (e) => { - const t2 = w$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), await this.persist(); - }), this.events.on(w$1.deleted, async (e) => { - const t2 = w$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), await this.persist(); - }); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - async restartToComplete() { - this.restartInProgress && await new Promise((e) => { - const t2 = setInterval(() => { - this.restartInProgress || (clearInterval(t2), e()); - }, this.pollingInterval); - }); - } -} -var Pr = Object.defineProperty, Ut = Object.getOwnPropertySymbols, xr = Object.prototype.hasOwnProperty, Or = Object.prototype.propertyIsEnumerable, Lt = (n3, e, t2) => e in n3 ? Pr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, Ar = (n3, e) => { - for (var t2 in e || (e = {})) - xr.call(e, t2) && Lt(n3, t2, e[t2]); - if (Ut) - for (var t2 of Ut(e)) - Or.call(e, t2) && Lt(n3, t2, e[t2]); - return n3; -}; -class $t extends g$4 { - constructor(e) { - super(e), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = ut, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.request = async (t2) => { - this.logger.debug("Publishing Request Payload"); - const i2 = t2.id; - try { - await this.toEstablishConnection(); - const s2 = this.provider.request(t2); - return this.requestsInFlight.set(i2, { promise: s2, request: t2 }), await s2; - } catch (s2) { - throw this.logger.debug("Failed to Publish Request"), this.logger.error(s2), s2; - } finally { - this.requestsInFlight.delete(i2); - } - }, this.onPayloadHandler = (t2) => { - this.onProviderPayload(t2); - }, this.onConnectHandler = () => { - this.events.emit(D$1.connect); - }, this.onDisconnectHandler = () => { - this.onProviderDisconnect(); - }, this.onProviderErrorHandler = (t2) => { - this.logger.error(t2), this.events.emit(D$1.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); - }, this.registerProviderListeners = () => { - this.provider.on(P$1.payload, this.onPayloadHandler), this.provider.on(P$1.connect, this.onConnectHandler), this.provider.on(P$1.disconnect, this.onDisconnectHandler), this.provider.on(P$1.error, this.onProviderErrorHandler); - }, this.core = e.core, this.logger = typeof e.logger < "u" && typeof e.logger != "string" ? cjs$3.generateChildLogger(e.logger, this.name) : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: e.logger || ct })), this.messages = new Ot(this.logger, e.core), this.subscriber = new Nt(this, this.logger), this.publisher = new vr(this, this.logger), this.relayUrl = (e == null ? void 0 : e.relayUrl) || ge$1, this.projectId = e.projectId, this.bundleId = Jn(), this.provider = {}; - } - async init() { - this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); - try { - await this.transportOpen(); - } catch { - this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$1}...`), await this.restartTransport(pe$1); - } - this.initialized = true, setTimeout(async () => { - this.subscriber.topics.length === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); - }, pt); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - get connected() { - return this.provider.connection.connected; - } - get connecting() { - return this.provider.connection.connecting; - } - async publish(e, t2, i2) { - this.isInitialized(), await this.publisher.publish(e, t2, i2), await this.recordMessageEvent({ topic: e, message: t2, publishedAt: Date.now() }); - } - async subscribe(e, t2) { - var i2; - this.isInitialized(); - let s2 = ((i2 = this.subscriber.topicMap.get(e)) == null ? void 0 : i2[0]) || ""; - if (s2) - return s2; - let r2; - const o2 = (a3) => { - a3.topic === e && (this.subscriber.off(w$1.created, o2), r2()); - }; - return await Promise.all([new Promise((a3) => { - r2 = a3, this.subscriber.on(w$1.created, o2); - }), new Promise(async (a3) => { - s2 = await this.subscriber.subscribe(e, t2), a3(); - })]), s2; - } - async unsubscribe(e, t2) { - this.isInitialized(), await this.subscriber.unsubscribe(e, t2); - } - on(e, t2) { - this.events.on(e, t2); - } - once(e, t2) { - this.events.once(e, t2); - } - off(e, t2) { - this.events.off(e, t2); - } - removeListener(e, t2) { - this.events.removeListener(e, t2); - } - async transportClose() { - this.requestsInFlight.size > 0 && (this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."), this.requestsInFlight.forEach(async (e) => { - await e.promise; - })), this.transportExplicitlyClosed = true, this.hasExperiencedNetworkDisruption && this.connected ? await ut$1(this.provider.disconnect(), 1e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.connected && await this.provider.disconnect(); - } - async transportOpen(e) { - if (this.transportExplicitlyClosed = false, await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress) { - e && e !== this.relayUrl && (this.relayUrl = e, await this.transportClose(), await this.createProvider()), this.connectionAttemptInProgress = true; - try { - await Promise.all([new Promise((t2) => { - if (!this.initialized) - return t2(); - this.subscriber.once(w$1.resubscribed, () => { - t2(); - }); - }), new Promise(async (t2, i2) => { - try { - await ut$1(this.provider.connect(), 1e4, `Socket stalled when trying to connect to ${this.relayUrl}`); - } catch (s2) { - i2(s2); - return; - } - t2(); - })]); - } catch (t2) { - this.logger.error(t2); - const i2 = t2; - if (!this.isConnectionStalled(i2.message)) - throw t2; - this.provider.events.emit(P$1.disconnect); - } finally { - this.connectionAttemptInProgress = false, this.hasExperiencedNetworkDisruption = false; - } - } - } - async restartTransport(e) { - await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress && (this.relayUrl = e || this.relayUrl, await this.transportClose(), await this.createProvider(), await this.transportOpen()); - } - async confirmOnlineStateOrThrow() { - if (!await rr$1()) - throw new Error("No internet connection detected. Please restart your network and try again."); - } - isConnectionStalled(e) { - return this.staleConnectionErrors.some((t2) => e.includes(t2)); - } - async createProvider() { - this.provider.connection && this.unregisterProviderListeners(); - const e = await this.core.crypto.signJWT(this.relayUrl); - this.provider = new JsonRpcProvider(new f(Xn({ sdkVersion: gt, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); - } - async recordMessageEvent(e) { - const { topic: t2, message: i2 } = e; - await this.messages.set(t2, i2); - } - async shouldIgnoreMessageEvent(e) { - const { topic: t2, message: i2 } = e; - if (!i2 || i2.length === 0) - return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; - if (!await this.subscriber.isSubscribed(t2)) - return this.logger.debug(`Ignoring message for non-subscribed topic ${t2}`), true; - const s2 = this.messages.has(t2, i2); - return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; - } - async onProviderPayload(e) { - if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e }), isJsonRpcRequest(e)) { - if (!e.method.endsWith(lt)) - return; - const t2 = e.params, { topic: i2, message: s2, publishedAt: r2 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r2 }; - this.logger.debug("Emitting Relayer Payload"), this.logger.trace(Ar({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e), await this.onMessageEvent(o2); - } else - isJsonRpcResponse(e) && this.events.emit(D$1.message_ack, e); - } - async onMessageEvent(e) { - await this.shouldIgnoreMessageEvent(e) || (this.events.emit(D$1.message, e), await this.recordMessageEvent(e)); - } - async acknowledgePayload(e) { - const t2 = formatJsonRpcResult(e.id, true); - await this.provider.connection.send(t2); - } - unregisterProviderListeners() { - this.provider.off(P$1.payload, this.onPayloadHandler), this.provider.off(P$1.connect, this.onConnectHandler), this.provider.off(P$1.disconnect, this.onDisconnectHandler), this.provider.off(P$1.error, this.onProviderErrorHandler); - } - async registerEventListeners() { - this.events.on(D$1.connection_stalled, () => { - this.restartTransport().catch((t2) => this.logger.error(t2)); - }); - let e = await rr$1(); - or$1(async (t2) => { - this.initialized && e !== t2 && (e = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportClose().catch((i2) => this.logger.error(i2)))); - }); - } - onProviderDisconnect() { - this.events.emit(D$1.disconnect), this.attemptToReconnect(); - } - attemptToReconnect() { - this.transportExplicitlyClosed || (this.logger.info("attemptToReconnect called. Connecting..."), setTimeout(async () => { - await this.restartTransport().catch((e) => this.logger.error(e)); - }, cjs$4.toMiliseconds(dt))); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - async toEstablishConnection() { - if (await this.confirmOnlineStateOrThrow(), !this.connected) { - if (this.connectionAttemptInProgress) - return await new Promise((e) => { - const t2 = setInterval(() => { - this.connected && (clearInterval(t2), e()); - }, this.connectionStatusPollingInterval); - }); - await this.restartTransport(); - } - } -} -var zr = Object.defineProperty, Ft = Object.getOwnPropertySymbols, Nr = Object.prototype.hasOwnProperty, Ur = Object.prototype.propertyIsEnumerable, Mt = (n3, e, t2) => e in n3 ? zr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, kt = (n3, e) => { - for (var t2 in e || (e = {})) - Nr.call(e, t2) && Mt(n3, t2, e[t2]); - if (Ft) - for (var t2 of Ft(e)) - Ur.call(e, t2) && Mt(n3, t2, e[t2]); - return n3; -}; -class Kt extends p$2 { - constructor(e, t2, i2, s2 = O, r2 = void 0) { - super(e, t2, i2, s2), this.core = e, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = Dt, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o2) => { - this.getKey && o2 !== null && !w$3(o2) ? this.map.set(this.getKey(o2), o2) : Lt$1(o2) ? this.map.set(o2.id, o2) : xt$1(o2) && this.map.set(o2.topic, o2); - }), this.cached = [], this.initialized = true); - }, this.set = async (o2, a3) => { - this.isInitialized(), this.map.has(o2) ? await this.update(o2, a3) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o2, value: a3 }), this.map.set(o2, a3), await this.persist()); - }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a3) => Object.keys(o2).every((h4) => Gi(a3[h4], o2[h4]))) : this.values), this.update = async (o2, a3) => { - this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o2, update: a3 }); - const h4 = kt(kt({}, this.getData(o2)), a3); - this.map.set(o2, h4), await this.persist(); - }, this.delete = async (o2, a3) => { - this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a3 }), this.map.delete(o2), await this.persist()); - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.storagePrefix = s2, this.getKey = r2; - } - get context() { - return cjs$3.getLoggerContext(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()); - } - async setDataStore(e) { - await this.core.storage.setItem(this.storageKey, e); - } - async getDataStore() { - return await this.core.storage.getItem(this.storageKey); - } - getData(e) { - const t2 = this.map.get(e); - if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw this.logger.error(i2), new Error(i2); - } - return t2; - } - async persist() { - await this.setDataStore(this.values); - } - async restore() { - try { - const e = await this.getDataStore(); - if (typeof e > "u" || !e.length) - return; - if (this.map.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); - } - 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) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class Bt { - constructor(e, t2) { - this.core = e, this.logger = t2, this.name = Et, this.version = wt, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = O, this.ignoredPayloadTypes = [_$1], this.registeredMethods = [], this.init = async () => { - this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); - }, this.register = ({ methods: i2 }) => { - this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; - }, this.create = async () => { - this.isInitialized(); - const i2 = Vn(), s2 = await this.core.crypto.setSymKey(i2), r2 = pt$1(cjs$4.FIVE_MINUTES), o2 = { protocol: ht }, a3 = { topic: s2, expiry: r2, relay: o2, active: false }, h4 = Rt$1({ protocol: this.core.protocol, version: this.core.version, topic: s2, symKey: i2, relay: o2, expiryTimestamp: r2 }); - return await this.pairings.set(s2, a3), await this.core.relayer.subscribe(s2), this.core.expirer.set(s2, r2), { topic: s2, uri: h4 }; - }, this.pair = async (i2) => { - this.isInitialized(), this.isValidPair(i2); - const { topic: s2, symKey: r2, relay: o2, expiryTimestamp: a3 } = Pt$1(i2.uri); - let h4; - if (this.pairings.keys.includes(s2) && (h4 = this.pairings.get(s2), h4.active)) - throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); - const l2 = a3 || pt$1(cjs$4.FIVE_MINUTES), d3 = { topic: s2, relay: o2, expiry: l2, active: false }; - return await this.pairings.set(s2, d3), this.core.expirer.set(s2, l2), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V.create, d3), this.core.crypto.keychain.has(s2) || (await this.core.crypto.setSymKey(r2, s2), await this.core.relayer.subscribe(s2, { relay: o2 })), d3; - }, this.activate = async ({ topic: i2 }) => { - this.isInitialized(); - const s2 = pt$1(cjs$4.THIRTY_DAYS); - await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); - }, this.ping = async (i2) => { - this.isInitialized(), await this.isValidPing(i2); - const { topic: s2 } = i2; - if (this.pairings.keys.includes(s2)) { - const r2 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a3, reject: h4 } = at$1(); - this.events.once(yt$1("pairing_ping", r2), ({ error: l2 }) => { - l2 ? h4(l2) : a3(); - }), await o2(); - } - }, this.updateExpiry = async ({ topic: i2, expiry: s2 }) => { - this.isInitialized(), await this.pairings.update(i2, { expiry: s2 }); - }, this.updateMetadata = async ({ topic: i2, metadata: s2 }) => { - this.isInitialized(), await this.pairings.update(i2, { peerMetadata: s2 }); - }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { - this.isInitialized(), await this.isValidDisconnect(i2); - const { topic: s2 } = i2; - this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", U$2("USER_DISCONNECTED")), await this.deletePairing(s2)); - }, this.sendRequest = async (i2, s2, r2) => { - const o2 = formatJsonRpcRequest(s2, r2), a3 = await this.core.crypto.encode(i2, o2), h4 = $[s2].req; - return this.core.history.set(i2, o2), this.core.relayer.publish(i2, a3, h4), o2.id; - }, this.sendResult = async (i2, s2, r2) => { - const o2 = formatJsonRpcResult(i2, r2), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = $[h4.request.method].res; - await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); - }, this.sendError = async (i2, s2, r2) => { - const o2 = formatJsonRpcError(i2, r2), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = $[h4.request.method] ? $[h4.request.method].res : $.unregistered_method.res; - await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); - }, this.deletePairing = async (i2, s2) => { - await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, U$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); - }, this.cleanup = async () => { - const i2 = this.pairings.getAll().filter((s2) => mt$1(s2.expiry)); - await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); - }, this.onRelayEventRequest = (i2) => { - const { topic: s2, payload: r2 } = i2; - switch (r2.method) { - case "wc_pairingPing": - return this.onPairingPingRequest(s2, r2); - case "wc_pairingDelete": - return this.onPairingDeleteRequest(s2, r2); - default: - return this.onUnknownRpcMethodRequest(s2, r2); - } - }, this.onRelayEventResponse = async (i2) => { - const { topic: s2, payload: r2 } = i2, o2 = (await this.core.history.get(s2, r2.id)).request.method; - switch (o2) { - case "wc_pairingPing": - return this.onPairingPingResponse(s2, r2); - default: - return this.onUnknownRpcMethodResponse(o2); - } - }, this.onPairingPingRequest = async (i2, s2) => { - const { id: r2 } = s2; - try { - this.isValidPing({ topic: i2 }), await this.sendResult(r2, i2, true), this.events.emit(V.ping, { id: r2, topic: i2 }); - } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); - } - }, this.onPairingPingResponse = (i2, s2) => { - const { id: r2 } = s2; - setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("pairing_ping", r2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("pairing_ping", r2), { error: s2.error }); - }, 500); - }, this.onPairingDeleteRequest = async (i2, s2) => { - const { id: r2 } = s2; - try { - this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V.delete, { id: r2, topic: i2 }); - } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); - } - }, this.onUnknownRpcMethodRequest = async (i2, s2) => { - const { id: r2, method: o2 } = s2; - try { - if (this.registeredMethods.includes(o2)) - return; - const a3 = U$2("WC_METHOD_UNSUPPORTED", o2); - await this.sendError(r2, i2, a3), this.logger.error(a3); - } catch (a3) { - await this.sendError(r2, i2, a3), this.logger.error(a3); - } - }, this.onUnknownRpcMethodResponse = (i2) => { - this.registeredMethods.includes(i2) || this.logger.error(U$2("WC_METHOD_UNSUPPORTED", i2)); - }, this.isValidPair = (i2) => { - var s2; - if (!Gt$1(i2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `pair() params: ${i2}`); - throw new Error(o2); - } - if (!Kt$1(i2.uri)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); - throw new Error(o2); - } - const r2 = Pt$1(i2.uri); - if (!((s2 = r2 == null ? void 0 : r2.relay) != null && s2.protocol)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", "pair() uri#relay-protocol"); - throw new Error(o2); - } - if (!(r2 != null && r2.symKey)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", "pair() uri#symKey"); - throw new Error(o2); - } - if (r2 != null && r2.expiryTimestamp && cjs$4.toMiliseconds(r2 == null ? void 0 : r2.expiryTimestamp) < Date.now()) { - const { message: o2 } = N$1("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); - throw new Error(o2); - } - }, this.isValidPing = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `ping() params: ${i2}`); - throw new Error(r2); - } - const { topic: s2 } = i2; - await this.isValidPairingTopic(s2); - }, this.isValidDisconnect = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${i2}`); - throw new Error(r2); - } - const { topic: s2 } = i2; - await this.isValidPairingTopic(s2); - }, this.isValidPairingTopic = async (i2) => { - if (!g$3(i2, false)) { - const { message: s2 } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); - throw new Error(s2); - } - if (!this.pairings.keys.includes(i2)) { - const { message: s2 } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); - throw new Error(s2); - } - if (mt$1(this.pairings.get(i2).expiry)) { - await this.deletePairing(i2); - const { message: s2 } = N$1("EXPIRED", `pairing topic: ${i2}`); - throw new Error(s2); - } - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.pairings = new Kt(this.core, this.logger, this.name, this.storagePrefix); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - registerRelayerEvents() { - this.core.relayer.on(D$1.message, async (e) => { - const { topic: t2, message: i2 } = e; - if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) - return; - const s2 = await this.core.crypto.decode(t2, i2); - try { - isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); - } catch (r2) { - this.logger.error(r2); - } - }); - } - registerExpirerEvents() { - this.core.expirer.on(v2.expired, async (e) => { - const { topic: t2 } = ft$1(e.target); - t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V.expire, { topic: t2 })); - }); - } -} -class Vt extends h$2 { - constructor(e, t2) { - super(e, t2), this.core = e, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = vt, this.version = It, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.set = (i2, s2, r2) => { - if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r2 }), this.records.has(s2.id)) - return; - const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r2, expiry: pt$1(cjs$4.THIRTY_DAYS) }; - this.records.set(o2.id, o2), this.events.emit(R$1.created, o2); - }, this.resolve = async (i2) => { - if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) - return; - const s2 = await this.getRecord(i2.id); - typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.events.emit(R$1.updated, s2)); - }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { - this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r2) => { - if (r2.topic === i2) { - if (typeof s2 < "u" && r2.id !== s2) - return; - this.records.delete(r2.id), this.events.emit(R$1.deleted, r2); - } - }); - }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); - } - get context() { - return cjs$3.getLoggerContext(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() { - const e = []; - return this.values.forEach((t2) => { - if (typeof t2.response < "u") - return; - const i2 = { topic: t2.topic, request: formatJsonRpcRequest(t2.request.method, t2.request.params, t2.id), chainId: t2.chainId }; - return e.push(i2); - }), 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(); - const t2 = this.records.get(e); - if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw new Error(i2); - } - return t2; - } - async persist() { - await this.setJsonRpcRecords(this.values), this.events.emit(R$1.sync); - } - async restore() { - try { - const e = await this.getJsonRpcRecords(); - if (typeof e > "u" || !e.length) - return; - if (this.records.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); - } - 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(R$1.created, (e) => { - const t2 = R$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.events.on(R$1.updated, (e) => { - const t2 = R$1.updated; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.events.on(R$1.deleted, (e) => { - const t2 = R$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { - this.cleanup(); - }); - } - cleanup() { - try { - this.records.forEach((e) => { - cjs$4.toMiliseconds(e.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${e.id}`), this.delete(e.topic, e.id)); - }); - } catch (e) { - this.logger.warn(e); - } - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class qt extends E { - constructor(e, t2) { - super(e, t2), this.core = e, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = Rt, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.has = (i2) => { - try { - const s2 = this.formatTarget(i2); - return typeof this.getExpiration(s2) < "u"; - } catch { - return false; - } - }, this.set = (i2, s2) => { - this.isInitialized(); - const r2 = this.formatTarget(i2), o2 = { target: r2, expiry: s2 }; - this.expirations.set(r2, o2), this.checkExpiry(r2, o2), this.events.emit(v2.created, { target: r2, expiration: o2 }); - }, this.get = (i2) => { - this.isInitialized(); - const s2 = this.formatTarget(i2); - return this.getExpiration(s2); - }, this.del = (i2) => { - if (this.isInitialized(), this.has(i2)) { - const s2 = this.formatTarget(i2), r2 = this.getExpiration(s2); - this.expirations.delete(s2), this.events.emit(v2.deleted, { target: s2, expiration: r2 }); - } - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); - } - get context() { - return cjs$3.getLoggerContext(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 lt$1(e); - if (typeof e == "number") - return dt$1(e); - const { message: t2 } = N$1("UNKNOWN_TYPE", `Target type: ${typeof e}`); - throw new Error(t2); - } - 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(v2.sync); - } - async restore() { - try { - const e = await this.getExpirations(); - if (typeof e > "u" || !e.length) - return; - if (this.expirations.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); - } - 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) { - const t2 = this.expirations.get(e); - if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw this.logger.error(i2), new Error(i2); - } - return t2; - } - checkExpiry(e, t2) { - const { expiry: i2 } = t2; - cjs$4.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e, t2); - } - expire(e, t2) { - this.expirations.delete(e), this.events.emit(v2.expired, { target: e, expiration: t2 }); - } - checkExpirations() { - this.core.relayer.connected && this.expirations.forEach((e, t2) => this.checkExpiry(t2, e)); - } - registerEventListeners() { - this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(v2.created, (e) => { - const t2 = v2.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }), this.events.on(v2.expired, (e) => { - const t2 = v2.expired; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }), this.events.on(v2.deleted, (e) => { - const t2 = v2.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class jt extends y$1 { - constructor(e, t2) { - super(e, t2), this.projectId = e, this.logger = t2, this.name = Z, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { - if (this.verifyDisabled || $$1() || !D$2()) - return; - const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; - try { - await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2); - } - if (!this.initialized) { - this.removeIframe(), this.verifyUrl = ee; - try { - await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2), this.verifyDisabled = true; - } - } - }, this.register = async (i2) => { - this.initialized ? this.sendPost(i2.attestationId) : (this.addToQueue(i2.attestationId), await this.init()); - }, this.resolve = async (i2) => { - if (this.isDevEnv) - return ""; - const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - let r2; - try { - r2 = await this.fetchAttestation(i2.attestationId, s2); - } catch (o2) { - this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r2 = await this.fetchAttestation(i2.attestationId, ee); - } - return r2; - }, this.fetchAttestation = async (i2, s2) => { - this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); - const r2 = this.startAbortTimer(cjs$4.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); - return clearTimeout(r2), o2.status === 200 ? await o2.json() : void 0; - }, this.addToQueue = (i2) => { - this.queue.push(i2); - }, this.processQueue = () => { - this.queue.length !== 0 && (this.queue.forEach((i2) => this.sendPost(i2)), this.queue = []); - }, this.sendPost = (i2) => { - var s2; - try { - if (!this.iframe) - return; - (s2 = this.iframe.contentWindow) == null || s2.postMessage(i2, "*"), this.logger.info(`postMessage sent: ${i2} ${this.verifyUrl}`); - } catch { - } - }, this.createIframe = async () => { - let i2; - const s2 = (r2) => { - r2.data === "verify_ready" && (this.initialized = true, this.processQueue(), window.removeEventListener("message", s2), i2()); - }; - await Promise.race([new Promise((r2) => { - if (document.getElementById(Z)) - return r2(); - window.addEventListener("message", s2); - const o2 = document.createElement("iframe"); - o2.id = Z, o2.src = `${this.verifyUrl}/${this.projectId}`, o2.style.display = "none", document.body.append(o2), this.iframe = o2, i2 = r2; - }), new Promise((r2, o2) => setTimeout(() => { - window.removeEventListener("message", s2), o2("verify iframe load timeout"); - }, cjs$4.toMiliseconds(cjs$4.FIVE_SECONDS)))]); - }, this.removeIframe = () => { - this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); - }, this.getVerifyUrl = (i2) => { - let s2 = i2 || F$1; - return _t.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${F$1}`), s2 = F$1), s2; - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.verifyUrl = F$1, this.abortController = new AbortController(), this.isDevEnv = te$1() && process.env.IS_VITEST; - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - startAbortTimer(e) { - return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$4.toMiliseconds(e)); - } -} -class Gt extends v$1 { - constructor(e, t2) { - super(e, t2), this.projectId = e, this.logger = t2, this.context = Tt, this.registerDeviceToken = async (i2) => { - const { clientId: s2, token: r2, notificationType: o2, enableEncrypted: a3 = false } = i2, h4 = `${St}/${this.projectId}/clients`; - await Yi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r2, always_raw: a3 }) }); - }, this.logger = cjs$3.generateChildLogger(t2, this.context); - } -} -var Lr = Object.defineProperty, Yt = Object.getOwnPropertySymbols, $r = Object.prototype.hasOwnProperty, Fr = Object.prototype.propertyIsEnumerable, Ht = (n3, e, t2) => e in n3 ? Lr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, Jt = (n3, e) => { - for (var t2 in e || (e = {})) - $r.call(e, t2) && Ht(n3, t2, e[t2]); - if (Yt) - for (var t2 of Yt(e)) - Fr.call(e, t2) && Ht(n3, t2, e[t2]); - return n3; -}; -class te extends n$1 { - constructor(e) { - super(e), this.protocol = le$1, this.version = We, this.name = Q$1, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (i2, s2) => this.events.on(i2, s2), this.once = (i2, s2) => this.events.once(i2, s2), this.off = (i2, s2) => this.events.off(i2, s2), this.removeListener = (i2, s2) => this.events.removeListener(i2, s2), this.projectId = e == null ? void 0 : e.projectId, this.relayUrl = (e == null ? void 0 : e.relayUrl) || ge$1, this.customStoragePrefix = e != null && e.customStoragePrefix ? `:${e.customStoragePrefix}` : ""; - const t2 = typeof (e == null ? void 0 : e.logger) < "u" && typeof (e == null ? void 0 : e.logger) != "string" ? e.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (e == null ? void 0 : e.logger) || Qe.logger })); - this.logger = cjs$3.generateChildLogger(t2, this.name), this.heartbeat = new cjs$5.HeartBeat(), this.crypto = new xt(this, this.logger, e == null ? void 0 : e.keychain), this.history = new Vt(this, this.logger), this.expirer = new qt(this, this.logger), this.storage = e != null && e.storage ? e.storage : new h$3(Jt(Jt({}, Ze), e == null ? void 0 : e.storageOptions)), this.relayer = new $t({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new Bt(this, this.logger), this.verify = new jt(this.projectId || "", this.logger), this.echoClient = new Gt(this.projectId || "", this.logger); - } - static async init(e) { - const t2 = new te(e); - await t2.initialize(); - const i2 = await t2.crypto.getClientId(); - return await t2.storage.setItem(yt, i2), t2; - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - async start() { - this.initialized || await this.initialize(); - } - 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.initialized = true, 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; - } - } -} -const Mr = te; -const J = "wc", F = 2, X = "client", G = `${J}@${F}:${X}:`, M = { name: X, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, H = "WALLETCONNECT_DEEPLINK_CHOICE", oe = "proposal", ae = "Proposal expired", ce = "session", L = cjs$4.SEVEN_DAYS, le = "engine", R = { wc_sessionPropose: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1114 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1115 } } }, U$1 = { min: cjs$4.FIVE_MINUTES, max: cjs$4.SEVEN_DAYS }, I = { idle: "IDLE", active: "ACTIVE" }, pe = "request", he = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"]; -var as = Object.defineProperty, cs = Object.defineProperties, ls = Object.getOwnPropertyDescriptors, de = Object.getOwnPropertySymbols, ps = Object.prototype.hasOwnProperty, hs = Object.prototype.propertyIsEnumerable, ue = (w3, r2, e) => r2 in w3 ? as(w3, r2, { enumerable: true, configurable: true, writable: true, value: e }) : w3[r2] = e, g$1 = (w3, r2) => { - for (var e in r2 || (r2 = {})) - ps.call(r2, e) && ue(w3, e, r2[e]); - if (de) - for (var e of de(r2)) - hs.call(r2, e) && ue(w3, e, r2[e]); - return w3; -}, D = (w3, r2) => cs(w3, ls(r2)); -class ds extends w$4 { - constructor(r2) { - super(r2), this.name = le, this.events = new EventEmitter$1(), this.initialized = false, this.ignoredPayloadTypes = [_$1], this.requestQueue = { state: I.idle, queue: [] }, this.sessionRequestQueue = { state: I.idle, queue: [] }, this.requestQueueDelay = cjs$4.ONE_SECOND, this.init = async () => { - this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(R) }), this.initialized = true, setTimeout(() => { - this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay))); - }, this.connect = async (e) => { - await this.isInitialized(); - const s2 = D(g$1({}, e), { requiredNamespaces: e.requiredNamespaces || {}, optionalNamespaces: e.optionalNamespaces || {} }); - await this.isValidConnect(s2); - const { pairingTopic: t2, requiredNamespaces: i2, optionalNamespaces: n3, sessionProperties: o2, relays: a3 } = s2; - let c2 = t2, p3, d3 = false; - if (c2 && (d3 = this.client.core.pairing.pairings.get(c2).active), !c2 || !d3) { - const { topic: T2, uri: _3 } = await this.client.core.pairing.create(); - c2 = T2, p3 = _3; - } - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = R.wc_sessionPropose.req.ttl || cjs$4.FIVE_MINUTES, m2 = pt$1(N2), f2 = g$1({ requiredNamespaces: i2, optionalNamespaces: n3, relays: a3 ?? [{ protocol: ht }], proposer: { publicKey: h4, metadata: this.client.metadata }, expiryTimestamp: m2 }, o2 && { sessionProperties: o2 }), { reject: k2, resolve: O2, done: we } = at$1(N2, ae); - if (this.events.once(yt$1("session_connect"), async ({ error: T2, session: _3 }) => { - if (T2) - k2(T2); - else if (_3) { - _3.self.publicKey = h4; - const B2 = D(g$1({}, _3), { requiredNamespaces: f2.requiredNamespaces, optionalNamespaces: f2.optionalNamespaces }); - await this.client.session.set(_3.topic, B2), await this.setExpiry(_3.topic, _3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: _3.peer.metadata }), O2(B2); - } - }), !c2) { - const { message: T2 } = N$1("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); - throw new Error(T2); - } - const W2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: f2, throwOnFailedPublish: true }); - return await this.setProposal(W2, g$1({ id: W2 }, f2)), { uri: p3, approval: we }; - }, this.pair = async (e) => (await this.isInitialized(), await this.client.core.pairing.pair(e)), this.approve = async (e) => { - await this.isInitialized(), await this.isValidApprove(e); - const { id: s2, relayProtocol: t2, namespaces: i2, sessionProperties: n3 } = e, o2 = this.client.proposal.get(s2); - let { pairingTopic: a3, proposer: c2, requiredNamespaces: p3, optionalNamespaces: d3 } = o2; - a3 = a3 || ""; - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = c2.publicKey, m2 = await this.client.core.crypto.generateSharedKey(h4, N2); - a3 && s2 && (await this.client.core.pairing.updateMetadata({ topic: a3, metadata: c2.metadata }), await this.sendResult({ id: s2, topic: a3, result: { relay: { protocol: t2 ?? "irn" }, responderPublicKey: h4 } }), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: a3 })); - const f2 = g$1({ relay: { protocol: t2 ?? "irn" }, namespaces: i2, pairingTopic: a3, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: pt$1(L) }, n3 && { sessionProperties: n3 }); - await this.client.core.relayer.subscribe(m2); - const k2 = D(g$1({}, f2), { topic: m2, requiredNamespaces: p3, optionalNamespaces: d3, pairingTopic: a3, acknowledged: false, self: f2.controller, peer: { publicKey: c2.publicKey, metadata: c2.metadata }, controller: h4 }); - await this.client.session.set(m2, k2); - try { - await this.sendRequest({ topic: m2, method: "wc_sessionSettle", params: f2, throwOnFailedPublish: true }); - } catch (O2) { - throw this.client.logger.error(O2), this.client.session.delete(m2, U$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(m2), O2; - } - return await this.setExpiry(m2, pt$1(L)), { topic: m2, acknowledged: () => new Promise((O2) => setTimeout(() => O2(this.client.session.get(m2)), 500)) }; - }, this.reject = async (e) => { - await this.isInitialized(), await this.isValidReject(e); - const { id: s2, reason: t2 } = e, { pairingTopic: i2 } = this.client.proposal.get(s2); - i2 && (await this.sendError(s2, i2, t2), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED"))); - }, this.update = async (e) => { - await this.isInitialized(), await this.isValidUpdate(e); - const { topic: s2, namespaces: t2 } = e, i2 = await this.sendRequest({ topic: s2, method: "wc_sessionUpdate", params: { namespaces: t2 } }), { done: n3, resolve: o2, reject: a3 } = at$1(); - return this.events.once(yt$1("session_update", i2), ({ error: c2 }) => { - c2 ? a3(c2) : o2(); - }), await this.client.session.update(s2, { namespaces: t2 }), { acknowledged: n3 }; - }, this.extend = async (e) => { - await this.isInitialized(), await this.isValidExtend(e); - const { topic: s2 } = e, t2 = await this.sendRequest({ topic: s2, method: "wc_sessionExtend", params: {} }), { done: i2, resolve: n3, reject: o2 } = at$1(); - return this.events.once(yt$1("session_extend", t2), ({ error: a3 }) => { - a3 ? o2(a3) : n3(); - }), await this.setExpiry(s2, pt$1(L)), { acknowledged: i2 }; - }, this.request = async (e) => { - await this.isInitialized(), await this.isValidRequest(e); - const { chainId: s2, request: t2, topic: i2, expiry: n3 = R.wc_sessionRequest.req.ttl } = e, o2 = payloadId(), { done: a3, resolve: c2, reject: p3 } = at$1(n3, "Request expired. Please try again."); - return this.events.once(yt$1("session_request", o2), ({ error: d3, result: h4 }) => { - d3 ? p3(d3) : c2(h4); - }), await Promise.all([new Promise(async (d3) => { - await this.sendRequest({ clientRpcId: o2, topic: i2, method: "wc_sessionRequest", params: { request: D(g$1({}, t2), { expiryTimestamp: pt$1(n3) }), chainId: s2 }, expiry: n3, throwOnFailedPublish: true }).catch((h4) => p3(h4)), this.client.events.emit("session_request_sent", { topic: i2, request: t2, chainId: s2, id: o2 }), d3(); - }), new Promise(async (d3) => { - const h4 = await ht$1(this.client.core.storage, H); - gt$1({ id: o2, topic: i2, wcDeepLink: h4 }), d3(); - }), a3()]).then((d3) => d3[2]); - }, this.respond = async (e) => { - await this.isInitialized(), await this.isValidRespond(e); - const { topic: s2, response: t2 } = e, { id: i2 } = t2; - isJsonRpcResult(t2) ? await this.sendResult({ id: i2, topic: s2, result: t2.result, throwOnFailedPublish: true }) : isJsonRpcError(t2) && await this.sendError(i2, s2, t2.error), this.cleanupAfterResponse(e); - }, this.ping = async (e) => { - await this.isInitialized(), await this.isValidPing(e); - const { topic: s2 } = e; - if (this.client.session.keys.includes(s2)) { - const t2 = await this.sendRequest({ topic: s2, method: "wc_sessionPing", params: {} }), { done: i2, resolve: n3, reject: o2 } = at$1(); - this.events.once(yt$1("session_ping", t2), ({ error: a3 }) => { - a3 ? o2(a3) : n3(); - }), await i2(); - } else - this.client.core.pairing.pairings.keys.includes(s2) && await this.client.core.pairing.ping({ topic: s2 }); - }, this.emit = async (e) => { - await this.isInitialized(), await this.isValidEmit(e); - const { topic: s2, event: t2, chainId: i2 } = e; - await this.sendRequest({ topic: s2, method: "wc_sessionEvent", params: { event: t2, chainId: i2 } }); - }, this.disconnect = async (e) => { - await this.isInitialized(), await this.isValidDisconnect(e); - const { topic: s2 } = e; - if (this.client.session.keys.includes(s2)) - await this.sendRequest({ topic: s2, method: "wc_sessionDelete", params: U$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: s2, emitEvent: false }); - else if (this.client.core.pairing.pairings.keys.includes(s2)) - await this.client.core.pairing.disconnect({ topic: s2 }); - else { - const { message: t2 } = N$1("MISMATCHED_TOPIC", `Session or pairing topic not found: ${s2}`); - throw new Error(t2); - } - }, this.find = (e) => (this.isInitialized(), this.client.session.getAll().filter((s2) => Mt$1(s2, e))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.cleanupDuplicatePairings = async (e) => { - if (e.pairingTopic) - try { - const s2 = this.client.core.pairing.pairings.get(e.pairingTopic), t2 = this.client.core.pairing.pairings.getAll().filter((i2) => { - var n3, o2; - return ((n3 = i2.peerMetadata) == null ? void 0 : n3.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === e.peer.metadata.url && i2.topic && i2.topic !== s2.topic; - }); - if (t2.length === 0) - return; - this.client.logger.info(`Cleaning up ${t2.length} duplicate pairing(s)`), await Promise.all(t2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.deleteSession = async (e) => { - const { topic: s2, expirerHasDeleted: t2 = false, emitEvent: i2 = true, id: n3 = 0 } = e, { self: o2 } = this.client.session.get(s2); - await this.client.core.relayer.unsubscribe(s2), await this.client.session.delete(s2, U$2("USER_DISCONNECTED")), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(s2) && await this.client.core.crypto.deleteSymKey(s2), t2 || this.client.core.expirer.del(s2), this.client.core.storage.removeItem(H).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { - a3.topic === s2 && this.deletePendingSessionRequest(a3.id, U$2("USER_DISCONNECTED")); - }), i2 && this.client.events.emit("session_delete", { id: n3, topic: s2 }); - }, this.deleteProposal = async (e, s2) => { - await Promise.all([this.client.proposal.delete(e, U$2("USER_DISCONNECTED")), s2 ? Promise.resolve() : this.client.core.expirer.del(e)]); - }, this.deletePendingSessionRequest = async (e, s2, t2 = false) => { - await Promise.all([this.client.pendingRequest.delete(e, s2), t2 ? Promise.resolve() : this.client.core.expirer.del(e)]), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== e), t2 && (this.sessionRequestQueue.state = I.idle, this.client.events.emit("session_request_expire", { id: e })); - }, this.setExpiry = async (e, s2) => { - this.client.session.keys.includes(e) && await this.client.session.update(e, { expiry: s2 }), this.client.core.expirer.set(e, s2); - }, this.setProposal = async (e, s2) => { - await this.client.proposal.set(e, s2), this.client.core.expirer.set(e, pt$1(R.wc_sessionPropose.req.ttl)); - }, this.setPendingSessionRequest = async (e) => { - const { id: s2, topic: t2, params: i2, verifyContext: n3 } = e, o2 = i2.request.expiryTimestamp || pt$1(R.wc_sessionRequest.req.ttl); - await this.client.pendingRequest.set(s2, { id: s2, topic: t2, params: i2, verifyContext: n3 }), o2 && this.client.core.expirer.set(s2, o2); - }, this.sendRequest = async (e) => { - const { topic: s2, method: t2, params: i2, expiry: n3, relayRpcId: o2, clientRpcId: a3, throwOnFailedPublish: c2 } = e, p3 = formatJsonRpcRequest(t2, i2, a3); - if (D$2() && he.includes(t2)) { - const N2 = Ln(JSON.stringify(p3)); - this.client.core.verify.register({ attestationId: N2 }); - } - const d3 = await this.client.core.crypto.encode(s2, p3), h4 = R[t2].req; - return n3 && (h4.ttl = n3), o2 && (h4.id = o2), this.client.core.history.set(s2, p3), c2 ? (h4.internal = D(g$1({}, h4.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, d3, h4)) : this.client.core.relayer.publish(s2, d3, h4).catch((N2) => this.client.logger.error(N2)), p3.id; - }, this.sendResult = async (e) => { - const { id: s2, topic: t2, result: i2, throwOnFailedPublish: n3 } = e, o2 = formatJsonRpcResult(s2, i2), a3 = await this.client.core.crypto.encode(t2, o2), c2 = await this.client.core.history.get(t2, s2), p3 = R[c2.request.method].res; - n3 ? (p3.internal = D(g$1({}, p3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(t2, a3, p3)) : this.client.core.relayer.publish(t2, a3, p3).catch((d3) => this.client.logger.error(d3)), await this.client.core.history.resolve(o2); - }, this.sendError = async (e, s2, t2) => { - const i2 = formatJsonRpcError(e, t2), n3 = await this.client.core.crypto.encode(s2, i2), o2 = await this.client.core.history.get(s2, e), a3 = R[o2.request.method].res; - this.client.core.relayer.publish(s2, n3, a3), await this.client.core.history.resolve(i2); - }, this.cleanup = async () => { - const e = [], s2 = []; - this.client.session.getAll().forEach((t2) => { - let i2 = false; - mt$1(t2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(t2.topic) || (i2 = true), i2 && e.push(t2.topic); - }), this.client.proposal.getAll().forEach((t2) => { - mt$1(t2.expiryTimestamp) && s2.push(t2.id); - }), await Promise.all([...e.map((t2) => this.deleteSession({ topic: t2 })), ...s2.map((t2) => this.deleteProposal(t2))]); - }, this.onRelayEventRequest = async (e) => { - this.requestQueue.queue.push(e), await this.processRequestsQueue(); - }, this.processRequestsQueue = async () => { - if (this.requestQueue.state === I.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 = I.active; - const e = this.requestQueue.queue.shift(); - if (e) - try { - this.processRequest(e), await new Promise((s2) => setTimeout(s2, 300)); - } catch (s2) { - this.client.logger.warn(s2); - } - } - this.requestQueue.state = I.idle; - }, this.processRequest = (e) => { - const { topic: s2, payload: t2 } = e, i2 = t2.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeRequest(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleRequest(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateRequest(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendRequest(s2, t2); - case "wc_sessionPing": - return this.onSessionPingRequest(s2, t2); - case "wc_sessionDelete": - return this.onSessionDeleteRequest(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequest(s2, t2); - case "wc_sessionEvent": - return this.onSessionEventRequest(s2, t2); - default: - return this.client.logger.info(`Unsupported request method ${i2}`); - } - }, this.onRelayEventResponse = async (e) => { - const { topic: s2, payload: t2 } = e, i2 = (await this.client.core.history.get(s2, t2.id)).request.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeResponse(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleResponse(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateResponse(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendResponse(s2, t2); - case "wc_sessionPing": - return this.onSessionPingResponse(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequestResponse(s2, t2); - default: - return this.client.logger.info(`Unsupported response method ${i2}`); - } - }, this.onRelayEventUnknownPayload = (e) => { - const { topic: s2 } = e, { message: t2 } = N$1("MISSING_OR_INVALID", `Decoded payload on topic ${s2} is not identifiable as a JSON-RPC request or a response.`); - throw new Error(t2); - }, this.onSessionProposeRequest = async (e, s2) => { - const { params: t2, id: i2 } = s2; - try { - this.isValidConnect(g$1({}, s2.params)); - const n3 = t2.expiryTimestamp || pt$1(R.wc_sessionPropose.req.ttl), o2 = g$1({ id: i2, pairingTopic: e, expiryTimestamp: n3 }, t2); - await this.setProposal(i2, o2); - const a3 = Ln(JSON.stringify(s2)), c2 = await this.getVerifyContext(a3, o2.proposer.metadata); - this.client.events.emit("session_proposal", { id: i2, params: o2, verifyContext: c2 }); - } catch (n3) { - await this.sendError(i2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionProposeResponse = async (e, s2) => { - const { id: t2 } = s2; - if (isJsonRpcResult(s2)) { - const { result: i2 } = s2; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); - const n3 = this.client.proposal.get(t2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: n3 }); - const o2 = n3.proposer.publicKey; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o2 }); - const a3 = i2.responderPublicKey; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a3 }); - const c2 = await this.client.core.crypto.generateSharedKey(o2, a3); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); - const p3 = await this.client.core.relayer.subscribe(c2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: p3 }), await this.client.core.pairing.activate({ topic: e }); - } else - isJsonRpcError(s2) && (await this.client.proposal.delete(t2, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_connect"), { error: s2.error })); - }, this.onSessionSettleRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; - try { - this.isValidSessionSettleRequest(i2); - const { relay: n3, controller: o2, expiry: a3, namespaces: c2, sessionProperties: p3, pairingTopic: d3 } = s2.params, h4 = g$1({ topic: e, relay: n3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: d3, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, p3 && { sessionProperties: p3 }); - await this.sendResult({ id: s2.id, topic: e, result: true }), this.events.emit(yt$1("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionSettleResponse = async (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? (await this.client.session.update(e, { acknowledged: true }), this.events.emit(yt$1("session_approve", t2), {})) : isJsonRpcError(s2) && (await this.client.session.delete(e, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_approve", t2), { error: s2.error })); - }, this.onSessionUpdateRequest = async (e, s2) => { - const { params: t2, id: i2 } = s2; - try { - const n3 = `${e}_session_update`, o2 = sr$1.get(n3); - if (o2 && this.isRequestOutOfSync(o2, i2)) { - this.client.logger.info(`Discarding out of sync request - ${i2}`); - return; - } - this.isValidUpdate(g$1({ topic: e }, t2)), await this.client.session.update(e, { namespaces: t2.namespaces }), await this.sendResult({ id: i2, topic: e, result: true }), this.client.events.emit("session_update", { id: i2, topic: e, params: t2 }), sr$1.set(n3, i2); - } catch (n3) { - await this.sendError(i2, e, n3), this.client.logger.error(n3); - } - }, this.isRequestOutOfSync = (e, s2) => parseInt(s2.toString().slice(0, -3)) <= parseInt(e.toString().slice(0, -3)), this.onSessionUpdateResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_update", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_update", t2), { error: s2.error }); - }, this.onSessionExtendRequest = async (e, s2) => { - const { id: t2 } = s2; - try { - this.isValidExtend({ topic: e }), await this.setExpiry(e, pt$1(L)), await this.sendResult({ id: t2, topic: e, result: true }), this.client.events.emit("session_extend", { id: t2, topic: e }); - } catch (i2) { - await this.sendError(t2, e, i2), this.client.logger.error(i2); - } - }, this.onSessionExtendResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_extend", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_extend", t2), { error: s2.error }); - }, this.onSessionPingRequest = async (e, s2) => { - const { id: t2 } = s2; - try { - this.isValidPing({ topic: e }), await this.sendResult({ id: t2, topic: e, result: true }), this.client.events.emit("session_ping", { id: t2, topic: e }); - } catch (i2) { - await this.sendError(t2, e, i2), this.client.logger.error(i2); - } - }, this.onSessionPingResponse = (e, s2) => { - const { id: t2 } = s2; - setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_ping", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_ping", t2), { error: s2.error }); - }, 500); - }, this.onSessionDeleteRequest = async (e, s2) => { - const { id: t2 } = s2; - try { - this.isValidDisconnect({ topic: e, reason: s2.params }), await Promise.all([new Promise((i2) => { - this.client.core.relayer.once(D$1.publish, async () => { - i2(await this.deleteSession({ topic: e, id: t2 })); - }); - }), this.sendResult({ id: t2, topic: e, result: true }), this.cleanupPendingSentRequestsForTopic({ topic: e, error: U$2("USER_DISCONNECTED") })]); - } catch (i2) { - this.client.logger.error(i2); - } - }, this.onSessionRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; - try { - this.isValidRequest(g$1({ topic: e }, i2)); - const n3 = Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, t2))), o2 = this.client.session.get(e), a3 = await this.getVerifyContext(n3, o2.peer.metadata), c2 = { id: t2, topic: e, params: i2, verifyContext: a3 }; - await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionRequestResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_request", t2), { result: s2.result }) : isJsonRpcError(s2) && this.events.emit(yt$1("session_request", t2), { error: s2.error }); - }, this.onSessionEventRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; - try { - const n3 = `${e}_session_event_${i2.event.name}`, o2 = sr$1.get(n3); - if (o2 && this.isRequestOutOfSync(o2, t2)) { - this.client.logger.info(`Discarding out of sync request - ${t2}`); - return; - } - this.isValidEmit(g$1({ topic: e }, i2)), this.client.events.emit("session_event", { id: t2, topic: e, params: i2 }), sr$1.set(n3, t2); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.addSessionRequestToSessionRequestQueue = (e) => { - this.sessionRequestQueue.queue.push(e); - }, this.cleanupAfterResponse = (e) => { - this.deletePendingSessionRequest(e.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { - this.sessionRequestQueue.state = I.idle, this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay)); - }, this.cleanupPendingSentRequestsForTopic = ({ topic: e, error: s2 }) => { - const t2 = this.client.core.history.pending; - t2.length > 0 && t2.filter((i2) => i2.topic === e && i2.request.method === "wc_sessionRequest").forEach((i2) => { - this.events.emit(yt$1("session_request", i2.request.id), { error: s2 }); - }); - }, this.processSessionRequestQueue = () => { - if (this.sessionRequestQueue.state === I.active) { - this.client.logger.info("session request queue is already active."); - return; - } - const e = this.sessionRequestQueue.queue[0]; - if (!e) { - this.client.logger.info("session request queue is empty."); - return; - } - try { - this.sessionRequestQueue.state = I.active, this.client.events.emit("session_request", e); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.onPairingCreated = (e) => { - if (e.active) - return; - const s2 = this.client.proposal.getAll().find((t2) => t2.pairingTopic === e.topic); - s2 && this.onSessionProposeRequest(e.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: s2.requiredNamespaces, optionalNamespaces: s2.optionalNamespaces, relays: s2.relays, proposer: s2.proposer, sessionProperties: s2.sessionProperties }, s2.id)); - }, this.isValidConnect = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(e)}`); - throw new Error(a3); - } - const { pairingTopic: s2, requiredNamespaces: t2, optionalNamespaces: i2, sessionProperties: n3, relays: o2 } = e; - if (w$3(s2) || await this.isValidPairingTopic(s2), !qt$1(o2, true)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() relays: ${o2}`); - throw new Error(a3); - } - !w$3(t2) && B$1(t2) !== 0 && this.validateNamespaces(t2, "requiredNamespaces"), !w$3(i2) && B$1(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.validateNamespaces = (e, s2) => { - const t2 = Ht$1(e, "connect()", s2); - if (t2) - throw new Error(t2.message); - }, this.isValidApprove = async (e) => { - if (!Gt$1(e)) - throw new Error(N$1("MISSING_OR_INVALID", `approve() params: ${e}`).message); - const { id: s2, namespaces: t2, relayProtocol: i2, sessionProperties: n3 } = e; - await this.isValidProposalId(s2); - const o2 = this.client.proposal.get(s2), a3 = ln(t2, "approve()"); - if (a3) - throw new Error(a3.message); - const c2 = fn(o2.requiredNamespaces, t2, "approve()"); - if (c2) - throw new Error(c2.message); - if (!g$3(i2, true)) { - const { message: p3 } = N$1("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); - throw new Error(p3); - } - w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.isValidReject = async (e) => { - if (!Gt$1(e)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() params: ${e}`); - throw new Error(i2); - } - const { id: s2, reason: t2 } = e; - if (await this.isValidProposalId(s2), !Wt(t2)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(t2)}`); - throw new Error(i2); - } - }, this.isValidSessionSettleRequest = (e) => { - if (!Gt$1(e)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${e}`); - throw new Error(c2); - } - const { relay: s2, controller: t2, namespaces: i2, expiry: n3 } = e; - if (!dn(s2)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); - throw new Error(c2); - } - const o2 = Ft$1(t2, "onSessionSettleRequest()"); - if (o2) - throw new Error(o2.message); - const a3 = ln(i2, "onSessionSettleRequest()"); - if (a3) - throw new Error(a3.message); - if (mt$1(n3)) { - const { message: c2 } = N$1("EXPIRED", "onSessionSettleRequest()"); - throw new Error(c2); - } - }, this.isValidUpdate = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `update() params: ${e}`); - throw new Error(a3); - } - const { topic: s2, namespaces: t2 } = e; - await this.isValidSessionTopic(s2); - const i2 = this.client.session.get(s2), n3 = ln(t2, "update()"); - if (n3) - throw new Error(n3.message); - const o2 = fn(i2.requiredNamespaces, t2, "update()"); - if (o2) - throw new Error(o2.message); - }, this.isValidExtend = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `extend() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionTopic(s2); - }, this.isValidRequest = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() params: ${e}`); - throw new Error(a3); - } - const { topic: s2, request: t2, chainId: i2, expiry: n3 } = e; - await this.isValidSessionTopic(s2); - const { namespaces: o2 } = this.client.session.get(s2); - if (!Qt(o2, i2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() chainId: ${i2}`); - throw new Error(a3); - } - if (!zt$1(t2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() ${JSON.stringify(t2)}`); - throw new Error(a3); - } - if (!Zt(o2, i2, t2.method)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() method: ${t2.method}`); - throw new Error(a3); - } - if (n3 && !tr$1(n3, U$1)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() expiry: ${n3}. Expiry must be a number (in seconds) between ${U$1.min} and ${U$1.max}`); - throw new Error(a3); - } - }, this.isValidRespond = async (e) => { - var s2; - if (!Gt$1(e)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() params: ${e}`); - throw new Error(n3); - } - const { topic: t2, response: i2 } = e; - try { - await this.isValidSessionTopic(t2); - } catch (n3) { - throw (s2 = e == null ? void 0 : e.response) != null && s2.id && this.cleanupAfterResponse(e), n3; - } - if (!Yt$1(i2)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); - throw new Error(n3); - } - }, this.isValidPing = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `ping() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionOrPairingTopic(s2); - }, this.isValidEmit = async (e) => { - if (!Gt$1(e)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() params: ${e}`); - throw new Error(o2); - } - const { topic: s2, event: t2, chainId: i2 } = e; - await this.isValidSessionTopic(s2); - const { namespaces: n3 } = this.client.session.get(s2); - if (!Qt(n3, i2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() chainId: ${i2}`); - throw new Error(o2); - } - if (!Jt$1(t2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); - throw new Error(o2); - } - if (!Xt(n3, i2, t2.name)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); - throw new Error(o2); - } - }, this.isValidDisconnect = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionOrPairingTopic(s2); - }, this.getVerifyContext = async (e, s2) => { - const t2 = { verified: { verifyUrl: s2.verifyUrl || F$1, validation: "UNKNOWN", origin: s2.url || "" } }; - try { - const i2 = await this.client.core.verify.resolve({ attestationId: e, verifyUrl: s2.verifyUrl }); - i2 && (t2.verified.origin = i2.origin, t2.verified.isScam = i2.isScam, t2.verified.validation = i2.origin === new URL(s2.url).origin ? "VALID" : "INVALID"); - } catch (i2) { - this.client.logger.info(i2); - } - return this.client.logger.info(`Verify context: ${JSON.stringify(t2)}`), t2; - }, this.validateSessionProps = (e, s2) => { - Object.values(e).forEach((t2) => { - if (!g$3(t2, false)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `${s2} must be in Record format. Received: ${JSON.stringify(t2)}`); - throw new Error(i2); - } - }); - }; - } - async isInitialized() { - if (!this.initialized) { - const { message: r2 } = N$1("NOT_INITIALIZED", this.name); - throw new Error(r2); - } - await this.client.core.relayer.confirmOnlineStateOrThrow(); - } - registerRelayerEvents() { - this.client.core.relayer.on(D$1.message, async (r2) => { - const { topic: e, message: s2 } = r2; - if (this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s2))) - return; - const t2 = await this.client.core.crypto.decode(e, s2); - try { - isJsonRpcRequest(t2) ? (this.client.core.history.set(e, t2), this.onRelayEventRequest({ topic: e, payload: t2 })) : isJsonRpcResponse(t2) ? (await this.client.core.history.resolve(t2), await this.onRelayEventResponse({ topic: e, payload: t2 }), this.client.core.history.delete(e, t2.id)) : this.onRelayEventUnknownPayload({ topic: e, payload: t2 }); - } catch (i2) { - this.client.logger.error(i2); - } - }); - } - registerExpirerEvents() { - this.client.core.expirer.on(v2.expired, async (r2) => { - const { topic: e, id: s2 } = ft$1(r2.target); - if (s2 && this.client.pendingRequest.keys.includes(s2)) - return await this.deletePendingSessionRequest(s2, N$1("EXPIRED"), true); - e ? this.client.session.keys.includes(e) && (await this.deleteSession({ topic: e, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: e })) : s2 && (await this.deleteProposal(s2, true), this.client.events.emit("proposal_expire", { id: s2 })); - }); - } - registerPairingEvents() { - this.client.core.pairing.events.on(V.create, (r2) => this.onPairingCreated(r2)); - } - isValidPairingTopic(r2) { - if (!g$3(r2, false)) { - const { message: e } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${r2}`); - throw new Error(e); - } - if (!this.client.core.pairing.pairings.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${r2}`); - throw new Error(e); - } - if (mt$1(this.client.core.pairing.pairings.get(r2).expiry)) { - const { message: e } = N$1("EXPIRED", `pairing topic: ${r2}`); - throw new Error(e); - } - } - async isValidSessionTopic(r2) { - if (!g$3(r2, false)) { - const { message: e } = N$1("MISSING_OR_INVALID", `session topic should be a string: ${r2}`); - throw new Error(e); - } - if (!this.client.session.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `session topic doesn't exist: ${r2}`); - throw new Error(e); - } - if (mt$1(this.client.session.get(r2).expiry)) { - await this.deleteSession({ topic: r2 }); - const { message: e } = N$1("EXPIRED", `session topic: ${r2}`); - throw new Error(e); - } - if (!this.client.core.crypto.keychain.has(r2)) { - const { message: e } = N$1("MISSING_OR_INVALID", `session topic does not exist in keychain: ${r2}`); - throw await this.deleteSession({ topic: r2 }), new Error(e); - } - } - async isValidSessionOrPairingTopic(r2) { - if (this.client.session.keys.includes(r2)) - await this.isValidSessionTopic(r2); - else if (this.client.core.pairing.pairings.keys.includes(r2)) - this.isValidPairingTopic(r2); - else if (g$3(r2, false)) { - const { message: e } = N$1("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${r2}`); - throw new Error(e); - } else { - const { message: e } = N$1("MISSING_OR_INVALID", `session or pairing topic should be a string: ${r2}`); - throw new Error(e); - } - } - async isValidProposalId(r2) { - if (!Bt$1(r2)) { - const { message: e } = N$1("MISSING_OR_INVALID", `proposal id should be a number: ${r2}`); - throw new Error(e); - } - if (!this.client.proposal.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `proposal id doesn't exist: ${r2}`); - throw new Error(e); - } - if (mt$1(this.client.proposal.get(r2).expiryTimestamp)) { - await this.deleteProposal(r2); - const { message: e } = N$1("EXPIRED", `proposal id: ${r2}`); - throw new Error(e); - } - } -} -class us extends Kt { - constructor(r2, e) { - super(r2, e, oe, G), this.core = r2, this.logger = e; - } -} -class ge extends Kt { - constructor(r2, e) { - super(r2, e, ce, G), this.core = r2, this.logger = e; - } -} -class gs extends Kt { - constructor(r2, e) { - super(r2, e, pe, G, (s2) => s2.id), this.core = r2, this.logger = e; - } -} -class Q extends b$1 { - constructor(r2) { - super(r2), this.protocol = J, this.version = F, this.name = M.name, this.events = new eventsExports.EventEmitter(), this.on = (s2, t2) => this.events.on(s2, t2), this.once = (s2, t2) => this.events.once(s2, t2), this.off = (s2, t2) => this.events.off(s2, t2), this.removeListener = (s2, t2) => this.events.removeListener(s2, t2), this.removeAllListeners = (s2) => this.events.removeAllListeners(s2), this.connect = async (s2) => { - try { - return await this.engine.connect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.pair = async (s2) => { - try { - return await this.engine.pair(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.approve = async (s2) => { - try { - return await this.engine.approve(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.reject = async (s2) => { - try { - return await this.engine.reject(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.update = async (s2) => { - try { - return await this.engine.update(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.extend = async (s2) => { - try { - return await this.engine.extend(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.request = async (s2) => { - try { - return await this.engine.request(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.respond = async (s2) => { - try { - return await this.engine.respond(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.ping = async (s2) => { - try { - return await this.engine.ping(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.emit = async (s2) => { - try { - return await this.engine.emit(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.disconnect = async (s2) => { - try { - return await this.engine.disconnect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.find = (s2) => { - try { - return this.engine.find(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.getPendingSessionRequests = () => { - try { - return this.engine.getPendingSessionRequests(); - } catch (s2) { - throw this.logger.error(s2.message), s2; - } - }, this.name = (r2 == null ? void 0 : r2.name) || M.name, this.metadata = (r2 == null ? void 0 : r2.metadata) || Qn(); - const e = typeof (r2 == null ? void 0 : r2.logger) < "u" && typeof (r2 == null ? void 0 : r2.logger) != "string" ? r2.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (r2 == null ? void 0 : r2.logger) || M.logger })); - this.core = (r2 == null ? void 0 : r2.core) || new Mr(r2), this.logger = cjs$3.generateChildLogger(e, this.name), this.session = new ge(this.core, this.logger), this.proposal = new us(this.core, this.logger), this.pendingRequest = new gs(this.core, this.logger), this.engine = new ds(this); - } - static async init(r2) { - const e = new Q(r2); - return await e.initialize(), e; - } - get context() { - return cjs$3.getLoggerContext(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.engine.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); - } catch (r2) { - throw this.logger.info("SignClient Initialization Failure"), this.logger.error(r2.message), r2; - } - } -} -var P = Object.defineProperty, x = Object.defineProperties, N = Object.getOwnPropertyDescriptors, j = Object.getOwnPropertySymbols, U = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable, W = (e, t2, s2) => t2 in e ? P(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, q = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - U.call(t2, s2) && W(e, s2, t2[s2]); - if (j) - for (var s2 of j(t2)) - T.call(t2, s2) && W(e, s2, t2[s2]); - return e; -}, A = (e, t2) => x(e, N(t2)), S = (e, t2, s2) => { - if (!t2.has(e)) - throw TypeError("Cannot " + s2); -}, a2 = (e, t2, s2) => (S(e, t2, "read from private field"), s2 ? s2.call(e) : t2.get(e)), l = (e, t2, s2) => { - if (t2.has(e)) - throw TypeError("Cannot add the same private member more than once"); - t2 instanceof WeakSet ? t2.add(e) : t2.set(e, s2); -}, y2 = (e, t2, s2, d3) => (S(e, t2, "write to private field"), d3 ? d3.call(e, s2) : t2.set(e, s2), s2), o = (e, t2, s2) => (S(e, t2, "access private method"), s2), h3, p2, w2, i, u2, _2, n2, r, m, g2; -let z$1 = class z { - constructor(t2) { - l(this, u2), l(this, n2), l(this, m), l(this, h3, void 0), l(this, p2, void 0), l(this, w2, void 0), l(this, i, void 0), y2(this, h3, t2), y2(this, p2, o(this, u2, _2).call(this)), o(this, n2, r).call(this); - } - async connect(t2) { - const { requiredNamespaces: s2, optionalNamespaces: d3 } = t2; - return new Promise(async (C2, b3) => { - await o(this, n2, r).call(this); - const E2 = a2(this, p2).subscribeModal((c2) => { - c2.open || (E2(), b3(new Error("Modal closed"))); - }), { uri: O2, approval: I2 } = await a2(this, i).connect(t2); - if (O2) { - const c2 = /* @__PURE__ */ new Set(); - s2 && Object.values(s2).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), d3 && Object.values(d3).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), await a2(this, p2).openModal({ uri: O2, chains: Array.from(c2) }); - } - try { - const c2 = await I2(); - C2(c2); - } catch (c2) { - b3(c2); - } finally { - E2(), a2(this, p2).closeModal(); - } - }); - } - async disconnect(t2) { - await o(this, n2, r).call(this), await a2(this, i).disconnect(t2); - } - async request(t2) { - return await o(this, n2, r).call(this), await a2(this, i).request(t2); - } - async getSessions() { - return await o(this, n2, r).call(this), a2(this, i).session.getAll(); - } - async getSession() { - return await o(this, n2, r).call(this), a2(this, i).session.getAll().at(-1); - } - async onSessionEvent(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_event", t2); - } - async offSessionEvent(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_event", t2); - } - async onSessionUpdate(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_update", t2); - } - async offSessionUpdate(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_update", t2); - } - async onSessionDelete(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_delete", t2); - } - async offSessionDelete(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_delete", t2); - } - async onSessionExpire(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_expire", t2); - } - async offSessionExpire(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_expire", t2); - } -}; -h3 = /* @__PURE__ */ new WeakMap(), p2 = /* @__PURE__ */ new WeakMap(), w2 = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), u2 = /* @__PURE__ */ new WeakSet(), _2 = function() { - const { modalOptions: e, projectId: t2 } = a2(this, h3); - return new d$1(A(q({}, e), { projectId: t2 })); -}, n2 = /* @__PURE__ */ new WeakSet(), r = async function() { - return a2(this, i) ? true : (!a2(this, w2) && typeof window < "u" && y2(this, w2, o(this, m, g2).call(this)), a2(this, w2)); -}, m = /* @__PURE__ */ new WeakSet(), g2 = async function() { - y2(this, i, await Q.init({ metadata: a2(this, h3).metadata, projectId: a2(this, h3).projectId, relayUrl: a2(this, h3).relayUrl })); - const e = await a2(this, i).core.crypto.getClientId(); - try { - localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e); - } catch { - console.info("Unable to set client id"); - } -}; -const wc_aleo_methods = [ - "decrypt", - "disconnect", - "getSelectedAccount", - "getBalance", - "getRecords", - "requestCreateEvent", - "getEvent", - "getEvents", - "createSharedState", - "importSharedState", - "requestSignature" -]; -const wc_aleo_chains = ["aleo:1"]; -const wc_events = [ - "chainChanged", - "accountSelected", - "selectedAccountSynced", - "sharedAccountSynced" -]; -const projectId = "f0aaeffe71b636da453fce042d79d723"; -function isAndroid() { - if (!navigator) { - return false; - } - return /Android/i.test(navigator.userAgent); -} -const web3modal_puzzle_props_android = { - projectId, - chains: ["aleo:3"], - enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png" - } -}; -const web3modal_puzzle_props_default = { - projectId, - chains: wc_aleo_chains, - enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } - } - ], - desktopWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "", - universal: "https://walletconnect.puzzle.online/" - } - }, - { - id: "avail", - name: "Avail Wallet", - links: { - native: "avail://", - universal: "https://avail.global" - } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png", - avail: "https://i.imgur.com/GxNn8BO.png" - } -}; -const web3modal_puzzle_props = isAndroid() ? web3modal_puzzle_props_android : web3modal_puzzle_props_default; -const signClient_puzzleProps = { - requiredNamespaces: { - aleo: { - methods: wc_aleo_methods, - chains: web3modal_puzzle_props.chains, - events: wc_events - } - } -}; -const name = "@puzzlehq/sdk-core"; -const displayName = "Puzzle SDK"; -const version = "0.3.1"; -const description = "Your portal to privacy"; -const main = "./dist/puzzle.cjs.js"; -const module$1 = "./dist/puzzle.es.js"; -const browser$1 = "./dist/puzzle.umd.js"; -const types = "./dist/types/src/index.d.ts"; -const exports$1 = { - ".": { - "import": "./dist/puzzle.es.js", - require: "./dist/puzzle.cjs.js", - browser: "./dist/puzzle.umd.js", - types: "./dist/types/src/index.d.ts" - } -}; -const type = "module"; -const scripts = { - "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", - "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, - build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", - "type-check": "tsc --noEmit" -}; -const repository = { - type: "git", - url: "git+https://github.com/puzzlehq/puzzle-sdk.git" -}; -const dependencies = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", - "@walletconnect/types": "^2.11.2", - "@walletconnect/utils": "^2.11.2", - debug: "^4.3.4", - events: "^3.3.0", - ws: "^8.16.0" -}; -const peerDependencies = { - buffer: "^6.0.3" -}; -const keywords = [ - "puzzle", - "cryptocurrency wallet", - "privacy", - "aleo", - "web3", - "crypto", - "typescript" -]; -const author = "Puzzle"; -const license = "ISC"; -const bugs = { - url: "https://github.com/puzzlehq/puzzle-sdk/issues" -}; -const homepage = "https://github.com/puzzlehq/puzzle-sdk#readme"; -const pkg = { - name, - displayName, - version, - description, - main, - module: module$1, - browser: browser$1, - types, - "private": false, - exports: exports$1, - type, - scripts, - repository, - dependencies, - peerDependencies, - keywords, - author, - license, - bugs, - homepage -}; -const emitter = new EventEmitter$1(); -exports.connection = void 0; -async function configureConnection(options) { - let disconnectSessions = false; - const thisVersion = pkg.version; - const prevVersion = localStorage.getItem("puzzle_sdk_version"); - if (thisVersion !== prevVersion) { - console.log( - `${pkg.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" - ); - localStorage.setItem("puzzle_sdk_version", thisVersion); - disconnectSessions = true; - } - exports.connection = new z$1({ - projectId: options.projectId ?? projectId, - metadata: { - name: options.dAppName, - description: options.dAppDescription, - url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", - icons: [options.dAppIconURL] - }, - modalOptions: { ...web3modal_puzzle_props } - }); - if (disconnectSessions) { - localStorage.removeItem("puzzle-hasInjectedConnection"); - try { - disconnectOnVersionChange(exports.connection, options.onDisconnect); - } catch (e) { - console.error(e); - } - } - exports.connection.onSessionDelete(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - exports.connection.onSessionExpire(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - if (typeof window !== "undefined") { - window.puzzleSdkConnection = exports.connection; - } - return exports.connection; -} -async function disconnectOnVersionChange(connection2, onDisconnect) { - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (session) { - console.log("Disconnecting session", session); - onDisconnect && onDisconnect(); - connection2.disconnect({ - topic: session.topic, - reason: U$2("USER_DISCONNECTED") - }); - } -} -async function getWalletConnectModalSignClient() { - return new Promise((resolve) => { - if (exports.connection) { - resolve(exports.connection); - } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { - resolve(window.puzzleSdkConnection); - } else { - const interval = setInterval(() => { - if (exports.connection) { - clearInterval(interval); - resolve(exports.connection); - } - }, 200); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - }); -} -const checkForDesktopConnection = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - try { - const res = await window.aleo.puzzleWalletClient.isConnected.query( - { sessionTopic } - ); - if (res) { - localStorage.setItem("puzzle-hasInjectedConnection", "true"); - return true; - } else { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - } catch (e) { - console.warn(e); - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } -}; -const hasInjectedConnection = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - return false; - } - const puzzleHasDesktopConnection = localStorage.getItem( - "puzzle-hasInjectedConnection" - ); - return puzzleHasDesktopConnection === "true"; -}; -const getAccount = async () => { - const connection = await getWalletConnectModalSignClient(); - const session = await connection.getSession(); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getSelectedAccount" - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getSelectedAccount.query(query); - return response; - } catch (e) { - console.error("getAccount error", e); - return { error: e.message }; - } - } - try { - const response = await connection.request(query); - return response; - } catch (e) { - console.error("getAccount error", e); - const error = e.message; - return { error }; - } -}; -const getBalance = async ({ - address -}) => { - const connection = await getWalletConnectModalSignClient(); - const session = await connection.getSession(); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getBalance", - params: { - assetId: void 0, - address - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getBalance.query(query); - return response; - } catch (e) { - const error = e.message; - console.error("getBalance error", e); - return { error }; - } - } - try { - const response = await connection.request(query); - return response; - } catch (e) { - const error = e.message; - console.error("getBalance error", e); - return { error }; - } -}; -const connect = async () => { - const connection = await getWalletConnectModalSignClient(); - if (!connection) { - throw new Error("call setConnection() first!"); - } - const existingSession = await connection.getSession(); - if (existingSession) { - console.log("Already connected!", existingSession); - return existingSession; - } - try { - const newSession = await connection.connect({ - requiredNamespaces: { - aleo: { - methods: wc_aleo_methods, - chains: wc_aleo_chains, - events: wc_events - } - } - }); - emitter.emit("session_change"); - if (newSession) { - await checkForDesktopConnection(newSession.topic); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - return newSession; - } catch (e) { - console.error("connect error", e); - } -}; -const requestCreateEvent = async (requestData) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { - if (typeof input === "string") { - return input; - } - return input.plaintext; - }); - try { - const response = await connection.request({ - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "requestCreateEvent", - params: { - ...requestData, - inputs - } - } - }); - return response; - } catch (e) { - console.error("createEvent error", e); - const error = e.message; - return { error }; - } -}; -const createSharedState = async () => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "createSharedState", - params: {} - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.createSharedState.mutate( - query - ); - return response; - } catch (e) { - console.error("createSharedState error", e); - const error = e.message; - return { error }; - } - } - try { - const response = await connection.request(query); - return response; - } catch (e) { - console.error("createSharedState error", e); - const error = e.message; - return { error }; - } -}; -const decrypt = async (ciphertexts) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "decrypt", - params: { - ciphertexts - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.decrypt.query(query); - return response; - } catch (e) { - const error = e.message; - console.error("decrypt error", e); - return { error }; - } - } - try { - const response = await connection.request(query); - return response; - } catch (e) { - console.error("decrypt error", e); - return { error: e.message }; - } -}; -const disconnect = async () => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - try { - try { - await connection.disconnect({ - reason: U$2("USER_DISCONNECTED"), - topic: session.topic - }); - localStorage.removeItem("puzzle-hasInjectedConnection"); - emitter.emit("session_change"); - } catch (e) { - console.warn(e); - } - return {}; - } catch (e) { - console.error("error disconnecting", e); - const error = e.message; - return { error }; - } -}; -const getEvent = async ({ - id, - address -}) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { event: void 0, error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getEvent", - params: { - id, - address - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getEvent.query(query); - return response; - } catch (e) { - console.error("getEvent error", e); - const error = e.message; - return { error }; - } - } - const fetchEvent = async () => { - const response = await connection.request(query); - return response; - }; - try { - const response = await fetchEvent(); - return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; - return { error }; - } -}; -const getEvents = async (filter) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { events: void 0, error: "no session or connection" }; - } - if ((filter == null ? void 0 : filter.programId) === "") { - filter.programId = void 0; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getEvents", - params: { - filter, - page: 0 - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getEvents.query(query); - return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; - return { error }; - } - } - const fetchPage = async (page = 0) => { - const response = await connection.request(query); - return response; - }; - try { - const response = await fetchPage(); - return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; - return { error }; - } -}; -const importSharedState = async (seed) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "importSharedState", - params: { - seed - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.importSharedState.mutate(query); - return response; - } catch (e) { - console.error("importSharedState error", e); - const error = e.message; - return { error }; - } - } - try { - const response = await connection.request(query); - return response; - } catch (e) { - console.error("importSharedState error", e); - const error = e.message; - return { error }; - } -}; -const getRecords = async ({ - address, - filter, - page = 0 -}) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getRecords", - params: { - address, - filter, - page - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getRecords.query(query); - return response; - } catch (e) { - console.error("getRecords error", e); - const error = e.message; - return { error }; - } - } - const fetchPage = async (page2 = 0) => { - const response = await connection.request(query); - return response; - }; - try { - const response = await fetchPage(); - return response; - } catch (e) { - console.error("getRecords error", e); - const error = e.message; - return { error }; - } -}; -var util; -(function(util2) { - util2.assertEqual = (val) => val; - function assertIs(_arg) { - } - util2.assertIs = assertIs; - function assertNever(_x) { - throw new Error(); - } - util2.assertNever = assertNever; - util2.arrayToEnum = (items) => { - const obj = {}; - for (const item of items) { - obj[item] = item; - } - return obj; - }; - util2.getValidEnumValues = (obj) => { - const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number"); - const filtered = {}; - for (const k2 of validKeys) { - filtered[k2] = obj[k2]; - } - return util2.objectValues(filtered); - }; - util2.objectValues = (obj) => { - return util2.objectKeys(obj).map(function(e) { - return obj[e]; - }); - }; - util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { - const keys2 = []; - for (const key in object) { - if (Object.prototype.hasOwnProperty.call(object, key)) { - keys2.push(key); - } - } - return keys2; - }; - util2.find = (arr, checker) => { - for (const item of arr) { - if (checker(item)) - return item; - } - return void 0; - }; - util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val; - function joinValues(array, separator = " | ") { - return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator); - } - util2.joinValues = joinValues; - util2.jsonStringifyReplacer = (_3, value) => { - if (typeof value === "bigint") { - return value.toString(); - } - return value; - }; -})(util || (util = {})); -var objectUtil; -(function(objectUtil2) { - objectUtil2.mergeShapes = (first, second) => { - return { - ...first, - ...second - // second overwrites first - }; - }; -})(objectUtil || (objectUtil = {})); -const ZodParsedType = util.arrayToEnum([ - "string", - "nan", - "number", - "integer", - "float", - "boolean", - "date", - "bigint", - "symbol", - "function", - "undefined", - "null", - "array", - "object", - "unknown", - "promise", - "void", - "never", - "map", - "set" -]); -const getParsedType = (data) => { - const t2 = typeof data; - switch (t2) { - case "undefined": - return ZodParsedType.undefined; - case "string": - return ZodParsedType.string; - case "number": - return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number; - case "boolean": - return ZodParsedType.boolean; - case "function": - return ZodParsedType.function; - case "bigint": - return ZodParsedType.bigint; - case "symbol": - return ZodParsedType.symbol; - case "object": - if (Array.isArray(data)) { - return ZodParsedType.array; - } - if (data === null) { - return ZodParsedType.null; - } - if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { - return ZodParsedType.promise; - } - if (typeof Map !== "undefined" && data instanceof Map) { - return ZodParsedType.map; - } - if (typeof Set !== "undefined" && data instanceof Set) { - return ZodParsedType.set; - } - if (typeof Date !== "undefined" && data instanceof Date) { - return ZodParsedType.date; - } - return ZodParsedType.object; - default: - return ZodParsedType.unknown; - } -}; -const ZodIssueCode = util.arrayToEnum([ - "invalid_type", - "invalid_literal", - "custom", - "invalid_union", - "invalid_union_discriminator", - "invalid_enum_value", - "unrecognized_keys", - "invalid_arguments", - "invalid_return_type", - "invalid_date", - "invalid_string", - "too_small", - "too_big", - "invalid_intersection_types", - "not_multiple_of", - "not_finite" -]); -const quotelessJson = (obj) => { - const json = JSON.stringify(obj, null, 2); - return json.replace(/"([^"]+)":/g, "$1:"); -}; -class ZodError extends Error { - constructor(issues) { - super(); - this.issues = []; - this.addIssue = (sub) => { - this.issues = [...this.issues, sub]; - }; - this.addIssues = (subs = []) => { - this.issues = [...this.issues, ...subs]; - }; - const actualProto = new.target.prototype; - if (Object.setPrototypeOf) { - Object.setPrototypeOf(this, actualProto); - } else { - this.__proto__ = actualProto; - } - this.name = "ZodError"; - this.issues = issues; - } - get errors() { - return this.issues; - } - format(_mapper) { - const mapper = _mapper || function(issue) { - return issue.message; - }; - const fieldErrors = { _errors: [] }; - const processError = (error) => { - for (const issue of error.issues) { - if (issue.code === "invalid_union") { - issue.unionErrors.map(processError); - } else if (issue.code === "invalid_return_type") { - processError(issue.returnTypeError); - } else if (issue.code === "invalid_arguments") { - processError(issue.argumentsError); - } else if (issue.path.length === 0) { - fieldErrors._errors.push(mapper(issue)); - } else { - let curr = fieldErrors; - let i2 = 0; - while (i2 < issue.path.length) { - const el = issue.path[i2]; - const terminal = i2 === issue.path.length - 1; - if (!terminal) { - curr[el] = curr[el] || { _errors: [] }; - } else { - curr[el] = curr[el] || { _errors: [] }; - curr[el]._errors.push(mapper(issue)); - } - curr = curr[el]; - i2++; - } - } - } - }; - processError(this); - return fieldErrors; - } - toString() { - return this.message; - } - get message() { - return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2); - } - get isEmpty() { - return this.issues.length === 0; - } - flatten(mapper = (issue) => issue.message) { - const fieldErrors = {}; - const formErrors = []; - for (const sub of this.issues) { - if (sub.path.length > 0) { - fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; - fieldErrors[sub.path[0]].push(mapper(sub)); - } else { - formErrors.push(mapper(sub)); - } - } - return { formErrors, fieldErrors }; - } - get formErrors() { - return this.flatten(); - } -} -ZodError.create = (issues) => { - const error = new ZodError(issues); - return error; -}; -const errorMap = (issue, _ctx) => { - let message; - switch (issue.code) { - case ZodIssueCode.invalid_type: - if (issue.received === ZodParsedType.undefined) { - message = "Required"; - } else { - message = `Expected ${issue.expected}, received ${issue.received}`; - } - break; - case ZodIssueCode.invalid_literal: - message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`; - break; - case ZodIssueCode.unrecognized_keys: - message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`; - break; - case ZodIssueCode.invalid_union: - message = `Invalid input`; - break; - case ZodIssueCode.invalid_union_discriminator: - message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`; - break; - case ZodIssueCode.invalid_enum_value: - message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`; - break; - case ZodIssueCode.invalid_arguments: - message = `Invalid function arguments`; - break; - case ZodIssueCode.invalid_return_type: - message = `Invalid function return type`; - break; - case ZodIssueCode.invalid_date: - message = `Invalid date`; - break; - case ZodIssueCode.invalid_string: - if (typeof issue.validation === "object") { - if ("includes" in issue.validation) { - message = `Invalid input: must include "${issue.validation.includes}"`; - if (typeof issue.validation.position === "number") { - message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; - } - } else if ("startsWith" in issue.validation) { - message = `Invalid input: must start with "${issue.validation.startsWith}"`; - } else if ("endsWith" in issue.validation) { - message = `Invalid input: must end with "${issue.validation.endsWith}"`; - } else { - util.assertNever(issue.validation); - } - } else if (issue.validation !== "regex") { - message = `Invalid ${issue.validation}`; - } else { - message = "Invalid"; - } - break; - case ZodIssueCode.too_small: - if (issue.type === "array") - message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`; - else if (issue.type === "string") - message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`; - else if (issue.type === "number") - message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`; - else if (issue.type === "date") - message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`; - else - message = "Invalid input"; - break; - case ZodIssueCode.too_big: - if (issue.type === "array") - message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`; - else if (issue.type === "string") - message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`; - else if (issue.type === "number") - message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; - else if (issue.type === "bigint") - message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; - else if (issue.type === "date") - message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`; - else - message = "Invalid input"; - break; - case ZodIssueCode.custom: - message = `Invalid input`; - break; - case ZodIssueCode.invalid_intersection_types: - message = `Intersection results could not be merged`; - break; - case ZodIssueCode.not_multiple_of: - message = `Number must be a multiple of ${issue.multipleOf}`; - break; - case ZodIssueCode.not_finite: - message = "Number must be finite"; - break; - default: - message = _ctx.defaultError; - util.assertNever(issue); - } - return { message }; -}; -let overrideErrorMap = errorMap; -function setErrorMap(map) { - overrideErrorMap = map; -} -function getErrorMap() { - return overrideErrorMap; -} -const makeIssue = (params) => { - const { data, path, errorMaps, issueData } = params; - const fullPath = [...path, ...issueData.path || []]; - const fullIssue = { - ...issueData, - path: fullPath - }; - let errorMessage = ""; - const maps = errorMaps.filter((m2) => !!m2).slice().reverse(); - for (const map of maps) { - errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; - } - return { - ...issueData, - path: fullPath, - message: issueData.message || errorMessage - }; -}; -const EMPTY_PATH = []; -function addIssueToContext(ctx, issueData) { - const issue = makeIssue({ - issueData, - data: ctx.data, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap(), - errorMap - // then global default map - ].filter((x2) => !!x2) - }); - ctx.common.issues.push(issue); -} -class ParseStatus { - constructor() { - this.value = "valid"; - } - dirty() { - if (this.value === "valid") - this.value = "dirty"; - } - abort() { - if (this.value !== "aborted") - this.value = "aborted"; - } - static mergeArray(status, results) { - const arrayValue = []; - for (const s2 of results) { - if (s2.status === "aborted") - return INVALID; - if (s2.status === "dirty") - status.dirty(); - arrayValue.push(s2.value); - } - return { status: status.value, value: arrayValue }; - } - static async mergeObjectAsync(status, pairs) { - const syncPairs = []; - for (const pair of pairs) { - syncPairs.push({ - key: await pair.key, - value: await pair.value - }); - } - return ParseStatus.mergeObjectSync(status, syncPairs); - } - static mergeObjectSync(status, pairs) { - const finalObject = {}; - for (const pair of pairs) { - const { key, value } = pair; - if (key.status === "aborted") - return INVALID; - if (value.status === "aborted") - return INVALID; - if (key.status === "dirty") - status.dirty(); - if (value.status === "dirty") - status.dirty(); - if (typeof value.value !== "undefined" || pair.alwaysSet) { - finalObject[key.value] = value.value; - } - } - return { status: status.value, value: finalObject }; - } -} -const INVALID = Object.freeze({ - status: "aborted" -}); -const DIRTY = (value) => ({ status: "dirty", value }); -const OK = (value) => ({ status: "valid", value }); -const isAborted = (x2) => x2.status === "aborted"; -const isDirty = (x2) => x2.status === "dirty"; -const isValid = (x2) => x2.status === "valid"; -const isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise; -var errorUtil; -(function(errorUtil2) { - errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {}; - errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; -})(errorUtil || (errorUtil = {})); -class ParseInputLazyPath { - constructor(parent, value, path, key) { - this._cachedPath = []; - this.parent = parent; - this.data = value; - this._path = path; - this._key = key; - } - get path() { - if (!this._cachedPath.length) { - if (this._key instanceof Array) { - this._cachedPath.push(...this._path, ...this._key); - } else { - this._cachedPath.push(...this._path, this._key); - } - } - return this._cachedPath; - } -} -const handleResult = (ctx, result) => { - if (isValid(result)) { - return { success: true, data: result.value }; - } else { - if (!ctx.common.issues.length) { - throw new Error("Validation failed but no issues detected."); - } - return { - success: false, - get error() { - if (this._error) - return this._error; - const error = new ZodError(ctx.common.issues); - this._error = error; - return this._error; - } - }; - } -}; -function processCreateParams(params) { - if (!params) - return {}; - const { errorMap: errorMap2, invalid_type_error, required_error, description: description2 } = params; - if (errorMap2 && (invalid_type_error || required_error)) { - throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); - } - if (errorMap2) - return { errorMap: errorMap2, description: description2 }; - const customMap = (iss, ctx) => { - if (iss.code !== "invalid_type") - return { message: ctx.defaultError }; - if (typeof ctx.data === "undefined") { - return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError }; - } - return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError }; - }; - return { errorMap: customMap, description: description2 }; -} -class ZodType { - constructor(def) { - this.spa = this.safeParseAsync; - this._def = def; - this.parse = this.parse.bind(this); - this.safeParse = this.safeParse.bind(this); - this.parseAsync = this.parseAsync.bind(this); - this.safeParseAsync = this.safeParseAsync.bind(this); - this.spa = this.spa.bind(this); - this.refine = this.refine.bind(this); - this.refinement = this.refinement.bind(this); - this.superRefine = this.superRefine.bind(this); - this.optional = this.optional.bind(this); - this.nullable = this.nullable.bind(this); - this.nullish = this.nullish.bind(this); - this.array = this.array.bind(this); - this.promise = this.promise.bind(this); - this.or = this.or.bind(this); - this.and = this.and.bind(this); - this.transform = this.transform.bind(this); - this.brand = this.brand.bind(this); - this.default = this.default.bind(this); - this.catch = this.catch.bind(this); - this.describe = this.describe.bind(this); - this.pipe = this.pipe.bind(this); - this.isNullable = this.isNullable.bind(this); - this.isOptional = this.isOptional.bind(this); - } - get description() { - return this._def.description; - } - _getType(input) { - return getParsedType(input.data); - } - _getOrReturnCtx(input, ctx) { - return ctx || { - common: input.parent.common, - data: input.data, - parsedType: getParsedType(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - }; - } - _processInputParams(input) { - return { - status: new ParseStatus(), - ctx: { - common: input.parent.common, - data: input.data, - parsedType: getParsedType(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - } - }; - } - _parseSync(input) { - const result = this._parse(input); - if (isAsync(result)) { - throw new Error("Synchronous parse encountered promise."); - } - return result; - } - _parseAsync(input) { - const result = this._parse(input); - return Promise.resolve(result); - } - parse(data, params) { - const result = this.safeParse(data, params); - if (result.success) - return result.data; - throw result.error; - } - safeParse(data, params) { - var _a; - const ctx = { - common: { - issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, - contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap - }, - path: (params === null || params === void 0 ? void 0 : params.path) || [], - schemaErrorMap: this._def.errorMap, - parent: null, - data, - parsedType: getParsedType(data) - }; - const result = this._parseSync({ data, path: ctx.path, parent: ctx }); - return handleResult(ctx, result); - } - async parseAsync(data, params) { - const result = await this.safeParseAsync(data, params); - if (result.success) - return result.data; - throw result.error; - } - async safeParseAsync(data, params) { - const ctx = { - common: { - issues: [], - contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap, - async: true - }, - path: (params === null || params === void 0 ? void 0 : params.path) || [], - schemaErrorMap: this._def.errorMap, - parent: null, - data, - parsedType: getParsedType(data) - }; - const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }); - const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); - return handleResult(ctx, result); - } - refine(check, message) { - const getIssueProperties = (val) => { - if (typeof message === "string" || typeof message === "undefined") { - return { message }; - } else if (typeof message === "function") { - return message(val); - } else { - return message; - } - }; - return this._refinement((val, ctx) => { - const result = check(val); - const setError = () => ctx.addIssue({ - code: ZodIssueCode.custom, - ...getIssueProperties(val) - }); - if (typeof Promise !== "undefined" && result instanceof Promise) { - return result.then((data) => { - if (!data) { - setError(); - return false; - } else { - return true; - } - }); - } - if (!result) { - setError(); - return false; - } else { - return true; - } - }); - } - refinement(check, refinementData) { - return this._refinement((val, ctx) => { - if (!check(val)) { - ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData); - return false; - } else { - return true; - } - }); - } - _refinement(refinement) { - return new ZodEffects({ - schema: this, - typeName: ZodFirstPartyTypeKind.ZodEffects, - effect: { type: "refinement", refinement } - }); - } - superRefine(refinement) { - return this._refinement(refinement); - } - optional() { - return ZodOptional.create(this, this._def); - } - nullable() { - return ZodNullable.create(this, this._def); - } - nullish() { - return this.nullable().optional(); - } - array() { - return ZodArray.create(this, this._def); - } - promise() { - return ZodPromise.create(this, this._def); - } - or(option) { - return ZodUnion.create([this, option], this._def); - } - and(incoming) { - return ZodIntersection.create(this, incoming, this._def); - } - transform(transform) { - return new ZodEffects({ - ...processCreateParams(this._def), - schema: this, - typeName: ZodFirstPartyTypeKind.ZodEffects, - effect: { type: "transform", transform } - }); - } - default(def) { - const defaultValueFunc = typeof def === "function" ? def : () => def; - return new ZodDefault({ - ...processCreateParams(this._def), - innerType: this, - defaultValue: defaultValueFunc, - typeName: ZodFirstPartyTypeKind.ZodDefault - }); - } - brand() { - return new ZodBranded({ - typeName: ZodFirstPartyTypeKind.ZodBranded, - type: this, - ...processCreateParams(this._def) - }); - } - catch(def) { - const catchValueFunc = typeof def === "function" ? def : () => def; - return new ZodCatch({ - ...processCreateParams(this._def), - innerType: this, - catchValue: catchValueFunc, - typeName: ZodFirstPartyTypeKind.ZodCatch - }); - } - describe(description2) { - const This = this.constructor; - return new This({ - ...this._def, - description: description2 - }); - } - pipe(target) { - return ZodPipeline.create(this, target); - } - isOptional() { - return this.safeParse(void 0).success; - } - isNullable() { - return this.safeParse(null).success; - } -} -const cuidRegex = /^c[^\s-]{8,}$/i; -const cuid2Regex = /^[a-z][a-z0-9]*$/; -const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/; -const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; -const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/; -const emojiRegex = new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u"); -const ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; -const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/; -const datetimeRegex = (args) => { - if (args.precision) { - if (args.offset) { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); - } else { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`); - } - } else if (args.precision === 0) { - if (args.offset) { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); - } else { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`); - } - } else { - if (args.offset) { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`); - } else { - return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`); - } - } -}; -function isValidIP(ip, version2) { - if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) { - return true; - } - if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) { - return true; - } - return false; -} -class ZodString extends ZodType { - constructor() { - super(...arguments); - this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), { - validation, - code: ZodIssueCode.invalid_string, - ...errorUtil.errToObj(message) - }); - this.nonempty = (message) => this.min(1, errorUtil.errToObj(message)); - this.trim = () => new ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "trim" }] - }); - this.toLowerCase = () => new ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "toLowerCase" }] - }); - this.toUpperCase = () => new ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "toUpperCase" }] - }); - } - _parse(input) { - if (this._def.coerce) { - input.data = String(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.string) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext( - ctx2, - { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.string, - received: ctx2.parsedType - } - // - ); - return INVALID; - } - const status = new ParseStatus(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.length < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: check.value, - type: "string", - inclusive: true, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.length > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: check.value, - type: "string", - inclusive: true, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "length") { - const tooBig = input.data.length > check.value; - const tooSmall = input.data.length < check.value; - if (tooBig || tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - if (tooBig) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: check.value, - type: "string", - inclusive: true, - exact: true, - message: check.message - }); - } else if (tooSmall) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: check.value, - type: "string", - inclusive: true, - exact: true, - message: check.message - }); - } - status.dirty(); - } - } else if (check.kind === "email") { - if (!emailRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "email", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "emoji") { - if (!emojiRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "emoji", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "uuid") { - if (!uuidRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "uuid", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "cuid") { - if (!cuidRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "cuid", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "cuid2") { - if (!cuid2Regex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "cuid2", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "ulid") { - if (!ulidRegex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "ulid", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "url") { - try { - new URL(input.data); - } catch (_a) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "url", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "regex") { - check.regex.lastIndex = 0; - const testResult = check.regex.test(input.data); - if (!testResult) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "regex", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "trim") { - input.data = input.data.trim(); - } else if (check.kind === "includes") { - if (!input.data.includes(check.value, check.position)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_string, - validation: { includes: check.value, position: check.position }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "toLowerCase") { - input.data = input.data.toLowerCase(); - } else if (check.kind === "toUpperCase") { - input.data = input.data.toUpperCase(); - } else if (check.kind === "startsWith") { - if (!input.data.startsWith(check.value)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_string, - validation: { startsWith: check.value }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "endsWith") { - if (!input.data.endsWith(check.value)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_string, - validation: { endsWith: check.value }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "datetime") { - const regex = datetimeRegex(check); - if (!regex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_string, - validation: "datetime", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "ip") { - if (!isValidIP(input.data, check.version)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - validation: "ip", - code: ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else { - util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - _addCheck(check) { - return new ZodString({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - email(message) { - return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) }); - } - url(message) { - return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) }); - } - emoji(message) { - return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) }); - } - uuid(message) { - return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) }); - } - cuid(message) { - return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) }); - } - cuid2(message) { - return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) }); - } - ulid(message) { - return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) }); - } - ip(options) { - return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); - } - datetime(options) { - var _a; - if (typeof options === "string") { - return this._addCheck({ - kind: "datetime", - precision: null, - offset: false, - message: options - }); - } - return this._addCheck({ - kind: "datetime", - precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, - ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) - }); - } - regex(regex, message) { - return this._addCheck({ - kind: "regex", - regex, - ...errorUtil.errToObj(message) - }); - } - includes(value, options) { - return this._addCheck({ - kind: "includes", - value, - position: options === null || options === void 0 ? void 0 : options.position, - ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) - }); - } - startsWith(value, message) { - return this._addCheck({ - kind: "startsWith", - value, - ...errorUtil.errToObj(message) - }); - } - endsWith(value, message) { - return this._addCheck({ - kind: "endsWith", - value, - ...errorUtil.errToObj(message) - }); - } - min(minLength, message) { - return this._addCheck({ - kind: "min", - value: minLength, - ...errorUtil.errToObj(message) - }); - } - max(maxLength, message) { - return this._addCheck({ - kind: "max", - value: maxLength, - ...errorUtil.errToObj(message) - }); - } - length(len, message) { - return this._addCheck({ - kind: "length", - value: len, - ...errorUtil.errToObj(message) - }); - } - get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); - } - get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); - } - get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); - } - get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); - } - get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); - } - get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); - } - get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); - } - get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); - } - get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); - } - get minLength() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxLength() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } -} -ZodString.create = (params) => { - var _a; - return new ZodString({ - checks: [], - typeName: ZodFirstPartyTypeKind.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, - ...processCreateParams(params) - }); -}; -function floatSafeRemainder(val, step) { - const valDecCount = (val.toString().split(".")[1] || "").length; - const stepDecCount = (step.toString().split(".")[1] || "").length; - const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; - const valInt = parseInt(val.toFixed(decCount).replace(".", "")); - const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); - return valInt % stepInt / Math.pow(10, decCount); -} -class ZodNumber extends ZodType { - constructor() { - super(...arguments); - this.min = this.gte; - this.max = this.lte; - this.step = this.multipleOf; - } - _parse(input) { - if (this._def.coerce) { - input.data = Number(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.number) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.number, - received: ctx2.parsedType - }); - return INVALID; - } - let ctx = void 0; - const status = new ParseStatus(); - for (const check of this._def.checks) { - if (check.kind === "int") { - if (!util.isInteger(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: "integer", - received: "float", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: check.value, - type: "number", - inclusive: check.inclusive, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: check.value, - type: "number", - inclusive: check.inclusive, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "multipleOf") { - if (floatSafeRemainder(input.data, check.value) !== 0) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.not_multiple_of, - multipleOf: check.value, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "finite") { - if (!Number.isFinite(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.not_finite, - message: check.message - }); - status.dirty(); - } - } else { - util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil.toString(message)); - } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil.toString(message)); - } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil.toString(message)); - } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil.toString(message)); - } - setLimit(kind, value, inclusive, message) { - return new ZodNumber({ - ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil.toString(message) - } - ] - }); - } - _addCheck(check) { - return new ZodNumber({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - int(message) { - return this._addCheck({ - kind: "int", - message: errorUtil.toString(message) - }); - } - positive(message) { - return this._addCheck({ - kind: "min", - value: 0, - inclusive: false, - message: errorUtil.toString(message) - }); - } - negative(message) { - return this._addCheck({ - kind: "max", - value: 0, - inclusive: false, - message: errorUtil.toString(message) - }); - } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: 0, - inclusive: true, - message: errorUtil.toString(message) - }); - } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: 0, - inclusive: true, - message: errorUtil.toString(message) - }); - } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil.toString(message) - }); - } - finite(message) { - return this._addCheck({ - kind: "finite", - message: errorUtil.toString(message) - }); - } - safe(message) { - return this._addCheck({ - kind: "min", - inclusive: true, - value: Number.MIN_SAFE_INTEGER, - message: errorUtil.toString(message) - })._addCheck({ - kind: "max", - inclusive: true, - value: Number.MAX_SAFE_INTEGER, - message: errorUtil.toString(message) - }); - } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } - get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); - } - get isFinite() { - let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { - return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return Number.isFinite(min) && Number.isFinite(max); - } -} -ZodNumber.create = (params) => { - return new ZodNumber({ - checks: [], - typeName: ZodFirstPartyTypeKind.ZodNumber, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - ...processCreateParams(params) - }); -}; -class ZodBigInt extends ZodType { - constructor() { - super(...arguments); - this.min = this.gte; - this.max = this.lte; - } - _parse(input) { - if (this._def.coerce) { - input.data = BigInt(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.bigint) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.bigint, - received: ctx2.parsedType - }); - return INVALID; - } - let ctx = void 0; - const status = new ParseStatus(); - for (const check of this._def.checks) { - if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - type: "bigint", - minimum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - type: "bigint", - maximum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "multipleOf") { - if (input.data % check.value !== BigInt(0)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.not_multiple_of, - multipleOf: check.value, - message: check.message - }); - status.dirty(); - } - } else { - util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil.toString(message)); - } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil.toString(message)); - } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil.toString(message)); - } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil.toString(message)); - } - setLimit(kind, value, inclusive, message) { - return new ZodBigInt({ - ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil.toString(message) - } - ] - }); - } - _addCheck(check) { - return new ZodBigInt({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - positive(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: false, - message: errorUtil.toString(message) - }); - } - negative(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: false, - message: errorUtil.toString(message) - }); - } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: true, - message: errorUtil.toString(message) - }); - } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: true, - message: errorUtil.toString(message) - }); - } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil.toString(message) - }); - } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } -} -ZodBigInt.create = (params) => { - var _a; - return new ZodBigInt({ - checks: [], - typeName: ZodFirstPartyTypeKind.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, - ...processCreateParams(params) - }); -}; -class ZodBoolean extends ZodType { - _parse(input) { - if (this._def.coerce) { - input.data = Boolean(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.boolean) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.boolean, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodBoolean.create = (params) => { - return new ZodBoolean({ - typeName: ZodFirstPartyTypeKind.ZodBoolean, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - ...processCreateParams(params) - }); -}; -class ZodDate extends ZodType { - _parse(input) { - if (this._def.coerce) { - input.data = new Date(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.date) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.date, - received: ctx2.parsedType - }); - return INVALID; - } - if (isNaN(input.data.getTime())) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_date - }); - return INVALID; - } - const status = new ParseStatus(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.getTime() < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - message: check.message, - inclusive: true, - exact: false, - minimum: check.value, - type: "date" - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.getTime() > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - message: check.message, - inclusive: true, - exact: false, - maximum: check.value, - type: "date" - }); - status.dirty(); - } - } else { - util.assertNever(check); - } - } - return { - status: status.value, - value: new Date(input.data.getTime()) - }; - } - _addCheck(check) { - return new ZodDate({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - min(minDate, message) { - return this._addCheck({ - kind: "min", - value: minDate.getTime(), - message: errorUtil.toString(message) - }); - } - max(maxDate, message) { - return this._addCheck({ - kind: "max", - value: maxDate.getTime(), - message: errorUtil.toString(message) - }); - } - get minDate() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min != null ? new Date(min) : null; - } - get maxDate() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max != null ? new Date(max) : null; - } -} -ZodDate.create = (params) => { - return new ZodDate({ - checks: [], - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - typeName: ZodFirstPartyTypeKind.ZodDate, - ...processCreateParams(params) - }); -}; -class ZodSymbol extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.symbol) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.symbol, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodSymbol.create = (params) => { - return new ZodSymbol({ - typeName: ZodFirstPartyTypeKind.ZodSymbol, - ...processCreateParams(params) - }); -}; -class ZodUndefined extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.undefined) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.undefined, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodUndefined.create = (params) => { - return new ZodUndefined({ - typeName: ZodFirstPartyTypeKind.ZodUndefined, - ...processCreateParams(params) - }); -}; -class ZodNull extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.null) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.null, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodNull.create = (params) => { - return new ZodNull({ - typeName: ZodFirstPartyTypeKind.ZodNull, - ...processCreateParams(params) - }); -}; -class ZodAny extends ZodType { - constructor() { - super(...arguments); - this._any = true; - } - _parse(input) { - return OK(input.data); - } -} -ZodAny.create = (params) => { - return new ZodAny({ - typeName: ZodFirstPartyTypeKind.ZodAny, - ...processCreateParams(params) - }); -}; -class ZodUnknown extends ZodType { - constructor() { - super(...arguments); - this._unknown = true; - } - _parse(input) { - return OK(input.data); - } -} -ZodUnknown.create = (params) => { - return new ZodUnknown({ - typeName: ZodFirstPartyTypeKind.ZodUnknown, - ...processCreateParams(params) - }); -}; -class ZodNever extends ZodType { - _parse(input) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.never, - received: ctx.parsedType - }); - return INVALID; - } -} -ZodNever.create = (params) => { - return new ZodNever({ - typeName: ZodFirstPartyTypeKind.ZodNever, - ...processCreateParams(params) - }); -}; -class ZodVoid extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.undefined) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.void, - received: ctx.parsedType - }); - return INVALID; - } - return OK(input.data); - } -} -ZodVoid.create = (params) => { - return new ZodVoid({ - typeName: ZodFirstPartyTypeKind.ZodVoid, - ...processCreateParams(params) - }); -}; -class ZodArray extends ZodType { - _parse(input) { - const { ctx, status } = this._processInputParams(input); - const def = this._def; - if (ctx.parsedType !== ZodParsedType.array) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.array, - received: ctx.parsedType - }); - return INVALID; - } - if (def.exactLength !== null) { - const tooBig = ctx.data.length > def.exactLength.value; - const tooSmall = ctx.data.length < def.exactLength.value; - if (tooBig || tooSmall) { - addIssueToContext(ctx, { - code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, - minimum: tooSmall ? def.exactLength.value : void 0, - maximum: tooBig ? def.exactLength.value : void 0, - type: "array", - inclusive: true, - exact: true, - message: def.exactLength.message - }); - status.dirty(); - } - } - if (def.minLength !== null) { - if (ctx.data.length < def.minLength.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: def.minLength.value, - type: "array", - inclusive: true, - exact: false, - message: def.minLength.message - }); - status.dirty(); - } - } - if (def.maxLength !== null) { - if (ctx.data.length > def.maxLength.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: def.maxLength.value, - type: "array", - inclusive: true, - exact: false, - message: def.maxLength.message - }); - status.dirty(); - } - } - if (ctx.common.async) { - return Promise.all([...ctx.data].map((item, i2) => { - return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); - })).then((result2) => { - return ParseStatus.mergeArray(status, result2); - }); - } - const result = [...ctx.data].map((item, i2) => { - return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); - }); - return ParseStatus.mergeArray(status, result); - } - get element() { - return this._def.type; - } - min(minLength, message) { - return new ZodArray({ - ...this._def, - minLength: { value: minLength, message: errorUtil.toString(message) } - }); - } - max(maxLength, message) { - return new ZodArray({ - ...this._def, - maxLength: { value: maxLength, message: errorUtil.toString(message) } - }); - } - length(len, message) { - return new ZodArray({ - ...this._def, - exactLength: { value: len, message: errorUtil.toString(message) } - }); - } - nonempty(message) { - return this.min(1, message); - } -} -ZodArray.create = (schema, params) => { - return new ZodArray({ - type: schema, - minLength: null, - maxLength: null, - exactLength: null, - typeName: ZodFirstPartyTypeKind.ZodArray, - ...processCreateParams(params) - }); -}; -function deepPartialify(schema) { - if (schema instanceof ZodObject) { - const newShape = {}; - for (const key in schema.shape) { - const fieldSchema = schema.shape[key]; - newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); - } - return new ZodObject({ - ...schema._def, - shape: () => newShape - }); - } else if (schema instanceof ZodArray) { - return new ZodArray({ - ...schema._def, - type: deepPartialify(schema.element) - }); - } else if (schema instanceof ZodOptional) { - return ZodOptional.create(deepPartialify(schema.unwrap())); - } else if (schema instanceof ZodNullable) { - return ZodNullable.create(deepPartialify(schema.unwrap())); - } else if (schema instanceof ZodTuple) { - return ZodTuple.create(schema.items.map((item) => deepPartialify(item))); - } else { - return schema; - } -} -class ZodObject extends ZodType { - constructor() { - super(...arguments); - this._cached = null; - this.nonstrict = this.passthrough; - this.augment = this.extend; - } - _getCached() { - if (this._cached !== null) - return this._cached; - const shape = this._def.shape(); - const keys2 = util.objectKeys(shape); - return this._cached = { shape, keys: keys2 }; - } - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.object) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, - received: ctx2.parsedType - }); - return INVALID; - } - const { status, ctx } = this._processInputParams(input); - const { shape, keys: shapeKeys } = this._getCached(); - const extraKeys = []; - if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { - for (const key in ctx.data) { - if (!shapeKeys.includes(key)) { - extraKeys.push(key); - } - } - } - const pairs = []; - for (const key of shapeKeys) { - const keyValidator = shape[key]; - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), - alwaysSet: key in ctx.data - }); - } - if (this._def.catchall instanceof ZodNever) { - const unknownKeys = this._def.unknownKeys; - if (unknownKeys === "passthrough") { - for (const key of extraKeys) { - pairs.push({ - key: { status: "valid", value: key }, - value: { status: "valid", value: ctx.data[key] } - }); - } - } else if (unknownKeys === "strict") { - if (extraKeys.length > 0) { - addIssueToContext(ctx, { - code: ZodIssueCode.unrecognized_keys, - keys: extraKeys - }); - status.dirty(); - } - } else if (unknownKeys === "strip") - ; - else { - throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); - } - } else { - const catchall = this._def.catchall; - for (const key of extraKeys) { - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: catchall._parse( - new ParseInputLazyPath(ctx, value, ctx.path, key) - //, ctx.child(key), value, getParsedType(value) - ), - alwaysSet: key in ctx.data - }); - } - } - if (ctx.common.async) { - return Promise.resolve().then(async () => { - const syncPairs = []; - for (const pair of pairs) { - const key = await pair.key; - syncPairs.push({ - key, - value: await pair.value, - alwaysSet: pair.alwaysSet - }); - } - return syncPairs; - }).then((syncPairs) => { - return ParseStatus.mergeObjectSync(status, syncPairs); - }); - } else { - return ParseStatus.mergeObjectSync(status, pairs); - } - } - get shape() { - return this._def.shape(); - } - strict(message) { - errorUtil.errToObj; - return new ZodObject({ - ...this._def, - unknownKeys: "strict", - ...message !== void 0 ? { - errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; - if (issue.code === "unrecognized_keys") - return { - message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError - }; - return { - message: defaultError - }; - } - } : {} - }); - } - strip() { - return new ZodObject({ - ...this._def, - unknownKeys: "strip" - }); - } - passthrough() { - return new ZodObject({ - ...this._def, - unknownKeys: "passthrough" - }); - } - // const AugmentFactory = - // (def: Def) => - // ( - // augmentation: Augmentation - // ): ZodObject< - // extendShape, Augmentation>, - // Def["unknownKeys"], - // Def["catchall"] - // > => { - // return new ZodObject({ - // ...def, - // shape: () => ({ - // ...def.shape(), - // ...augmentation, - // }), - // }) as any; - // }; - extend(augmentation) { - return new ZodObject({ - ...this._def, - shape: () => ({ - ...this._def.shape(), - ...augmentation - }) - }); - } - /** - * Prior to zod@1.0.12 there was a bug in the - * inferred type of merged objects. Please - * upgrade if you are experiencing issues. - */ - merge(merging) { - const merged = new ZodObject({ - unknownKeys: merging._def.unknownKeys, - catchall: merging._def.catchall, - shape: () => ({ - ...this._def.shape(), - ...merging._def.shape() - }), - typeName: ZodFirstPartyTypeKind.ZodObject - }); - return merged; - } - // merge< - // Incoming extends AnyZodObject, - // Augmentation extends Incoming["shape"], - // NewOutput extends { - // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation - // ? Augmentation[k]["_output"] - // : k extends keyof Output - // ? Output[k] - // : never; - // }, - // NewInput extends { - // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation - // ? Augmentation[k]["_input"] - // : k extends keyof Input - // ? Input[k] - // : never; - // } - // >( - // merging: Incoming - // ): ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"], - // NewOutput, - // NewInput - // > { - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - setKey(key, schema) { - return this.augment({ [key]: schema }); - } - // merge( - // merging: Incoming - // ): //ZodObject = (merging) => { - // ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"] - // > { - // // const mergedShape = objectUtil.mergeShapes( - // // this._def.shape(), - // // merging._def.shape() - // // ); - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - catchall(index) { - return new ZodObject({ - ...this._def, - catchall: index - }); - } - pick(mask) { - const shape = {}; - util.objectKeys(mask).forEach((key) => { - if (mask[key] && this.shape[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ - ...this._def, - shape: () => shape - }); - } - omit(mask) { - const shape = {}; - util.objectKeys(this.shape).forEach((key) => { - if (!mask[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ - ...this._def, - shape: () => shape - }); - } - /** - * @deprecated - */ - deepPartial() { - return deepPartialify(this); - } - partial(mask) { - const newShape = {}; - util.objectKeys(this.shape).forEach((key) => { - const fieldSchema = this.shape[key]; - if (mask && !mask[key]) { - newShape[key] = fieldSchema; - } else { - newShape[key] = fieldSchema.optional(); - } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape - }); - } - required(mask) { - const newShape = {}; - util.objectKeys(this.shape).forEach((key) => { - if (mask && !mask[key]) { - newShape[key] = this.shape[key]; - } else { - const fieldSchema = this.shape[key]; - let newField = fieldSchema; - while (newField instanceof ZodOptional) { - newField = newField._def.innerType; - } - newShape[key] = newField; - } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape - }); - } - keyof() { - return createZodEnum(util.objectKeys(this.shape)); - } -} -ZodObject.create = (shape, params) => { - return new ZodObject({ - shape: () => shape, - unknownKeys: "strip", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, - ...processCreateParams(params) - }); -}; -ZodObject.strictCreate = (shape, params) => { - return new ZodObject({ - shape: () => shape, - unknownKeys: "strict", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, - ...processCreateParams(params) - }); -}; -ZodObject.lazycreate = (shape, params) => { - return new ZodObject({ - shape, - unknownKeys: "strip", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, - ...processCreateParams(params) - }); -}; -class ZodUnion extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - const options = this._def.options; - function handleResults(results) { - for (const result of results) { - if (result.result.status === "valid") { - return result.result; - } - } - for (const result of results) { - if (result.result.status === "dirty") { - ctx.common.issues.push(...result.ctx.common.issues); - return result.result; - } - } - const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues)); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union, - unionErrors - }); - return INVALID; - } - if (ctx.common.async) { - return Promise.all(options.map(async (option) => { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - return { - result: await option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }), - ctx: childCtx - }; - })).then(handleResults); - } else { - let dirty = void 0; - const issues = []; - for (const option of options) { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - const result = option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }); - if (result.status === "valid") { - return result; - } else if (result.status === "dirty" && !dirty) { - dirty = { result, ctx: childCtx }; - } - if (childCtx.common.issues.length) { - issues.push(childCtx.common.issues); - } - } - if (dirty) { - ctx.common.issues.push(...dirty.ctx.common.issues); - return dirty.result; - } - const unionErrors = issues.map((issues2) => new ZodError(issues2)); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union, - unionErrors - }); - return INVALID; - } - } - get options() { - return this._def.options; - } -} -ZodUnion.create = (types2, params) => { - return new ZodUnion({ - options: types2, - typeName: ZodFirstPartyTypeKind.ZodUnion, - ...processCreateParams(params) - }); -}; -const getDiscriminator = (type2) => { - if (type2 instanceof ZodLazy) { - return getDiscriminator(type2.schema); - } else if (type2 instanceof ZodEffects) { - return getDiscriminator(type2.innerType()); - } else if (type2 instanceof ZodLiteral) { - return [type2.value]; - } else if (type2 instanceof ZodEnum) { - return type2.options; - } else if (type2 instanceof ZodNativeEnum) { - return Object.keys(type2.enum); - } else if (type2 instanceof ZodDefault) { - return getDiscriminator(type2._def.innerType); - } else if (type2 instanceof ZodUndefined) { - return [void 0]; - } else if (type2 instanceof ZodNull) { - return [null]; - } else { - return null; - } -}; -class ZodDiscriminatedUnion extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.object) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, - received: ctx.parsedType - }); - return INVALID; - } - const discriminator = this.discriminator; - const discriminatorValue = ctx.data[discriminator]; - const option = this.optionsMap.get(discriminatorValue); - if (!option) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union_discriminator, - options: Array.from(this.optionsMap.keys()), - path: [discriminator] - }); - return INVALID; - } - if (ctx.common.async) { - return option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } else { - return option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } - } - get discriminator() { - return this._def.discriminator; - } - get options() { - return this._def.options; - } - get optionsMap() { - return this._def.optionsMap; - } - /** - * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. - * However, it only allows a union of objects, all of which need to share a discriminator property. This property must - * have a different value for each object in the union. - * @param discriminator the name of the discriminator property - * @param types an array of object schemas - * @param params - */ - static create(discriminator, options, params) { - const optionsMap = /* @__PURE__ */ new Map(); - for (const type2 of options) { - const discriminatorValues = getDiscriminator(type2.shape[discriminator]); - if (!discriminatorValues) { - throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); - } - for (const value of discriminatorValues) { - if (optionsMap.has(value)) { - throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); - } - optionsMap.set(value, type2); - } - } - return new ZodDiscriminatedUnion({ - typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, - discriminator, - options, - optionsMap, - ...processCreateParams(params) - }); - } -} -function mergeValues(a3, b3) { - const aType = getParsedType(a3); - const bType = getParsedType(b3); - if (a3 === b3) { - return { valid: true, data: a3 }; - } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) { - const bKeys = util.objectKeys(b3); - const sharedKeys = util.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1); - const newObj = { ...a3, ...b3 }; - for (const key of sharedKeys) { - const sharedValue = mergeValues(a3[key], b3[key]); - if (!sharedValue.valid) { - return { valid: false }; - } - newObj[key] = sharedValue.data; - } - return { valid: true, data: newObj }; - } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { - if (a3.length !== b3.length) { - return { valid: false }; - } - const newArray = []; - for (let index = 0; index < a3.length; index++) { - const itemA = a3[index]; - const itemB = b3[index]; - const sharedValue = mergeValues(itemA, itemB); - if (!sharedValue.valid) { - return { valid: false }; - } - newArray.push(sharedValue.data); - } - return { valid: true, data: newArray }; - } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a3 === +b3) { - return { valid: true, data: a3 }; - } else { - return { valid: false }; - } -} -class ZodIntersection extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const handleParsed = (parsedLeft, parsedRight) => { - if (isAborted(parsedLeft) || isAborted(parsedRight)) { - return INVALID; - } - const merged = mergeValues(parsedLeft.value, parsedRight.value); - if (!merged.valid) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_intersection_types - }); - return INVALID; - } - if (isDirty(parsedLeft) || isDirty(parsedRight)) { - status.dirty(); - } - return { status: status.value, value: merged.data }; - }; - if (ctx.common.async) { - return Promise.all([ - this._def.left._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), - this._def.right._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }) - ]).then(([left, right]) => handleParsed(left, right)); - } else { - return handleParsed(this._def.left._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), this._def.right._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - })); - } - } -} -ZodIntersection.create = (left, right, params) => { - return new ZodIntersection({ - left, - right, - typeName: ZodFirstPartyTypeKind.ZodIntersection, - ...processCreateParams(params) - }); -}; -class ZodTuple extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.array) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.array, - received: ctx.parsedType - }); - return INVALID; - } - if (ctx.data.length < this._def.items.length) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - return INVALID; - } - const rest = this._def.rest; - if (!rest && ctx.data.length > this._def.items.length) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - status.dirty(); - } - const items = [...ctx.data].map((item, itemIndex) => { - const schema = this._def.items[itemIndex] || this._def.rest; - if (!schema) - return null; - return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)); - }).filter((x2) => !!x2); - if (ctx.common.async) { - return Promise.all(items).then((results) => { - return ParseStatus.mergeArray(status, results); - }); - } else { - return ParseStatus.mergeArray(status, items); - } - } - get items() { - return this._def.items; - } - rest(rest) { - return new ZodTuple({ - ...this._def, - rest - }); - } -} -ZodTuple.create = (schemas, params) => { - if (!Array.isArray(schemas)) { - throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); - } - return new ZodTuple({ - items: schemas, - typeName: ZodFirstPartyTypeKind.ZodTuple, - rest: null, - ...processCreateParams(params) - }); -}; -class ZodRecord extends ZodType { - get keySchema() { - return this._def.keyType; - } - get valueSchema() { - return this._def.valueType; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.object) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, - received: ctx.parsedType - }); - return INVALID; - } - const pairs = []; - const keyType = this._def.keyType; - const valueType = this._def.valueType; - for (const key in ctx.data) { - pairs.push({ - key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), - value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) - }); - } - if (ctx.common.async) { - return ParseStatus.mergeObjectAsync(status, pairs); - } else { - return ParseStatus.mergeObjectSync(status, pairs); - } - } - get element() { - return this._def.valueType; - } - static create(first, second, third) { - if (second instanceof ZodType) { - return new ZodRecord({ - keyType: first, - valueType: second, - typeName: ZodFirstPartyTypeKind.ZodRecord, - ...processCreateParams(third) - }); - } - return new ZodRecord({ - keyType: ZodString.create(), - valueType: first, - typeName: ZodFirstPartyTypeKind.ZodRecord, - ...processCreateParams(second) - }); - } -} -class ZodMap extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.map) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.map, - received: ctx.parsedType - }); - return INVALID; - } - const keyType = this._def.keyType; - const valueType = this._def.valueType; - const pairs = [...ctx.data.entries()].map(([key, value], index) => { - return { - key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])), - value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"])) - }; - }); - if (ctx.common.async) { - const finalMap = /* @__PURE__ */ new Map(); - return Promise.resolve().then(async () => { - for (const pair of pairs) { - const key = await pair.key; - const value = await pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - }); - } else { - const finalMap = /* @__PURE__ */ new Map(); - for (const pair of pairs) { - const key = pair.key; - const value = pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - } - } -} -ZodMap.create = (keyType, valueType, params) => { - return new ZodMap({ - valueType, - keyType, - typeName: ZodFirstPartyTypeKind.ZodMap, - ...processCreateParams(params) - }); -}; -class ZodSet extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.set) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.set, - received: ctx.parsedType - }); - return INVALID; - } - const def = this._def; - if (def.minSize !== null) { - if (ctx.data.size < def.minSize.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: def.minSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.minSize.message - }); - status.dirty(); - } - } - if (def.maxSize !== null) { - if (ctx.data.size > def.maxSize.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: def.maxSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.maxSize.message - }); - status.dirty(); - } - } - const valueType = this._def.valueType; - function finalizeSet(elements2) { - const parsedSet = /* @__PURE__ */ new Set(); - for (const element of elements2) { - if (element.status === "aborted") - return INVALID; - if (element.status === "dirty") - status.dirty(); - parsedSet.add(element.value); - } - return { status: status.value, value: parsedSet }; - } - const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2))); - if (ctx.common.async) { - return Promise.all(elements).then((elements2) => finalizeSet(elements2)); - } else { - return finalizeSet(elements); - } - } - min(minSize, message) { - return new ZodSet({ - ...this._def, - minSize: { value: minSize, message: errorUtil.toString(message) } - }); - } - max(maxSize, message) { - return new ZodSet({ - ...this._def, - maxSize: { value: maxSize, message: errorUtil.toString(message) } - }); - } - size(size, message) { - return this.min(size, message).max(size, message); - } - nonempty(message) { - return this.min(1, message); - } -} -ZodSet.create = (valueType, params) => { - return new ZodSet({ - valueType, - minSize: null, - maxSize: null, - typeName: ZodFirstPartyTypeKind.ZodSet, - ...processCreateParams(params) - }); -}; -class ZodFunction extends ZodType { - constructor() { - super(...arguments); - this.validate = this.implement; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.function) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.function, - received: ctx.parsedType - }); - return INVALID; - } - function makeArgsIssue(args, error) { - return makeIssue({ - data: args, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap(), - errorMap - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode.invalid_arguments, - argumentsError: error - } - }); - } - function makeReturnsIssue(returns, error) { - return makeIssue({ - data: returns, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap(), - errorMap - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode.invalid_return_type, - returnTypeError: error - } - }); - } - const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; - if (this._def.returns instanceof ZodPromise) { - return OK(async (...args) => { - const error = new ZodError([]); - const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => { - error.addIssue(makeArgsIssue(args, e)); - throw error; - }); - const result = await fn2(...parsedArgs); - const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => { - error.addIssue(makeReturnsIssue(result, e)); - throw error; - }); - return parsedReturns; - }); - } else { - return OK((...args) => { - const parsedArgs = this._def.args.safeParse(args, params); - if (!parsedArgs.success) { - throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); - } - const result = fn2(...parsedArgs.data); - const parsedReturns = this._def.returns.safeParse(result, params); - if (!parsedReturns.success) { - throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); - } - return parsedReturns.data; - }); - } - } - parameters() { - return this._def.args; - } - returnType() { - return this._def.returns; - } - args(...items) { - return new ZodFunction({ - ...this._def, - args: ZodTuple.create(items).rest(ZodUnknown.create()) - }); - } - returns(returnType) { - return new ZodFunction({ - ...this._def, - returns: returnType - }); - } - implement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - strictImplement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - static create(args, returns, params) { - return new ZodFunction({ - args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()), - returns: returns || ZodUnknown.create(), - typeName: ZodFirstPartyTypeKind.ZodFunction, - ...processCreateParams(params) - }); - } -} -class ZodLazy extends ZodType { - get schema() { - return this._def.getter(); - } - _parse(input) { - const { ctx } = this._processInputParams(input); - const lazySchema = this._def.getter(); - return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); - } -} -ZodLazy.create = (getter, params) => { - return new ZodLazy({ - getter, - typeName: ZodFirstPartyTypeKind.ZodLazy, - ...processCreateParams(params) - }); -}; -class ZodLiteral extends ZodType { - _parse(input) { - if (input.data !== this._def.value) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_literal, - expected: this._def.value - }); - return INVALID; - } - return { status: "valid", value: input.data }; - } - get value() { - return this._def.value; - } -} -ZodLiteral.create = (value, params) => { - return new ZodLiteral({ - value, - typeName: ZodFirstPartyTypeKind.ZodLiteral, - ...processCreateParams(params) - }); -}; -function createZodEnum(values, params) { - return new ZodEnum({ - values, - typeName: ZodFirstPartyTypeKind.ZodEnum, - ...processCreateParams(params) - }); -} -class ZodEnum extends ZodType { - _parse(input) { - if (typeof input.data !== "string") { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext(ctx, { - expected: util.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode.invalid_type - }); - return INVALID; - } - if (this._def.values.indexOf(input.data) === -1) { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_enum_value, - options: expectedValues - }); - return INVALID; - } - return OK(input.data); - } - get options() { - return this._def.values; - } - get enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - get Values() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - get Enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - extract(values) { - return ZodEnum.create(values); - } - exclude(values) { - return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); - } -} -ZodEnum.create = createZodEnum; -class ZodNativeEnum extends ZodType { - _parse(input) { - const nativeEnumValues = util.getValidEnumValues(this._def.values); - const ctx = this._getOrReturnCtx(input); - if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { - const expectedValues = util.objectValues(nativeEnumValues); - addIssueToContext(ctx, { - expected: util.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode.invalid_type - }); - return INVALID; - } - if (nativeEnumValues.indexOf(input.data) === -1) { - const expectedValues = util.objectValues(nativeEnumValues); - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_enum_value, - options: expectedValues - }); - return INVALID; - } - return OK(input.data); - } - get enum() { - return this._def.values; - } -} -ZodNativeEnum.create = (values, params) => { - return new ZodNativeEnum({ - values, - typeName: ZodFirstPartyTypeKind.ZodNativeEnum, - ...processCreateParams(params) - }); -}; -class ZodPromise extends ZodType { - unwrap() { - return this._def.type; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.promise, - received: ctx.parsedType - }); - return INVALID; - } - const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); - return OK(promisified.then((data) => { - return this._def.type.parseAsync(data, { - path: ctx.path, - errorMap: ctx.common.contextualErrorMap - }); - })); - } -} -ZodPromise.create = (schema, params) => { - return new ZodPromise({ - type: schema, - typeName: ZodFirstPartyTypeKind.ZodPromise, - ...processCreateParams(params) - }); -}; -class ZodEffects extends ZodType { - innerType() { - return this._def.schema; - } - sourceType() { - return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const effect = this._def.effect || null; - if (effect.type === "preprocess") { - const processed = effect.transform(ctx.data); - if (ctx.common.async) { - return Promise.resolve(processed).then((processed2) => { - return this._def.schema._parseAsync({ - data: processed2, - path: ctx.path, - parent: ctx - }); - }); - } else { - return this._def.schema._parseSync({ - data: processed, - path: ctx.path, - parent: ctx - }); - } - } - const checkCtx = { - addIssue: (arg) => { - addIssueToContext(ctx, arg); - if (arg.fatal) { - status.abort(); - } else { - status.dirty(); - } - }, - get path() { - return ctx.path; - } - }; - checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); - if (effect.type === "refinement") { - const executeRefinement = (acc) => { - const result = effect.refinement(acc, checkCtx); - if (ctx.common.async) { - return Promise.resolve(result); - } - if (result instanceof Promise) { - throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); - } - return acc; - }; - if (ctx.common.async === false) { - const inner = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inner.status === "aborted") - return INVALID; - if (inner.status === "dirty") - status.dirty(); - executeRefinement(inner.value); - return { status: status.value, value: inner.value }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { - if (inner.status === "aborted") - return INVALID; - if (inner.status === "dirty") - status.dirty(); - return executeRefinement(inner.value).then(() => { - return { status: status.value, value: inner.value }; - }); - }); - } - } - if (effect.type === "transform") { - if (ctx.common.async === false) { - const base3 = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (!isValid(base3)) - return base3; - const result = effect.transform(base3.value, checkCtx); - if (result instanceof Promise) { - throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); - } - return { status: status.value, value: result }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { - if (!isValid(base3)) - return base3; - return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); - }); - } - } - util.assertNever(effect); - } -} -ZodEffects.create = (schema, effect, params) => { - return new ZodEffects({ - schema, - typeName: ZodFirstPartyTypeKind.ZodEffects, - effect, - ...processCreateParams(params) - }); -}; -ZodEffects.createWithPreprocess = (preprocess, schema, params) => { - return new ZodEffects({ - schema, - effect: { type: "preprocess", transform: preprocess }, - typeName: ZodFirstPartyTypeKind.ZodEffects, - ...processCreateParams(params) - }); -}; -class ZodOptional extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType.undefined) { - return OK(void 0); - } - return this._def.innerType._parse(input); - } - unwrap() { - return this._def.innerType; - } -} -ZodOptional.create = (type2, params) => { - return new ZodOptional({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodOptional, - ...processCreateParams(params) - }); -}; -class ZodNullable extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType.null) { - return OK(null); - } - return this._def.innerType._parse(input); - } - unwrap() { - return this._def.innerType; - } -} -ZodNullable.create = (type2, params) => { - return new ZodNullable({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodNullable, - ...processCreateParams(params) - }); -}; -class ZodDefault extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - let data = ctx.data; - if (ctx.parsedType === ZodParsedType.undefined) { - data = this._def.defaultValue(); - } - return this._def.innerType._parse({ - data, - path: ctx.path, - parent: ctx - }); - } - removeDefault() { - return this._def.innerType; - } -} -ZodDefault.create = (type2, params) => { - return new ZodDefault({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodDefault, - defaultValue: typeof params.default === "function" ? params.default : () => params.default, - ...processCreateParams(params) - }); -}; -class ZodCatch extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - const newCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - } - }; - const result = this._def.innerType._parse({ - data: newCtx.data, - path: newCtx.path, - parent: { - ...newCtx - } - }); - if (isAsync(result)) { - return result.then((result2) => { - return { - status: "valid", - value: result2.status === "valid" ? result2.value : this._def.catchValue({ - get error() { - return new ZodError(newCtx.common.issues); - } - }) - }; - }); - } else { - return { - status: "valid", - value: result.status === "valid" ? result.value : this._def.catchValue({ - get error() { - return new ZodError(newCtx.common.issues); - } - }) - }; - } - } - removeCatch() { - return this._def.innerType; - } -} -ZodCatch.create = (type2, params) => { - return new ZodCatch({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodCatch, - catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, - ...processCreateParams(params) - }); -}; -class ZodNaN extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.nan) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.nan, - received: ctx.parsedType - }); - return INVALID; - } - return { status: "valid", value: input.data }; - } -} -ZodNaN.create = (params) => { - return new ZodNaN({ - typeName: ZodFirstPartyTypeKind.ZodNaN, - ...processCreateParams(params) - }); -}; -const BRAND = Symbol("zod_brand"); -class ZodBranded extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - const data = ctx.data; - return this._def.type._parse({ - data, - path: ctx.path, - parent: ctx - }); - } - unwrap() { - return this._def.type; - } -} -class ZodPipeline extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.common.async) { - const handleAsync = async () => { - const inResult = await this._def.in._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID; - if (inResult.status === "dirty") { - status.dirty(); - return DIRTY(inResult.value); - } else { - return this._def.out._parseAsync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - }; - return handleAsync(); - } else { - const inResult = this._def.in._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID; - if (inResult.status === "dirty") { - status.dirty(); - return { - status: "dirty", - value: inResult.value - }; - } else { - return this._def.out._parseSync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - } - } - static create(a3, b3) { - return new ZodPipeline({ - in: a3, - out: b3, - typeName: ZodFirstPartyTypeKind.ZodPipeline - }); - } -} -const custom = (check, params = {}, fatal) => { - if (check) - return ZodAny.create().superRefine((data, ctx) => { - var _a, _b; - if (!check(data)) { - const p3 = typeof params === "function" ? params(data) : params; - const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p3 === "string" ? { message: p3 } : p3; - ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); - } - }); - return ZodAny.create(); -}; -const late = { - object: ZodObject.lazycreate -}; -var ZodFirstPartyTypeKind; -(function(ZodFirstPartyTypeKind2) { - ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; - ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; - ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; - ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; - ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; - ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; - ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; - ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; - ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; - ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; - ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; - ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; - ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; - ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; - ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; - ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; - ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; - ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; - ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; - ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; - ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; - ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; - ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; - ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; - ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; - ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; - ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; - ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; - ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; - ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; - ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; - ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; - ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; - ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; - ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; -})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); -const instanceOfType = (cls, params = { - message: `Input not instance of ${cls.name}` -}) => custom((data) => data instanceof cls, params); -const stringType = ZodString.create; -const numberType = ZodNumber.create; -const nanType = ZodNaN.create; -const bigIntType = ZodBigInt.create; -const booleanType = ZodBoolean.create; -const dateType = ZodDate.create; -const symbolType = ZodSymbol.create; -const undefinedType = ZodUndefined.create; -const nullType = ZodNull.create; -const anyType = ZodAny.create; -const unknownType = ZodUnknown.create; -const neverType = ZodNever.create; -const voidType = ZodVoid.create; -const arrayType = ZodArray.create; -const objectType = ZodObject.create; -const strictObjectType = ZodObject.strictCreate; -const unionType = ZodUnion.create; -const discriminatedUnionType = ZodDiscriminatedUnion.create; -const intersectionType = ZodIntersection.create; -const tupleType = ZodTuple.create; -const recordType = ZodRecord.create; -const mapType = ZodMap.create; -const setType = ZodSet.create; -const functionType = ZodFunction.create; -const lazyType = ZodLazy.create; -const literalType = ZodLiteral.create; -const enumType = ZodEnum.create; -const nativeEnumType = ZodNativeEnum.create; -const promiseType = ZodPromise.create; -const effectsType = ZodEffects.create; -const optionalType = ZodOptional.create; -const nullableType = ZodNullable.create; -const preprocessType = ZodEffects.createWithPreprocess; -const pipelineType = ZodPipeline.create; -const ostring = () => stringType().optional(); -const onumber = () => numberType().optional(); -const oboolean = () => booleanType().optional(); -const coerce = { - string: (arg) => ZodString.create({ ...arg, coerce: true }), - number: (arg) => ZodNumber.create({ ...arg, coerce: true }), - boolean: (arg) => ZodBoolean.create({ - ...arg, - coerce: true - }), - bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }), - date: (arg) => ZodDate.create({ ...arg, coerce: true }) -}; -const NEVER = INVALID; -var z2 = /* @__PURE__ */ Object.freeze({ - __proto__: null, - defaultErrorMap: errorMap, - setErrorMap, - getErrorMap, - makeIssue, - EMPTY_PATH, - addIssueToContext, - ParseStatus, - INVALID, - DIRTY, - OK, - isAborted, - isDirty, - isValid, - isAsync, - get util() { - return util; - }, - get objectUtil() { - return objectUtil; - }, - ZodParsedType, - getParsedType, - ZodType, - ZodString, - ZodNumber, - ZodBigInt, - ZodBoolean, - ZodDate, - ZodSymbol, - ZodUndefined, - ZodNull, - ZodAny, - ZodUnknown, - ZodNever, - ZodVoid, - ZodArray, - ZodObject, - ZodUnion, - ZodDiscriminatedUnion, - ZodIntersection, - ZodTuple, - ZodRecord, - ZodMap, - ZodSet, - ZodFunction, - ZodLazy, - ZodLiteral, - ZodEnum, - ZodNativeEnum, - ZodPromise, - ZodEffects, - ZodTransformer: ZodEffects, - ZodOptional, - ZodNullable, - ZodDefault, - ZodCatch, - ZodNaN, - BRAND, - ZodBranded, - ZodPipeline, - custom, - Schema: ZodType, - ZodSchema: ZodType, - late, - get ZodFirstPartyTypeKind() { - return ZodFirstPartyTypeKind; - }, - coerce, - any: anyType, - array: arrayType, - bigint: bigIntType, - boolean: booleanType, - date: dateType, - discriminatedUnion: discriminatedUnionType, - effect: effectsType, - "enum": enumType, - "function": functionType, - "instanceof": instanceOfType, - intersection: intersectionType, - lazy: lazyType, - literal: literalType, - map: mapType, - nan: nanType, - nativeEnum: nativeEnumType, - never: neverType, - "null": nullType, - nullable: nullableType, - number: numberType, - object: objectType, - oboolean, - onumber, - optional: optionalType, - ostring, - pipeline: pipelineType, - preprocess: preprocessType, - promise: promiseType, - record: recordType, - set: setType, - strictObject: strictObjectType, - string: stringType, - symbol: symbolType, - transformer: effectsType, - tuple: tupleType, - "undefined": undefinedType, - union: unionType, - unknown: unknownType, - "void": voidType, - NEVER, - ZodIssueCode, - quotelessJson, - ZodError -}); -const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; -const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; -const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; -const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; -const aleoFieldRegex = /^\d+field$/; -const aleoU32 = /^\d+u32$/; -const aleoU64 = /^\d+u64$/; -const zodAddress = z2.string().regex(aleoAddressRegex); -const zodViewKey = z2.string().regex(aleoViewKeyRegex); -const zodPrivateKey = z2.string().regex(aleoPrivateKeyRegex); -const zodTransactionId = z2.string().regex(aleoTransactionIdRegex); -const zodField = z2.string().regex(aleoFieldRegex); -const zodU32 = z2.string().regex(aleoU32); -const zodU64 = z2.string().regex(aleoU64); -var InputOutputType; -(function(InputOutputType2) { - InputOutputType2["Record"] = "record"; - InputOutputType2["OutputRecord"] = "outputRecord"; - InputOutputType2["Public"] = "public"; - InputOutputType2["Private"] = "private"; - InputOutputType2["Constant"] = "constant"; - InputOutputType2["Future"] = "future"; - InputOutputType2["ExternalRecord"] = "external_record"; -})(InputOutputType || (InputOutputType = {})); -exports.EventType = void 0; -(function(EventType) { - EventType["Deploy"] = "Deploy"; - EventType["Execute"] = "Execute"; - EventType["Send"] = "Send"; - EventType["Receive"] = "Receive"; - EventType["Join"] = "Join"; - EventType["Split"] = "Split"; - EventType["Shield"] = "Shield"; - EventType["Unshield"] = "Unshield"; -})(exports.EventType || (exports.EventType = {})); -exports.EventStatus = void 0; -(function(EventStatus) { - EventStatus["Creating"] = "Creating"; - EventStatus["Pending"] = "Pending"; - EventStatus["Settled"] = "Settled"; - EventStatus["Failed"] = "Failed"; -})(exports.EventStatus || (exports.EventStatus = {})); -exports.Visibility = void 0; -(function(Visibility) { - Visibility["Private"] = "Private"; - Visibility["Public"] = "Public"; -})(exports.Visibility || (exports.Visibility = {})); -exports.Network = void 0; -(function(Network) { - Network["AleoTestnet"] = "AleoTestnet"; - Network["AleoMainnet"] = "AleoMainnet"; -})(exports.Network || (exports.Network = {})); -exports.AssetType = void 0; -(function(AssetType) { - AssetType[AssetType["ALEO"] = 0] = "ALEO"; -})(exports.AssetType || (exports.AssetType = {})); -const zodEventType = z2.nativeEnum(exports.EventType); -const zodEventStatus = z2.nativeEnum(exports.EventStatus); -const zodNetwork = z2.nativeEnum(exports.Network); -const zodVisibility = z2.nativeEnum(exports.Visibility); -const requestSignature = async ({ - message, - address -}) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - try { - const response = await connection.request({ - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "requestSignature", - params: { - message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 - } - } - }); - return response; - } catch (e) { - console.error("signature error", e); - const error = e.message; - return { error }; - } -}; -const PAGE_SIZE = 20; -var browser = { exports: {} }; -var ms; -var hasRequiredMs; -function requireMs() { - if (hasRequiredMs) - return ms; - hasRequiredMs = 1; - var s2 = 1e3; - var m2 = s2 * 60; - var h4 = m2 * 60; - var d3 = h4 * 24; - var w3 = d3 * 7; - var y3 = d3 * 365.25; - ms = function(val, options) { - options = options || {}; - var type2 = typeof val; - if (type2 === "string" && val.length > 0) { - return parse(val); - } else if (type2 === "number" && isFinite(val)) { - return options.long ? fmtLong(val) : fmtShort(val); - } - throw new Error( - "val is not a non-empty string or a valid number. val=" + JSON.stringify(val) - ); - }; - function parse(str) { - str = String(str); - if (str.length > 100) { - return; - } - var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( - str - ); - if (!match) { - return; - } - var n3 = parseFloat(match[1]); - var type2 = (match[2] || "ms").toLowerCase(); - switch (type2) { - case "years": - case "year": - case "yrs": - case "yr": - case "y": - return n3 * y3; - case "weeks": - case "week": - case "w": - return n3 * w3; - case "days": - case "day": - case "d": - return n3 * d3; - case "hours": - case "hour": - case "hrs": - case "hr": - case "h": - return n3 * h4; - case "minutes": - case "minute": - case "mins": - case "min": - case "m": - return n3 * m2; - case "seconds": - case "second": - case "secs": - case "sec": - case "s": - return n3 * s2; - case "milliseconds": - case "millisecond": - case "msecs": - case "msec": - case "ms": - return n3; - default: - return void 0; - } - } - function fmtShort(ms2) { - var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return Math.round(ms2 / d3) + "d"; - } - if (msAbs >= h4) { - return Math.round(ms2 / h4) + "h"; - } - if (msAbs >= m2) { - return Math.round(ms2 / m2) + "m"; - } - if (msAbs >= s2) { - return Math.round(ms2 / s2) + "s"; - } - return ms2 + "ms"; - } - function fmtLong(ms2) { - var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return plural(ms2, msAbs, d3, "day"); - } - if (msAbs >= h4) { - return plural(ms2, msAbs, h4, "hour"); - } - if (msAbs >= m2) { - return plural(ms2, msAbs, m2, "minute"); - } - if (msAbs >= s2) { - return plural(ms2, msAbs, s2, "second"); - } - return ms2 + " ms"; - } - function plural(ms2, msAbs, n3, name2) { - var isPlural = msAbs >= n3 * 1.5; - return Math.round(ms2 / n3) + " " + name2 + (isPlural ? "s" : ""); - } - return ms; -} -function setup(env2) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce2; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = requireMs(); - createDebug.destroy = destroy; - Object.keys(env2).forEach((key) => { - createDebug[key] = env2[key]; - }); - createDebug.names = []; - createDebug.skips = []; - createDebug.formatters = {}; - function selectColor(namespace) { - let hash2 = 0; - for (let i2 = 0; i2 < namespace.length; i2++) { - hash2 = (hash2 << 5) - hash2 + namespace.charCodeAt(i2); - hash2 |= 0; - } - return createDebug.colors[Math.abs(hash2) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; - function debug2(...args) { - if (!debug2.enabled) { - return; - } - const self2 = debug2; - const curr = Number(/* @__PURE__ */ new Date()); - const ms2 = curr - (prevTime || curr); - self2.diff = ms2; - self2.prev = prevTime; - self2.curr = curr; - prevTime = curr; - args[0] = createDebug.coerce(args[0]); - if (typeof args[0] !== "string") { - args.unshift("%O"); - } - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - if (match === "%%") { - return "%"; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === "function") { - const val = args[index]; - match = formatter.call(self2, val); - args.splice(index, 1); - index--; - } - return match; - }); - createDebug.formatArgs.call(self2, args); - const logFn = self2.log || createDebug.log; - logFn.apply(self2, args); - } - debug2.namespace = namespace; - debug2.useColors = createDebug.useColors(); - debug2.color = createDebug.selectColor(namespace); - debug2.extend = extend; - debug2.destroy = createDebug.destroy; - Object.defineProperty(debug2, "enabled", { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } - return enabledCache; - }, - set: (v3) => { - enableOverride = v3; - } - }); - if (typeof createDebug.init === "function") { - createDebug.init(debug2); - } - return debug2; - } - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; - createDebug.names = []; - createDebug.skips = []; - let i2; - const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); - const len = split.length; - for (i2 = 0; i2 < len; i2++) { - if (!split[i2]) { - continue; - } - namespaces = split[i2].replace(/\*/g, ".*?"); - if (namespaces[0] === "-") { - createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$")); - } else { - createDebug.names.push(new RegExp("^" + namespaces + "$")); - } - } - } - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace) - ].join(","); - createDebug.enable(""); - return namespaces; - } - function enabled(name2) { - if (name2[name2.length - 1] === "*") { - return true; - } - let i2; - let len; - for (i2 = 0, len = createDebug.skips.length; i2 < len; i2++) { - if (createDebug.skips[i2].test(name2)) { - return false; - } - } - for (i2 = 0, len = createDebug.names.length; i2 < len; i2++) { - if (createDebug.names[i2].test(name2)) { - return true; - } - } - return false; - } - function toNamespace(regexp) { - return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*"); - } - function coerce2(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; - } - function destroy() { - console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); - } - createDebug.enable(createDebug.load()); - return createDebug; -} -var common = setup; -(function(module2, exports2) { - exports2.formatArgs = formatArgs; - exports2.save = save; - exports2.load = load; - exports2.useColors = useColors; - exports2.storage = localstorage(); - exports2.destroy = /* @__PURE__ */ (() => { - let warned = false; - return () => { - if (!warned) { - warned = true; - console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); - } - }; - })(); - exports2.colors = [ - "#0000CC", - "#0000FF", - "#0033CC", - "#0033FF", - "#0066CC", - "#0066FF", - "#0099CC", - "#0099FF", - "#00CC00", - "#00CC33", - "#00CC66", - "#00CC99", - "#00CCCC", - "#00CCFF", - "#3300CC", - "#3300FF", - "#3333CC", - "#3333FF", - "#3366CC", - "#3366FF", - "#3399CC", - "#3399FF", - "#33CC00", - "#33CC33", - "#33CC66", - "#33CC99", - "#33CCCC", - "#33CCFF", - "#6600CC", - "#6600FF", - "#6633CC", - "#6633FF", - "#66CC00", - "#66CC33", - "#9900CC", - "#9900FF", - "#9933CC", - "#9933FF", - "#99CC00", - "#99CC33", - "#CC0000", - "#CC0033", - "#CC0066", - "#CC0099", - "#CC00CC", - "#CC00FF", - "#CC3300", - "#CC3333", - "#CC3366", - "#CC3399", - "#CC33CC", - "#CC33FF", - "#CC6600", - "#CC6633", - "#CC9900", - "#CC9933", - "#CCCC00", - "#CCCC33", - "#FF0000", - "#FF0033", - "#FF0066", - "#FF0099", - "#FF00CC", - "#FF00FF", - "#FF3300", - "#FF3333", - "#FF3366", - "#FF3399", - "#FF33CC", - "#FF33FF", - "#FF6600", - "#FF6633", - "#FF9900", - "#FF9933", - "#FFCC00", - "#FFCC33" - ]; - function useColors() { - if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) { - return true; - } - if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } - return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 - typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker - typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); - } - function formatArgs(args) { - args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff); - if (!this.useColors) { - return; - } - const c2 = "color: " + this.color; - args.splice(1, 0, c2, "color: inherit"); - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, (match) => { - if (match === "%%") { - return; - } - index++; - if (match === "%c") { - lastC = index; - } - }); - args.splice(lastC, 0, c2); - } - exports2.log = console.debug || console.log || (() => { - }); - function save(namespaces) { - try { - if (namespaces) { - exports2.storage.setItem("debug", namespaces); - } else { - exports2.storage.removeItem("debug"); - } - } catch (error) { - } - } - function load() { - let r2; - try { - r2 = exports2.storage.getItem("debug"); - } catch (error) { - } - if (!r2 && typeof process !== "undefined" && "env" in process) { - r2 = process.env.DEBUG; - } - return r2; - } - function localstorage() { - try { - return localStorage; - } catch (error) { - } - } - module2.exports = common(exports2); - const { formatters } = module2.exports; - formatters.j = function(v3) { - try { - return JSON.stringify(v3); - } catch (error) { - return "[UnexpectedJSONParseError]: " + error.message; - } - }; -})(browser, browser.exports); -var browserExports = browser.exports; -const debug = /* @__PURE__ */ getDefaultExportFromCjs(browserExports); -const log_sdk = debug("wallet:sdk"); -log_sdk.enabled = true; -exports.PAGE_SIZE = PAGE_SIZE; -exports.R = R$4; -exports.T = T$1; -exports.a = a$3; -exports.aleoAddressRegex = aleoAddressRegex; -exports.aleoFieldRegex = aleoFieldRegex; -exports.aleoPrivateKeyRegex = aleoPrivateKeyRegex; -exports.aleoTransactionIdRegex = aleoTransactionIdRegex; -exports.aleoU32 = aleoU32; -exports.aleoU64 = aleoU64; -exports.aleoViewKeyRegex = aleoViewKeyRegex; -exports.checkForDesktopConnection = checkForDesktopConnection; -exports.configureConnection = configureConnection; -exports.connect = connect; -exports.createSharedState = createSharedState; -exports.decrypt = decrypt; -exports.disconnect = disconnect; -exports.emitter = emitter; -exports.getAccount = getAccount; -exports.getBalance = getBalance; -exports.getEvent = getEvent; -exports.getEvents = getEvents; -exports.getRecords = getRecords; -exports.getWalletConnectModalSignClient = getWalletConnectModalSignClient; -exports.hasInjectedConnection = hasInjectedConnection; -exports.importSharedState = importSharedState; -exports.log_sdk = log_sdk; -exports.ne = ne; -exports.oe = oe$1; -exports.p = p$3; -exports.projectId = projectId; -exports.requestCreateEvent = requestCreateEvent; -exports.requestSignature = requestSignature; -exports.se = se; -exports.signClient_puzzleProps = signClient_puzzleProps; -exports.te = te$2; -exports.wc_aleo_chains = wc_aleo_chains; -exports.wc_aleo_methods = wc_aleo_methods; -exports.wc_events = wc_events; -exports.web3modal_puzzle_props = web3modal_puzzle_props; -exports.web3modal_puzzle_props_android = web3modal_puzzle_props_android; -exports.web3modal_puzzle_props_default = web3modal_puzzle_props_default; -exports.y = y$3; -exports.zodAddress = zodAddress; -exports.zodEventStatus = zodEventStatus; -exports.zodEventType = zodEventType; -exports.zodField = zodField; -exports.zodNetwork = zodNetwork; -exports.zodPrivateKey = zodPrivateKey; -exports.zodTransactionId = zodTransactionId; -exports.zodU32 = zodU32; -exports.zodU64 = zodU64; -exports.zodViewKey = zodViewKey; -exports.zodVisibility = zodVisibility; diff --git a/packages/core/dist/puzzle.cjs.js b/packages/core/dist/puzzle.cjs.js index dbc04310..248348aa 100644 --- a/packages/core/dist/puzzle.cjs.js +++ b/packages/core/dist/puzzle.cjs.js @@ -1,10 +1,6 @@ "use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); -const index = require("./index-rLSm9-3e.cjs"); -Object.defineProperty(exports, "AssetType", { - enumerable: true, - get: () => index.AssetType -}); +const index = require("./index-Cc7iYKrS.cjs"); Object.defineProperty(exports, "EventStatus", { enumerable: true, get: () => index.EventStatus @@ -29,6 +25,7 @@ exports.aleoTransactionIdRegex = index.aleoTransactionIdRegex; exports.aleoU32 = index.aleoU32; exports.aleoU64 = index.aleoU64; exports.aleoViewKeyRegex = index.aleoViewKeyRegex; +exports.chainIdToNetwork = index.chainIdToNetwork; exports.checkForDesktopConnection = index.checkForDesktopConnection; exports.configureConnection = index.configureConnection; exports.connect = index.connect; @@ -49,6 +46,7 @@ exports.getWalletConnectModalSignClient = index.getWalletConnectModalSignClient; exports.hasInjectedConnection = index.hasInjectedConnection; exports.importSharedState = index.importSharedState; exports.log_sdk = index.log_sdk; +exports.networkToChainId = index.networkToChainId; exports.projectId = index.projectId; exports.requestCreateEvent = index.requestCreateEvent; exports.requestSignature = index.requestSignature; @@ -56,6 +54,8 @@ exports.signClient_puzzleProps = index.signClient_puzzleProps; exports.wc_aleo_chains = index.wc_aleo_chains; exports.wc_aleo_methods = index.wc_aleo_methods; exports.wc_events = index.wc_events; +exports.wc_optional_aleo_chains = index.wc_optional_aleo_chains; +exports.wc_required_aleo_chains = index.wc_required_aleo_chains; exports.web3modal_puzzle_props = index.web3modal_puzzle_props; exports.web3modal_puzzle_props_android = index.web3modal_puzzle_props_android; exports.web3modal_puzzle_props_default = index.web3modal_puzzle_props_default; diff --git a/packages/core/dist/puzzle.es.js b/packages/core/dist/puzzle.es.js index afcb3535..591fc910 100644 --- a/packages/core/dist/puzzle.es.js +++ b/packages/core/dist/puzzle.es.js @@ -1,45 +1,48 @@ -import { A, E, b, N, P, V, c, d, e, f, g, h, i, a0, a4, D, a3, G, H, I, a2, B, C, J, K, M, a5, a1, L, $, W, F, O, _, S, Q, U, Z, X, Y, z, j, k, l, m, q, r, u, v, w, x } from "./index-0kpjH3lP.js"; +import { E, a, N, P, V, b, c, d, e, f, g, h, a1, a3, a7, C, a6, F, G, H, a5, A, B, I, J, L, a8, a4, K, a2, a0, X, D, M, $, U, O, W, S, Q, _, Y, Z, z, j, k, l, m, q, r, u, v, w, x } from "./index-CB32TCFB.js"; export { - A as AssetType, E as EventStatus, - b as EventType, + a as EventType, N as Network, P as PAGE_SIZE, V as Visibility, - c as aleoAddressRegex, - d as aleoFieldRegex, - e as aleoPrivateKeyRegex, - f as aleoTransactionIdRegex, - g as aleoU32, - h as aleoU64, - i as aleoViewKeyRegex, - a0 as checkForDesktopConnection, - a4 as configureConnection, - D as connect, - a3 as connection, - G as createSharedState, - H as decrypt, - I as disconnect, - a2 as emitter, - B as getAccount, - C as getBalance, - J as getEvent, - K as getEvents, - M as getRecords, - a5 as getWalletConnectModalSignClient, - a1 as hasInjectedConnection, - L as importSharedState, - $ as log_sdk, - W as projectId, - F as requestCreateEvent, - O as requestSignature, - _ as signClient_puzzleProps, - S as wc_aleo_chains, - Q as wc_aleo_methods, - U as wc_events, - Z as web3modal_puzzle_props, - X as web3modal_puzzle_props_android, - Y as web3modal_puzzle_props_default, + b as aleoAddressRegex, + c as aleoFieldRegex, + d as aleoPrivateKeyRegex, + e as aleoTransactionIdRegex, + f as aleoU32, + g as aleoU64, + h as aleoViewKeyRegex, + a1 as chainIdToNetwork, + a3 as checkForDesktopConnection, + a7 as configureConnection, + C as connect, + a6 as connection, + F as createSharedState, + G as decrypt, + H as disconnect, + a5 as emitter, + A as getAccount, + B as getBalance, + I as getEvent, + J as getEvents, + L as getRecords, + a8 as getWalletConnectModalSignClient, + a4 as hasInjectedConnection, + K as importSharedState, + a2 as log_sdk, + a0 as networkToChainId, + X as projectId, + D as requestCreateEvent, + M as requestSignature, + $ as signClient_puzzleProps, + U as wc_aleo_chains, + O as wc_aleo_methods, + W as wc_events, + S as wc_optional_aleo_chains, + Q as wc_required_aleo_chains, + _ as web3modal_puzzle_props, + Y as web3modal_puzzle_props_android, + Z as web3modal_puzzle_props_default, z as zodAddress, j as zodEventStatus, k as zodEventType, diff --git a/packages/core/dist/puzzle.umd.js b/packages/core/dist/puzzle.umd.js index 9a42b7e6..9d7de6e7 100644 --- a/packages/core/dist/puzzle.umd.js +++ b/packages/core/dist/puzzle.umd.js @@ -3,8 +3,8 @@ })(this, function(exports2) { "use strict"; const t$4 = Symbol(); - const s$4 = Object.getPrototypeOf, c$5 = /* @__PURE__ */ new WeakMap(), l$6 = (e2) => e2 && (c$5.has(e2) ? c$5.get(e2) : s$4(e2) === Object.prototype || s$4(e2) === Array.prototype), y$5 = (e2) => l$6(e2) && e2[t$4] || null, h$7 = (e2, t2 = true) => { - c$5.set(e2, t2); + const s$6 = Object.getPrototypeOf, c$6 = /* @__PURE__ */ new WeakMap(), l$6 = (e2) => e2 && (c$6.has(e2) ? c$6.get(e2) : s$6(e2) === Object.prototype || s$6(e2) === Array.prototype), y$6 = (e2) => l$6(e2) && e2[t$4] || null, h$6 = (e2, t2 = true) => { + c$6.set(e2, t2); }; var define_import_meta_env_default = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false }; const isObject = (x2) => typeof x2 === "object" && x2 !== null; @@ -25,7 +25,7 @@ return cache[1]; } const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); - h$7(snap, true); + h$6(snap, true); snapCache.set(target, [version2, snap]); Reflect.ownKeys(target).forEach((key) => { if (Object.getOwnPropertyDescriptor(snap, key)) { @@ -40,7 +40,7 @@ configurable: true }; if (refSet.has(value)) { - h$7(value, false); + h$6(value, false); } else if (value instanceof Promise) { delete desc.value; desc.get = () => handlePromise(value); @@ -104,11 +104,11 @@ } }; const removePropListener = (prop) => { - var _a; + var _a2; const entry = propProxyStates.get(prop); if (entry) { propProxyStates.delete(prop); - (_a = entry[1]) == null ? void 0 : _a.call(entry); + (_a2 = entry[1]) == null ? void 0 : _a2.call(entry); } }; const addListener = (listener) => { @@ -154,7 +154,7 @@ } removePropListener(prop); if (isObject(value)) { - value = y$5(value) || value; + value = y$6(value) || value; } let nextValue = value; if (value instanceof Promise) { @@ -234,10 +234,6 @@ let isListenerActive = false; const listener = (op) => { ops.push(op); - if (notifyInSync) { - callback(ops.splice(0)); - return; - } if (!promise) { promise = Promise.resolve().then(() => { promise = void 0; @@ -262,388 +258,240 @@ const [target, ensureVersion, createSnapshot] = proxyState; return createSnapshot(target, ensureVersion(), handlePromise); } - const o$6 = proxy({ - history: ["ConnectWallet"], - view: "ConnectWallet", - data: void 0 - }), T$3 = { - state: o$6, - subscribe(e2) { - return subscribe(o$6, () => e2(o$6)); - }, - push(e2, t2) { - e2 !== o$6.view && (o$6.view = e2, t2 && (o$6.data = t2), o$6.history.push(e2)); - }, - reset(e2) { - o$6.view = e2, o$6.history = [e2]; - }, - replace(e2) { - o$6.history.length > 1 && (o$6.history[o$6.history.length - 1] = e2, o$6.view = e2); - }, - goBack() { - if (o$6.history.length > 1) { - o$6.history.pop(); - const [e2] = o$6.history.slice(-1); - o$6.view = e2; - } - }, - setData(e2) { - o$6.data = e2; - } - }, a$5 = { - WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", - WCM_VERSION: "WCM_VERSION", - RECOMMENDED_WALLET_AMOUNT: 9, - isMobile() { - return typeof window < "u" ? Boolean( - window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test( - navigator.userAgent - ) - ) : false; - }, - isAndroid() { - return a$5.isMobile() && navigator.userAgent.toLowerCase().includes("android"); - }, - isIos() { - const e2 = navigator.userAgent.toLowerCase(); - return a$5.isMobile() && (e2.includes("iphone") || e2.includes("ipad")); - }, - isHttpUrl(e2) { - return e2.startsWith("http://") || e2.startsWith("https://"); - }, - isArray(e2) { - return Array.isArray(e2) && e2.length > 0; - }, - formatNativeUrl(e2, t2, s2) { - if (a$5.isHttpUrl(e2)) - return this.formatUniversalUrl(e2, t2, s2); - let n2 = e2; - n2.includes("://") || (n2 = e2.replaceAll("/", "").replaceAll(":", ""), n2 = `${n2}://`), n2.endsWith("/") || (n2 = `${n2}/`), this.setWalletConnectDeepLink(n2, s2); - const i2 = encodeURIComponent(t2); - return `${n2}wc?uri=${i2}`; - }, - formatUniversalUrl(e2, t2, s2) { - if (!a$5.isHttpUrl(e2)) - return this.formatNativeUrl(e2, t2, s2); - let n2 = e2; - n2.endsWith("/") || (n2 = `${n2}/`), this.setWalletConnectDeepLink(n2, s2); - const i2 = encodeURIComponent(t2); - return `${n2}wc?uri=${i2}`; - }, - async wait(e2) { - return new Promise((t2) => { - setTimeout(t2, e2); - }); - }, - openHref(e2, t2) { - window.open(e2, t2, "noreferrer noopener"); - }, - setWalletConnectDeepLink(e2, t2) { - try { - localStorage.setItem( - a$5.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: e2, name: t2 }) - ); - } catch { - console.info("Unable to set WalletConnect deep link"); - } - }, - setWalletConnectAndroidDeepLink(e2) { - try { - const [t2] = e2.split("?"); - localStorage.setItem( - a$5.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: t2, name: "Android" }) - ); - } catch { - console.info("Unable to set WalletConnect android deep link"); - } - }, - removeWalletConnectDeepLink() { - try { - localStorage.removeItem(a$5.WALLETCONNECT_DEEPLINK_CHOICE); - } catch { - console.info("Unable to remove WalletConnect deep link"); - } - }, - setModalVersionInStorage() { - try { - typeof localStorage < "u" && localStorage.setItem(a$5.WCM_VERSION, "2.6.2"); - } catch { - console.info("Unable to set Web3Modal version in storage"); - } - }, - getWalletRouterData() { - var e2; - const t2 = (e2 = T$3.state.data) == null ? void 0 : e2.Wallet; - if (!t2) - throw new Error('Missing "Wallet" view data'); - return t2; + const o$6 = proxy({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), T$3 = { state: o$6, subscribe(e2) { + return subscribe(o$6, () => e2(o$6)); + }, push(e2, t2) { + e2 !== o$6.view && (o$6.view = e2, t2 && (o$6.data = t2), o$6.history.push(e2)); + }, reset(e2) { + o$6.view = e2, o$6.history = [e2]; + }, replace(e2) { + o$6.history.length > 1 && (o$6.history[o$6.history.length - 1] = e2, o$6.view = e2); + }, goBack() { + if (o$6.history.length > 1) { + o$6.history.pop(); + const [e2] = o$6.history.slice(-1); + o$6.view = e2; + } + }, setData(e2) { + o$6.data = e2; + } }, i$5 = { WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", WCM_VERSION: "WCM_VERSION", RECOMMENDED_WALLET_AMOUNT: 9, isMobile() { + return typeof window < "u" ? Boolean(window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : false; + }, isAndroid() { + return i$5.isMobile() && navigator.userAgent.toLowerCase().includes("android"); + }, isIos() { + const e2 = navigator.userAgent.toLowerCase(); + return i$5.isMobile() && (e2.includes("iphone") || e2.includes("ipad")); + }, isHttpUrl(e2) { + return e2.startsWith("http://") || e2.startsWith("https://"); + }, isArray(e2) { + return Array.isArray(e2) && e2.length > 0; + }, formatNativeUrl(e2, t2, s2) { + if (i$5.isHttpUrl(e2)) + return this.formatUniversalUrl(e2, t2, s2); + let n2 = e2; + n2.includes("://") || (n2 = e2.replaceAll("/", "").replaceAll(":", ""), n2 = `${n2}://`), n2.endsWith("/") || (n2 = `${n2}/`), this.setWalletConnectDeepLink(n2, s2); + const r2 = encodeURIComponent(t2); + return `${n2}wc?uri=${r2}`; + }, formatUniversalUrl(e2, t2, s2) { + if (!i$5.isHttpUrl(e2)) + return this.formatNativeUrl(e2, t2, s2); + let n2 = e2; + n2.endsWith("/") || (n2 = `${n2}/`), this.setWalletConnectDeepLink(n2, s2); + const r2 = encodeURIComponent(t2); + return `${n2}wc?uri=${r2}`; + }, async wait(e2) { + return new Promise((t2) => { + setTimeout(t2, e2); + }); + }, openHref(e2, t2) { + window.open(e2, t2, "noreferrer noopener"); + }, setWalletConnectDeepLink(e2, t2) { + try { + localStorage.setItem(i$5.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: e2, name: t2 })); + } catch { + console.info("Unable to set WalletConnect deep link"); } - }, _$5 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), r$4 = proxy({ - enabled: _$5, - userSessionId: "", - events: [], - connectedWalletId: void 0 - }), R$5 = { - state: r$4, - subscribe(e2) { - return subscribe(r$4.events, () => e2(snapshot(r$4.events[r$4.events.length - 1]))); - }, - initialize() { - r$4.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (r$4.userSessionId = crypto.randomUUID()); - }, - setConnectedWalletId(e2) { - r$4.connectedWalletId = e2; - }, - click(e2) { - if (r$4.enabled) { - const t2 = { - type: "CLICK", - name: e2.name, - userSessionId: r$4.userSessionId, - timestamp: Date.now(), - data: e2 - }; - r$4.events.push(t2); - } - }, - track(e2) { - if (r$4.enabled) { - const t2 = { - type: "TRACK", - name: e2.name, - userSessionId: r$4.userSessionId, - timestamp: Date.now(), - data: e2 - }; - r$4.events.push(t2); - } - }, - view(e2) { - if (r$4.enabled) { - const t2 = { - type: "VIEW", - name: e2.name, - userSessionId: r$4.userSessionId, - timestamp: Date.now(), - data: e2 - }; - r$4.events.push(t2); - } - } - }, c$4 = proxy({ - chains: void 0, - walletConnectUri: void 0, - isAuth: false, - isCustomDesktop: false, - isCustomMobile: false, - isDataLoaded: false, - isUiLoaded: false - }), p$4 = { - state: c$4, - subscribe(e2) { - return subscribe(c$4, () => e2(c$4)); - }, - setChains(e2) { - c$4.chains = e2; - }, - setWalletConnectUri(e2) { - c$4.walletConnectUri = e2; - }, - setIsCustomDesktop(e2) { - c$4.isCustomDesktop = e2; - }, - setIsCustomMobile(e2) { - c$4.isCustomMobile = e2; - }, - setIsDataLoaded(e2) { - c$4.isDataLoaded = e2; - }, - setIsUiLoaded(e2) { - c$4.isUiLoaded = e2; - }, - setIsAuth(e2) { - c$4.isAuth = e2; - } - }, W$2 = proxy({ - projectId: "", - mobileWallets: void 0, - desktopWallets: void 0, - walletImages: void 0, - chains: void 0, - enableAuthMode: false, - enableExplorer: true, - explorerExcludedWalletIds: void 0, - explorerRecommendedWalletIds: void 0, - termsOfServiceUrl: void 0, - privacyPolicyUrl: void 0 - }), y$4 = { - state: W$2, - subscribe(e2) { - return subscribe(W$2, () => e2(W$2)); - }, - setConfig(e2) { - var t2, s2; - R$5.initialize(), p$4.setChains(e2.chains), p$4.setIsAuth(Boolean(e2.enableAuthMode)), p$4.setIsCustomMobile( - Boolean((t2 = e2.mobileWallets) == null ? void 0 : t2.length) - ), p$4.setIsCustomDesktop( - Boolean((s2 = e2.desktopWallets) == null ? void 0 : s2.length) - ), a$5.setModalVersionInStorage(), Object.assign(W$2, e2); + }, setWalletConnectAndroidDeepLink(e2) { + try { + const [t2] = e2.split("?"); + localStorage.setItem(i$5.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: t2, name: "Android" })); + } catch { + console.info("Unable to set WalletConnect android deep link"); } - }; - var V$3 = Object.defineProperty, D$6 = Object.getOwnPropertySymbols, H$3 = Object.prototype.hasOwnProperty, B$4 = Object.prototype.propertyIsEnumerable, M$2 = (e2, t2, s2) => t2 in e2 ? V$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, K$2 = (e2, t2) => { + }, removeWalletConnectDeepLink() { + try { + localStorage.removeItem(i$5.WALLETCONNECT_DEEPLINK_CHOICE); + } catch { + console.info("Unable to remove WalletConnect deep link"); + } + }, setModalVersionInStorage() { + try { + typeof localStorage < "u" && localStorage.setItem(i$5.WCM_VERSION, "0.0.6"); + } catch { + console.info("Unable to set Web3Modal version in storage"); + } + }, getWalletRouterData() { + var e2; + const t2 = (e2 = T$3.state.data) == null ? void 0 : e2.Wallet; + if (!t2) + throw new Error('Missing "Wallet" view data'); + return t2; + } }, _$4 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), a$4 = proxy({ enabled: _$4, userSessionId: "", events: [], connectedWalletId: void 0 }), R$2 = { state: a$4, subscribe(e2) { + return subscribe(a$4.events, () => e2(snapshot(a$4.events[a$4.events.length - 1]))); + }, initialize() { + a$4.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (a$4.userSessionId = crypto.randomUUID()); + }, setConnectedWalletId(e2) { + a$4.connectedWalletId = e2; + }, click(e2) { + if (a$4.enabled) { + const t2 = { type: "CLICK", name: e2.name, userSessionId: a$4.userSessionId, timestamp: Date.now(), data: e2 }; + a$4.events.push(t2); + } + }, track(e2) { + if (a$4.enabled) { + const t2 = { type: "TRACK", name: e2.name, userSessionId: a$4.userSessionId, timestamp: Date.now(), data: e2 }; + a$4.events.push(t2); + } + }, view(e2) { + if (a$4.enabled) { + const t2 = { type: "VIEW", name: e2.name, userSessionId: a$4.userSessionId, timestamp: Date.now(), data: e2 }; + a$4.events.push(t2); + } + } }, c$5 = proxy({ chains: void 0, walletConnectUri: void 0, isAuth: false, isCustomDesktop: false, isCustomMobile: false, isDataLoaded: false, isUiLoaded: false }), p$3 = { state: c$5, subscribe(e2) { + return subscribe(c$5, () => e2(c$5)); + }, setChains(e2) { + c$5.chains = e2; + }, setWalletConnectUri(e2) { + c$5.walletConnectUri = e2; + }, setIsCustomDesktop(e2) { + c$5.isCustomDesktop = e2; + }, setIsCustomMobile(e2) { + c$5.isCustomMobile = e2; + }, setIsDataLoaded(e2) { + c$5.isDataLoaded = e2; + }, setIsUiLoaded(e2) { + c$5.isUiLoaded = e2; + }, setIsAuth(e2) { + c$5.isAuth = e2; + } }, W = proxy({ projectId: "", mobileWallets: void 0, desktopWallets: void 0, walletImages: void 0, chains: void 0, enableAuthMode: false, enableExplorer: true, explorerExcludedWalletIds: void 0, explorerRecommendedWalletIds: void 0, termsOfServiceUrl: void 0, privacyPolicyUrl: void 0 }), y$5 = { state: W, subscribe(e2) { + return subscribe(W, () => e2(W)); + }, setConfig(e2) { + var t2, s2; + R$2.initialize(), p$3.setChains(e2.chains), p$3.setIsAuth(Boolean(e2.enableAuthMode)), p$3.setIsCustomMobile(Boolean((t2 = e2.mobileWallets) == null ? void 0 : t2.length)), p$3.setIsCustomDesktop(Boolean((s2 = e2.desktopWallets) == null ? void 0 : s2.length)), i$5.setModalVersionInStorage(), Object.assign(W, e2); + } }; + var V$4 = Object.defineProperty, D$4 = Object.getOwnPropertySymbols, H$2 = Object.prototype.hasOwnProperty, B$3 = Object.prototype.propertyIsEnumerable, M$2 = (e2, t2, s2) => t2 in e2 ? V$4(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, K$5 = (e2, t2) => { for (var s2 in t2 || (t2 = {})) - H$3.call(t2, s2) && M$2(e2, s2, t2[s2]); - if (D$6) - for (var s2 of D$6(t2)) - B$4.call(t2, s2) && M$2(e2, s2, t2[s2]); + H$2.call(t2, s2) && M$2(e2, s2, t2[s2]); + if (D$4) + for (var s2 of D$4(t2)) + B$3.call(t2, s2) && M$2(e2, s2, t2[s2]); return e2; }; - const L$4 = "https://explorer-api.walletconnect.com", E$3 = "wcm", O$3 = "js-2.6.2"; - async function w$6(e2, t2) { - const s2 = K$2({ sdkType: E$3, sdkVersion: O$3 }, t2), n2 = new URL(e2, L$4); - return n2.searchParams.append("projectId", y$4.state.projectId), Object.entries(s2).forEach(([i2, l2]) => { - l2 && n2.searchParams.append(i2, String(l2)); + const L$7 = "https://explorer-api.walletconnect.com", E$4 = "wcm", O$3 = "js-0.0.6"; + async function w$5(e2, t2) { + const s2 = K$5({ sdkType: E$4, sdkVersion: O$3 }, t2), n2 = new URL(e2, L$7); + return n2.searchParams.append("projectId", y$5.state.projectId), Object.entries(s2).forEach(([r2, l2]) => { + l2 && n2.searchParams.append(r2, String(l2)); }), (await fetch(n2)).json(); } - const m$3 = { - async getDesktopListings(e2) { - return w$6("/w3m/v1/getDesktopListings", e2); - }, - async getMobileListings(e2) { - return w$6("/w3m/v1/getMobileListings", e2); - }, - async getInjectedListings(e2) { - return w$6("/w3m/v1/getInjectedListings", e2); - }, - async getAllListings(e2) { - return w$6("/w3m/v1/getAllListings", e2); - }, - getWalletImageUrl(e2) { - return `${L$4}/w3m/v1/getWalletImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; - }, - getAssetImageUrl(e2) { - return `${L$4}/w3m/v1/getAssetImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; - } - }; - var z$4 = Object.defineProperty, j$4 = Object.getOwnPropertySymbols, J$2 = Object.prototype.hasOwnProperty, q$3 = Object.prototype.propertyIsEnumerable, k$3 = (e2, t2, s2) => t2 in e2 ? z$4(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, F$4 = (e2, t2) => { + const m$3 = { async getDesktopListings(e2) { + return w$5("/w3m/v1/getDesktopListings", e2); + }, async getMobileListings(e2) { + return w$5("/w3m/v1/getMobileListings", e2); + }, async getInjectedListings(e2) { + return w$5("/w3m/v1/getInjectedListings", e2); + }, async getAllListings(e2) { + return w$5("/w3m/v1/getAllListings", e2); + }, getWalletImageUrl(e2) { + return `${L$7}/w3m/v1/getWalletImage/${e2}?projectId=${y$5.state.projectId}&sdkType=${E$4}&sdkVersion=${O$3}`; + }, getAssetImageUrl(e2) { + return `${L$7}/w3m/v1/getAssetImage/${e2}?projectId=${y$5.state.projectId}&sdkType=${E$4}&sdkVersion=${O$3}`; + } }; + var z$5 = Object.defineProperty, j$4 = Object.getOwnPropertySymbols, J$2 = Object.prototype.hasOwnProperty, q$3 = Object.prototype.propertyIsEnumerable, k$5 = (e2, t2, s2) => t2 in e2 ? z$5(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, F$2 = (e2, t2) => { for (var s2 in t2 || (t2 = {})) - J$2.call(t2, s2) && k$3(e2, s2, t2[s2]); + J$2.call(t2, s2) && k$5(e2, s2, t2[s2]); if (j$4) for (var s2 of j$4(t2)) - q$3.call(t2, s2) && k$3(e2, s2, t2[s2]); + q$3.call(t2, s2) && k$5(e2, s2, t2[s2]); return e2; }; - const N$4 = a$5.isMobile(), d$4 = proxy({ - wallets: { listings: [], total: 0, page: 1 }, - search: { listings: [], total: 0, page: 1 }, - recomendedWallets: [] - }), te$3 = { - state: d$4, - async getRecomendedWallets() { - const { explorerRecommendedWalletIds: e2, explorerExcludedWalletIds: t2 } = y$4.state; - if (e2 === "NONE" || t2 === "ALL" && !e2) - return d$4.recomendedWallets; - if (a$5.isArray(e2)) { - const s2 = { recommendedIds: e2.join(",") }, { listings: n2 } = await m$3.getAllListings(s2), i2 = Object.values(n2); - i2.sort && i2.sort((l2, v2) => { - const b2 = e2.indexOf(l2.id), f2 = e2.indexOf(v2.id); - return b2 - f2; - }), d$4.recomendedWallets = i2; - } else { - const { chains: s2, isAuth: n2 } = p$4.state, i2 = s2 == null ? void 0 : s2.join(","), l2 = a$5.isArray(t2), v2 = { - page: 1, - sdks: n2 ? "auth_v1" : void 0, - entries: a$5.RECOMMENDED_WALLET_AMOUNT, - chains: i2, - version: 2, - excludedIds: l2 ? t2.join(",") : void 0 - }, { listings: b2 } = N$4 ? await m$3.getMobileListings(v2) : await m$3.getDesktopListings(v2); - d$4.recomendedWallets = Object.values(b2); - } - return d$4.recomendedWallets; - }, - async getWallets(e2) { - const t2 = F$4({}, e2), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n2 } = y$4.state, { recomendedWallets: i2 } = d$4; - if (n2 === "ALL") - return d$4.wallets; - i2.length ? t2.excludedIds = i2.map((x2) => x2.id).join(",") : a$5.isArray(s2) && (t2.excludedIds = s2.join(",")), a$5.isArray(n2) && (t2.excludedIds = [t2.excludedIds, n2].filter(Boolean).join(",")), p$4.state.isAuth && (t2.sdks = "auth_v1"); - const { page: l2, search: v2 } = e2, { listings: b2, total: f2 } = N$4 ? await m$3.getMobileListings(t2) : await m$3.getDesktopListings(t2), A2 = Object.values(b2), U2 = v2 ? "search" : "wallets"; - return d$4[U2] = { listings: [...d$4[U2].listings, ...A2], total: f2, page: l2 ?? 1 }, { listings: A2, total: f2 }; - }, - getWalletImageUrl(e2) { - return m$3.getWalletImageUrl(e2); - }, - getAssetImageUrl(e2) { - return m$3.getAssetImageUrl(e2); - }, - resetSearch() { - d$4.search = { listings: [], total: 0, page: 1 }; - } - }, I$2 = proxy({ open: false }), se$1 = { - state: I$2, - subscribe(e2) { - return subscribe(I$2, () => e2(I$2)); - }, - async open(e2) { - return new Promise((t2) => { - const { isUiLoaded: s2, isDataLoaded: n2 } = p$4.state; - if (a$5.removeWalletConnectDeepLink(), p$4.setWalletConnectUri(e2 == null ? void 0 : e2.uri), p$4.setChains(e2 == null ? void 0 : e2.chains), T$3.reset("ConnectWallet"), s2 && n2) - I$2.open = true, t2(); - else { - const i2 = setInterval(() => { - const l2 = p$4.state; - l2.isUiLoaded && l2.isDataLoaded && (clearInterval(i2), I$2.open = true, t2()); - }, 200); - } - }); - }, - close() { - I$2.open = false; - } - }; - var G$3 = Object.defineProperty, $$3 = Object.getOwnPropertySymbols, Q$4 = Object.prototype.hasOwnProperty, X$2 = Object.prototype.propertyIsEnumerable, S$5 = (e2, t2, s2) => t2 in e2 ? G$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, Y$1 = (e2, t2) => { + const N$4 = i$5.isMobile(), d$6 = proxy({ wallets: { listings: [], total: 0, page: 1 }, search: { listings: [], total: 0, page: 1 }, recomendedWallets: [] }), te$1 = { state: d$6, async getRecomendedWallets() { + const { explorerRecommendedWalletIds: e2, explorerExcludedWalletIds: t2 } = y$5.state; + if (e2 === "NONE" || t2 === "ALL" && !e2) + return d$6.recomendedWallets; + if (i$5.isArray(e2)) { + const s2 = { recommendedIds: e2.join(",") }, { listings: n2 } = await m$3.getAllListings(s2), r2 = Object.values(n2); + n2 && r2.sort && r2.sort((l2, v2) => { + const b2 = e2.indexOf(l2.id), f2 = e2.indexOf(v2.id); + return b2 - f2; + }), d$6.recomendedWallets = r2; + } else { + const { chains: s2, isAuth: n2 } = p$3.state, r2 = s2 == null ? void 0 : s2.join(","), l2 = i$5.isArray(t2), v2 = { page: 1, sdks: n2 ? "auth_v1" : void 0, entries: i$5.RECOMMENDED_WALLET_AMOUNT, chains: r2, version: 2, excludedIds: l2 ? t2.join(",") : void 0 }, { listings: b2 } = N$4 ? await m$3.getMobileListings(v2) : await m$3.getDesktopListings(v2); + d$6.recomendedWallets = Object.values(b2); + } + return d$6.recomendedWallets; + }, async getWallets(e2) { + const t2 = F$2({}, e2), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n2 } = y$5.state, { recomendedWallets: r2 } = d$6; + if (n2 === "ALL") + return d$6.wallets; + r2.length ? t2.excludedIds = r2.map((x2) => x2.id).join(",") : i$5.isArray(s2) && (t2.excludedIds = s2.join(",")), i$5.isArray(n2) && (t2.excludedIds = [t2.excludedIds, n2].filter(Boolean).join(",")), p$3.state.isAuth && (t2.sdks = "auth_v1"); + const { page: l2, search: v2 } = e2, { listings: b2, total: f2 } = N$4 ? await m$3.getMobileListings(t2) : await m$3.getDesktopListings(t2), A2 = Object.values(b2), U2 = v2 ? "search" : "wallets"; + return d$6[U2] = { listings: [...d$6[U2].listings, ...A2], total: f2, page: l2 ?? 1 }, { listings: A2, total: f2 }; + }, getWalletImageUrl(e2) { + return m$3.getWalletImageUrl(e2); + }, getAssetImageUrl(e2) { + return m$3.getAssetImageUrl(e2); + }, resetSearch() { + d$6.search = { listings: [], total: 0, page: 1 }; + } }, I$4 = proxy({ open: false }), se$4 = { state: I$4, subscribe(e2) { + return subscribe(I$4, () => e2(I$4)); + }, async open(e2) { + return new Promise((t2) => { + const { isUiLoaded: s2, isDataLoaded: n2 } = p$3.state; + if (i$5.removeWalletConnectDeepLink(), p$3.setWalletConnectUri(e2 == null ? void 0 : e2.uri), p$3.setChains(e2 == null ? void 0 : e2.chains), T$3.reset("ConnectWallet"), s2 && n2) + I$4.open = true, t2(); + else { + const r2 = setInterval(() => { + const l2 = p$3.state; + l2.isUiLoaded && l2.isDataLoaded && (clearInterval(r2), I$4.open = true, t2()); + }, 200); + } + }); + }, close() { + I$4.open = false; + } }; + var G$2 = Object.defineProperty, $$1 = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$2 = Object.prototype.propertyIsEnumerable, S$7 = (e2, t2, s2) => t2 in e2 ? G$2(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, Y$1 = (e2, t2) => { for (var s2 in t2 || (t2 = {})) - Q$4.call(t2, s2) && S$5(e2, s2, t2[s2]); - if ($$3) - for (var s2 of $$3(t2)) - X$2.call(t2, s2) && S$5(e2, s2, t2[s2]); + Q$3.call(t2, s2) && S$7(e2, s2, t2[s2]); + if ($$1) + for (var s2 of $$1(t2)) + X$2.call(t2, s2) && S$7(e2, s2, t2[s2]); return e2; }; - function Z$4() { + function Z$3() { return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; } - const C$1 = proxy({ themeMode: Z$4() ? "dark" : "light" }), ne$1 = { - state: C$1, - subscribe(e2) { - return subscribe(C$1, () => e2(C$1)); - }, - setThemeConfig(e2) { - const { themeMode: t2, themeVariables: s2 } = e2; - t2 && (C$1.themeMode = t2), s2 && (C$1.themeVariables = Y$1({}, s2)); - } - }, g$6 = proxy({ open: false, message: "", variant: "success" }), oe$2 = { - state: g$6, - subscribe(e2) { - return subscribe(g$6, () => e2(g$6)); - }, - openToast(e2, t2) { - g$6.open = true, g$6.message = e2, g$6.variant = t2; - }, - closeToast() { - g$6.open = false; - } - }; - let d$3 = class d { + const C$4 = proxy({ themeMode: Z$3() ? "dark" : "light" }), ne$4 = { state: C$4, subscribe(e2) { + return subscribe(C$4, () => e2(C$4)); + }, setThemeConfig(e2) { + const { themeMode: t2, themeVariables: s2 } = e2; + t2 && (C$4.themeMode = t2), s2 && (C$4.themeVariables = Y$1({}, s2)); + } }, g$4 = proxy({ open: false, message: "", variant: "success" }), oe$2 = { state: g$4, subscribe(e2) { + return subscribe(g$4, () => e2(g$4)); + }, openToast(e2, t2) { + g$4.open = true, g$4.message = e2, g$4.variant = t2; + }, closeToast() { + g$4.open = false; + } }; + let d$5 = class d { constructor(e2) { - this.openModal = se$1.open, this.closeModal = se$1.close, this.subscribeModal = se$1.subscribe, this.setTheme = ne$1.setThemeConfig, ne$1.setThemeConfig(e2), y$4.setConfig(e2), this.initUi(); + this.openModal = se$4.open, this.closeModal = se$4.close, this.subscribeModal = se$4.subscribe, this.setTheme = ne$4.setThemeConfig, ne$4.setThemeConfig(e2), y$5.setConfig(e2), this.initUi(); } async initUi() { if (typeof window < "u") { await Promise.resolve().then(() => index); const e2 = document.createElement("wcm-modal"); - document.body.insertAdjacentElement("beforeend", e2), p$4.setIsUiLoaded(true); + document.body.insertAdjacentElement("beforeend", e2), p$3.setIsUiLoaded(true); } } }; @@ -678,13 +526,13 @@ return a2; } var events = { exports: {} }; - var R$4 = typeof Reflect === "object" ? Reflect : null; - var ReflectApply = R$4 && typeof R$4.apply === "function" ? R$4.apply : function ReflectApply2(target, receiver, args) { + var R$1 = typeof Reflect === "object" ? Reflect : null; + var ReflectApply = R$1 && typeof R$1.apply === "function" ? R$1.apply : function ReflectApply2(target, receiver, args) { return Function.prototype.apply.call(target, receiver, args); }; var ReflectOwnKeys; - if (R$4 && typeof R$4.ownKeys === "function") { - ReflectOwnKeys = R$4.ownKeys; + if (R$1 && typeof R$1.ownKeys === "function") { + ReflectOwnKeys = R$1.ownKeys; } else if (Object.getOwnPropertySymbols) { ReflectOwnKeys = function ReflectOwnKeys2(target) { return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); @@ -1389,7 +1237,7 @@ async setItems(items, commonOptions) { await runBatch(items, commonOptions, async (batch) => { if (batch.driver.setItems) { - await asyncCall( + return asyncCall( batch.driver.setItems, batch.items.map((item) => ({ key: item.relativeKey, @@ -1625,7 +1473,7 @@ function get(key, customStore = defaultGetStore()) { return customStore("readonly", (store) => promisifyRequest(store.get(key))); } - function set(key, value, customStore = defaultGetStore()) { + function set$1(key, value, customStore = defaultGetStore()) { return customStore("readwrite", (store) => { store.put(value, key); return promisifyRequest(store.transaction); @@ -1678,7 +1526,7 @@ } try { return JSONParse(value); - } catch (_a) { + } catch (_a2) { return value; } } @@ -1686,7 +1534,7 @@ return typeof value === "string" ? value : JSONStringify(value) || ""; } const x$2 = "idb-keyval"; - var z$3 = (i2 = {}) => { + var z$4 = (i2 = {}) => { const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e2 = (s2) => t2 + s2; let n2; return i2.dbName && i2.storeName && (n2 = createStore(i2.dbName, i2.storeName)), { name: x$2, options: i2, async hasItem(s2) { @@ -1694,7 +1542,7 @@ }, async getItem(s2) { return await get(e2(s2), n2) ?? null; }, setItem(s2, a2) { - return set(e2(s2), a2, n2); + return set$1(e2(s2), a2, n2); }, removeItem(s2) { return del(e2(s2), n2); }, getKeys() { @@ -1703,10 +1551,10 @@ return clear(n2); } }; }; - const D$5 = "WALLET_CONNECT_V2_INDEXED_DB", E$2 = "keyvaluestorage"; - let _$4 = class _ { + const D$3 = "WALLET_CONNECT_V2_INDEXED_DB", E$3 = "keyvaluestorage"; + let _$3 = class _ { constructor() { - this.indexedDb = createStorage({ driver: z$3({ dbName: D$5, storeName: E$2 }) }); + this.indexedDb = createStorage({ driver: z$4({ dbName: D$3, storeName: E$3 }) }); } async getKeys() { return this.indexedDb.getKeys(); @@ -1726,7 +1574,7 @@ await this.indexedDb.removeItem(t2); } }; - var l$5 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c$3 = { exports: {} }; + var l$5 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c$4 = { exports: {} }; (function() { let i2; function t2() { @@ -1746,21 +1594,21 @@ return e2 = e2 || 0, Object.keys(this)[e2]; }, i2.prototype.__defineGetter__("length", function() { return Object.keys(this).length; - }), typeof l$5 < "u" && l$5.localStorage ? c$3.exports = l$5.localStorage : typeof window < "u" && window.localStorage ? c$3.exports = window.localStorage : c$3.exports = new t2(); + }), typeof l$5 < "u" && l$5.localStorage ? c$4.exports = l$5.localStorage : typeof window < "u" && window.localStorage ? c$4.exports = window.localStorage : c$4.exports = new t2(); })(); - function k$2(i2) { + function k$4(i2) { var t2; return [i2[0], safeJsonParse((t2 = i2[1]) != null ? t2 : "")]; } - let K$1 = class K { + let K$4 = class K { constructor() { - this.localStorage = c$3.exports; + this.localStorage = c$4.exports; } async getKeys() { return Object.keys(this.localStorage); } async getEntries() { - return Object.entries(this.localStorage).map(k$2); + return Object.entries(this.localStorage).map(k$4); } async getItem(t2) { const e2 = this.localStorage.getItem(t2); @@ -1774,9 +1622,9 @@ this.localStorage.removeItem(t2); } }; - const N$3 = "wc_storage_version", y$3 = 1, O$2 = async (i2, t2, e2) => { + const N$3 = "wc_storage_version", y$4 = 1, O$2 = async (i2, t2, e2) => { const n2 = N$3, s2 = await t2.getItem(n2); - if (s2 && s2 >= y$3) { + if (s2 && s2 >= y$4) { e2(t2); return; } @@ -1796,21 +1644,21 @@ await t2.setItem(r2, f2), m2.push(r2); } } - await t2.setItem(n2, y$3), e2(t2), j$3(i2, m2); + await t2.setItem(n2, y$4), e2(t2), j$3(i2, m2); }, j$3 = async (i2, t2) => { t2.length && t2.forEach(async (e2) => { await i2.removeItem(e2); }); }; - let h$6 = class h { + let h$5 = class h { constructor() { this.initialized = false, this.setInitialized = (e2) => { this.storage = e2, this.initialized = true; }; - const t2 = new K$1(); + const t2 = new K$4(); this.storage = t2; try { - const e2 = new _$4(); + const e2 = new _$3(); O$2(t2, e2, this.setInitialized); } catch { this.initialized = true; @@ -1839,7 +1687,7 @@ }); } }; - var cjs$5 = {}; + var cjs$4 = {}; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. @@ -2213,8 +2061,8 @@ }, Symbol.toStringTag, { value: "Module" })); const require$$0$2 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6); var heartbeat$2 = {}; - var cjs$4 = {}; - var utils$3 = {}; + var cjs$3 = {}; + var utils$2 = {}; var delay = {}; var hasRequiredDelay; function requireDelay() { @@ -2234,7 +2082,7 @@ return delay; } var convert = {}; - var constants$2 = {}; + var constants$1 = {}; var misc = {}; var hasRequiredMisc; function requireMisc() { @@ -2284,18 +2132,18 @@ })(time$1); return time$1; } - var hasRequiredConstants$2; - function requireConstants$2() { - if (hasRequiredConstants$2) - return constants$2; - hasRequiredConstants$2 = 1; + var hasRequiredConstants$1; + function requireConstants$1() { + if (hasRequiredConstants$1) + return constants$1; + hasRequiredConstants$1 = 1; (function(exports3) { Object.defineProperty(exports3, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireMisc(), exports3); tslib_1.__exportStar(requireTime(), exports3); - })(constants$2); - return constants$2; + })(constants$1); + return constants$1; } var hasRequiredConvert; function requireConvert() { @@ -2304,7 +2152,7 @@ hasRequiredConvert = 1; Object.defineProperty(convert, "__esModule", { value: true }); convert.fromMiliseconds = convert.toMiliseconds = void 0; - const constants_1 = requireConstants$2(); + const constants_1 = requireConstants$1(); function toMiliseconds(seconds) { return seconds * constants_1.ONE_THOUSAND; } @@ -2315,18 +2163,18 @@ convert.fromMiliseconds = fromMiliseconds; return convert; } - var hasRequiredUtils$1; - function requireUtils$1() { - if (hasRequiredUtils$1) - return utils$3; - hasRequiredUtils$1 = 1; + var hasRequiredUtils; + function requireUtils() { + if (hasRequiredUtils) + return utils$2; + hasRequiredUtils = 1; (function(exports3) { Object.defineProperty(exports3, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireDelay(), exports3); tslib_1.__exportStar(requireConvert(), exports3); - })(utils$3); - return utils$3; + })(utils$2); + return utils$2; } var watch$1 = {}; var hasRequiredWatch$1; @@ -2400,18 +2248,18 @@ (function(exports3) { Object.defineProperty(exports3, "__esModule", { value: true }); const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireUtils$1(), exports3); + tslib_1.__exportStar(requireUtils(), exports3); tslib_1.__exportStar(requireWatch$1(), exports3); tslib_1.__exportStar(requireTypes$1(), exports3); - tslib_1.__exportStar(requireConstants$2(), exports3); - })(cjs$4); + tslib_1.__exportStar(requireConstants$1(), exports3); + })(cjs$3); var types$1 = {}; var heartbeat$1 = {}; - let IEvents$1 = class IEvents { - }; + class IEvents { + } const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, - IEvents: IEvents$1 + IEvents }, Symbol.toStringTag, { value: "Module" })); const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(esm); var hasRequiredHeartbeat$2; @@ -2442,7 +2290,7 @@ })(types$1); return types$1; } - var constants$1 = {}; + var constants = {}; var heartbeat = {}; var hasRequiredHeartbeat$1; function requireHeartbeat$1() { @@ -2451,24 +2299,24 @@ hasRequiredHeartbeat$1 = 1; Object.defineProperty(heartbeat, "__esModule", { value: true }); heartbeat.HEARTBEAT_EVENTS = heartbeat.HEARTBEAT_INTERVAL = void 0; - const time_1 = cjs$4; + const time_1 = cjs$3; heartbeat.HEARTBEAT_INTERVAL = time_1.FIVE_SECONDS; heartbeat.HEARTBEAT_EVENTS = { pulse: "heartbeat_pulse" }; return heartbeat; } - var hasRequiredConstants$1; - function requireConstants$1() { - if (hasRequiredConstants$1) - return constants$1; - hasRequiredConstants$1 = 1; + var hasRequiredConstants; + function requireConstants() { + if (hasRequiredConstants) + return constants; + hasRequiredConstants = 1; (function(exports3) { Object.defineProperty(exports3, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireHeartbeat$1(), exports3); - })(constants$1); - return constants$1; + })(constants); + return constants; } var hasRequiredHeartbeat; function requireHeartbeat() { @@ -2479,9 +2327,9 @@ heartbeat$2.HeartBeat = void 0; const tslib_1 = require$$0$2; const events_1 = eventsExports; - const time_1 = cjs$4; + const time_1 = cjs$3; const types_1 = requireTypes(); - const constants_1 = requireConstants$1(); + const constants_1 = requireConstants(); class HeartBeat extends types_1.IHeartBeat { constructor(opts) { super(opts); @@ -2533,573 +2381,654 @@ const tslib_1 = require$$0$2; tslib_1.__exportStar(requireHeartbeat(), exports3); tslib_1.__exportStar(requireTypes(), exports3); - tslib_1.__exportStar(requireConstants$1(), exports3); - })(cjs$5); - var cjs$3 = {}; - var quickFormatUnescaped; - var hasRequiredQuickFormatUnescaped; - function requireQuickFormatUnescaped() { - if (hasRequiredQuickFormatUnescaped) - return quickFormatUnescaped; - hasRequiredQuickFormatUnescaped = 1; - function tryStringify(o2) { - try { - return JSON.stringify(o2); - } catch (e2) { - return '"[Circular]"'; - } + tslib_1.__exportStar(requireConstants(), exports3); + })(cjs$4); + function tryStringify(o2) { + try { + return JSON.stringify(o2); + } catch (e2) { + return '"[Circular]"'; } - quickFormatUnescaped = format; - function format(f2, args, opts) { - var ss2 = opts && opts.stringify || tryStringify; - var offset = 1; - if (typeof f2 === "object" && f2 !== null) { - var len = args.length + offset; - if (len === 1) - return f2; - var objects = new Array(len); - objects[0] = ss2(f2); - for (var index2 = 1; index2 < len; index2++) { - objects[index2] = ss2(args[index2]); - } - return objects.join(" "); - } - if (typeof f2 !== "string") { - return f2; - } - var argLen = args.length; - if (argLen === 0) + } + var quickFormatUnescaped = format$1; + function format$1(f2, args, opts) { + var ss2 = opts && opts.stringify || tryStringify; + var offset = 1; + if (typeof f2 === "object" && f2 !== null) { + var len = args.length + offset; + if (len === 1) return f2; - var str = ""; - var a2 = 1 - offset; - var lastPos = -1; - var flen = f2 && f2.length || 0; - for (var i2 = 0; i2 < flen; ) { - if (f2.charCodeAt(i2) === 37 && i2 + 1 < flen) { - lastPos = lastPos > -1 ? lastPos : 0; - switch (f2.charCodeAt(i2 + 1)) { - case 100: - case 102: - if (a2 >= argLen) - break; - if (args[a2] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Number(args[a2]); - lastPos = i2 + 2; - i2++; + var objects = new Array(len); + objects[0] = ss2(f2); + for (var index2 = 1; index2 < len; index2++) { + objects[index2] = ss2(args[index2]); + } + return objects.join(" "); + } + if (typeof f2 !== "string") { + return f2; + } + var argLen = args.length; + if (argLen === 0) + return f2; + var str = ""; + var a2 = 1 - offset; + var lastPos = -1; + var flen = f2 && f2.length || 0; + for (var i2 = 0; i2 < flen; ) { + if (f2.charCodeAt(i2) === 37 && i2 + 1 < flen) { + lastPos = lastPos > -1 ? lastPos : 0; + switch (f2.charCodeAt(i2 + 1)) { + case 100: + case 102: + if (a2 >= argLen) break; - case 105: - if (a2 >= argLen) - break; - if (args[a2] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Math.floor(Number(args[a2])); - lastPos = i2 + 2; - i2++; + if (args[a2] == null) break; - case 79: - case 111: - case 106: - if (a2 >= argLen) - break; - if (args[a2] === void 0) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - var type2 = typeof args[a2]; - if (type2 === "string") { - str += "'" + args[a2] + "'"; - lastPos = i2 + 2; - i2++; - break; - } - if (type2 === "function") { - str += args[a2].name || ""; - lastPos = i2 + 2; - i2++; - break; - } - str += ss2(args[a2]); - lastPos = i2 + 2; - i2++; + if (lastPos < i2) + str += f2.slice(lastPos, i2); + str += Number(args[a2]); + lastPos = i2 + 2; + i2++; + break; + case 105: + if (a2 >= argLen) break; - case 115: - if (a2 >= argLen) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += String(args[a2]); + if (args[a2] == null) + break; + if (lastPos < i2) + str += f2.slice(lastPos, i2); + str += Math.floor(Number(args[a2])); + lastPos = i2 + 2; + i2++; + break; + case 79: + case 111: + case 106: + if (a2 >= argLen) + break; + if (args[a2] === void 0) + break; + if (lastPos < i2) + str += f2.slice(lastPos, i2); + var type2 = typeof args[a2]; + if (type2 === "string") { + str += "'" + args[a2] + "'"; lastPos = i2 + 2; i2++; break; - case 37: - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += "%"; + } + if (type2 === "function") { + str += args[a2].name || ""; lastPos = i2 + 2; i2++; - a2--; break; - } - ++a2; + } + str += ss2(args[a2]); + lastPos = i2 + 2; + i2++; + break; + case 115: + if (a2 >= argLen) + break; + if (lastPos < i2) + str += f2.slice(lastPos, i2); + str += String(args[a2]); + lastPos = i2 + 2; + i2++; + break; + case 37: + if (lastPos < i2) + str += f2.slice(lastPos, i2); + str += "%"; + lastPos = i2 + 2; + i2++; + a2--; + break; } - ++i2; - } - if (lastPos === -1) - return f2; - else if (lastPos < flen) { - str += f2.slice(lastPos); + ++a2; } - return str; + ++i2; } - return quickFormatUnescaped; - } - var browser$5; - var hasRequiredBrowser; - function requireBrowser() { - if (hasRequiredBrowser) - return browser$5; - hasRequiredBrowser = 1; - const format = requireQuickFormatUnescaped(); - browser$5 = pino; - const _console = pfGlobalThisOrFallback().console || {}; - const stdSerializers = { - mapHttpRequest: mock, - mapHttpResponse: mock, - wrapRequestSerializer: passthrough, - wrapResponseSerializer: passthrough, - wrapErrorSerializer: passthrough, - req: mock, - res: mock, - err: asErrValue - }; - function shouldSerialize(serialize, serializers) { - if (Array.isArray(serialize)) { - const hasToFilter = serialize.filter(function(k2) { - return k2 !== "!stdSerializers.err"; - }); - return hasToFilter; - } else if (serialize === true) { - return Object.keys(serializers); - } - return false; + if (lastPos === -1) + return f2; + else if (lastPos < flen) { + str += f2.slice(lastPos); } - function pino(opts) { - opts = opts || {}; - opts.browser = opts.browser || {}; - const transmit2 = opts.browser.transmit; - if (transmit2 && typeof transmit2.send !== "function") { - throw Error("pino: transmit option must have a send function"); - } - const proto = opts.browser.write || _console; - if (opts.browser.write) - opts.browser.asObject = true; - const serializers = opts.serializers || {}; - const serialize = shouldSerialize(opts.browser.serialize, serializers); - let stdErrSerialize = opts.browser.serialize; - if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) - stdErrSerialize = false; - const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; - if (typeof proto === "function") { - proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; - } - if (opts.enabled === false) - opts.level = "silent"; - const level = opts.level || "info"; - const logger = Object.create(proto); - if (!logger.log) - logger.log = noop2; - Object.defineProperty(logger, "levelVal", { - get: getLevelVal - }); - Object.defineProperty(logger, "level", { - get: getLevel, - set: setLevel + return str; + } + const format = quickFormatUnescaped; + var browser$5 = pino; + const _console = pfGlobalThisOrFallback().console || {}; + const stdSerializers = { + mapHttpRequest: mock, + mapHttpResponse: mock, + wrapRequestSerializer: passthrough, + wrapResponseSerializer: passthrough, + wrapErrorSerializer: passthrough, + req: mock, + res: mock, + err: asErrValue + }; + function shouldSerialize(serialize, serializers) { + if (Array.isArray(serialize)) { + const hasToFilter = serialize.filter(function(k2) { + return k2 !== "!stdSerializers.err"; }); - const setOpts = { - transmit: transmit2, - serialize, - asObject: opts.browser.asObject, - levels, - timestamp: getTimeFunction(opts) - }; - logger.levels = pino.levels; - logger.level = level; - logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop2; - logger.serializers = serializers; - logger._serialize = serialize; - logger._stdErrSerialize = stdErrSerialize; - logger.child = child; - if (transmit2) - logger._logEvent = createLogEventShape(); - function getLevelVal() { - return this.level === "silent" ? Infinity : this.levels.values[this.level]; - } - function getLevel() { - return this._level; - } - function setLevel(level2) { - if (level2 !== "silent" && !this.levels.values[level2]) { - throw Error("unknown level " + level2); - } - this._level = level2; - set2(setOpts, logger, "error", "log"); - set2(setOpts, logger, "fatal", "error"); - set2(setOpts, logger, "warn", "error"); - set2(setOpts, logger, "info", "log"); - set2(setOpts, logger, "debug", "log"); - set2(setOpts, logger, "trace", "log"); - } - function child(bindings, childOptions) { - if (!bindings) { - throw new Error("missing bindings for child Pino"); - } - childOptions = childOptions || {}; - if (serialize && bindings.serializers) { - childOptions.serializers = bindings.serializers; - } - const childOptionsSerializers = childOptions.serializers; - if (serialize && childOptionsSerializers) { - var childSerializers = Object.assign({}, serializers, childOptionsSerializers); - var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; - delete bindings.serializers; - applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); - } - function Child(parent) { - this._childLevel = (parent._childLevel | 0) + 1; - this.error = bind(parent, bindings, "error"); - this.fatal = bind(parent, bindings, "fatal"); - this.warn = bind(parent, bindings, "warn"); - this.info = bind(parent, bindings, "info"); - this.debug = bind(parent, bindings, "debug"); - this.trace = bind(parent, bindings, "trace"); - if (childSerializers) { - this.serializers = childSerializers; - this._serialize = childSerialize; - } - if (transmit2) { - this._logEvent = createLogEventShape( - [].concat(parent._logEvent.bindings, bindings) - ); - } - } - Child.prototype = this; - return new Child(this); - } - return logger; + return hasToFilter; + } else if (serialize === true) { + return Object.keys(serializers); } - pino.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" - } + return false; + } + function pino(opts) { + opts = opts || {}; + opts.browser = opts.browser || {}; + const transmit2 = opts.browser.transmit; + if (transmit2 && typeof transmit2.send !== "function") { + throw Error("pino: transmit option must have a send function"); + } + const proto = opts.browser.write || _console; + if (opts.browser.write) + opts.browser.asObject = true; + const serializers = opts.serializers || {}; + const serialize = shouldSerialize(opts.browser.serialize, serializers); + let stdErrSerialize = opts.browser.serialize; + if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) + stdErrSerialize = false; + const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; + if (typeof proto === "function") { + proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; + } + if (opts.enabled === false) + opts.level = "silent"; + const level = opts.level || "info"; + const logger = Object.create(proto); + if (!logger.log) + logger.log = noop$1; + Object.defineProperty(logger, "levelVal", { + get: getLevelVal + }); + Object.defineProperty(logger, "level", { + get: getLevel, + set: setLevel + }); + const setOpts = { + transmit: transmit2, + serialize, + asObject: opts.browser.asObject, + levels, + timestamp: getTimeFunction(opts) }; - pino.stdSerializers = stdSerializers; - pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); - function set2(opts, logger, level, fallback) { - const proto = Object.getPrototypeOf(logger); - logger[level] = logger.levelVal > logger.levels.values[level] ? noop2 : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop2; - wrap2(opts, logger, level); - } - function wrap2(opts, logger, level) { - if (!opts.transmit && logger[level] === noop2) - return; - logger[level] = /* @__PURE__ */ function(write) { - return function LOG() { - const ts2 = opts.timestamp(); - const args = new Array(arguments.length); - const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; - for (var i2 = 0; i2 < args.length; i2++) - args[i2] = arguments[i2]; - if (opts.serialize && !opts.asObject) { - applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); - } - if (opts.asObject) - write.call(proto, asObject(this, level, args, ts2)); - else - write.apply(proto, args); - if (opts.transmit) { - const transmitLevel = opts.transmit.level || logger.level; - const transmitValue = pino.levels.values[transmitLevel]; - const methodValue = pino.levels.values[level]; - if (methodValue < transmitValue) - return; - transmit(this, { - ts: ts2, - methodLevel: level, - methodValue, - transmitLevel, - transmitValue: pino.levels.values[opts.transmit.level || logger.level], - send: opts.transmit.send, - val: logger.levelVal - }, args); - } - }; - }(logger[level]); - } - function asObject(logger, level, args, ts2) { - if (logger._serialize) - applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); - const argsCloned = args.slice(); - let msg = argsCloned[0]; - const o2 = {}; - if (ts2) { - o2.time = ts2; - } - o2.level = pino.levels.values[level]; - let lvl = (logger._childLevel | 0) + 1; - if (lvl < 1) - lvl = 1; - if (msg !== null && typeof msg === "object") { - while (lvl-- && typeof argsCloned[0] === "object") { - Object.assign(o2, argsCloned.shift()); - } - msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; - } else if (typeof msg === "string") - msg = format(argsCloned.shift(), argsCloned); - if (msg !== void 0) - o2.msg = msg; - return o2; - } - function applySerializers(args, serialize, serializers, stdErrSerialize) { - for (const i2 in args) { - if (stdErrSerialize && args[i2] instanceof Error) { - args[i2] = pino.stdSerializers.err(args[i2]); - } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { - for (const k2 in args[i2]) { - if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { - args[i2][k2] = serializers[k2](args[i2][k2]); - } - } + logger.levels = pino.levels; + logger.level = level; + logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop$1; + logger.serializers = serializers; + logger._serialize = serialize; + logger._stdErrSerialize = stdErrSerialize; + logger.child = child; + if (transmit2) + logger._logEvent = createLogEventShape(); + function getLevelVal() { + return this.level === "silent" ? Infinity : this.levels.values[this.level]; + } + function getLevel() { + return this._level; + } + function setLevel(level2) { + if (level2 !== "silent" && !this.levels.values[level2]) { + throw Error("unknown level " + level2); + } + this._level = level2; + set(setOpts, logger, "error", "log"); + set(setOpts, logger, "fatal", "error"); + set(setOpts, logger, "warn", "error"); + set(setOpts, logger, "info", "log"); + set(setOpts, logger, "debug", "log"); + set(setOpts, logger, "trace", "log"); + } + function child(bindings, childOptions) { + if (!bindings) { + throw new Error("missing bindings for child Pino"); + } + childOptions = childOptions || {}; + if (serialize && bindings.serializers) { + childOptions.serializers = bindings.serializers; + } + const childOptionsSerializers = childOptions.serializers; + if (serialize && childOptionsSerializers) { + var childSerializers = Object.assign({}, serializers, childOptionsSerializers); + var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; + delete bindings.serializers; + applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); + } + function Child(parent) { + this._childLevel = (parent._childLevel | 0) + 1; + this.error = bind(parent, bindings, "error"); + this.fatal = bind(parent, bindings, "fatal"); + this.warn = bind(parent, bindings, "warn"); + this.info = bind(parent, bindings, "info"); + this.debug = bind(parent, bindings, "debug"); + this.trace = bind(parent, bindings, "trace"); + if (childSerializers) { + this.serializers = childSerializers; + this._serialize = childSerialize; + } + if (transmit2) { + this._logEvent = createLogEventShape( + [].concat(parent._logEvent.bindings, bindings) + ); } } + Child.prototype = this; + return new Child(this); } - function bind(parent, bindings, level) { - return function() { - const args = new Array(1 + arguments.length); - args[0] = bindings; - for (var i2 = 1; i2 < args.length; i2++) { - args[i2] = arguments[i2 - 1]; + return logger; + } + pino.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" + } + }; + pino.stdSerializers = stdSerializers; + pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); + function set(opts, logger, level, fallback) { + const proto = Object.getPrototypeOf(logger); + logger[level] = logger.levelVal > logger.levels.values[level] ? noop$1 : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop$1; + wrap$1(opts, logger, level); + } + function wrap$1(opts, logger, level) { + if (!opts.transmit && logger[level] === noop$1) + return; + logger[level] = /* @__PURE__ */ function(write) { + return function LOG() { + const ts2 = opts.timestamp(); + const args = new Array(arguments.length); + const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; + for (var i2 = 0; i2 < args.length; i2++) + args[i2] = arguments[i2]; + if (opts.serialize && !opts.asObject) { + applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); + } + if (opts.asObject) + write.call(proto, asObject(this, level, args, ts2)); + else + write.apply(proto, args); + if (opts.transmit) { + const transmitLevel = opts.transmit.level || logger.level; + const transmitValue = pino.levels.values[transmitLevel]; + const methodValue = pino.levels.values[level]; + if (methodValue < transmitValue) + return; + transmit(this, { + ts: ts2, + methodLevel: level, + methodValue, + transmitLevel, + transmitValue: pino.levels.values[opts.transmit.level || logger.level], + send: opts.transmit.send, + val: logger.levelVal + }, args); } - return parent[level].apply(this, args); - }; - } - function transmit(logger, opts, args) { - const send = opts.send; - const ts2 = opts.ts; - const methodLevel = opts.methodLevel; - const methodValue = opts.methodValue; - const val = opts.val; - const bindings = logger._logEvent.bindings; - applySerializers( - args, - logger._serialize || Object.keys(logger.serializers), - logger.serializers, - logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize - ); - logger._logEvent.ts = ts2; - logger._logEvent.messages = args.filter(function(arg) { - return bindings.indexOf(arg) === -1; - }); - logger._logEvent.level.label = methodLevel; - logger._logEvent.level.value = methodValue; - send(methodLevel, logger._logEvent, val); - logger._logEvent = createLogEventShape(bindings); - } - function createLogEventShape(bindings) { - return { - ts: 0, - messages: [], - bindings: bindings || [], - level: { label: "", value: 0 } - }; - } - function asErrValue(err) { - const obj = { - type: err.constructor.name, - msg: err.message, - stack: err.stack }; - for (const key in err) { - if (obj[key] === void 0) { - obj[key] = err[key]; + }(logger[level]); + } + function asObject(logger, level, args, ts2) { + if (logger._serialize) + applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); + const argsCloned = args.slice(); + let msg = argsCloned[0]; + const o2 = {}; + if (ts2) { + o2.time = ts2; + } + o2.level = pino.levels.values[level]; + let lvl = (logger._childLevel | 0) + 1; + if (lvl < 1) + lvl = 1; + if (msg !== null && typeof msg === "object") { + while (lvl-- && typeof argsCloned[0] === "object") { + Object.assign(o2, argsCloned.shift()); + } + msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; + } else if (typeof msg === "string") + msg = format(argsCloned.shift(), argsCloned); + if (msg !== void 0) + o2.msg = msg; + return o2; + } + function applySerializers(args, serialize, serializers, stdErrSerialize) { + for (const i2 in args) { + if (stdErrSerialize && args[i2] instanceof Error) { + args[i2] = pino.stdSerializers.err(args[i2]); + } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { + for (const k2 in args[i2]) { + if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { + args[i2][k2] = serializers[k2](args[i2][k2]); + } } } - return obj; } - function getTimeFunction(opts) { - if (typeof opts.timestamp === "function") { - return opts.timestamp; + } + function bind(parent, bindings, level) { + return function() { + const args = new Array(1 + arguments.length); + args[0] = bindings; + for (var i2 = 1; i2 < args.length; i2++) { + args[i2] = arguments[i2 - 1]; } - if (opts.timestamp === false) { - return nullTime; + return parent[level].apply(this, args); + }; + } + function transmit(logger, opts, args) { + const send = opts.send; + const ts2 = opts.ts; + const methodLevel = opts.methodLevel; + const methodValue = opts.methodValue; + const val = opts.val; + const bindings = logger._logEvent.bindings; + applySerializers( + args, + logger._serialize || Object.keys(logger.serializers), + logger.serializers, + logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize + ); + logger._logEvent.ts = ts2; + logger._logEvent.messages = args.filter(function(arg) { + return bindings.indexOf(arg) === -1; + }); + logger._logEvent.level.label = methodLevel; + logger._logEvent.level.value = methodValue; + send(methodLevel, logger._logEvent, val); + logger._logEvent = createLogEventShape(bindings); + } + function createLogEventShape(bindings) { + return { + ts: 0, + messages: [], + bindings: bindings || [], + level: { label: "", value: 0 } + }; + } + function asErrValue(err) { + const obj = { + type: err.constructor.name, + msg: err.message, + stack: err.stack + }; + for (const key in err) { + if (obj[key] === void 0) { + obj[key] = err[key]; } - return epochTime; - } - function mock() { - return {}; - } - function passthrough(a2) { - return a2; } - function noop2() { - } - function nullTime() { - return false; - } - function epochTime() { - return Date.now(); + return obj; + } + function getTimeFunction(opts) { + if (typeof opts.timestamp === "function") { + return opts.timestamp; } - function unixTime() { - return Math.round(Date.now() / 1e3); + if (opts.timestamp === false) { + return nullTime; } - function isoTime() { - return new Date(Date.now()).toISOString(); + return epochTime; + } + function mock() { + return {}; + } + function passthrough(a2) { + return a2; + } + function noop$1() { + } + function nullTime() { + return false; + } + function epochTime() { + return Date.now(); + } + function unixTime() { + return Math.round(Date.now() / 1e3); + } + function isoTime() { + return new Date(Date.now()).toISOString(); + } + function pfGlobalThisOrFallback() { + function defd(o2) { + return typeof o2 !== "undefined" && o2; } - function pfGlobalThisOrFallback() { - function defd(o2) { - return typeof o2 !== "undefined" && o2; - } - try { - if (typeof globalThis !== "undefined") - return globalThis; - Object.defineProperty(Object.prototype, "globalThis", { - get: function() { - delete Object.prototype.globalThis; - return this.globalThis = this; - }, - configurable: true - }); + try { + if (typeof globalThis !== "undefined") return globalThis; - } catch (e2) { - return defd(self) || defd(window) || defd(this) || {}; - } + Object.defineProperty(Object.prototype, "globalThis", { + get: function() { + delete Object.prototype.globalThis; + return this.globalThis = this; + }, + configurable: true + }); + return globalThis; + } catch (e2) { + return defd(self) || defd(window) || defd(this) || {}; } - return browser$5; - } - var constants = {}; - var hasRequiredConstants; - function requireConstants() { - if (hasRequiredConstants) - return constants; - hasRequiredConstants = 1; - Object.defineProperty(constants, "__esModule", { value: true }); - constants.PINO_CUSTOM_CONTEXT_KEY = constants.PINO_LOGGER_DEFAULTS = void 0; - constants.PINO_LOGGER_DEFAULTS = { - level: "info" - }; - constants.PINO_CUSTOM_CONTEXT_KEY = "custom_context"; - return constants; } - var utils$2 = {}; - var hasRequiredUtils; - function requireUtils() { - if (hasRequiredUtils) - return utils$2; - hasRequiredUtils = 1; - Object.defineProperty(utils$2, "__esModule", { value: true }); - utils$2.generateChildLogger = utils$2.formatChildLoggerContext = utils$2.getLoggerContext = utils$2.setBrowserLoggerContext = utils$2.getBrowserLoggerContext = utils$2.getDefaultLoggerOptions = void 0; - const constants_1 = requireConstants(); - function getDefaultLoggerOptions(opts) { - return Object.assign(Object.assign({}, opts), { level: (opts === null || opts === void 0 ? void 0 : opts.level) || constants_1.PINO_LOGGER_DEFAULTS.level }); - } - utils$2.getDefaultLoggerOptions = getDefaultLoggerOptions; - function getBrowserLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - return logger[customContextKey] || ""; - } - utils$2.getBrowserLoggerContext = getBrowserLoggerContext; - function setBrowserLoggerContext(logger, context, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - logger[customContextKey] = context; - return logger; - } - utils$2.setBrowserLoggerContext = setBrowserLoggerContext; - function getLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - let context = ""; - if (typeof logger.bindings === "undefined") { - context = getBrowserLoggerContext(logger, customContextKey); - } else { - context = logger.bindings().context || ""; - } - return context; + const nt$2 = /* @__PURE__ */ getDefaultExportFromCjs(browser$5); + const c$3 = { level: "info" }, n$9 = "custom_context", l$4 = 1e3 * 1024; + let O$1 = class O { + constructor(e2) { + this.nodeValue = e2, this.sizeInBytes = new TextEncoder().encode(this.nodeValue).length, this.next = null; } - utils$2.getLoggerContext = getLoggerContext; - function formatChildLoggerContext(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const parentContext = getLoggerContext(logger, customContextKey); - const context = parentContext.trim() ? `${parentContext}/${childContext}` : childContext; - return context; + get value() { + return this.nodeValue; } - utils$2.formatChildLoggerContext = formatChildLoggerContext; - function generateChildLogger(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const context = formatChildLoggerContext(logger, childContext, customContextKey); - const child = logger.child({ context }); - return setBrowserLoggerContext(child, context, customContextKey); + get size() { + return this.sizeInBytes; } - utils$2.generateChildLogger = generateChildLogger; - return utils$2; + }; + let d$4 = class d { + constructor(e2) { + this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e2, this.sizeInBytes = 0; + } + append(e2) { + const t2 = new O$1(e2); + if (t2.size > this.maxSizeInBytes) + throw new Error(`[LinkedList] Value too big to insert into list: ${e2} with size ${t2.size}`); + for (; this.size + t2.size > this.maxSizeInBytes; ) + this.shift(); + this.head ? (this.tail && (this.tail.next = t2), this.tail = t2) : (this.head = t2, this.tail = t2), this.lengthInNodes++, this.sizeInBytes += t2.size; + } + shift() { + if (!this.head) + return; + const e2 = this.head; + this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e2.size; + } + toArray() { + const e2 = []; + let t2 = this.head; + for (; t2 !== null; ) + e2.push(t2.value), t2 = t2.next; + return e2; + } + get length() { + return this.lengthInNodes; + } + get size() { + return this.sizeInBytes; + } + toOrderedArray() { + return Array.from(this); + } + [Symbol.iterator]() { + let e2 = this.head; + return { next: () => { + if (!e2) + return { done: true, value: null }; + const t2 = e2.value; + return e2 = e2.next, { done: false, value: t2 }; + } }; + } + }; + let L$6 = class L { + constructor(e2, t2 = l$4) { + this.level = e2 ?? "error", this.levelValue = browser$5.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = t2, this.logs = new d$4(this.MAX_LOG_SIZE_IN_BYTES); + } + forwardToConsole(e2, t2) { + t2 === browser$5.levels.values.error ? console.error(e2) : t2 === browser$5.levels.values.warn ? console.warn(e2) : t2 === browser$5.levels.values.debug ? console.debug(e2) : t2 === browser$5.levels.values.trace ? console.trace(e2) : console.log(e2); + } + appendToLogs(e2) { + this.logs.append(safeJsonStringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: e2 })); + const t2 = typeof e2 == "string" ? JSON.parse(e2).level : e2.level; + t2 >= this.levelValue && this.forwardToConsole(e2, t2); + } + getLogs() { + return this.logs; + } + clearLogs() { + this.logs = new d$4(this.MAX_LOG_SIZE_IN_BYTES); + } + getLogArray() { + return Array.from(this.logs); + } + logsToBlob(e2) { + const t2 = this.getLogArray(); + return t2.push(safeJsonStringify({ extraMetadata: e2 })), new Blob(t2, { type: "application/json" }); + } + }; + let m$2 = class m { + constructor(e2, t2 = l$4) { + this.baseChunkLogger = new L$6(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } + downloadLogsBlobInBrowser(e2) { + const t2 = URL.createObjectURL(this.logsToBlob(e2)), o2 = document.createElement("a"); + o2.href = t2, o2.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(o2), o2.click(), document.body.removeChild(o2), URL.revokeObjectURL(t2); + } + }; + let B$2 = class B { + constructor(e2, t2 = l$4) { + this.baseChunkLogger = new L$6(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } + }; + var x$1 = Object.defineProperty, S$6 = Object.defineProperties, _$2 = Object.getOwnPropertyDescriptors, p$2 = Object.getOwnPropertySymbols, T$2 = Object.prototype.hasOwnProperty, z$3 = Object.prototype.propertyIsEnumerable, f$4 = (r2, e2, t2) => e2 in r2 ? x$1(r2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : r2[e2] = t2, i$4 = (r2, e2) => { + for (var t2 in e2 || (e2 = {})) + T$2.call(e2, t2) && f$4(r2, t2, e2[t2]); + if (p$2) + for (var t2 of p$2(e2)) + z$3.call(e2, t2) && f$4(r2, t2, e2[t2]); + return r2; + }, g$3 = (r2, e2) => S$6(r2, _$2(e2)); + function k$3(r2) { + return g$3(i$4({}, r2), { level: (r2 == null ? void 0 : r2.level) || c$3.level }); } - (function(exports3) { - Object.defineProperty(exports3, "__esModule", { value: true }); - exports3.pino = void 0; - const tslib_1 = require$$0$2; - const pino_1 = tslib_1.__importDefault(requireBrowser()); - Object.defineProperty(exports3, "pino", { enumerable: true, get: function() { - return pino_1.default; - } }); - tslib_1.__exportStar(requireConstants(), exports3); - tslib_1.__exportStar(requireUtils(), exports3); - })(cjs$3); - let n$7 = class n extends IEvents$1 { + function v$3(r2, e2 = n$9) { + return r2[e2] || ""; + } + function b$4(r2, e2, t2 = n$9) { + return r2[t2] = e2, r2; + } + function y$3(r2, e2 = n$9) { + let t2 = ""; + return typeof r2.bindings > "u" ? t2 = v$3(r2, e2) : t2 = r2.bindings().context || "", t2; + } + function w$4(r2, e2, t2 = n$9) { + const o2 = y$3(r2, t2); + return o2.trim() ? `${o2}/${e2}` : e2; + } + function E$2(r2, e2, t2 = n$9) { + const o2 = w$4(r2, e2, t2), a2 = r2.child({ context: o2 }); + return b$4(a2, o2, t2); + } + function C$3(r2) { + var e2, t2; + const o2 = new m$2((e2 = r2.opts) == null ? void 0 : e2.level, r2.maxSizeInBytes); + return { logger: nt$2(g$3(i$4({}, r2.opts), { level: "trace", browser: g$3(i$4({}, (t2 = r2.opts) == null ? void 0 : t2.browser), { write: (a2) => o2.write(a2) }) })), chunkLoggerController: o2 }; + } + function I$3(r2) { + var e2; + const t2 = new B$2((e2 = r2.opts) == null ? void 0 : e2.level, r2.maxSizeInBytes); + return { logger: nt$2(g$3(i$4({}, r2.opts), { level: "trace" }), t2), chunkLoggerController: t2 }; + } + function A$3(r2) { + return typeof r2.loggerOverride < "u" && typeof r2.loggerOverride != "string" ? { logger: r2.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? C$3(r2) : I$3(r2); + } + let n$8 = class n extends IEvents { constructor(s2) { super(), this.opts = s2, this.protocol = "wc", this.version = 2; } }; - let h$5 = class h extends IEvents$1 { + let h$4 = class h extends IEvents { constructor(s2, t2) { super(), this.core = s2, this.logger = t2, this.records = /* @__PURE__ */ new Map(); } }; - let a$4 = class a { + let a$3 = class a { constructor(s2, t2) { this.logger = s2, this.core = t2; } }; - let u$3 = class u extends IEvents$1 { + let u$3 = class u extends IEvents { constructor(s2, t2) { super(), this.relayer = s2, this.logger = t2; } }; - let g$5 = class g extends IEvents$1 { + let g$2 = class g extends IEvents { constructor(s2) { super(); } }; - let p$3 = class p { + let p$1 = class p { constructor(s2, t2, o2, M2) { this.core = s2, this.logger = t2, this.name = o2; } }; - let d$2 = class d extends IEvents$1 { + let d$3 = class d extends IEvents { constructor(s2, t2) { super(), this.relayer = s2, this.logger = t2; } }; - let E$1 = class E extends IEvents$1 { + let E$1 = class E extends IEvents { constructor(s2, t2) { super(), this.core = s2, this.logger = t2; } @@ -3109,17 +3038,17 @@ this.projectId = s2, this.logger = t2; } }; - let v$3 = class v { + let v$2 = class v { constructor(s2, t2) { this.projectId = s2, this.logger = t2; } }; - let b$2 = class b { + let b$3 = class b { constructor(s2) { this.opts = s2, this.protocol = "wc", this.version = 2; } }; - let w$5 = class w { + let w$3 = class w { constructor(s2) { this.client = s2; } @@ -3240,9 +3169,9 @@ (function(exports3) { Object.defineProperty(exports3, "__esModule", { value: true }); function imulShim(a2, b2) { - var ah = a2 >>> 16 & 65535, al = a2 & 65535; + var ah2 = a2 >>> 16 & 65535, al = a2 & 65535; var bh = b2 >>> 16 & 65535, bl = b2 & 65535; - return al * bl + (ah * bl + al * bh << 16 >>> 0) | 0; + return al * bl + (ah2 * bl + al * bh << 16 >>> 0) | 0; } exports3.mul = Math.imul || imulShim; function add(a2, b2) { @@ -3963,10 +3892,10 @@ 1816402316, 1246189591 ]); - function hashBlocks(wh, wl, hh, hl, m2, pos, len) { - var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; + function hashBlocks(wh, wl, hh2, hl, m2, pos, len) { + var ah0 = hh2[0], ah1 = hh2[1], ah2 = hh2[2], ah3 = hh2[3], ah4 = hh2[4], ah5 = hh2[5], ah6 = hh2[6], ah7 = hh2[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; var h2, l2; - var th, tl; + var th2, tl; var a2, b2, c2, d2; while (len >= 128) { for (var i2 = 0; i2 < 16; i2++) { @@ -4024,9 +3953,9 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - th = c2 & 65535 | d2 << 16; + th2 = c2 & 65535 | d2 << 16; tl = a2 & 65535 | b2 << 16; - h2 = th; + h2 = th2; l2 = tl; a2 = l2 & 65535; b2 = l2 >>> 16; @@ -4055,7 +3984,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = th; + h2 = th2; l2 = tl; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4096,18 +4025,18 @@ b2 += l2 >>> 16; c2 += h2 & 65535; d2 += h2 >>> 16; - th = wh[(j2 + 1) % 16]; + th2 = wh[(j2 + 1) % 16]; tl = wl[(j2 + 1) % 16]; - h2 = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7; - l2 = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7); + h2 = (th2 >>> 1 | tl << 32 - 1) ^ (th2 >>> 8 | tl << 32 - 8) ^ th2 >>> 7; + l2 = (tl >>> 1 | th2 << 32 - 1) ^ (tl >>> 8 | th2 << 32 - 8) ^ (tl >>> 7 | th2 << 32 - 7); a2 += l2 & 65535; b2 += l2 >>> 16; c2 += h2 & 65535; d2 += h2 >>> 16; - th = wh[(j2 + 14) % 16]; + th2 = wh[(j2 + 14) % 16]; tl = wl[(j2 + 14) % 16]; - h2 = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6; - l2 = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6); + h2 = (th2 >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th2 << 32 - (61 - 32)) ^ th2 >>> 6; + l2 = (tl >>> 19 | th2 << 32 - 19) ^ (th2 >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th2 << 32 - 6); a2 += l2 & 65535; b2 += l2 >>> 16; c2 += h2 & 65535; @@ -4126,7 +4055,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = hh[0]; + h2 = hh2[0]; l2 = hl[0]; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4135,7 +4064,7 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - hh[0] = ah0 = c2 & 65535 | d2 << 16; + hh2[0] = ah0 = c2 & 65535 | d2 << 16; hl[0] = al0 = a2 & 65535 | b2 << 16; h2 = ah1; l2 = al1; @@ -4143,7 +4072,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = hh[1]; + h2 = hh2[1]; l2 = hl[1]; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4152,7 +4081,7 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - hh[1] = ah1 = c2 & 65535 | d2 << 16; + hh2[1] = ah1 = c2 & 65535 | d2 << 16; hl[1] = al1 = a2 & 65535 | b2 << 16; h2 = ah2; l2 = al2; @@ -4160,7 +4089,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = hh[2]; + h2 = hh2[2]; l2 = hl[2]; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4169,7 +4098,7 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - hh[2] = ah2 = c2 & 65535 | d2 << 16; + hh2[2] = ah2 = c2 & 65535 | d2 << 16; hl[2] = al2 = a2 & 65535 | b2 << 16; h2 = ah3; l2 = al3; @@ -4177,7 +4106,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = hh[3]; + h2 = hh2[3]; l2 = hl[3]; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4186,7 +4115,7 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - hh[3] = ah3 = c2 & 65535 | d2 << 16; + hh2[3] = ah3 = c2 & 65535 | d2 << 16; hl[3] = al3 = a2 & 65535 | b2 << 16; h2 = ah4; l2 = al4; @@ -4194,7 +4123,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = hh[4]; + h2 = hh2[4]; l2 = hl[4]; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4203,7 +4132,7 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - hh[4] = ah4 = c2 & 65535 | d2 << 16; + hh2[4] = ah4 = c2 & 65535 | d2 << 16; hl[4] = al4 = a2 & 65535 | b2 << 16; h2 = ah5; l2 = al5; @@ -4211,7 +4140,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = hh[5]; + h2 = hh2[5]; l2 = hl[5]; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4220,7 +4149,7 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - hh[5] = ah5 = c2 & 65535 | d2 << 16; + hh2[5] = ah5 = c2 & 65535 | d2 << 16; hl[5] = al5 = a2 & 65535 | b2 << 16; h2 = ah6; l2 = al6; @@ -4228,7 +4157,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = hh[6]; + h2 = hh2[6]; l2 = hl[6]; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4237,7 +4166,7 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - hh[6] = ah6 = c2 & 65535 | d2 << 16; + hh2[6] = ah6 = c2 & 65535 | d2 << 16; hl[6] = al6 = a2 & 65535 | b2 << 16; h2 = ah7; l2 = al7; @@ -4245,7 +4174,7 @@ b2 = l2 >>> 16; c2 = h2 & 65535; d2 = h2 >>> 16; - h2 = hh[7]; + h2 = hh2[7]; l2 = hl[7]; a2 += l2 & 65535; b2 += l2 >>> 16; @@ -4254,7 +4183,7 @@ b2 += a2 >>> 16; c2 += b2 >>> 16; d2 += c2 >>> 16; - hh[7] = ah7 = c2 & 65535 | d2 << 16; + hh2[7] = ah7 = c2 & 65535 | d2 << 16; hl[7] = al7 = a2 & 65535 | b2 << 16; pos += 128; len -= 128; @@ -4280,7 +4209,7 @@ exports3.PUBLIC_KEY_LENGTH = 32; exports3.SECRET_KEY_LENGTH = 64; exports3.SEED_LENGTH = 32; - function gf(init) { + function gf2(init) { const r2 = new Float64Array(16); if (init) { for (let i2 = 0; i2 < init.length; i2++) { @@ -4291,9 +4220,9 @@ } const _9 = new Uint8Array(32); _9[0] = 9; - const gf0 = gf(); - const gf1 = gf([1]); - const D2 = gf([ + const gf0 = gf2(); + const gf1 = gf2([1]); + const D2 = gf2([ 30883, 4953, 19914, @@ -4311,7 +4240,7 @@ 27886, 20995 ]); - const D22 = gf([ + const D22 = gf2([ 61785, 9906, 39828, @@ -4329,7 +4258,7 @@ 55772, 9222 ]); - const X2 = gf([ + const X2 = gf2([ 54554, 36645, 11616, @@ -4347,7 +4276,7 @@ 14035, 8553 ]); - const Y2 = gf([ + const Y2 = gf2([ 26200, 26214, 26214, @@ -4365,7 +4294,7 @@ 26214, 26214 ]); - const I2 = gf([ + const I2 = gf2([ 41136, 18958, 6951, @@ -4406,8 +4335,8 @@ } } function pack25519(o2, n2) { - const m2 = gf(); - const t2 = gf(); + const m2 = gf2(); + const t2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { t2[i2] = n2[i2]; } @@ -4466,9 +4395,9 @@ } } function mul(o2, a2, b2) { - let v2, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b2[0], b1 = b2[1], b22 = b2[2], b3 = b2[3], b4 = b2[4], b5 = b2[5], b6 = b2[6], b7 = b2[7], b8 = b2[8], b9 = b2[9], b10 = b2[10], b11 = b2[11], b12 = b2[12], b13 = b2[13], b14 = b2[14], b15 = b2[15]; + let v2, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b2[0], b1 = b2[1], b22 = b2[2], b3 = b2[3], b4 = b2[4], b5 = b2[5], b6 = b2[6], b7 = b2[7], b8 = b2[8], b9 = b2[9], b10 = b2[10], b11 = b2[11], b12 = b2[12], b13 = b2[13], b14 = b2[14], b15 = b2[15]; v2 = a2[0]; - t0 += v2 * b0; + t0 += v2 * b02; t1 += v2 * b1; t2 += v2 * b22; t3 += v2 * b3; @@ -4485,7 +4414,7 @@ t14 += v2 * b14; t15 += v2 * b15; v2 = a2[1]; - t1 += v2 * b0; + t1 += v2 * b02; t2 += v2 * b1; t3 += v2 * b22; t4 += v2 * b3; @@ -4502,7 +4431,7 @@ t15 += v2 * b14; t16 += v2 * b15; v2 = a2[2]; - t2 += v2 * b0; + t2 += v2 * b02; t3 += v2 * b1; t4 += v2 * b22; t5 += v2 * b3; @@ -4519,7 +4448,7 @@ t16 += v2 * b14; t17 += v2 * b15; v2 = a2[3]; - t3 += v2 * b0; + t3 += v2 * b02; t4 += v2 * b1; t5 += v2 * b22; t6 += v2 * b3; @@ -4536,7 +4465,7 @@ t17 += v2 * b14; t18 += v2 * b15; v2 = a2[4]; - t4 += v2 * b0; + t4 += v2 * b02; t5 += v2 * b1; t6 += v2 * b22; t7 += v2 * b3; @@ -4553,7 +4482,7 @@ t18 += v2 * b14; t19 += v2 * b15; v2 = a2[5]; - t5 += v2 * b0; + t5 += v2 * b02; t6 += v2 * b1; t7 += v2 * b22; t8 += v2 * b3; @@ -4570,7 +4499,7 @@ t19 += v2 * b14; t20 += v2 * b15; v2 = a2[6]; - t6 += v2 * b0; + t6 += v2 * b02; t7 += v2 * b1; t8 += v2 * b22; t9 += v2 * b3; @@ -4587,7 +4516,7 @@ t20 += v2 * b14; t21 += v2 * b15; v2 = a2[7]; - t7 += v2 * b0; + t7 += v2 * b02; t8 += v2 * b1; t9 += v2 * b22; t10 += v2 * b3; @@ -4604,7 +4533,7 @@ t21 += v2 * b14; t22 += v2 * b15; v2 = a2[8]; - t8 += v2 * b0; + t8 += v2 * b02; t9 += v2 * b1; t10 += v2 * b22; t11 += v2 * b3; @@ -4621,7 +4550,7 @@ t22 += v2 * b14; t23 += v2 * b15; v2 = a2[9]; - t9 += v2 * b0; + t9 += v2 * b02; t10 += v2 * b1; t11 += v2 * b22; t12 += v2 * b3; @@ -4638,7 +4567,7 @@ t23 += v2 * b14; t24 += v2 * b15; v2 = a2[10]; - t10 += v2 * b0; + t10 += v2 * b02; t11 += v2 * b1; t12 += v2 * b22; t13 += v2 * b3; @@ -4655,7 +4584,7 @@ t24 += v2 * b14; t25 += v2 * b15; v2 = a2[11]; - t11 += v2 * b0; + t11 += v2 * b02; t12 += v2 * b1; t13 += v2 * b22; t14 += v2 * b3; @@ -4672,7 +4601,7 @@ t25 += v2 * b14; t26 += v2 * b15; v2 = a2[12]; - t12 += v2 * b0; + t12 += v2 * b02; t13 += v2 * b1; t14 += v2 * b22; t15 += v2 * b3; @@ -4689,7 +4618,7 @@ t26 += v2 * b14; t27 += v2 * b15; v2 = a2[13]; - t13 += v2 * b0; + t13 += v2 * b02; t14 += v2 * b1; t15 += v2 * b22; t16 += v2 * b3; @@ -4706,7 +4635,7 @@ t27 += v2 * b14; t28 += v2 * b15; v2 = a2[14]; - t14 += v2 * b0; + t14 += v2 * b02; t15 += v2 * b1; t16 += v2 * b22; t17 += v2 * b3; @@ -4723,7 +4652,7 @@ t28 += v2 * b14; t29 += v2 * b15; v2 = a2[15]; - t15 += v2 * b0; + t15 += v2 * b02; t16 += v2 * b1; t17 += v2 * b22; t18 += v2 * b3; @@ -4875,7 +4804,7 @@ mul(o2, a2, a2); } function inv25519(o2, i2) { - const c2 = gf(); + const c2 = gf2(); let a2; for (a2 = 0; a2 < 16; a2++) { c2[a2] = i2[a2]; @@ -4891,7 +4820,7 @@ } } function pow2523(o2, i2) { - const c2 = gf(); + const c2 = gf2(); let a2; for (a2 = 0; a2 < 16; a2++) { c2[a2] = i2[a2]; @@ -4907,7 +4836,7 @@ } } function edadd(p2, q2) { - const a2 = gf(), b2 = gf(), c2 = gf(), d2 = gf(), e2 = gf(), f2 = gf(), g2 = gf(), h2 = gf(), t2 = gf(); + const a2 = gf2(), b2 = gf2(), c2 = gf2(), d2 = gf2(), e2 = gf2(), f2 = gf2(), g2 = gf2(), h2 = gf2(), t2 = gf2(); sub(a2, p2[1], p2[0]); sub(t2, q2[1], q2[0]); mul(a2, a2, t2); @@ -4933,10 +4862,10 @@ } } function pack(r2, p2) { - const tx = gf(), ty = gf(), zi = gf(); - inv25519(zi, p2[2]); - mul(tx, p2[0], zi); - mul(ty, p2[1], zi); + const tx = gf2(), ty = gf2(), zi2 = gf2(); + inv25519(zi2, p2[2]); + mul(tx, p2[0], zi2); + mul(ty, p2[1], zi2); pack25519(r2, ty); r2[31] ^= par25519(tx) << 7; } @@ -4954,7 +4883,7 @@ } } function scalarbase(p2, s2) { - const q2 = [gf(), gf(), gf(), gf()]; + const q2 = [gf2(), gf2(), gf2(), gf2()]; set25519(q2[0], X2); set25519(q2[1], Y2); set25519(q2[2], gf1); @@ -4970,7 +4899,7 @@ d2[31] &= 127; d2[31] |= 64; const publicKey = new Uint8Array(32); - const p2 = [gf(), gf(), gf(), gf()]; + const p2 = [gf2(), gf2(), gf2(), gf2()]; scalarbase(p2, d2); pack(publicKey, p2); const secretKey = new Uint8Array(64); @@ -5071,7 +5000,7 @@ } function sign(secretKey, message) { const x2 = new Float64Array(64); - const p2 = [gf(), gf(), gf(), gf()]; + const p2 = [gf2(), gf2(), gf2(), gf2()]; const d2 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); d2[0] &= 248; d2[31] &= 127; @@ -5105,7 +5034,7 @@ } exports3.sign = sign; function unpackneg(r2, p2) { - const t2 = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf(); + const t2 = gf2(), chk = gf2(), num = gf2(), den = gf2(), den2 = gf2(), den4 = gf2(), den6 = gf2(); set25519(r2[2], gf1); unpack25519(r2[1], p2); square(num, r2[1]); @@ -5140,8 +5069,8 @@ } function verify(publicKey, message, signature) { const t2 = new Uint8Array(32); - const p2 = [gf(), gf(), gf(), gf()]; - const q2 = [gf(), gf(), gf(), gf()]; + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const q2 = [gf2(), gf2(), gf2(), gf2()]; if (signature.length !== exports3.SIGNATURE_LENGTH) { throw new Error(`ed25519: signature must be ${exports3.SIGNATURE_LENGTH} bytes`); } @@ -5165,12 +5094,12 @@ } exports3.verify = verify; function convertPublicKeyToX25519(publicKey) { - let q2 = [gf(), gf(), gf(), gf()]; + let q2 = [gf2(), gf2(), gf2(), gf2()]; if (unpackneg(q2, publicKey)) { throw new Error("Ed25519: invalid public key"); } - let a2 = gf(); - let b2 = gf(); + let a2 = gf2(); + let b2 = gf2(); let y2 = q2[1]; add(a2, gf1, y2); sub(b2, gf1, y2); @@ -5844,7 +5773,7 @@ function generateKeyPair(seed = random.randomBytes(KEY_PAIR_SEED_LENGTH)) { return ed25519.generateKeyPairFromSeed(seed); } - async function signJWT(sub, aud, ttl, keyPair, iat = cjs$4.fromMiliseconds(Date.now())) { + async function signJWT(sub, aud, ttl, keyPair, iat = cjs$3.fromMiliseconds(Date.now())) { const header = { alg: JWT_IRIDIUM_ALG, typ: JWT_IRIDIUM_TYP }; const iss = encodeIss(keyPair.publicKey); const exp = iat + ttl; @@ -5853,248 +5782,1047 @@ const signature = ed25519.sign(keyPair.secretKey, data2); return encodeJWT({ header, payload, signature }); } - var chacha20poly1305 = {}; - var chacha = {}; - Object.defineProperty(chacha, "__esModule", { value: true }); - var binary_1 = binary; - var wipe_1$2 = wipe$1; - var ROUNDS = 20; - function core(out, input, key) { - var j0 = 1634760805; - var j1 = 857760878; - var j2 = 2036477234; - var j3 = 1797285236; - var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; - var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; - var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; - var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; - var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; - var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; - var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; - var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; - var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; - var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; - var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; - var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; - var x0 = j0; - var x1 = j1; - var x2 = j2; - var x3 = j3; - var x4 = j4; - var x5 = j5; - var x6 = j6; - var x7 = j7; - var x8 = j8; - var x9 = j9; - var x10 = j10; - var x11 = j11; - var x12 = j12; - var x13 = j13; - var x14 = j14; - var x15 = j15; - for (var i2 = 0; i2 < ROUNDS; i2 += 2) { - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 16 | x12 << 16; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 12 | x4 << 12; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 16 | x13 << 16; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 12 | x5 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 16 | x14 << 16; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 12 | x6 << 12; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 16 | x15 << 16; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 12 | x7 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 8 | x14 << 8; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 7 | x6 << 7; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 8 | x15 << 8; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 7 | x7 << 7; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 8 | x13 << 8; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 7 | x5 << 7; - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 8 | x12 << 8; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 7 | x4 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 16 | x15 << 16; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 12 | x5 << 12; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 16 | x12 << 16; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 12 | x6 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 16 | x13 << 16; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 12 | x7 << 12; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 16 | x14 << 16; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 12 | x4 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 8 | x13 << 8; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 7 | x7 << 7; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 8 | x14 << 8; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 7 | x4 << 7; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 8 | x12 << 8; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 7 | x6 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 8 | x15 << 8; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 7 | x5 << 7; - } - binary_1.writeUint32LE(x0 + j0 | 0, out, 0); - binary_1.writeUint32LE(x1 + j1 | 0, out, 4); - binary_1.writeUint32LE(x2 + j2 | 0, out, 8); - binary_1.writeUint32LE(x3 + j3 | 0, out, 12); - binary_1.writeUint32LE(x4 + j4 | 0, out, 16); - binary_1.writeUint32LE(x5 + j5 | 0, out, 20); - binary_1.writeUint32LE(x6 + j6 | 0, out, 24); - binary_1.writeUint32LE(x7 + j7 | 0, out, 28); - binary_1.writeUint32LE(x8 + j8 | 0, out, 32); - binary_1.writeUint32LE(x9 + j9 | 0, out, 36); - binary_1.writeUint32LE(x10 + j10 | 0, out, 40); - binary_1.writeUint32LE(x11 + j11 | 0, out, 44); - binary_1.writeUint32LE(x12 + j12 | 0, out, 48); - binary_1.writeUint32LE(x13 + j13 | 0, out, 52); - binary_1.writeUint32LE(x14 + j14 | 0, out, 56); - binary_1.writeUint32LE(x15 + j15 | 0, out, 60); - } - function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - if (key.length !== 32) { - throw new Error("ChaCha: key size must be 32 bytes"); - } - if (dst.length < src2.length) { - throw new Error("ChaCha: destination is shorter than source"); - } - var nc; - var counterLength; - if (nonceInplaceCounterLength === 0) { - if (nonce.length !== 8 && nonce.length !== 12) { - throw new Error("ChaCha nonce must be 8 or 12 bytes"); - } - nc = new Uint8Array(16); - counterLength = nc.length - nonce.length; - nc.set(nonce, counterLength); - } else { - if (nonce.length !== 16) { - throw new Error("ChaCha nonce with counter must be 16 bytes"); + var __spreadArray = function(to2, from2, pack) { + if (pack || arguments.length === 2) + for (var i2 = 0, l2 = from2.length, ar2; i2 < l2; i2++) { + if (ar2 || !(i2 in from2)) { + if (!ar2) + ar2 = Array.prototype.slice.call(from2, 0, i2); + ar2[i2] = from2[i2]; + } } - nc = nonce; - counterLength = nonceInplaceCounterLength; - } - var block = new Uint8Array(64); - for (var i2 = 0; i2 < src2.length; i2 += 64) { - core(block, nc, key); - for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { - dst[j2] = src2[j2] ^ block[j2 - i2]; + return to2.concat(ar2 || Array.prototype.slice.call(from2)); + }; + var BrowserInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BrowserInfo2(name2, version2, os2) { + this.name = name2; + this.version = version2; + this.os = os2; + this.type = "browser"; } - incrementCounter(nc, 0, counterLength); + return BrowserInfo2; + }() + ); + var NodeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function NodeInfo2(version2) { + this.version = version2; + this.type = "node"; + this.name = "node"; + this.os = process.platform; + } + return NodeInfo2; + }() + ); + var SearchBotDeviceInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function SearchBotDeviceInfo2(name2, version2, os2, bot) { + this.name = name2; + this.version = version2; + this.os = os2; + this.bot = bot; + this.type = "bot-device"; + } + return SearchBotDeviceInfo2; + }() + ); + var BotInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BotInfo2() { + this.type = "bot"; + this.bot = true; + this.name = "bot"; + this.version = null; + this.os = null; + } + return BotInfo2; + }() + ); + var ReactNativeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function ReactNativeInfo2() { + this.type = "react-native"; + this.name = "react-native"; + this.version = null; + this.os = null; + } + return ReactNativeInfo2; + }() + ); + var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; + var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; + var REQUIRED_VERSION_PARTS = 3; + var userAgentRules = [ + ["aol", /AOLShield\/([0-9\._]+)/], + ["edge", /Edge\/([0-9\._]+)/], + ["edge-ios", /EdgiOS\/([0-9\._]+)/], + ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], + ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], + ["samsung", /SamsungBrowser\/([0-9\.]+)/], + ["silk", /\bSilk\/([0-9._-]+)\b/], + ["miui", /MiuiBrowser\/([0-9\.]+)$/], + ["beaker", /BeakerBrowser\/([0-9\.]+)/], + ["edge-chromium", /EdgA?\/([0-9\.]+)/], + [ + "chromium-webview", + /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ + ], + ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], + ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], + ["fxios", /FxiOS\/([0-9\.]+)/], + ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], + ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], + ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], + ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], + ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], + ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], + ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ["ie", /MSIE\s(7\.0)/], + ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], + ["android", /Android\s([0-9\.]+)/], + ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ["safari", /Version\/([0-9\._]+).*Safari/], + ["facebook", /FB[AS]V\/([0-9\.]+)/], + ["instagram", /Instagram\s([0-9\.]+)/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ["curl", /^curl\/([0-9\.]+)$/], + ["searchbot", SEARCHBOX_UA_REGEX] + ]; + var operatingSystemRules = [ + ["iOS", /iP(hone|od|ad)/], + ["Android OS", /Android/], + ["BlackBerry OS", /BlackBerry|BB10/], + ["Windows Mobile", /IEMobile/], + ["Amazon OS", /Kindle/], + ["Windows 3.11", /Win16/], + ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], + ["Windows 98", /(Windows 98)|(Win98)/], + ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], + ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], + ["Windows Server 2003", /(Windows NT 5.2)/], + ["Windows Vista", /(Windows NT 6.0)/], + ["Windows 7", /(Windows NT 6.1)/], + ["Windows 8", /(Windows NT 6.2)/], + ["Windows 8.1", /(Windows NT 6.3)/], + ["Windows 10", /(Windows NT 10.0)/], + ["Windows ME", /Windows ME/], + ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], + ["Open BSD", /OpenBSD/], + ["Sun OS", /SunOS/], + ["Chrome OS", /CrOS/], + ["Linux", /(Linux)|(X11)/], + ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], + ["QNX", /QNX/], + ["BeOS", /BeOS/], + ["OS/2", /OS\/2/] + ]; + function detect(userAgent) { + if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { + return new ReactNativeInfo(); } - wipe_1$2.wipe(block); - if (nonceInplaceCounterLength === 0) { - wipe_1$2.wipe(nc); + if (typeof navigator !== "undefined") { + return parseUserAgent(navigator.userAgent); } - return dst; + return getNodeVersion(); } - chacha.streamXOR = streamXOR; - function stream(key, nonce, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - wipe_1$2.wipe(dst); - return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); + function matchUserAgent(ua2) { + return ua2 !== "" && userAgentRules.reduce(function(matched, _a2) { + var browser2 = _a2[0], regex2 = _a2[1]; + if (matched) { + return matched; + } + var uaMatch = regex2.exec(ua2); + return !!uaMatch && [browser2, uaMatch]; + }, false); } - chacha.stream = stream; - function incrementCounter(counter, pos, len) { - var carry = 1; - while (len--) { - carry = carry + (counter[pos] & 255) | 0; - counter[pos] = carry & 255; - carry >>>= 8; - pos++; + function parseUserAgent(ua2) { + var matchedRule = matchUserAgent(ua2); + if (!matchedRule) { + return null; } - if (carry > 0) { - throw new Error("ChaCha: counter overflow"); + var name2 = matchedRule[0], match = matchedRule[1]; + if (name2 === "searchbot") { + return new BotInfo(); + } + var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); + if (versionParts) { + if (versionParts.length < REQUIRED_VERSION_PARTS) { + versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); + } + } else { + versionParts = []; + } + var version2 = versionParts.join("."); + var os2 = detectOS(ua2); + var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua2); + if (searchBotMatch && searchBotMatch[1]) { + return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); } + return new BrowserInfo(name2, version2, os2); } - var poly1305 = {}; - var constantTime = {}; - Object.defineProperty(constantTime, "__esModule", { value: true }); - function select(subject, resultIfOne, resultIfZero) { - return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; + function detectOS(ua2) { + for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { + var _a2 = operatingSystemRules[ii], os2 = _a2[0], regex2 = _a2[1]; + var match = regex2.exec(ua2); + if (match) { + return os2; + } + } + return null; } - constantTime.select = select; - function lessOrEqual(a2, b2) { - return (a2 | 0) - (b2 | 0) - 1 >>> 31 & 1; + function getNodeVersion() { + var isNode = typeof process !== "undefined" && process.version; + return isNode ? new NodeInfo(process.version.slice(1)) : null; } - constantTime.lessOrEqual = lessOrEqual; - function compare(a2, b2) { - if (a2.length !== b2.length) { - return 0; + function createVersionParts(count) { + var output = []; + for (var ii = 0; ii < count; ii++) { + output.push("0"); } - var result = 0; - for (var i2 = 0; i2 < a2.length; i2++) { - result |= a2[i2] ^ b2[i2]; + return output; + } + var cjs$2 = {}; + Object.defineProperty(cjs$2, "__esModule", { value: true }); + cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; + function getFromWindow(name2) { + let res = void 0; + if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { + res = window[name2]; } - return 1 & result - 1 >>> 8; + return res; } - constantTime.compare = compare; - function equal(a2, b2) { - if (a2.length === 0 || b2.length === 0) { - return false; + cjs$2.getFromWindow = getFromWindow; + function getFromWindowOrThrow(name2) { + const res = getFromWindow(name2); + if (!res) { + throw new Error(`${name2} is not defined in Window`); } - return compare(a2, b2) !== 0; + return res; + } + cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; + function getDocumentOrThrow() { + return getFromWindowOrThrow("document"); + } + cjs$2.getDocumentOrThrow = getDocumentOrThrow; + function getDocument() { + return getFromWindow("document"); + } + var getDocument_1 = cjs$2.getDocument = getDocument; + function getNavigatorOrThrow() { + return getFromWindowOrThrow("navigator"); + } + cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; + function getNavigator() { + return getFromWindow("navigator"); + } + var getNavigator_1 = cjs$2.getNavigator = getNavigator; + function getLocationOrThrow() { + return getFromWindowOrThrow("location"); + } + cjs$2.getLocationOrThrow = getLocationOrThrow; + function getLocation() { + return getFromWindow("location"); + } + var getLocation_1 = cjs$2.getLocation = getLocation; + function getCryptoOrThrow() { + return getFromWindowOrThrow("crypto"); + } + cjs$2.getCryptoOrThrow = getCryptoOrThrow; + function getCrypto() { + return getFromWindow("crypto"); + } + cjs$2.getCrypto = getCrypto; + function getLocalStorageOrThrow() { + return getFromWindowOrThrow("localStorage"); + } + cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; + function getLocalStorage() { + return getFromWindow("localStorage"); + } + cjs$2.getLocalStorage = getLocalStorage; + var cjs$1 = {}; + Object.defineProperty(cjs$1, "__esModule", { value: true }); + var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; + const window_getters_1 = cjs$2; + function getWindowMetadata() { + let doc; + let loc; + try { + doc = window_getters_1.getDocumentOrThrow(); + loc = window_getters_1.getLocationOrThrow(); + } catch (e2) { + return null; + } + function getIcons() { + const links = doc.getElementsByTagName("link"); + const icons2 = []; + for (let i2 = 0; i2 < links.length; i2++) { + const link = links[i2]; + const rel = link.getAttribute("rel"); + if (rel) { + if (rel.toLowerCase().indexOf("icon") > -1) { + const href = link.getAttribute("href"); + if (href) { + if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { + let absoluteHref = loc.protocol + "//" + loc.host; + if (href.indexOf("/") === 0) { + absoluteHref += href; + } else { + const path = loc.pathname.split("/"); + path.pop(); + const finalPath = path.join("/"); + absoluteHref += finalPath + "/" + href; + } + icons2.push(absoluteHref); + } else if (href.indexOf("//") === 0) { + const absoluteUrl = loc.protocol + href; + icons2.push(absoluteUrl); + } else { + icons2.push(href); + } + } + } + } + } + return icons2; + } + function getWindowMetadataOfAny(...args) { + const metaTags = doc.getElementsByTagName("meta"); + for (let i2 = 0; i2 < metaTags.length; i2++) { + const tag = metaTags[i2]; + const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { + if (attr) { + return args.includes(attr); + } + return false; + }); + if (attributes.length && attributes) { + const content = tag.getAttribute("content"); + if (content) { + return content; + } + } + } + return ""; + } + function getName() { + let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); + if (!name3) { + name3 = doc.title; + } + return name3; + } + function getDescription() { + const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); + return description3; + } + const name2 = getName(); + const description2 = getDescription(); + const url = loc.origin; + const icons = getIcons(); + const meta = { + description: description2, + url, + icons, + name: name2 + }; + return meta; + } + getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; + var queryString = {}; + var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); + var token = "%[a-f0-9]{2}"; + var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); + var multiMatcher = new RegExp("(" + token + ")+", "gi"); + function decodeComponents(components, split) { + try { + return [decodeURIComponent(components.join(""))]; + } catch (err) { + } + if (components.length === 1) { + return components; + } + split = split || 1; + var left = components.slice(0, split); + var right = components.slice(split); + return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); + } + function decode(input) { + try { + return decodeURIComponent(input); + } catch (err) { + var tokens = input.match(singleMatcher) || []; + for (var i2 = 1; i2 < tokens.length; i2++) { + input = decodeComponents(tokens, i2).join(""); + tokens = input.match(singleMatcher) || []; + } + return input; + } + } + function customDecodeURIComponent(input) { + var replaceMap = { + "%FE%FF": "��", + "%FF%FE": "��" + }; + var match = multiMatcher.exec(input); + while (match) { + try { + replaceMap[match[0]] = decodeURIComponent(match[0]); + } catch (err) { + var result = decode(match[0]); + if (result !== match[0]) { + replaceMap[match[0]] = result; + } + } + match = multiMatcher.exec(input); + } + replaceMap["%C2"] = "�"; + var entries = Object.keys(replaceMap); + for (var i2 = 0; i2 < entries.length; i2++) { + var key = entries[i2]; + input = input.replace(new RegExp(key, "g"), replaceMap[key]); + } + return input; + } + var decodeUriComponent = function(encodedURI) { + if (typeof encodedURI !== "string") { + throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + } + try { + encodedURI = encodedURI.replace(/\+/g, " "); + return decodeURIComponent(encodedURI); + } catch (err) { + return customDecodeURIComponent(encodedURI); + } + }; + var splitOnFirst = (string2, separator) => { + if (!(typeof string2 === "string" && typeof separator === "string")) { + throw new TypeError("Expected the arguments to be of type `string`"); + } + if (separator === "") { + return [string2]; + } + const separatorIndex = string2.indexOf(separator); + if (separatorIndex === -1) { + return [string2]; + } + return [ + string2.slice(0, separatorIndex), + string2.slice(separatorIndex + separator.length) + ]; + }; + var filterObj = function(obj, predicate) { + var ret = {}; + var keys2 = Object.keys(obj); + var isArr = Array.isArray(predicate); + for (var i2 = 0; i2 < keys2.length; i2++) { + var key = keys2[i2]; + var val = obj[key]; + if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { + ret[key] = val; + } + } + return ret; + }; + (function(exports3) { + const strictUriEncode$1 = strictUriEncode; + const decodeComponent = decodeUriComponent; + const splitOnFirst$1 = splitOnFirst; + const filterObject = filterObj; + const isNullOrUndefined = (value) => value === null || value === void 0; + const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); + function encoderForArrayFormat(options) { + switch (options.arrayFormat) { + case "index": + return (key) => (result, value) => { + const index2 = result.length; + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), "[", index2, "]"].join("")]; + } + return [ + ...result, + [encode2(key, options), "[", encode2(index2, options), "]=", encode2(value, options)].join("") + ]; + }; + case "bracket": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), "[]"].join("")]; + } + return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; + }; + case "colon-list-separator": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), ":list="].join("")]; + } + return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; + }; + case "comma": + case "separator": + case "bracket-separator": { + const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + value = value === null ? "" : value; + if (result.length === 0) { + return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; + } + return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; + }; + } + default: + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, encode2(key, options)]; + } + return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; + }; + } + } + function parserForArrayFormat(options) { + let result; + switch (options.arrayFormat) { + case "index": + return (key, value, accumulator) => { + result = /\[(\d*)\]$/.exec(key); + key = key.replace(/\[\d*\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = {}; + } + accumulator[key][result[1]] = value; + }; + case "bracket": + return (key, value, accumulator) => { + result = /(\[\])$/.exec(key); + key = key.replace(/\[\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "colon-list-separator": + return (key, value, accumulator) => { + result = /(:list)$/.exec(key); + key = key.replace(/:list$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "comma": + case "separator": + return (key, value, accumulator) => { + const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator); + const isEncodedArray = typeof value === "string" && !isArray && decode2(value, options).includes(options.arrayFormatSeparator); + value = isEncodedArray ? decode2(value, options) : value; + const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); + accumulator[key] = newValue; + }; + case "bracket-separator": + return (key, value, accumulator) => { + const isArray = /(\[\])$/.test(key); + key = key.replace(/\[\]$/, ""); + if (!isArray) { + accumulator[key] = value ? decode2(value, options) : value; + return; + } + const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); + if (accumulator[key] === void 0) { + accumulator[key] = arrayValue; + return; + } + accumulator[key] = [].concat(accumulator[key], arrayValue); + }; + default: + return (key, value, accumulator) => { + if (accumulator[key] === void 0) { + accumulator[key] = value; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + } + } + function validateArrayFormatSeparator(value) { + if (typeof value !== "string" || value.length !== 1) { + throw new TypeError("arrayFormatSeparator must be single character string"); + } + } + function encode2(value, options) { + if (options.encode) { + return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); + } + return value; + } + function decode2(value, options) { + if (options.decode) { + return decodeComponent(value); + } + return value; + } + function keysSorter(input) { + if (Array.isArray(input)) { + return input.sort(); + } + if (typeof input === "object") { + return keysSorter(Object.keys(input)).sort((a2, b2) => Number(a2) - Number(b2)).map((key) => input[key]); + } + return input; + } + function removeHash(input) { + const hashStart = input.indexOf("#"); + if (hashStart !== -1) { + input = input.slice(0, hashStart); + } + return input; + } + function getHash(url) { + let hash2 = ""; + const hashStart = url.indexOf("#"); + if (hashStart !== -1) { + hash2 = url.slice(hashStart); + } + return hash2; + } + function extract(input) { + input = removeHash(input); + const queryStart = input.indexOf("?"); + if (queryStart === -1) { + return ""; + } + return input.slice(queryStart + 1); + } + function parseValue(value, options) { + if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { + value = Number(value); + } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { + value = value.toLowerCase() === "true"; + } + return value; + } + function parse(query, options) { + options = Object.assign({ + decode: true, + sort: true, + arrayFormat: "none", + arrayFormatSeparator: ",", + parseNumbers: false, + parseBooleans: false + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const formatter = parserForArrayFormat(options); + const ret = /* @__PURE__ */ Object.create(null); + if (typeof query !== "string") { + return ret; + } + query = query.trim().replace(/^[?#&]/, ""); + if (!query) { + return ret; + } + for (const param of query.split("&")) { + if (param === "") { + continue; + } + let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); + value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); + formatter(decode2(key, options), value, ret); + } + for (const key of Object.keys(ret)) { + const value = ret[key]; + if (typeof value === "object" && value !== null) { + for (const k2 of Object.keys(value)) { + value[k2] = parseValue(value[k2], options); + } + } else { + ret[key] = parseValue(value, options); + } + } + if (options.sort === false) { + return ret; + } + return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { + const value = ret[key]; + if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { + result[key] = keysSorter(value); + } else { + result[key] = value; + } + return result; + }, /* @__PURE__ */ Object.create(null)); + } + exports3.extract = extract; + exports3.parse = parse; + exports3.stringify = (object, options) => { + if (!object) { + return ""; + } + options = Object.assign({ + encode: true, + strict: true, + arrayFormat: "none", + arrayFormatSeparator: "," + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; + const formatter = encoderForArrayFormat(options); + const objectCopy = {}; + for (const key of Object.keys(object)) { + if (!shouldFilter(key)) { + objectCopy[key] = object[key]; + } + } + const keys2 = Object.keys(objectCopy); + if (options.sort !== false) { + keys2.sort(options.sort); + } + return keys2.map((key) => { + const value = object[key]; + if (value === void 0) { + return ""; + } + if (value === null) { + return encode2(key, options); + } + if (Array.isArray(value)) { + if (value.length === 0 && options.arrayFormat === "bracket-separator") { + return encode2(key, options) + "[]"; + } + return value.reduce(formatter(key), []).join("&"); + } + return encode2(key, options) + "=" + encode2(value, options); + }).filter((x2) => x2.length > 0).join("&"); + }; + exports3.parseUrl = (url, options) => { + options = Object.assign({ + decode: true + }, options); + const [url_, hash2] = splitOnFirst$1(url, "#"); + return Object.assign( + { + url: url_.split("?")[0] || "", + query: parse(extract(url), options) + }, + options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} + ); + }; + exports3.stringifyUrl = (object, options) => { + options = Object.assign({ + encode: true, + strict: true, + [encodeFragmentIdentifier]: true + }, options); + const url = removeHash(object.url).split("?")[0] || ""; + const queryFromUrl = exports3.extract(object.url); + const parsedQueryFromUrl = exports3.parse(queryFromUrl, { sort: false }); + const query = Object.assign(parsedQueryFromUrl, object.query); + let queryString2 = exports3.stringify(query, options); + if (queryString2) { + queryString2 = `?${queryString2}`; + } + let hash2 = getHash(object.url); + if (object.fragmentIdentifier) { + hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + } + return `${url}${queryString2}${hash2}`; + }; + exports3.pick = (input, filter, options) => { + options = Object.assign({ + parseFragmentIdentifier: true, + [encodeFragmentIdentifier]: false + }, options); + const { url, query, fragmentIdentifier } = exports3.parseUrl(input, options); + return exports3.stringifyUrl({ + url, + query: filterObject(query, filter), + fragmentIdentifier + }, options); + }; + exports3.exclude = (input, filter, options) => { + const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); + return exports3.pick(input, exclusionFilter, options); + }; + })(queryString); + var chacha20poly1305 = {}; + var chacha = {}; + Object.defineProperty(chacha, "__esModule", { value: true }); + var binary_1 = binary; + var wipe_1$2 = wipe$1; + var ROUNDS = 20; + function core(out, input, key) { + var j02 = 1634760805; + var j1 = 857760878; + var j2 = 2036477234; + var j3 = 1797285236; + var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; + var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; + var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; + var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; + var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; + var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; + var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; + var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; + var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; + var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; + var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; + var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; + var x02 = j02; + var x1 = j1; + var x2 = j2; + var x3 = j3; + var x4 = j4; + var x5 = j5; + var x6 = j6; + var x7 = j7; + var x8 = j8; + var x9 = j9; + var x10 = j10; + var x11 = j11; + var x12 = j12; + var x13 = j13; + var x14 = j14; + var x15 = j15; + for (var i2 = 0; i2 < ROUNDS; i2 += 2) { + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 16 | x12 << 16; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 12 | x4 << 12; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 16 | x13 << 16; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 12 | x5 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 16 | x14 << 16; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 12 | x6 << 12; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 16 | x15 << 16; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 12 | x7 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 8 | x14 << 8; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 7 | x6 << 7; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 8 | x15 << 8; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 7 | x7 << 7; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 8 | x13 << 8; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 7 | x5 << 7; + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 8 | x12 << 8; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 7 | x4 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 16 | x15 << 16; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 12 | x5 << 12; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 16 | x12 << 16; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 12 | x6 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 16 | x13 << 16; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 12 | x7 << 12; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 16 | x14 << 16; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 12 | x4 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 8 | x13 << 8; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 7 | x7 << 7; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 8 | x14 << 8; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 7 | x4 << 7; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 8 | x12 << 8; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 7 | x6 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 8 | x15 << 8; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 7 | x5 << 7; + } + binary_1.writeUint32LE(x02 + j02 | 0, out, 0); + binary_1.writeUint32LE(x1 + j1 | 0, out, 4); + binary_1.writeUint32LE(x2 + j2 | 0, out, 8); + binary_1.writeUint32LE(x3 + j3 | 0, out, 12); + binary_1.writeUint32LE(x4 + j4 | 0, out, 16); + binary_1.writeUint32LE(x5 + j5 | 0, out, 20); + binary_1.writeUint32LE(x6 + j6 | 0, out, 24); + binary_1.writeUint32LE(x7 + j7 | 0, out, 28); + binary_1.writeUint32LE(x8 + j8 | 0, out, 32); + binary_1.writeUint32LE(x9 + j9 | 0, out, 36); + binary_1.writeUint32LE(x10 + j10 | 0, out, 40); + binary_1.writeUint32LE(x11 + j11 | 0, out, 44); + binary_1.writeUint32LE(x12 + j12 | 0, out, 48); + binary_1.writeUint32LE(x13 + j13 | 0, out, 52); + binary_1.writeUint32LE(x14 + j14 | 0, out, 56); + binary_1.writeUint32LE(x15 + j15 | 0, out, 60); + } + function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + if (key.length !== 32) { + throw new Error("ChaCha: key size must be 32 bytes"); + } + if (dst.length < src2.length) { + throw new Error("ChaCha: destination is shorter than source"); + } + var nc; + var counterLength; + if (nonceInplaceCounterLength === 0) { + if (nonce.length !== 8 && nonce.length !== 12) { + throw new Error("ChaCha nonce must be 8 or 12 bytes"); + } + nc = new Uint8Array(16); + counterLength = nc.length - nonce.length; + nc.set(nonce, counterLength); + } else { + if (nonce.length !== 16) { + throw new Error("ChaCha nonce with counter must be 16 bytes"); + } + nc = nonce; + counterLength = nonceInplaceCounterLength; + } + var block = new Uint8Array(64); + for (var i2 = 0; i2 < src2.length; i2 += 64) { + core(block, nc, key); + for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { + dst[j2] = src2[j2] ^ block[j2 - i2]; + } + incrementCounter(nc, 0, counterLength); + } + wipe_1$2.wipe(block); + if (nonceInplaceCounterLength === 0) { + wipe_1$2.wipe(nc); + } + return dst; + } + chacha.streamXOR = streamXOR; + function stream(key, nonce, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + wipe_1$2.wipe(dst); + return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); + } + chacha.stream = stream; + function incrementCounter(counter, pos, len) { + var carry = 1; + while (len--) { + carry = carry + (counter[pos] & 255) | 0; + counter[pos] = carry & 255; + carry >>>= 8; + pos++; + } + if (carry > 0) { + throw new Error("ChaCha: counter overflow"); + } + } + var poly1305 = {}; + var constantTime = {}; + Object.defineProperty(constantTime, "__esModule", { value: true }); + function select(subject, resultIfOne, resultIfZero) { + return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; + } + constantTime.select = select; + function lessOrEqual(a2, b2) { + return (a2 | 0) - (b2 | 0) - 1 >>> 31 & 1; + } + constantTime.lessOrEqual = lessOrEqual; + function compare(a2, b2) { + if (a2.length !== b2.length) { + return 0; + } + var result = 0; + for (var i2 = 0; i2 < a2.length; i2++) { + result |= a2[i2] ^ b2[i2]; + } + return 1 & result - 1 >>> 8; + } + constantTime.compare = compare; + function equal(a2, b2) { + if (a2.length === 0 || b2.length === 0) { + return false; + } + return compare(a2, b2) !== 0; } constantTime.equal = equal; (function(exports3) { @@ -6143,11 +6871,11 @@ } Poly13052.prototype._blocks = function(m2, mpos, bytes) { var hibit = this._fin ? 0 : 1 << 11; - var h0 = this._h[0], h1 = this._h[1], h2 = this._h[2], h3 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; + var h02 = this._h[0], h1 = this._h[1], h2 = this._h[2], h3 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; var r0 = this._r[0], r1 = this._r[1], r2 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; while (bytes >= 16) { var t0 = m2[mpos + 0] | m2[mpos + 1] << 8; - h0 += t0 & 8191; + h02 += t0 & 8191; var t1 = m2[mpos + 2] | m2[mpos + 3] << 8; h1 += (t0 >>> 13 | t1 << 3) & 8191; var t2 = m2[mpos + 4] | m2[mpos + 5] << 8; @@ -6165,23 +6893,23 @@ h8 += (t6 >>> 8 | t7 << 8) & 8191; h9 += t7 >>> 5 | hibit; var c2 = 0; - var d0 = c2; - d0 += h0 * r0; - d0 += h1 * (5 * r9); - d0 += h2 * (5 * r8); - d0 += h3 * (5 * r7); - d0 += h4 * (5 * r6); - c2 = d0 >>> 13; - d0 &= 8191; - d0 += h5 * (5 * r5); - d0 += h6 * (5 * r4); - d0 += h7 * (5 * r3); - d0 += h8 * (5 * r2); - d0 += h9 * (5 * r1); - c2 += d0 >>> 13; - d0 &= 8191; + var d02 = c2; + d02 += h02 * r0; + d02 += h1 * (5 * r9); + d02 += h2 * (5 * r8); + d02 += h3 * (5 * r7); + d02 += h4 * (5 * r6); + c2 = d02 >>> 13; + d02 &= 8191; + d02 += h5 * (5 * r5); + d02 += h6 * (5 * r4); + d02 += h7 * (5 * r3); + d02 += h8 * (5 * r2); + d02 += h9 * (5 * r1); + c2 += d02 >>> 13; + d02 &= 8191; var d1 = c2; - d1 += h0 * r1; + d1 += h02 * r1; d1 += h1 * r0; d1 += h2 * (5 * r9); d1 += h3 * (5 * r8); @@ -6196,7 +6924,7 @@ c2 += d1 >>> 13; d1 &= 8191; var d2 = c2; - d2 += h0 * r2; + d2 += h02 * r2; d2 += h1 * r1; d2 += h2 * r0; d2 += h3 * (5 * r9); @@ -6211,7 +6939,7 @@ c2 += d2 >>> 13; d2 &= 8191; var d3 = c2; - d3 += h0 * r3; + d3 += h02 * r3; d3 += h1 * r2; d3 += h2 * r1; d3 += h3 * r0; @@ -6226,7 +6954,7 @@ c2 += d3 >>> 13; d3 &= 8191; var d4 = c2; - d4 += h0 * r4; + d4 += h02 * r4; d4 += h1 * r3; d4 += h2 * r2; d4 += h3 * r1; @@ -6241,7 +6969,7 @@ c2 += d4 >>> 13; d4 &= 8191; var d5 = c2; - d5 += h0 * r5; + d5 += h02 * r5; d5 += h1 * r4; d5 += h2 * r3; d5 += h3 * r2; @@ -6256,7 +6984,7 @@ c2 += d5 >>> 13; d5 &= 8191; var d6 = c2; - d6 += h0 * r6; + d6 += h02 * r6; d6 += h1 * r5; d6 += h2 * r4; d6 += h3 * r3; @@ -6271,7 +6999,7 @@ c2 += d6 >>> 13; d6 &= 8191; var d7 = c2; - d7 += h0 * r7; + d7 += h02 * r7; d7 += h1 * r6; d7 += h2 * r5; d7 += h3 * r4; @@ -6286,7 +7014,7 @@ c2 += d7 >>> 13; d7 &= 8191; var d8 = c2; - d8 += h0 * r8; + d8 += h02 * r8; d8 += h1 * r7; d8 += h2 * r6; d8 += h3 * r5; @@ -6301,7 +7029,7 @@ c2 += d8 >>> 13; d8 &= 8191; var d9 = c2; - d9 += h0 * r9; + d9 += h02 * r9; d9 += h1 * r8; d9 += h2 * r7; d9 += h3 * r6; @@ -6316,11 +7044,11 @@ c2 += d9 >>> 13; d9 &= 8191; c2 = (c2 << 2) + c2 | 0; - c2 = c2 + d0 | 0; - d0 = c2 & 8191; + c2 = c2 + d02 | 0; + d02 = c2 & 8191; c2 = c2 >>> 13; d1 += c2; - h0 = d0; + h02 = d02; h1 = d1; h2 = d2; h3 = d3; @@ -6333,7 +7061,7 @@ mpos += 16; bytes -= 16; } - this._h[0] = h0; + this._h[0] = h02; this._h[1] = h1; this._h[2] = h2; this._h[3] = h3; @@ -7039,7 +7767,7 @@ exports3.PUBLIC_KEY_LENGTH = 32; exports3.SECRET_KEY_LENGTH = 32; exports3.SHARED_KEY_LENGTH = 32; - function gf(init) { + function gf2(init) { const r2 = new Float64Array(16); if (init) { for (let i2 = 0; i2 < init.length; i2++) { @@ -7050,7 +7778,7 @@ } const _9 = new Uint8Array(32); _9[0] = 9; - const _121665 = gf([56129, 1]); + const _121665 = gf2([56129, 1]); function car25519(o2) { let c2 = 1; for (let i2 = 0; i2 < 16; i2++) { @@ -7069,8 +7797,8 @@ } } function pack25519(o2, n2) { - const m2 = gf(); - const t2 = gf(); + const m2 = gf2(); + const t2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { t2[i2] = n2[i2]; } @@ -7110,9 +7838,9 @@ } } function mul(o2, a2, b2) { - let v2, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b2[0], b1 = b2[1], b22 = b2[2], b3 = b2[3], b4 = b2[4], b5 = b2[5], b6 = b2[6], b7 = b2[7], b8 = b2[8], b9 = b2[9], b10 = b2[10], b11 = b2[11], b12 = b2[12], b13 = b2[13], b14 = b2[14], b15 = b2[15]; + let v2, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b2[0], b1 = b2[1], b22 = b2[2], b3 = b2[3], b4 = b2[4], b5 = b2[5], b6 = b2[6], b7 = b2[7], b8 = b2[8], b9 = b2[9], b10 = b2[10], b11 = b2[11], b12 = b2[12], b13 = b2[13], b14 = b2[14], b15 = b2[15]; v2 = a2[0]; - t0 += v2 * b0; + t0 += v2 * b02; t1 += v2 * b1; t2 += v2 * b22; t3 += v2 * b3; @@ -7129,7 +7857,7 @@ t14 += v2 * b14; t15 += v2 * b15; v2 = a2[1]; - t1 += v2 * b0; + t1 += v2 * b02; t2 += v2 * b1; t3 += v2 * b22; t4 += v2 * b3; @@ -7146,7 +7874,7 @@ t15 += v2 * b14; t16 += v2 * b15; v2 = a2[2]; - t2 += v2 * b0; + t2 += v2 * b02; t3 += v2 * b1; t4 += v2 * b22; t5 += v2 * b3; @@ -7163,7 +7891,7 @@ t16 += v2 * b14; t17 += v2 * b15; v2 = a2[3]; - t3 += v2 * b0; + t3 += v2 * b02; t4 += v2 * b1; t5 += v2 * b22; t6 += v2 * b3; @@ -7180,7 +7908,7 @@ t17 += v2 * b14; t18 += v2 * b15; v2 = a2[4]; - t4 += v2 * b0; + t4 += v2 * b02; t5 += v2 * b1; t6 += v2 * b22; t7 += v2 * b3; @@ -7197,7 +7925,7 @@ t18 += v2 * b14; t19 += v2 * b15; v2 = a2[5]; - t5 += v2 * b0; + t5 += v2 * b02; t6 += v2 * b1; t7 += v2 * b22; t8 += v2 * b3; @@ -7214,7 +7942,7 @@ t19 += v2 * b14; t20 += v2 * b15; v2 = a2[6]; - t6 += v2 * b0; + t6 += v2 * b02; t7 += v2 * b1; t8 += v2 * b22; t9 += v2 * b3; @@ -7231,7 +7959,7 @@ t20 += v2 * b14; t21 += v2 * b15; v2 = a2[7]; - t7 += v2 * b0; + t7 += v2 * b02; t8 += v2 * b1; t9 += v2 * b22; t10 += v2 * b3; @@ -7248,7 +7976,7 @@ t21 += v2 * b14; t22 += v2 * b15; v2 = a2[8]; - t8 += v2 * b0; + t8 += v2 * b02; t9 += v2 * b1; t10 += v2 * b22; t11 += v2 * b3; @@ -7265,7 +7993,7 @@ t22 += v2 * b14; t23 += v2 * b15; v2 = a2[9]; - t9 += v2 * b0; + t9 += v2 * b02; t10 += v2 * b1; t11 += v2 * b22; t12 += v2 * b3; @@ -7282,7 +8010,7 @@ t23 += v2 * b14; t24 += v2 * b15; v2 = a2[10]; - t10 += v2 * b0; + t10 += v2 * b02; t11 += v2 * b1; t12 += v2 * b22; t13 += v2 * b3; @@ -7299,7 +8027,7 @@ t24 += v2 * b14; t25 += v2 * b15; v2 = a2[11]; - t11 += v2 * b0; + t11 += v2 * b02; t12 += v2 * b1; t13 += v2 * b22; t14 += v2 * b3; @@ -7316,7 +8044,7 @@ t25 += v2 * b14; t26 += v2 * b15; v2 = a2[12]; - t12 += v2 * b0; + t12 += v2 * b02; t13 += v2 * b1; t14 += v2 * b22; t15 += v2 * b3; @@ -7333,7 +8061,7 @@ t26 += v2 * b14; t27 += v2 * b15; v2 = a2[13]; - t13 += v2 * b0; + t13 += v2 * b02; t14 += v2 * b1; t15 += v2 * b22; t16 += v2 * b3; @@ -7350,7 +8078,7 @@ t27 += v2 * b14; t28 += v2 * b15; v2 = a2[14]; - t14 += v2 * b0; + t14 += v2 * b02; t15 += v2 * b1; t16 += v2 * b22; t17 += v2 * b3; @@ -7367,7 +8095,7 @@ t28 += v2 * b14; t29 += v2 * b15; v2 = a2[15]; - t15 += v2 * b0; + t15 += v2 * b02; t16 += v2 * b1; t17 += v2 * b22; t18 += v2 * b3; @@ -7519,7 +8247,7 @@ mul(o2, a2, a2); } function inv25519(o2, inp) { - const c2 = gf(); + const c2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { c2[i2] = inp[i2]; } @@ -7536,7 +8264,7 @@ function scalarMult(n2, p2) { const z2 = new Uint8Array(32); const x2 = new Float64Array(80); - const a2 = gf(), b2 = gf(), c2 = gf(), d2 = gf(), e2 = gf(), f2 = gf(); + const a2 = gf2(), b2 = gf2(), c2 = gf2(), d2 = gf2(), e2 = gf2(), f2 = gf2(); for (let i2 = 0; i2 < 31; i2++) { z2[i2] = n2[i2]; } @@ -7631,1186 +8359,3970 @@ } exports3.sharedKey = sharedKey; })(x25519); - var __spreadArray = function(to2, from2, pack) { - if (pack || arguments.length === 2) - for (var i2 = 0, l2 = from2.length, ar2; i2 < l2; i2++) { - if (ar2 || !(i2 in from2)) { - if (!ar2) - ar2 = Array.prototype.slice.call(from2, 0, i2); - ar2[i2] = from2[i2]; - } - } - return to2.concat(ar2 || Array.prototype.slice.call(from2)); + const C$2 = { 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" } }; + const Ir$1 = ":"; + function dn(e2) { + const [t2, r2] = e2.split(Ir$1); + return { namespace: t2, reference: r2 }; + } + function _r$1(e2, t2) { + return e2.includes(":") ? [e2] : t2.chains || []; + } + var Qo = Object.defineProperty, bn = Object.getOwnPropertySymbols, Jo$1 = Object.prototype.hasOwnProperty, Go$1 = Object.prototype.propertyIsEnumerable, yn = (e2, t2, r2) => t2 in e2 ? Qo(e2, t2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[t2] = r2, wn = (e2, t2) => { + for (var r2 in t2 || (t2 = {})) + Jo$1.call(t2, r2) && yn(e2, r2, t2[r2]); + if (bn) + for (var r2 of bn(t2)) + Go$1.call(t2, r2) && yn(e2, r2, t2[r2]); + return e2; }; - var BrowserInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BrowserInfo2(name2, version2, os2) { - this.name = name2; - this.version = version2; - this.os = os2; - this.type = "browser"; - } - return BrowserInfo2; - }() - ); - var NodeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function NodeInfo2(version2) { - this.version = version2; - this.type = "node"; - this.name = "node"; - this.os = process.platform; - } - return NodeInfo2; - }() - ); - var SearchBotDeviceInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function SearchBotDeviceInfo2(name2, version2, os2, bot) { - this.name = name2; - this.version = version2; - this.os = os2; - this.bot = bot; - this.type = "bot-device"; - } - return SearchBotDeviceInfo2; - }() - ); - var BotInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BotInfo2() { - this.type = "bot"; - this.bot = true; - this.name = "bot"; - this.version = null; - this.os = null; - } - return BotInfo2; - }() - ); - var ReactNativeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function ReactNativeInfo2() { - this.type = "react-native"; - this.name = "react-native"; - this.version = null; - this.os = null; - } - return ReactNativeInfo2; - }() - ); - var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; - var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; - var REQUIRED_VERSION_PARTS = 3; - var userAgentRules = [ - ["aol", /AOLShield\/([0-9\._]+)/], - ["edge", /Edge\/([0-9\._]+)/], - ["edge-ios", /EdgiOS\/([0-9\._]+)/], - ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], - ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], - ["samsung", /SamsungBrowser\/([0-9\.]+)/], - ["silk", /\bSilk\/([0-9._-]+)\b/], - ["miui", /MiuiBrowser\/([0-9\.]+)$/], - ["beaker", /BeakerBrowser\/([0-9\.]+)/], - ["edge-chromium", /EdgA?\/([0-9\.]+)/], - [ - "chromium-webview", - /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ - ], - ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], - ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], - ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], - ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], - ["fxios", /FxiOS\/([0-9\.]+)/], - ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], - ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], - ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], - ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], - ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], - ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], - ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], - ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], - ["ie", /MSIE\s(7\.0)/], - ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], - ["android", /Android\s([0-9\.]+)/], - ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], - ["safari", /Version\/([0-9\._]+).*Safari/], - ["facebook", /FB[AS]V\/([0-9\.]+)/], - ["instagram", /Instagram\s([0-9\.]+)/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], - ["curl", /^curl\/([0-9\.]+)$/], - ["searchbot", SEARCHBOX_UA_REGEX] - ]; - var operatingSystemRules = [ - ["iOS", /iP(hone|od|ad)/], - ["Android OS", /Android/], - ["BlackBerry OS", /BlackBerry|BB10/], - ["Windows Mobile", /IEMobile/], - ["Amazon OS", /Kindle/], - ["Windows 3.11", /Win16/], - ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], - ["Windows 98", /(Windows 98)|(Win98)/], - ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], - ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], - ["Windows Server 2003", /(Windows NT 5.2)/], - ["Windows Vista", /(Windows NT 6.0)/], - ["Windows 7", /(Windows NT 6.1)/], - ["Windows 8", /(Windows NT 6.2)/], - ["Windows 8.1", /(Windows NT 6.3)/], - ["Windows 10", /(Windows NT 10.0)/], - ["Windows ME", /Windows ME/], - ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], - ["Open BSD", /OpenBSD/], - ["Sun OS", /SunOS/], - ["Chrome OS", /CrOS/], - ["Linux", /(Linux)|(X11)/], - ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], - ["QNX", /QNX/], - ["BeOS", /BeOS/], - ["OS/2", /OS\/2/] - ]; - function detect(userAgent) { - if (!!userAgent) { - return parseUserAgent(userAgent); - } - if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { - return new ReactNativeInfo(); - } - if (typeof navigator !== "undefined") { - return parseUserAgent(navigator.userAgent); - } - return getNodeVersion(); + const xn = "ReactNative", qt$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, En = "js"; + function pi() { + return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; } - function matchUserAgent(ua) { - return ua !== "" && userAgentRules.reduce(function(matched, _a) { - var browser2 = _a[0], regex2 = _a[1]; - if (matched) { - return matched; - } - var uaMatch = regex2.exec(ua); - return !!uaMatch && [browser2, uaMatch]; - }, false); + function er$2() { + return !getDocument_1() && !!getNavigator_1() && navigator.product === xn; } - function parseUserAgent(ua) { - var matchedRule = matchUserAgent(ua); - if (!matchedRule) { - return null; - } - var name2 = matchedRule[0], match = matchedRule[1]; - if (name2 === "searchbot") { - return new BotInfo(); - } - var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); - if (versionParts) { - if (versionParts.length < REQUIRED_VERSION_PARTS) { - versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); - } - } else { - versionParts = []; - } - var version2 = versionParts.join("."); - var os2 = detectOS(ua); - var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua); - if (searchBotMatch && searchBotMatch[1]) { - return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); + function pr$1() { + return !pi() && !!getNavigator_1() && !!getDocument_1(); + } + function We$3() { + return er$2() ? qt$1.reactNative : pi() ? qt$1.node : pr$1() ? qt$1.browser : qt$1.unknown; + } + function Wo$1() { + var e2; + try { + return er$2() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e2 = global.Application) == null ? void 0 : e2.applicationId : void 0; + } catch { + return; } - return new BrowserInfo(name2, version2, os2); } - function detectOS(ua) { - for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { - var _a = operatingSystemRules[ii], os2 = _a[0], regex2 = _a[1]; - var match = regex2.exec(ua); - if (match) { - return os2; - } + function Sn(e2, t2) { + let r2 = queryString.parse(e2); + return r2 = wn(wn({}, r2), t2), e2 = queryString.stringify(r2), e2; + } + function Xo$1() { + return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; + } + function Nn() { + if (We$3() === qt$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { + const { OS: r2, Version: i2 } = global.Platform; + return [r2, i2].join("-"); } - return null; + const e2 = detect(); + if (e2 === null) + return "unknown"; + const t2 = e2.os ? e2.os.replace(" ", "").toLowerCase() : "unknown"; + return e2.type === "browser" ? [t2, e2.name, e2.version].join("-") : [t2, e2.version].join("-"); + } + function In() { + var e2; + const t2 = We$3(); + return t2 === qt$1.browser ? [t2, ((e2 = getLocation_1()) == null ? void 0 : e2.host) || "unknown"].join(":") : t2; + } + function _n(e2, t2, r2) { + const i2 = Nn(), n2 = In(); + return [[e2, t2].join("-"), [En, r2].join("-"), i2, n2].join("/"); + } + function $o({ protocol: e2, version: t2, relayUrl: r2, sdkVersion: i2, auth: n2, projectId: o2, useOnCloseEvent: h2, bundleId: p2 }) { + const b2 = r2.split("?"), m2 = _n(e2, t2, i2), w2 = { auth: n2, ua: m2, projectId: o2, useOnCloseEvent: h2 || void 0, origin: p2 || void 0 }, y2 = Sn(b2[1] || "", w2); + return b2[0] + "?" + y2; + } + function _e$2(e2, t2) { + return e2.filter((r2) => t2.includes(r2)).length === e2.length; } - function getNodeVersion() { - var isNode = typeof process !== "undefined" && process.version; - return isNode ? new NodeInfo(process.version.slice(1)) : null; + function i0(e2) { + return Object.fromEntries(e2.entries()); } - function createVersionParts(count) { - var output = []; - for (var ii = 0; ii < count; ii++) { - output.push("0"); - } - return output; + function n0(e2) { + return new Map(Object.entries(e2)); } - var cjs$2 = {}; - Object.defineProperty(cjs$2, "__esModule", { value: true }); - cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; - function getFromWindow(name2) { - let res = void 0; - if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { - res = window[name2]; - } - return res; + function a0(e2 = cjs$3.FIVE_MINUTES, t2) { + const r2 = cjs$3.toMiliseconds(e2 || cjs$3.FIVE_MINUTES); + let i2, n2, o2; + return { resolve: (h2) => { + o2 && i2 && (clearTimeout(o2), i2(h2)); + }, reject: (h2) => { + o2 && n2 && (clearTimeout(o2), n2(h2)); + }, done: () => new Promise((h2, p2) => { + o2 = setTimeout(() => { + p2(new Error(t2)); + }, r2), i2 = h2, n2 = p2; + }) }; } - cjs$2.getFromWindow = getFromWindow; - function getFromWindowOrThrow(name2) { - const res = getFromWindow(name2); - if (!res) { - throw new Error(`${name2} is not defined in Window`); + function u0(e2, t2, r2) { + return new Promise(async (i2, n2) => { + const o2 = setTimeout(() => n2(new Error(r2)), t2); + try { + const h2 = await e2; + i2(h2); + } catch (h2) { + n2(h2); + } + clearTimeout(o2); + }); + } + function vi(e2, t2) { + if (typeof t2 == "string" && t2.startsWith(`${e2}:`)) + return t2; + if (e2.toLowerCase() === "topic") { + if (typeof t2 != "string") + throw new Error('Value must be "string" for expirer target type: topic'); + return `topic:${t2}`; + } else if (e2.toLowerCase() === "id") { + if (typeof t2 != "number") + throw new Error('Value must be "number" for expirer target type: id'); + return `id:${t2}`; } - return res; + throw new Error(`Unknown expirer target type: ${e2}`); } - cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; - function getDocumentOrThrow() { - return getFromWindowOrThrow("document"); + function h0(e2) { + return vi("topic", e2); } - cjs$2.getDocumentOrThrow = getDocumentOrThrow; - function getDocument() { - return getFromWindow("document"); + function c0(e2) { + return vi("id", e2); } - var getDocument_1 = cjs$2.getDocument = getDocument; - function getNavigatorOrThrow() { - return getFromWindowOrThrow("navigator"); + function l0(e2) { + const [t2, r2] = e2.split(":"), i2 = { id: void 0, topic: void 0 }; + if (t2 === "topic" && typeof r2 == "string") + i2.topic = r2; + else if (t2 === "id" && Number.isInteger(Number(r2))) + i2.id = Number(r2); + else + throw new Error(`Invalid target, expected id:number or topic:string, got ${t2}:${r2}`); + return i2; } - cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; - function getNavigator() { - return getFromWindow("navigator"); + function d0(e2, t2) { + return cjs$3.fromMiliseconds(Date.now() + cjs$3.toMiliseconds(e2)); } - var getNavigator_1 = cjs$2.getNavigator = getNavigator; - function getLocationOrThrow() { - return getFromWindowOrThrow("location"); + function p0(e2) { + return Date.now() >= cjs$3.toMiliseconds(e2); } - cjs$2.getLocationOrThrow = getLocationOrThrow; - function getLocation() { - return getFromWindow("location"); + function v0(e2, t2) { + return `${e2}${t2 ? `:${t2}` : ""}`; } - var getLocation_1 = cjs$2.getLocation = getLocation; - function getCryptoOrThrow() { - return getFromWindowOrThrow("crypto"); + function ge$2(e2 = [], t2 = []) { + return [.../* @__PURE__ */ new Set([...e2, ...t2])]; } - cjs$2.getCryptoOrThrow = getCryptoOrThrow; - function getCrypto() { - return getFromWindow("crypto"); + async function m0({ id: e2, topic: t2, wcDeepLink: r2 }) { + try { + if (!r2) + return; + const i2 = typeof r2 == "string" ? JSON.parse(r2) : r2; + let n2 = i2 == null ? void 0 : i2.href; + if (typeof n2 != "string") + return; + n2.endsWith("/") && (n2 = n2.slice(0, -1)); + const o2 = `${n2}/wc?requestId=${e2}&sessionTopic=${t2}`, h2 = We$3(); + h2 === qt$1.browser ? o2.startsWith("https://") || o2.startsWith("http://") ? window.open(o2, "_blank", "noreferrer noopener") : window.open(o2, "_self", "noreferrer noopener") : h2 === qt$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(o2); + } catch (i2) { + console.error(i2); + } } - cjs$2.getCrypto = getCrypto; - function getLocalStorageOrThrow() { - return getFromWindowOrThrow("localStorage"); + async function g0(e2, t2) { + try { + return await e2.getItem(t2) || (pr$1() ? localStorage.getItem(t2) : void 0); + } catch (r2) { + console.error(r2); + } } - cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; - function getLocalStorage() { - return getFromWindow("localStorage"); + var On$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; + function A0$1(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r2 = function() { + return t2.apply(this, arguments); + }; + r2.prototype = t2.prototype; + } else + r2 = {}; + return Object.defineProperty(r2, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n2 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r2, i2, n2.get ? n2 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r2; } - cjs$2.getLocalStorage = getLocalStorage; - var cjs$1 = {}; - Object.defineProperty(cjs$1, "__esModule", { value: true }); - var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; - const window_getters_1 = cjs$2; - function getWindowMetadata() { - let doc; - let loc; + var Pn$1 = { exports: {} }; + /** + * [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 + */ + (function(e2) { + (function() { + var t2 = "input is invalid type", r2 = "finalize already called", i2 = typeof window == "object", n2 = i2 ? window : {}; + n2.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h2 = !n2.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h2 ? n2 = On$1 : o2 && (n2 = self); + var p2 = !n2.JS_SHA3_NO_COMMON_JS && true && e2.exports, b2 = !n2.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m2 = "0123456789abcdef".split(""), w2 = [31, 7936, 2031616, 520093696], y2 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n2.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u2) { + return Object.prototype.toString.call(u2) === "[object Array]"; + }), b2 && (n2.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u2) { + return typeof u2 == "object" && u2.buffer && u2.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u2, E2, _2) { + return function(B2) { + return new s2(u2, E2, u2).update(B2)[_2](); + }; + }, H2 = function(u2, E2, _2) { + return function(B2, R2) { + return new s2(u2, E2, R2).update(B2)[_2](); + }; + }, z2 = function(u2, E2, _2) { + return function(B2, R2, T2, P2) { + return f2["cshake" + u2].update(B2, R2, T2, P2)[_2](); + }; + }, Pt2 = function(u2, E2, _2) { + return function(B2, R2, T2, P2) { + return f2["kmac" + u2].update(B2, R2, T2, P2)[_2](); + }; + }, W2 = function(u2, E2, _2, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u2[T2] = E2(_2, B2, T2); + } + return u2; + }, Rt2 = function(u2, E2) { + var _2 = G2(u2, E2, "hex"); + return _2.create = function() { + return new s2(u2, E2, u2); + }, _2.update = function(B2) { + return _2.create().update(B2); + }, W2(_2, G2, u2, E2); + }, Yt2 = function(u2, E2) { + var _2 = H2(u2, E2, "hex"); + return _2.create = function(B2) { + return new s2(u2, E2, B2); + }, _2.update = function(B2, R2) { + return _2.create(R2).update(B2); + }, W2(_2, H2, u2, E2); + }, Y2 = function(u2, E2) { + var _2 = Bt2[u2], B2 = z2(u2, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f2["shake" + u2].create(R2) : new s2(u2, E2, R2).bytepad([T2, P2], _2); + }, B2.update = function(R2, T2, P2, O2) { + return B2.create(T2, P2, O2).update(R2); + }, W2(B2, z2, u2, E2); + }, Vt2 = function(u2, E2) { + var _2 = Bt2[u2], B2 = Pt2(u2, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v2(u2, E2, T2).bytepad(["KMAC", P2], _2).bytepad([R2], _2); + }, B2.update = function(R2, T2, P2, O2) { + return B2.create(R2, P2, O2).update(T2); + }, W2(B2, Pt2, u2, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w2, bits: U2, createMethod: Yt2 }, { name: "cshake", padding: y2, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y2, bits: U2, createMethod: Vt2 }], f2 = {}, a2 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d2 = A2[c2], g2 = d2.bits, x2 = 0; x2 < g2.length; ++x2) { + var M2 = d2.name + "_" + g2[x2]; + if (a2.push(M2), f2[M2] = d2.createMethod(g2[x2], d2.padding), d2.name !== "sha3") { + var l2 = d2.name + g2[x2]; + a2.push(l2), f2[l2] = f2[M2]; + } + } + function s2(u2, E2, _2) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _2, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u2 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _2 >> 5, this.extraBytes = (_2 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u2) { + if (this.finalized) + throw new Error(r2); + var E2, _2 = typeof u2; + if (_2 !== "string") { + if (_2 === "object") { + if (u2 === null) + throw new Error(t2); + if (b2 && u2.constructor === ArrayBuffer) + u2 = new Uint8Array(u2); + else if (!Array.isArray(u2) && (!b2 || !ArrayBuffer.isView(u2))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u2.length, P2 = this.blockCount, O2 = 0, Ct2 = this.s, D2, q2; O2 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O2 < T2 && D2 < R2; ++O2) + B2[D2 >> 2] |= u2[O2] << N2[D2++ & 3]; + else + for (D2 = this.start; O2 < T2 && D2 < R2; ++O2) + q2 = u2.charCodeAt(O2), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u2.charCodeAt(++O2) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; + } + return this; + }, s2.prototype.encode = function(u2, E2) { + var _2 = u2 & 255, B2 = 1, R2 = [_2]; + for (u2 = u2 >> 8, _2 = u2 & 255; _2 > 0; ) + R2.unshift(_2), u2 = u2 >> 8, _2 = u2 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u2) { + var E2, _2 = typeof u2; + if (_2 !== "string") { + if (_2 === "object") { + if (u2 === null) + throw new Error(t2); + if (b2 && u2.constructor === ArrayBuffer) + u2 = new Uint8Array(u2); + else if (!Array.isArray(u2) && (!b2 || !ArrayBuffer.isView(u2))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u2.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u2.length; ++T2) { + var P2 = u2.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u2.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u2), B2; + }, s2.prototype.bytepad = function(u2, E2) { + for (var _2 = this.encode(E2), B2 = 0; B2 < u2.length; ++B2) + _2 += this.encodeString(u2[B2]); + var R2 = E2 - _2 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u2 = this.blocks, E2 = this.lastByteIndex, _2 = this.blockCount, B2 = this.s; + if (u2[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u2[0] = u2[_2], E2 = 1; E2 < _2 + 1; ++E2) + u2[E2] = 0; + for (u2[_2 - 1] |= 2147483648, E2 = 0; E2 < _2; ++E2) + B2[E2] ^= u2[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u2 = this.blockCount, E2 = this.s, _2 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O2; T2 < _2; ) { + for (R2 = 0; R2 < u2 && T2 < _2; ++R2, ++T2) + O2 = E2[R2], P2 += m2[O2 >> 4 & 15] + m2[O2 & 15] + m2[O2 >> 12 & 15] + m2[O2 >> 8 & 15] + m2[O2 >> 20 & 15] + m2[O2 >> 16 & 15] + m2[O2 >> 28 & 15] + m2[O2 >> 24 & 15]; + T2 % u2 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O2 = E2[R2], P2 += m2[O2 >> 4 & 15] + m2[O2 & 15], B2 > 1 && (P2 += m2[O2 >> 12 & 15] + m2[O2 >> 8 & 15]), B2 > 2 && (P2 += m2[O2 >> 20 & 15] + m2[O2 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u2 = this.blockCount, E2 = this.s, _2 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O2; + B2 ? O2 = new ArrayBuffer(_2 + 1 << 2) : O2 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O2); T2 < _2; ) { + for (R2 = 0; R2 < u2 && T2 < _2; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u2 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O2 = O2.slice(0, P2)), O2; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u2 = this.blockCount, E2 = this.s, _2 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O2, Ct2; T2 < _2; ) { + for (R2 = 0; R2 < u2 && T2 < _2; ++R2, ++T2) + O2 = T2 << 2, Ct2 = E2[R2], P2[O2] = Ct2 & 255, P2[O2 + 1] = Ct2 >> 8 & 255, P2[O2 + 2] = Ct2 >> 16 & 255, P2[O2 + 3] = Ct2 >> 24 & 255; + T2 % u2 === 0 && k2(E2); + } + return B2 && (O2 = T2 << 2, Ct2 = E2[R2], P2[O2] = Ct2 & 255, B2 > 1 && (P2[O2 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O2 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v2(u2, E2, _2) { + s2.call(this, u2, E2, _2); + } + v2.prototype = new s2(), v2.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u2) { + var E2, _2, B2, R2, T2, P2, O2, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te2, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le2, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne2, Ie2; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u2[0] ^ u2[10] ^ u2[20] ^ u2[30] ^ u2[40], T2 = u2[1] ^ u2[11] ^ u2[21] ^ u2[31] ^ u2[41], P2 = u2[2] ^ u2[12] ^ u2[22] ^ u2[32] ^ u2[42], O2 = u2[3] ^ u2[13] ^ u2[23] ^ u2[33] ^ u2[43], Ct2 = u2[4] ^ u2[14] ^ u2[24] ^ u2[34] ^ u2[44], D2 = u2[5] ^ u2[15] ^ u2[25] ^ u2[35] ^ u2[45], q2 = u2[6] ^ u2[16] ^ u2[26] ^ u2[36] ^ u2[46], De2 = u2[7] ^ u2[17] ^ u2[27] ^ u2[37] ^ u2[47], X2 = u2[8] ^ u2[18] ^ u2[28] ^ u2[38] ^ u2[48], Z2 = u2[9] ^ u2[19] ^ u2[29] ^ u2[39] ^ u2[49], E2 = X2 ^ (P2 << 1 | O2 >>> 31), _2 = Z2 ^ (O2 << 1 | P2 >>> 31), u2[0] ^= E2, u2[1] ^= _2, u2[10] ^= E2, u2[11] ^= _2, u2[20] ^= E2, u2[21] ^= _2, u2[30] ^= E2, u2[31] ^= _2, u2[40] ^= E2, u2[41] ^= _2, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _2 = T2 ^ (D2 << 1 | Ct2 >>> 31), u2[2] ^= E2, u2[3] ^= _2, u2[12] ^= E2, u2[13] ^= _2, u2[22] ^= E2, u2[23] ^= _2, u2[32] ^= E2, u2[33] ^= _2, u2[42] ^= E2, u2[43] ^= _2, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _2 = O2 ^ (De2 << 1 | q2 >>> 31), u2[4] ^= E2, u2[5] ^= _2, u2[14] ^= E2, u2[15] ^= _2, u2[24] ^= E2, u2[25] ^= _2, u2[34] ^= E2, u2[35] ^= _2, u2[44] ^= E2, u2[45] ^= _2, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _2 = D2 ^ (Z2 << 1 | X2 >>> 31), u2[6] ^= E2, u2[7] ^= _2, u2[16] ^= E2, u2[17] ^= _2, u2[26] ^= E2, u2[27] ^= _2, u2[36] ^= E2, u2[37] ^= _2, u2[46] ^= E2, u2[47] ^= _2, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _2 = De2 ^ (T2 << 1 | R2 >>> 31), u2[8] ^= E2, u2[9] ^= _2, u2[18] ^= E2, u2[19] ^= _2, u2[28] ^= E2, u2[29] ^= _2, u2[38] ^= E2, u2[39] ^= _2, u2[48] ^= E2, u2[49] ^= _2, Fe2 = u2[0], $2 = u2[1], yt2 = u2[11] << 4 | u2[10] >>> 28, Je2 = u2[10] << 4 | u2[11] >>> 28, at2 = u2[20] << 3 | u2[21] >>> 29, Ke2 = u2[21] << 3 | u2[20] >>> 29, Ee2 = u2[31] << 9 | u2[30] >>> 23, Se2 = u2[30] << 9 | u2[31] >>> 23, gt2 = u2[40] << 18 | u2[41] >>> 14, At2 = u2[41] << 18 | u2[40] >>> 14, lt2 = u2[2] << 1 | u2[3] >>> 31, ze2 = u2[3] << 1 | u2[2] >>> 31, tt2 = u2[13] << 12 | u2[12] >>> 20, Te2 = u2[12] << 12 | u2[13] >>> 20, wt2 = u2[22] << 10 | u2[23] >>> 22, xt2 = u2[23] << 10 | u2[22] >>> 22, ut2 = u2[33] << 13 | u2[32] >>> 19, ht2 = u2[32] << 13 | u2[33] >>> 19, Ne2 = u2[42] << 2 | u2[43] >>> 30, Ie2 = u2[43] << 2 | u2[42] >>> 30, St2 = u2[5] << 30 | u2[4] >>> 2, Nt2 = u2[4] << 30 | u2[5] >>> 2, dt2 = u2[14] << 6 | u2[15] >>> 26, pt2 = u2[15] << 6 | u2[14] >>> 26, et2 = u2[25] << 11 | u2[24] >>> 21, rt2 = u2[24] << 11 | u2[25] >>> 21, Ge2 = u2[34] << 15 | u2[35] >>> 17, Mt2 = u2[35] << 15 | u2[34] >>> 17, He2 = u2[45] << 29 | u2[44] >>> 3, ct2 = u2[44] << 29 | u2[45] >>> 3, ft2 = u2[6] << 28 | u2[7] >>> 4, ot2 = u2[7] << 28 | u2[6] >>> 4, Ve2 = u2[17] << 23 | u2[16] >>> 9, It2 = u2[16] << 23 | u2[17] >>> 9, Le2 = u2[26] << 25 | u2[27] >>> 7, vt2 = u2[27] << 25 | u2[26] >>> 7, Ue2 = u2[36] << 21 | u2[37] >>> 11, it2 = u2[37] << 21 | u2[36] >>> 11, Et2 = u2[47] << 24 | u2[46] >>> 8, Ye2 = u2[46] << 24 | u2[47] >>> 8, Qe2 = u2[8] << 27 | u2[9] >>> 5, bt2 = u2[9] << 27 | u2[8] >>> 5, qe2 = u2[18] << 20 | u2[19] >>> 12, st2 = u2[19] << 20 | u2[18] >>> 12, _t2 = u2[29] << 7 | u2[28] >>> 25, Me2 = u2[28] << 7 | u2[29] >>> 25, mt2 = u2[38] << 8 | u2[39] >>> 24, je2 = u2[39] << 8 | u2[38] >>> 24, nt2 = u2[48] << 14 | u2[49] >>> 18, ke2 = u2[49] << 14 | u2[48] >>> 18, u2[0] = Fe2 ^ ~tt2 & et2, u2[1] = $2 ^ ~Te2 & rt2, u2[10] = ft2 ^ ~qe2 & at2, u2[11] = ot2 ^ ~st2 & Ke2, u2[20] = lt2 ^ ~dt2 & Le2, u2[21] = ze2 ^ ~pt2 & vt2, u2[30] = Qe2 ^ ~yt2 & wt2, u2[31] = bt2 ^ ~Je2 & xt2, u2[40] = St2 ^ ~Ve2 & _t2, u2[41] = Nt2 ^ ~It2 & Me2, u2[2] = tt2 ^ ~et2 & Ue2, u2[3] = Te2 ^ ~rt2 & it2, u2[12] = qe2 ^ ~at2 & ut2, u2[13] = st2 ^ ~Ke2 & ht2, u2[22] = dt2 ^ ~Le2 & mt2, u2[23] = pt2 ^ ~vt2 & je2, u2[32] = yt2 ^ ~wt2 & Ge2, u2[33] = Je2 ^ ~xt2 & Mt2, u2[42] = Ve2 ^ ~_t2 & Ee2, u2[43] = It2 ^ ~Me2 & Se2, u2[4] = et2 ^ ~Ue2 & nt2, u2[5] = rt2 ^ ~it2 & ke2, u2[14] = at2 ^ ~ut2 & He2, u2[15] = Ke2 ^ ~ht2 & ct2, u2[24] = Le2 ^ ~mt2 & gt2, u2[25] = vt2 ^ ~je2 & At2, u2[34] = wt2 ^ ~Ge2 & Et2, u2[35] = xt2 ^ ~Mt2 & Ye2, u2[44] = _t2 ^ ~Ee2 & Ne2, u2[45] = Me2 ^ ~Se2 & Ie2, u2[6] = Ue2 ^ ~nt2 & Fe2, u2[7] = it2 ^ ~ke2 & $2, u2[16] = ut2 ^ ~He2 & ft2, u2[17] = ht2 ^ ~ct2 & ot2, u2[26] = mt2 ^ ~gt2 & lt2, u2[27] = je2 ^ ~At2 & ze2, u2[36] = Ge2 ^ ~Et2 & Qe2, u2[37] = Mt2 ^ ~Ye2 & bt2, u2[46] = Ee2 ^ ~Ne2 & St2, u2[47] = Se2 ^ ~Ie2 & Nt2, u2[8] = nt2 ^ ~Fe2 & tt2, u2[9] = ke2 ^ ~$2 & Te2, u2[18] = He2 ^ ~ft2 & qe2, u2[19] = ct2 ^ ~ot2 & st2, u2[28] = gt2 ^ ~lt2 & dt2, u2[29] = At2 ^ ~ze2 & pt2, u2[38] = Et2 ^ ~Qe2 & yt2, u2[39] = Ye2 ^ ~bt2 & Je2, u2[48] = Ne2 ^ ~St2 & Ve2, u2[49] = Ie2 ^ ~Nt2 & It2, u2[0] ^= C2[B2], u2[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f2; + else + for (c2 = 0; c2 < a2.length; ++c2) + n2[a2[c2]] = f2[a2[c2]]; + })(); + })(Pn$1); + var b0 = Pn$1.exports; + const y0$1 = "logger/5.7.0"; + let Dn$1 = false, Fn$1 = false; + const Cr$2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; + let Tn$1 = Cr$2.default, gi$1 = null; + function w0$1() { try { - doc = window_getters_1.getDocumentOrThrow(); - loc = window_getters_1.getLocationOrThrow(); + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); } catch (e2) { - return null; + return e2.message; } - function getIcons() { - const links = doc.getElementsByTagName("link"); - const icons2 = []; - for (let i2 = 0; i2 < links.length; i2++) { - const link = links[i2]; - const rel = link.getAttribute("rel"); - if (rel) { - if (rel.toLowerCase().indexOf("icon") > -1) { - const href = link.getAttribute("href"); - if (href) { - if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { - let absoluteHref = loc.protocol + "//" + loc.host; - if (href.indexOf("/") === 0) { - absoluteHref += href; - } else { - const path = loc.pathname.split("/"); - path.pop(); - const finalPath = path.join("/"); - absoluteHref += finalPath + "/" + href; - } - icons2.push(absoluteHref); - } else if (href.indexOf("//") === 0) { - const absoluteUrl = loc.protocol + href; - icons2.push(absoluteUrl); - } else { - icons2.push(href); - } - } + return null; + } + const Un$1 = w0$1(); + var Ai$1; + (function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; + })(Ai$1 || (Ai$1 = {})); + var re$3; + (function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; + })(re$3 || (re$3 = {})); + const kn$1 = "0123456789abcdef"; + let L$5 = class L2 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); + } + _log(t2, r2) { + const i2 = t2.toLowerCase(); + Cr$2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn$1 > Cr$2[i2]) && console.log.apply(console, r2); + } + debug(...t2) { + this._log(L2.levels.DEBUG, t2); + } + info(...t2) { + this._log(L2.levels.INFO, t2); + } + warn(...t2) { + this._log(L2.levels.WARNING, t2); + } + makeError(t2, r2, i2) { + if (Fn$1) + return this.makeError("censored error", r2, {}); + r2 || (r2 = L2.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n2 = []; + Object.keys(i2).forEach((b2) => { + const m2 = i2[b2]; + try { + if (m2 instanceof Uint8Array) { + let w2 = ""; + for (let y2 = 0; y2 < m2.length; y2++) + w2 += kn$1[m2[y2] >> 4], w2 += kn$1[m2[y2] & 15]; + n2.push(b2 + "=Uint8Array(0x" + w2 + ")"); + } else + n2.push(b2 + "=" + JSON.stringify(m2)); + } catch { + n2.push(b2 + "=" + JSON.stringify(i2[b2].toString())); + } + }), n2.push(`code=${r2}`), n2.push(`version=${this.version}`); + const o2 = t2; + let h2 = ""; + switch (r2) { + case re$3.NUMERIC_FAULT: { + h2 = "NUMERIC_FAULT"; + const b2 = t2; + switch (b2) { + case "overflow": + case "underflow": + case "division-by-zero": + h2 += "-" + b2; + break; + case "negative-power": + case "negative-width": + h2 += "-unsupported"; + break; + case "unbound-bitwise-result": + h2 += "-unbound-result"; + break; } + break; } + case re$3.CALL_EXCEPTION: + case re$3.INSUFFICIENT_FUNDS: + case re$3.MISSING_NEW: + case re$3.NONCE_EXPIRED: + case re$3.REPLACEMENT_UNDERPRICED: + case re$3.TRANSACTION_REPLACED: + case re$3.UNPREDICTABLE_GAS_LIMIT: + h2 = r2; + break; } - return icons2; + h2 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h2 + " ]"), n2.length && (t2 += " (" + n2.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r2, Object.keys(i2).forEach(function(b2) { + p2[b2] = i2[b2]; + }), p2; } - function getWindowMetadataOfAny(...args) { - const metaTags = doc.getElementsByTagName("meta"); - for (let i2 = 0; i2 < metaTags.length; i2++) { - const tag = metaTags[i2]; - const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { - if (attr) { - return args.includes(attr); - } - return false; - }); - if (attributes.length && attributes) { - const content = tag.getAttribute("content"); - if (content) { - return content; - } - } + throwError(t2, r2, i2) { + throw this.makeError(t2, r2, i2); + } + throwArgumentError(t2, r2, i2) { + return this.throwError(t2, L2.errors.INVALID_ARGUMENT, { argument: r2, value: i2 }); + } + assert(t2, r2, i2, n2) { + t2 || this.throwError(r2, i2, n2); + } + assertArgument(t2, r2, i2, n2) { + t2 || this.throwArgumentError(r2, i2, n2); + } + checkNormalize(t2) { + Un$1 && this.throwError("platform missing String.prototype.normalize", L2.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un$1 }); + } + checkSafeUint53(t2, r2) { + typeof t2 == "number" && (r2 == null && (r2 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r2, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r2, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); + } + checkArgumentCount(t2, r2, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r2 && this.throwError("missing argument" + i2, L2.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r2 }), t2 > r2 && this.throwError("too many arguments" + i2, L2.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r2 }); + } + checkNew(t2, r2) { + (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r2.name }); + } + checkAbstract(t2, r2) { + t2 === r2 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r2.name) + " directly; use a sub-class", L2.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r2.name }); + } + static globalLogger() { + return gi$1 || (gi$1 = new L2(y0$1)), gi$1; + } + static setCensorship(t2, r2) { + if (!t2 && r2 && this.globalLogger().throwError("cannot permanently disable censorship", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn$1) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } - return ""; + Fn$1 = !!t2, Dn$1 = !!r2; } - function getName() { - let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); - if (!name3) { - name3 = doc.title; + static setLogLevel(t2) { + const r2 = Cr$2[t2.toLowerCase()]; + if (r2 == null) { + L2.globalLogger().warn("invalid log level - " + t2); + return; } - return name3; + Tn$1 = r2; } - function getDescription() { - const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); - return description3; + static from(t2) { + return new L2(t2); } - const name2 = getName(); - const description2 = getDescription(); - const url = loc.origin; - const icons = getIcons(); - const meta = { - description: description2, - url, - icons, - name: name2 - }; - return meta; + }; + L$5.errors = re$3, L$5.levels = Ai$1; + const x0$1 = "bytes/5.7.0", Dt$3 = new L$5(x0$1); + function qn$1(e2) { + return !!e2.toHexString; } - getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; - var queryString = {}; - var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); - var token = "%[a-f0-9]{2}"; - var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); - var multiMatcher = new RegExp("(" + token + ")+", "gi"); - function decodeComponents(components, split) { - try { - return [decodeURIComponent(components.join(""))]; - } catch (err) { - } - if (components.length === 1) { - return components; + function rr$3(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr$3(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; + } + function M0(e2) { + return Qt$2(e2) && !(e2.length % 2) || ir$3(e2); + } + function Kn$1(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; + } + function ir$3(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn$1(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r2 = e2[t2]; + if (!Kn$1(r2) || r2 < 0 || r2 >= 256) + return false; } - split = split || 1; - var left = components.slice(0, split); - var right = components.slice(split); - return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); + return true; } - function decode(input) { - try { - return decodeURIComponent(input); - } catch (err) { - var tokens = input.match(singleMatcher) || []; - for (var i2 = 1; i2 < tokens.length; i2++) { - input = decodeComponents(tokens, i2).join(""); - tokens = input.match(singleMatcher) || []; + function Ot$3(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$3.checkSafeUint53(e2, "invalid arrayify value"); + const r2 = []; + for (; e2; ) + r2.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r2.length === 0 && r2.push(0), rr$3(new Uint8Array(r2)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2) && (e2 = e2.toHexString()), Qt$2(e2)) { + let r2 = e2.substring(2); + r2.length % 2 && (t2.hexPad === "left" ? r2 = "0" + r2 : t2.hexPad === "right" ? r2 += "0" : Dt$3.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n2 = 0; n2 < r2.length; n2 += 2) + i2.push(parseInt(r2.substring(n2, n2 + 2), 16)); + return rr$3(new Uint8Array(i2)); + } + return ir$3(e2) ? rr$3(new Uint8Array(e2)) : Dt$3.throwArgumentError("invalid arrayify value", "value", e2); + } + function E0(e2) { + const t2 = e2.map((n2) => Ot$3(n2)), r2 = t2.reduce((n2, o2) => n2 + o2.length, 0), i2 = new Uint8Array(r2); + return t2.reduce((n2, o2) => (i2.set(o2, n2), n2 + o2.length), 0), rr$3(i2); + } + function S0(e2, t2) { + e2 = Ot$3(e2), e2.length > t2 && Dt$3.throwArgumentError("value out of range", "value", arguments[0]); + const r2 = new Uint8Array(t2); + return r2.set(e2, t2 - e2.length), rr$3(r2); + } + function Qt$2(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2 && e2.length !== 2 + 2 * t2); + } + const bi$1 = "0123456789abcdef"; + function Kt$3(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$3.checkSafeUint53(e2, "invalid hexlify value"); + let r2 = ""; + for (; e2; ) + r2 = bi$1[e2 & 15] + r2, e2 = Math.floor(e2 / 16); + return r2.length ? (r2.length % 2 && (r2 = "0" + r2), "0x" + r2) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2)) + return e2.toHexString(); + if (Qt$2(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt$3.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir$3(e2)) { + let r2 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n2 = e2[i2]; + r2 += bi$1[(n2 & 240) >> 4] + bi$1[n2 & 15]; } - return input; + return r2; } + return Dt$3.throwArgumentError("invalid hexlify value", "value", e2); } - function customDecodeURIComponent(input) { - var replaceMap = { - "%FE%FF": "��", - "%FF%FE": "��" - }; - var match = multiMatcher.exec(input); - while (match) { + function N0(e2) { + if (typeof e2 != "string") + e2 = Kt$3(e2); + else if (!Qt$2(e2) || e2.length % 2) + return null; + return (e2.length - 2) / 2; + } + function Hn(e2, t2, r2) { + return typeof e2 != "string" ? e2 = Kt$3(e2) : (!Qt$2(e2) || e2.length % 2) && Dt$3.throwArgumentError("invalid hexData", "value", e2), t2 = 2 + 2 * t2, r2 != null ? "0x" + e2.substring(t2, 2 + 2 * r2) : "0x" + e2.substring(t2); + } + function oe$1(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt$3(e2) : Qt$2(e2) || Dt$3.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt$3.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; + } + function zn(e2) { + const t2 = { r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0, yParityAndS: "0x", compact: "0x" }; + if (M0(e2)) { + let r2 = Ot$3(e2); + r2.length === 64 ? (t2.v = 27 + (r2[32] >> 7), r2[32] &= 127, t2.r = Kt$3(r2.slice(0, 32)), t2.s = Kt$3(r2.slice(32, 64))) : r2.length === 65 ? (t2.r = Kt$3(r2.slice(0, 32)), t2.s = Kt$3(r2.slice(32, 64)), t2.v = r2[64]) : Dt$3.throwArgumentError("invalid signature string", "signature", e2), t2.v < 27 && (t2.v === 0 || t2.v === 1 ? t2.v += 27 : Dt$3.throwArgumentError("signature invalid v byte", "signature", e2)), t2.recoveryParam = 1 - t2.v % 2, t2.recoveryParam && (r2[32] |= 128), t2._vs = Kt$3(r2.slice(32, 64)); + } else { + if (t2.r = e2.r, t2.s = e2.s, t2.v = e2.v, t2.recoveryParam = e2.recoveryParam, t2._vs = e2._vs, t2._vs != null) { + const n2 = S0(Ot$3(t2._vs), 32); + t2._vs = Kt$3(n2); + const o2 = n2[0] >= 128 ? 1 : 0; + t2.recoveryParam == null ? t2.recoveryParam = o2 : t2.recoveryParam !== o2 && Dt$3.throwArgumentError("signature recoveryParam mismatch _vs", "signature", e2), n2[0] &= 127; + const h2 = Kt$3(n2); + t2.s == null ? t2.s = h2 : t2.s !== h2 && Dt$3.throwArgumentError("signature v mismatch _vs", "signature", e2); + } + if (t2.recoveryParam == null) + t2.v == null ? Dt$3.throwArgumentError("signature missing v and recoveryParam", "signature", e2) : t2.v === 0 || t2.v === 1 ? t2.recoveryParam = t2.v : t2.recoveryParam = 1 - t2.v % 2; + else if (t2.v == null) + t2.v = 27 + t2.recoveryParam; + else { + const n2 = t2.v === 0 || t2.v === 1 ? t2.v : 1 - t2.v % 2; + t2.recoveryParam !== n2 && Dt$3.throwArgumentError("signature recoveryParam mismatch v", "signature", e2); + } + t2.r == null || !Qt$2(t2.r) ? Dt$3.throwArgumentError("signature missing or invalid r", "signature", e2) : t2.r = oe$1(t2.r, 32), t2.s == null || !Qt$2(t2.s) ? Dt$3.throwArgumentError("signature missing or invalid s", "signature", e2) : t2.s = oe$1(t2.s, 32); + const r2 = Ot$3(t2.s); + r2[0] >= 128 && Dt$3.throwArgumentError("signature s out of range", "signature", e2), t2.recoveryParam && (r2[0] |= 128); + const i2 = Kt$3(r2); + t2._vs && (Qt$2(t2._vs) || Dt$3.throwArgumentError("signature invalid _vs", "signature", e2), t2._vs = oe$1(t2._vs, 32)), t2._vs == null ? t2._vs = i2 : t2._vs !== i2 && Dt$3.throwArgumentError("signature _vs mismatch v and s", "signature", e2); + } + return t2.yParityAndS = t2._vs, t2.compact = t2.r + t2.yParityAndS.substring(2), t2; + } + function yi(e2) { + return "0x" + b0.keccak_256(Ot$3(e2)); + } + var Ln$1 = { exports: {} }, I0$1 = {}, _0$1 = Object.freeze({ __proto__: null, default: I0$1 }), B0$1 = A0$1(_0$1); + (function(e2) { + (function(t2, r2) { + function i2(A2, f2) { + if (!A2) + throw new Error(f2 || "Assertion failed"); + } + function n2(A2, f2) { + A2.super_ = f2; + var a2 = function() { + }; + a2.prototype = f2.prototype, A2.prototype = new a2(), A2.prototype.constructor = A2; + } + function o2(A2, f2, a2) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f2 === "le" || f2 === "be") && (a2 = f2, f2 = 10), this._init(A2 || 0, f2 || 10, a2 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r2.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h2; try { - replaceMap[match[0]] = decodeURIComponent(match[0]); - } catch (err) { - var result = decode(match[0]); - if (result !== match[0]) { - replaceMap[match[0]] = result; + typeof window < "u" && typeof window.Buffer < "u" ? h2 = window.Buffer : h2 = B0$1.Buffer; + } catch { + } + o2.isBN = function(f2) { + return f2 instanceof o2 ? true : f2 !== null && typeof f2 == "object" && f2.constructor.wordSize === o2.wordSize && Array.isArray(f2.words); + }, o2.max = function(f2, a2) { + return f2.cmp(a2) > 0 ? f2 : a2; + }, o2.min = function(f2, a2) { + return f2.cmp(a2) < 0 ? f2 : a2; + }, o2.prototype._init = function(f2, a2, c2) { + if (typeof f2 == "number") + return this._initNumber(f2, a2, c2); + if (typeof f2 == "object") + return this._initArray(f2, a2, c2); + a2 === "hex" && (a2 = 16), i2(a2 === (a2 | 0) && a2 >= 2 && a2 <= 36), f2 = f2.toString().replace(/\s+/g, ""); + var d2 = 0; + f2[0] === "-" && (d2++, this.negative = 1), d2 < f2.length && (a2 === 16 ? this._parseHex(f2, d2, c2) : (this._parseBase(f2, a2, d2), c2 === "le" && this._initArray(this.toArray(), a2, c2))); + }, o2.prototype._initNumber = function(f2, a2, c2) { + f2 < 0 && (this.negative = 1, f2 = -f2), f2 < 67108864 ? (this.words = [f2 & 67108863], this.length = 1) : f2 < 4503599627370496 ? (this.words = [f2 & 67108863, f2 / 67108864 & 67108863], this.length = 2) : (i2(f2 < 9007199254740992), this.words = [f2 & 67108863, f2 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a2, c2); + }, o2.prototype._initArray = function(f2, a2, c2) { + if (i2(typeof f2.length == "number"), f2.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f2.length / 3), this.words = new Array(this.length); + for (var d2 = 0; d2 < this.length; d2++) + this.words[d2] = 0; + var g2, x2, M2 = 0; + if (c2 === "be") + for (d2 = f2.length - 1, g2 = 0; d2 >= 0; d2 -= 3) + x2 = f2[d2] | f2[d2 - 1] << 8 | f2[d2 - 2] << 16, this.words[g2] |= x2 << M2 & 67108863, this.words[g2 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g2++); + else if (c2 === "le") + for (d2 = 0, g2 = 0; d2 < f2.length; d2 += 3) + x2 = f2[d2] | f2[d2 + 1] << 8 | f2[d2 + 2] << 16, this.words[g2] |= x2 << M2 & 67108863, this.words[g2 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g2++); + return this._strip(); + }; + function p2(A2, f2) { + var a2 = A2.charCodeAt(f2); + if (a2 >= 48 && a2 <= 57) + return a2 - 48; + if (a2 >= 65 && a2 <= 70) + return a2 - 55; + if (a2 >= 97 && a2 <= 102) + return a2 - 87; + i2(false, "Invalid character in " + A2); + } + function b2(A2, f2, a2) { + var c2 = p2(A2, a2); + return a2 - 1 >= f2 && (c2 |= p2(A2, a2 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f2, a2, c2) { + this.length = Math.ceil((f2.length - a2) / 6), this.words = new Array(this.length); + for (var d2 = 0; d2 < this.length; d2++) + this.words[d2] = 0; + var g2 = 0, x2 = 0, M2; + if (c2 === "be") + for (d2 = f2.length - 1; d2 >= a2; d2 -= 2) + M2 = b2(f2, a2, d2) << g2, this.words[x2] |= M2 & 67108863, g2 >= 18 ? (g2 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g2 += 8; + else { + var l2 = f2.length - a2; + for (d2 = l2 % 2 === 0 ? a2 + 1 : a2; d2 < f2.length; d2 += 2) + M2 = b2(f2, a2, d2) << g2, this.words[x2] |= M2 & 67108863, g2 >= 18 ? (g2 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g2 += 8; + } + this._strip(); + }; + function m2(A2, f2, a2, c2) { + for (var d2 = 0, g2 = 0, x2 = Math.min(A2.length, a2), M2 = f2; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d2 *= c2, l2 >= 49 ? g2 = l2 - 49 + 10 : l2 >= 17 ? g2 = l2 - 17 + 10 : g2 = l2, i2(l2 >= 0 && g2 < c2, "Invalid character"), d2 += g2; + } + return d2; + } + o2.prototype._parseBase = function(f2, a2, c2) { + this.words = [0], this.length = 1; + for (var d2 = 0, g2 = 1; g2 <= 67108863; g2 *= a2) + d2++; + d2--, g2 = g2 / a2 | 0; + for (var x2 = f2.length - c2, M2 = x2 % d2, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v2 = c2; v2 < l2; v2 += d2) + s2 = m2(f2, v2, v2 + d2, a2), this.imuln(g2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m2(f2, v2, f2.length, a2), v2 = 0; v2 < M2; v2++) + k2 *= a2; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f2) { + f2.words = new Array(this.length); + for (var a2 = 0; a2 < this.length; a2++) + f2.words[a2] = this.words[a2]; + f2.length = this.length, f2.negative = this.negative, f2.red = this.red; + }; + function w2(A2, f2) { + A2.words = f2.words, A2.length = f2.length, A2.negative = f2.negative, A2.red = f2.red; + } + if (o2.prototype._move = function(f2) { + w2(f2, this); + }, o2.prototype.clone = function() { + var f2 = new o2(null); + return this.copy(f2), f2; + }, o2.prototype._expand = function(f2) { + for (; this.length < f2; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y2; + } catch { + o2.prototype.inspect = y2; + } + else + o2.prototype.inspect = y2; + function y2() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f2, a2) { + f2 = f2 || 10, a2 = a2 | 0 || 1; + var c2; + if (f2 === 16 || f2 === "hex") { + c2 = ""; + for (var d2 = 0, g2 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d2 | g2) & 16777215).toString(16); + g2 = M2 >>> 24 - d2 & 16777215, d2 += 2, d2 >= 26 && (d2 -= 26, x2--), g2 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g2 !== 0 && (c2 = g2.toString(16) + c2); c2.length % a2 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f2 === (f2 | 0) && f2 >= 2 && f2 <= 36) { + var s2 = I2[f2], v2 = N2[f2]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u2 = k2.modrn(v2).toString(f2); + k2 = k2.idivn(v2), k2.isZero() ? c2 = u2 + c2 : c2 = S2[s2 - u2.length] + u2 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a2 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f2 = this.words[0]; + return this.length === 2 ? f2 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f2 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f2 : f2; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h2 && (o2.prototype.toBuffer = function(f2, a2) { + return this.toArrayLike(h2, f2, a2); + }), o2.prototype.toArray = function(f2, a2) { + return this.toArrayLike(Array, f2, a2); + }; + var C2 = function(f2, a2) { + return f2.allocUnsafe ? f2.allocUnsafe(a2) : new f2(a2); + }; + o2.prototype.toArrayLike = function(f2, a2, c2) { + this._strip(); + var d2 = this.byteLength(), g2 = c2 || Math.max(1, d2); + i2(d2 <= g2, "byte array longer than desired length"), i2(g2 > 0, "Requested array length <= 0"); + var x2 = C2(f2, g2), M2 = a2 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d2), x2; + }, o2.prototype._toArrayLikeLE = function(f2, a2) { + for (var c2 = 0, d2 = 0, g2 = 0, x2 = 0; g2 < this.length; g2++) { + var M2 = this.words[g2] << x2 | d2; + f2[c2++] = M2 & 255, c2 < f2.length && (f2[c2++] = M2 >> 8 & 255), c2 < f2.length && (f2[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f2.length && (f2[c2++] = M2 >> 24 & 255), d2 = 0, x2 = 0) : (d2 = M2 >>> 24, x2 += 2); + } + if (c2 < f2.length) + for (f2[c2++] = d2; c2 < f2.length; ) + f2[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f2, a2) { + for (var c2 = f2.length - 1, d2 = 0, g2 = 0, x2 = 0; g2 < this.length; g2++) { + var M2 = this.words[g2] << x2 | d2; + f2[c2--] = M2 & 255, c2 >= 0 && (f2[c2--] = M2 >> 8 & 255), c2 >= 0 && (f2[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f2[c2--] = M2 >> 24 & 255), d2 = 0, x2 = 0) : (d2 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f2[c2--] = d2; c2 >= 0; ) + f2[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f2) { + return 32 - Math.clz32(f2); + } : o2.prototype._countBits = function(f2) { + var a2 = f2, c2 = 0; + return a2 >= 4096 && (c2 += 13, a2 >>>= 13), a2 >= 64 && (c2 += 7, a2 >>>= 7), a2 >= 8 && (c2 += 4, a2 >>>= 4), a2 >= 2 && (c2 += 2, a2 >>>= 2), c2 + a2; + }, o2.prototype._zeroBits = function(f2) { + if (f2 === 0) + return 26; + var a2 = f2, c2 = 0; + return a2 & 8191 || (c2 += 13, a2 >>>= 13), a2 & 127 || (c2 += 7, a2 >>>= 7), a2 & 15 || (c2 += 4, a2 >>>= 4), a2 & 3 || (c2 += 2, a2 >>>= 2), a2 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f2 = this.words[this.length - 1], a2 = this._countBits(f2); + return (this.length - 1) * 26 + a2; + }; + function F2(A2) { + for (var f2 = new Array(A2.bitLength()), a2 = 0; a2 < f2.length; a2++) { + var c2 = a2 / 26 | 0, d2 = a2 % 26; + f2[a2] = A2.words[c2] >>> d2 & 1; } + return f2; } - match = multiMatcher.exec(input); + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f2 = 0, a2 = 0; a2 < this.length; a2++) { + var c2 = this._zeroBits(this.words[a2]); + if (f2 += c2, c2 !== 26) + break; + } + return f2; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f2) { + return this.negative !== 0 ? this.abs().inotn(f2).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f2) { + return this.testn(f2 - 1) ? this.notn(f2).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f2) { + for (; this.length < f2.length; ) + this.words[this.length++] = 0; + for (var a2 = 0; a2 < f2.length; a2++) + this.words[a2] = this.words[a2] | f2.words[a2]; + return this._strip(); + }, o2.prototype.ior = function(f2) { + return i2((this.negative | f2.negative) === 0), this.iuor(f2); + }, o2.prototype.or = function(f2) { + return this.length > f2.length ? this.clone().ior(f2) : f2.clone().ior(this); + }, o2.prototype.uor = function(f2) { + return this.length > f2.length ? this.clone().iuor(f2) : f2.clone().iuor(this); + }, o2.prototype.iuand = function(f2) { + var a2; + this.length > f2.length ? a2 = f2 : a2 = this; + for (var c2 = 0; c2 < a2.length; c2++) + this.words[c2] = this.words[c2] & f2.words[c2]; + return this.length = a2.length, this._strip(); + }, o2.prototype.iand = function(f2) { + return i2((this.negative | f2.negative) === 0), this.iuand(f2); + }, o2.prototype.and = function(f2) { + return this.length > f2.length ? this.clone().iand(f2) : f2.clone().iand(this); + }, o2.prototype.uand = function(f2) { + return this.length > f2.length ? this.clone().iuand(f2) : f2.clone().iuand(this); + }, o2.prototype.iuxor = function(f2) { + var a2, c2; + this.length > f2.length ? (a2 = this, c2 = f2) : (a2 = f2, c2 = this); + for (var d2 = 0; d2 < c2.length; d2++) + this.words[d2] = a2.words[d2] ^ c2.words[d2]; + if (this !== a2) + for (; d2 < a2.length; d2++) + this.words[d2] = a2.words[d2]; + return this.length = a2.length, this._strip(); + }, o2.prototype.ixor = function(f2) { + return i2((this.negative | f2.negative) === 0), this.iuxor(f2); + }, o2.prototype.xor = function(f2) { + return this.length > f2.length ? this.clone().ixor(f2) : f2.clone().ixor(this); + }, o2.prototype.uxor = function(f2) { + return this.length > f2.length ? this.clone().iuxor(f2) : f2.clone().iuxor(this); + }, o2.prototype.inotn = function(f2) { + i2(typeof f2 == "number" && f2 >= 0); + var a2 = Math.ceil(f2 / 26) | 0, c2 = f2 % 26; + this._expand(a2), c2 > 0 && a2--; + for (var d2 = 0; d2 < a2; d2++) + this.words[d2] = ~this.words[d2] & 67108863; + return c2 > 0 && (this.words[d2] = ~this.words[d2] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f2) { + return this.clone().inotn(f2); + }, o2.prototype.setn = function(f2, a2) { + i2(typeof f2 == "number" && f2 >= 0); + var c2 = f2 / 26 | 0, d2 = f2 % 26; + return this._expand(c2 + 1), a2 ? this.words[c2] = this.words[c2] | 1 << d2 : this.words[c2] = this.words[c2] & ~(1 << d2), this._strip(); + }, o2.prototype.iadd = function(f2) { + var a2; + if (this.negative !== 0 && f2.negative === 0) + return this.negative = 0, a2 = this.isub(f2), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f2.negative !== 0) + return f2.negative = 0, a2 = this.isub(f2), f2.negative = 1, a2._normSign(); + var c2, d2; + this.length > f2.length ? (c2 = this, d2 = f2) : (c2 = f2, d2 = this); + for (var g2 = 0, x2 = 0; x2 < d2.length; x2++) + a2 = (c2.words[x2] | 0) + (d2.words[x2] | 0) + g2, this.words[x2] = a2 & 67108863, g2 = a2 >>> 26; + for (; g2 !== 0 && x2 < c2.length; x2++) + a2 = (c2.words[x2] | 0) + g2, this.words[x2] = a2 & 67108863, g2 = a2 >>> 26; + if (this.length = c2.length, g2 !== 0) + this.words[this.length] = g2, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f2) { + var a2; + return f2.negative !== 0 && this.negative === 0 ? (f2.negative = 0, a2 = this.sub(f2), f2.negative ^= 1, a2) : f2.negative === 0 && this.negative !== 0 ? (this.negative = 0, a2 = f2.sub(this), this.negative = 1, a2) : this.length > f2.length ? this.clone().iadd(f2) : f2.clone().iadd(this); + }, o2.prototype.isub = function(f2) { + if (f2.negative !== 0) { + f2.negative = 0; + var a2 = this.iadd(f2); + return f2.negative = 1, a2._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f2), this.negative = 1, this._normSign(); + var c2 = this.cmp(f2); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d2, g2; + c2 > 0 ? (d2 = this, g2 = f2) : (d2 = f2, g2 = this); + for (var x2 = 0, M2 = 0; M2 < g2.length; M2++) + a2 = (d2.words[M2] | 0) - (g2.words[M2] | 0) + x2, x2 = a2 >> 26, this.words[M2] = a2 & 67108863; + for (; x2 !== 0 && M2 < d2.length; M2++) + a2 = (d2.words[M2] | 0) + x2, x2 = a2 >> 26, this.words[M2] = a2 & 67108863; + if (x2 === 0 && M2 < d2.length && d2 !== this) + for (; M2 < d2.length; M2++) + this.words[M2] = d2.words[M2]; + return this.length = Math.max(this.length, M2), d2 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f2) { + return this.clone().isub(f2); + }; + function U2(A2, f2, a2) { + a2.negative = f2.negative ^ A2.negative; + var c2 = A2.length + f2.length | 0; + a2.length = c2, c2 = c2 - 1 | 0; + var d2 = A2.words[0] | 0, g2 = f2.words[0] | 0, x2 = d2 * g2, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a2.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v2 = l2 >>> 26, k2 = l2 & 67108863, u2 = Math.min(s2, f2.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u2; E2++) { + var _2 = s2 - E2 | 0; + d2 = A2.words[_2] | 0, g2 = f2.words[E2] | 0, x2 = d2 * g2 + k2, v2 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a2.words[s2] = k2 | 0, l2 = v2 | 0; + } + return l2 !== 0 ? a2.words[s2] = l2 | 0 : a2.length--, a2._strip(); + } + var J2 = function(f2, a2, c2) { + var d2 = f2.words, g2 = a2.words, x2 = c2.words, M2 = 0, l2, s2, v2, k2 = d2[0] | 0, u2 = k2 & 8191, E2 = k2 >>> 13, _2 = d2[1] | 0, B2 = _2 & 8191, R2 = _2 >>> 13, T2 = d2[2] | 0, P2 = T2 & 8191, O2 = T2 >>> 13, Ct2 = d2[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d2[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d2[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te2 = d2[6] | 0, et2 = Te2 & 8191, rt2 = Te2 >>> 13, Ue2 = d2[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d2[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d2[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g2[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g2[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g2[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le2 = g2[3] | 0, vt2 = Le2 & 8191, mt2 = Le2 >>> 13, je2 = g2[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g2[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g2[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g2[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g2[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g2[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f2.negative ^ a2.negative, c2.length = 19, l2 = Math.imul(u2, ut2), s2 = Math.imul(u2, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v2 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v2 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u2, ct2) | 0, s2 = s2 + Math.imul(u2, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v2 = v2 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O2, ut2) | 0, v2 = Math.imul(O2, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v2 = v2 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u2, dt2) | 0, s2 = s2 + Math.imul(u2, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v2 = v2 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v2 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O2, ct2) | 0, v2 = v2 + Math.imul(O2, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v2 = v2 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u2, vt2) | 0, s2 = s2 + Math.imul(u2, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v2 = v2 + Math.imul(E2, mt2) | 0; + var Ne2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Ne2 >>> 26) | 0, Ne2 &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v2 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v2 = v2 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O2, dt2) | 0, v2 = v2 + Math.imul(O2, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v2 = v2 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u2, gt2) | 0, s2 = s2 + Math.imul(u2, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v2 = v2 + Math.imul(E2, At2) | 0; + var Ie2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Ie2 >>> 26) | 0, Ie2 &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v2 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v2 = v2 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v2 = v2 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O2, vt2) | 0, v2 = v2 + Math.imul(O2, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v2 = v2 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u2, bt2) | 0, s2 = s2 + Math.imul(u2, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v2 = v2 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v2 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v2 = v2 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v2 = v2 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v2 = v2 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O2, gt2) | 0, v2 = v2 + Math.imul(O2, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v2 = v2 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u2, wt2) | 0, s2 = s2 + Math.imul(u2, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v2 = v2 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v2 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v2 = v2 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v2 = v2 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v2 = v2 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v2 = v2 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O2, bt2) | 0, v2 = v2 + Math.imul(O2, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v2 = v2 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u2, Mt2) | 0, s2 = s2 + Math.imul(u2, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v2 = v2 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v2 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v2 = v2 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v2 = v2 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v2 = v2 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v2 = v2 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v2 = v2 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O2, wt2) | 0, v2 = v2 + Math.imul(O2, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v2 = v2 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u2, St2) | 0, s2 = s2 + Math.imul(u2, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v2 = v2 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v2 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v2 = v2 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v2 = v2 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v2 = v2 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v2 = v2 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v2 = v2 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v2 = v2 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O2, Mt2) | 0, v2 = v2 + Math.imul(O2, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v2 = v2 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u2, It2) | 0, s2 = s2 + Math.imul(u2, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v2 = v2 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v2 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v2 = v2 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v2 = v2 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v2 = v2 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v2 = v2 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v2 = v2 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v2 = v2 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O2, St2) | 0, v2 = v2 + Math.imul(O2, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v2 = v2 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v2 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v2 = v2 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v2 = v2 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v2 = v2 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v2 = v2 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v2 = v2 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v2 = v2 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O2, It2) | 0, v2 = v2 + Math.imul(O2, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v2 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v2 = v2 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v2 = v2 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v2 = v2 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v2 = v2 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v2 = v2 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v2 = v2 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v2 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v2 = v2 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v2 = v2 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v2 = v2 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v2 = v2 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v2 = v2 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v2 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v2 = v2 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v2 = v2 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v2 = v2 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v2 = v2 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v2 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v2 = v2 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v2 = v2 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v2 = v2 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v2 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v2 = v2 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v2 = v2 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v2 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v2 = v2 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v2 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v2 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne2, x2[4] = Ie2, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f2, a2) { + a2.negative = f2.negative ^ A2.negative, a2.length = A2.length + f2.length; + for (var c2 = 0, d2 = 0, g2 = 0; g2 < a2.length - 1; g2++) { + var x2 = d2; + d2 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g2, f2.length - 1), s2 = Math.max(0, g2 - A2.length + 1); s2 <= l2; s2++) { + var v2 = g2 - s2, k2 = A2.words[v2] | 0, u2 = f2.words[s2] | 0, E2 = k2 * u2, _2 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _2 = _2 + M2 | 0, M2 = _2 & 67108863, x2 = x2 + (_2 >>> 26) | 0, d2 += x2 >>> 26, x2 &= 67108863; + } + a2.words[g2] = M2, c2 = x2, x2 = d2; + } + return c2 !== 0 ? a2.words[g2] = c2 : a2.length--, a2._strip(); + } + function G2(A2, f2, a2) { + return Bt2(A2, f2, a2); + } + o2.prototype.mulTo = function(f2, a2) { + var c2, d2 = this.length + f2.length; + return this.length === 10 && f2.length === 10 ? c2 = J2(this, f2, a2) : d2 < 63 ? c2 = U2(this, f2, a2) : d2 < 1024 ? c2 = Bt2(this, f2, a2) : c2 = G2(this, f2, a2), c2; + }, o2.prototype.mul = function(f2) { + var a2 = new o2(null); + return a2.words = new Array(this.length + f2.length), this.mulTo(f2, a2); + }, o2.prototype.mulf = function(f2) { + var a2 = new o2(null); + return a2.words = new Array(this.length + f2.length), G2(this, f2, a2); + }, o2.prototype.imul = function(f2) { + return this.clone().mulTo(f2, this); + }, o2.prototype.imuln = function(f2) { + var a2 = f2 < 0; + a2 && (f2 = -f2), i2(typeof f2 == "number"), i2(f2 < 67108864); + for (var c2 = 0, d2 = 0; d2 < this.length; d2++) { + var g2 = (this.words[d2] | 0) * f2, x2 = (g2 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g2 / 67108864 | 0, c2 += x2 >>> 26, this.words[d2] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d2] = c2, this.length++), a2 ? this.ineg() : this; + }, o2.prototype.muln = function(f2) { + return this.clone().imuln(f2); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f2) { + var a2 = F2(f2); + if (a2.length === 0) + return new o2(1); + for (var c2 = this, d2 = 0; d2 < a2.length && a2[d2] === 0; d2++, c2 = c2.sqr()) + ; + if (++d2 < a2.length) + for (var g2 = c2.sqr(); d2 < a2.length; d2++, g2 = g2.sqr()) + a2[d2] !== 0 && (c2 = c2.mul(g2)); + return c2; + }, o2.prototype.iushln = function(f2) { + i2(typeof f2 == "number" && f2 >= 0); + var a2 = f2 % 26, c2 = (f2 - a2) / 26, d2 = 67108863 >>> 26 - a2 << 26 - a2, g2; + if (a2 !== 0) { + var x2 = 0; + for (g2 = 0; g2 < this.length; g2++) { + var M2 = this.words[g2] & d2, l2 = (this.words[g2] | 0) - M2 << a2; + this.words[g2] = l2 | x2, x2 = M2 >>> 26 - a2; + } + x2 && (this.words[g2] = x2, this.length++); + } + if (c2 !== 0) { + for (g2 = this.length - 1; g2 >= 0; g2--) + this.words[g2 + c2] = this.words[g2]; + for (g2 = 0; g2 < c2; g2++) + this.words[g2] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f2) { + return i2(this.negative === 0), this.iushln(f2); + }, o2.prototype.iushrn = function(f2, a2, c2) { + i2(typeof f2 == "number" && f2 >= 0); + var d2; + a2 ? d2 = (a2 - a2 % 26) / 26 : d2 = 0; + var g2 = f2 % 26, x2 = Math.min((f2 - g2) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g2 << g2, l2 = c2; + if (d2 -= x2, d2 = Math.max(0, d2), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v2 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v2 !== 0 || s2 >= d2); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v2 << 26 - g2 | k2 >>> g2, v2 = k2 & M2; + } + return l2 && v2 !== 0 && (l2.words[l2.length++] = v2), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f2, a2, c2) { + return i2(this.negative === 0), this.iushrn(f2, a2, c2); + }, o2.prototype.shln = function(f2) { + return this.clone().ishln(f2); + }, o2.prototype.ushln = function(f2) { + return this.clone().iushln(f2); + }, o2.prototype.shrn = function(f2) { + return this.clone().ishrn(f2); + }, o2.prototype.ushrn = function(f2) { + return this.clone().iushrn(f2); + }, o2.prototype.testn = function(f2) { + i2(typeof f2 == "number" && f2 >= 0); + var a2 = f2 % 26, c2 = (f2 - a2) / 26, d2 = 1 << a2; + if (this.length <= c2) + return false; + var g2 = this.words[c2]; + return !!(g2 & d2); + }, o2.prototype.imaskn = function(f2) { + i2(typeof f2 == "number" && f2 >= 0); + var a2 = f2 % 26, c2 = (f2 - a2) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a2 !== 0 && c2++, this.length = Math.min(c2, this.length), a2 !== 0) { + var d2 = 67108863 ^ 67108863 >>> a2 << a2; + this.words[this.length - 1] &= d2; + } + return this._strip(); + }, o2.prototype.maskn = function(f2) { + return this.clone().imaskn(f2); + }, o2.prototype.iaddn = function(f2) { + return i2(typeof f2 == "number"), i2(f2 < 67108864), f2 < 0 ? this.isubn(-f2) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f2 ? (this.words[0] = f2 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f2), this.negative = 1, this) : this._iaddn(f2); + }, o2.prototype._iaddn = function(f2) { + this.words[0] += f2; + for (var a2 = 0; a2 < this.length && this.words[a2] >= 67108864; a2++) + this.words[a2] -= 67108864, a2 === this.length - 1 ? this.words[a2 + 1] = 1 : this.words[a2 + 1]++; + return this.length = Math.max(this.length, a2 + 1), this; + }, o2.prototype.isubn = function(f2) { + if (i2(typeof f2 == "number"), i2(f2 < 67108864), f2 < 0) + return this.iaddn(-f2); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f2), this.negative = 1, this; + if (this.words[0] -= f2, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a2 = 0; a2 < this.length && this.words[a2] < 0; a2++) + this.words[a2] += 67108864, this.words[a2 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f2) { + return this.clone().iaddn(f2); + }, o2.prototype.subn = function(f2) { + return this.clone().isubn(f2); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f2, a2, c2) { + var d2 = f2.length + c2, g2; + this._expand(d2); + var x2, M2 = 0; + for (g2 = 0; g2 < f2.length; g2++) { + x2 = (this.words[g2 + c2] | 0) + M2; + var l2 = (f2.words[g2] | 0) * a2; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g2 + c2] = x2 & 67108863; + } + for (; g2 < this.length - c2; g2++) + x2 = (this.words[g2 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g2 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g2 = 0; g2 < this.length; g2++) + x2 = -(this.words[g2] | 0) + M2, M2 = x2 >> 26, this.words[g2] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f2, a2) { + var c2 = this.length - f2.length, d2 = this.clone(), g2 = f2, x2 = g2.words[g2.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g2 = g2.ushln(c2), d2.iushln(c2), x2 = g2.words[g2.length - 1] | 0); + var l2 = d2.length - g2.length, s2; + if (a2 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v2 = 0; v2 < s2.length; v2++) + s2.words[v2] = 0; + } + var k2 = d2.clone()._ishlnsubmul(g2, 1, l2); + k2.negative === 0 && (d2 = k2, s2 && (s2.words[l2] = 1)); + for (var u2 = l2 - 1; u2 >= 0; u2--) { + var E2 = (d2.words[g2.length + u2] | 0) * 67108864 + (d2.words[g2.length + u2 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d2._ishlnsubmul(g2, E2, u2); d2.negative !== 0; ) + E2--, d2.negative = 0, d2._ishlnsubmul(g2, 1, u2), d2.isZero() || (d2.negative ^= 1); + s2 && (s2.words[u2] = E2); + } + return s2 && s2._strip(), d2._strip(), a2 !== "div" && c2 !== 0 && d2.iushrn(c2), { div: s2 || null, mod: d2 }; + }, o2.prototype.divmod = function(f2, a2, c2) { + if (i2(!f2.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d2, g2, x2; + return this.negative !== 0 && f2.negative === 0 ? (x2 = this.neg().divmod(f2, a2), a2 !== "mod" && (d2 = x2.div.neg()), a2 !== "div" && (g2 = x2.mod.neg(), c2 && g2.negative !== 0 && g2.iadd(f2)), { div: d2, mod: g2 }) : this.negative === 0 && f2.negative !== 0 ? (x2 = this.divmod(f2.neg(), a2), a2 !== "mod" && (d2 = x2.div.neg()), { div: d2, mod: x2.mod }) : this.negative & f2.negative ? (x2 = this.neg().divmod(f2.neg(), a2), a2 !== "div" && (g2 = x2.mod.neg(), c2 && g2.negative !== 0 && g2.isub(f2)), { div: x2.div, mod: g2 }) : f2.length > this.length || this.cmp(f2) < 0 ? { div: new o2(0), mod: this } : f2.length === 1 ? a2 === "div" ? { div: this.divn(f2.words[0]), mod: null } : a2 === "mod" ? { div: null, mod: new o2(this.modrn(f2.words[0])) } : { div: this.divn(f2.words[0]), mod: new o2(this.modrn(f2.words[0])) } : this._wordDiv(f2, a2); + }, o2.prototype.div = function(f2) { + return this.divmod(f2, "div", false).div; + }, o2.prototype.mod = function(f2) { + return this.divmod(f2, "mod", false).mod; + }, o2.prototype.umod = function(f2) { + return this.divmod(f2, "mod", true).mod; + }, o2.prototype.divRound = function(f2) { + var a2 = this.divmod(f2); + if (a2.mod.isZero()) + return a2.div; + var c2 = a2.div.negative !== 0 ? a2.mod.isub(f2) : a2.mod, d2 = f2.ushrn(1), g2 = f2.andln(1), x2 = c2.cmp(d2); + return x2 < 0 || g2 === 1 && x2 === 0 ? a2.div : a2.div.negative !== 0 ? a2.div.isubn(1) : a2.div.iaddn(1); + }, o2.prototype.modrn = function(f2) { + var a2 = f2 < 0; + a2 && (f2 = -f2), i2(f2 <= 67108863); + for (var c2 = (1 << 26) % f2, d2 = 0, g2 = this.length - 1; g2 >= 0; g2--) + d2 = (c2 * d2 + (this.words[g2] | 0)) % f2; + return a2 ? -d2 : d2; + }, o2.prototype.modn = function(f2) { + return this.modrn(f2); + }, o2.prototype.idivn = function(f2) { + var a2 = f2 < 0; + a2 && (f2 = -f2), i2(f2 <= 67108863); + for (var c2 = 0, d2 = this.length - 1; d2 >= 0; d2--) { + var g2 = (this.words[d2] | 0) + c2 * 67108864; + this.words[d2] = g2 / f2 | 0, c2 = g2 % f2; + } + return this._strip(), a2 ? this.ineg() : this; + }, o2.prototype.divn = function(f2) { + return this.clone().idivn(f2); + }, o2.prototype.egcd = function(f2) { + i2(f2.negative === 0), i2(!f2.isZero()); + var a2 = this, c2 = f2.clone(); + a2.negative !== 0 ? a2 = a2.umod(f2) : a2 = a2.clone(); + for (var d2 = new o2(1), g2 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a2.isEven() && c2.isEven(); ) + a2.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v2 = a2.clone(); !a2.isZero(); ) { + for (var k2 = 0, u2 = 1; !(a2.words[0] & u2) && k2 < 26; ++k2, u2 <<= 1) + ; + if (k2 > 0) + for (a2.iushrn(k2); k2-- > 0; ) + (d2.isOdd() || g2.isOdd()) && (d2.iadd(s2), g2.isub(v2)), d2.iushrn(1), g2.iushrn(1); + for (var E2 = 0, _2 = 1; !(c2.words[0] & _2) && E2 < 26; ++E2, _2 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v2)), x2.iushrn(1), M2.iushrn(1); + a2.cmp(c2) >= 0 ? (a2.isub(c2), d2.isub(x2), g2.isub(M2)) : (c2.isub(a2), x2.isub(d2), M2.isub(g2)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f2) { + i2(f2.negative === 0), i2(!f2.isZero()); + var a2 = this, c2 = f2.clone(); + a2.negative !== 0 ? a2 = a2.umod(f2) : a2 = a2.clone(); + for (var d2 = new o2(1), g2 = new o2(0), x2 = c2.clone(); a2.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a2.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a2.iushrn(M2); M2-- > 0; ) + d2.isOdd() && d2.iadd(x2), d2.iushrn(1); + for (var s2 = 0, v2 = 1; !(c2.words[0] & v2) && s2 < 26; ++s2, v2 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g2.isOdd() && g2.iadd(x2), g2.iushrn(1); + a2.cmp(c2) >= 0 ? (a2.isub(c2), d2.isub(g2)) : (c2.isub(a2), g2.isub(d2)); + } + var k2; + return a2.cmpn(1) === 0 ? k2 = d2 : k2 = g2, k2.cmpn(0) < 0 && k2.iadd(f2), k2; + }, o2.prototype.gcd = function(f2) { + if (this.isZero()) + return f2.abs(); + if (f2.isZero()) + return this.abs(); + var a2 = this.clone(), c2 = f2.clone(); + a2.negative = 0, c2.negative = 0; + for (var d2 = 0; a2.isEven() && c2.isEven(); d2++) + a2.iushrn(1), c2.iushrn(1); + do { + for (; a2.isEven(); ) + a2.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g2 = a2.cmp(c2); + if (g2 < 0) { + var x2 = a2; + a2 = c2, c2 = x2; + } else if (g2 === 0 || c2.cmpn(1) === 0) + break; + a2.isub(c2); + } while (true); + return c2.iushln(d2); + }, o2.prototype.invm = function(f2) { + return this.egcd(f2).a.umod(f2); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f2) { + return this.words[0] & f2; + }, o2.prototype.bincn = function(f2) { + i2(typeof f2 == "number"); + var a2 = f2 % 26, c2 = (f2 - a2) / 26, d2 = 1 << a2; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d2, this; + for (var g2 = d2, x2 = c2; g2 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g2, g2 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g2 !== 0 && (this.words[x2] = g2, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f2) { + var a2 = f2 < 0; + if (this.negative !== 0 && !a2) + return -1; + if (this.negative === 0 && a2) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a2 && (f2 = -f2), i2(f2 <= 67108863, "Number is too big"); + var d2 = this.words[0] | 0; + c2 = d2 === f2 ? 0 : d2 < f2 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f2) { + if (this.negative !== 0 && f2.negative === 0) + return -1; + if (this.negative === 0 && f2.negative !== 0) + return 1; + var a2 = this.ucmp(f2); + return this.negative !== 0 ? -a2 | 0 : a2; + }, o2.prototype.ucmp = function(f2) { + if (this.length > f2.length) + return 1; + if (this.length < f2.length) + return -1; + for (var a2 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d2 = this.words[c2] | 0, g2 = f2.words[c2] | 0; + if (d2 !== g2) { + d2 < g2 ? a2 = -1 : d2 > g2 && (a2 = 1); + break; + } + } + return a2; + }, o2.prototype.gtn = function(f2) { + return this.cmpn(f2) === 1; + }, o2.prototype.gt = function(f2) { + return this.cmp(f2) === 1; + }, o2.prototype.gten = function(f2) { + return this.cmpn(f2) >= 0; + }, o2.prototype.gte = function(f2) { + return this.cmp(f2) >= 0; + }, o2.prototype.ltn = function(f2) { + return this.cmpn(f2) === -1; + }, o2.prototype.lt = function(f2) { + return this.cmp(f2) === -1; + }, o2.prototype.lten = function(f2) { + return this.cmpn(f2) <= 0; + }, o2.prototype.lte = function(f2) { + return this.cmp(f2) <= 0; + }, o2.prototype.eqn = function(f2) { + return this.cmpn(f2) === 0; + }, o2.prototype.eq = function(f2) { + return this.cmp(f2) === 0; + }, o2.red = function(f2) { + return new Y2(f2); + }, o2.prototype.toRed = function(f2) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f2.convertTo(this)._forceRed(f2); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f2) { + return this.red = f2, this; + }, o2.prototype.forceRed = function(f2) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f2); + }, o2.prototype.redAdd = function(f2) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f2); + }, o2.prototype.redIAdd = function(f2) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f2); + }, o2.prototype.redSub = function(f2) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f2); + }, o2.prototype.redISub = function(f2) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f2); + }, o2.prototype.redShl = function(f2) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f2); + }, o2.prototype.redMul = function(f2) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f2), this.red.mul(this, f2); + }, o2.prototype.redIMul = function(f2) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f2), this.red.imul(this, f2); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f2) { + return i2(this.red && !f2.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f2); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f2) { + this.name = A2, this.p = new o2(f2, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f2 = new o2(null); + return f2.words = new Array(Math.ceil(this.n / 13)), f2; + }, z2.prototype.ireduce = function(f2) { + var a2 = f2, c2; + do + this.split(a2, this.tmp), a2 = this.imulK(a2), a2 = a2.iadd(this.tmp), c2 = a2.bitLength(); + while (c2 > this.n); + var d2 = c2 < this.n ? -1 : a2.ucmp(this.p); + return d2 === 0 ? (a2.words[0] = 0, a2.length = 1) : d2 > 0 ? a2.isub(this.p) : a2.strip !== void 0 ? a2.strip() : a2._strip(), a2; + }, z2.prototype.split = function(f2, a2) { + f2.iushrn(this.n, 0, a2); + }, z2.prototype.imulK = function(f2) { + return f2.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n2(Pt2, z2), Pt2.prototype.split = function(f2, a2) { + for (var c2 = 4194303, d2 = Math.min(f2.length, 9), g2 = 0; g2 < d2; g2++) + a2.words[g2] = f2.words[g2]; + if (a2.length = d2, f2.length <= 9) { + f2.words[0] = 0, f2.length = 1; + return; + } + var x2 = f2.words[9]; + for (a2.words[a2.length++] = x2 & c2, g2 = 10; g2 < f2.length; g2++) { + var M2 = f2.words[g2] | 0; + f2.words[g2 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f2.words[g2 - 10] = x2, x2 === 0 && f2.length > 10 ? f2.length -= 10 : f2.length -= 9; + }, Pt2.prototype.imulK = function(f2) { + f2.words[f2.length] = 0, f2.words[f2.length + 1] = 0, f2.length += 2; + for (var a2 = 0, c2 = 0; c2 < f2.length; c2++) { + var d2 = f2.words[c2] | 0; + a2 += d2 * 977, f2.words[c2] = a2 & 67108863, a2 = d2 * 64 + (a2 / 67108864 | 0); + } + return f2.words[f2.length - 1] === 0 && (f2.length--, f2.words[f2.length - 1] === 0 && f2.length--), f2; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n2(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n2(Rt2, z2); + function Yt2() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n2(Yt2, z2), Yt2.prototype.imulK = function(f2) { + for (var a2 = 0, c2 = 0; c2 < f2.length; c2++) { + var d2 = (f2.words[c2] | 0) * 19 + a2, g2 = d2 & 67108863; + d2 >>>= 26, f2.words[c2] = g2, a2 = d2; + } + return a2 !== 0 && (f2.words[f2.length++] = a2), f2; + }, o2._prime = function(f2) { + if (H2[f2]) + return H2[f2]; + var a2; + if (f2 === "k256") + a2 = new Pt2(); + else if (f2 === "p224") + a2 = new W2(); + else if (f2 === "p192") + a2 = new Rt2(); + else if (f2 === "p25519") + a2 = new Yt2(); + else + throw new Error("Unknown prime " + f2); + return H2[f2] = a2, a2; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f2 = o2._prime(A2); + this.m = f2.p, this.prime = f2; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f2) { + i2(f2.negative === 0, "red works only with positives"), i2(f2.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f2, a2) { + i2((f2.negative | a2.negative) === 0, "red works only with positives"), i2(f2.red && f2.red === a2.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f2) { + return this.prime ? this.prime.ireduce(f2)._forceRed(this) : (w2(f2, f2.umod(this.m)._forceRed(this)), f2); + }, Y2.prototype.neg = function(f2) { + return f2.isZero() ? f2.clone() : this.m.sub(f2)._forceRed(this); + }, Y2.prototype.add = function(f2, a2) { + this._verify2(f2, a2); + var c2 = f2.add(a2); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f2, a2) { + this._verify2(f2, a2); + var c2 = f2.iadd(a2); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f2, a2) { + this._verify2(f2, a2); + var c2 = f2.sub(a2); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f2, a2) { + this._verify2(f2, a2); + var c2 = f2.isub(a2); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f2, a2) { + return this._verify1(f2), this.imod(f2.ushln(a2)); + }, Y2.prototype.imul = function(f2, a2) { + return this._verify2(f2, a2), this.imod(f2.imul(a2)); + }, Y2.prototype.mul = function(f2, a2) { + return this._verify2(f2, a2), this.imod(f2.mul(a2)); + }, Y2.prototype.isqr = function(f2) { + return this.imul(f2, f2.clone()); + }, Y2.prototype.sqr = function(f2) { + return this.mul(f2, f2); + }, Y2.prototype.sqrt = function(f2) { + if (f2.isZero()) + return f2.clone(); + var a2 = this.m.andln(3); + if (i2(a2 % 2 === 1), a2 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f2, c2); + } + for (var d2 = this.m.subn(1), g2 = 0; !d2.isZero() && d2.andln(1) === 0; ) + g2++, d2.iushrn(1); + i2(!d2.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v2 = this.pow(s2, d2), k2 = this.pow(f2, d2.addn(1).iushrn(1)), u2 = this.pow(f2, d2), E2 = g2; u2.cmp(x2) !== 0; ) { + for (var _2 = u2, B2 = 0; _2.cmp(x2) !== 0; B2++) + _2 = _2.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v2, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v2 = R2.redSqr(), u2 = u2.redMul(v2), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f2) { + var a2 = f2._invmp(this.m); + return a2.negative !== 0 ? (a2.negative = 0, this.imod(a2).redNeg()) : this.imod(a2); + }, Y2.prototype.pow = function(f2, a2) { + if (a2.isZero()) + return new o2(1).toRed(this); + if (a2.cmpn(1) === 0) + return f2.clone(); + var c2 = 4, d2 = new Array(1 << c2); + d2[0] = new o2(1).toRed(this), d2[1] = f2; + for (var g2 = 2; g2 < d2.length; g2++) + d2[g2] = this.mul(d2[g2 - 1], f2); + var x2 = d2[0], M2 = 0, l2 = 0, s2 = a2.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g2 = a2.length - 1; g2 >= 0; g2--) { + for (var v2 = a2.words[g2], k2 = s2 - 1; k2 >= 0; k2--) { + var u2 = v2 >> k2 & 1; + if (x2 !== d2[0] && (x2 = this.sqr(x2)), u2 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u2, l2++, !(l2 !== c2 && (g2 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d2[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f2) { + var a2 = f2.umod(this.m); + return a2 === f2 ? a2.clone() : a2; + }, Y2.prototype.convertFrom = function(f2) { + var a2 = f2.clone(); + return a2.red = null, a2; + }, o2.mont = function(f2) { + return new Vt2(f2); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n2(Vt2, Y2), Vt2.prototype.convertTo = function(f2) { + return this.imod(f2.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f2) { + var a2 = this.imod(f2.mul(this.rinv)); + return a2.red = null, a2; + }, Vt2.prototype.imul = function(f2, a2) { + if (f2.isZero() || a2.isZero()) + return f2.words[0] = 0, f2.length = 1, f2; + var c2 = f2.imul(a2), d2 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g2 = c2.isub(d2).iushrn(this.shift), x2 = g2; + return g2.cmp(this.m) >= 0 ? x2 = g2.isub(this.m) : g2.cmpn(0) < 0 && (x2 = g2.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f2, a2) { + if (f2.isZero() || a2.isZero()) + return new o2(0)._forceRed(this); + var c2 = f2.mul(a2), d2 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g2 = c2.isub(d2).iushrn(this.shift), x2 = g2; + return g2.cmp(this.m) >= 0 ? x2 = g2.isub(this.m) : g2.cmpn(0) < 0 && (x2 = g2.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f2) { + var a2 = this.imod(f2._invmp(this.m).mul(this.r2)); + return a2._forceRed(this); + }; + })(e2, On$1); + })(Ln$1); + var K$3 = Ln$1.exports; + const jn$1 = "bignumber/5.7.0"; + var Rr$2 = K$3.BN; + const Ae$2 = new L$5(jn$1), wi$1 = {}, Qn$1 = 9007199254740991; + function C0$1(e2) { + return e2 != null && (V$3.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt$2(e2) || typeof e2 == "bigint" || ir$3(e2)); + } + let Jn$1 = false; + let V$3 = class V2 { + constructor(t2, r2) { + t2 !== wi$1 && Ae$2.throwError("cannot call constructor directly; use BigNumber.from", L$5.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r2, this._isBigNumber = true, Object.freeze(this); } - replaceMap["%C2"] = "�"; - var entries = Object.keys(replaceMap); - for (var i2 = 0; i2 < entries.length; i2++) { - var key = entries[i2]; - input = input.replace(new RegExp(key, "g"), replaceMap[key]); + fromTwos(t2) { + return Lt$3(j$2(this).fromTwos(t2)); } - return input; - } - var decodeUriComponent = function(encodedURI) { - if (typeof encodedURI !== "string") { - throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + toTwos(t2) { + return Lt$3(j$2(this).toTwos(t2)); } - try { - encodedURI = encodedURI.replace(/\+/g, " "); - return decodeURIComponent(encodedURI); - } catch (err) { - return customDecodeURIComponent(encodedURI); + abs() { + return this._hex[0] === "-" ? V2.from(this._hex.substring(1)) : this; } - }; - var splitOnFirst = (string2, separator) => { - if (!(typeof string2 === "string" && typeof separator === "string")) { - throw new TypeError("Expected the arguments to be of type `string`"); + add(t2) { + return Lt$3(j$2(this).add(j$2(t2))); } - if (separator === "") { - return [string2]; + sub(t2) { + return Lt$3(j$2(this).sub(j$2(t2))); } - const separatorIndex = string2.indexOf(separator); - if (separatorIndex === -1) { - return [string2]; + div(t2) { + return V2.from(t2).isZero() && Wt$4("division-by-zero", "div"), Lt$3(j$2(this).div(j$2(t2))); } - return [ - string2.slice(0, separatorIndex), - string2.slice(separatorIndex + separator.length) - ]; - }; - var filterObj = function(obj, predicate) { - var ret = {}; - var keys2 = Object.keys(obj); - var isArr = Array.isArray(predicate); - for (var i2 = 0; i2 < keys2.length; i2++) { - var key = keys2[i2]; - var val = obj[key]; - if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { - ret[key] = val; - } + mul(t2) { + return Lt$3(j$2(this).mul(j$2(t2))); } - return ret; - }; - (function(exports3) { - const strictUriEncode$1 = strictUriEncode; - const decodeComponent = decodeUriComponent; - const splitOnFirst$1 = splitOnFirst; - const filterObject = filterObj; - const isNullOrUndefined = (value) => value === null || value === void 0; - const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); - function encoderForArrayFormat(options) { - switch (options.arrayFormat) { - case "index": - return (key) => (result, value) => { - const index2 = result.length; - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[", index2, "]"].join("")]; - } - return [ - ...result, - [encode2(key, options), "[", encode2(index2, options), "]=", encode2(value, options)].join("") - ]; - }; - case "bracket": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[]"].join("")]; - } - return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; - }; - case "colon-list-separator": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), ":list="].join("")]; - } - return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; - }; - case "comma": - case "separator": - case "bracket-separator": { - const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - value = value === null ? "" : value; - if (result.length === 0) { - return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; - } - return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; - }; - } - default: - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, encode2(key, options)]; - } - return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; - }; - } + mod(t2) { + const r2 = j$2(t2); + return r2.isNeg() && Wt$4("division-by-zero", "mod"), Lt$3(j$2(this).umod(r2)); } - function parserForArrayFormat(options) { - let result; - switch (options.arrayFormat) { - case "index": - return (key, value, accumulator) => { - result = /\[(\d*)\]$/.exec(key); - key = key.replace(/\[\d*\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = {}; - } - accumulator[key][result[1]] = value; - }; - case "bracket": - return (key, value, accumulator) => { - result = /(\[\])$/.exec(key); - key = key.replace(/\[\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "colon-list-separator": - return (key, value, accumulator) => { - result = /(:list)$/.exec(key); - key = key.replace(/:list$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "comma": - case "separator": - return (key, value, accumulator) => { - const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator); - const isEncodedArray = typeof value === "string" && !isArray && decode2(value, options).includes(options.arrayFormatSeparator); - value = isEncodedArray ? decode2(value, options) : value; - const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); - accumulator[key] = newValue; - }; - case "bracket-separator": - return (key, value, accumulator) => { - const isArray = /(\[\])$/.test(key); - key = key.replace(/\[\]$/, ""); - if (!isArray) { - accumulator[key] = value ? decode2(value, options) : value; - return; - } - const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); - if (accumulator[key] === void 0) { - accumulator[key] = arrayValue; - return; - } - accumulator[key] = [].concat(accumulator[key], arrayValue); - }; - default: - return (key, value, accumulator) => { - if (accumulator[key] === void 0) { - accumulator[key] = value; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - } + pow(t2) { + const r2 = j$2(t2); + return r2.isNeg() && Wt$4("negative-power", "pow"), Lt$3(j$2(this).pow(r2)); + } + and(t2) { + const r2 = j$2(t2); + return (this.isNegative() || r2.isNeg()) && Wt$4("unbound-bitwise-result", "and"), Lt$3(j$2(this).and(r2)); } - function validateArrayFormatSeparator(value) { - if (typeof value !== "string" || value.length !== 1) { - throw new TypeError("arrayFormatSeparator must be single character string"); - } + or(t2) { + const r2 = j$2(t2); + return (this.isNegative() || r2.isNeg()) && Wt$4("unbound-bitwise-result", "or"), Lt$3(j$2(this).or(r2)); } - function encode2(value, options) { - if (options.encode) { - return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); - } - return value; + xor(t2) { + const r2 = j$2(t2); + return (this.isNegative() || r2.isNeg()) && Wt$4("unbound-bitwise-result", "xor"), Lt$3(j$2(this).xor(r2)); } - function decode2(value, options) { - if (options.decode) { - return decodeComponent(value); - } - return value; + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt$4("negative-width", "mask"), Lt$3(j$2(this).maskn(t2)); } - function keysSorter(input) { - if (Array.isArray(input)) { - return input.sort(); - } - if (typeof input === "object") { - return keysSorter(Object.keys(input)).sort((a2, b2) => Number(a2) - Number(b2)).map((key) => input[key]); - } - return input; + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt$4("negative-width", "shl"), Lt$3(j$2(this).shln(t2)); } - function removeHash(input) { - const hashStart = input.indexOf("#"); - if (hashStart !== -1) { - input = input.slice(0, hashStart); - } - return input; + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt$4("negative-width", "shr"), Lt$3(j$2(this).shrn(t2)); } - function getHash(url) { - let hash2 = ""; - const hashStart = url.indexOf("#"); - if (hashStart !== -1) { - hash2 = url.slice(hashStart); - } - return hash2; + eq(t2) { + return j$2(this).eq(j$2(t2)); } - function extract(input) { - input = removeHash(input); - const queryStart = input.indexOf("?"); - if (queryStart === -1) { - return ""; - } - return input.slice(queryStart + 1); + lt(t2) { + return j$2(this).lt(j$2(t2)); } - function parseValue(value, options) { - if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { - value = Number(value); - } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { - value = value.toLowerCase() === "true"; - } - return value; + lte(t2) { + return j$2(this).lte(j$2(t2)); } - function parse(query, options) { - options = Object.assign({ - decode: true, - sort: true, - arrayFormat: "none", - arrayFormatSeparator: ",", - parseNumbers: false, - parseBooleans: false - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const formatter = parserForArrayFormat(options); - const ret = /* @__PURE__ */ Object.create(null); - if (typeof query !== "string") { - return ret; - } - query = query.trim().replace(/^[?#&]/, ""); - if (!query) { - return ret; - } - for (const param of query.split("&")) { - if (param === "") { - continue; - } - let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); - value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); - formatter(decode2(key, options), value, ret); - } - for (const key of Object.keys(ret)) { - const value = ret[key]; - if (typeof value === "object" && value !== null) { - for (const k2 of Object.keys(value)) { - value[k2] = parseValue(value[k2], options); - } - } else { - ret[key] = parseValue(value, options); - } + gt(t2) { + return j$2(this).gt(j$2(t2)); + } + gte(t2) { + return j$2(this).gte(j$2(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j$2(this).isZero(); + } + toNumber() { + try { + return j$2(this).toNumber(); + } catch { + Wt$4("overflow", "toNumber", this.toString()); } - if (options.sort === false) { - return ret; + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { } - return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { - const value = ret[key]; - if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { - result[key] = keysSorter(value); + return Ae$2.throwError("this platform does not support BigInt", L$5.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn$1 || (Jn$1 = true, Ae$2.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae$2.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L$5.errors.UNEXPECTED_ARGUMENT, {}) : Ae$2.throwError("BigNumber.toString does not accept parameters", L$5.errors.UNEXPECTED_ARGUMENT, {})), j$2(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V2) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V2(wi$1, vr$1(t2)) : t2.match(/^-?[0-9]+$/) ? new V2(wi$1, vr$1(new Rr$2(t2))) : Ae$2.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt$4("underflow", "BigNumber.from", t2), (t2 >= Qn$1 || t2 <= -Qn$1) && Wt$4("overflow", "BigNumber.from", t2), V2.from(String(t2)); + const r2 = t2; + if (typeof r2 == "bigint") + return V2.from(r2.toString()); + if (ir$3(r2)) + return V2.from(Kt$3(r2)); + if (r2) + if (r2.toHexString) { + const i2 = r2.toHexString(); + if (typeof i2 == "string") + return V2.from(i2); } else { - result[key] = value; + let i2 = r2._hex; + if (i2 == null && r2.type === "BigNumber" && (i2 = r2.hex), typeof i2 == "string" && (Qt$2(i2) || i2[0] === "-" && Qt$2(i2.substring(1)))) + return V2.from(i2); } - return result; - }, /* @__PURE__ */ Object.create(null)); + return Ae$2.throwArgumentError("invalid BigNumber value", "value", t2); } - exports3.extract = extract; - exports3.parse = parse; - exports3.stringify = (object, options) => { - if (!object) { - return ""; - } - options = Object.assign({ - encode: true, - strict: true, - arrayFormat: "none", - arrayFormatSeparator: "," - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; - const formatter = encoderForArrayFormat(options); - const objectCopy = {}; - for (const key of Object.keys(object)) { - if (!shouldFilter(key)) { - objectCopy[key] = object[key]; - } - } - const keys2 = Object.keys(objectCopy); - if (options.sort !== false) { - keys2.sort(options.sort); + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } + }; + function vr$1(e2) { + if (typeof e2 != "string") + return vr$1(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae$2.throwArgumentError("invalid hex", "value", e2), e2 = vr$1(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; + } + function Lt$3(e2) { + return V$3.from(vr$1(e2)); + } + function j$2(e2) { + const t2 = V$3.from(e2).toHexString(); + return t2[0] === "-" ? new Rr$2("-" + t2.substring(3), 16) : new Rr$2(t2.substring(2), 16); + } + function Wt$4(e2, t2, r2) { + const i2 = { fault: e2, operation: t2 }; + return r2 != null && (i2.value = r2), Ae$2.throwError(e2, L$5.errors.NUMERIC_FAULT, i2); + } + function R0(e2) { + return new Rr$2(e2, 36).toString(16); + } + const Ht$4 = new L$5(jn$1), mr$3 = {}, Gn$1 = V$3.from(0), Yn$1 = V$3.from(-1); + function Vn$1(e2, t2, r2, i2) { + const n2 = { fault: t2, operation: r2 }; + return i2 !== void 0 && (n2.value = i2), Ht$4.throwError(e2, L$5.errors.NUMERIC_FAULT, n2); + } + let gr$2 = "0"; + for (; gr$2.length < 256; ) + gr$2 += gr$2; + function xi$1(e2) { + if (typeof e2 != "number") + try { + e2 = V$3.from(e2).toNumber(); + } catch { } - return keys2.map((key) => { - const value = object[key]; - if (value === void 0) { - return ""; - } - if (value === null) { - return encode2(key, options); - } - if (Array.isArray(value)) { - if (value.length === 0 && options.arrayFormat === "bracket-separator") { - return encode2(key, options) + "[]"; + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr$2.substring(0, e2) : Ht$4.throwArgumentError("invalid decimal size", "decimals", e2); + } + function Mi$1(e2, t2) { + t2 == null && (t2 = 0); + const r2 = xi$1(t2); + e2 = V$3.from(e2); + const i2 = e2.lt(Gn$1); + i2 && (e2 = e2.mul(Yn$1)); + let n2 = e2.mod(r2).toString(); + for (; n2.length < r2.length - 1; ) + n2 = "0" + n2; + n2 = n2.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r2).toString(); + return r2.length === 1 ? e2 = o2 : e2 = o2 + "." + n2, i2 && (e2 = "-" + e2), e2; + } + function be$2(e2, t2) { + t2 == null && (t2 = 0); + const r2 = xi$1(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht$4.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht$4.throwArgumentError("missing value", "value", e2); + const n2 = e2.split("."); + n2.length > 2 && Ht$4.throwArgumentError("too many decimal points", "value", e2); + let o2 = n2[0], h2 = n2[1]; + for (o2 || (o2 = "0"), h2 || (h2 = "0"); h2[h2.length - 1] === "0"; ) + h2 = h2.substring(0, h2.length - 1); + for (h2.length > r2.length - 1 && Vn$1("fractional component exceeds decimals", "underflow", "parseFixed"), h2 === "" && (h2 = "0"); h2.length < r2.length - 1; ) + h2 += "0"; + const p2 = V$3.from(o2), b2 = V$3.from(h2); + let m2 = p2.mul(r2).add(b2); + return i2 && (m2 = m2.mul(Yn$1)), m2; + } + let dr$3 = class dr2 { + constructor(t2, r2, i2, n2) { + t2 !== mr$3 && Ht$4.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L$5.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r2, this.width = i2, this.decimals = n2, this.name = (r2 ? "" : "u") + "fixed" + String(i2) + "x" + String(n2), this._multiplier = xi$1(n2), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr2) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r2 = true, i2 = 128, n2 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r2 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht$4.throwArgumentError("invalid fixed format", "format", t2), r2 = o2[1] !== "u", i2 = parseInt(o2[2]), n2 = parseInt(o2[3]); } - return value.reduce(formatter(key), []).join("&"); - } - return encode2(key, options) + "=" + encode2(value, options); - }).filter((x2) => x2.length > 0).join("&"); - }; - exports3.parseUrl = (url, options) => { - options = Object.assign({ - decode: true - }, options); - const [url_, hash2] = splitOnFirst$1(url, "#"); - return Object.assign( - { - url: url_.split("?")[0] || "", - query: parse(extract(url), options) - }, - options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} - ); + } else if (t2) { + const o2 = (h2, p2, b2) => t2[h2] == null ? b2 : (typeof t2[h2] !== p2 && Ht$4.throwArgumentError("invalid fixed format (" + h2 + " not " + p2 + ")", "format." + h2, t2[h2]), t2[h2]); + r2 = o2("signed", "boolean", r2), i2 = o2("width", "number", i2), n2 = o2("decimals", "number", n2); + } + return i2 % 8 && Ht$4.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n2 > 80 && Ht$4.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n2), new dr2(mr$3, r2, i2, n2); + } + }; + let Ut$3 = class Ut2 { + constructor(t2, r2, i2, n2) { + t2 !== mr$3 && Ht$4.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L$5.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n2, this._hex = r2, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht$4.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r2 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut2.fromValue(r2.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r2 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut2.fromValue(r2.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r2 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut2.fromValue(r2.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r2 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut2.fromValue(r2.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r2 = Ut2.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r2 = r2.subUnsafe(Wn$1.toFormat(r2.format))), r2; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r2 = Ut2.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r2 = r2.addUnsafe(Wn$1.toFormat(r2.format))), r2; + } + round(t2) { + t2 == null && (t2 = 0); + const r2 = this.toString().split("."); + if (r2.length === 1 && r2.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht$4.throwArgumentError("invalid decimal count", "decimals", t2), r2[1].length <= t2) + return this; + const i2 = Ut2.from("1" + gr$2.substring(0, t2), this.format), n2 = O0$1.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n2).floor().divUnsafe(i2); + } + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht$4.throwArgumentError("invalid byte width", "width", t2); + const r2 = V$3.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe$1(r2, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut2.fromString(this._value, t2); + } + static fromValue(t2, r2, i2) { + return i2 == null && r2 != null && !C0$1(r2) && (i2 = r2, r2 = null), r2 == null && (r2 = 0), i2 == null && (i2 = "fixed"), Ut2.fromString(Mi$1(t2, r2), dr$3.from(i2)); + } + static fromString(t2, r2) { + r2 == null && (r2 = "fixed"); + const i2 = dr$3.from(r2), n2 = be$2(t2, i2.decimals); + !i2.signed && n2.lt(Gn$1) && Vn$1("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n2.toTwos(i2.width).toHexString() : (o2 = n2.toHexString(), o2 = oe$1(o2, i2.width / 8)); + const h2 = Mi$1(n2, i2.decimals); + return new Ut2(mr$3, o2, h2, i2); + } + static fromBytes(t2, r2) { + r2 == null && (r2 = "fixed"); + const i2 = dr$3.from(r2); + if (Ot$3(t2).length > i2.width / 8) + throw new Error("overflow"); + let n2 = V$3.from(t2); + i2.signed && (n2 = n2.fromTwos(i2.width)); + const o2 = n2.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h2 = Mi$1(n2, i2.decimals); + return new Ut2(mr$3, o2, h2, i2); + } + static from(t2, r2) { + if (typeof t2 == "string") + return Ut2.fromString(t2, r2); + if (ir$3(t2)) + return Ut2.fromBytes(t2, r2); + try { + return Ut2.fromValue(t2, 0, r2); + } catch (i2) { + if (i2.code !== L$5.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht$4.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } + }; + const Wn$1 = Ut$3.from(1), O0$1 = Ut$3.from("0.5"), P0 = "strings/5.7.0", Xn = new L$5(P0); + var Or$2; + (function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; + })(Or$2 || (Or$2 = {})); + var nr$3; + (function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; + })(nr$3 || (nr$3 = {})); + function Ei(e2, t2 = Or$2.current) { + t2 != Or$2.current && (Xn.checkNormalize(), e2 = e2.normalize(t2)); + let r2 = []; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2.charCodeAt(i2); + if (n2 < 128) + r2.push(n2); + else if (n2 < 2048) + r2.push(n2 >> 6 | 192), r2.push(n2 & 63 | 128); + else if ((n2 & 64512) == 55296) { + i2++; + const o2 = e2.charCodeAt(i2); + if (i2 >= e2.length || (o2 & 64512) !== 56320) + throw new Error("invalid utf-8 string"); + const h2 = 65536 + ((n2 & 1023) << 10) + (o2 & 1023); + r2.push(h2 >> 18 | 240), r2.push(h2 >> 12 & 63 | 128), r2.push(h2 >> 6 & 63 | 128), r2.push(h2 & 63 | 128); + } else + r2.push(n2 >> 12 | 224), r2.push(n2 >> 6 & 63 | 128), r2.push(n2 & 63 | 128); + } + return Ot$3(r2); + } + function T0$1(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r2 = 0; r2 < e2.length; r2 += 4) + t2.push(parseInt(e2.substring(r2, r2 + 4), 16)); + return t2; + } + function Si$1(e2, t2) { + t2 || (t2 = function(n2) { + return [parseInt(n2, 16)]; + }); + let r2 = 0, i2 = {}; + return e2.split(",").forEach((n2) => { + let o2 = n2.split(":"); + r2 += parseInt(o2[0], 16), i2[r2] = t2(o2[1]); + }), i2; + } + function $n$1(e2) { + let t2 = 0; + return e2.split(",").map((r2) => { + let i2 = r2.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n2 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n2, h: t2 }; + }); + } + $n$1("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si$1("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si$1("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si$1("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0$1), $n$1("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); + function U0$1(e2) { + e2 = atob(e2); + const t2 = []; + for (let r2 = 0; r2 < e2.length; r2++) + t2.push(e2.charCodeAt(r2)); + return Ot$3(t2); + } + function ef$1(e2, t2) { + t2 == null && (t2 = 1); + const r2 = [], i2 = r2.forEach, n2 = function(o2, h2) { + i2.call(o2, function(p2) { + h2 > 0 && Array.isArray(p2) ? n2(p2, h2 - 1) : r2.push(p2); + }); }; - exports3.stringifyUrl = (object, options) => { - options = Object.assign({ - encode: true, - strict: true, - [encodeFragmentIdentifier]: true - }, options); - const url = removeHash(object.url).split("?")[0] || ""; - const queryFromUrl = exports3.extract(object.url); - const parsedQueryFromUrl = exports3.parse(queryFromUrl, { sort: false }); - const query = Object.assign(parsedQueryFromUrl, object.query); - let queryString2 = exports3.stringify(query, options); - if (queryString2) { - queryString2 = `?${queryString2}`; - } - let hash2 = getHash(object.url); - if (object.fragmentIdentifier) { - hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + return n2(e2, t2), r2; + } + function k0$1(e2) { + const t2 = {}; + for (let r2 = 0; r2 < e2.length; r2++) { + const i2 = e2[r2]; + t2[i2[0]] = i2[1]; + } + return t2; + } + function q0$1(e2) { + let t2 = 0; + function r2() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r2(), n2 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n2 += r2()); + let h2 = r2(), p2 = t2; + t2 += h2; + let b2 = 0, m2 = 0; + function w2() { + return b2 == 0 && (m2 = m2 << 8 | e2[t2++], b2 = 8), m2 >> --b2 & 1; + } + const y2 = 31, S2 = Math.pow(2, y2), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y2; H2++) + F2 = F2 << 1 | w2(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n2 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt2 = z2 + Pt2 >>> 1; + H2 < o2[Yt2] ? Pt2 = Yt2 : z2 = Yt2; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n2), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n2) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w2(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w2(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; } - return `${url}${queryString2}${hash2}`; - }; - exports3.pick = (input, filter, options) => { - options = Object.assign({ - parseFragmentIdentifier: true, - [encodeFragmentIdentifier]: false - }, options); - const { url, query, fragmentIdentifier } = exports3.parseUrl(input, options); - return exports3.stringifyUrl({ - url, - query: filterObject(query, filter), - fragmentIdentifier - }, options); - }; - exports3.exclude = (input, filter, options) => { - const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); - return exports3.pick(input, exclusionFilter, options); - }; - })(queryString); - const RELAY_JSONRPC = { - waku: { - publish: "waku_publish", - batchPublish: "waku_batchPublish", - subscribe: "waku_subscribe", - batchSubscribe: "waku_batchSubscribe", - subscription: "waku_subscription", - unsubscribe: "waku_unsubscribe", - batchUnsubscribe: "waku_batchUnsubscribe" - }, - irn: { - publish: "irn_publish", - batchPublish: "irn_batchPublish", - subscribe: "irn_subscribe", - batchSubscribe: "irn_batchSubscribe", - subscription: "irn_subscription", - unsubscribe: "irn_unsubscribe", - batchUnsubscribe: "irn_batchUnsubscribe" - }, - iridium: { - publish: "iridium_publish", - batchPublish: "iridium_batchPublish", - subscribe: "iridium_subscribe", - batchSubscribe: "iridium_batchSubscribe", - subscription: "iridium_subscription", - unsubscribe: "iridium_unsubscribe", - batchUnsubscribe: "iridium_batchUnsubscribe" + }); + } + function K0$1(e2) { + let t2 = 0; + return () => e2[t2++]; + } + function H0$1(e2) { + return K0$1(q0$1(e2)); + } + function z0$1(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; + } + function L0$1(e2, t2) { + let r2 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r2[i2] = 1 + t2(); + return r2; + } + function rf$1(e2, t2) { + let r2 = Array(e2); + for (let i2 = 0, n2 = -1; i2 < e2; i2++) + r2[i2] = n2 += 1 + t2(); + return r2; + } + function j0$1(e2, t2) { + let r2 = Array(e2); + for (let i2 = 0, n2 = 0; i2 < e2; i2++) + r2[i2] = n2 += z0$1(t2()); + return r2; + } + function Pr$2(e2, t2) { + let r2 = rf$1(e2(), e2), i2 = e2(), n2 = rf$1(i2, e2), o2 = L0$1(i2, e2); + for (let h2 = 0; h2 < i2; h2++) + for (let p2 = 0; p2 < o2[h2]; p2++) + r2.push(n2[h2] + p2); + return t2 ? r2.map((h2) => t2[h2]) : r2; + } + function Q0$1(e2) { + let t2 = []; + for (; ; ) { + let r2 = e2(); + if (r2 == 0) + break; + t2.push(G0$1(r2, e2)); + } + for (; ; ) { + let r2 = e2() - 1; + if (r2 < 0) + break; + t2.push(Y0$1(r2, e2)); + } + return k0$1(ef$1(t2)); + } + function J0$1(e2) { + let t2 = []; + for (; ; ) { + let r2 = e2(); + if (r2 == 0) + break; + t2.push(r2); + } + return t2; + } + function nf$1(e2, t2, r2) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n2 = 0; n2 < t2; n2++) + j0$1(e2, r2).forEach((o2, h2) => i2[h2].push(o2)); + return i2; + } + function G0$1(e2, t2) { + let r2 = 1 + t2(), i2 = t2(), n2 = J0$1(t2), o2 = nf$1(n2.length, 1 + e2, t2); + return ef$1(o2.map((h2, p2) => { + const b2 = h2[0], m2 = h2.slice(1); + return Array(n2[p2]).fill(void 0).map((w2, y2) => { + let S2 = y2 * i2; + return [b2 + y2 * r2, m2.map((I2) => I2 + S2)]; + }); + })); + } + function Y0$1(e2, t2) { + let r2 = 1 + t2(); + return nf$1(r2, 1 + e2, t2).map((n2) => [n2[0], n2.slice(1)]); + } + function V0$1(e2) { + let t2 = Pr$2(e2).sort((i2, n2) => i2 - n2); + return r2(); + function r2() { + let i2 = []; + for (; ; ) { + let m2 = Pr$2(e2, t2); + if (m2.length == 0) + break; + i2.push({ set: new Set(m2), node: r2() }); + } + i2.sort((m2, w2) => w2.set.size - m2.set.size); + let n2 = e2(), o2 = n2 % 3; + n2 = n2 / 3 | 0; + let h2 = !!(n2 & 1); + n2 >>= 1; + let p2 = n2 == 1, b2 = n2 == 2; + return { branches: i2, valid: o2, fe0f: h2, save: p2, check: b2 }; + } + } + function W0$1() { + return H0$1(U0$1("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); + } + const Dr$2 = W0$1(); + new Set(Pr$2(Dr$2)), new Set(Pr$2(Dr$2)), Q0$1(Dr$2), V0$1(Dr$2); + const X0$1 = new Uint8Array(32); + X0$1.fill(0); + const Z0 = `Ethereum Signed Message: +`; + function ff(e2) { + return typeof e2 == "string" && (e2 = Ei(e2)), yi(E0([Ei(Z0), Ei(String(e2.length)), e2])); + } + const ts$2 = "address/5.7.0", Ar$1 = new L$5(ts$2); + function of(e2) { + Qt$2(e2, 20) || Ar$1.throwArgumentError("invalid address", "address", e2), e2 = e2.toLowerCase(); + const t2 = e2.substring(2).split(""), r2 = new Uint8Array(40); + for (let n2 = 0; n2 < 40; n2++) + r2[n2] = t2[n2].charCodeAt(0); + const i2 = Ot$3(yi(r2)); + for (let n2 = 0; n2 < 40; n2 += 2) + i2[n2 >> 1] >> 4 >= 8 && (t2[n2] = t2[n2].toUpperCase()), (i2[n2 >> 1] & 15) >= 8 && (t2[n2 + 1] = t2[n2 + 1].toUpperCase()); + return "0x" + t2.join(""); + } + const es$2 = 9007199254740991; + function rs$2(e2) { + return Math.log10 ? Math.log10(e2) : Math.log(e2) / Math.LN10; + } + const Ni = {}; + for (let e2 = 0; e2 < 10; e2++) + Ni[String(e2)] = String(e2); + for (let e2 = 0; e2 < 26; e2++) + Ni[String.fromCharCode(65 + e2)] = String(10 + e2); + const sf = Math.floor(rs$2(es$2)); + function is$2(e2) { + e2 = e2.toUpperCase(), e2 = e2.substring(4) + e2.substring(0, 2) + "00"; + let t2 = e2.split("").map((i2) => Ni[i2]).join(""); + for (; t2.length >= sf; ) { + let i2 = t2.substring(0, sf); + t2 = parseInt(i2, 10) % 97 + t2.substring(i2.length); + } + let r2 = String(98 - parseInt(t2, 10) % 97); + for (; r2.length < 2; ) + r2 = "0" + r2; + return r2; + } + function ns$1(e2) { + let t2 = null; + if (typeof e2 != "string" && Ar$1.throwArgumentError("invalid address", "address", e2), e2.match(/^(0x)?[0-9a-fA-F]{40}$/)) + e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), t2 = of(e2), e2.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && t2 !== e2 && Ar$1.throwArgumentError("bad address checksum", "address", e2); + else if (e2.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + for (e2.substring(2, 4) !== is$2(e2) && Ar$1.throwArgumentError("bad icap checksum", "address", e2), t2 = R0(e2.substring(4)); t2.length < 40; ) + t2 = "0" + t2; + t2 = of("0x" + t2); + } else + Ar$1.throwArgumentError("invalid address", "address", e2); + return t2; + } + function br$1(e2, t2, r2) { + Object.defineProperty(e2, t2, { enumerable: true, value: r2, writable: false }); + } + const os$2 = new Uint8Array(32); + os$2.fill(0), V$3.from(-1); + const ss$3 = V$3.from(0), as$2 = V$3.from(1); + V$3.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe$1(as$2.toHexString(), 32), oe$1(ss$3.toHexString(), 32); + var se$3 = {}, Q$2 = {}, yr$2 = af$1; + function af$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); + } + af$1.equal = function(t2, r2, i2) { + if (t2 != r2) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r2); + }; + var Ii$1 = { exports: {} }; + typeof Object.create == "function" ? Ii$1.exports = function(t2, r2) { + r2 && (t2.super_ = r2, t2.prototype = Object.create(r2.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); + } : Ii$1.exports = function(t2, r2) { + if (r2) { + t2.super_ = r2; + var i2 = function() { + }; + i2.prototype = r2.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; } }; - function L$3(e2, n2) { - return e2.includes(":") ? [e2] : n2.chains || []; + var us$2 = yr$2, hs$2 = Ii$1.exports; + Q$2.inherits = hs$2; + function cs$2(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; } - const J$1 = "base10", p$2 = "base16", F$3 = "base64pad", H$2 = "utf8", Q$3 = 0, _$3 = 1, Dn = 0, Te$1 = 1, Z$3 = 12, X$1 = 32; - function kn() { - const e2 = x25519.generateKeyPair(); - return { privateKey: toString(e2.secretKey, p$2), publicKey: toString(e2.publicKey, p$2) }; + function ls$2(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r2 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n2 = 0; n2 < e2.length; n2 += 2) + r2.push(parseInt(e2[n2] + e2[n2 + 1], 16)); + } else + for (var i2 = 0, n2 = 0; n2 < e2.length; n2++) { + var o2 = e2.charCodeAt(n2); + o2 < 128 ? r2[i2++] = o2 : o2 < 2048 ? (r2[i2++] = o2 >> 6 | 192, r2[i2++] = o2 & 63 | 128) : cs$2(e2, n2) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n2) & 1023), r2[i2++] = o2 >> 18 | 240, r2[i2++] = o2 >> 12 & 63 | 128, r2[i2++] = o2 >> 6 & 63 | 128, r2[i2++] = o2 & 63 | 128) : (r2[i2++] = o2 >> 12 | 224, r2[i2++] = o2 >> 6 & 63 | 128, r2[i2++] = o2 & 63 | 128); + } + else + for (n2 = 0; n2 < e2.length; n2++) + r2[n2] = e2[n2] | 0; + return r2; } - function Vn() { - const e2 = random.randomBytes(X$1); - return toString(e2, p$2); + Q$2.toArray = ls$2; + function ds$2(e2) { + for (var t2 = "", r2 = 0; r2 < e2.length; r2++) + t2 += hf$1(e2[r2].toString(16)); + return t2; } - function Mn(e2, n2) { - const t2 = x25519.sharedKey(fromString(e2, p$2), fromString(n2, p$2), true), r2 = new HKDF_1(sha256.SHA256, t2).expand(X$1); - return toString(r2, p$2); + Q$2.toHex = ds$2; + function uf$1(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; } - function Kn(e2) { - const n2 = sha256.hash(fromString(e2, p$2)); - return toString(n2, p$2); + Q$2.htonl = uf$1; + function ps$2(e2, t2) { + for (var r2 = "", i2 = 0; i2 < e2.length; i2++) { + var n2 = e2[i2]; + t2 === "little" && (n2 = uf$1(n2)), r2 += cf$1(n2.toString(16)); + } + return r2; } - function Ln(e2) { - const n2 = sha256.hash(fromString(e2, H$2)); - return toString(n2, p$2); + Q$2.toHex32 = ps$2; + function hf$1(e2) { + return e2.length === 1 ? "0" + e2 : e2; } - function Pe$1(e2) { - return fromString(`${e2}`, J$1); + Q$2.zero2 = hf$1; + function cf$1(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; } - function j$2(e2) { - return Number(toString(e2, J$1)); + Q$2.zero8 = cf$1; + function vs$2(e2, t2, r2, i2) { + var n2 = r2 - t2; + us$2(n2 % 4 === 0); + for (var o2 = new Array(n2 / 4), h2 = 0, p2 = t2; h2 < o2.length; h2++, p2 += 4) { + var b2; + i2 === "big" ? b2 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b2 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h2] = b2 >>> 0; + } + return o2; } - function xn(e2) { - const n2 = Pe$1(typeof e2.type < "u" ? e2.type : Q$3); - if (j$2(n2) === _$3 && typeof e2.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - const t2 = typeof e2.senderPublicKey < "u" ? fromString(e2.senderPublicKey, p$2) : void 0, r2 = typeof e2.iv < "u" ? fromString(e2.iv, p$2) : random.randomBytes(Z$3), o2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, p$2)).seal(r2, fromString(e2.message, H$2)); - return Re$1({ type: n2, sealed: o2, iv: r2, senderPublicKey: t2 }); + Q$2.join32 = vs$2; + function ms$3(e2, t2) { + for (var r2 = new Array(e2.length * 4), i2 = 0, n2 = 0; i2 < e2.length; i2++, n2 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r2[n2] = o2 >>> 24, r2[n2 + 1] = o2 >>> 16 & 255, r2[n2 + 2] = o2 >>> 8 & 255, r2[n2 + 3] = o2 & 255) : (r2[n2 + 3] = o2 >>> 24, r2[n2 + 2] = o2 >>> 16 & 255, r2[n2 + 1] = o2 >>> 8 & 255, r2[n2] = o2 & 255); + } + return r2; } - function Fn(e2) { - const n2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, p$2)), { sealed: t2, iv: r2 } = ee$2(e2.encoded), o2 = n2.open(r2, t2); - if (o2 === null) - throw new Error("Failed to decrypt"); - return toString(o2, H$2); + Q$2.split32 = ms$3; + function gs$2(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; + } + Q$2.rotr32 = gs$2; + function As$2(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; + } + Q$2.rotl32 = As$2; + function bs$2(e2, t2) { + return e2 + t2 >>> 0; + } + Q$2.sum32 = bs$2; + function ys$2(e2, t2, r2) { + return e2 + t2 + r2 >>> 0; + } + Q$2.sum32_3 = ys$2; + function ws$2(e2, t2, r2, i2) { + return e2 + t2 + r2 + i2 >>> 0; + } + Q$2.sum32_4 = ws$2; + function xs$2(e2, t2, r2, i2, n2) { + return e2 + t2 + r2 + i2 + n2 >>> 0; + } + Q$2.sum32_5 = xs$2; + function Ms$2(e2, t2, r2, i2) { + var n2 = e2[t2], o2 = e2[t2 + 1], h2 = i2 + o2 >>> 0, p2 = (h2 < i2 ? 1 : 0) + r2 + n2; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h2; + } + Q$2.sum64 = Ms$2; + function Es$2(e2, t2, r2, i2) { + var n2 = t2 + i2 >>> 0, o2 = (n2 < t2 ? 1 : 0) + e2 + r2; + return o2 >>> 0; + } + Q$2.sum64_hi = Es$2; + function Ss$2(e2, t2, r2, i2) { + var n2 = t2 + i2; + return n2 >>> 0; + } + Q$2.sum64_lo = Ss$2; + function Ns$2(e2, t2, r2, i2, n2, o2, h2, p2) { + var b2 = 0, m2 = t2; + m2 = m2 + i2 >>> 0, b2 += m2 < t2 ? 1 : 0, m2 = m2 + o2 >>> 0, b2 += m2 < o2 ? 1 : 0, m2 = m2 + p2 >>> 0, b2 += m2 < p2 ? 1 : 0; + var w2 = e2 + r2 + n2 + h2 + b2; + return w2 >>> 0; + } + Q$2.sum64_4_hi = Ns$2; + function Is$2(e2, t2, r2, i2, n2, o2, h2, p2) { + var b2 = t2 + i2 + o2 + p2; + return b2 >>> 0; + } + Q$2.sum64_4_lo = Is$2; + function _s$2(e2, t2, r2, i2, n2, o2, h2, p2, b2, m2) { + var w2 = 0, y2 = t2; + y2 = y2 + i2 >>> 0, w2 += y2 < t2 ? 1 : 0, y2 = y2 + o2 >>> 0, w2 += y2 < o2 ? 1 : 0, y2 = y2 + p2 >>> 0, w2 += y2 < p2 ? 1 : 0, y2 = y2 + m2 >>> 0, w2 += y2 < m2 ? 1 : 0; + var S2 = e2 + r2 + n2 + h2 + b2 + w2; + return S2 >>> 0; + } + Q$2.sum64_5_hi = _s$2; + function Bs$2(e2, t2, r2, i2, n2, o2, h2, p2, b2, m2) { + var w2 = t2 + i2 + o2 + p2 + m2; + return w2 >>> 0; + } + Q$2.sum64_5_lo = Bs$2; + function Cs$2(e2, t2, r2) { + var i2 = t2 << 32 - r2 | e2 >>> r2; + return i2 >>> 0; + } + Q$2.rotr64_hi = Cs$2; + function Rs$2(e2, t2, r2) { + var i2 = e2 << 32 - r2 | t2 >>> r2; + return i2 >>> 0; + } + Q$2.rotr64_lo = Rs$2; + function Os$2(e2, t2, r2) { + return e2 >>> r2; + } + Q$2.shr64_hi = Os$2; + function Ps$2(e2, t2, r2) { + var i2 = e2 << 32 - r2 | t2 >>> r2; + return i2 >>> 0; + } + Q$2.shr64_lo = Ps$2; + var fr$1 = {}, lf$1 = Q$2, Ds$2 = yr$2; + function Fr$2() { + 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; + } + fr$1.BlockHash = Fr$2, Fr$2.prototype.update = function(t2, r2) { + if (t2 = lf$1.toArray(t2, r2), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf$1.join32(t2, 0, t2.length - i2, this.endian); + for (var n2 = 0; n2 < t2.length; n2 += this._delta32) + this._update(t2, n2, n2 + this._delta32); + } + return this; + }, Fr$2.prototype.digest = function(t2) { + return this.update(this._pad()), Ds$2(this.pending === null), this._digest(t2); + }, Fr$2.prototype._pad = function() { + var t2 = this.pendingTotal, r2 = this._delta8, i2 = r2 - (t2 + this.padLength) % r2, n2 = new Array(i2 + this.padLength); + n2[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n2[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h2 = 8; h2 < this.padLength; h2++) + n2[o2++] = 0; + n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = t2 >>> 24 & 255, n2[o2++] = t2 >>> 16 & 255, n2[o2++] = t2 >>> 8 & 255, n2[o2++] = t2 & 255; + } else + for (n2[o2++] = t2 & 255, n2[o2++] = t2 >>> 8 & 255, n2[o2++] = t2 >>> 16 & 255, n2[o2++] = t2 >>> 24 & 255, n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = 0, h2 = 8; h2 < this.padLength; h2++) + n2[o2++] = 0; + return n2; + }; + var or$2 = {}, ae$2 = {}, Fs$2 = Q$2, ue$1 = Fs$2.rotr32; + function Ts$2(e2, t2, r2, i2) { + if (e2 === 0) + return df$1(t2, r2, i2); + if (e2 === 1 || e2 === 3) + return vf$1(t2, r2, i2); + if (e2 === 2) + return pf$1(t2, r2, i2); + } + ae$2.ft_1 = Ts$2; + function df$1(e2, t2, r2) { + return e2 & t2 ^ ~e2 & r2; + } + ae$2.ch32 = df$1; + function pf$1(e2, t2, r2) { + return e2 & t2 ^ e2 & r2 ^ t2 & r2; + } + ae$2.maj32 = pf$1; + function vf$1(e2, t2, r2) { + return e2 ^ t2 ^ r2; + } + ae$2.p32 = vf$1; + function Us$2(e2) { + return ue$1(e2, 2) ^ ue$1(e2, 13) ^ ue$1(e2, 22); + } + ae$2.s0_256 = Us$2; + function ks$2(e2) { + return ue$1(e2, 6) ^ ue$1(e2, 11) ^ ue$1(e2, 25); + } + ae$2.s1_256 = ks$2; + function qs$2(e2) { + return ue$1(e2, 7) ^ ue$1(e2, 18) ^ e2 >>> 3; + } + ae$2.g0_256 = qs$2; + function Ks$2(e2) { + return ue$1(e2, 17) ^ ue$1(e2, 19) ^ e2 >>> 10; + } + ae$2.g1_256 = Ks$2; + var sr$3 = Q$2, Hs$2 = fr$1, zs$2 = ae$2, _i$1 = sr$3.rotl32, wr$2 = sr$3.sum32, Ls$2 = sr$3.sum32_5, js$2 = zs$2.ft_1, mf$1 = Hs$2.BlockHash, Qs$2 = [1518500249, 1859775393, 2400959708, 3395469782]; + function he$2() { + if (!(this instanceof he$2)) + return new he$2(); + mf$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); + } + sr$3.inherits(he$2, mf$1); + var Js$2 = he$2; + he$2.blockSize = 512, he$2.outSize = 160, he$2.hmacStrength = 80, he$2.padLength = 64, he$2.prototype._update = function(t2, r2) { + for (var i2 = this.W, n2 = 0; n2 < 16; n2++) + i2[n2] = t2[r2 + n2]; + for (; n2 < i2.length; n2++) + i2[n2] = _i$1(i2[n2 - 3] ^ i2[n2 - 8] ^ i2[n2 - 14] ^ i2[n2 - 16], 1); + var o2 = this.h[0], h2 = this.h[1], p2 = this.h[2], b2 = this.h[3], m2 = this.h[4]; + for (n2 = 0; n2 < i2.length; n2++) { + var w2 = ~~(n2 / 20), y2 = Ls$2(_i$1(o2, 5), js$2(w2, h2, p2, b2), m2, i2[n2], Qs$2[w2]); + m2 = b2, b2 = p2, p2 = _i$1(h2, 30), h2 = o2, o2 = y2; + } + this.h[0] = wr$2(this.h[0], o2), this.h[1] = wr$2(this.h[1], h2), this.h[2] = wr$2(this.h[2], p2), this.h[3] = wr$2(this.h[3], b2), this.h[4] = wr$2(this.h[4], m2); + }, he$2.prototype._digest = function(t2) { + return t2 === "hex" ? sr$3.toHex32(this.h, "big") : sr$3.split32(this.h, "big"); + }; + var ar$2 = Q$2, Gs$2 = fr$1, ur$2 = ae$2, Ys$2 = yr$2, ie$4 = ar$2.sum32, Vs$2 = ar$2.sum32_4, Ws$2 = ar$2.sum32_5, Xs$2 = ur$2.ch32, Zs$2 = ur$2.maj32, $s$2 = ur$2.s0_256, ta$1 = ur$2.s1_256, ea$1 = ur$2.g0_256, ra$1 = ur$2.g1_256, gf$1 = Gs$2.BlockHash, ia$1 = [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 ce$2() { + if (!(this instanceof ce$2)) + return new ce$2(); + gf$1.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia$1, this.W = new Array(64); + } + ar$2.inherits(ce$2, gf$1); + var Af$1 = ce$2; + ce$2.blockSize = 512, ce$2.outSize = 256, ce$2.hmacStrength = 192, ce$2.padLength = 64, ce$2.prototype._update = function(t2, r2) { + for (var i2 = this.W, n2 = 0; n2 < 16; n2++) + i2[n2] = t2[r2 + n2]; + for (; n2 < i2.length; n2++) + i2[n2] = Vs$2(ra$1(i2[n2 - 2]), i2[n2 - 7], ea$1(i2[n2 - 15]), i2[n2 - 16]); + var o2 = this.h[0], h2 = this.h[1], p2 = this.h[2], b2 = this.h[3], m2 = this.h[4], w2 = this.h[5], y2 = this.h[6], S2 = this.h[7]; + for (Ys$2(this.k.length === i2.length), n2 = 0; n2 < i2.length; n2++) { + var I2 = Ws$2(S2, ta$1(m2), Xs$2(m2, w2, y2), this.k[n2], i2[n2]), N2 = ie$4($s$2(o2), Zs$2(o2, h2, p2)); + S2 = y2, y2 = w2, w2 = m2, m2 = ie$4(b2, I2), b2 = p2, p2 = h2, h2 = o2, o2 = ie$4(I2, N2); + } + this.h[0] = ie$4(this.h[0], o2), this.h[1] = ie$4(this.h[1], h2), this.h[2] = ie$4(this.h[2], p2), this.h[3] = ie$4(this.h[3], b2), this.h[4] = ie$4(this.h[4], m2), this.h[5] = ie$4(this.h[5], w2), this.h[6] = ie$4(this.h[6], y2), this.h[7] = ie$4(this.h[7], S2); + }, ce$2.prototype._digest = function(t2) { + return t2 === "hex" ? ar$2.toHex32(this.h, "big") : ar$2.split32(this.h, "big"); + }; + var Bi$1 = Q$2, bf$1 = Af$1; + function ye$3() { + if (!(this instanceof ye$3)) + return new ye$3(); + bf$1.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; + } + Bi$1.inherits(ye$3, bf$1); + var na$1 = ye$3; + ye$3.blockSize = 512, ye$3.outSize = 224, ye$3.hmacStrength = 192, ye$3.padLength = 64, ye$3.prototype._digest = function(t2) { + return t2 === "hex" ? Bi$1.toHex32(this.h.slice(0, 7), "big") : Bi$1.split32(this.h.slice(0, 7), "big"); + }; + var jt$3 = Q$2, fa$1 = fr$1, oa$1 = yr$2, le$2 = jt$3.rotr64_hi, de$3 = jt$3.rotr64_lo, yf$1 = jt$3.shr64_hi, wf$1 = jt$3.shr64_lo, Be$4 = jt$3.sum64, Ci$1 = jt$3.sum64_hi, Ri$1 = jt$3.sum64_lo, sa$1 = jt$3.sum64_4_hi, aa$1 = jt$3.sum64_4_lo, ua$1 = jt$3.sum64_5_hi, ha$1 = jt$3.sum64_5_lo, xf$1 = fa$1.BlockHash, ca$1 = [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 ne$3() { + if (!(this instanceof ne$3)) + return new ne$3(); + xf$1.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca$1, this.W = new Array(160); + } + jt$3.inherits(ne$3, xf$1); + var Mf$1 = ne$3; + ne$3.blockSize = 1024, ne$3.outSize = 512, ne$3.hmacStrength = 192, ne$3.padLength = 128, ne$3.prototype._prepareBlock = function(t2, r2) { + for (var i2 = this.W, n2 = 0; n2 < 32; n2++) + i2[n2] = t2[r2 + n2]; + for (; n2 < i2.length; n2 += 2) { + var o2 = xa$1(i2[n2 - 4], i2[n2 - 3]), h2 = Ma$1(i2[n2 - 4], i2[n2 - 3]), p2 = i2[n2 - 14], b2 = i2[n2 - 13], m2 = ya$1(i2[n2 - 30], i2[n2 - 29]), w2 = wa$1(i2[n2 - 30], i2[n2 - 29]), y2 = i2[n2 - 32], S2 = i2[n2 - 31]; + i2[n2] = sa$1(o2, h2, p2, b2, m2, w2, y2, S2), i2[n2 + 1] = aa$1(o2, h2, p2, b2, m2, w2, y2, S2); + } + }, ne$3.prototype._update = function(t2, r2) { + this._prepareBlock(t2, r2); + var i2 = this.W, n2 = this.h[0], o2 = this.h[1], h2 = this.h[2], p2 = this.h[3], b2 = this.h[4], m2 = this.h[5], w2 = this.h[6], y2 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa$1(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa$1(S2, I2), W2 = ba$1(S2, I2), Rt2 = la$1(S2, I2, N2, C2, F2), Yt2 = da$1(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f2 = i2[G2 + 1], a2 = ua$1(H2, z2, Pt2, W2, Rt2, Yt2, Y2, Vt2, A2, f2), c2 = ha$1(H2, z2, Pt2, W2, Rt2, Yt2, Y2, Vt2, A2, f2); + H2 = ma$1(n2, o2), z2 = ga$1(n2, o2), Pt2 = pa$1(n2, o2, h2, p2, b2), W2 = va$1(n2, o2, h2, p2, b2, m2); + var d2 = Ci$1(H2, z2, Pt2, W2), g2 = Ri$1(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci$1(w2, y2, a2, c2), I2 = Ri$1(y2, y2, a2, c2), w2 = b2, y2 = m2, b2 = h2, m2 = p2, h2 = n2, p2 = o2, n2 = Ci$1(a2, c2, d2, g2), o2 = Ri$1(a2, c2, d2, g2); + } + Be$4(this.h, 0, n2, o2), Be$4(this.h, 2, h2, p2), Be$4(this.h, 4, b2, m2), Be$4(this.h, 6, w2, y2), Be$4(this.h, 8, S2, I2), Be$4(this.h, 10, N2, C2), Be$4(this.h, 12, F2, U2), Be$4(this.h, 14, J2, Bt2); + }, ne$3.prototype._digest = function(t2) { + return t2 === "hex" ? jt$3.toHex32(this.h, "big") : jt$3.split32(this.h, "big"); + }; + function la$1(e2, t2, r2, i2, n2) { + var o2 = e2 & r2 ^ ~e2 & n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function da$1(e2, t2, r2, i2, n2, o2) { + var h2 = t2 & i2 ^ ~t2 & o2; + return h2 < 0 && (h2 += 4294967296), h2; + } + function pa$1(e2, t2, r2, i2, n2) { + var o2 = e2 & r2 ^ e2 & n2 ^ r2 & n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function va$1(e2, t2, r2, i2, n2, o2) { + var h2 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h2 < 0 && (h2 += 4294967296), h2; + } + function ma$1(e2, t2) { + var r2 = le$2(e2, t2, 28), i2 = le$2(t2, e2, 2), n2 = le$2(t2, e2, 7), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function ga$1(e2, t2) { + var r2 = de$3(e2, t2, 28), i2 = de$3(t2, e2, 2), n2 = de$3(t2, e2, 7), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function Aa$1(e2, t2) { + var r2 = le$2(e2, t2, 14), i2 = le$2(e2, t2, 18), n2 = le$2(t2, e2, 9), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function ba$1(e2, t2) { + var r2 = de$3(e2, t2, 14), i2 = de$3(e2, t2, 18), n2 = de$3(t2, e2, 9), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function ya$1(e2, t2) { + var r2 = le$2(e2, t2, 1), i2 = le$2(e2, t2, 8), n2 = yf$1(e2, t2, 7), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function wa$1(e2, t2) { + var r2 = de$3(e2, t2, 1), i2 = de$3(e2, t2, 8), n2 = wf$1(e2, t2, 7), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function xa$1(e2, t2) { + var r2 = le$2(e2, t2, 19), i2 = le$2(t2, e2, 29), n2 = yf$1(e2, t2, 6), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function Ma$1(e2, t2) { + var r2 = de$3(e2, t2, 19), i2 = de$3(t2, e2, 29), n2 = wf$1(e2, t2, 6), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + var Oi$1 = Q$2, Ef$1 = Mf$1; + function we$2() { + if (!(this instanceof we$2)) + return new we$2(); + Ef$1.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; + } + Oi$1.inherits(we$2, Ef$1); + var Ea$1 = we$2; + we$2.blockSize = 1024, we$2.outSize = 384, we$2.hmacStrength = 192, we$2.padLength = 128, we$2.prototype._digest = function(t2) { + return t2 === "hex" ? Oi$1.toHex32(this.h.slice(0, 12), "big") : Oi$1.split32(this.h.slice(0, 12), "big"); + }, or$2.sha1 = Js$2, or$2.sha224 = na$1, or$2.sha256 = Af$1, or$2.sha384 = Ea$1, or$2.sha512 = Mf$1; + var Sf$1 = {}, Xe$3 = Q$2, Sa$1 = fr$1, Tr$2 = Xe$3.rotl32, Nf$1 = Xe$3.sum32, xr$2 = Xe$3.sum32_3, If$1 = Xe$3.sum32_4, _f$1 = Sa$1.BlockHash; + function pe$3() { + if (!(this instanceof pe$3)) + return new pe$3(); + _f$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; + } + Xe$3.inherits(pe$3, _f$1), Sf$1.ripemd160 = pe$3, pe$3.blockSize = 512, pe$3.outSize = 160, pe$3.hmacStrength = 192, pe$3.padLength = 64, pe$3.prototype._update = function(t2, r2) { + for (var i2 = this.h[0], n2 = this.h[1], o2 = this.h[2], h2 = this.h[3], p2 = this.h[4], b2 = i2, m2 = n2, w2 = o2, y2 = h2, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf$1(Tr$2(If$1(i2, Bf$1(I2, n2, o2, h2), t2[_a$1[I2] + r2], Na$1(I2)), Ca$1[I2]), p2); + i2 = p2, p2 = h2, h2 = Tr$2(o2, 10), o2 = n2, n2 = N2, N2 = Nf$1(Tr$2(If$1(b2, Bf$1(79 - I2, m2, w2, y2), t2[Ba$1[I2] + r2], Ia$1(I2)), Ra$1[I2]), S2), b2 = S2, S2 = y2, y2 = Tr$2(w2, 10), w2 = m2, m2 = N2; + } + N2 = xr$2(this.h[1], o2, y2), this.h[1] = xr$2(this.h[2], h2, S2), this.h[2] = xr$2(this.h[3], p2, b2), this.h[3] = xr$2(this.h[4], i2, m2), this.h[4] = xr$2(this.h[0], n2, w2), this.h[0] = N2; + }, pe$3.prototype._digest = function(t2) { + return t2 === "hex" ? Xe$3.toHex32(this.h, "little") : Xe$3.split32(this.h, "little"); + }; + function Bf$1(e2, t2, r2, i2) { + return e2 <= 15 ? t2 ^ r2 ^ i2 : e2 <= 31 ? t2 & r2 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r2) ^ i2 : e2 <= 63 ? t2 & i2 | r2 & ~i2 : t2 ^ (r2 | ~i2); + } + function Na$1(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; + } + function Ia$1(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; + } + var _a$1 = [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], Ba$1 = [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], Ca$1 = [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], Ra$1 = [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], Oa$1 = Q$2, Pa$1 = yr$2; + function hr$2(e2, t2, r2) { + if (!(this instanceof hr$2)) + return new hr$2(e2, t2, r2); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa$1.toArray(t2, r2)); + } + var Da$1 = hr$2; + hr$2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa$1(t2.length <= this.blockSize); + for (var r2 = t2.length; r2 < this.blockSize; r2++) + t2.push(0); + for (r2 = 0; r2 < t2.length; r2++) + t2[r2] ^= 54; + for (this.inner = new this.Hash().update(t2), r2 = 0; r2 < t2.length; r2++) + t2[r2] ^= 106; + this.outer = new this.Hash().update(t2); + }, hr$2.prototype.update = function(t2, r2) { + return this.inner.update(t2, r2), this; + }, hr$2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); + }, function(e2) { + var t2 = e2; + t2.utils = Q$2, t2.common = fr$1, t2.sha = or$2, t2.ripemd = Sf$1, t2.hmac = Da$1, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; + }(se$3); + function cr$3(e2, t2, r2) { + return r2 = { path: t2, exports: {}, require: function(i2, n2) { + return Fa$1(i2, n2 ?? r2.path); + } }, e2(r2, r2.exports), r2.exports; + } + function Fa$1() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); + } + var Pi$1 = Cf$1; + function Cf$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); + } + Cf$1.equal = function(t2, r2, i2) { + if (t2 != r2) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r2); + }; + var fe$3 = cr$3(function(e2, t2) { + var r2 = t2; + function i2(h2, p2) { + if (Array.isArray(h2)) + return h2.slice(); + if (!h2) + return []; + var b2 = []; + if (typeof h2 != "string") { + for (var m2 = 0; m2 < h2.length; m2++) + b2[m2] = h2[m2] | 0; + return b2; + } + if (p2 === "hex") { + h2 = h2.replace(/[^a-z0-9]+/ig, ""), h2.length % 2 !== 0 && (h2 = "0" + h2); + for (var m2 = 0; m2 < h2.length; m2 += 2) + b2.push(parseInt(h2[m2] + h2[m2 + 1], 16)); + } else + for (var m2 = 0; m2 < h2.length; m2++) { + var w2 = h2.charCodeAt(m2), y2 = w2 >> 8, S2 = w2 & 255; + y2 ? b2.push(y2, S2) : b2.push(S2); + } + return b2; + } + r2.toArray = i2; + function n2(h2) { + return h2.length === 1 ? "0" + h2 : h2; + } + r2.zero2 = n2; + function o2(h2) { + for (var p2 = "", b2 = 0; b2 < h2.length; b2++) + p2 += n2(h2[b2].toString(16)); + return p2; + } + r2.toHex = o2, r2.encode = function(p2, b2) { + return b2 === "hex" ? o2(p2) : p2; + }; + }), Jt$4 = cr$3(function(e2, t2) { + var r2 = t2; + r2.assert = Pi$1, r2.toArray = fe$3.toArray, r2.zero2 = fe$3.zero2, r2.toHex = fe$3.toHex, r2.encode = fe$3.encode; + function i2(b2, m2, w2) { + var y2 = new Array(Math.max(b2.bitLength(), w2) + 1); + y2.fill(0); + for (var S2 = 1 << m2 + 1, I2 = b2.clone(), N2 = 0; N2 < y2.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y2[N2] = C2, I2.iushrn(1); + } + return y2; + } + r2.getNAF = i2; + function n2(b2, m2) { + var w2 = [[], []]; + b2 = b2.clone(), m2 = m2.clone(); + for (var y2 = 0, S2 = 0, I2; b2.cmpn(-y2) > 0 || m2.cmpn(-S2) > 0; ) { + var N2 = b2.andln(3) + y2 & 3, C2 = m2.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b2.andln(7) + y2 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w2[0].push(F2); + var U2; + C2 & 1 ? (I2 = m2.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w2[1].push(U2), 2 * y2 === F2 + 1 && (y2 = 1 - y2), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b2.iushrn(1), m2.iushrn(1); + } + return w2; + } + r2.getJSF = n2; + function o2(b2, m2, w2) { + var y2 = "_" + m2; + b2.prototype[m2] = function() { + return this[y2] !== void 0 ? this[y2] : this[y2] = w2.call(this); + }; + } + r2.cachedProperty = o2; + function h2(b2) { + return typeof b2 == "string" ? r2.toArray(b2, "hex") : b2; + } + r2.parseBytes = h2; + function p2(b2) { + return new K$3(b2, "hex", "le"); + } + r2.intFromLE = p2; + }), Ur$2 = Jt$4.getNAF, Ta$1 = Jt$4.getJSF, kr$2 = Jt$4.assert; + function Ce$2(e2, t2) { + this.type = e2, this.p = new K$3(t2.p, 16), this.red = t2.prime ? K$3.red(t2.prime) : K$3.mont(this.p), this.zero = new K$3(0).toRed(this.red), this.one = new K$3(1).toRed(this.red), this.two = new K$3(2).toRed(this.red), this.n = t2.n && new K$3(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r2 = this.n && this.p.div(this.n); + !r2 || r2.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); + } + var Ze$3 = Ce$2; + Ce$2.prototype.point = function() { + throw new Error("Not implemented"); + }, Ce$2.prototype.validate = function() { + throw new Error("Not implemented"); + }, Ce$2.prototype._fixedNafMul = function(t2, r2) { + kr$2(t2.precomputed); + var i2 = t2._getDoubles(), n2 = Ur$2(r2, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h2 = [], p2, b2; + for (p2 = 0; p2 < n2.length; p2 += i2.step) { + b2 = 0; + for (var m2 = p2 + i2.step - 1; m2 >= p2; m2--) + b2 = (b2 << 1) + n2[m2]; + h2.push(b2); + } + for (var w2 = this.jpoint(null, null, null), y2 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h2.length; p2++) + b2 = h2[p2], b2 === S2 ? y2 = y2.mixedAdd(i2.points[p2]) : b2 === -S2 && (y2 = y2.mixedAdd(i2.points[p2].neg())); + w2 = w2.add(y2); + } + return w2.toP(); + }, Ce$2.prototype._wnafMul = function(t2, r2) { + var i2 = 4, n2 = t2._getNAFPoints(i2); + i2 = n2.wnd; + for (var o2 = n2.points, h2 = Ur$2(r2, i2, this._bitLength), p2 = this.jpoint(null, null, null), b2 = h2.length - 1; b2 >= 0; b2--) { + for (var m2 = 0; b2 >= 0 && h2[b2] === 0; b2--) + m2++; + if (b2 >= 0 && m2++, p2 = p2.dblp(m2), b2 < 0) + break; + var w2 = h2[b2]; + kr$2(w2 !== 0), t2.type === "affine" ? w2 > 0 ? p2 = p2.mixedAdd(o2[w2 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w2 - 1 >> 1].neg()) : w2 > 0 ? p2 = p2.add(o2[w2 - 1 >> 1]) : p2 = p2.add(o2[-w2 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; + }, Ce$2.prototype._wnafMulAdd = function(t2, r2, i2, n2, o2) { + var h2 = this._wnafT1, p2 = this._wnafT2, b2 = this._wnafT3, m2 = 0, w2, y2, S2; + for (w2 = 0; w2 < n2; w2++) { + S2 = r2[w2]; + var I2 = S2._getNAFPoints(t2); + h2[w2] = I2.wnd, p2[w2] = I2.points; + } + for (w2 = n2 - 1; w2 >= 1; w2 -= 2) { + var N2 = w2 - 1, C2 = w2; + if (h2[N2] !== 1 || h2[C2] !== 1) { + b2[N2] = Ur$2(i2[N2], h2[N2], this._bitLength), b2[C2] = Ur$2(i2[C2], h2[C2], this._bitLength), m2 = Math.max(b2[N2].length, m2), m2 = Math.max(b2[C2].length, m2); + continue; + } + var F2 = [r2[N2], null, null, r2[C2]]; + r2[N2].y.cmp(r2[C2].y) === 0 ? (F2[1] = r2[N2].add(r2[C2]), F2[2] = r2[N2].toJ().mixedAdd(r2[C2].neg())) : r2[N2].y.cmp(r2[C2].y.redNeg()) === 0 ? (F2[1] = r2[N2].toJ().mixedAdd(r2[C2]), F2[2] = r2[N2].add(r2[C2].neg())) : (F2[1] = r2[N2].toJ().mixedAdd(r2[C2]), F2[2] = r2[N2].toJ().mixedAdd(r2[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta$1(i2[N2], i2[C2]); + for (m2 = Math.max(J2[0].length, m2), b2[N2] = new Array(m2), b2[C2] = new Array(m2), y2 = 0; y2 < m2; y2++) { + var Bt2 = J2[0][y2] | 0, G2 = J2[1][y2] | 0; + b2[N2][y2] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b2[C2][y2] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w2 = m2; w2 >= 0; w2--) { + for (var Pt2 = 0; w2 >= 0; ) { + var W2 = true; + for (y2 = 0; y2 < n2; y2++) + z2[y2] = b2[y2][w2] | 0, z2[y2] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w2--; + } + if (w2 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w2 < 0) + break; + for (y2 = 0; y2 < n2; y2++) { + var Rt2 = z2[y2]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y2][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y2][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w2 = 0; w2 < n2; w2++) + p2[w2] = null; + return o2 ? H2 : H2.toP(); + }; + function Xt$4(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; + } + Ce$2.BasePoint = Xt$4, Xt$4.prototype.eq = function() { + throw new Error("Not implemented"); + }, Xt$4.prototype.validate = function() { + return this.curve.validate(this); + }, Ce$2.prototype.decodePoint = function(t2, r2) { + t2 = Jt$4.toArray(t2, r2); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr$2(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr$2(t2[t2.length - 1] % 2 === 1); + var n2 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n2; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); + }, Xt$4.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); + }, Xt$4.prototype._encode = function(t2) { + var r2 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r2); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r2)); + }, Xt$4.prototype.encode = function(t2, r2) { + return Jt$4.encode(this._encode(r2), t2); + }, Xt$4.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r2 = { doubles: null, naf: null, beta: null }; + return r2.naf = this._getNAFPoints(8), r2.doubles = this._getDoubles(4, t2), r2.beta = this._getBeta(), this.precomputed = r2, this; + }, Xt$4.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r2 = this.precomputed.doubles; + return r2 ? r2.points.length >= Math.ceil((t2.bitLength() + 1) / r2.step) : false; + }, Xt$4.prototype._getDoubles = function(t2, r2) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n2 = this, o2 = 0; o2 < r2; o2 += t2) { + for (var h2 = 0; h2 < t2; h2++) + n2 = n2.dbl(); + i2.push(n2); + } + return { step: t2, points: i2 }; + }, Xt$4.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r2 = [this], i2 = (1 << t2) - 1, n2 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r2[o2] = r2[o2 - 1].add(n2); + return { wnd: t2, points: r2 }; + }, Xt$4.prototype._getBeta = function() { + return null; + }, Xt$4.prototype.dblp = function(t2) { + for (var r2 = this, i2 = 0; i2 < t2; i2++) + r2 = r2.dbl(); + return r2; + }; + var Di$1 = cr$3(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r2, i2) { + i2 && (r2.super_ = i2, r2.prototype = Object.create(i2.prototype, { constructor: { value: r2, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r2, i2) { + if (i2) { + r2.super_ = i2; + var n2 = function() { + }; + n2.prototype = i2.prototype, r2.prototype = new n2(), r2.prototype.constructor = r2; + } + }; + }), Ua$1 = Jt$4.assert; + function Zt$3(e2) { + Ze$3.call(this, "short", e2), this.a = new K$3(e2.a, 16).toRed(this.red), this.b = new K$3(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); + } + Di$1(Zt$3, Ze$3); + var ka$1 = Zt$3; + Zt$3.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r2, i2; + if (t2.beta) + r2 = new K$3(t2.beta, 16).toRed(this.red); + else { + var n2 = this._getEndoRoots(this.p); + r2 = n2[0].cmp(n2[1]) < 0 ? n2[0] : n2[1], r2 = r2.toRed(this.red); + } + if (t2.lambda) + i2 = new K$3(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r2)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua$1(this.g.mul(i2).x.cmp(this.g.x.redMul(r2)) === 0)); + } + var h2; + return t2.basis ? h2 = t2.basis.map(function(p2) { + return { a: new K$3(p2.a, 16), b: new K$3(p2.b, 16) }; + }) : h2 = this._getEndoBasis(i2), { beta: r2, lambda: i2, basis: h2 }; + } + }, Zt$3.prototype._getEndoRoots = function(t2) { + var r2 = t2 === this.p ? this.red : K$3.mont(t2), i2 = new K$3(2).toRed(r2).redInvm(), n2 = i2.redNeg(), o2 = new K$3(3).toRed(r2).redNeg().redSqrt().redMul(i2), h2 = n2.redAdd(o2).fromRed(), p2 = n2.redSub(o2).fromRed(); + return [h2, p2]; + }, Zt$3.prototype._getEndoBasis = function(t2) { + for (var r2 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n2 = this.n.clone(), o2 = new K$3(1), h2 = new K$3(0), p2 = new K$3(0), b2 = new K$3(1), m2, w2, y2, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n2.div(i2); + U2 = n2.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b2.sub(Bt2.mul(h2)); + if (!y2 && U2.cmp(r2) < 0) + m2 = C2.neg(), w2 = o2, y2 = U2.neg(), S2 = J2; + else if (y2 && ++F2 === 2) + break; + C2 = U2, n2 = i2, i2 = U2, p2 = o2, o2 = J2, b2 = h2, h2 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y2.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m2, N2 = w2), y2.negative && (y2 = y2.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y2, b: S2 }, { a: I2, b: N2 }]; + }, Zt$3.prototype._endoSplit = function(t2) { + var r2 = this.endo.basis, i2 = r2[0], n2 = r2[1], o2 = n2.b.mul(t2).divRound(this.n), h2 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b2 = h2.mul(n2.a), m2 = o2.mul(i2.b), w2 = h2.mul(n2.b), y2 = t2.sub(p2).sub(b2), S2 = m2.add(w2).neg(); + return { k1: y2, k2: S2 }; + }, Zt$3.prototype.pointFromX = function(t2, r2) { + t2 = new K$3(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n2 = i2.redSqrt(); + if (n2.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n2.fromRed().isOdd(); + return (r2 && !o2 || !r2 && o2) && (n2 = n2.redNeg()), this.point(t2, n2); + }, Zt$3.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r2 = t2.x, i2 = t2.y, n2 = this.a.redMul(r2), o2 = r2.redSqr().redMul(r2).redIAdd(n2).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; + }, Zt$3.prototype._endoWnafMulAdd = function(t2, r2, i2) { + for (var n2 = this._endoWnafT1, o2 = this._endoWnafT2, h2 = 0; h2 < t2.length; h2++) { + var p2 = this._endoSplit(r2[h2]), b2 = t2[h2], m2 = b2._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b2 = b2.neg(true)), p2.k2.negative && (p2.k2.ineg(), m2 = m2.neg(true)), n2[h2 * 2] = b2, n2[h2 * 2 + 1] = m2, o2[h2 * 2] = p2.k1, o2[h2 * 2 + 1] = p2.k2; + } + for (var w2 = this._wnafMulAdd(1, n2, o2, h2 * 2, i2), y2 = 0; y2 < h2 * 2; y2++) + n2[y2] = null, o2[y2] = null; + return w2; + }; + function Ft$3(e2, t2, r2, i2) { + Ze$3.BasePoint.call(this, e2, "affine"), t2 === null && r2 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K$3(t2, 16), this.y = new K$3(r2, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); + } + Di$1(Ft$3, Ze$3.BasePoint), Zt$3.prototype.point = function(t2, r2, i2) { + return new Ft$3(this, t2, r2, i2); + }, Zt$3.prototype.pointFromJSON = function(t2, r2) { + return Ft$3.fromJSON(this, t2, r2); + }, Ft$3.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r2 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n2 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r2, r2.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n2) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n2) } }; + } + return r2; + } + }, Ft$3.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; + }, Ft$3.fromJSON = function(t2, r2, i2) { + typeof r2 == "string" && (r2 = JSON.parse(r2)); + var n2 = t2.point(r2[0], r2[1], i2); + if (!r2[2]) + return n2; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h2 = r2[2]; + return n2.precomputed = { beta: null, doubles: h2.doubles && { step: h2.doubles.step, points: [n2].concat(h2.doubles.points.map(o2)) }, naf: h2.naf && { wnd: h2.naf.wnd, points: [n2].concat(h2.naf.points.map(o2)) } }, n2; + }, Ft$3.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, Ft$3.prototype.isInfinity = function() { + return this.inf; + }, Ft$3.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r2 = this.y.redSub(t2.y); + r2.cmpn(0) !== 0 && (r2 = r2.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r2.redSqr().redISub(this.x).redISub(t2.x), n2 = r2.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n2); + }, Ft$3.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r2 = this.curve.a, i2 = this.x.redSqr(), n2 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r2).redMul(n2), h2 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h2)).redISub(this.y); + return this.curve.point(h2, p2); + }, Ft$3.prototype.getX = function() { + return this.x.fromRed(); + }, Ft$3.prototype.getY = function() { + return this.y.fromRed(); + }, Ft$3.prototype.mul = function(t2) { + return t2 = new K$3(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); + }, Ft$3.prototype.mulAdd = function(t2, r2, i2) { + var n2 = [this, r2], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n2, o2) : this.curve._wnafMulAdd(1, n2, o2, 2); + }, Ft$3.prototype.jmulAdd = function(t2, r2, i2) { + var n2 = [this, r2], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n2, o2, true) : this.curve._wnafMulAdd(1, n2, o2, 2, true); + }, Ft$3.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); + }, Ft$3.prototype.neg = function(t2) { + if (this.inf) + return this; + var r2 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n2 = function(o2) { + return o2.neg(); + }; + r2.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n2) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n2) } }; + } + return r2; + }, Ft$3.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; + }; + function Tt$3(e2, t2, r2, i2) { + Ze$3.BasePoint.call(this, e2, "jacobian"), t2 === null && r2 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K$3(0)) : (this.x = new K$3(t2, 16), this.y = new K$3(r2, 16), this.z = new K$3(i2, 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; + } + Di$1(Tt$3, Ze$3.BasePoint), Zt$3.prototype.jpoint = function(t2, r2, i2) { + return new Tt$3(this, t2, r2, i2); + }, Tt$3.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r2 = t2.redSqr(), i2 = this.x.redMul(r2), n2 = this.y.redMul(r2).redMul(t2); + return this.curve.point(i2, n2); + }, Tt$3.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }, Tt$3.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r2 = t2.z.redSqr(), i2 = this.z.redSqr(), n2 = this.x.redMul(r2), o2 = t2.x.redMul(i2), h2 = this.y.redMul(r2.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b2 = n2.redSub(o2), m2 = h2.redSub(p2); + if (b2.cmpn(0) === 0) + return m2.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w2 = b2.redSqr(), y2 = w2.redMul(b2), S2 = n2.redMul(w2), I2 = m2.redSqr().redIAdd(y2).redISub(S2).redISub(S2), N2 = m2.redMul(S2.redISub(I2)).redISub(h2.redMul(y2)), C2 = this.z.redMul(t2.z).redMul(b2); + return this.curve.jpoint(I2, N2, C2); + }, Tt$3.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r2 = this.z.redSqr(), i2 = this.x, n2 = t2.x.redMul(r2), o2 = this.y, h2 = t2.y.redMul(r2).redMul(this.z), p2 = i2.redSub(n2), b2 = o2.redSub(h2); + if (p2.cmpn(0) === 0) + return b2.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m2 = p2.redSqr(), w2 = m2.redMul(p2), y2 = i2.redMul(m2), S2 = b2.redSqr().redIAdd(w2).redISub(y2).redISub(y2), I2 = b2.redMul(y2.redISub(S2)).redISub(o2.redMul(w2)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); + }, Tt$3.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r2; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r2 = 0; r2 < t2; r2++) + i2 = i2.dbl(); + return i2; + } + var n2 = this.curve.a, o2 = this.curve.tinv, h2 = this.x, p2 = this.y, b2 = this.z, m2 = b2.redSqr().redSqr(), w2 = p2.redAdd(p2); + for (r2 = 0; r2 < t2; r2++) { + var y2 = h2.redSqr(), S2 = w2.redSqr(), I2 = S2.redSqr(), N2 = y2.redAdd(y2).redIAdd(y2).redIAdd(n2.redMul(m2)), C2 = h2.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w2.redMul(b2); + r2 + 1 < t2 && (m2 = m2.redMul(I2)), h2 = F2, b2 = Bt2, w2 = J2; + } + return this.curve.jpoint(h2, w2.redMul(o2), b2); + }, Tt$3.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); + }, Tt$3.prototype._zeroDbl = function() { + var t2, r2, i2; + if (this.zOne) { + var n2 = this.x.redSqr(), o2 = this.y.redSqr(), h2 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n2).redISub(h2); + p2 = p2.redIAdd(p2); + var b2 = n2.redAdd(n2).redIAdd(n2), m2 = b2.redSqr().redISub(p2).redISub(p2), w2 = h2.redIAdd(h2); + w2 = w2.redIAdd(w2), w2 = w2.redIAdd(w2), t2 = m2, r2 = b2.redMul(p2.redISub(m2)).redISub(w2), i2 = this.y.redAdd(this.y); + } else { + var y2 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y2).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y2.redAdd(y2).redIAdd(y2), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r2 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r2, i2); + }, Tt$3.prototype._threeDbl = function() { + var t2, r2, i2; + if (this.zOne) { + var n2 = this.x.redSqr(), o2 = this.y.redSqr(), h2 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n2).redISub(h2); + p2 = p2.redIAdd(p2); + var b2 = n2.redAdd(n2).redIAdd(n2).redIAdd(this.curve.a), m2 = b2.redSqr().redISub(p2).redISub(p2); + t2 = m2; + var w2 = h2.redIAdd(h2); + w2 = w2.redIAdd(w2), w2 = w2.redIAdd(w2), r2 = b2.redMul(p2.redISub(m2)).redISub(w2), i2 = this.y.redAdd(this.y); + } else { + var y2 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y2).redMul(this.x.redAdd(y2)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y2); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r2 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r2, i2); + }, Tt$3.prototype._dbl = function() { + var t2 = this.curve.a, r2 = this.x, i2 = this.y, n2 = this.z, o2 = n2.redSqr().redSqr(), h2 = r2.redSqr(), p2 = i2.redSqr(), b2 = h2.redAdd(h2).redIAdd(h2).redIAdd(t2.redMul(o2)), m2 = r2.redAdd(r2); + m2 = m2.redIAdd(m2); + var w2 = m2.redMul(p2), y2 = b2.redSqr().redISub(w2.redAdd(w2)), S2 = w2.redISub(y2), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b2.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n2); + return this.curve.jpoint(y2, N2, C2); + }, Tt$3.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r2 = this.y.redSqr(), i2 = this.z.redSqr(), n2 = r2.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h2 = o2.redSqr(), p2 = this.x.redAdd(r2).redSqr().redISub(t2).redISub(n2); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h2); + var b2 = p2.redSqr(), m2 = n2.redIAdd(n2); + m2 = m2.redIAdd(m2), m2 = m2.redIAdd(m2), m2 = m2.redIAdd(m2); + var w2 = o2.redIAdd(p2).redSqr().redISub(h2).redISub(b2).redISub(m2), y2 = r2.redMul(w2); + y2 = y2.redIAdd(y2), y2 = y2.redIAdd(y2); + var S2 = this.x.redMul(b2).redISub(y2); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w2.redMul(m2.redISub(w2)).redISub(p2.redMul(b2))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b2); + return this.curve.jpoint(S2, I2, N2); + }, Tt$3.prototype.mul = function(t2, r2) { + return t2 = new K$3(t2, r2), this.curve._wnafMul(this, t2); + }, Tt$3.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r2 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r2)).cmpn(0) !== 0) + return false; + var n2 = r2.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n2)).cmpn(0) === 0; + }, Tt$3.prototype.eqXToP = function(t2) { + var r2 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r2); + if (this.x.cmp(i2) === 0) + return true; + for (var n2 = t2.clone(), o2 = this.curve.redN.redMul(r2); ; ) { + if (n2.iadd(this.curve.n), n2.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } + }, Tt$3.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, Tt$3.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; + }; + var qr$1 = cr$3(function(e2, t2) { + var r2 = t2; + r2.base = Ze$3, r2.short = ka$1, r2.mont = null, r2.edwards = null; + }), Kr$1 = cr$3(function(e2, t2) { + var r2 = t2, i2 = Jt$4.assert; + function n2(p2) { + p2.type === "short" ? this.curve = new qr$1.short(p2) : p2.type === "edwards" ? this.curve = new qr$1.edwards(p2) : this.curve = new qr$1.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r2.PresetCurve = n2; + function o2(p2, b2) { + Object.defineProperty(r2, p2, { configurable: true, enumerable: true, get: function() { + var m2 = new n2(b2); + return Object.defineProperty(r2, p2, { configurable: true, enumerable: true, value: m2 }), m2; + } }); + } + o2("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: se$3.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se$3.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se$3.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se$3.sha384, gRed: false, 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"] }), o2("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: se$3.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se$3.sha256, gRed: false, g: ["9"] }), o2("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: se$3.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h2; + try { + h2 = null.crash(); + } catch { + h2 = void 0; + } + o2("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: se$3.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h2] }); + }); + function Re$3(e2) { + if (!(this instanceof Re$3)) + return new Re$3(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe$3.toArray(e2.entropy, e2.entropyEnc || "hex"), r2 = fe$3.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe$3.toArray(e2.pers, e2.persEnc || "hex"); + Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r2, i2); + } + var Rf$1 = Re$3; + Re$3.prototype._init = function(t2, r2, i2) { + var n2 = t2.concat(r2).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n2), this._reseed = 1, this.reseedInterval = 281474976710656; + }, Re$3.prototype._hmac = function() { + return new se$3.hmac(this.hash, this.K); + }, Re$3.prototype._update = function(t2) { + var r2 = this._hmac().update(this.V).update([0]); + t2 && (r2 = r2.update(t2)), this.K = r2.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); + }, Re$3.prototype.reseed = function(t2, r2, i2, n2) { + typeof r2 != "string" && (n2 = i2, i2 = r2, r2 = null), t2 = fe$3.toArray(t2, r2), i2 = fe$3.toArray(i2, n2), Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; + }, Re$3.prototype.generate = function(t2, r2, i2, n2) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r2 != "string" && (n2 = i2, i2 = r2, r2 = null), i2 && (i2 = fe$3.toArray(i2, n2 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h2 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe$3.encode(h2, r2); + }; + var Fi$1 = Jt$4.assert; + function kt$2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); + } + var Ti$1 = kt$2; + kt$2.fromPublic = function(t2, r2, i2) { + return r2 instanceof kt$2 ? r2 : new kt$2(t2, { pub: r2, pubEnc: i2 }); + }, kt$2.fromPrivate = function(t2, r2, i2) { + return r2 instanceof kt$2 ? r2 : new kt$2(t2, { priv: r2, privEnc: i2 }); + }, kt$2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; + }, kt$2.prototype.getPublic = function(t2, r2) { + return typeof t2 == "string" && (r2 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r2 ? this.pub.encode(r2, t2) : this.pub; + }, kt$2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; + }, kt$2.prototype._importPrivate = function(t2, r2) { + this.priv = new K$3(t2, r2 || 16), this.priv = this.priv.umod(this.ec.curve.n); + }, kt$2.prototype._importPublic = function(t2, r2) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi$1(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi$1(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r2); + }, kt$2.prototype.derive = function(t2) { + return t2.validate() || Fi$1(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); + }, kt$2.prototype.sign = function(t2, r2, i2) { + return this.ec.sign(t2, this, r2, i2); + }, kt$2.prototype.verify = function(t2, r2) { + return this.ec.verify(t2, r2, this); + }, kt$2.prototype.inspect = function() { + return ""; + }; + var qa$1 = Jt$4.assert; + function Hr$1(e2, t2) { + if (e2 instanceof Hr$1) + return e2; + this._importDER(e2, t2) || (qa$1(e2.r && e2.s, "Signature without r or s"), this.r = new K$3(e2.r, 16), this.s = new K$3(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); + } + var zr$2 = Hr$1; + function Ka$1() { + this.place = 0; + } + function Ui$1(e2, t2) { + var r2 = e2[t2.place++]; + if (!(r2 & 128)) + return r2; + var i2 = r2 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n2 = 0, o2 = 0, h2 = t2.place; o2 < i2; o2++, h2++) + n2 <<= 8, n2 |= e2[h2], n2 >>>= 0; + return n2 <= 127 ? false : (t2.place = h2, n2); + } + function Of$1(e2) { + for (var t2 = 0, r2 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r2; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); + } + Hr$1.prototype._importDER = function(t2, r2) { + t2 = Jt$4.toArray(t2, r2); + var i2 = new Ka$1(); + if (t2[i2.place++] !== 48) + return false; + var n2 = Ui$1(t2, i2); + if (n2 === false || n2 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui$1(t2, i2); + if (o2 === false) + return false; + var h2 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui$1(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b2 = t2.slice(i2.place, p2 + i2.place); + if (h2[0] === 0) + if (h2[1] & 128) + h2 = h2.slice(1); + else + return false; + if (b2[0] === 0) + if (b2[1] & 128) + b2 = b2.slice(1); + else + return false; + return this.r = new K$3(h2), this.s = new K$3(b2), this.recoveryParam = null, true; + }; + function ki$1(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r2 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r2 | 128); --r2; ) + e2.push(t2 >>> (r2 << 3) & 255); + e2.push(t2); + } + Hr$1.prototype.toDER = function(t2) { + var r2 = this.r.toArray(), i2 = this.s.toArray(); + for (r2[0] & 128 && (r2 = [0].concat(r2)), i2[0] & 128 && (i2 = [0].concat(i2)), r2 = Of$1(r2), i2 = Of$1(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n2 = [2]; + ki$1(n2, r2.length), n2 = n2.concat(r2), n2.push(2), ki$1(n2, i2.length); + var o2 = n2.concat(i2), h2 = [48]; + return ki$1(h2, o2.length), h2 = h2.concat(o2), Jt$4.encode(h2, t2); + }; + var Ha$1 = function() { + throw new Error("unsupported"); + }, Pf$1 = Jt$4.assert; + function $t$3(e2) { + if (!(this instanceof $t$3)) + return new $t$3(e2); + typeof e2 == "string" && (Pf$1(Object.prototype.hasOwnProperty.call(Kr$1, e2), "Unknown curve " + e2), e2 = Kr$1[e2]), e2 instanceof Kr$1.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; + } + var za$1 = $t$3; + $t$3.prototype.keyPair = function(t2) { + return new Ti$1(this, t2); + }, $t$3.prototype.keyFromPrivate = function(t2, r2) { + return Ti$1.fromPrivate(this, t2, r2); + }, $t$3.prototype.keyFromPublic = function(t2, r2) { + return Ti$1.fromPublic(this, t2, r2); + }, $t$3.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r2 = new Rf$1({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha$1(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n2 = this.n.sub(new K$3(2)); ; ) { + var o2 = new K$3(r2.generate(i2)); + if (!(o2.cmp(n2) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } + }, $t$3.prototype._truncateToN = function(t2, r2) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r2 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; + }, $t$3.prototype.sign = function(t2, r2, i2, n2) { + typeof i2 == "object" && (n2 = i2, i2 = null), n2 || (n2 = {}), r2 = this.keyFromPrivate(r2, i2), t2 = this._truncateToN(new K$3(t2, 16)); + for (var o2 = this.n.byteLength(), h2 = r2.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b2 = new Rf$1({ hash: this.hash, entropy: h2, nonce: p2, pers: n2.pers, persEnc: n2.persEnc || "utf8" }), m2 = this.n.sub(new K$3(1)), w2 = 0; ; w2++) { + var y2 = n2.k ? n2.k(w2) : new K$3(b2.generate(this.n.byteLength())); + if (y2 = this._truncateToN(y2, true), !(y2.cmpn(1) <= 0 || y2.cmp(m2) >= 0)) { + var S2 = this.g.mul(y2); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y2.invm(this.n).mul(N2.mul(r2.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n2.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr$2({ r: N2, s: C2, recoveryParam: F2 }); + } + } + } + } + } + }, $t$3.prototype.verify = function(t2, r2, i2, n2) { + t2 = this._truncateToN(new K$3(t2, 16)), i2 = this.keyFromPublic(i2, n2), r2 = new zr$2(r2, "hex"); + var o2 = r2.r, h2 = r2.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h2.cmpn(1) < 0 || h2.cmp(this.n) >= 0) + return false; + var p2 = h2.invm(this.n), b2 = p2.mul(t2).umod(this.n), m2 = p2.mul(o2).umod(this.n), w2; + return this.curve._maxwellTrick ? (w2 = this.g.jmulAdd(b2, i2.getPublic(), m2), w2.isInfinity() ? false : w2.eqXToP(o2)) : (w2 = this.g.mulAdd(b2, i2.getPublic(), m2), w2.isInfinity() ? false : w2.getX().umod(this.n).cmp(o2) === 0); + }, $t$3.prototype.recoverPubKey = function(e2, t2, r2, i2) { + Pf$1((3 & r2) === r2, "The recovery param is more than two bits"), t2 = new zr$2(t2, i2); + var n2 = this.n, o2 = new K$3(e2), h2 = t2.r, p2 = t2.s, b2 = r2 & 1, m2 = r2 >> 1; + if (h2.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m2) + throw new Error("Unable to find sencond key candinate"); + m2 ? h2 = this.curve.pointFromX(h2.add(this.curve.n), b2) : h2 = this.curve.pointFromX(h2, b2); + var w2 = t2.r.invm(n2), y2 = n2.sub(o2).mul(w2).umod(n2), S2 = p2.mul(w2).umod(n2); + return this.g.mulAdd(y2, h2, S2); + }, $t$3.prototype.getKeyRecoveryParam = function(e2, t2, r2, i2) { + if (t2 = new zr$2(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n2 = 0; n2 < 4; n2++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n2); + } catch { + continue; + } + if (o2.eq(r2)) + return n2; + } + throw new Error("Unable to find valid recovery factor"); + }; + var La$1 = cr$3(function(e2, t2) { + var r2 = t2; + r2.version = "6.5.4", r2.utils = Jt$4, r2.rand = function() { + throw new Error("unsupported"); + }, r2.curve = qr$1, r2.curves = Kr$1, r2.ec = za$1, r2.eddsa = null; + }), ja = La$1.ec; + const Qa = "signing-key/5.7.0", qi = new L$5(Qa); + let Ki = null; + function ve$1() { + return Ki || (Ki = new ja("secp256k1")), Ki; } - function Re$1(e2) { - if (j$2(e2.type) === _$3) { - if (typeof e2.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - return toString(concat([e2.type, e2.senderPublicKey, e2.iv, e2.sealed]), F$3); + class Ja { + constructor(t2) { + br$1(this, "curve", "secp256k1"), br$1(this, "privateKey", Kt$3(t2)), N0(this.privateKey) !== 32 && qi.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); + const r2 = ve$1().keyFromPrivate(Ot$3(this.privateKey)); + br$1(this, "publicKey", "0x" + r2.getPublic(false, "hex")), br$1(this, "compressedPublicKey", "0x" + r2.getPublic(true, "hex")), br$1(this, "_isSigningKey", true); + } + _addPoint(t2) { + const r2 = ve$1().keyFromPublic(Ot$3(this.publicKey)), i2 = ve$1().keyFromPublic(Ot$3(t2)); + return "0x" + r2.pub.add(i2.pub).encodeCompressed("hex"); + } + signDigest(t2) { + const r2 = ve$1().keyFromPrivate(Ot$3(this.privateKey)), i2 = Ot$3(t2); + i2.length !== 32 && qi.throwArgumentError("bad digest length", "digest", t2); + const n2 = r2.sign(i2, { canonical: true }); + return zn({ recoveryParam: n2.recoveryParam, r: oe$1("0x" + n2.r.toString(16), 32), s: oe$1("0x" + n2.s.toString(16), 32) }); + } + computeSharedSecret(t2) { + const r2 = ve$1().keyFromPrivate(Ot$3(this.privateKey)), i2 = ve$1().keyFromPublic(Ot$3(Df(t2))); + return oe$1("0x" + r2.derive(i2.getPublic()).toString(16), 32); + } + static isSigningKey(t2) { + return !!(t2 && t2._isSigningKey); } - return toString(concat([e2.type, e2.iv, e2.sealed]), F$3); } - function ee$2(e2) { - const n2 = fromString(e2, F$3), t2 = n2.slice(Dn, Te$1), r2 = Te$1; - if (j$2(t2) === _$3) { - const d2 = r2 + X$1, l2 = d2 + Z$3, c2 = n2.slice(r2, d2), u2 = n2.slice(d2, l2), a2 = n2.slice(l2); - return { type: t2, sealed: a2, iv: u2, senderPublicKey: c2 }; + function Ga(e2, t2) { + const r2 = zn(t2), i2 = { r: Ot$3(r2.r), s: Ot$3(r2.s) }; + return "0x" + ve$1().recoverPubKey(Ot$3(e2), i2, r2.recoveryParam).encode("hex", false); + } + function Df(e2, t2) { + const r2 = Ot$3(e2); + if (r2.length === 32) { + const i2 = new Ja(r2); + return i2.publicKey; + } else { + if (r2.length === 33) + return "0x" + ve$1().keyFromPublic(r2).getPublic(false, "hex"); + if (r2.length === 65) + return Kt$3(r2); + } + return qi.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); + } + var Ff$1; + (function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; + })(Ff$1 || (Ff$1 = {})); + function Va(e2) { + const t2 = Df(e2); + return ns$1(Hn(yi(Hn(t2, 1)), 12)); + } + function Wa(e2, t2) { + return Va(Ga(Ot$3(e2), t2)); + } + const Xa = "https://rpc.walletconnect.com/v1"; + async function Tf(e2, t2, r2, i2, n2, o2) { + switch (r2.t) { + case "eip191": + return Uf(e2, t2, r2.s); + case "eip1271": + return await kf(e2, t2, r2.s, i2, n2, o2); + default: + throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r2.t}`); } - const o2 = r2 + Z$3, s2 = n2.slice(r2, o2), i2 = n2.slice(o2); - return { type: t2, sealed: i2, iv: s2 }; } - function Hn(e2, n2) { - const t2 = ee$2(e2); - return Ae$1({ type: j$2(t2.type), senderPublicKey: typeof t2.senderPublicKey < "u" ? toString(t2.senderPublicKey, p$2) : void 0, receiverPublicKey: n2 == null ? void 0 : n2.receiverPublicKey }); + function Uf(e2, t2, r2) { + return Wa(ff(t2), r2).toLowerCase() === e2.toLowerCase(); } - function Ae$1(e2) { - const n2 = (e2 == null ? void 0 : e2.type) || Q$3; - if (n2 === _$3) { - if (typeof (e2 == null ? void 0 : e2.senderPublicKey) > "u") - throw new Error("missing sender public key"); - if (typeof (e2 == null ? void 0 : e2.receiverPublicKey) > "u") - throw new Error("missing receiver public key"); + async function kf(e2, t2, r2, i2, n2, o2) { + try { + const h2 = "0x1626ba7e", p2 = "0000000000000000000000000000000000000000000000000000000000000040", b2 = "0000000000000000000000000000000000000000000000000000000000000041", m2 = r2.substring(2), w2 = ff(t2).substring(2), y2 = h2 + w2 + p2 + b2 + m2, S2 = await fetch(`${o2 || Xa}/?chainId=${i2}&projectId=${n2}`, { method: "POST", body: JSON.stringify({ id: Za(), jsonrpc: "2.0", method: "eth_call", params: [{ to: e2, data: y2 }, "latest"] }) }), { result: I2 } = await S2.json(); + return I2 ? I2.slice(0, h2.length).toLowerCase() === h2.toLowerCase() : false; + } catch (h2) { + return console.error("isValidEip1271Signature: ", h2), false; } - return { type: n2, senderPublicKey: e2 == null ? void 0 : e2.senderPublicKey, receiverPublicKey: e2 == null ? void 0 : e2.receiverPublicKey }; } - function qn(e2) { - return e2.type === _$3 && typeof e2.senderPublicKey == "string" && typeof e2.receiverPublicKey == "string"; + function Za() { + return Date.now() + Math.floor(Math.random() * 1e3); } - var Bn = Object.defineProperty, Ue$2 = Object.getOwnPropertySymbols, Gn = Object.prototype.hasOwnProperty, Wn = Object.prototype.propertyIsEnumerable, _e$1 = (e2, n2, t2) => n2 in e2 ? Bn(e2, n2, { enumerable: true, configurable: true, writable: true, value: t2 }) : e2[n2] = t2, $e$2 = (e2, n2) => { - for (var t2 in n2 || (n2 = {})) - Gn.call(n2, t2) && _e$1(e2, t2, n2[t2]); - if (Ue$2) - for (var t2 of Ue$2(n2)) - Wn.call(n2, t2) && _e$1(e2, t2, n2[t2]); + var $a = Object.defineProperty, tu = Object.defineProperties, eu = Object.getOwnPropertyDescriptors, qf = Object.getOwnPropertySymbols, ru = Object.prototype.hasOwnProperty, iu = Object.prototype.propertyIsEnumerable, Kf = (e2, t2, r2) => t2 in e2 ? $a(e2, t2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[t2] = r2, Hi$1 = (e2, t2) => { + for (var r2 in t2 || (t2 = {})) + ru.call(t2, r2) && Kf(e2, r2, t2[r2]); + if (qf) + for (var r2 of qf(t2)) + iu.call(t2, r2) && Kf(e2, r2, t2[r2]); return e2; - }; - const Ce$1 = "ReactNative", m$2 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, De$2 = "js"; - function te$2() { - return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; + }, Hf = (e2, t2) => tu(e2, eu(t2)); + const nu = "did:pkh:", Lr$1 = (e2) => e2 == null ? void 0 : e2.split(":"), zi = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return e2.includes(nu) ? t2[3] : t2[1]; + }, fu = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2[2] + ":" + t2[3]; + }, Li = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2.pop(); + }; + async function ou(e2) { + const { cacao: t2, projectId: r2 } = e2, { s: i2, p: n2 } = t2, o2 = zf(n2, n2.iss), h2 = Li(n2.iss); + return await Tf(h2, o2, i2, zi(n2.iss), r2); + } + const zf = (e2, t2) => { + const r2 = `${e2.domain} wants you to sign in with your Ethereum account:`, i2 = Li(t2); + if (!e2.aud && !e2.uri) + throw new Error("Either `aud` or `uri` is required to construct the message"); + let n2 = e2.statement || void 0; + const o2 = `URI: ${e2.aud || e2.uri}`, h2 = `Version: ${e2.version}`, p2 = `Chain ID: ${zi(t2)}`, b2 = `Nonce: ${e2.nonce}`, m2 = `Issued At: ${e2.iat}`, w2 = e2.resources ? `Resources:${e2.resources.map((S2) => ` +- ${S2}`).join("")}` : void 0, y2 = Qr(e2.resources); + if (y2) { + const S2 = Oe$1(y2); + n2 = Ji$1(n2, S2); + } + return [r2, i2, "", n2, "", o2, h2, p2, b2, m2, w2].filter((S2) => S2 != null).join(` +`); + }; + function Jf(e2) { + return Buffer.from(JSON.stringify(e2)).toString("base64"); + } + function Gf(e2) { + return JSON.parse(Buffer.from(e2, "base64").toString("utf-8")); + } + function me$2(e2) { + if (!e2) + throw new Error("No recap provided, value is undefined"); + if (!e2.att) + throw new Error("No `att` property found"); + const t2 = Object.keys(e2.att); + if (!(t2 != null && t2.length)) + throw new Error("No resources found in `att` property"); + t2.forEach((r2) => { + const i2 = e2.att[r2]; + if (Array.isArray(i2)) + throw new Error(`Resource must be an object: ${r2}`); + if (typeof i2 != "object") + throw new Error(`Resource must be an object: ${r2}`); + if (!Object.keys(i2).length) + throw new Error(`Resource object is empty: ${r2}`); + Object.keys(i2).forEach((n2) => { + const o2 = i2[n2]; + if (!Array.isArray(o2)) + throw new Error(`Ability limits ${n2} must be an array of objects, found: ${o2}`); + if (!o2.length) + throw new Error(`Value of ${n2} is empty array, must be an array with objects`); + o2.forEach((h2) => { + if (typeof h2 != "object") + throw new Error(`Ability limits (${n2}) must be an array of objects, found: ${h2}`); + }); + }); + }); } - function $$2() { - return !getDocument_1() && !!getNavigator_1() && navigator.product === Ce$1; + function Yf(e2, t2, r2, i2 = {}) { + return r2 == null ? void 0 : r2.sort((n2, o2) => n2.localeCompare(o2)), { att: { [e2]: ji(t2, r2, i2) } }; } - function D$4() { - return !te$2() && !!getNavigator_1() && !!getDocument_1(); + function ji(e2, t2, r2 = {}) { + t2 = t2 == null ? void 0 : t2.sort((n2, o2) => n2.localeCompare(o2)); + const i2 = t2.map((n2) => ({ [`${e2}/${n2}`]: [r2] })); + return Object.assign({}, ...i2); } - function R$3() { - return $$2() ? m$2.reactNative : te$2() ? m$2.node : D$4() ? m$2.browser : m$2.unknown; + function jr(e2) { + return me$2(e2), `urn:recap:${Jf(e2).replace(/=/g, "")}`; } - function Jn() { - var e2; - try { - return $$2() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e2 = global.Application) == null ? void 0 : e2.applicationId : void 0; - } catch { - return; - } + function Oe$1(e2) { + const t2 = Gf(e2.replace("urn:recap:", "")); + return me$2(t2), t2; } - function ke$2(e2, n2) { - let t2 = queryString.parse(e2); - return t2 = $e$2($e$2({}, t2), n2), e2 = queryString.stringify(t2), e2; + function cu(e2, t2, r2) { + const i2 = Yf(e2, t2, r2); + return jr(i2); } - function Qn() { - return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; + function Qi$1(e2) { + return e2 && e2.includes("urn:recap:"); } - function Ve$2() { - if (R$3() === m$2.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { - const { OS: t2, Version: r2 } = global.Platform; - return [t2, r2].join("-"); - } - const e2 = detect(); - if (e2 === null) - return "unknown"; - const n2 = e2.os ? e2.os.replace(" ", "").toLowerCase() : "unknown"; - return e2.type === "browser" ? [n2, e2.name, e2.version].join("-") : [n2, e2.version].join("-"); + function lu(e2, t2) { + const r2 = Oe$1(e2), i2 = Oe$1(t2), n2 = Wf(r2, i2); + return jr(n2); } - function Me$2() { - var e2; - const n2 = R$3(); - return n2 === m$2.browser ? [n2, ((e2 = getLocation_1()) == null ? void 0 : e2.host) || "unknown"].join(":") : n2; + function Wf(e2, t2) { + me$2(e2), me$2(t2); + const r2 = Object.keys(e2.att).concat(Object.keys(t2.att)).sort((n2, o2) => n2.localeCompare(o2)), i2 = { att: {} }; + return r2.forEach((n2) => { + var o2, h2; + Object.keys(((o2 = e2.att) == null ? void 0 : o2[n2]) || {}).concat(Object.keys(((h2 = t2.att) == null ? void 0 : h2[n2]) || {})).sort((p2, b2) => p2.localeCompare(b2)).forEach((p2) => { + var b2, m2; + i2.att[n2] = Hf(Hi$1({}, i2.att[n2]), { [p2]: ((b2 = e2.att[n2]) == null ? void 0 : b2[p2]) || ((m2 = t2.att[n2]) == null ? void 0 : m2[p2]) }); + }); + }), i2; + } + function Ji$1(e2 = "", t2) { + me$2(t2); + const r2 = "I further authorize the stated URI to perform the following actions on my behalf: "; + if (e2.includes(r2)) + return e2; + const i2 = []; + let n2 = 0; + Object.keys(t2.att).forEach((p2) => { + const b2 = Object.keys(t2.att[p2]).map((y2) => ({ ability: y2.split("/")[0], action: y2.split("/")[1] })); + b2.sort((y2, S2) => y2.action.localeCompare(S2.action)); + const m2 = {}; + b2.forEach((y2) => { + m2[y2.ability] || (m2[y2.ability] = []), m2[y2.ability].push(y2.action); + }); + const w2 = Object.keys(m2).map((y2) => (n2++, `(${n2}) '${y2}': '${m2[y2].join("', '")}' for '${p2}'.`)); + i2.push(w2.join(", ").replace(".,", ".")); + }); + const o2 = i2.join(" "), h2 = `${r2}${o2}`; + return `${e2 ? e2 + " " : ""}${h2}`; } - function Ke$2(e2, n2, t2) { - const r2 = Ve$2(), o2 = Me$2(); - return [[e2, n2].join("-"), [De$2, t2].join("-"), r2, o2].join("/"); + function du(e2) { + var t2; + const r2 = Oe$1(e2); + me$2(r2); + const i2 = (t2 = r2.att) == null ? void 0 : t2.eip155; + return i2 ? Object.keys(i2).map((n2) => n2.split("/")[1]) : []; + } + function pu(e2) { + const t2 = Oe$1(e2); + me$2(t2); + const r2 = []; + return Object.values(t2.att).forEach((i2) => { + Object.values(i2).forEach((n2) => { + var o2; + (o2 = n2 == null ? void 0 : n2[0]) != null && o2.chains && r2.push(n2[0].chains); + }); + }), [...new Set(r2.flat())]; } - function Xn({ protocol: e2, version: n2, relayUrl: t2, sdkVersion: r2, auth: o2, projectId: s2, useOnCloseEvent: i2, bundleId: d2 }) { - const l2 = t2.split("?"), c2 = Ke$2(e2, n2, r2), u2 = { auth: o2, ua: c2, projectId: s2, useOnCloseEvent: i2 || void 0, origin: d2 || void 0 }, a2 = ke$2(l2[1] || "", u2); - return l2[0] + "?" + a2; + function Qr(e2) { + if (!e2) + return; + const t2 = e2 == null ? void 0 : e2[e2.length - 1]; + return Qi$1(t2) ? t2 : void 0; } - function O$1(e2, n2) { - return e2.filter((t2) => n2.includes(t2)).length === e2.length; + const Gi = "base10", zt$2 = "base16", Jr = "base64pad", Gr = "utf8", Yi$1 = 0, lr$1 = 1, vu = 0, Zf = 1, Vi = 12, Wi$1 = 32; + function mu() { + const e2 = x25519.generateKeyPair(); + return { privateKey: toString(e2.secretKey, zt$2), publicKey: toString(e2.publicKey, zt$2) }; } - function rt$2(e2) { - return Object.fromEntries(e2.entries()); + function gu() { + const e2 = random.randomBytes(Wi$1); + return toString(e2, zt$2); } - function ot$2(e2) { - return new Map(Object.entries(e2)); + function Au(e2, t2) { + const r2 = x25519.sharedKey(fromString(e2, zt$2), fromString(t2, zt$2), true), i2 = new HKDF_1(sha256.SHA256, r2).expand(Wi$1); + return toString(i2, zt$2); } - function at$2(e2 = cjs$4.FIVE_MINUTES, n2) { - const t2 = cjs$4.toMiliseconds(e2 || cjs$4.FIVE_MINUTES); - let r2, o2, s2; - return { resolve: (i2) => { - s2 && r2 && (clearTimeout(s2), r2(i2)); - }, reject: (i2) => { - s2 && o2 && (clearTimeout(s2), o2(i2)); - }, done: () => new Promise((i2, d2) => { - s2 = setTimeout(() => { - d2(new Error(n2)); - }, t2), r2 = i2, o2 = d2; - }) }; + function bu(e2) { + const t2 = sha256.hash(fromString(e2, zt$2)); + return toString(t2, zt$2); } - function ut$2(e2, n2, t2) { - return new Promise(async (r2, o2) => { - const s2 = setTimeout(() => o2(new Error(t2)), n2); - try { - const i2 = await e2; - r2(i2); - } catch (i2) { - o2(i2); - } - clearTimeout(s2); - }); + function yu(e2) { + const t2 = sha256.hash(fromString(e2, Gr)); + return toString(t2, zt$2); } - function re$1(e2, n2) { - if (typeof n2 == "string" && n2.startsWith(`${e2}:`)) - return n2; - if (e2.toLowerCase() === "topic") { - if (typeof n2 != "string") - throw new Error('Value must be "string" for expirer target type: topic'); - return `topic:${n2}`; - } else if (e2.toLowerCase() === "id") { - if (typeof n2 != "number") - throw new Error('Value must be "number" for expirer target type: id'); - return `id:${n2}`; - } - throw new Error(`Unknown expirer target type: ${e2}`); + function $f(e2) { + return fromString(`${e2}`, Gi); } - function lt$2(e2) { - return re$1("topic", e2); + function Mr(e2) { + return Number(toString(e2, Gi)); } - function dt$2(e2) { - return re$1("id", e2); + function wu(e2) { + const t2 = $f(typeof e2.type < "u" ? e2.type : Yi$1); + if (Mr(t2) === lr$1 && typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + const r2 = typeof e2.senderPublicKey < "u" ? fromString(e2.senderPublicKey, zt$2) : void 0, i2 = typeof e2.iv < "u" ? fromString(e2.iv, zt$2) : random.randomBytes(Vi), n2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$2)).seal(i2, fromString(e2.message, Gr)); + return to$1({ type: t2, sealed: n2, iv: i2, senderPublicKey: r2 }); } - function ft$2(e2) { - const [n2, t2] = e2.split(":"), r2 = { id: void 0, topic: void 0 }; - if (n2 === "topic" && typeof t2 == "string") - r2.topic = t2; - else if (n2 === "id" && Number.isInteger(Number(t2))) - r2.id = Number(t2); - else - throw new Error(`Invalid target, expected id:number or topic:string, got ${n2}:${t2}`); - return r2; + function xu(e2) { + const t2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$2)), { sealed: r2, iv: i2 } = Xi$1(e2.encoded), n2 = t2.open(i2, r2); + if (n2 === null) + throw new Error("Failed to decrypt"); + return toString(n2, Gr); } - function pt$2(e2, n2) { - return cjs$4.fromMiliseconds((n2 || Date.now()) + cjs$4.toMiliseconds(e2)); + function to$1(e2) { + if (Mr(e2.type) === lr$1) { + if (typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + return toString(concat([e2.type, e2.senderPublicKey, e2.iv, e2.sealed]), Jr); + } + return toString(concat([e2.type, e2.iv, e2.sealed]), Jr); } - function mt$2(e2) { - return Date.now() >= cjs$4.toMiliseconds(e2); + function Xi$1(e2) { + const t2 = fromString(e2, Jr), r2 = t2.slice(vu, Zf), i2 = Zf; + if (Mr(r2) === lr$1) { + const p2 = i2 + Wi$1, b2 = p2 + Vi, m2 = t2.slice(i2, p2), w2 = t2.slice(p2, b2), y2 = t2.slice(b2); + return { type: r2, sealed: y2, iv: w2, senderPublicKey: m2 }; + } + const n2 = i2 + Vi, o2 = t2.slice(i2, n2), h2 = t2.slice(n2); + return { type: r2, sealed: h2, iv: o2 }; } - function yt$2(e2, n2) { - return `${e2}${n2 ? `:${n2}` : ""}`; + function Mu(e2, t2) { + const r2 = Xi$1(e2); + return eo$1({ type: Mr(r2.type), senderPublicKey: typeof r2.senderPublicKey < "u" ? toString(r2.senderPublicKey, zt$2) : void 0, receiverPublicKey: t2 == null ? void 0 : t2.receiverPublicKey }); } - async function gt$2({ id: e2, topic: n2, wcDeepLink: t2 }) { - try { - if (!t2) - return; - const r2 = typeof t2 == "string" ? JSON.parse(t2) : t2; - let o2 = r2 == null ? void 0 : r2.href; - if (typeof o2 != "string") - return; - o2.endsWith("/") && (o2 = o2.slice(0, -1)); - const s2 = `${o2}/wc?requestId=${e2}&sessionTopic=${n2}`, i2 = R$3(); - i2 === m$2.browser ? s2.startsWith("https://") ? window.open(s2, "_blank", "noreferrer noopener") : window.open(s2, "_self", "noreferrer noopener") : i2 === m$2.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(s2); - } catch (r2) { - console.error(r2); + function eo$1(e2) { + const t2 = (e2 == null ? void 0 : e2.type) || Yi$1; + if (t2 === lr$1) { + if (typeof (e2 == null ? void 0 : e2.senderPublicKey) > "u") + throw new Error("missing sender public key"); + if (typeof (e2 == null ? void 0 : e2.receiverPublicKey) > "u") + throw new Error("missing receiver public key"); } + return { type: t2, senderPublicKey: e2 == null ? void 0 : e2.senderPublicKey, receiverPublicKey: e2 == null ? void 0 : e2.receiverPublicKey }; } - async function ht$2(e2, n2) { - try { - return await e2.getItem(n2) || (D$4() ? localStorage.getItem(n2) : void 0); - } catch (t2) { - console.error(t2); - } + function Eu(e2) { + return e2.type === lr$1 && typeof e2.senderPublicKey == "string" && typeof e2.receiverPublicKey == "string"; } - const He$2 = "irn"; - function vt$2(e2) { - return (e2 == null ? void 0 : e2.relay) || { protocol: He$2 }; + const ro$1 = "irn"; + function Su(e2) { + return (e2 == null ? void 0 : e2.relay) || { protocol: ro$1 }; } - function Et$2(e2) { - const n2 = RELAY_JSONRPC[e2]; - if (typeof n2 > "u") + function Nu(e2) { + const t2 = C$2[e2]; + if (typeof t2 > "u") throw new Error(`Relay Protocol not supported: ${e2}`); - return n2; + return t2; } - var bt$2 = Object.defineProperty, Nt$2 = Object.defineProperties, Ot$2 = Object.getOwnPropertyDescriptors, qe$2 = Object.getOwnPropertySymbols, St$2 = Object.prototype.hasOwnProperty, wt$2 = Object.prototype.propertyIsEnumerable, Be$2 = (e2, n2, t2) => n2 in e2 ? bt$2(e2, n2, { enumerable: true, configurable: true, writable: true, value: t2 }) : e2[n2] = t2, It$2 = (e2, n2) => { - for (var t2 in n2 || (n2 = {})) - St$2.call(n2, t2) && Be$2(e2, t2, n2[t2]); - if (qe$2) - for (var t2 of qe$2(n2)) - wt$2.call(n2, t2) && Be$2(e2, t2, n2[t2]); + var Iu = Object.defineProperty, _u = Object.defineProperties, Bu = Object.getOwnPropertyDescriptors, io = Object.getOwnPropertySymbols, Cu = Object.prototype.hasOwnProperty, Ru = Object.prototype.propertyIsEnumerable, no$1 = (e2, t2, r2) => t2 in e2 ? Iu(e2, t2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[t2] = r2, fo$1 = (e2, t2) => { + for (var r2 in t2 || (t2 = {})) + Cu.call(t2, r2) && no$1(e2, r2, t2[r2]); + if (io) + for (var r2 of io(t2)) + Ru.call(t2, r2) && no$1(e2, r2, t2[r2]); return e2; - }, Tt$2 = (e2, n2) => Nt$2(e2, Ot$2(n2)); - function Ge$2(e2, n2 = "-") { - const t2 = {}, r2 = "relay" + n2; - return Object.keys(e2).forEach((o2) => { - if (o2.startsWith(r2)) { - const s2 = o2.replace(r2, ""), i2 = e2[o2]; - t2[s2] = i2; + }, Ou = (e2, t2) => _u(e2, Bu(t2)); + function oo$1(e2, t2 = "-") { + const r2 = {}, i2 = "relay" + t2; + return Object.keys(e2).forEach((n2) => { + if (n2.startsWith(i2)) { + const o2 = n2.replace(i2, ""), h2 = e2[n2]; + r2[o2] = h2; } - }), t2; + }), r2; } - function Pt$2(e2) { + function Pu(e2) { e2 = e2.includes("wc://") ? e2.replace("wc://", "") : e2, e2 = e2.includes("wc:") ? e2.replace("wc:", "") : e2; - const n2 = e2.indexOf(":"), t2 = e2.indexOf("?") !== -1 ? e2.indexOf("?") : void 0, r2 = e2.substring(0, n2), o2 = e2.substring(n2 + 1, t2).split("@"), s2 = typeof t2 < "u" ? e2.substring(t2) : "", i2 = queryString.parse(s2); - return { protocol: r2, topic: We$2(o2[0]), version: parseInt(o2[1], 10), symKey: i2.symKey, relay: Ge$2(i2), expiryTimestamp: i2.expiryTimestamp ? parseInt(i2.expiryTimestamp, 10) : void 0 }; + const t2 = e2.indexOf(":"), r2 = e2.indexOf("?") !== -1 ? e2.indexOf("?") : void 0, i2 = e2.substring(0, t2), n2 = e2.substring(t2 + 1, r2).split("@"), o2 = typeof r2 < "u" ? e2.substring(r2) : "", h2 = queryString.parse(o2), p2 = typeof h2.methods == "string" ? h2.methods.split(",") : void 0; + return { protocol: i2, topic: so(n2[0]), version: parseInt(n2[1], 10), symKey: h2.symKey, relay: oo$1(h2), methods: p2, expiryTimestamp: h2.expiryTimestamp ? parseInt(h2.expiryTimestamp, 10) : void 0 }; } - function We$2(e2) { + function so(e2) { return e2.startsWith("//") ? e2.substring(2) : e2; } - function ze$1(e2, n2 = "-") { - const t2 = "relay", r2 = {}; - return Object.keys(e2).forEach((o2) => { - const s2 = t2 + n2 + o2; - e2[o2] && (r2[s2] = e2[o2]); - }), r2; - } - function Rt$2(e2) { - return `${e2.protocol}:${e2.topic}@${e2.version}?` + queryString.stringify(Tt$2(It$2({ symKey: e2.symKey }, ze$1(e2.relay)), { expiryTimestamp: e2.expiryTimestamp })); - } - function A$3(e2) { - const n2 = []; - return e2.forEach((t2) => { - const [r2, o2] = t2.split(":"); - n2.push(`${r2}:${o2}`); - }), n2; + function ao$1(e2, t2 = "-") { + const r2 = "relay", i2 = {}; + return Object.keys(e2).forEach((n2) => { + const o2 = r2 + t2 + n2; + e2[n2] && (i2[o2] = e2[n2]); + }), i2; } - function Qe$2(e2) { - const n2 = []; - return Object.values(e2).forEach((t2) => { - n2.push(...A$3(t2.accounts)); - }), n2; + function Du(e2) { + return `${e2.protocol}:${e2.topic}@${e2.version}?` + queryString.stringify(fo$1(Ou(fo$1({ symKey: e2.symKey }, ao$1(e2.relay)), { expiryTimestamp: e2.expiryTimestamp }), e2.methods ? { methods: e2.methods.join(",") } : {})); } - function Ze$1(e2, n2) { + function $e$2(e2) { const t2 = []; - return Object.values(e2).forEach((r2) => { - A$3(r2.accounts).includes(n2) && t2.push(...r2.methods); + return e2.forEach((r2) => { + const [i2, n2] = r2.split(":"); + t2.push(`${i2}:${n2}`); }), t2; } - function Xe$1(e2, n2) { + function co$1(e2) { const t2 = []; return Object.values(e2).forEach((r2) => { - A$3(r2.accounts).includes(n2) && t2.push(...r2.events); + t2.push(...$e$2(r2.accounts)); + }), t2; + } + function lo(e2, t2) { + const r2 = []; + return Object.values(e2).forEach((i2) => { + $e$2(i2.accounts).includes(t2) && r2.push(...i2.methods); + }), r2; + } + function po$1(e2, t2) { + const r2 = []; + return Object.values(e2).forEach((i2) => { + $e$2(i2.accounts).includes(t2) && r2.push(...i2.events); + }), r2; + } + function mo(e2) { + const t2 = {}; + return e2 == null ? void 0 : e2.forEach((r2) => { + const [i2, n2] = r2.split(":"); + t2[i2] || (t2[i2] = { accounts: [], chains: [], events: [] }), t2[i2].accounts.push(r2), t2[i2].chains.push(`${i2}:${n2}`); }), t2; } - const nn = { 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 } }, tn = { 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 N$2(e2, n2) { - const { message: t2, code: r2 } = tn[e2]; - return { message: n2 ? `${t2} ${n2}` : t2, code: r2 }; + function ju(e2, t2) { + t2 = t2.map((i2) => i2.replace("did:pkh:", "")); + const r2 = mo(t2); + for (const [i2, n2] of Object.entries(r2)) + n2.methods ? n2.methods = ge$2(n2.methods, e2) : n2.methods = e2, n2.events = ["chainChanged", "accountsChanged"]; + return r2; + } + const go$2 = { 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 } }, Ao$1 = { 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 xe$1(e2, t2) { + const { message: r2, code: i2 } = Ao$1[e2]; + return { message: t2 ? `${r2} ${t2}` : r2, code: i2 }; } - function U$3(e2, n2) { - const { message: t2, code: r2 } = nn[e2]; - return { message: n2 ? `${t2} ${n2}` : t2, code: r2 }; + function tr$2(e2, t2) { + const { message: r2, code: i2 } = go$2[e2]; + return { message: t2 ? `${r2} ${t2}` : r2, code: i2 }; } - function k$1(e2, n2) { - return Array.isArray(e2) ? typeof n2 < "u" && e2.length ? e2.every(n2) : true : false; + function Er(e2, t2) { + return Array.isArray(e2) ? true : false; } - function B$3(e2) { + function Yr(e2) { return Object.getPrototypeOf(e2) === Object.prototype && Object.keys(e2).length; } - function w$4(e2) { + function Pe$1(e2) { return typeof e2 > "u"; } - function g$4(e2, n2) { - return n2 && w$4(e2) ? true : typeof e2 == "string" && !!e2.trim().length; + function Gt$2(e2, t2) { + return t2 && Pe$1(e2) ? true : typeof e2 == "string" && !!e2.trim().length; } - function G$2(e2, n2) { - return n2 && w$4(e2) ? true : typeof e2 == "number" && !isNaN(e2); + function Vr(e2, t2) { + return typeof e2 == "number" && !isNaN(e2); } - function Mt$2(e2, n2) { - const { requiredNamespaces: t2 } = n2, r2 = Object.keys(e2.namespaces), o2 = Object.keys(t2); - let s2 = true; - return O$1(o2, r2) ? (r2.forEach((i2) => { - const { accounts: d2, methods: l2, events: c2 } = e2.namespaces[i2], u2 = A$3(d2), a2 = t2[i2]; - (!O$1(L$3(i2, a2), u2) || !O$1(a2.methods, l2) || !O$1(a2.events, c2)) && (s2 = false); - }), s2) : false; + function Qu(e2, t2) { + const { requiredNamespaces: r2 } = t2, i2 = Object.keys(e2.namespaces), n2 = Object.keys(r2); + let o2 = true; + return _e$2(n2, i2) ? (i2.forEach((h2) => { + const { accounts: p2, methods: b2, events: m2 } = e2.namespaces[h2], w2 = $e$2(p2), y2 = r2[h2]; + (!_e$2(_r$1(h2, y2), w2) || !_e$2(y2.methods, b2) || !_e$2(y2.events, m2)) && (o2 = false); + }), o2) : false; } - function V$2(e2) { - return g$4(e2, false) && e2.includes(":") ? e2.split(":").length === 2 : false; + function Sr$1(e2) { + return Gt$2(e2, false) && e2.includes(":") ? e2.split(":").length === 2 : false; } - function rn(e2) { - if (g$4(e2, false) && e2.includes(":")) { - const n2 = e2.split(":"); - if (n2.length === 3) { - const t2 = n2[0] + ":" + n2[1]; - return !!n2[2] && V$2(t2); + function bo(e2) { + if (Gt$2(e2, false) && e2.includes(":")) { + const t2 = e2.split(":"); + if (t2.length === 3) { + const r2 = t2[0] + ":" + t2[1]; + return !!t2[2] && Sr$1(r2); } } return false; } - function Kt$2(e2) { - if (g$4(e2, false)) + function Ju(e2) { + if (Gt$2(e2, false)) try { return typeof new URL(e2) < "u"; } catch { @@ -8818,227 +12330,227 @@ } return false; } - function Lt$2(e2) { - var n2; - return (n2 = e2 == null ? void 0 : e2.proposer) == null ? void 0 : n2.publicKey; + function Gu(e2) { + var t2; + return (t2 = e2 == null ? void 0 : e2.proposer) == null ? void 0 : t2.publicKey; } - function xt$2(e2) { + function Yu(e2) { return e2 == null ? void 0 : e2.topic; } - function Ft$2(e2, n2) { - let t2 = null; - return g$4(e2 == null ? void 0 : e2.publicKey, false) || (t2 = N$2("MISSING_OR_INVALID", `${n2} controller public key should be a string`)), t2; + function Vu(e2, t2) { + let r2 = null; + return Gt$2(e2 == null ? void 0 : e2.publicKey, false) || (r2 = xe$1("MISSING_OR_INVALID", `${t2} controller public key should be a string`)), r2; + } + function tn(e2) { + let t2 = true; + return Er(e2) ? e2.length && (t2 = e2.every((r2) => Gt$2(r2, false))) : t2 = false, t2; } - function ie$1(e2) { - let n2 = true; - return k$1(e2) ? e2.length && (n2 = e2.every((t2) => g$4(t2, false))) : n2 = false, n2; + function yo(e2, t2, r2) { + let i2 = null; + return Er(t2) && t2.length ? t2.forEach((n2) => { + i2 || Sr$1(n2) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r2}, chain ${n2} should be a string and conform to "namespace:chainId" format`)); + }) : Sr$1(e2) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r2}, 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"] }`)), i2; + } + function wo$1(e2, t2, r2) { + let i2 = null; + return Object.entries(e2).forEach(([n2, o2]) => { + if (i2) + return; + const h2 = yo(n2, _r$1(n2, o2), `${t2} ${r2}`); + h2 && (i2 = h2); + }), i2; } - function on(e2, n2, t2) { + function xo$1(e2, t2) { let r2 = null; - return k$1(n2) && n2.length ? n2.forEach((o2) => { - r2 || V$2(o2) || (r2 = U$3("UNSUPPORTED_CHAINS", `${t2}, chain ${o2} should be a string and conform to "namespace:chainId" format`)); - }) : V$2(e2) || (r2 = U$3("UNSUPPORTED_CHAINS", `${t2}, 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"] }`)), r2; + return Er(e2) ? e2.forEach((i2) => { + r2 || bo(i2) || (r2 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, account ${i2} should be a string and conform to "namespace:chainId:address" format`)); + }) : r2 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), r2; } - function sn(e2, n2, t2) { + function Mo$1(e2, t2) { let r2 = null; - return Object.entries(e2).forEach(([o2, s2]) => { + return Object.values(e2).forEach((i2) => { if (r2) return; - const i2 = on(o2, L$3(o2, s2), `${n2} ${t2}`); - i2 && (r2 = i2); + const n2 = xo$1(i2 == null ? void 0 : i2.accounts, `${t2} namespace`); + n2 && (r2 = n2); }), r2; } - function cn(e2, n2) { - let t2 = null; - return k$1(e2) ? e2.forEach((r2) => { - t2 || rn(r2) || (t2 = U$3("UNSUPPORTED_ACCOUNTS", `${n2}, account ${r2} should be a string and conform to "namespace:chainId:address" format`)); - }) : t2 = U$3("UNSUPPORTED_ACCOUNTS", `${n2}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), t2; + function Eo$1(e2, t2) { + let r2 = null; + return tn(e2 == null ? void 0 : e2.methods) ? tn(e2 == null ? void 0 : e2.events) || (r2 = tr$2("UNSUPPORTED_EVENTS", `${t2}, events should be an array of strings or empty array for no events`)) : r2 = tr$2("UNSUPPORTED_METHODS", `${t2}, methods should be an array of strings or empty array for no methods`), r2; } - function an(e2, n2) { - let t2 = null; - return Object.values(e2).forEach((r2) => { - if (t2) + function en(e2, t2) { + let r2 = null; + return Object.values(e2).forEach((i2) => { + if (r2) return; - const o2 = cn(r2 == null ? void 0 : r2.accounts, `${n2} namespace`); - o2 && (t2 = o2); - }), t2; - } - function un(e2, n2) { - let t2 = null; - return ie$1(e2 == null ? void 0 : e2.methods) ? ie$1(e2 == null ? void 0 : e2.events) || (t2 = U$3("UNSUPPORTED_EVENTS", `${n2}, events should be an array of strings or empty array for no events`)) : t2 = U$3("UNSUPPORTED_METHODS", `${n2}, methods should be an array of strings or empty array for no methods`), t2; + const n2 = Eo$1(i2, `${t2}, namespace`); + n2 && (r2 = n2); + }), r2; } - function ce$3(e2, n2) { - let t2 = null; - return Object.values(e2).forEach((r2) => { - if (t2) - return; - const o2 = un(r2, `${n2}, namespace`); - o2 && (t2 = o2); - }), t2; + function Wu(e2, t2, r2) { + let i2 = null; + if (e2 && Yr(e2)) { + const n2 = en(e2, t2); + n2 && (i2 = n2); + const o2 = wo$1(e2, t2, r2); + o2 && (i2 = o2); + } else + i2 = xe$1("MISSING_OR_INVALID", `${t2}, ${r2} should be an object with data`); + return i2; } - function Ht$2(e2, n2, t2) { + function So(e2, t2) { let r2 = null; - if (e2 && B$3(e2)) { - const o2 = ce$3(e2, n2); - o2 && (r2 = o2); - const s2 = sn(e2, n2, t2); - s2 && (r2 = s2); + if (e2 && Yr(e2)) { + const i2 = en(e2, t2); + i2 && (r2 = i2); + const n2 = Mo$1(e2, t2); + n2 && (r2 = n2); } else - r2 = N$2("MISSING_OR_INVALID", `${n2}, ${t2} should be an object with data`); + r2 = xe$1("MISSING_OR_INVALID", `${t2}, namespaces should be an object with data`); return r2; } - function ln(e2, n2) { - let t2 = null; - if (e2 && B$3(e2)) { - const r2 = ce$3(e2, n2); - r2 && (t2 = r2); - const o2 = an(e2, n2); - o2 && (t2 = o2); - } else - t2 = N$2("MISSING_OR_INVALID", `${n2}, namespaces should be an object with data`); - return t2; - } - function dn(e2) { - return g$4(e2.protocol, true); + function No$1(e2) { + return Gt$2(e2.protocol, true); } - function qt$2(e2, n2) { - let t2 = false; - return n2 && !e2 ? t2 = true : e2 && k$1(e2) && e2.length && e2.forEach((r2) => { - t2 = dn(r2); - }), t2; + function Xu(e2, t2) { + let r2 = false; + return !e2 ? r2 = true : e2 && Er(e2) && e2.length && e2.forEach((i2) => { + r2 = No$1(i2); + }), r2; } - function Bt$2(e2) { + function Zu(e2) { return typeof e2 == "number"; } - function Gt$2(e2) { + function $u(e2) { return typeof e2 < "u" && typeof e2 !== null; } - function Wt$1(e2) { - return !(!e2 || typeof e2 != "object" || !e2.code || !G$2(e2.code, false) || !e2.message || !g$4(e2.message, false)); + function th(e2) { + return !(!e2 || typeof e2 != "object" || !e2.code || !Vr(e2.code) || !e2.message || !Gt$2(e2.message, false)); } - function zt$2(e2) { - return !(w$4(e2) || !g$4(e2.method, false)); + function eh(e2) { + return !(Pe$1(e2) || !Gt$2(e2.method, false)); } - function Yt$2(e2) { - return !(w$4(e2) || w$4(e2.result) && w$4(e2.error) || !G$2(e2.id, false) || !g$4(e2.jsonrpc, false)); + function rh(e2) { + return !(Pe$1(e2) || Pe$1(e2.result) && Pe$1(e2.error) || !Vr(e2.id) || !Gt$2(e2.jsonrpc, false)); } - function Jt$2(e2) { - return !(w$4(e2) || !g$4(e2.name, false)); + function ih(e2) { + return !(Pe$1(e2) || !Gt$2(e2.name, false)); } - function Qt$1(e2, n2) { - return !(!V$2(n2) || !Qe$2(e2).includes(n2)); + function nh(e2, t2) { + return !(!Sr$1(t2) || !co$1(e2).includes(t2)); } - function Zt$1(e2, n2, t2) { - return g$4(t2, false) ? Ze$1(e2, n2).includes(t2) : false; + function fh(e2, t2, r2) { + return Gt$2(r2, false) ? lo(e2, t2).includes(r2) : false; } - function Xt$1(e2, n2, t2) { - return g$4(t2, false) ? Xe$1(e2, n2).includes(t2) : false; + function oh(e2, t2, r2) { + return Gt$2(r2, false) ? po$1(e2, t2).includes(r2) : false; } - function fn(e2, n2, t2) { - let r2 = null; - const o2 = er$2(e2), s2 = nr$2(n2), i2 = Object.keys(o2), d2 = Object.keys(s2), l2 = pn(Object.keys(e2)), c2 = pn(Object.keys(n2)), u2 = l2.filter((a2) => !c2.includes(a2)); - return u2.length && (r2 = N$2("NON_CONFORMING_NAMESPACES", `${t2} namespaces keys don't satisfy requiredNamespaces. - Required: ${u2.toString()} - Received: ${Object.keys(n2).toString()}`)), O$1(i2, d2) || (r2 = N$2("NON_CONFORMING_NAMESPACES", `${t2} namespaces chains don't satisfy required namespaces. - Required: ${i2.toString()} - Approved: ${d2.toString()}`)), Object.keys(n2).forEach((a2) => { - if (!a2.includes(":") || r2) + function Io(e2, t2, r2) { + let i2 = null; + const n2 = sh(e2), o2 = ah(t2), h2 = Object.keys(n2), p2 = Object.keys(o2), b2 = _o(Object.keys(e2)), m2 = _o(Object.keys(t2)), w2 = b2.filter((y2) => !m2.includes(y2)); + return w2.length && (i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r2} namespaces keys don't satisfy requiredNamespaces. + Required: ${w2.toString()} + Received: ${Object.keys(t2).toString()}`)), _e$2(h2, p2) || (i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r2} namespaces chains don't satisfy required namespaces. + Required: ${h2.toString()} + Approved: ${p2.toString()}`)), Object.keys(t2).forEach((y2) => { + if (!y2.includes(":") || i2) return; - const b2 = A$3(n2[a2].accounts); - b2.includes(a2) || (r2 = N$2("NON_CONFORMING_NAMESPACES", `${t2} namespaces accounts don't satisfy namespace accounts for ${a2} - Required: ${a2} - Approved: ${b2.toString()}`)); - }), i2.forEach((a2) => { - r2 || (O$1(o2[a2].methods, s2[a2].methods) ? O$1(o2[a2].events, s2[a2].events) || (r2 = N$2("NON_CONFORMING_NAMESPACES", `${t2} namespaces events don't satisfy namespace events for ${a2}`)) : r2 = N$2("NON_CONFORMING_NAMESPACES", `${t2} namespaces methods don't satisfy namespace methods for ${a2}`)); - }), r2; - } - function er$2(e2) { - const n2 = {}; - return Object.keys(e2).forEach((t2) => { - var r2; - t2.includes(":") ? n2[t2] = e2[t2] : (r2 = e2[t2].chains) == null || r2.forEach((o2) => { - n2[o2] = { methods: e2[t2].methods, events: e2[t2].events }; + const S2 = $e$2(t2[y2].accounts); + S2.includes(y2) || (i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r2} namespaces accounts don't satisfy namespace accounts for ${y2} + Required: ${y2} + Approved: ${S2.toString()}`)); + }), h2.forEach((y2) => { + i2 || (_e$2(n2[y2].methods, o2[y2].methods) ? _e$2(n2[y2].events, o2[y2].events) || (i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r2} namespaces events don't satisfy namespace events for ${y2}`)) : i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r2} namespaces methods don't satisfy namespace methods for ${y2}`)); + }), i2; + } + function sh(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r2) => { + var i2; + r2.includes(":") ? t2[r2] = e2[r2] : (i2 = e2[r2].chains) == null || i2.forEach((n2) => { + t2[n2] = { methods: e2[r2].methods, events: e2[r2].events }; }); - }), n2; + }), t2; } - function pn(e2) { - return [...new Set(e2.map((n2) => n2.includes(":") ? n2.split(":")[0] : n2))]; + function _o(e2) { + return [...new Set(e2.map((t2) => t2.includes(":") ? t2.split(":")[0] : t2))]; } - function nr$2(e2) { - const n2 = {}; - return Object.keys(e2).forEach((t2) => { - if (t2.includes(":")) - n2[t2] = e2[t2]; + function ah(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r2) => { + if (r2.includes(":")) + t2[r2] = e2[r2]; else { - const r2 = A$3(e2[t2].accounts); - r2 == null ? void 0 : r2.forEach((o2) => { - n2[o2] = { accounts: e2[t2].accounts.filter((s2) => s2.includes(`${o2}:`)), methods: e2[t2].methods, events: e2[t2].events }; + const i2 = $e$2(e2[r2].accounts); + i2 == null ? void 0 : i2.forEach((n2) => { + t2[n2] = { accounts: e2[r2].accounts.filter((o2) => o2.includes(`${n2}:`)), methods: e2[r2].methods, events: e2[r2].events }; }); } - }), n2; + }), t2; } - function tr$2(e2, n2) { - return G$2(e2, false) && e2 <= n2.max && e2 >= n2.min; + function uh(e2, t2) { + return Vr(e2) && e2 <= t2.max && e2 >= t2.min; } - function rr$2() { - const e2 = R$3(); - return new Promise((n2) => { + function hh() { + const e2 = We$3(); + return new Promise((t2) => { switch (e2) { - case m$2.browser: - n2(mn()); + case qt$1.browser: + t2(Bo()); break; - case m$2.reactNative: - n2(yn()); + case qt$1.reactNative: + t2(Co$1()); break; - case m$2.node: - n2(gn()); + case qt$1.node: + t2(Ro$1()); break; default: - n2(true); + t2(true); } }); } - function mn() { - return D$4() && (navigator == null ? void 0 : navigator.onLine); + function Bo() { + return pr$1() && (navigator == null ? void 0 : navigator.onLine); } - async function yn() { - if ($$2() && typeof global < "u" && global != null && global.NetInfo) { + async function Co$1() { + if (er$2() && typeof global < "u" && global != null && global.NetInfo) { const e2 = await (global == null ? void 0 : global.NetInfo.fetch()); return e2 == null ? void 0 : e2.isConnected; } return true; } - function gn() { + function Ro$1() { return true; } - function or$2(e2) { - switch (R$3()) { - case m$2.browser: - hn(e2); + function ch(e2) { + switch (We$3()) { + case qt$1.browser: + Oo(e2); break; - case m$2.reactNative: - vn(e2); + case qt$1.reactNative: + Po$1(e2); break; } } - function hn(e2) { - !$$2() && D$4() && (window.addEventListener("online", () => e2(true)), window.addEventListener("offline", () => e2(false))); + function Oo(e2) { + !er$2() && pr$1() && (window.addEventListener("online", () => e2(true)), window.addEventListener("offline", () => e2(false))); } - function vn(e2) { - $$2() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((n2) => e2(n2 == null ? void 0 : n2.isConnected))); + function Po$1(e2) { + er$2() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((t2) => e2(t2 == null ? void 0 : t2.isConnected))); } - const ae$2 = {}; - let sr$2 = class sr { - static get(n2) { - return ae$2[n2]; + const rn = {}; + class lh { + static get(t2) { + return rn[t2]; } - static set(n2, t2) { - ae$2[n2] = t2; + static set(t2, r2) { + rn[t2] = r2; } - static delete(n2) { - delete ae$2[n2]; + static delete(t2) { + delete rn[t2]; } - }; + } const PARSE_ERROR = "PARSE_ERROR"; const INVALID_REQUEST = "INVALID_REQUEST"; const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; @@ -9153,7 +12665,7 @@ return { id, jsonrpc: "2.0", - error: formatErrorMessage(error, data2) + error: formatErrorMessage(error) }; } function formatErrorMessage(error, data2) { @@ -9163,26 +12675,23 @@ if (typeof error === "string") { error = Object.assign(Object.assign({}, getError(SERVER_ERROR)), { message: error }); } - if (typeof data2 !== "undefined") { - error.data = data2; - } if (isReservedErrorCode(error.code)) { error = getErrorByCode(error.code); } return error; } - class IEvents { - } - class IBaseJsonRpcProvider extends IEvents { + let e$6 = class e { + }; + let n$7 = class n extends e$6 { constructor() { super(); } - } - class IJsonRpcProvider extends IBaseJsonRpcProvider { - constructor(connection) { + }; + let r$4 = class r extends n$7 { + constructor(c2) { super(); } - } + }; const WS_REGEX = "^wss?:"; function getUrlProtocol(url) { const matches = url.match(new RegExp(/^\w+:/, "gi")); @@ -9217,7 +12726,7 @@ function isJsonRpcError(payload) { return "error" in payload; } - class JsonRpcProvider extends IJsonRpcProvider { + class JsonRpcProvider extends r$4 { constructor(connection) { super(connection); this.events = new eventsExports.EventEmitter(); @@ -9318,8 +12827,8 @@ this.hasRegisteredEventListeners = true; } } - const w$3 = () => 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 : require("ws"), b$1 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a$3 = (c2) => c2.split("?")[0], h$4 = 10, S$4 = w$3(); - let f$1 = class f { + const w$2 = () => 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 : require("ws"), b$2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a$2 = (c2) => c2.split("?")[0], h$3 = 10, S$5 = w$2(); + let f$3 = class f { constructor(e2) { if (this.url = e2, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(e2)) throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); @@ -9381,8 +12890,8 @@ }); } return this.url = e2, this.registering = true, new Promise((t2, n2) => { - const o2 = new URLSearchParams(e2).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e2) }, i2 = new S$4(e2, [], s2); - b$1() ? i2.onerror = (r2) => { + const o2 = new URLSearchParams(e2).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e2) }, i2 = new S$5(e2, [], s2); + b$2() ? i2.onerror = (r2) => { const l2 = r2; n2(this.emitError(l2.error)); } : i2.on("error", (r2) => { @@ -9409,13 +12918,13 @@ this.events.emit("payload", s2); } parseError(e2, t2 = this.url) { - return parseConnectionError(e2, a$3(t2), "WS"); + return parseConnectionError(e2, a$2(t2), "WS"); } resetMaxListeners() { - this.events.getMaxListeners() > h$4 && this.events.setMaxListeners(h$4); + this.events.getMaxListeners() > h$3 && this.events.setMaxListeners(h$3); } emitError(e2) { - const t2 = this.parseError(new Error((e2 == null ? void 0 : e2.message) || `WebSocket connection failed for host: ${a$3(this.url)}`)); + const t2 = this.parseError(new Error((e2 == null ? void 0 : e2.message) || `WebSocket connection failed for host: ${a$2(this.url)}`)); return this.events.emit("register_error", t2), t2; } }; @@ -9712,7 +13221,7 @@ function arrayLikeKeys(value, inherited) { var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. + if (hasOwnProperty.call(value, key) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. @@ -10070,7 +13579,7 @@ module3.exports = isEqual; })(lodash_isequal, lodash_isequal.exports); var lodash_isequalExports = lodash_isequal.exports; - const Gi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); + const Yi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); function unfetch_module(e2, n2) { return n2 = n2 || {}, new Promise(function(t2, r2) { var s2 = new XMLHttpRequest(), o2 = [], u2 = [], i2 = {}, a2 = function() { @@ -10105,8 +13614,8 @@ }, Symbol.toStringTag, { value: "Module" })); const require$$0 = /* @__PURE__ */ getAugmentedNamespace(unfetch_module$1); var browser$3 = fetch || (self.fetch = require$$0.default || require$$0); - const Yi = /* @__PURE__ */ getDefaultExportFromCjs(browser$3); - function Hi(n2, e2) { + const Hi = /* @__PURE__ */ getDefaultExportFromCjs(browser$3); + function Ji(n2, e2) { if (n2.length >= 255) throw new TypeError("Alphabet too long"); for (var t2 = new Uint8Array(256), i2 = 0; i2 < t2.length; i2++) @@ -10118,64 +13627,64 @@ t2[o2] = s2; } var a2 = n2.length, h2 = n2.charAt(0), l2 = Math.log(a2) / Math.log(256), d2 = Math.log(256) / Math.log(a2); - function p2(u2) { + function g2(u2) { if (u2 instanceof Uint8Array || (ArrayBuffer.isView(u2) ? u2 = new Uint8Array(u2.buffer, u2.byteOffset, u2.byteLength) : Array.isArray(u2) && (u2 = Uint8Array.from(u2))), !(u2 instanceof Uint8Array)) throw new TypeError("Expected Uint8Array"); if (u2.length === 0) return ""; - for (var m2 = 0, z2 = 0, I2 = 0, _2 = u2.length; I2 !== _2 && u2[I2] === 0; ) - I2++, m2++; - for (var T2 = (_2 - I2) * d2 + 1 >>> 0, f2 = new Uint8Array(T2); I2 !== _2; ) { - for (var S2 = u2[I2], A2 = 0, C2 = T2 - 1; (S2 !== 0 || A2 < z2) && C2 !== -1; C2--, A2++) - S2 += 256 * f2[C2] >>> 0, f2[C2] = S2 % a2 >>> 0, S2 = S2 / a2 >>> 0; - if (S2 !== 0) + for (var p2 = 0, _2 = 0, D2 = 0, P2 = u2.length; D2 !== P2 && u2[D2] === 0; ) + D2++, p2++; + for (var x2 = (P2 - D2) * d2 + 1 >>> 0, E2 = new Uint8Array(x2); D2 !== P2; ) { + for (var O2 = u2[D2], N2 = 0, R2 = x2 - 1; (O2 !== 0 || N2 < _2) && R2 !== -1; R2--, N2++) + O2 += 256 * E2[R2] >>> 0, E2[R2] = O2 % a2 >>> 0, O2 = O2 / a2 >>> 0; + if (O2 !== 0) throw new Error("Non-zero carry"); - z2 = A2, I2++; + _2 = N2, D2++; } - for (var x2 = T2 - z2; x2 !== T2 && f2[x2] === 0; ) - x2++; - for (var j2 = h2.repeat(m2); x2 < T2; ++x2) - j2 += n2.charAt(f2[x2]); + for (var A2 = x2 - _2; A2 !== x2 && E2[A2] === 0; ) + A2++; + for (var j2 = h2.repeat(p2); A2 < x2; ++A2) + j2 += n2.charAt(E2[A2]); return j2; } - function y2(u2) { + function m2(u2) { if (typeof u2 != "string") throw new TypeError("Expected String"); if (u2.length === 0) return new Uint8Array(); - var m2 = 0; - if (u2[m2] !== " ") { - for (var z2 = 0, I2 = 0; u2[m2] === h2; ) - z2++, m2++; - for (var _2 = (u2.length - m2) * l2 + 1 >>> 0, T2 = new Uint8Array(_2); u2[m2]; ) { - var f2 = t2[u2.charCodeAt(m2)]; - if (f2 === 255) + var p2 = 0; + if (u2[p2] !== " ") { + for (var _2 = 0, D2 = 0; u2[p2] === h2; ) + _2++, p2++; + for (var P2 = (u2.length - p2) * l2 + 1 >>> 0, x2 = new Uint8Array(P2); u2[p2]; ) { + var E2 = t2[u2.charCodeAt(p2)]; + if (E2 === 255) return; - for (var S2 = 0, A2 = _2 - 1; (f2 !== 0 || S2 < I2) && A2 !== -1; A2--, S2++) - f2 += a2 * T2[A2] >>> 0, T2[A2] = f2 % 256 >>> 0, f2 = f2 / 256 >>> 0; - if (f2 !== 0) + for (var O2 = 0, N2 = P2 - 1; (E2 !== 0 || O2 < D2) && N2 !== -1; N2--, O2++) + E2 += a2 * x2[N2] >>> 0, x2[N2] = E2 % 256 >>> 0, E2 = E2 / 256 >>> 0; + if (E2 !== 0) throw new Error("Non-zero carry"); - I2 = S2, m2++; + D2 = O2, p2++; } - if (u2[m2] !== " ") { - for (var C2 = _2 - I2; C2 !== _2 && T2[C2] === 0; ) - C2++; - for (var x2 = new Uint8Array(z2 + (_2 - C2)), j2 = z2; C2 !== _2; ) - x2[j2++] = T2[C2++]; - return x2; + if (u2[p2] !== " ") { + for (var R2 = P2 - D2; R2 !== P2 && x2[R2] === 0; ) + R2++; + for (var A2 = new Uint8Array(_2 + (P2 - R2)), j2 = _2; R2 !== P2; ) + A2[j2++] = x2[R2++]; + return A2; } } } - function M2(u2) { - var m2 = y2(u2); - if (m2) - return m2; + function L2(u2) { + var p2 = m2(u2); + if (p2) + return p2; throw new Error(`Non-${e2} character`); } - return { encode: p2, decodeUnsafe: y2, decode: M2 }; + return { encode: g2, decodeUnsafe: m2, decode: L2 }; } - var Ji = Hi, Xi = Ji; - const Ne = (n2) => { + var Xi = Ji, Wi = Xi; + const Ue$2 = (n2) => { if (n2 instanceof Uint8Array && n2.constructor.name === "Uint8Array") return n2; if (n2 instanceof ArrayBuffer) @@ -10183,8 +13692,8 @@ if (ArrayBuffer.isView(n2)) return new Uint8Array(n2.buffer, n2.byteOffset, n2.byteLength); throw new Error("Unknown type, must be binary type"); - }, Wi = (n2) => new TextEncoder().encode(n2), Qi = (n2) => new TextDecoder().decode(n2); - class Zi { + }, Qi = (n2) => new TextEncoder().encode(n2), Zi = (n2) => new TextDecoder().decode(n2); + let es$1 = class es { constructor(e2, t2, i2) { this.name = e2, this.prefix = t2, this.baseEncode = i2; } @@ -10193,8 +13702,8 @@ return `${this.prefix}${this.baseEncode(e2)}`; throw Error("Unknown type, must be binary type"); } - } - class es { + }; + let ts$1 = class ts { constructor(e2, t2, i2) { if (this.name = e2, this.prefix = t2, t2.codePointAt(0) === void 0) throw new Error("Invalid prefix character"); @@ -10209,15 +13718,15 @@ throw Error("Can only multibase decode strings"); } or(e2) { - return Ue$1(this, e2); + return $e$1(this, e2); } - } - class ts { + }; + let is$1 = class is { constructor(e2) { this.decoders = e2; } or(e2) { - return Ue$1(this, e2); + return $e$1(this, e2); } decode(e2) { const t2 = e2[0], i2 = this.decoders[t2]; @@ -10225,11 +13734,11 @@ return i2.decode(e2); throw RangeError(`Unable to decode multibase string ${JSON.stringify(e2)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); } - } - const Ue$1 = (n2, e2) => new ts({ ...n2.decoders || { [n2.prefix]: n2 }, ...e2.decoders || { [e2.prefix]: e2 } }); - class is { + }; + const $e$1 = (n2, e2) => new is$1({ ...n2.decoders || { [n2.prefix]: n2 }, ...e2.decoders || { [e2.prefix]: e2 } }); + let ss$2 = class ss { constructor(e2, t2, i2, s2) { - this.name = e2, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new Zi(e2, t2, i2), this.decoder = new es(e2, t2, s2); + this.name = e2, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new es$1(e2, t2, i2), this.decoder = new ts$1(e2, t2, s2); } encode(e2) { return this.encoder.encode(e2); @@ -10237,11 +13746,11 @@ decode(e2) { return this.decoder.decode(e2); } - } - const W$1 = ({ name: n2, prefix: e2, encode: t2, decode: i2 }) => new is(n2, e2, t2, i2), B$2 = ({ prefix: n2, name: e2, alphabet: t2 }) => { - const { encode: i2, decode: s2 } = Xi(t2, e2); - return W$1({ prefix: n2, name: e2, encode: i2, decode: (r2) => Ne(s2(r2)) }); - }, ss = (n2, e2, t2, i2) => { + }; + const Q$1 = ({ name: n2, prefix: e2, encode: t2, decode: i2 }) => new ss$2(n2, e2, t2, i2), K$2 = ({ prefix: n2, name: e2, alphabet: t2 }) => { + const { encode: i2, decode: s2 } = Wi(t2, e2); + return Q$1({ prefix: n2, name: e2, encode: i2, decode: (r2) => Ue$2(s2(r2)) }); + }, rs$1 = (n2, e2, t2, i2) => { const s2 = {}; for (let d2 = 0; d2 < e2.length; ++d2) s2[e2[d2]] = d2; @@ -10251,15 +13760,15 @@ const o2 = new Uint8Array(r2 * t2 / 8 | 0); let a2 = 0, h2 = 0, l2 = 0; for (let d2 = 0; d2 < r2; ++d2) { - const p2 = s2[n2[d2]]; - if (p2 === void 0) + const g2 = s2[n2[d2]]; + if (g2 === void 0) throw new SyntaxError(`Non-${i2} character`); - h2 = h2 << t2 | p2, a2 += t2, a2 >= 8 && (a2 -= 8, o2[l2++] = 255 & h2 >> a2); + h2 = h2 << t2 | g2, a2 += t2, a2 >= 8 && (a2 -= 8, o2[l2++] = 255 & h2 >> a2); } if (a2 >= t2 || 255 & h2 << 8 - a2) throw new SyntaxError("Unexpected end of data"); return o2; - }, rs = (n2, e2, t2) => { + }, ns = (n2, e2, t2) => { const i2 = e2[e2.length - 1] === "=", s2 = (1 << t2) - 1; let r2 = "", o2 = 0, a2 = 0; for (let h2 = 0; h2 < n2.length; ++h2) @@ -10269,125 +13778,125 @@ for (; r2.length * t2 & 7; ) r2 += "="; return r2; - }, g$3 = ({ name: n2, prefix: e2, bitsPerChar: t2, alphabet: i2 }) => W$1({ prefix: e2, name: n2, encode(s2) { - return rs(s2, i2, t2); + }, y$1 = ({ name: n2, prefix: e2, bitsPerChar: t2, alphabet: i2 }) => Q$1({ prefix: e2, name: n2, encode(s2) { + return ns(s2, i2, t2); }, decode(s2) { - return ss(s2, i2, t2, n2); - } }), ns = W$1({ prefix: "\0", name: "identity", encode: (n2) => Qi(n2), decode: (n2) => Wi(n2) }); - var os = Object.freeze({ __proto__: null, identity: ns }); - const as$1 = g$3({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); - var hs$1 = Object.freeze({ __proto__: null, base2: as$1 }); - const cs$1 = g$3({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); - var us$1 = Object.freeze({ __proto__: null, base8: cs$1 }); - const ls$1 = B$2({ prefix: "9", name: "base10", alphabet: "0123456789" }); - var ds$1 = Object.freeze({ __proto__: null, base10: ls$1 }); - const gs$1 = g$3({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), ps$1 = g$3({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); - var Ds = Object.freeze({ __proto__: null, base16: gs$1, base16upper: ps$1 }); - const ys = g$3({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), ms$1 = g$3({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), bs = g$3({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), fs = g$3({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), Es = g$3({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), ws = g$3({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), vs = g$3({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Is = g$3({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), Cs = g$3({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); - var Rs = Object.freeze({ __proto__: null, base32: ys, base32upper: ms$1, base32pad: bs, base32padupper: fs, base32hex: Es, base32hexupper: ws, base32hexpad: vs, base32hexpadupper: Is, base32z: Cs }); - const _s = B$2({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ts = B$2({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); - var Ss = Object.freeze({ __proto__: null, base36: _s, base36upper: Ts }); - const Ps = B$2({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), xs = B$2({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); - var Os = Object.freeze({ __proto__: null, base58btc: Ps, base58flickr: xs }); - const As = g$3({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), zs = g$3({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ns = g$3({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us = g$3({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); - var Ls = Object.freeze({ __proto__: null, base64: As, base64pad: zs, base64url: Ns, base64urlpad: Us }); - const Le$1 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), $s = Le$1.reduce((n2, e2, t2) => (n2[t2] = e2, n2), []), Fs = Le$1.reduce((n2, e2, t2) => (n2[e2.codePointAt(0)] = t2, n2), []); - function Ms(n2) { - return n2.reduce((e2, t2) => (e2 += $s[t2], e2), ""); - } - function ks(n2) { + return rs$1(s2, i2, t2, n2); + } }), os$1 = Q$1({ prefix: "\0", name: "identity", encode: (n2) => Zi(n2), decode: (n2) => Qi(n2) }); + var as$1 = Object.freeze({ __proto__: null, identity: os$1 }); + const hs$1 = y$1({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); + var cs$1 = Object.freeze({ __proto__: null, base2: hs$1 }); + const ls$1 = y$1({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); + var us$1 = Object.freeze({ __proto__: null, base8: ls$1 }); + const ds$1 = K$2({ prefix: "9", name: "base10", alphabet: "0123456789" }); + var gs$1 = Object.freeze({ __proto__: null, base10: ds$1 }); + const ps$1 = y$1({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), Ds$1 = y$1({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); + var ys$1 = Object.freeze({ __proto__: null, base16: ps$1, base16upper: Ds$1 }); + const ms$2 = y$1({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), bs$1 = y$1({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), fs = y$1({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), Es$1 = y$1({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), ws$1 = y$1({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), vs$1 = y$1({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), Is$1 = y$1({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Cs$1 = y$1({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), _s$1 = y$1({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); + var Rs$1 = Object.freeze({ __proto__: null, base32: ms$2, base32upper: bs$1, base32pad: fs, base32padupper: Es$1, base32hex: ws$1, base32hexupper: vs$1, base32hexpad: Is$1, base32hexpadupper: Cs$1, base32z: _s$1 }); + const Ts$1 = K$2({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ss$1 = K$2({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); + var Ps$1 = Object.freeze({ __proto__: null, base36: Ts$1, base36upper: Ss$1 }); + const xs$1 = K$2({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), Os$1 = K$2({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); + var As$1 = Object.freeze({ __proto__: null, base58btc: xs$1, base58flickr: Os$1 }); + const zs$1 = y$1({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), Ns$1 = y$1({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ls$1 = y$1({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us$1 = y$1({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); + var $s$1 = Object.freeze({ __proto__: null, base64: zs$1, base64pad: Ns$1, base64url: Ls$1, base64urlpad: Us$1 }); + const Fe$2 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), Fs$1 = Fe$2.reduce((n2, e2, t2) => (n2[t2] = e2, n2), []), ks$1 = Fe$2.reduce((n2, e2, t2) => (n2[e2.codePointAt(0)] = t2, n2), []); + function Bs$1(n2) { + return n2.reduce((e2, t2) => (e2 += Fs$1[t2], e2), ""); + } + function Ms$1(n2) { const e2 = []; for (const t2 of n2) { - const i2 = Fs[t2.codePointAt(0)]; + const i2 = ks$1[t2.codePointAt(0)]; if (i2 === void 0) throw new Error(`Non-base256emoji character: ${t2}`); e2.push(i2); } return new Uint8Array(e2); } - const Ks = W$1({ prefix: "🚀", name: "base256emoji", encode: Ms, decode: ks }); - var Bs = Object.freeze({ __proto__: null, base256emoji: Ks }), Vs = Fe$1, $e$1 = 128, qs = 127, js = ~qs, Gs = Math.pow(2, 31); - function Fe$1(n2, e2, t2) { + const Ks$1 = Q$1({ prefix: "🚀", name: "base256emoji", encode: Bs$1, decode: Ms$1 }); + var Vs$1 = Object.freeze({ __proto__: null, base256emoji: Ks$1 }), qs$1 = Be$3, ke$2 = 128, js$1 = 127, Gs$1 = ~js$1, Ys$1 = Math.pow(2, 31); + function Be$3(n2, e2, t2) { e2 = e2 || [], t2 = t2 || 0; - for (var i2 = t2; n2 >= Gs; ) - e2[t2++] = n2 & 255 | $e$1, n2 /= 128; - for (; n2 & js; ) - e2[t2++] = n2 & 255 | $e$1, n2 >>>= 7; - return e2[t2] = n2 | 0, Fe$1.bytes = t2 - i2 + 1, e2; - } - var Ys = he$2, Hs = 128, Me$1 = 127; - function he$2(n2, i2) { + for (var i2 = t2; n2 >= Ys$1; ) + e2[t2++] = n2 & 255 | ke$2, n2 /= 128; + for (; n2 & Gs$1; ) + e2[t2++] = n2 & 255 | ke$2, n2 >>>= 7; + return e2[t2] = n2 | 0, Be$3.bytes = t2 - i2 + 1, e2; + } + var Hs$1 = de$2, Js$1 = 128, Me$1 = 127; + function de$2(n2, i2) { var t2 = 0, i2 = i2 || 0, s2 = 0, r2 = i2, o2, a2 = n2.length; do { if (r2 >= a2) - throw he$2.bytes = 0, new RangeError("Could not decode varint"); + throw de$2.bytes = 0, new RangeError("Could not decode varint"); o2 = n2[r2++], t2 += s2 < 28 ? (o2 & Me$1) << s2 : (o2 & Me$1) * Math.pow(2, s2), s2 += 7; - } while (o2 >= Hs); - return he$2.bytes = r2 - i2, t2; + } while (o2 >= Js$1); + return de$2.bytes = r2 - i2, t2; } - var Js = Math.pow(2, 7), Xs = Math.pow(2, 14), Ws = Math.pow(2, 21), Qs = Math.pow(2, 28), Zs = Math.pow(2, 35), er$1 = Math.pow(2, 42), tr$1 = Math.pow(2, 49), ir$1 = Math.pow(2, 56), sr$1 = Math.pow(2, 63), rr$1 = function(n2) { - return n2 < Js ? 1 : n2 < Xs ? 2 : n2 < Ws ? 3 : n2 < Qs ? 4 : n2 < Zs ? 5 : n2 < er$1 ? 6 : n2 < tr$1 ? 7 : n2 < ir$1 ? 8 : n2 < sr$1 ? 9 : 10; - }, nr$1 = { encode: Vs, decode: Ys, encodingLength: rr$1 }, ke$1 = nr$1; - const Ke$1 = (n2, e2, t2 = 0) => (ke$1.encode(n2, e2, t2), e2), Be$1 = (n2) => ke$1.encodingLength(n2), ce$2 = (n2, e2) => { - const t2 = e2.byteLength, i2 = Be$1(n2), s2 = i2 + Be$1(t2), r2 = new Uint8Array(s2 + t2); - return Ke$1(n2, r2, 0), Ke$1(t2, r2, i2), r2.set(e2, s2), new or$1(n2, t2, e2, r2); + var Xs$1 = Math.pow(2, 7), Ws$1 = Math.pow(2, 14), Qs$1 = Math.pow(2, 21), Zs$1 = Math.pow(2, 28), er$1 = Math.pow(2, 35), tr$1 = Math.pow(2, 42), ir$2 = Math.pow(2, 49), sr$2 = Math.pow(2, 56), rr$2 = Math.pow(2, 63), nr$2 = function(n2) { + return n2 < Xs$1 ? 1 : n2 < Ws$1 ? 2 : n2 < Qs$1 ? 3 : n2 < Zs$1 ? 4 : n2 < er$1 ? 5 : n2 < tr$1 ? 6 : n2 < ir$2 ? 7 : n2 < sr$2 ? 8 : n2 < rr$2 ? 9 : 10; + }, or$1 = { encode: qs$1, decode: Hs$1, encodingLength: nr$2 }, Ke$2 = or$1; + const Ve$1 = (n2, e2, t2 = 0) => (Ke$2.encode(n2, e2, t2), e2), qe$1 = (n2) => Ke$2.encodingLength(n2), ge$1 = (n2, e2) => { + const t2 = e2.byteLength, i2 = qe$1(n2), s2 = i2 + qe$1(t2), r2 = new Uint8Array(s2 + t2); + return Ve$1(n2, r2, 0), Ve$1(t2, r2, i2), r2.set(e2, s2), new ar$1(n2, t2, e2, r2); }; - let or$1 = class or { + let ar$1 = class ar { constructor(e2, t2, i2, s2) { this.code = e2, this.size = t2, this.digest = i2, this.bytes = s2; } }; - const Ve$1 = ({ name: n2, code: e2, encode: t2 }) => new ar$1(n2, e2, t2); - let ar$1 = class ar { + const je$2 = ({ name: n2, code: e2, encode: t2 }) => new hr$1(n2, e2, t2); + let hr$1 = class hr { constructor(e2, t2, i2) { this.name = e2, this.code = t2, this.encode = i2; } digest(e2) { if (e2 instanceof Uint8Array) { const t2 = this.encode(e2); - return t2 instanceof Uint8Array ? ce$2(this.code, t2) : t2.then((i2) => ce$2(this.code, i2)); + return t2 instanceof Uint8Array ? ge$1(this.code, t2) : t2.then((i2) => ge$1(this.code, i2)); } else throw Error("Unknown type, must be binary type"); } }; - const qe$1 = (n2) => async (e2) => new Uint8Array(await crypto.subtle.digest(n2, e2)), hr$1 = Ve$1({ name: "sha2-256", code: 18, encode: qe$1("SHA-256") }), cr$1 = Ve$1({ name: "sha2-512", code: 19, encode: qe$1("SHA-512") }); - var ur = Object.freeze({ __proto__: null, sha256: hr$1, sha512: cr$1 }); - const je$1 = 0, lr$1 = "identity", Ge$1 = Ne, dr$1 = (n2) => ce$2(je$1, Ge$1(n2)), gr = { code: je$1, name: lr$1, encode: Ge$1, digest: dr$1 }; - var pr = Object.freeze({ __proto__: null, identity: gr }); + const Ge$2 = (n2) => async (e2) => new Uint8Array(await crypto.subtle.digest(n2, e2)), cr$2 = je$2({ name: "sha2-256", code: 18, encode: Ge$2("SHA-256") }), lr = je$2({ name: "sha2-512", code: 19, encode: Ge$2("SHA-512") }); + var ur$1 = Object.freeze({ __proto__: null, sha256: cr$2, sha512: lr }); + const Ye$2 = 0, dr$2 = "identity", He$2 = Ue$2, gr$1 = (n2) => ge$1(Ye$2, He$2(n2)), pr = { code: Ye$2, name: dr$2, encode: He$2, digest: gr$1 }; + var Dr$1 = Object.freeze({ __proto__: null, identity: pr }); new TextEncoder(), new TextDecoder(); - const Ye$1 = { ...os, ...hs$1, ...us$1, ...ds$1, ...Ds, ...Rs, ...Ss, ...Os, ...Ls, ...Bs }; - ({ ...ur, ...pr }); - function He$1(n2) { + const Je$1 = { ...as$1, ...cs$1, ...us$1, ...gs$1, ...ys$1, ...Rs$1, ...Ps$1, ...As$1, ...$s$1, ...Vs$1 }; + ({ ...ur$1, ...Dr$1 }); + function Xe$2(n2) { return globalThis.Buffer != null ? new Uint8Array(n2.buffer, n2.byteOffset, n2.byteLength) : n2; } - function Dr(n2 = 0) { - return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? He$1(globalThis.Buffer.allocUnsafe(n2)) : new Uint8Array(n2); + function yr$1(n2 = 0) { + return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? Xe$2(globalThis.Buffer.allocUnsafe(n2)) : new Uint8Array(n2); } - function Je(n2, e2, t2, i2) { + function We$2(n2, e2, t2, i2) { return { name: n2, prefix: e2, encoder: { name: n2, prefix: e2, encode: t2 }, decoder: { decode: i2 } }; } - const Xe = Je("utf8", "u", (n2) => "u" + new TextDecoder("utf8").decode(n2), (n2) => new TextEncoder().encode(n2.substring(1))), ue$2 = Je("ascii", "a", (n2) => { + const Qe$2 = We$2("utf8", "u", (n2) => "u" + new TextDecoder("utf8").decode(n2), (n2) => new TextEncoder().encode(n2.substring(1))), pe$2 = We$2("ascii", "a", (n2) => { let e2 = "a"; for (let t2 = 0; t2 < n2.length; t2++) e2 += String.fromCharCode(n2[t2]); return e2; }, (n2) => { n2 = n2.substring(1); - const e2 = Dr(n2.length); + const e2 = yr$1(n2.length); for (let t2 = 0; t2 < n2.length; t2++) e2[t2] = n2.charCodeAt(t2); return e2; - }), yr = { utf8: Xe, "utf-8": Xe, hex: Ye$1.base16, latin1: ue$2, ascii: ue$2, binary: ue$2, ...Ye$1 }; - function mr$1(n2, e2 = "utf8") { - const t2 = yr[e2]; + }), mr$2 = { utf8: Qe$2, "utf-8": Qe$2, hex: Je$1.base16, latin1: pe$2, ascii: pe$2, binary: pe$2, ...Je$1 }; + function br(n2, e2 = "utf8") { + const t2 = mr$2[e2]; if (!t2) throw new Error(`Unsupported encoding "${e2}"`); - return (e2 === "utf8" || e2 === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? He$1(globalThis.Buffer.from(n2, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n2}`); + return (e2 === "utf8" || e2 === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? Xe$2(globalThis.Buffer.from(n2, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n2}`); } - const le$2 = "wc", We$1 = 2, Q$2 = "core", O = `${le$2}@2:${Q$2}:`, Qe$1 = { name: Q$2, logger: "error" }, Ze = { database: ":memory:" }, et$1 = "crypto", de$2 = "client_ed25519_seed", tt$1 = cjs$4.ONE_DAY, it$1 = "keychain", st$1 = "0.3", rt$1 = "messages", nt$1 = "0.3", ot$1 = cjs$4.SIX_HOURS, at$1 = "publisher", ht$1 = "irn", ct$1 = "error", ge$1 = "wss://relay.walletconnect.com", pe$1 = "wss://relay.walletconnect.org", ut$1 = "relayer", D$3 = { 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" }, lt$1 = "_subscription", P$2 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, dt$1 = cjs$4.ONE_SECOND, gt$1 = "2.11.2", pt$1 = 1e4, Dt$1 = "0.3", yt$1 = "WALLETCONNECT_CLIENT_ID", w$2 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, mt$1 = "subscription", bt$1 = "0.3", ft$1 = cjs$4.FIVE_SECONDS * 1e3, Et$1 = "pairing", wt$1 = "0.3", $$1 = { wc_pairingDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 } } }, V$1 = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, R$2 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, vt$1 = "history", It$1 = "0.3", Ct$1 = "expirer", v$2 = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Rt$1 = "0.3", Z$2 = "verify-api", F$2 = "https://verify.walletconnect.com", ee$1 = "https://verify.walletconnect.org", _t$1 = [F$2, ee$1], Tt$1 = "echo", St$1 = "https://echo.walletconnect.com"; - let Pt$1 = class Pt { + const De$1 = "wc", Ze$2 = 2, Z$2 = "core", z$2 = `${De$1}@2:${Z$2}:`, et$1 = { name: Z$2, logger: "error" }, tt$1 = { database: ":memory:" }, it$1 = "crypto", ye$2 = "client_ed25519_seed", st$1 = cjs$3.ONE_DAY, rt$1 = "keychain", nt$1 = "0.3", ot$1 = "messages", at$1 = "0.3", ht$1 = cjs$3.SIX_HOURS, ct$1 = "publisher", lt$1 = "irn", ut$1 = "error", me$1 = "wss://relay.walletconnect.com", be$1 = "wss://relay.walletconnect.org", dt$1 = "relayer", v$1 = { 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" }, gt = "_subscription", f$2 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, pt$1 = cjs$3.ONE_SECOND, Dt$2 = "2.12.2", yt$1 = 1e4, mt = "0.3", bt$1 = "WALLETCONNECT_CLIENT_ID", S$4 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, ft = "subscription", Et$1 = "0.3", wt = cjs$3.FIVE_SECONDS * 1e3, vt = "pairing", It$1 = "0.3", F$1 = { wc_pairingDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 } } }, V$2 = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, I$2 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, Ct = "history", _t$1 = "0.3", Rt$1 = "expirer", C$1 = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Tt$2 = "0.3", ee$1 = "verify-api", k$2 = "https://verify.walletconnect.com", te = "https://verify.walletconnect.org", St$1 = [k$2, te], Pt$1 = "echo", xt = "https://echo.walletconnect.com"; + let Ot$2 = class Ot { constructor(e2, t2) { - this.core = e2, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = it$1, this.version = st$1, this.initialized = false, this.storagePrefix = O, this.init = async () => { + this.core = e2, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = rt$1, this.version = nt$1, this.initialized = false, this.storagePrefix = z$2, this.init = async () => { if (!this.initialized) { const i2 = await this.getKeyChain(); typeof i2 < "u" && (this.keychain = i2), this.initialized = true; @@ -10398,40 +13907,40 @@ this.isInitialized(); const s2 = this.keychain.get(i2); if (typeof s2 > "u") { - const { message: r2 } = N$2("NO_MATCHING_KEY", `${this.name}: ${i2}`); + const { message: r2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${i2}`); throw new Error(r2); } return s2; }, this.del = async (i2) => { this.isInitialized(), this.keychain.delete(i2), await this.persist(); - }, this.core = e2, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.core = e2, this.logger = E$2(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$3(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } async setKeyChain(e2) { - await this.core.storage.setItem(this.storageKey, rt$2(e2)); + await this.core.storage.setItem(this.storageKey, i0(e2)); } async getKeyChain() { const e2 = await this.core.storage.getItem(this.storageKey); - return typeof e2 < "u" ? ot$2(e2) : void 0; + return typeof e2 < "u" ? n0(e2) : void 0; } async persist() { await this.setKeyChain(this.keychain); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } }; - let xt$1 = class xt { + let At$1 = class At { constructor(e2, t2, i2) { - this.core = e2, this.logger = t2, this.name = et$1, this.initialized = false, this.init = async () => { + this.core = e2, this.logger = t2, this.name = it$1, this.initialized = false, this.init = async () => { this.initialized || (await this.keychain.init(), this.initialized = true); }, this.hasKeys = (s2) => (this.isInitialized(), this.keychain.has(s2)), this.getClientId = async () => { this.isInitialized(); @@ -10439,19 +13948,19 @@ return encodeIss(r2.publicKey); }, this.generateKeyPair = () => { this.isInitialized(); - const s2 = kn(); + const s2 = mu(); return this.setPrivateKey(s2.publicKey, s2.privateKey); }, this.signJWT = async (s2) => { this.isInitialized(); - const r2 = await this.getClientSeed(), o2 = generateKeyPair(r2), a2 = Vn(), h2 = tt$1; + const r2 = await this.getClientSeed(), o2 = generateKeyPair(r2), a2 = gu(), h2 = st$1; return await signJWT(a2, s2, h2, o2); }, this.generateSharedKey = (s2, r2, o2) => { this.isInitialized(); - const a2 = this.getPrivateKey(s2), h2 = Mn(a2, r2); + const a2 = this.getPrivateKey(s2), h2 = Au(a2, r2); return this.setSymKey(h2, o2); }, this.setSymKey = async (s2, r2) => { this.isInitialized(); - const o2 = r2 || Kn(s2); + const o2 = r2 || bu(s2); return await this.keychain.set(o2, s2), o2; }, this.deleteKeyPair = async (s2) => { this.isInitialized(), await this.keychain.del(s2); @@ -10459,36 +13968,36 @@ this.isInitialized(), await this.keychain.del(s2); }, this.encode = async (s2, r2, o2) => { this.isInitialized(); - const a2 = Ae$1(o2), h2 = safeJsonStringify(r2); - if (qn(a2)) { - const y2 = a2.senderPublicKey, M2 = a2.receiverPublicKey; - s2 = await this.generateSharedKey(y2, M2); + const a2 = eo$1(o2), h2 = safeJsonStringify(r2); + if (Eu(a2)) { + const m2 = a2.senderPublicKey, L2 = a2.receiverPublicKey; + s2 = await this.generateSharedKey(m2, L2); } - const l2 = this.getSymKey(s2), { type: d2, senderPublicKey: p2 } = a2; - return xn({ type: d2, symKey: l2, message: h2, senderPublicKey: p2 }); + const l2 = this.getSymKey(s2), { type: d2, senderPublicKey: g2 } = a2; + return wu({ type: d2, symKey: l2, message: h2, senderPublicKey: g2 }); }, this.decode = async (s2, r2, o2) => { this.isInitialized(); - const a2 = Hn(r2, o2); - if (qn(a2)) { + const a2 = Mu(r2, o2); + if (Eu(a2)) { const h2 = a2.receiverPublicKey, l2 = a2.senderPublicKey; s2 = await this.generateSharedKey(h2, l2); } try { - const h2 = this.getSymKey(s2), l2 = Fn({ symKey: h2, encoded: r2 }); + const h2 = this.getSymKey(s2), l2 = xu({ symKey: h2, encoded: r2 }); return safeJsonParse(l2); } catch (h2) { this.logger.error(`Failed to decode message from topic: '${s2}', clientId: '${await this.getClientId()}'`), this.logger.error(h2); } }, this.getPayloadType = (s2) => { - const r2 = ee$2(s2); - return j$2(r2.type); + const r2 = Xi$1(s2); + return Mr(r2.type); }, this.getPayloadSenderPublicKey = (s2) => { - const r2 = ee$2(s2); - return r2.senderPublicKey ? toString(r2.senderPublicKey, p$2) : void 0; - }, this.core = e2, this.logger = cjs$3.generateChildLogger(t2, this.name), this.keychain = i2 || new Pt$1(this.core, this.logger); + const r2 = Xi$1(s2); + return r2.senderPublicKey ? toString(r2.senderPublicKey, zt$2) : void 0; + }, this.core = e2, this.logger = E$2(t2, this.name), this.keychain = i2 || new Ot$2(this.core, this.logger); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$3(this.logger); } async setPrivateKey(e2, t2) { return await this.keychain.set(e2, t2), e2; @@ -10499,25 +14008,25 @@ async getClientSeed() { let e2 = ""; try { - e2 = this.keychain.get(de$2); + e2 = this.keychain.get(ye$2); } catch { - e2 = Vn(), await this.keychain.set(de$2, e2); + e2 = gu(), await this.keychain.set(ye$2, e2); } - return mr$1(e2, "base16"); + return br(e2, "base16"); } getSymKey(e2) { return this.keychain.get(e2); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } }; - let Ot$1 = class Ot extends a$4 { + let zt$1 = class zt extends a$3 { constructor(e2, t2) { - super(e2, t2), this.logger = e2, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = rt$1, this.version = nt$1, this.initialized = false, this.storagePrefix = O, this.init = async () => { + super(e2, t2), this.logger = e2, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = ot$1, this.version = at$1, this.initialized = false, this.storagePrefix = z$2, this.init = async () => { if (!this.initialized) { this.logger.trace("Initialized"); try { @@ -10531,7 +14040,7 @@ } }, this.set = async (i2, s2) => { this.isInitialized(); - const r2 = Ln(s2); + const r2 = yu(s2); let o2 = this.messages.get(i2); return typeof o2 > "u" && (o2 = {}), typeof o2[r2] < "u" || (o2[r2] = s2, this.messages.set(i2, o2), await this.persist()), r2; }, this.get = (i2) => { @@ -10540,54 +14049,53 @@ return typeof s2 > "u" && (s2 = {}), s2; }, this.has = (i2, s2) => { this.isInitialized(); - const r2 = this.get(i2), o2 = Ln(s2); + const r2 = this.get(i2), o2 = yu(s2); return typeof r2[o2] < "u"; }, this.del = async (i2) => { this.isInitialized(), this.messages.delete(i2), await this.persist(); - }, this.logger = cjs$3.generateChildLogger(e2, this.name), this.core = t2; + }, this.logger = E$2(e2, this.name), this.core = t2; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$3(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } async setRelayerMessages(e2) { - await this.core.storage.setItem(this.storageKey, rt$2(e2)); + await this.core.storage.setItem(this.storageKey, i0(e2)); } async getRelayerMessages() { const e2 = await this.core.storage.getItem(this.storageKey); - return typeof e2 < "u" ? ot$2(e2) : void 0; + return typeof e2 < "u" ? n0(e2) : void 0; } async persist() { await this.setRelayerMessages(this.messages); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } }; - class vr extends u$3 { + class Ir extends u$3 { constructor(e2, t2) { - super(e2, t2), this.relayer = e2, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = at$1, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$4.toMiliseconds(cjs$4.TEN_SECONDS * 2), this.needsTransportRestart = false, this.publish = async (i2, s2, r2) => { + super(e2, t2), this.relayer = e2, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = ct$1, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.failedPublishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_SECOND), this.needsTransportRestart = false, this.publish = async (i2, s2, r2) => { var o2; this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); + const a2 = (r2 == null ? void 0 : r2.ttl) || ht$1, h2 = Su(r2), l2 = (r2 == null ? void 0 : r2.prompt) || false, d2 = (r2 == null ? void 0 : r2.tag) || 0, g2 = (r2 == null ? void 0 : r2.id) || getBigIntRpcId().toString(), m2 = { topic: i2, message: s2, opts: { ttl: a2, relay: h2, prompt: l2, tag: d2, id: g2 } }, L2 = `Failed to publish payload, please try again. id:${g2} tag:${d2}`, u2 = Date.now(); + let p2, _2 = 1; try { - const a2 = (r2 == null ? void 0 : r2.ttl) || ot$1, h2 = vt$2(r2), l2 = (r2 == null ? void 0 : r2.prompt) || false, d2 = (r2 == null ? void 0 : r2.tag) || 0, p2 = (r2 == null ? void 0 : r2.id) || getBigIntRpcId().toString(), y2 = { topic: i2, message: s2, opts: { ttl: a2, relay: h2, prompt: l2, tag: d2, id: p2 } }, M2 = setTimeout(() => this.queue.set(p2, y2), this.publishTimeout); - try { - await await ut$2(this.rpcPublish(i2, s2, a2, h2, l2, d2, p2), this.publishTimeout, `Failed to publish payload, please try again. id:${p2} tag:${d2}`), this.removeRequestFromQueue(p2), this.relayer.events.emit(D$3.publish, y2); - } catch (u2) { - if (this.logger.debug("Publishing Payload stalled"), this.needsTransportRestart = true, (o2 = r2 == null ? void 0 : r2.internal) != null && o2.throwOnFailedPublish) - throw this.removeRequestFromQueue(p2), u2; - return; - } finally { - clearTimeout(M2); + for (; p2 === void 0; ) { + if (Date.now() - u2 > this.publishTimeout) + throw new Error(L2); + this.logger.trace({ id: g2, attempts: _2 }, `publisher.publish - attempt ${_2}`), p2 = await await u0(this.rpcPublish(i2, s2, a2, h2, l2, d2, g2).catch((D2) => this.logger.warn(D2)), this.publishTimeout, L2), _2++, p2 || await new Promise((D2) => setTimeout(D2, this.failedPublishTimeout)); } - this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); - } catch (a2) { - throw this.logger.debug("Failed to Publish Payload"), this.logger.error(a2), a2; + this.relayer.events.emit(v$1.publish, m2), this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { id: g2, topic: i2, message: s2, opts: r2 } }); + } catch (D2) { + if (this.logger.debug("Failed to Publish Payload"), this.logger.error(D2), (o2 = r2 == null ? void 0 : r2.internal) != null && o2.throwOnFailedPublish) + throw D2; + this.queue.set(g2, m2); } }, this.on = (i2, s2) => { this.events.on(i2, s2); @@ -10597,15 +14105,15 @@ this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); - }, this.relayer = e2, this.logger = cjs$3.generateChildLogger(t2, this.name), this.registerEventListeners(); + }, this.relayer = e2, this.logger = E$2(t2, this.name), this.registerEventListeners(); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$3(this.logger); } rpcPublish(e2, t2, i2, s2, r2, o2, a2) { - var h2, l2, d2, p2; - const y2 = { method: Et$2(s2.protocol).publish, params: { topic: e2, message: t2, ttl: i2, prompt: r2, tag: o2 }, id: a2 }; - return w$4((h2 = y2.params) == null ? void 0 : h2.prompt) && ((l2 = y2.params) == null || delete l2.prompt), w$4((d2 = y2.params) == null ? void 0 : d2.tag) && ((p2 = y2.params) == null || delete p2.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: y2 }), this.relayer.request(y2); + var h2, l2, d2, g2; + const m2 = { method: Nu(s2.protocol).publish, params: { topic: e2, message: t2, ttl: i2, prompt: r2, tag: o2 }, id: a2 }; + return Pe$1((h2 = m2.params) == null ? void 0 : h2.prompt) && ((l2 = m2.params) == null || delete l2.prompt), Pe$1((d2 = m2.params) == null ? void 0 : d2.tag) && ((g2 = m2.params) == null || delete g2.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: m2 }), this.relayer.request(m2); } removeRequestFromQueue(e2) { this.queue.delete(e2); @@ -10617,18 +14125,18 @@ }); } registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { if (this.needsTransportRestart) { - this.needsTransportRestart = false, this.relayer.events.emit(D$3.connection_stalled); + this.needsTransportRestart = false, this.relayer.events.emit(v$1.connection_stalled); return; } this.checkQueue(); - }), this.relayer.on(D$3.message_ack, (e2) => { + }), this.relayer.on(v$1.message_ack, (e2) => { this.removeRequestFromQueue(e2.id.toString()); }); } } - class Ir { + let Cr$1 = class Cr { constructor() { this.map = /* @__PURE__ */ new Map(), this.set = (e2, t2) => { const i2 = this.get(e2); @@ -10656,26 +14164,26 @@ get topics() { return Array.from(this.map.keys()); } - } - var Cr = Object.defineProperty, Rr = Object.defineProperties, _r = Object.getOwnPropertyDescriptors, At$1 = Object.getOwnPropertySymbols, Tr = Object.prototype.hasOwnProperty, Sr = Object.prototype.propertyIsEnumerable, zt$1 = (n2, e2, t2) => e2 in n2 ? Cr(n2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n2[e2] = t2, q$2 = (n2, e2) => { + }; + var _r = Object.defineProperty, Rr$1 = Object.defineProperties, Tr$1 = Object.getOwnPropertyDescriptors, Nt$1 = Object.getOwnPropertySymbols, Sr = Object.prototype.hasOwnProperty, Pr$1 = Object.prototype.propertyIsEnumerable, Lt$2 = (n2, e2, t2) => e2 in n2 ? _r(n2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n2[e2] = t2, q$2 = (n2, e2) => { for (var t2 in e2 || (e2 = {})) - Tr.call(e2, t2) && zt$1(n2, t2, e2[t2]); - if (At$1) - for (var t2 of At$1(e2)) - Sr.call(e2, t2) && zt$1(n2, t2, e2[t2]); + Sr.call(e2, t2) && Lt$2(n2, t2, e2[t2]); + if (Nt$1) + for (var t2 of Nt$1(e2)) + Pr$1.call(e2, t2) && Lt$2(n2, t2, e2[t2]); return n2; - }, De$1 = (n2, e2) => Rr(n2, _r(e2)); - let Nt$1 = class Nt extends d$2 { + }, fe$2 = (n2, e2) => Rr$1(n2, Tr$1(e2)); + let Ut$2 = class Ut extends d$3 { constructor(e2, t2) { - super(e2, t2), this.relayer = e2, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Ir(), this.events = new eventsExports.EventEmitter(), this.name = mt$1, this.version = bt$1, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = O, this.subscribeTimeout = 1e4, this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { + super(e2, t2), this.relayer = e2, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Cr$1(), this.events = new eventsExports.EventEmitter(), this.name = ft, this.version = Et$1, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = z$2, this.subscribeTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), this.clientId = await this.relayer.core.crypto.getClientId()); }, this.subscribe = async (i2, s2) => { await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }); try { - const r2 = vt$2(s2), o2 = { topic: i2, relay: r2 }; + const r2 = Su(s2), o2 = { topic: i2, relay: r2 }; this.pending.set(i2, o2); const a2 = await this.rpcSubscribe(i2, r2); - return this.onSubscribe(a2, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }), a2; + return typeof a2 == "string" && (this.onSubscribe(a2, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } })), a2; } catch (r2) { throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r2), r2; } @@ -10686,10 +14194,10 @@ return true; const s2 = `${this.pendingSubscriptionWatchLabel}_${i2}`; return await new Promise((r2, o2) => { - const a2 = new cjs$4.Watch(); + const a2 = new cjs$3.Watch(); a2.start(s2); const h2 = setInterval(() => { - !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h2), a2.stop(s2), r2(true)), a2.elapsed(s2) >= ft$1 && (clearInterval(h2), a2.stop(s2), o2(new Error("Subscription resolution timeout"))); + !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h2), a2.stop(s2), r2(true)), a2.elapsed(s2) >= wt && (clearInterval(h2), a2.stop(s2), o2(new Error("Subscription resolution timeout"))); }, this.pollingInterval); }).catch(() => false); }, this.on = (i2, s2) => { @@ -10700,12 +14208,16 @@ this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); + }, this.start = async () => { + await this.onConnect(); + }, this.stop = async () => { + await this.onDisconnect(); }, this.restart = async () => { this.restartInProgress = true, await this.restore(), await this.reset(), this.restartInProgress = false; - }, this.relayer = e2, this.logger = cjs$3.generateChildLogger(t2, this.name), this.clientId = ""; + }, this.relayer = e2, this.logger = E$2(t2, this.name), this.clientId = ""; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$3(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.relayer.core.customStoragePrefix + "//" + this.name; @@ -10743,2504 +14255,2166 @@ async unsubscribeById(e2, t2, i2) { this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); try { - const s2 = vt$2(i2); + const s2 = Su(i2); await this.rpcUnsubscribe(e2, t2, s2); - const r2 = U$3("USER_DISCONNECTED", `${this.name}, ${e2}`); + const r2 = tr$2("USER_DISCONNECTED", `${this.name}, ${e2}`); await this.onUnsubscribe(e2, t2, r2), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); } catch (s2) { throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s2), s2; } } async rpcSubscribe(e2, t2) { - const i2 = { method: Et$2(t2.protocol).subscribe, params: { topic: e2 } }; + const i2 = { method: Nu(t2.protocol).subscribe, params: { topic: e2 } }; this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); try { - await await ut$2(this.relayer.request(i2), this.subscribeTimeout); + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout) ? yu(e2 + this.clientId) : null; } catch { - this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(D$3.connection_stalled); + this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(v$1.connection_stalled); } - return Ln(e2 + this.clientId); + return null; } async rpcBatchSubscribe(e2) { if (!e2.length) return; - const t2 = e2[0].relay, i2 = { method: Et$2(t2.protocol).batchSubscribe, params: { topics: e2.map((s2) => s2.topic) } }; + const t2 = e2[0].relay, i2 = { method: Nu(t2.protocol).batchSubscribe, params: { topics: e2.map((s2) => s2.topic) } }; this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); try { - return await await ut$2(this.relayer.request(i2), this.subscribeTimeout); + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout); } catch { - this.logger.debug("Outgoing Relay Payload stalled"), this.relayer.events.emit(D$3.connection_stalled); + this.relayer.events.emit(v$1.connection_stalled); } } rpcUnsubscribe(e2, t2, i2) { - const s2 = { method: Et$2(i2.protocol).unsubscribe, params: { topic: e2, id: t2 } }; + const s2 = { method: Nu(i2.protocol).unsubscribe, params: { topic: e2, id: t2 } }; return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s2 }), this.relayer.request(s2); } onSubscribe(e2, t2) { - this.setSubscription(e2, De$1(q$2({}, t2), { id: e2 })), this.pending.delete(t2.topic); - } - onBatchSubscribe(e2) { - e2.length && e2.forEach((t2) => { - this.setSubscription(t2.id, q$2({}, t2)), this.pending.delete(t2.topic); - }); - } - async onUnsubscribe(e2, t2, i2) { - this.events.removeAllListeners(t2), this.hasSubscription(t2, e2) && this.deleteSubscription(t2, i2), await this.relayer.messages.del(e2); - } - async setRelayerSubscriptions(e2) { - await this.relayer.core.storage.setItem(this.storageKey, e2); - } - async getRelayerSubscriptions() { - return await this.relayer.core.storage.getItem(this.storageKey); - } - setSubscription(e2, t2) { - this.subscriptions.has(e2) || (this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e2, subscription: t2 }), this.addSubscription(e2, t2)); - } - addSubscription(e2, t2) { - this.subscriptions.set(e2, q$2({}, t2)), this.topicMap.set(t2.topic, e2), this.events.emit(w$2.created, t2); - } - getSubscription(e2) { - this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e2 }); - const t2 = this.subscriptions.get(e2); - if (!t2) { - const { message: i2 } = N$2("NO_MATCHING_KEY", `${this.name}: ${e2}`); - throw new Error(i2); - } - return t2; - } - deleteSubscription(e2, t2) { - this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e2, reason: t2 }); - const i2 = this.getSubscription(e2); - this.subscriptions.delete(e2), this.topicMap.delete(i2.topic, e2), this.events.emit(w$2.deleted, De$1(q$2({}, i2), { reason: t2 })); - } - async persist() { - await this.setRelayerSubscriptions(this.values), this.events.emit(w$2.sync); - } - async reset() { - if (this.cached.length) { - const e2 = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); - for (let t2 = 0; t2 < e2; t2++) { - const i2 = this.cached.splice(0, this.batchSubscribeTopicsLimit); - await this.batchSubscribe(i2); - } - } - this.events.emit(w$2.resubscribed); - } - async restore() { - try { - const e2 = await this.getRelayerSubscriptions(); - if (typeof e2 > "u" || !e2.length) - return; - if (this.subscriptions.size) { - const { message: t2 } = N$2("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); - } - this.cached = e2, this.logger.debug(`Successfully Restored subscriptions for ${this.name}`), this.logger.trace({ type: "method", method: "restore", subscriptions: this.values }); - } catch (e2) { - this.logger.debug(`Failed to Restore subscriptions for ${this.name}`), this.logger.error(e2); - } - } - async batchSubscribe(e2) { - if (!e2.length) - return; - const t2 = await this.rpcBatchSubscribe(e2); - k$1(t2) && this.onBatchSubscribe(t2.map((i2, s2) => De$1(q$2({}, e2[s2]), { id: i2 }))); - } - async onConnect() { - this.restartInProgress || (await this.restart(), this.onEnable()); - } - onDisconnect() { - this.onDisable(); - } - async checkPending() { - if (!this.initialized || this.relayer.transportExplicitlyClosed) - return; - const e2 = []; - this.pending.forEach((t2) => { - e2.push(t2); - }), await this.batchSubscribe(e2); - } - registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, async () => { - await this.checkPending(); - }), this.relayer.on(D$3.connect, async () => { - await this.onConnect(); - }), this.relayer.on(D$3.disconnect, () => { - this.onDisconnect(); - }), this.events.on(w$2.created, async (e2) => { - const t2 = w$2.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); - }), this.events.on(w$2.deleted, async (e2) => { - const t2 = w$2.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); - }); - } - isInitialized() { - if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); - throw new Error(e2); - } - } - async restartToComplete() { - this.restartInProgress && await new Promise((e2) => { - const t2 = setInterval(() => { - this.restartInProgress || (clearInterval(t2), e2()); - }, this.pollingInterval); - }); - } - }; - var Pr = Object.defineProperty, Ut$1 = Object.getOwnPropertySymbols, xr = Object.prototype.hasOwnProperty, Or = Object.prototype.propertyIsEnumerable, Lt$1 = (n2, e2, t2) => e2 in n2 ? Pr(n2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n2[e2] = t2, Ar = (n2, e2) => { - for (var t2 in e2 || (e2 = {})) - xr.call(e2, t2) && Lt$1(n2, t2, e2[t2]); - if (Ut$1) - for (var t2 of Ut$1(e2)) - Or.call(e2, t2) && Lt$1(n2, t2, e2[t2]); - return n2; - }; - let $t$1 = class $t extends g$5 { - constructor(e2) { - super(e2), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = ut$1, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.request = async (t2) => { - this.logger.debug("Publishing Request Payload"); - const i2 = t2.id; - try { - await this.toEstablishConnection(); - const s2 = this.provider.request(t2); - return this.requestsInFlight.set(i2, { promise: s2, request: t2 }), await s2; - } catch (s2) { - throw this.logger.debug("Failed to Publish Request"), this.logger.error(s2), s2; - } finally { - this.requestsInFlight.delete(i2); - } - }, this.onPayloadHandler = (t2) => { - this.onProviderPayload(t2); - }, this.onConnectHandler = () => { - this.events.emit(D$3.connect); - }, this.onDisconnectHandler = () => { - this.onProviderDisconnect(); - }, this.onProviderErrorHandler = (t2) => { - this.logger.error(t2), this.events.emit(D$3.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); - }, this.registerProviderListeners = () => { - this.provider.on(P$2.payload, this.onPayloadHandler), this.provider.on(P$2.connect, this.onConnectHandler), this.provider.on(P$2.disconnect, this.onDisconnectHandler), this.provider.on(P$2.error, this.onProviderErrorHandler); - }, this.core = e2.core, this.logger = typeof e2.logger < "u" && typeof e2.logger != "string" ? cjs$3.generateChildLogger(e2.logger, this.name) : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: e2.logger || ct$1 })), this.messages = new Ot$1(this.logger, e2.core), this.subscriber = new Nt$1(this, this.logger), this.publisher = new vr(this, this.logger), this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || ge$1, this.projectId = e2.projectId, this.bundleId = Jn(), this.provider = {}; - } - async init() { - this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); - try { - await this.transportOpen(); - } catch { - this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$1}...`), await this.restartTransport(pe$1); - } - this.initialized = true, setTimeout(async () => { - this.subscriber.topics.length === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); - }, pt$1); - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - get connected() { - return this.provider.connection.connected; - } - get connecting() { - return this.provider.connection.connecting; - } - async publish(e2, t2, i2) { - this.isInitialized(), await this.publisher.publish(e2, t2, i2), await this.recordMessageEvent({ topic: e2, message: t2, publishedAt: Date.now() }); - } - async subscribe(e2, t2) { - var i2; - this.isInitialized(); - let s2 = ((i2 = this.subscriber.topicMap.get(e2)) == null ? void 0 : i2[0]) || ""; - if (s2) - return s2; - let r2; - const o2 = (a2) => { - a2.topic === e2 && (this.subscriber.off(w$2.created, o2), r2()); - }; - return await Promise.all([new Promise((a2) => { - r2 = a2, this.subscriber.on(w$2.created, o2); - }), new Promise(async (a2) => { - s2 = await this.subscriber.subscribe(e2, t2), a2(); - })]), s2; - } - async unsubscribe(e2, t2) { - this.isInitialized(), await this.subscriber.unsubscribe(e2, t2); - } - on(e2, t2) { - this.events.on(e2, t2); - } - once(e2, t2) { - this.events.once(e2, t2); - } - off(e2, t2) { - this.events.off(e2, t2); - } - removeListener(e2, t2) { - this.events.removeListener(e2, t2); - } - async transportClose() { - this.requestsInFlight.size > 0 && (this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."), this.requestsInFlight.forEach(async (e2) => { - await e2.promise; - })), this.transportExplicitlyClosed = true, this.hasExperiencedNetworkDisruption && this.connected ? await ut$2(this.provider.disconnect(), 1e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.connected && await this.provider.disconnect(); - } - async transportOpen(e2) { - if (this.transportExplicitlyClosed = false, await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress) { - e2 && e2 !== this.relayUrl && (this.relayUrl = e2, await this.transportClose(), await this.createProvider()), this.connectionAttemptInProgress = true; - try { - await Promise.all([new Promise((t2) => { - if (!this.initialized) - return t2(); - this.subscriber.once(w$2.resubscribed, () => { - t2(); - }); - }), new Promise(async (t2, i2) => { - try { - await ut$2(this.provider.connect(), 1e4, `Socket stalled when trying to connect to ${this.relayUrl}`); - } catch (s2) { - i2(s2); - return; - } - t2(); - })]); - } catch (t2) { - this.logger.error(t2); - const i2 = t2; - if (!this.isConnectionStalled(i2.message)) - throw t2; - this.provider.events.emit(P$2.disconnect); - } finally { - this.connectionAttemptInProgress = false, this.hasExperiencedNetworkDisruption = false; - } - } - } - async restartTransport(e2) { - await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress && (this.relayUrl = e2 || this.relayUrl, await this.transportClose(), await this.createProvider(), await this.transportOpen()); - } - async confirmOnlineStateOrThrow() { - if (!await rr$2()) - throw new Error("No internet connection detected. Please restart your network and try again."); - } - isConnectionStalled(e2) { - return this.staleConnectionErrors.some((t2) => e2.includes(t2)); - } - async createProvider() { - this.provider.connection && this.unregisterProviderListeners(); - const e2 = await this.core.crypto.signJWT(this.relayUrl); - this.provider = new JsonRpcProvider(new f$1(Xn({ sdkVersion: gt$1, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e2, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); - } - async recordMessageEvent(e2) { - const { topic: t2, message: i2 } = e2; - await this.messages.set(t2, i2); - } - async shouldIgnoreMessageEvent(e2) { - const { topic: t2, message: i2 } = e2; - if (!i2 || i2.length === 0) - return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; - if (!await this.subscriber.isSubscribed(t2)) - return this.logger.debug(`Ignoring message for non-subscribed topic ${t2}`), true; - const s2 = this.messages.has(t2, i2); - return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; - } - async onProviderPayload(e2) { - if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e2 }), isJsonRpcRequest(e2)) { - if (!e2.method.endsWith(lt$1)) - return; - const t2 = e2.params, { topic: i2, message: s2, publishedAt: r2 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r2 }; - this.logger.debug("Emitting Relayer Payload"), this.logger.trace(Ar({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e2), await this.onMessageEvent(o2); - } else - isJsonRpcResponse(e2) && this.events.emit(D$3.message_ack, e2); - } - async onMessageEvent(e2) { - await this.shouldIgnoreMessageEvent(e2) || (this.events.emit(D$3.message, e2), await this.recordMessageEvent(e2)); - } - async acknowledgePayload(e2) { - const t2 = formatJsonRpcResult(e2.id, true); - await this.provider.connection.send(t2); - } - unregisterProviderListeners() { - this.provider.off(P$2.payload, this.onPayloadHandler), this.provider.off(P$2.connect, this.onConnectHandler), this.provider.off(P$2.disconnect, this.onDisconnectHandler), this.provider.off(P$2.error, this.onProviderErrorHandler); - } - async registerEventListeners() { - this.events.on(D$3.connection_stalled, () => { - this.restartTransport().catch((t2) => this.logger.error(t2)); - }); - let e2 = await rr$2(); - or$2(async (t2) => { - this.initialized && e2 !== t2 && (e2 = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportClose().catch((i2) => this.logger.error(i2)))); - }); - } - onProviderDisconnect() { - this.events.emit(D$3.disconnect), this.attemptToReconnect(); - } - attemptToReconnect() { - this.transportExplicitlyClosed || (this.logger.info("attemptToReconnect called. Connecting..."), setTimeout(async () => { - await this.restartTransport().catch((e2) => this.logger.error(e2)); - }, cjs$4.toMiliseconds(dt$1))); - } - isInitialized() { - if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); - throw new Error(e2); - } - } - async toEstablishConnection() { - if (await this.confirmOnlineStateOrThrow(), !this.connected) { - if (this.connectionAttemptInProgress) - return await new Promise((e2) => { - const t2 = setInterval(() => { - this.connected && (clearInterval(t2), e2()); - }, this.connectionStatusPollingInterval); - }); - await this.restartTransport(); - } + this.setSubscription(e2, fe$2(q$2({}, t2), { id: e2 })), this.pending.delete(t2.topic); } - }; - var zr = Object.defineProperty, Ft$1 = Object.getOwnPropertySymbols, Nr = Object.prototype.hasOwnProperty, Ur = Object.prototype.propertyIsEnumerable, Mt$1 = (n2, e2, t2) => e2 in n2 ? zr(n2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n2[e2] = t2, kt$1 = (n2, e2) => { - for (var t2 in e2 || (e2 = {})) - Nr.call(e2, t2) && Mt$1(n2, t2, e2[t2]); - if (Ft$1) - for (var t2 of Ft$1(e2)) - Ur.call(e2, t2) && Mt$1(n2, t2, e2[t2]); - return n2; - }; - let Kt$1 = class Kt extends p$3 { - constructor(e2, t2, i2, s2 = O, r2 = void 0) { - super(e2, t2, i2, s2), this.core = e2, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = Dt$1, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o2) => { - this.getKey && o2 !== null && !w$4(o2) ? this.map.set(this.getKey(o2), o2) : Lt$2(o2) ? this.map.set(o2.id, o2) : xt$2(o2) && this.map.set(o2.topic, o2); - }), this.cached = [], this.initialized = true); - }, this.set = async (o2, a2) => { - this.isInitialized(), this.map.has(o2) ? await this.update(o2, a2) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o2, value: a2 }), this.map.set(o2, a2), await this.persist()); - }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a2) => Object.keys(o2).every((h2) => Gi(a2[h2], o2[h2]))) : this.values), this.update = async (o2, a2) => { - this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o2, update: a2 }); - const h2 = kt$1(kt$1({}, this.getData(o2)), a2); - this.map.set(o2, h2), await this.persist(); - }, this.delete = async (o2, a2) => { - this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a2 }), this.map.delete(o2), await this.persist()); - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.storagePrefix = s2, this.getKey = r2; - } - get context() { - return cjs$3.getLoggerContext(this.logger); - } - get storageKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; + onBatchSubscribe(e2) { + e2.length && e2.forEach((t2) => { + this.setSubscription(t2.id, q$2({}, t2)), this.pending.delete(t2.topic); + }); } - get length() { - return this.map.size; + async onUnsubscribe(e2, t2, i2) { + this.events.removeAllListeners(t2), this.hasSubscription(t2, e2) && this.deleteSubscription(t2, i2), await this.relayer.messages.del(e2); } - get keys() { - return Array.from(this.map.keys()); + async setRelayerSubscriptions(e2) { + await this.relayer.core.storage.setItem(this.storageKey, e2); } - get values() { - return Array.from(this.map.values()); + async getRelayerSubscriptions() { + return await this.relayer.core.storage.getItem(this.storageKey); } - async setDataStore(e2) { - await this.core.storage.setItem(this.storageKey, e2); + setSubscription(e2, t2) { + this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e2, subscription: t2 }), this.addSubscription(e2, t2); } - async getDataStore() { - return await this.core.storage.getItem(this.storageKey); + addSubscription(e2, t2) { + this.subscriptions.set(e2, q$2({}, t2)), this.topicMap.set(t2.topic, e2), this.events.emit(S$4.created, t2); } - getData(e2) { - const t2 = this.map.get(e2); + getSubscription(e2) { + this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e2 }); + const t2 = this.subscriptions.get(e2); if (!t2) { - const { message: i2 } = N$2("NO_MATCHING_KEY", `${this.name}: ${e2}`); - throw this.logger.error(i2), new Error(i2); + const { message: i2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw new Error(i2); } return t2; } + deleteSubscription(e2, t2) { + this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e2, reason: t2 }); + const i2 = this.getSubscription(e2); + this.subscriptions.delete(e2), this.topicMap.delete(i2.topic, e2), this.events.emit(S$4.deleted, fe$2(q$2({}, i2), { reason: t2 })); + } async persist() { - await this.setDataStore(this.values); + await this.setRelayerSubscriptions(this.values), this.events.emit(S$4.sync); + } + async reset() { + if (this.cached.length) { + const e2 = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); + for (let t2 = 0; t2 < e2; t2++) { + const i2 = this.cached.splice(0, this.batchSubscribeTopicsLimit); + await this.batchSubscribe(i2); + } + } + this.events.emit(S$4.resubscribed); } async restore() { try { - const e2 = await this.getDataStore(); + const e2 = await this.getRelayerSubscriptions(); if (typeof e2 > "u" || !e2.length) return; - if (this.map.size) { - const { message: t2 } = N$2("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); + if (this.subscriptions.size) { + const { message: t2 } = xe$1("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); } - this.cached = e2, this.logger.debug(`Successfully Restored value for ${this.name}`), this.logger.trace({ type: "method", method: "restore", value: this.values }); + this.cached = e2, this.logger.debug(`Successfully Restored subscriptions for ${this.name}`), this.logger.trace({ type: "method", method: "restore", subscriptions: this.values }); } catch (e2) { - this.logger.debug(`Failed to Restore value for ${this.name}`), this.logger.error(e2); + this.logger.debug(`Failed to Restore subscriptions for ${this.name}`), this.logger.error(e2); } } - isInitialized() { - if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); - throw new Error(e2); - } + async batchSubscribe(e2) { + if (!e2.length) + return; + const t2 = await this.rpcBatchSubscribe(e2); + Er(t2) && this.onBatchSubscribe(t2.map((i2, s2) => fe$2(q$2({}, e2[s2]), { id: i2 }))); } - }; - let Bt$1 = class Bt { - constructor(e2, t2) { - this.core = e2, this.logger = t2, this.name = Et$1, this.version = wt$1, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = O, this.ignoredPayloadTypes = [_$3], this.registeredMethods = [], this.init = async () => { - this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); - }, this.register = ({ methods: i2 }) => { - this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; - }, this.create = async () => { - this.isInitialized(); - const i2 = Vn(), s2 = await this.core.crypto.setSymKey(i2), r2 = pt$2(cjs$4.FIVE_MINUTES), o2 = { protocol: ht$1 }, a2 = { topic: s2, expiry: r2, relay: o2, active: false }, h2 = Rt$2({ protocol: this.core.protocol, version: this.core.version, topic: s2, symKey: i2, relay: o2, expiryTimestamp: r2 }); - return await this.pairings.set(s2, a2), await this.core.relayer.subscribe(s2), this.core.expirer.set(s2, r2), { topic: s2, uri: h2 }; - }, this.pair = async (i2) => { - this.isInitialized(), this.isValidPair(i2); - const { topic: s2, symKey: r2, relay: o2, expiryTimestamp: a2 } = Pt$2(i2.uri); - let h2; - if (this.pairings.keys.includes(s2) && (h2 = this.pairings.get(s2), h2.active)) - throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); - const l2 = a2 || pt$2(cjs$4.FIVE_MINUTES), d2 = { topic: s2, relay: o2, expiry: l2, active: false }; - return await this.pairings.set(s2, d2), this.core.expirer.set(s2, l2), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V$1.create, d2), this.core.crypto.keychain.has(s2) || (await this.core.crypto.setSymKey(r2, s2), await this.core.relayer.subscribe(s2, { relay: o2 })), d2; - }, this.activate = async ({ topic: i2 }) => { - this.isInitialized(); - const s2 = pt$2(cjs$4.THIRTY_DAYS); - await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); - }, this.ping = async (i2) => { - this.isInitialized(), await this.isValidPing(i2); - const { topic: s2 } = i2; - if (this.pairings.keys.includes(s2)) { - const r2 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a2, reject: h2 } = at$2(); - this.events.once(yt$2("pairing_ping", r2), ({ error: l2 }) => { - l2 ? h2(l2) : a2(); - }), await o2(); - } - }, this.updateExpiry = async ({ topic: i2, expiry: s2 }) => { - this.isInitialized(), await this.pairings.update(i2, { expiry: s2 }); - }, this.updateMetadata = async ({ topic: i2, metadata: s2 }) => { - this.isInitialized(), await this.pairings.update(i2, { peerMetadata: s2 }); - }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { - this.isInitialized(), await this.isValidDisconnect(i2); - const { topic: s2 } = i2; - this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", U$3("USER_DISCONNECTED")), await this.deletePairing(s2)); - }, this.sendRequest = async (i2, s2, r2) => { - const o2 = formatJsonRpcRequest(s2, r2), a2 = await this.core.crypto.encode(i2, o2), h2 = $$1[s2].req; - return this.core.history.set(i2, o2), this.core.relayer.publish(i2, a2, h2), o2.id; - }, this.sendResult = async (i2, s2, r2) => { - const o2 = formatJsonRpcResult(i2, r2), a2 = await this.core.crypto.encode(s2, o2), h2 = await this.core.history.get(s2, i2), l2 = $$1[h2.request.method].res; - await this.core.relayer.publish(s2, a2, l2), await this.core.history.resolve(o2); - }, this.sendError = async (i2, s2, r2) => { - const o2 = formatJsonRpcError(i2, r2), a2 = await this.core.crypto.encode(s2, o2), h2 = await this.core.history.get(s2, i2), l2 = $$1[h2.request.method] ? $$1[h2.request.method].res : $$1.unregistered_method.res; - await this.core.relayer.publish(s2, a2, l2), await this.core.history.resolve(o2); - }, this.deletePairing = async (i2, s2) => { - await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, U$3("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); - }, this.cleanup = async () => { - const i2 = this.pairings.getAll().filter((s2) => mt$2(s2.expiry)); - await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); - }, this.onRelayEventRequest = (i2) => { - const { topic: s2, payload: r2 } = i2; - switch (r2.method) { - case "wc_pairingPing": - return this.onPairingPingRequest(s2, r2); - case "wc_pairingDelete": - return this.onPairingDeleteRequest(s2, r2); - default: - return this.onUnknownRpcMethodRequest(s2, r2); - } - }, this.onRelayEventResponse = async (i2) => { - const { topic: s2, payload: r2 } = i2, o2 = (await this.core.history.get(s2, r2.id)).request.method; - switch (o2) { - case "wc_pairingPing": - return this.onPairingPingResponse(s2, r2); - default: - return this.onUnknownRpcMethodResponse(o2); - } - }, this.onPairingPingRequest = async (i2, s2) => { - const { id: r2 } = s2; - try { - this.isValidPing({ topic: i2 }), await this.sendResult(r2, i2, true), this.events.emit(V$1.ping, { id: r2, topic: i2 }); - } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); - } - }, this.onPairingPingResponse = (i2, s2) => { - const { id: r2 } = s2; - setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$2("pairing_ping", r2), {}) : isJsonRpcError(s2) && this.events.emit(yt$2("pairing_ping", r2), { error: s2.error }); - }, 500); - }, this.onPairingDeleteRequest = async (i2, s2) => { - const { id: r2 } = s2; - try { - this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V$1.delete, { id: r2, topic: i2 }); - } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); - } - }, this.onUnknownRpcMethodRequest = async (i2, s2) => { - const { id: r2, method: o2 } = s2; - try { - if (this.registeredMethods.includes(o2)) - return; - const a2 = U$3("WC_METHOD_UNSUPPORTED", o2); - await this.sendError(r2, i2, a2), this.logger.error(a2); - } catch (a2) { - await this.sendError(r2, i2, a2), this.logger.error(a2); - } - }, this.onUnknownRpcMethodResponse = (i2) => { - this.registeredMethods.includes(i2) || this.logger.error(U$3("WC_METHOD_UNSUPPORTED", i2)); - }, this.isValidPair = (i2) => { - var s2; - if (!Gt$2(i2)) { - const { message: o2 } = N$2("MISSING_OR_INVALID", `pair() params: ${i2}`); - throw new Error(o2); - } - if (!Kt$2(i2.uri)) { - const { message: o2 } = N$2("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); - throw new Error(o2); - } - const r2 = Pt$2(i2.uri); - if (!((s2 = r2 == null ? void 0 : r2.relay) != null && s2.protocol)) { - const { message: o2 } = N$2("MISSING_OR_INVALID", "pair() uri#relay-protocol"); - throw new Error(o2); - } - if (!(r2 != null && r2.symKey)) { - const { message: o2 } = N$2("MISSING_OR_INVALID", "pair() uri#symKey"); - throw new Error(o2); - } - if (r2 != null && r2.expiryTimestamp && cjs$4.toMiliseconds(r2 == null ? void 0 : r2.expiryTimestamp) < Date.now()) { - const { message: o2 } = N$2("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); - throw new Error(o2); - } - }, this.isValidPing = async (i2) => { - if (!Gt$2(i2)) { - const { message: r2 } = N$2("MISSING_OR_INVALID", `ping() params: ${i2}`); - throw new Error(r2); - } - const { topic: s2 } = i2; - await this.isValidPairingTopic(s2); - }, this.isValidDisconnect = async (i2) => { - if (!Gt$2(i2)) { - const { message: r2 } = N$2("MISSING_OR_INVALID", `disconnect() params: ${i2}`); - throw new Error(r2); - } - const { topic: s2 } = i2; - await this.isValidPairingTopic(s2); - }, this.isValidPairingTopic = async (i2) => { - if (!g$4(i2, false)) { - const { message: s2 } = N$2("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); - throw new Error(s2); - } - if (!this.pairings.keys.includes(i2)) { - const { message: s2 } = N$2("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); - throw new Error(s2); - } - if (mt$2(this.pairings.get(i2).expiry)) { - await this.deletePairing(i2); - const { message: s2 } = N$2("EXPIRED", `pairing topic: ${i2}`); - throw new Error(s2); - } - }, this.core = e2, this.logger = cjs$3.generateChildLogger(t2, this.name), this.pairings = new Kt$1(this.core, this.logger, this.name, this.storagePrefix); + async onConnect() { + await this.restart(), this.onEnable(); } - get context() { - return cjs$3.getLoggerContext(this.logger); + onDisconnect() { + this.onDisable(); + } + async checkPending() { + if (!this.initialized || !this.relayer.connected) + return; + const e2 = []; + this.pending.forEach((t2) => { + e2.push(t2); + }), await this.batchSubscribe(e2); + } + registerEventListeners() { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, async () => { + await this.checkPending(); + }), this.events.on(S$4.created, async (e2) => { + const t2 = S$4.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); + }), this.events.on(S$4.deleted, async (e2) => { + const t2 = S$4.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); + }); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } - registerRelayerEvents() { - this.core.relayer.on(D$3.message, async (e2) => { - const { topic: t2, message: i2 } = e2; - if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) - return; - const s2 = await this.core.crypto.decode(t2, i2); - try { - isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); - } catch (r2) { - this.logger.error(r2); - } - }); - } - registerExpirerEvents() { - this.core.expirer.on(v$2.expired, async (e2) => { - const { topic: t2 } = ft$2(e2.target); - t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V$1.expire, { topic: t2 })); + async restartToComplete() { + this.restartInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.restartInProgress || (clearInterval(t2), e2()); + }, this.pollingInterval); }); } }; - let Vt$1 = class Vt extends h$5 { - constructor(e2, t2) { - super(e2, t2), this.core = e2, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = vt$1, this.version = It$1, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.set = (i2, s2, r2) => { - if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r2 }), this.records.has(s2.id)) - return; - const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r2, expiry: pt$2(cjs$4.THIRTY_DAYS) }; - this.records.set(o2.id, o2), this.events.emit(R$2.created, o2); - }, this.resolve = async (i2) => { - if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) - return; - const s2 = await this.getRecord(i2.id); - typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.events.emit(R$2.updated, s2)); - }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { - this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r2) => { - if (r2.topic === i2) { - if (typeof s2 < "u" && r2.id !== s2) - return; - this.records.delete(r2.id), this.events.emit(R$2.deleted, r2); + var xr$1 = Object.defineProperty, $t$2 = Object.getOwnPropertySymbols, Or$1 = Object.prototype.hasOwnProperty, Ar = Object.prototype.propertyIsEnumerable, Ft$2 = (n2, e2, t2) => e2 in n2 ? xr$1(n2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n2[e2] = t2, zr$1 = (n2, e2) => { + for (var t2 in e2 || (e2 = {})) + Or$1.call(e2, t2) && Ft$2(n2, t2, e2[t2]); + if ($t$2) + for (var t2 of $t$2(e2)) + Ar.call(e2, t2) && Ft$2(n2, t2, e2[t2]); + return n2; + }; + let kt$1 = class kt extends g$2 { + constructor(e2) { + super(e2), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = dt$1, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled", "interrupted"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.heartBeatTimeout = cjs$3.toMiliseconds(cjs$3.THIRTY_SECONDS + cjs$3.ONE_SECOND), this.request = async (t2) => { + var i2, s2; + this.logger.debug("Publishing Request Payload"); + const r2 = t2.id || getBigIntRpcId().toString(); + await this.toEstablishConnection(); + try { + const o2 = this.provider.request(t2); + this.requestsInFlight.set(r2, { promise: o2, request: t2 }), this.logger.trace({ id: r2, method: t2.method, topic: (i2 = t2.params) == null ? void 0 : i2.topic }, "relayer.request - attempt to publish..."); + const a2 = await new Promise(async (h2, l2) => { + const d2 = () => { + l2(new Error(`relayer.request - publish interrupted, id: ${r2}`)); + }; + this.provider.on(f$2.disconnect, d2); + const g2 = await o2; + this.provider.off(f$2.disconnect, d2), h2(g2); + }); + return this.logger.trace({ id: r2, method: t2.method, topic: (s2 = t2.params) == null ? void 0 : s2.topic }, "relayer.request - published"), a2; + } catch (o2) { + throw this.logger.debug(`Failed to Publish Request: ${r2}`), o2; + } finally { + this.requestsInFlight.delete(r2); + } + }, this.resetPingTimeout = () => { + if (pi()) + try { + clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => { + var t2, i2, s2; + (s2 = (i2 = (t2 = this.provider) == null ? void 0 : t2.connection) == null ? void 0 : i2.socket) == null || s2.terminate(); + }, this.heartBeatTimeout); + } catch (t2) { + this.logger.warn(t2); } - }); - }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.onPayloadHandler = (t2) => { + this.onProviderPayload(t2), this.resetPingTimeout(); + }, this.onConnectHandler = () => { + this.startPingTimeout(), this.events.emit(v$1.connect); + }, this.onDisconnectHandler = () => { + this.onProviderDisconnect(); + }, this.onProviderErrorHandler = (t2) => { + this.logger.error(t2), this.events.emit(v$1.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); + }, this.registerProviderListeners = () => { + this.provider.on(f$2.payload, this.onPayloadHandler), this.provider.on(f$2.connect, this.onConnectHandler), this.provider.on(f$2.disconnect, this.onDisconnectHandler), this.provider.on(f$2.error, this.onProviderErrorHandler); + }, this.core = e2.core, this.logger = typeof e2.logger < "u" && typeof e2.logger != "string" ? E$2(e2.logger, this.name) : nt$2(k$3({ level: e2.logger || ut$1 })), this.messages = new zt$1(this.logger, e2.core), this.subscriber = new Ut$2(this, this.logger), this.publisher = new Ir(this, this.logger), this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me$1, this.projectId = e2.projectId, this.bundleId = Wo$1(), this.provider = {}; + } + async init() { + this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); + try { + await this.transportOpen(); + } catch { + this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${be$1}...`), await this.restartTransport(be$1); + } + this.initialized = true, setTimeout(async () => { + this.subscriber.topics.length === 0 && this.subscriber.pending.size === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); + }, yt$1); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$3(this.logger); } - get storageKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; + get connected() { + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 1; } - get size() { - return this.records.size; + get connecting() { + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 0; } - get keys() { - return Array.from(this.records.keys()); + async publish(e2, t2, i2) { + this.isInitialized(), await this.publisher.publish(e2, t2, i2), await this.recordMessageEvent({ topic: e2, message: t2, publishedAt: Date.now() }); } - get values() { - return Array.from(this.records.values()); + async subscribe(e2, t2) { + var i2; + this.isInitialized(); + let s2 = ((i2 = this.subscriber.topicMap.get(e2)) == null ? void 0 : i2[0]) || "", r2; + const o2 = (a2) => { + a2.topic === e2 && (this.subscriber.off(S$4.created, o2), r2()); + }; + return await Promise.all([new Promise((a2) => { + r2 = a2, this.subscriber.on(S$4.created, o2); + }), new Promise(async (a2) => { + s2 = await this.subscriber.subscribe(e2, t2) || s2, a2(); + })]), s2; } - get pending() { - const e2 = []; - return this.values.forEach((t2) => { - if (typeof t2.response < "u") - return; - const i2 = { topic: t2.topic, request: formatJsonRpcRequest(t2.request.method, t2.request.params, t2.id), chainId: t2.chainId }; - return e2.push(i2); - }), e2; + async unsubscribe(e2, t2) { + this.isInitialized(), await this.subscriber.unsubscribe(e2, t2); } - async setJsonRpcRecords(e2) { - await this.core.storage.setItem(this.storageKey, e2); + on(e2, t2) { + this.events.on(e2, t2); } - async getJsonRpcRecords() { - return await this.core.storage.getItem(this.storageKey); + once(e2, t2) { + this.events.once(e2, t2); } - getRecord(e2) { - this.isInitialized(); - const t2 = this.records.get(e2); - if (!t2) { - const { message: i2 } = N$2("NO_MATCHING_KEY", `${this.name}: ${e2}`); - throw new Error(i2); - } - return t2; + off(e2, t2) { + this.events.off(e2, t2); } - async persist() { - await this.setJsonRpcRecords(this.values), this.events.emit(R$2.sync); + removeListener(e2, t2) { + this.events.removeListener(e2, t2); } - async restore() { - try { - const e2 = await this.getJsonRpcRecords(); - if (typeof e2 > "u" || !e2.length) - return; - if (this.records.size) { - const { message: t2 } = N$2("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); + async transportDisconnect() { + if (!this.hasExperiencedNetworkDisruption && this.connected && this.requestsInFlight.size > 0) + try { + await Promise.all(Array.from(this.requestsInFlight.values()).map((e2) => e2.promise)); + } catch (e2) { + this.logger.warn(e2); } - this.cached = e2, this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", records: this.values }); - } catch (e2) { - this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(e2); - } + this.hasExperiencedNetworkDisruption || this.connected ? await u0(this.provider.disconnect(), 2e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.onProviderDisconnect(); } - registerEventListeners() { - this.events.on(R$2.created, (e2) => { - const t2 = R$2.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }), this.persist(); - }), this.events.on(R$2.updated, (e2) => { - const t2 = R$2.updated; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }), this.persist(); - }), this.events.on(R$2.deleted, (e2) => { - const t2 = R$2.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }), this.persist(); - }), this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { - this.cleanup(); - }); + async transportClose() { + this.transportExplicitlyClosed = true, await this.transportDisconnect(); } - cleanup() { + async transportOpen(e2) { + await this.confirmOnlineStateOrThrow(), e2 && e2 !== this.relayUrl && (this.relayUrl = e2, await this.transportDisconnect(), await this.createProvider()), this.connectionAttemptInProgress = true, this.transportExplicitlyClosed = false; try { - this.records.forEach((e2) => { - cjs$4.toMiliseconds(e2.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${e2.id}`), this.delete(e2.topic, e2.id)); + await new Promise(async (t2, i2) => { + const s2 = () => { + this.provider.off(f$2.disconnect, s2), i2(new Error("Connection interrupted while trying to subscribe")); + }; + this.provider.on(f$2.disconnect, s2), await u0(this.provider.connect(), cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), `Socket stalled when trying to connect to ${this.relayUrl}`).catch((r2) => { + i2(r2); + }), await this.subscriber.start(), this.hasExperiencedNetworkDisruption = false, t2(); }); - } catch (e2) { - this.logger.warn(e2); + } catch (t2) { + this.logger.error(t2); + const i2 = t2; + if (!this.isConnectionStalled(i2.message)) + throw t2; + } finally { + this.connectionAttemptInProgress = false; } } - isInitialized() { - if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); - throw new Error(e2); - } + async restartTransport(e2) { + this.connectionAttemptInProgress || (this.relayUrl = e2 || this.relayUrl, await this.confirmOnlineStateOrThrow(), await this.transportClose(), await this.createProvider(), await this.transportOpen()); } - }; - let qt$1 = class qt extends E$1 { - constructor(e2, t2) { - super(e2, t2), this.core = e2, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct$1, this.version = Rt$1, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.has = (i2) => { + async confirmOnlineStateOrThrow() { + if (!await hh()) + throw new Error("No internet connection detected. Please restart your network and try again."); + } + startPingTimeout() { + var e2, t2, i2, s2, r2; + if (pi()) try { - const s2 = this.formatTarget(i2); - return typeof this.getExpiration(s2) < "u"; - } catch { - return false; - } - }, this.set = (i2, s2) => { - this.isInitialized(); - const r2 = this.formatTarget(i2), o2 = { target: r2, expiry: s2 }; - this.expirations.set(r2, o2), this.checkExpiry(r2, o2), this.events.emit(v$2.created, { target: r2, expiration: o2 }); - }, this.get = (i2) => { - this.isInitialized(); - const s2 = this.formatTarget(i2); - return this.getExpiration(s2); - }, this.del = (i2) => { - if (this.isInitialized(), this.has(i2)) { - const s2 = this.formatTarget(i2), r2 = this.getExpiration(s2); - this.expirations.delete(s2), this.events.emit(v$2.deleted, { target: s2, expiration: r2 }); + (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) != null && t2.socket && ((r2 = (s2 = (i2 = this.provider) == null ? void 0 : i2.connection) == null ? void 0 : s2.socket) == null || r2.once("ping", () => { + this.resetPingTimeout(); + })), this.resetPingTimeout(); + } catch (o2) { + this.logger.warn(o2); } - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); } - get context() { - return cjs$3.getLoggerContext(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(e2) { - if (typeof e2 == "string") - return lt$2(e2); - if (typeof e2 == "number") - return dt$2(e2); - const { message: t2 } = N$2("UNKNOWN_TYPE", `Target type: ${typeof e2}`); - throw new Error(t2); + isConnectionStalled(e2) { + return this.staleConnectionErrors.some((t2) => e2.includes(t2)); } - async setExpirations(e2) { - await this.core.storage.setItem(this.storageKey, e2); + async createProvider() { + this.provider.connection && this.unregisterProviderListeners(); + const e2 = await this.core.crypto.signJWT(this.relayUrl); + this.provider = new JsonRpcProvider(new f$3($o({ sdkVersion: Dt$2, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e2, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); } - async getExpirations() { - return await this.core.storage.getItem(this.storageKey); + async recordMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; + await this.messages.set(t2, i2); } - async persist() { - await this.setExpirations(this.values), this.events.emit(v$2.sync); + async shouldIgnoreMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; + if (!i2 || i2.length === 0) + return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; + if (!await this.subscriber.isSubscribed(t2)) + return this.logger.debug(`Ignoring message for non-subscribed topic ${t2}`), true; + const s2 = this.messages.has(t2, i2); + return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; } - async restore() { - try { - const e2 = await this.getExpirations(); - if (typeof e2 > "u" || !e2.length) + async onProviderPayload(e2) { + if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e2 }), isJsonRpcRequest(e2)) { + if (!e2.method.endsWith(gt)) return; - if (this.expirations.size) { - const { message: t2 } = N$2("RESTORE_WILL_OVERRIDE", this.name); - throw this.logger.error(t2), new Error(t2); - } - this.cached = e2, this.logger.debug(`Successfully Restored expirations for ${this.name}`), this.logger.trace({ type: "method", method: "restore", expirations: this.values }); - } catch (e2) { - this.logger.debug(`Failed to Restore expirations for ${this.name}`), this.logger.error(e2); - } - } - getExpiration(e2) { - const t2 = this.expirations.get(e2); - if (!t2) { - const { message: i2 } = N$2("NO_MATCHING_KEY", `${this.name}: ${e2}`); - throw this.logger.error(i2), new Error(i2); - } - return t2; + const t2 = e2.params, { topic: i2, message: s2, publishedAt: r2 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r2 }; + this.logger.debug("Emitting Relayer Payload"), this.logger.trace(zr$1({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e2), await this.onMessageEvent(o2); + } else + isJsonRpcResponse(e2) && this.events.emit(v$1.message_ack, e2); } - checkExpiry(e2, t2) { - const { expiry: i2 } = t2; - cjs$4.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e2, t2); + async onMessageEvent(e2) { + await this.shouldIgnoreMessageEvent(e2) || (this.events.emit(v$1.message, e2), await this.recordMessageEvent(e2)); } - expire(e2, t2) { - this.expirations.delete(e2), this.events.emit(v$2.expired, { target: e2, expiration: t2 }); + async acknowledgePayload(e2) { + const t2 = formatJsonRpcResult(e2.id, true); + await this.provider.connection.send(t2); } - checkExpirations() { - this.core.relayer.connected && this.expirations.forEach((e2, t2) => this.checkExpiry(t2, e2)); + unregisterProviderListeners() { + this.provider.off(f$2.payload, this.onPayloadHandler), this.provider.off(f$2.connect, this.onConnectHandler), this.provider.off(f$2.disconnect, this.onDisconnectHandler), this.provider.off(f$2.error, this.onProviderErrorHandler); } - registerEventListeners() { - this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(v$2.created, (e2) => { - const t2 = v$2.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); - }), this.events.on(v$2.expired, (e2) => { - const t2 = v$2.expired; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); - }), this.events.on(v$2.deleted, (e2) => { - const t2 = v$2.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + async registerEventListeners() { + let e2 = await hh(); + ch(async (t2) => { + e2 !== t2 && (e2 = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportDisconnect(), this.transportExplicitlyClosed = false)); }); } + async onProviderDisconnect() { + await this.subscriber.stop(), this.events.emit(v$1.disconnect), this.connectionAttemptInProgress = false, !this.transportExplicitlyClosed && setTimeout(async () => { + await this.transportOpen().catch((e2) => this.logger.error(e2)); + }, cjs$3.toMiliseconds(pt$1)); + } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$2("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } + async toEstablishConnection() { + await this.confirmOnlineStateOrThrow(), !this.connected && (this.connectionAttemptInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.connected && (clearInterval(t2), e2()); + }, this.connectionStatusPollingInterval); + }), await this.transportOpen()); + } }; - let jt$1 = class jt extends y$2 { - constructor(e2, t2) { - super(e2, t2), this.projectId = e2, this.logger = t2, this.name = Z$2, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { - if (this.verifyDisabled || $$2() || !D$4()) - return; - const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; - try { - await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2); - } - if (!this.initialized) { - this.removeIframe(), this.verifyUrl = ee$1; - try { - await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2), this.verifyDisabled = true; - } - } - }, this.register = async (i2) => { - this.initialized ? this.sendPost(i2.attestationId) : (this.addToQueue(i2.attestationId), await this.init()); - }, this.resolve = async (i2) => { - if (this.isDevEnv) - return ""; - const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - let r2; - try { - r2 = await this.fetchAttestation(i2.attestationId, s2); - } catch (o2) { - this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r2 = await this.fetchAttestation(i2.attestationId, ee$1); - } - return r2; - }, this.fetchAttestation = async (i2, s2) => { - this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); - const r2 = this.startAbortTimer(cjs$4.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); - return clearTimeout(r2), o2.status === 200 ? await o2.json() : void 0; - }, this.addToQueue = (i2) => { - this.queue.push(i2); - }, this.processQueue = () => { - this.queue.length !== 0 && (this.queue.forEach((i2) => this.sendPost(i2)), this.queue = []); - }, this.sendPost = (i2) => { - var s2; - try { - if (!this.iframe) - return; - (s2 = this.iframe.contentWindow) == null || s2.postMessage(i2, "*"), this.logger.info(`postMessage sent: ${i2} ${this.verifyUrl}`); - } catch { - } - }, this.createIframe = async () => { - let i2; - const s2 = (r2) => { - r2.data === "verify_ready" && (this.initialized = true, this.processQueue(), window.removeEventListener("message", s2), i2()); - }; - await Promise.race([new Promise((r2) => { - if (document.getElementById(Z$2)) - return r2(); - window.addEventListener("message", s2); - const o2 = document.createElement("iframe"); - o2.id = Z$2, o2.src = `${this.verifyUrl}/${this.projectId}`, o2.style.display = "none", document.body.append(o2), this.iframe = o2, i2 = r2; - }), new Promise((r2, o2) => setTimeout(() => { - window.removeEventListener("message", s2), o2("verify iframe load timeout"); - }, cjs$4.toMiliseconds(cjs$4.FIVE_SECONDS)))]); - }, this.removeIframe = () => { - this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); - }, this.getVerifyUrl = (i2) => { - let s2 = i2 || F$2; - return _t$1.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${F$2}`), s2 = F$2), s2; - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.verifyUrl = F$2, this.abortController = new AbortController(), this.isDevEnv = te$2() && process.env.IS_VITEST; + var Nr = Object.defineProperty, Bt$2 = Object.getOwnPropertySymbols, Lr = Object.prototype.hasOwnProperty, Ur$1 = Object.prototype.propertyIsEnumerable, Mt$1 = (n2, e2, t2) => e2 in n2 ? Nr(n2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n2[e2] = t2, Kt$2 = (n2, e2) => { + for (var t2 in e2 || (e2 = {})) + Lr.call(e2, t2) && Mt$1(n2, t2, e2[t2]); + if (Bt$2) + for (var t2 of Bt$2(e2)) + Ur$1.call(e2, t2) && Mt$1(n2, t2, e2[t2]); + return n2; + }; + class Vt extends p$1 { + constructor(e2, t2, i2, s2 = z$2, r2 = void 0) { + super(e2, t2, i2, s2), this.core = e2, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = mt, this.cached = [], this.initialized = false, this.storagePrefix = z$2, this.recentlyDeleted = [], this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o2) => { + this.getKey && o2 !== null && !Pe$1(o2) ? this.map.set(this.getKey(o2), o2) : Gu(o2) ? this.map.set(o2.id, o2) : Yu(o2) && this.map.set(o2.topic, o2); + }), this.cached = [], this.initialized = true); + }, this.set = async (o2, a2) => { + this.isInitialized(), this.map.has(o2) ? await this.update(o2, a2) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o2, value: a2 }), this.map.set(o2, a2), await this.persist()); + }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a2) => Object.keys(o2).every((h2) => Yi(a2[h2], o2[h2]))) : this.values), this.update = async (o2, a2) => { + this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o2, update: a2 }); + const h2 = Kt$2(Kt$2({}, this.getData(o2)), a2); + this.map.set(o2, h2), await this.persist(); + }, this.delete = async (o2, a2) => { + this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a2 }), this.map.delete(o2), this.addToRecentlyDeleted(o2), await this.persist()); + }, this.logger = E$2(t2, this.name), this.storagePrefix = s2, this.getKey = r2; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$3(this.logger); } - startAbortTimer(e2) { - return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$4.toMiliseconds(e2)); + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } - }; - let Gt$1 = class Gt extends v$3 { - constructor(e2, t2) { - super(e2, t2), this.projectId = e2, this.logger = t2, this.context = Tt$1, this.registerDeviceToken = async (i2) => { - const { clientId: s2, token: r2, notificationType: o2, enableEncrypted: a2 = false } = i2, h2 = `${St$1}/${this.projectId}/clients`; - await Yi(h2, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r2, always_raw: a2 }) }); - }, this.logger = cjs$3.generateChildLogger(t2, this.context); + get length() { + return this.map.size; } - }; - var Lr = Object.defineProperty, Yt$1 = Object.getOwnPropertySymbols, $r = Object.prototype.hasOwnProperty, Fr = Object.prototype.propertyIsEnumerable, Ht$1 = (n2, e2, t2) => e2 in n2 ? Lr(n2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n2[e2] = t2, Jt$1 = (n2, e2) => { - for (var t2 in e2 || (e2 = {})) - $r.call(e2, t2) && Ht$1(n2, t2, e2[t2]); - if (Yt$1) - for (var t2 of Yt$1(e2)) - Fr.call(e2, t2) && Ht$1(n2, t2, e2[t2]); - return n2; - }; - let te$1 = class te2 extends n$7 { - constructor(e2) { - super(e2), this.protocol = le$2, this.version = We$1, this.name = Q$2, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (i2, s2) => this.events.on(i2, s2), this.once = (i2, s2) => this.events.once(i2, s2), this.off = (i2, s2) => this.events.off(i2, s2), this.removeListener = (i2, s2) => this.events.removeListener(i2, s2), this.projectId = e2 == null ? void 0 : e2.projectId, this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || ge$1, this.customStoragePrefix = e2 != null && e2.customStoragePrefix ? `:${e2.customStoragePrefix}` : ""; - const t2 = typeof (e2 == null ? void 0 : e2.logger) < "u" && typeof (e2 == null ? void 0 : e2.logger) != "string" ? e2.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (e2 == null ? void 0 : e2.logger) || Qe$1.logger })); - this.logger = cjs$3.generateChildLogger(t2, this.name), this.heartbeat = new cjs$5.HeartBeat(), this.crypto = new xt$1(this, this.logger, e2 == null ? void 0 : e2.keychain), this.history = new Vt$1(this, this.logger), this.expirer = new qt$1(this, this.logger), this.storage = e2 != null && e2.storage ? e2.storage : new h$6(Jt$1(Jt$1({}, Ze), e2 == null ? void 0 : e2.storageOptions)), this.relayer = new $t$1({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new Bt$1(this, this.logger), this.verify = new jt$1(this.projectId || "", this.logger), this.echoClient = new Gt$1(this.projectId || "", this.logger); + get keys() { + return Array.from(this.map.keys()); } - static async init(e2) { - const t2 = new te2(e2); - await t2.initialize(); - const i2 = await t2.crypto.getClientId(); - return await t2.storage.setItem(yt$1, i2), t2; + get values() { + return Array.from(this.map.values()); } - get context() { - return cjs$3.getLoggerContext(this.logger); + addToRecentlyDeleted(e2) { + this.recentlyDeleted.push(e2), this.recentlyDeleted.length >= this.recentlyDeletedLimit && this.recentlyDeleted.splice(0, this.recentlyDeletedLimit / 2); } - async start() { - this.initialized || await this.initialize(); + async setDataStore(e2) { + await this.core.storage.setItem(this.storageKey, e2); } - async initialize() { - this.logger.trace("Initialized"); + async getDataStore() { + return await this.core.storage.getItem(this.storageKey); + } + getData(e2) { + const t2 = this.map.get(e2); + if (!t2) { + if (this.recentlyDeleted.includes(e2)) { + const { message: s2 } = xe$1("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e2}`); + throw this.logger.error(s2), new Error(s2); + } + const { message: i2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.error(i2), new Error(i2); + } + return t2; + } + async persist() { + await this.setDataStore(this.values); + } + async restore() { 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.initialized = true, this.logger.info("Core Initialization Success"); + const e2 = await this.getDataStore(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.map.size) { + const { message: t2 } = xe$1("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored value for ${this.name}`), this.logger.trace({ type: "method", method: "restore", value: this.values }); } catch (e2) { - throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`, e2), this.logger.error(e2.message), e2; + this.logger.debug(`Failed to Restore value for ${this.name}`), this.logger.error(e2); } } - }; - const Mr = te$1; - const J = "wc", F$1 = 2, X = "client", G$1 = `${J}@${F$1}:${X}:`, M$1 = { name: X, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, H$1 = "WALLETCONNECT_DEEPLINK_CHOICE", oe$1 = "proposal", ae$1 = "Proposal expired", ce$1 = "session", L$2 = cjs$4.SEVEN_DAYS, le$1 = "engine", R$1 = { wc_sessionPropose: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1114 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1115 } } }, U$2 = { min: cjs$4.FIVE_MINUTES, max: cjs$4.SEVEN_DAYS }, I$1 = { idle: "IDLE", active: "ACTIVE" }, pe = "request", he$1 = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"]; - var as = Object.defineProperty, cs = Object.defineProperties, ls = Object.getOwnPropertyDescriptors, de$1 = Object.getOwnPropertySymbols, ps = Object.prototype.hasOwnProperty, hs = Object.prototype.propertyIsEnumerable, ue$1 = (w2, r2, e2) => r2 in w2 ? as(w2, r2, { enumerable: true, configurable: true, writable: true, value: e2 }) : w2[r2] = e2, g$2 = (w2, r2) => { - for (var e2 in r2 || (r2 = {})) - ps.call(r2, e2) && ue$1(w2, e2, r2[e2]); - if (de$1) - for (var e2 of de$1(r2)) - hs.call(r2, e2) && ue$1(w2, e2, r2[e2]); - return w2; - }, D$2 = (w2, r2) => cs(w2, ls(r2)); - class ds extends w$5 { - constructor(r2) { - super(r2), this.name = le$1, this.events = new EventEmitter$1(), this.initialized = false, this.ignoredPayloadTypes = [_$3], this.requestQueue = { state: I$1.idle, queue: [] }, this.sessionRequestQueue = { state: I$1.idle, queue: [] }, this.requestQueueDelay = cjs$4.ONE_SECOND, this.init = async () => { - this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(R$1) }), this.initialized = true, setTimeout(() => { - this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay))); - }, this.connect = async (e2) => { - await this.isInitialized(); - const s2 = D$2(g$2({}, e2), { requiredNamespaces: e2.requiredNamespaces || {}, optionalNamespaces: e2.optionalNamespaces || {} }); - await this.isValidConnect(s2); - const { pairingTopic: t2, requiredNamespaces: i2, optionalNamespaces: n2, sessionProperties: o2, relays: a2 } = s2; - let c2 = t2, p2, d2 = false; - if (c2 && (d2 = this.client.core.pairing.pairings.get(c2).active), !c2 || !d2) { - const { topic: T2, uri: _2 } = await this.client.core.pairing.create(); - c2 = T2, p2 = _2; - } - const h2 = await this.client.core.crypto.generateKeyPair(), N2 = R$1.wc_sessionPropose.req.ttl || cjs$4.FIVE_MINUTES, m2 = pt$2(N2), f2 = g$2({ requiredNamespaces: i2, optionalNamespaces: n2, relays: a2 ?? [{ protocol: ht$1 }], proposer: { publicKey: h2, metadata: this.client.metadata }, expiryTimestamp: m2 }, o2 && { sessionProperties: o2 }), { reject: k2, resolve: O2, done: we2 } = at$2(N2, ae$1); - if (this.events.once(yt$2("session_connect"), async ({ error: T2, session: _2 }) => { - if (T2) - k2(T2); - else if (_2) { - _2.self.publicKey = h2; - const B2 = D$2(g$2({}, _2), { requiredNamespaces: f2.requiredNamespaces, optionalNamespaces: f2.optionalNamespaces }); - await this.client.session.set(_2.topic, B2), await this.setExpiry(_2.topic, _2.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: _2.peer.metadata }), O2(B2); - } - }), !c2) { - const { message: T2 } = N$2("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); - throw new Error(T2); - } - const W2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: f2, throwOnFailedPublish: true }); - return await this.setProposal(W2, g$2({ id: W2 }, f2)), { uri: p2, approval: we2 }; - }, this.pair = async (e2) => (await this.isInitialized(), await this.client.core.pairing.pair(e2)), this.approve = async (e2) => { - await this.isInitialized(), await this.isValidApprove(e2); - const { id: s2, relayProtocol: t2, namespaces: i2, sessionProperties: n2 } = e2, o2 = this.client.proposal.get(s2); - let { pairingTopic: a2, proposer: c2, requiredNamespaces: p2, optionalNamespaces: d2 } = o2; - a2 = a2 || ""; - const h2 = await this.client.core.crypto.generateKeyPair(), N2 = c2.publicKey, m2 = await this.client.core.crypto.generateSharedKey(h2, N2); - a2 && s2 && (await this.client.core.pairing.updateMetadata({ topic: a2, metadata: c2.metadata }), await this.sendResult({ id: s2, topic: a2, result: { relay: { protocol: t2 ?? "irn" }, responderPublicKey: h2 } }), await this.client.proposal.delete(s2, U$3("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: a2 })); - const f2 = g$2({ relay: { protocol: t2 ?? "irn" }, namespaces: i2, pairingTopic: a2, controller: { publicKey: h2, metadata: this.client.metadata }, expiry: pt$2(L$2) }, n2 && { sessionProperties: n2 }); - await this.client.core.relayer.subscribe(m2); - const k2 = D$2(g$2({}, f2), { topic: m2, requiredNamespaces: p2, optionalNamespaces: d2, pairingTopic: a2, acknowledged: false, self: f2.controller, peer: { publicKey: c2.publicKey, metadata: c2.metadata }, controller: h2 }); - await this.client.session.set(m2, k2); - try { - await this.sendRequest({ topic: m2, method: "wc_sessionSettle", params: f2, throwOnFailedPublish: true }); - } catch (O2) { - throw this.client.logger.error(O2), this.client.session.delete(m2, U$3("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(m2), O2; - } - return await this.setExpiry(m2, pt$2(L$2)), { topic: m2, acknowledged: () => new Promise((O2) => setTimeout(() => O2(this.client.session.get(m2)), 500)) }; - }, this.reject = async (e2) => { - await this.isInitialized(), await this.isValidReject(e2); - const { id: s2, reason: t2 } = e2, { pairingTopic: i2 } = this.client.proposal.get(s2); - i2 && (await this.sendError(s2, i2, t2), await this.client.proposal.delete(s2, U$3("USER_DISCONNECTED"))); - }, this.update = async (e2) => { - await this.isInitialized(), await this.isValidUpdate(e2); - const { topic: s2, namespaces: t2 } = e2, i2 = await this.sendRequest({ topic: s2, method: "wc_sessionUpdate", params: { namespaces: t2 } }), { done: n2, resolve: o2, reject: a2 } = at$2(); - return this.events.once(yt$2("session_update", i2), ({ error: c2 }) => { - c2 ? a2(c2) : o2(); - }), await this.client.session.update(s2, { namespaces: t2 }), { acknowledged: n2 }; - }, this.extend = async (e2) => { - await this.isInitialized(), await this.isValidExtend(e2); - const { topic: s2 } = e2, t2 = await this.sendRequest({ topic: s2, method: "wc_sessionExtend", params: {} }), { done: i2, resolve: n2, reject: o2 } = at$2(); - return this.events.once(yt$2("session_extend", t2), ({ error: a2 }) => { - a2 ? o2(a2) : n2(); - }), await this.setExpiry(s2, pt$2(L$2)), { acknowledged: i2 }; - }, this.request = async (e2) => { - await this.isInitialized(), await this.isValidRequest(e2); - const { chainId: s2, request: t2, topic: i2, expiry: n2 = R$1.wc_sessionRequest.req.ttl } = e2, o2 = payloadId(), { done: a2, resolve: c2, reject: p2 } = at$2(n2, "Request expired. Please try again."); - return this.events.once(yt$2("session_request", o2), ({ error: d2, result: h2 }) => { - d2 ? p2(d2) : c2(h2); - }), await Promise.all([new Promise(async (d2) => { - await this.sendRequest({ clientRpcId: o2, topic: i2, method: "wc_sessionRequest", params: { request: D$2(g$2({}, t2), { expiryTimestamp: pt$2(n2) }), chainId: s2 }, expiry: n2, throwOnFailedPublish: true }).catch((h2) => p2(h2)), this.client.events.emit("session_request_sent", { topic: i2, request: t2, chainId: s2, id: o2 }), d2(); - }), new Promise(async (d2) => { - const h2 = await ht$2(this.client.core.storage, H$1); - gt$2({ id: o2, topic: i2, wcDeepLink: h2 }), d2(); - }), a2()]).then((d2) => d2[2]); - }, this.respond = async (e2) => { - await this.isInitialized(), await this.isValidRespond(e2); - const { topic: s2, response: t2 } = e2, { id: i2 } = t2; - isJsonRpcResult(t2) ? await this.sendResult({ id: i2, topic: s2, result: t2.result, throwOnFailedPublish: true }) : isJsonRpcError(t2) && await this.sendError(i2, s2, t2.error), this.cleanupAfterResponse(e2); - }, this.ping = async (e2) => { - await this.isInitialized(), await this.isValidPing(e2); - const { topic: s2 } = e2; - if (this.client.session.keys.includes(s2)) { - const t2 = await this.sendRequest({ topic: s2, method: "wc_sessionPing", params: {} }), { done: i2, resolve: n2, reject: o2 } = at$2(); - this.events.once(yt$2("session_ping", t2), ({ error: a2 }) => { - a2 ? o2(a2) : n2(); - }), await i2(); - } else - this.client.core.pairing.pairings.keys.includes(s2) && await this.client.core.pairing.ping({ topic: s2 }); - }, this.emit = async (e2) => { - await this.isInitialized(), await this.isValidEmit(e2); - const { topic: s2, event: t2, chainId: i2 } = e2; - await this.sendRequest({ topic: s2, method: "wc_sessionEvent", params: { event: t2, chainId: i2 } }); - }, this.disconnect = async (e2) => { - await this.isInitialized(), await this.isValidDisconnect(e2); - const { topic: s2 } = e2; - if (this.client.session.keys.includes(s2)) - await this.sendRequest({ topic: s2, method: "wc_sessionDelete", params: U$3("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: s2, emitEvent: false }); - else if (this.client.core.pairing.pairings.keys.includes(s2)) - await this.client.core.pairing.disconnect({ topic: s2 }); - else { - const { message: t2 } = N$2("MISMATCHED_TOPIC", `Session or pairing topic not found: ${s2}`); - throw new Error(t2); + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); + throw new Error(e2); + } + } + } + class qt { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.name = vt, this.version = It$1, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = z$2, this.ignoredPayloadTypes = [lr$1], this.registeredMethods = [], this.init = async () => { + this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); + }, this.register = ({ methods: i2 }) => { + this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; + }, this.create = async (i2) => { + this.isInitialized(); + const s2 = gu(), r2 = await this.core.crypto.setSymKey(s2), o2 = d0(cjs$3.FIVE_MINUTES), a2 = { protocol: lt$1 }, h2 = { topic: r2, expiry: o2, relay: a2, active: false }, l2 = Du({ protocol: this.core.protocol, version: this.core.version, topic: r2, symKey: s2, relay: a2, expiryTimestamp: o2, methods: i2 == null ? void 0 : i2.methods }); + return await this.pairings.set(r2, h2), await this.core.relayer.subscribe(r2), this.core.expirer.set(r2, o2), { topic: r2, uri: l2 }; + }, this.pair = async (i2) => { + this.isInitialized(), this.isValidPair(i2); + const { topic: s2, symKey: r2, relay: o2, expiryTimestamp: a2, methods: h2 } = Pu(i2.uri); + let l2; + if (this.pairings.keys.includes(s2) && (l2 = this.pairings.get(s2), l2.active)) + throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); + const d2 = a2 || d0(cjs$3.FIVE_MINUTES), g2 = { topic: s2, relay: o2, expiry: d2, active: false, methods: h2 }; + return await this.pairings.set(s2, g2), this.core.expirer.set(s2, d2), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V$2.create, g2), this.core.crypto.keychain.has(s2) || await this.core.crypto.setSymKey(r2, s2), await this.core.relayer.subscribe(s2, { relay: o2 }), g2; + }, this.activate = async ({ topic: i2 }) => { + this.isInitialized(); + const s2 = d0(cjs$3.THIRTY_DAYS); + await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); + }, this.ping = async (i2) => { + this.isInitialized(), await this.isValidPing(i2); + const { topic: s2 } = i2; + if (this.pairings.keys.includes(s2)) { + const r2 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a2, reject: h2 } = a0(); + this.events.once(v0("pairing_ping", r2), ({ error: l2 }) => { + l2 ? h2(l2) : a2(); + }), await o2(); } - }, this.find = (e2) => (this.isInitialized(), this.client.session.getAll().filter((s2) => Mt$2(s2, e2))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.cleanupDuplicatePairings = async (e2) => { - if (e2.pairingTopic) - try { - const s2 = this.client.core.pairing.pairings.get(e2.pairingTopic), t2 = this.client.core.pairing.pairings.getAll().filter((i2) => { - var n2, o2; - return ((n2 = i2.peerMetadata) == null ? void 0 : n2.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === e2.peer.metadata.url && i2.topic && i2.topic !== s2.topic; - }); - if (t2.length === 0) - return; - this.client.logger.info(`Cleaning up ${t2.length} duplicate pairing(s)`), await Promise.all(t2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.deleteSession = async (e2) => { - const { topic: s2, expirerHasDeleted: t2 = false, emitEvent: i2 = true, id: n2 = 0 } = e2, { self: o2 } = this.client.session.get(s2); - await this.client.core.relayer.unsubscribe(s2), await this.client.session.delete(s2, U$3("USER_DISCONNECTED")), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(s2) && await this.client.core.crypto.deleteSymKey(s2), t2 || this.client.core.expirer.del(s2), this.client.core.storage.removeItem(H$1).catch((a2) => this.client.logger.warn(a2)), this.getPendingSessionRequests().forEach((a2) => { - a2.topic === s2 && this.deletePendingSessionRequest(a2.id, U$3("USER_DISCONNECTED")); - }), i2 && this.client.events.emit("session_delete", { id: n2, topic: s2 }); - }, this.deleteProposal = async (e2, s2) => { - await Promise.all([this.client.proposal.delete(e2, U$3("USER_DISCONNECTED")), s2 ? Promise.resolve() : this.client.core.expirer.del(e2)]); - }, this.deletePendingSessionRequest = async (e2, s2, t2 = false) => { - await Promise.all([this.client.pendingRequest.delete(e2, s2), t2 ? Promise.resolve() : this.client.core.expirer.del(e2)]), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== e2), t2 && (this.sessionRequestQueue.state = I$1.idle, this.client.events.emit("session_request_expire", { id: e2 })); - }, this.setExpiry = async (e2, s2) => { - this.client.session.keys.includes(e2) && await this.client.session.update(e2, { expiry: s2 }), this.client.core.expirer.set(e2, s2); - }, this.setProposal = async (e2, s2) => { - await this.client.proposal.set(e2, s2), this.client.core.expirer.set(e2, pt$2(R$1.wc_sessionPropose.req.ttl)); - }, this.setPendingSessionRequest = async (e2) => { - const { id: s2, topic: t2, params: i2, verifyContext: n2 } = e2, o2 = i2.request.expiryTimestamp || pt$2(R$1.wc_sessionRequest.req.ttl); - await this.client.pendingRequest.set(s2, { id: s2, topic: t2, params: i2, verifyContext: n2 }), o2 && this.client.core.expirer.set(s2, o2); - }, this.sendRequest = async (e2) => { - const { topic: s2, method: t2, params: i2, expiry: n2, relayRpcId: o2, clientRpcId: a2, throwOnFailedPublish: c2 } = e2, p2 = formatJsonRpcRequest(t2, i2, a2); - if (D$4() && he$1.includes(t2)) { - const N2 = Ln(JSON.stringify(p2)); - this.client.core.verify.register({ attestationId: N2 }); - } - const d2 = await this.client.core.crypto.encode(s2, p2), h2 = R$1[t2].req; - return n2 && (h2.ttl = n2), o2 && (h2.id = o2), this.client.core.history.set(s2, p2), c2 ? (h2.internal = D$2(g$2({}, h2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, d2, h2)) : this.client.core.relayer.publish(s2, d2, h2).catch((N2) => this.client.logger.error(N2)), p2.id; - }, this.sendResult = async (e2) => { - const { id: s2, topic: t2, result: i2, throwOnFailedPublish: n2 } = e2, o2 = formatJsonRpcResult(s2, i2), a2 = await this.client.core.crypto.encode(t2, o2), c2 = await this.client.core.history.get(t2, s2), p2 = R$1[c2.request.method].res; - n2 ? (p2.internal = D$2(g$2({}, p2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(t2, a2, p2)) : this.client.core.relayer.publish(t2, a2, p2).catch((d2) => this.client.logger.error(d2)), await this.client.core.history.resolve(o2); - }, this.sendError = async (e2, s2, t2) => { - const i2 = formatJsonRpcError(e2, t2), n2 = await this.client.core.crypto.encode(s2, i2), o2 = await this.client.core.history.get(s2, e2), a2 = R$1[o2.request.method].res; - this.client.core.relayer.publish(s2, n2, a2), await this.client.core.history.resolve(i2); + }, this.updateExpiry = async ({ topic: i2, expiry: s2 }) => { + this.isInitialized(), await this.pairings.update(i2, { expiry: s2 }); + }, this.updateMetadata = async ({ topic: i2, metadata: s2 }) => { + this.isInitialized(), await this.pairings.update(i2, { peerMetadata: s2 }); + }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { + this.isInitialized(), await this.isValidDisconnect(i2); + const { topic: s2 } = i2; + this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", tr$2("USER_DISCONNECTED")), await this.deletePairing(s2)); + }, this.sendRequest = async (i2, s2, r2) => { + const o2 = formatJsonRpcRequest(s2, r2), a2 = await this.core.crypto.encode(i2, o2), h2 = F$1[s2].req; + return this.core.history.set(i2, o2), this.core.relayer.publish(i2, a2, h2), o2.id; + }, this.sendResult = async (i2, s2, r2) => { + const o2 = formatJsonRpcResult(i2, r2), a2 = await this.core.crypto.encode(s2, o2), h2 = await this.core.history.get(s2, i2), l2 = F$1[h2.request.method].res; + await this.core.relayer.publish(s2, a2, l2), await this.core.history.resolve(o2); + }, this.sendError = async (i2, s2, r2) => { + const o2 = formatJsonRpcError(i2, r2), a2 = await this.core.crypto.encode(s2, o2), h2 = await this.core.history.get(s2, i2), l2 = F$1[h2.request.method] ? F$1[h2.request.method].res : F$1.unregistered_method.res; + await this.core.relayer.publish(s2, a2, l2), await this.core.history.resolve(o2); + }, this.deletePairing = async (i2, s2) => { + await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, tr$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); }, this.cleanup = async () => { - const e2 = [], s2 = []; - this.client.session.getAll().forEach((t2) => { - let i2 = false; - mt$2(t2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(t2.topic) || (i2 = true), i2 && e2.push(t2.topic); - }), this.client.proposal.getAll().forEach((t2) => { - mt$2(t2.expiryTimestamp) && s2.push(t2.id); - }), await Promise.all([...e2.map((t2) => this.deleteSession({ topic: t2 })), ...s2.map((t2) => this.deleteProposal(t2))]); - }, this.onRelayEventRequest = async (e2) => { - this.requestQueue.queue.push(e2), await this.processRequestsQueue(); - }, this.processRequestsQueue = async () => { - if (this.requestQueue.state === I$1.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 = I$1.active; - const e2 = this.requestQueue.queue.shift(); - if (e2) - try { - this.processRequest(e2), await new Promise((s2) => setTimeout(s2, 300)); - } catch (s2) { - this.client.logger.warn(s2); - } - } - this.requestQueue.state = I$1.idle; - }, this.processRequest = (e2) => { - const { topic: s2, payload: t2 } = e2, i2 = t2.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeRequest(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleRequest(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateRequest(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendRequest(s2, t2); - case "wc_sessionPing": - return this.onSessionPingRequest(s2, t2); - case "wc_sessionDelete": - return this.onSessionDeleteRequest(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequest(s2, t2); - case "wc_sessionEvent": - return this.onSessionEventRequest(s2, t2); + const i2 = this.pairings.getAll().filter((s2) => p0(s2.expiry)); + await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); + }, this.onRelayEventRequest = (i2) => { + const { topic: s2, payload: r2 } = i2; + switch (r2.method) { + case "wc_pairingPing": + return this.onPairingPingRequest(s2, r2); + case "wc_pairingDelete": + return this.onPairingDeleteRequest(s2, r2); default: - return this.client.logger.info(`Unsupported request method ${i2}`); + return this.onUnknownRpcMethodRequest(s2, r2); } - }, this.onRelayEventResponse = async (e2) => { - const { topic: s2, payload: t2 } = e2, i2 = (await this.client.core.history.get(s2, t2.id)).request.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeResponse(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleResponse(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateResponse(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendResponse(s2, t2); - case "wc_sessionPing": - return this.onSessionPingResponse(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequestResponse(s2, t2); + }, this.onRelayEventResponse = async (i2) => { + const { topic: s2, payload: r2 } = i2, o2 = (await this.core.history.get(s2, r2.id)).request.method; + switch (o2) { + case "wc_pairingPing": + return this.onPairingPingResponse(s2, r2); default: - return this.client.logger.info(`Unsupported response method ${i2}`); - } - }, this.onRelayEventUnknownPayload = (e2) => { - const { topic: s2 } = e2, { message: t2 } = N$2("MISSING_OR_INVALID", `Decoded payload on topic ${s2} is not identifiable as a JSON-RPC request or a response.`); - throw new Error(t2); - }, this.onSessionProposeRequest = async (e2, s2) => { - const { params: t2, id: i2 } = s2; - try { - this.isValidConnect(g$2({}, s2.params)); - const n2 = t2.expiryTimestamp || pt$2(R$1.wc_sessionPropose.req.ttl), o2 = g$2({ id: i2, pairingTopic: e2, expiryTimestamp: n2 }, t2); - await this.setProposal(i2, o2); - const a2 = Ln(JSON.stringify(s2)), c2 = await this.getVerifyContext(a2, o2.proposer.metadata); - this.client.events.emit("session_proposal", { id: i2, params: o2, verifyContext: c2 }); - } catch (n2) { - await this.sendError(i2, e2, n2), this.client.logger.error(n2); - } - }, this.onSessionProposeResponse = async (e2, s2) => { - const { id: t2 } = s2; - if (isJsonRpcResult(s2)) { - const { result: i2 } = s2; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); - const n2 = this.client.proposal.get(t2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: n2 }); - const o2 = n2.proposer.publicKey; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o2 }); - const a2 = i2.responderPublicKey; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a2 }); - const c2 = await this.client.core.crypto.generateSharedKey(o2, a2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); - const p2 = await this.client.core.relayer.subscribe(c2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: p2 }), await this.client.core.pairing.activate({ topic: e2 }); - } else - isJsonRpcError(s2) && (await this.client.proposal.delete(t2, U$3("USER_DISCONNECTED")), this.events.emit(yt$2("session_connect"), { error: s2.error })); - }, this.onSessionSettleRequest = async (e2, s2) => { - const { id: t2, params: i2 } = s2; - try { - this.isValidSessionSettleRequest(i2); - const { relay: n2, controller: o2, expiry: a2, namespaces: c2, sessionProperties: p2, pairingTopic: d2 } = s2.params, h2 = g$2({ topic: e2, relay: n2, expiry: a2, namespaces: c2, acknowledged: true, pairingTopic: d2, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, p2 && { sessionProperties: p2 }); - await this.sendResult({ id: s2.id, topic: e2, result: true }), this.events.emit(yt$2("session_connect"), { session: h2 }), this.cleanupDuplicatePairings(h2); - } catch (n2) { - await this.sendError(t2, e2, n2), this.client.logger.error(n2); - } - }, this.onSessionSettleResponse = async (e2, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? (await this.client.session.update(e2, { acknowledged: true }), this.events.emit(yt$2("session_approve", t2), {})) : isJsonRpcError(s2) && (await this.client.session.delete(e2, U$3("USER_DISCONNECTED")), this.events.emit(yt$2("session_approve", t2), { error: s2.error })); - }, this.onSessionUpdateRequest = async (e2, s2) => { - const { params: t2, id: i2 } = s2; - try { - const n2 = `${e2}_session_update`, o2 = sr$2.get(n2); - if (o2 && this.isRequestOutOfSync(o2, i2)) { - this.client.logger.info(`Discarding out of sync request - ${i2}`); - return; - } - this.isValidUpdate(g$2({ topic: e2 }, t2)), await this.client.session.update(e2, { namespaces: t2.namespaces }), await this.sendResult({ id: i2, topic: e2, result: true }), this.client.events.emit("session_update", { id: i2, topic: e2, params: t2 }), sr$2.set(n2, i2); - } catch (n2) { - await this.sendError(i2, e2, n2), this.client.logger.error(n2); - } - }, this.isRequestOutOfSync = (e2, s2) => parseInt(s2.toString().slice(0, -3)) <= parseInt(e2.toString().slice(0, -3)), this.onSessionUpdateResponse = (e2, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$2("session_update", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$2("session_update", t2), { error: s2.error }); - }, this.onSessionExtendRequest = async (e2, s2) => { - const { id: t2 } = s2; - try { - this.isValidExtend({ topic: e2 }), await this.setExpiry(e2, pt$2(L$2)), await this.sendResult({ id: t2, topic: e2, result: true }), this.client.events.emit("session_extend", { id: t2, topic: e2 }); - } catch (i2) { - await this.sendError(t2, e2, i2), this.client.logger.error(i2); + return this.onUnknownRpcMethodResponse(o2); } - }, this.onSessionExtendResponse = (e2, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$2("session_extend", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$2("session_extend", t2), { error: s2.error }); - }, this.onSessionPingRequest = async (e2, s2) => { - const { id: t2 } = s2; + }, this.onPairingPingRequest = async (i2, s2) => { + const { id: r2 } = s2; try { - this.isValidPing({ topic: e2 }), await this.sendResult({ id: t2, topic: e2, result: true }), this.client.events.emit("session_ping", { id: t2, topic: e2 }); - } catch (i2) { - await this.sendError(t2, e2, i2), this.client.logger.error(i2); + this.isValidPing({ topic: i2 }), await this.sendResult(r2, i2, true), this.events.emit(V$2.ping, { id: r2, topic: i2 }); + } catch (o2) { + await this.sendError(r2, i2, o2), this.logger.error(o2); } - }, this.onSessionPingResponse = (e2, s2) => { - const { id: t2 } = s2; + }, this.onPairingPingResponse = (i2, s2) => { + const { id: r2 } = s2; setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$2("session_ping", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$2("session_ping", t2), { error: s2.error }); + isJsonRpcResult(s2) ? this.events.emit(v0("pairing_ping", r2), {}) : isJsonRpcError(s2) && this.events.emit(v0("pairing_ping", r2), { error: s2.error }); }, 500); - }, this.onSessionDeleteRequest = async (e2, s2) => { - const { id: t2 } = s2; + }, this.onPairingDeleteRequest = async (i2, s2) => { + const { id: r2 } = s2; try { - this.isValidDisconnect({ topic: e2, reason: s2.params }), await Promise.all([new Promise((i2) => { - this.client.core.relayer.once(D$3.publish, async () => { - i2(await this.deleteSession({ topic: e2, id: t2 })); - }); - }), this.sendResult({ id: t2, topic: e2, result: true }), this.cleanupPendingSentRequestsForTopic({ topic: e2, error: U$3("USER_DISCONNECTED") })]); - } catch (i2) { - this.client.logger.error(i2); + this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V$2.delete, { id: r2, topic: i2 }); + } catch (o2) { + await this.sendError(r2, i2, o2), this.logger.error(o2); } - }, this.onSessionRequest = async (e2, s2) => { - const { id: t2, params: i2 } = s2; - try { - this.isValidRequest(g$2({ topic: e2 }, i2)); - const n2 = Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, t2))), o2 = this.client.session.get(e2), a2 = await this.getVerifyContext(n2, o2.peer.metadata), c2 = { id: t2, topic: e2, params: i2, verifyContext: a2 }; - await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); - } catch (n2) { - await this.sendError(t2, e2, n2), this.client.logger.error(n2); - } - }, this.onSessionRequestResponse = (e2, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$2("session_request", t2), { result: s2.result }) : isJsonRpcError(s2) && this.events.emit(yt$2("session_request", t2), { error: s2.error }); - }, this.onSessionEventRequest = async (e2, s2) => { - const { id: t2, params: i2 } = s2; + }, this.onUnknownRpcMethodRequest = async (i2, s2) => { + const { id: r2, method: o2 } = s2; try { - const n2 = `${e2}_session_event_${i2.event.name}`, o2 = sr$2.get(n2); - if (o2 && this.isRequestOutOfSync(o2, t2)) { - this.client.logger.info(`Discarding out of sync request - ${t2}`); + if (this.registeredMethods.includes(o2)) return; - } - this.isValidEmit(g$2({ topic: e2 }, i2)), this.client.events.emit("session_event", { id: t2, topic: e2, params: i2 }), sr$2.set(n2, t2); - } catch (n2) { - await this.sendError(t2, e2, n2), this.client.logger.error(n2); - } - }, this.addSessionRequestToSessionRequestQueue = (e2) => { - this.sessionRequestQueue.queue.push(e2); - }, this.cleanupAfterResponse = (e2) => { - this.deletePendingSessionRequest(e2.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { - this.sessionRequestQueue.state = I$1.idle, this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay)); - }, this.cleanupPendingSentRequestsForTopic = ({ topic: e2, error: s2 }) => { - const t2 = this.client.core.history.pending; - t2.length > 0 && t2.filter((i2) => i2.topic === e2 && i2.request.method === "wc_sessionRequest").forEach((i2) => { - this.events.emit(yt$2("session_request", i2.request.id), { error: s2 }); - }); - }, this.processSessionRequestQueue = () => { - if (this.sessionRequestQueue.state === I$1.active) { - this.client.logger.info("session request queue is already active."); - return; - } - const e2 = this.sessionRequestQueue.queue[0]; - if (!e2) { - this.client.logger.info("session request queue is empty."); - return; - } - try { - this.sessionRequestQueue.state = I$1.active, this.client.events.emit("session_request", e2); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.onPairingCreated = (e2) => { - if (e2.active) - return; - const s2 = this.client.proposal.getAll().find((t2) => t2.pairingTopic === e2.topic); - s2 && this.onSessionProposeRequest(e2.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: s2.requiredNamespaces, optionalNamespaces: s2.optionalNamespaces, relays: s2.relays, proposer: s2.proposer, sessionProperties: s2.sessionProperties }, s2.id)); - }, this.isValidConnect = async (e2) => { - if (!Gt$2(e2)) { - const { message: a2 } = N$2("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(e2)}`); - throw new Error(a2); - } - const { pairingTopic: s2, requiredNamespaces: t2, optionalNamespaces: i2, sessionProperties: n2, relays: o2 } = e2; - if (w$4(s2) || await this.isValidPairingTopic(s2), !qt$2(o2, true)) { - const { message: a2 } = N$2("MISSING_OR_INVALID", `connect() relays: ${o2}`); - throw new Error(a2); - } - !w$4(t2) && B$3(t2) !== 0 && this.validateNamespaces(t2, "requiredNamespaces"), !w$4(i2) && B$3(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), w$4(n2) || this.validateSessionProps(n2, "sessionProperties"); - }, this.validateNamespaces = (e2, s2) => { - const t2 = Ht$2(e2, "connect()", s2); - if (t2) - throw new Error(t2.message); - }, this.isValidApprove = async (e2) => { - if (!Gt$2(e2)) - throw new Error(N$2("MISSING_OR_INVALID", `approve() params: ${e2}`).message); - const { id: s2, namespaces: t2, relayProtocol: i2, sessionProperties: n2 } = e2; - await this.isValidProposalId(s2); - const o2 = this.client.proposal.get(s2), a2 = ln(t2, "approve()"); - if (a2) - throw new Error(a2.message); - const c2 = fn(o2.requiredNamespaces, t2, "approve()"); - if (c2) - throw new Error(c2.message); - if (!g$4(i2, true)) { - const { message: p2 } = N$2("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); - throw new Error(p2); - } - w$4(n2) || this.validateSessionProps(n2, "sessionProperties"); - }, this.isValidReject = async (e2) => { - if (!Gt$2(e2)) { - const { message: i2 } = N$2("MISSING_OR_INVALID", `reject() params: ${e2}`); - throw new Error(i2); - } - const { id: s2, reason: t2 } = e2; - if (await this.isValidProposalId(s2), !Wt$1(t2)) { - const { message: i2 } = N$2("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(t2)}`); - throw new Error(i2); - } - }, this.isValidSessionSettleRequest = (e2) => { - if (!Gt$2(e2)) { - const { message: c2 } = N$2("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${e2}`); - throw new Error(c2); - } - const { relay: s2, controller: t2, namespaces: i2, expiry: n2 } = e2; - if (!dn(s2)) { - const { message: c2 } = N$2("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); - throw new Error(c2); - } - const o2 = Ft$2(t2, "onSessionSettleRequest()"); - if (o2) - throw new Error(o2.message); - const a2 = ln(i2, "onSessionSettleRequest()"); - if (a2) - throw new Error(a2.message); - if (mt$2(n2)) { - const { message: c2 } = N$2("EXPIRED", "onSessionSettleRequest()"); - throw new Error(c2); - } - }, this.isValidUpdate = async (e2) => { - if (!Gt$2(e2)) { - const { message: a2 } = N$2("MISSING_OR_INVALID", `update() params: ${e2}`); - throw new Error(a2); - } - const { topic: s2, namespaces: t2 } = e2; - await this.isValidSessionTopic(s2); - const i2 = this.client.session.get(s2), n2 = ln(t2, "update()"); - if (n2) - throw new Error(n2.message); - const o2 = fn(i2.requiredNamespaces, t2, "update()"); - if (o2) - throw new Error(o2.message); - }, this.isValidExtend = async (e2) => { - if (!Gt$2(e2)) { - const { message: t2 } = N$2("MISSING_OR_INVALID", `extend() params: ${e2}`); - throw new Error(t2); - } - const { topic: s2 } = e2; - await this.isValidSessionTopic(s2); - }, this.isValidRequest = async (e2) => { - if (!Gt$2(e2)) { - const { message: a2 } = N$2("MISSING_OR_INVALID", `request() params: ${e2}`); - throw new Error(a2); - } - const { topic: s2, request: t2, chainId: i2, expiry: n2 } = e2; - await this.isValidSessionTopic(s2); - const { namespaces: o2 } = this.client.session.get(s2); - if (!Qt$1(o2, i2)) { - const { message: a2 } = N$2("MISSING_OR_INVALID", `request() chainId: ${i2}`); - throw new Error(a2); - } - if (!zt$2(t2)) { - const { message: a2 } = N$2("MISSING_OR_INVALID", `request() ${JSON.stringify(t2)}`); - throw new Error(a2); - } - if (!Zt$1(o2, i2, t2.method)) { - const { message: a2 } = N$2("MISSING_OR_INVALID", `request() method: ${t2.method}`); - throw new Error(a2); - } - if (n2 && !tr$2(n2, U$2)) { - const { message: a2 } = N$2("MISSING_OR_INVALID", `request() expiry: ${n2}. Expiry must be a number (in seconds) between ${U$2.min} and ${U$2.max}`); - throw new Error(a2); + const a2 = tr$2("WC_METHOD_UNSUPPORTED", o2); + await this.sendError(r2, i2, a2), this.logger.error(a2); + } catch (a2) { + await this.sendError(r2, i2, a2), this.logger.error(a2); } - }, this.isValidRespond = async (e2) => { + }, this.onUnknownRpcMethodResponse = (i2) => { + this.registeredMethods.includes(i2) || this.logger.error(tr$2("WC_METHOD_UNSUPPORTED", i2)); + }, this.isValidPair = (i2) => { var s2; - if (!Gt$2(e2)) { - const { message: n2 } = N$2("MISSING_OR_INVALID", `respond() params: ${e2}`); - throw new Error(n2); + if (!$u(i2)) { + const { message: o2 } = xe$1("MISSING_OR_INVALID", `pair() params: ${i2}`); + throw new Error(o2); } - const { topic: t2, response: i2 } = e2; - try { - await this.isValidSessionTopic(t2); - } catch (n2) { - throw (s2 = e2 == null ? void 0 : e2.response) != null && s2.id && this.cleanupAfterResponse(e2), n2; - } - if (!Yt$2(i2)) { - const { message: n2 } = N$2("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); - throw new Error(n2); - } - }, this.isValidPing = async (e2) => { - if (!Gt$2(e2)) { - const { message: t2 } = N$2("MISSING_OR_INVALID", `ping() params: ${e2}`); - throw new Error(t2); - } - const { topic: s2 } = e2; - await this.isValidSessionOrPairingTopic(s2); - }, this.isValidEmit = async (e2) => { - if (!Gt$2(e2)) { - const { message: o2 } = N$2("MISSING_OR_INVALID", `emit() params: ${e2}`); + if (!Ju(i2.uri)) { + const { message: o2 } = xe$1("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); + throw new Error(o2); + } + const r2 = Pu(i2.uri); + if (!((s2 = r2 == null ? void 0 : r2.relay) != null && s2.protocol)) { + const { message: o2 } = xe$1("MISSING_OR_INVALID", "pair() uri#relay-protocol"); throw new Error(o2); } - const { topic: s2, event: t2, chainId: i2 } = e2; - await this.isValidSessionTopic(s2); - const { namespaces: n2 } = this.client.session.get(s2); - if (!Qt$1(n2, i2)) { - const { message: o2 } = N$2("MISSING_OR_INVALID", `emit() chainId: ${i2}`); + if (!(r2 != null && r2.symKey)) { + const { message: o2 } = xe$1("MISSING_OR_INVALID", "pair() uri#symKey"); throw new Error(o2); } - if (!Jt$2(t2)) { - const { message: o2 } = N$2("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); + if (r2 != null && r2.expiryTimestamp && cjs$3.toMiliseconds(r2 == null ? void 0 : r2.expiryTimestamp) < Date.now()) { + const { message: o2 } = xe$1("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); throw new Error(o2); } - if (!Xt$1(n2, i2, t2.name)) { - const { message: o2 } = N$2("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); - throw new Error(o2); + }, this.isValidPing = async (i2) => { + if (!$u(i2)) { + const { message: r2 } = xe$1("MISSING_OR_INVALID", `ping() params: ${i2}`); + throw new Error(r2); + } + const { topic: s2 } = i2; + await this.isValidPairingTopic(s2); + }, this.isValidDisconnect = async (i2) => { + if (!$u(i2)) { + const { message: r2 } = xe$1("MISSING_OR_INVALID", `disconnect() params: ${i2}`); + throw new Error(r2); + } + const { topic: s2 } = i2; + await this.isValidPairingTopic(s2); + }, this.isValidPairingTopic = async (i2) => { + if (!Gt$2(i2, false)) { + const { message: s2 } = xe$1("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); + throw new Error(s2); } - }, this.isValidDisconnect = async (e2) => { - if (!Gt$2(e2)) { - const { message: t2 } = N$2("MISSING_OR_INVALID", `disconnect() params: ${e2}`); - throw new Error(t2); + if (!this.pairings.keys.includes(i2)) { + const { message: s2 } = xe$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); + throw new Error(s2); } - const { topic: s2 } = e2; - await this.isValidSessionOrPairingTopic(s2); - }, this.getVerifyContext = async (e2, s2) => { - const t2 = { verified: { verifyUrl: s2.verifyUrl || F$2, validation: "UNKNOWN", origin: s2.url || "" } }; - try { - const i2 = await this.client.core.verify.resolve({ attestationId: e2, verifyUrl: s2.verifyUrl }); - i2 && (t2.verified.origin = i2.origin, t2.verified.isScam = i2.isScam, t2.verified.validation = i2.origin === new URL(s2.url).origin ? "VALID" : "INVALID"); - } catch (i2) { - this.client.logger.info(i2); + if (p0(this.pairings.get(i2).expiry)) { + await this.deletePairing(i2); + const { message: s2 } = xe$1("EXPIRED", `pairing topic: ${i2}`); + throw new Error(s2); } - return this.client.logger.info(`Verify context: ${JSON.stringify(t2)}`), t2; - }, this.validateSessionProps = (e2, s2) => { - Object.values(e2).forEach((t2) => { - if (!g$4(t2, false)) { - const { message: i2 } = N$2("MISSING_OR_INVALID", `${s2} must be in Record format. Received: ${JSON.stringify(t2)}`); - throw new Error(i2); - } - }); - }; + }, this.core = e2, this.logger = E$2(t2, this.name), this.pairings = new Vt(this.core, this.logger, this.name, this.storagePrefix); } - async isInitialized() { + get context() { + return y$3(this.logger); + } + isInitialized() { if (!this.initialized) { - const { message: r2 } = N$2("NOT_INITIALIZED", this.name); - throw new Error(r2); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); + throw new Error(e2); } - await this.client.core.relayer.confirmOnlineStateOrThrow(); } registerRelayerEvents() { - this.client.core.relayer.on(D$3.message, async (r2) => { - const { topic: e2, message: s2 } = r2; - if (this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s2))) + this.core.relayer.on(v$1.message, async (e2) => { + const { topic: t2, message: i2 } = e2; + if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) return; - const t2 = await this.client.core.crypto.decode(e2, s2); + const s2 = await this.core.crypto.decode(t2, i2); try { - isJsonRpcRequest(t2) ? (this.client.core.history.set(e2, t2), this.onRelayEventRequest({ topic: e2, payload: t2 })) : isJsonRpcResponse(t2) ? (await this.client.core.history.resolve(t2), await this.onRelayEventResponse({ topic: e2, payload: t2 }), this.client.core.history.delete(e2, t2.id)) : this.onRelayEventUnknownPayload({ topic: e2, payload: t2 }); - } catch (i2) { - this.client.logger.error(i2); + isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); + } catch (r2) { + this.logger.error(r2); } }); } registerExpirerEvents() { - this.client.core.expirer.on(v$2.expired, async (r2) => { - const { topic: e2, id: s2 } = ft$2(r2.target); - if (s2 && this.client.pendingRequest.keys.includes(s2)) - return await this.deletePendingSessionRequest(s2, N$2("EXPIRED"), true); - e2 ? this.client.session.keys.includes(e2) && (await this.deleteSession({ topic: e2, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: e2 })) : s2 && (await this.deleteProposal(s2, true), this.client.events.emit("proposal_expire", { id: s2 })); + this.core.expirer.on(C$1.expired, async (e2) => { + const { topic: t2 } = l0(e2.target); + t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V$2.expire, { topic: t2 })); }); } - registerPairingEvents() { - this.client.core.pairing.events.on(V$1.create, (r2) => this.onPairingCreated(r2)); + } + let jt$2 = class jt extends h$4 { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = _t$1, this.cached = [], this.initialized = false, this.storagePrefix = z$2, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); + }, this.set = (i2, s2, r2) => { + if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r2 }), this.records.has(s2.id)) + return; + const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r2, expiry: d0(cjs$3.THIRTY_DAYS) }; + this.records.set(o2.id, o2), this.persist(), this.events.emit(I$2.created, o2); + }, this.resolve = async (i2) => { + if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) + return; + const s2 = await this.getRecord(i2.id); + typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.persist(), this.events.emit(I$2.updated, s2)); + }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { + this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r2) => { + if (r2.topic === i2) { + if (typeof s2 < "u" && r2.id !== s2) + return; + this.records.delete(r2.id), this.events.emit(I$2.deleted, r2); + } + }), this.persist(); + }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.logger = E$2(t2, this.name); } - isValidPairingTopic(r2) { - if (!g$4(r2, false)) { - const { message: e2 } = N$2("MISSING_OR_INVALID", `pairing topic should be a string: ${r2}`); - throw new Error(e2); - } - if (!this.client.core.pairing.pairings.keys.includes(r2)) { - const { message: e2 } = N$2("NO_MATCHING_KEY", `pairing topic doesn't exist: ${r2}`); - throw new Error(e2); - } - if (mt$2(this.client.core.pairing.pairings.get(r2).expiry)) { - const { message: e2 } = N$2("EXPIRED", `pairing topic: ${r2}`); - throw new Error(e2); - } + get context() { + return y$3(this.logger); } - async isValidSessionTopic(r2) { - if (!g$4(r2, false)) { - const { message: e2 } = N$2("MISSING_OR_INVALID", `session topic should be a string: ${r2}`); - throw new Error(e2); - } - if (!this.client.session.keys.includes(r2)) { - const { message: e2 } = N$2("NO_MATCHING_KEY", `session topic doesn't exist: ${r2}`); - throw new Error(e2); - } - if (mt$2(this.client.session.get(r2).expiry)) { - await this.deleteSession({ topic: r2 }); - const { message: e2 } = N$2("EXPIRED", `session topic: ${r2}`); - throw new Error(e2); - } - if (!this.client.core.crypto.keychain.has(r2)) { - const { message: e2 } = N$2("MISSING_OR_INVALID", `session topic does not exist in keychain: ${r2}`); - throw await this.deleteSession({ topic: r2 }), new Error(e2); - } + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } - async isValidSessionOrPairingTopic(r2) { - if (this.client.session.keys.includes(r2)) - await this.isValidSessionTopic(r2); - else if (this.client.core.pairing.pairings.keys.includes(r2)) - this.isValidPairingTopic(r2); - else if (g$4(r2, false)) { - const { message: e2 } = N$2("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${r2}`); - throw new Error(e2); - } else { - const { message: e2 } = N$2("MISSING_OR_INVALID", `session or pairing topic should be a string: ${r2}`); - throw new Error(e2); - } + get size() { + return this.records.size; } - async isValidProposalId(r2) { - if (!Bt$2(r2)) { - const { message: e2 } = N$2("MISSING_OR_INVALID", `proposal id should be a number: ${r2}`); - throw new Error(e2); - } - if (!this.client.proposal.keys.includes(r2)) { - const { message: e2 } = N$2("NO_MATCHING_KEY", `proposal id doesn't exist: ${r2}`); - throw new Error(e2); - } - if (mt$2(this.client.proposal.get(r2).expiryTimestamp)) { - await this.deleteProposal(r2); - const { message: e2 } = N$2("EXPIRED", `proposal id: ${r2}`); - throw new Error(e2); - } + get keys() { + return Array.from(this.records.keys()); } - } - class us extends Kt$1 { - constructor(r2, e2) { - super(r2, e2, oe$1, G$1), this.core = r2, this.logger = e2; + get values() { + return Array.from(this.records.values()); } - } - class ge extends Kt$1 { - constructor(r2, e2) { - super(r2, e2, ce$1, G$1), this.core = r2, this.logger = e2; + get pending() { + const e2 = []; + return this.values.forEach((t2) => { + if (typeof t2.response < "u") + return; + const i2 = { topic: t2.topic, request: formatJsonRpcRequest(t2.request.method, t2.request.params, t2.id), chainId: t2.chainId }; + return e2.push(i2); + }), e2; } - } - class gs extends Kt$1 { - constructor(r2, e2) { - super(r2, e2, pe, G$1, (s2) => s2.id), this.core = r2, this.logger = e2; + async setJsonRpcRecords(e2) { + await this.core.storage.setItem(this.storageKey, e2); } - } - let Q$1 = class Q2 extends b$2 { - constructor(r2) { - super(r2), this.protocol = J, this.version = F$1, this.name = M$1.name, this.events = new eventsExports.EventEmitter(), this.on = (s2, t2) => this.events.on(s2, t2), this.once = (s2, t2) => this.events.once(s2, t2), this.off = (s2, t2) => this.events.off(s2, t2), this.removeListener = (s2, t2) => this.events.removeListener(s2, t2), this.removeAllListeners = (s2) => this.events.removeAllListeners(s2), this.connect = async (s2) => { - try { - return await this.engine.connect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.pair = async (s2) => { - try { - return await this.engine.pair(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.approve = async (s2) => { - try { - return await this.engine.approve(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.reject = async (s2) => { - try { - return await this.engine.reject(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.update = async (s2) => { - try { - return await this.engine.update(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.extend = async (s2) => { - try { - return await this.engine.extend(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.request = async (s2) => { - try { - return await this.engine.request(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.respond = async (s2) => { - try { - return await this.engine.respond(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.ping = async (s2) => { - try { - return await this.engine.ping(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.emit = async (s2) => { - try { - return await this.engine.emit(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.disconnect = async (s2) => { - try { - return await this.engine.disconnect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.find = (s2) => { - try { - return this.engine.find(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.getPendingSessionRequests = () => { - try { - return this.engine.getPendingSessionRequests(); - } catch (s2) { - throw this.logger.error(s2.message), s2; - } - }, this.name = (r2 == null ? void 0 : r2.name) || M$1.name, this.metadata = (r2 == null ? void 0 : r2.metadata) || Qn(); - const e2 = typeof (r2 == null ? void 0 : r2.logger) < "u" && typeof (r2 == null ? void 0 : r2.logger) != "string" ? r2.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (r2 == null ? void 0 : r2.logger) || M$1.logger })); - this.core = (r2 == null ? void 0 : r2.core) || new Mr(r2), this.logger = cjs$3.generateChildLogger(e2, this.name), this.session = new ge(this.core, this.logger), this.proposal = new us(this.core, this.logger), this.pendingRequest = new gs(this.core, this.logger), this.engine = new ds(this); + async getJsonRpcRecords() { + return await this.core.storage.getItem(this.storageKey); } - static async init(r2) { - const e2 = new Q2(r2); - return await e2.initialize(), e2; + getRecord(e2) { + this.isInitialized(); + const t2 = this.records.get(e2); + if (!t2) { + const { message: i2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw new Error(i2); + } + return t2; } - get context() { - return cjs$3.getLoggerContext(this.logger); + async persist() { + await this.setJsonRpcRecords(this.values), this.events.emit(I$2.sync); } - get pairing() { - return this.core.pairing.pairings; + async restore() { + try { + const e2 = await this.getJsonRpcRecords(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.records.size) { + const { message: t2 } = xe$1("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", records: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(e2); + } } - async initialize() { - this.logger.trace("Initialized"); + registerEventListeners() { + this.events.on(I$2.created, (e2) => { + const t2 = I$2.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$2.updated, (e2) => { + const t2 = I$2.updated; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$2.deleted, (e2) => { + const t2 = I$2.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { + this.cleanup(); + }); + } + cleanup() { try { - await this.core.start(), await this.session.init(), await this.proposal.init(), await this.pendingRequest.init(), await this.engine.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); - } catch (r2) { - throw this.logger.info("SignClient Initialization Failure"), this.logger.error(r2.message), r2; + this.isInitialized(); + let e2 = false; + this.records.forEach((t2) => { + cjs$3.toMiliseconds(t2.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${t2.id}`), this.records.delete(t2.id), this.events.emit(I$2.deleted, t2, false), e2 = true); + }), e2 && this.persist(); + } catch (e2) { + this.logger.warn(e2); + } + } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); + throw new Error(e2); } } }; - var P$1 = Object.defineProperty, x$1 = Object.defineProperties, N$1 = Object.getOwnPropertyDescriptors, j$1 = Object.getOwnPropertySymbols, U$1 = Object.prototype.hasOwnProperty, T$2 = Object.prototype.propertyIsEnumerable, W = (e2, t2, s2) => t2 in e2 ? P$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, q$1 = (e2, t2) => { - for (var s2 in t2 || (t2 = {})) - U$1.call(t2, s2) && W(e2, s2, t2[s2]); - if (j$1) - for (var s2 of j$1(t2)) - T$2.call(t2, s2) && W(e2, s2, t2[s2]); - return e2; - }, A$2 = (e2, t2) => x$1(e2, N$1(t2)), S$3 = (e2, t2, s2) => { - if (!t2.has(e2)) - throw TypeError("Cannot " + s2); - }, a$2 = (e2, t2, s2) => (S$3(e2, t2, "read from private field"), s2 ? s2.call(e2) : t2.get(e2)), l$4 = (e2, t2, s2) => { - if (t2.has(e2)) - throw TypeError("Cannot add the same private member more than once"); - t2 instanceof WeakSet ? t2.add(e2) : t2.set(e2, s2); - }, y$1 = (e2, t2, s2, d2) => (S$3(e2, t2, "write to private field"), d2 ? d2.call(e2, s2) : t2.set(e2, s2), s2), o$5 = (e2, t2, s2) => (S$3(e2, t2, "access private method"), s2), h$3, p$1, w$1, i$4, u$2, _$2, n$6, r$3, m$1, g$1; - let z$2 = class z { - constructor(t2) { - l$4(this, u$2), l$4(this, n$6), l$4(this, m$1), l$4(this, h$3, void 0), l$4(this, p$1, void 0), l$4(this, w$1, void 0), l$4(this, i$4, void 0), y$1(this, h$3, t2), y$1(this, p$1, o$5(this, u$2, _$2).call(this)), o$5(this, n$6, r$3).call(this); - } - async connect(t2) { - const { requiredNamespaces: s2, optionalNamespaces: d2 } = t2; - return new Promise(async (C2, b2) => { - await o$5(this, n$6, r$3).call(this); - const E2 = a$2(this, p$1).subscribeModal((c2) => { - c2.open || (E2(), b2(new Error("Modal closed"))); - }), { uri: O2, approval: I2 } = await a$2(this, i$4).connect(t2); - if (O2) { - const c2 = /* @__PURE__ */ new Set(); - s2 && Object.values(s2).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v2) => c2.add(v2)); - }), d2 && Object.values(d2).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v2) => c2.add(v2)); - }), await a$2(this, p$1).openModal({ uri: O2, chains: Array.from(c2) }); - } + let Gt$1 = class Gt extends E$1 { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Rt$1, this.version = Tt$2, this.cached = [], this.initialized = false, this.storagePrefix = z$2, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); + }, this.has = (i2) => { try { - const c2 = await I2(); - C2(c2); - } catch (c2) { - b2(c2); - } finally { - E2(), a$2(this, p$1).closeModal(); + const s2 = this.formatTarget(i2); + return typeof this.getExpiration(s2) < "u"; + } catch { + return false; } - }); + }, this.set = (i2, s2) => { + this.isInitialized(); + const r2 = this.formatTarget(i2), o2 = { target: r2, expiry: s2 }; + this.expirations.set(r2, o2), this.checkExpiry(r2, o2), this.events.emit(C$1.created, { target: r2, expiration: o2 }); + }, this.get = (i2) => { + this.isInitialized(); + const s2 = this.formatTarget(i2); + return this.getExpiration(s2); + }, this.del = (i2) => { + if (this.isInitialized(), this.has(i2)) { + const s2 = this.formatTarget(i2), r2 = this.getExpiration(s2); + this.expirations.delete(s2), this.events.emit(C$1.deleted, { target: s2, expiration: r2 }); + } + }, this.on = (i2, s2) => { + this.events.on(i2, s2); + }, this.once = (i2, s2) => { + this.events.once(i2, s2); + }, this.off = (i2, s2) => { + this.events.off(i2, s2); + }, this.removeListener = (i2, s2) => { + this.events.removeListener(i2, s2); + }, this.logger = E$2(t2, this.name); } - async disconnect(t2) { - await o$5(this, n$6, r$3).call(this), await a$2(this, i$4).disconnect(t2); + get context() { + return y$3(this.logger); } - async request(t2) { - return await o$5(this, n$6, r$3).call(this), await a$2(this, i$4).request(t2); + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } - async getSessions() { - return await o$5(this, n$6, r$3).call(this), a$2(this, i$4).session.getAll(); + get length() { + return this.expirations.size; } - async getSession() { - return await o$5(this, n$6, r$3).call(this), a$2(this, i$4).session.getAll().at(-1); + get keys() { + return Array.from(this.expirations.keys()); } - async onSessionEvent(t2) { - await o$5(this, n$6, r$3).call(this), a$2(this, i$4).on("session_event", t2); + get values() { + return Array.from(this.expirations.values()); } - async offSessionEvent(t2) { - await o$5(this, n$6, r$3).call(this), a$2(this, i$4).off("session_event", t2); + formatTarget(e2) { + if (typeof e2 == "string") + return h0(e2); + if (typeof e2 == "number") + return c0(e2); + const { message: t2 } = xe$1("UNKNOWN_TYPE", `Target type: ${typeof e2}`); + throw new Error(t2); } - async onSessionUpdate(t2) { - await o$5(this, n$6, r$3).call(this), a$2(this, i$4).on("session_update", t2); + async setExpirations(e2) { + await this.core.storage.setItem(this.storageKey, e2); } - async offSessionUpdate(t2) { - await o$5(this, n$6, r$3).call(this), a$2(this, i$4).off("session_update", t2); + async getExpirations() { + return await this.core.storage.getItem(this.storageKey); } - async onSessionDelete(t2) { - await o$5(this, n$6, r$3).call(this), a$2(this, i$4).on("session_delete", t2); + async persist() { + await this.setExpirations(this.values), this.events.emit(C$1.sync); } - async offSessionDelete(t2) { - await o$5(this, n$6, r$3).call(this), a$2(this, i$4).off("session_delete", t2); + async restore() { + try { + const e2 = await this.getExpirations(); + if (typeof e2 > "u" || !e2.length) + return; + if (this.expirations.size) { + const { message: t2 } = xe$1("RESTORE_WILL_OVERRIDE", this.name); + throw this.logger.error(t2), new Error(t2); + } + this.cached = e2, this.logger.debug(`Successfully Restored expirations for ${this.name}`), this.logger.trace({ type: "method", method: "restore", expirations: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore expirations for ${this.name}`), this.logger.error(e2); + } } - async onSessionExpire(t2) { - await o$5(this, n$6, r$3).call(this), a$2(this, i$4).on("session_expire", t2); + getExpiration(e2) { + const t2 = this.expirations.get(e2); + if (!t2) { + const { message: i2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.warn(i2), new Error(i2); + } + return t2; + } + checkExpiry(e2, t2) { + const { expiry: i2 } = t2; + cjs$3.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e2, t2); } - async offSessionExpire(t2) { - await o$5(this, n$6, r$3).call(this), a$2(this, i$4).off("session_expire", t2); + expire(e2, t2) { + this.expirations.delete(e2), this.events.emit(C$1.expired, { target: e2, expiration: t2 }); } - }; - h$3 = /* @__PURE__ */ new WeakMap(), p$1 = /* @__PURE__ */ new WeakMap(), w$1 = /* @__PURE__ */ new WeakMap(), i$4 = /* @__PURE__ */ new WeakMap(), u$2 = /* @__PURE__ */ new WeakSet(), _$2 = function() { - const { modalOptions: e2, projectId: t2 } = a$2(this, h$3); - return new d$3(A$2(q$1({}, e2), { projectId: t2 })); - }, n$6 = /* @__PURE__ */ new WeakSet(), r$3 = async function() { - return a$2(this, i$4) ? true : (!a$2(this, w$1) && typeof window < "u" && y$1(this, w$1, o$5(this, m$1, g$1).call(this)), a$2(this, w$1)); - }, m$1 = /* @__PURE__ */ new WeakSet(), g$1 = async function() { - y$1(this, i$4, await Q$1.init({ metadata: a$2(this, h$3).metadata, projectId: a$2(this, h$3).projectId, relayUrl: a$2(this, h$3).relayUrl })); - const e2 = await a$2(this, i$4).core.crypto.getClientId(); - try { - localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e2); - } catch { - console.info("Unable to set client id"); + checkExpirations() { + this.core.relayer.connected && this.expirations.forEach((e2, t2) => this.checkExpiry(t2, e2)); } - }; - const wc_aleo_methods = [ - "decrypt", - "disconnect", - "getSelectedAccount", - "getBalance", - "getRecords", - "requestCreateEvent", - "getEvent", - "getEvents", - "createSharedState", - "importSharedState", - "requestSignature" - ]; - const wc_aleo_chains = ["aleo:1"]; - const wc_events = [ - "chainChanged", - "accountSelected", - "selectedAccountSynced", - "sharedAccountSynced" - ]; - const projectId = "f0aaeffe71b636da453fce042d79d723"; - function isAndroid() { - if (!navigator) { - return false; + registerEventListeners() { + this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(C$1.created, (e2) => { + const t2 = C$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C$1.expired, (e2) => { + const t2 = C$1.expired; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C$1.deleted, (e2) => { + const t2 = C$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }); } - return /Android/i.test(navigator.userAgent); - } - const web3modal_puzzle_props_android = { - projectId, - chains: ["aleo:3"], - enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } + isInitialized() { + if (!this.initialized) { + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); + throw new Error(e2); } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png" } }; - const web3modal_puzzle_props_default = { - projectId, - chains: wc_aleo_chains, - enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" + let Yt$2 = class Yt extends y$2 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.name = ee$1, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { + if (this.verifyDisabled || er$2() || !pr$1()) + return; + const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); + this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; + try { + await this.createIframe(); + } catch (r2) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2); } - } - ], - desktopWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "", - universal: "https://walletconnect.puzzle.online/" + if (!this.initialized) { + this.removeIframe(), this.verifyUrl = te; + try { + await this.createIframe(); + } catch (r2) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2), this.verifyDisabled = true; + } } - }, - { - id: "avail", - name: "Avail Wallet", - links: { - native: "avail://", - universal: "https://avail.global" + }, this.register = async (i2) => { + this.initialized ? this.sendPost(i2.attestationId) : (this.addToQueue(i2.attestationId), await this.init()); + }, this.resolve = async (i2) => { + if (this.isDevEnv) + return ""; + const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); + let r2; + try { + r2 = await this.fetchAttestation(i2.attestationId, s2); + } catch (o2) { + this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r2 = await this.fetchAttestation(i2.attestationId, te); } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png", - avail: "https://i.imgur.com/GxNn8BO.png" + return r2; + }, this.fetchAttestation = async (i2, s2) => { + this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); + const r2 = this.startAbortTimer(cjs$3.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); + return clearTimeout(r2), o2.status === 200 ? await o2.json() : void 0; + }, this.addToQueue = (i2) => { + this.queue.push(i2); + }, this.processQueue = () => { + this.queue.length !== 0 && (this.queue.forEach((i2) => this.sendPost(i2)), this.queue = []); + }, this.sendPost = (i2) => { + var s2; + try { + if (!this.iframe) + return; + (s2 = this.iframe.contentWindow) == null || s2.postMessage(i2, "*"), this.logger.info(`postMessage sent: ${i2} ${this.verifyUrl}`); + } catch { + } + }, this.createIframe = async () => { + let i2; + const s2 = (r2) => { + r2.data === "verify_ready" && (this.onInit(), window.removeEventListener("message", s2), i2()); + }; + await Promise.race([new Promise((r2) => { + const o2 = document.getElementById(ee$1); + if (o2) + return this.iframe = o2, this.onInit(), r2(); + window.addEventListener("message", s2); + const a2 = document.createElement("iframe"); + a2.id = ee$1, a2.src = `${this.verifyUrl}/${this.projectId}`, a2.style.display = "none", document.body.append(a2), this.iframe = a2, i2 = r2; + }), new Promise((r2, o2) => setTimeout(() => { + window.removeEventListener("message", s2), o2("verify iframe load timeout"); + }, cjs$3.toMiliseconds(cjs$3.FIVE_SECONDS)))]); + }, this.onInit = () => { + this.initialized = true, this.processQueue(); + }, this.removeIframe = () => { + this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); + }, this.getVerifyUrl = (i2) => { + let s2 = i2 || k$2; + return St$1.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${k$2}`), s2 = k$2), s2; + }, this.logger = E$2(t2, this.name), this.verifyUrl = k$2, this.abortController = new AbortController(), this.isDevEnv = pi() && process.env.IS_VITEST; } - }; - const web3modal_puzzle_props = isAndroid() ? web3modal_puzzle_props_android : web3modal_puzzle_props_default; - const signClient_puzzleProps = { - requiredNamespaces: { - aleo: { - methods: wc_aleo_methods, - chains: web3modal_puzzle_props.chains, - events: wc_events - } + get context() { + return y$3(this.logger); } - }; - const name = "@puzzlehq/sdk-core"; - const displayName = "Puzzle SDK"; - const version$1 = "0.3.1"; - const description = "Your portal to privacy"; - const main = "./dist/puzzle.cjs.js"; - const module2 = "./dist/puzzle.es.js"; - const browser$2 = "./dist/puzzle.umd.js"; - const types = "./dist/types/src/index.d.ts"; - const exports$1 = { - ".": { - "import": "./dist/puzzle.es.js", - require: "./dist/puzzle.cjs.js", - browser: "./dist/puzzle.umd.js", - types: "./dist/types/src/index.d.ts" + startAbortTimer(e2) { + return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$3.toMiliseconds(e2)); } }; - const type = "module"; - const scripts = { - "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", - "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, - build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", - "type-check": "tsc --noEmit" - }; - const repository = { - type: "git", - url: "git+https://github.com/puzzlehq/puzzle-sdk.git" - }; - const dependencies = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", - "@walletconnect/types": "^2.11.2", - "@walletconnect/utils": "^2.11.2", - debug: "^4.3.4", - events: "^3.3.0", - ws: "^8.16.0" - }; - const peerDependencies = { - buffer: "^6.0.3" - }; - const keywords = [ - "puzzle", - "cryptocurrency wallet", - "privacy", - "aleo", - "web3", - "crypto", - "typescript" - ]; - const author = "Puzzle"; - const license = "ISC"; - const bugs = { - url: "https://github.com/puzzlehq/puzzle-sdk/issues" + let Ht$3 = class Ht extends v$2 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.context = Pt$1, this.registerDeviceToken = async (i2) => { + const { clientId: s2, token: r2, notificationType: o2, enableEncrypted: a2 = false } = i2, h2 = `${xt}/${this.projectId}/clients`; + await Hi(h2, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r2, always_raw: a2 }) }); + }, this.logger = E$2(t2, this.context); + } }; - const homepage = "https://github.com/puzzlehq/puzzle-sdk#readme"; - const pkg = { - name, - displayName, - version: version$1, - description, - main, - module: module2, - browser: browser$2, - types, - "private": false, - exports: exports$1, - type, - scripts, - repository, - dependencies, - peerDependencies, - keywords, - author, - license, - bugs, - homepage + var $r = Object.defineProperty, Jt$3 = Object.getOwnPropertySymbols, Fr$1 = Object.prototype.hasOwnProperty, kr$1 = Object.prototype.propertyIsEnumerable, Xt$3 = (n2, e2, t2) => e2 in n2 ? $r(n2, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n2[e2] = t2, Wt$3 = (n2, e2) => { + for (var t2 in e2 || (e2 = {})) + Fr$1.call(e2, t2) && Xt$3(n2, t2, e2[t2]); + if (Jt$3) + for (var t2 of Jt$3(e2)) + kr$1.call(e2, t2) && Xt$3(n2, t2, e2[t2]); + return n2; }; - const emitter = new EventEmitter$1(); - exports2.connection = void 0; - async function configureConnection(options) { - let disconnectSessions = false; - const thisVersion = pkg.version; - const prevVersion = localStorage.getItem("puzzle_sdk_version"); - if (thisVersion !== prevVersion) { - console.log( - `${pkg.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" - ); - localStorage.setItem("puzzle_sdk_version", thisVersion); - disconnectSessions = true; - } - exports2.connection = new z$2({ - projectId: options.projectId ?? projectId, - metadata: { - name: options.dAppName, - description: options.dAppDescription, - url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", - icons: [options.dAppIconURL] - }, - modalOptions: { ...web3modal_puzzle_props } - }); - if (disconnectSessions) { - localStorage.removeItem("puzzle-hasInjectedConnection"); - try { - disconnectOnVersionChange(exports2.connection, options.onDisconnect); - } catch (e2) { - console.error(e2); - } + let ie$3 = class ie2 extends n$8 { + constructor(e2) { + var t2; + super(e2), this.protocol = De$1, this.version = Ze$2, this.name = Z$2, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (o2, a2) => this.events.on(o2, a2), this.once = (o2, a2) => this.events.once(o2, a2), this.off = (o2, a2) => this.events.off(o2, a2), this.removeListener = (o2, a2) => this.events.removeListener(o2, a2), this.projectId = e2 == null ? void 0 : e2.projectId, this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me$1, this.customStoragePrefix = e2 != null && e2.customStoragePrefix ? `:${e2.customStoragePrefix}` : ""; + const i2 = k$3({ level: typeof (e2 == null ? void 0 : e2.logger) == "string" && e2.logger ? e2.logger : et$1.logger }), { logger: s2, chunkLoggerController: r2 } = A$3({ opts: i2, maxSizeInBytes: e2 == null ? void 0 : e2.maxLogBlobSizeInBytes, loggerOverride: e2 == null ? void 0 : e2.logger }); + this.logChunkController = r2, (t2 = this.logChunkController) != null && t2.downloadLogsBlobInBrowser && (window.downloadLogsBlobInBrowser = async () => { + var o2, a2; + (o2 = this.logChunkController) != null && o2.downloadLogsBlobInBrowser && ((a2 = this.logChunkController) == null || a2.downloadLogsBlobInBrowser({ clientId: await this.crypto.getClientId() })); + }), this.logger = E$2(s2, this.name), this.heartbeat = new cjs$4.HeartBeat(), this.crypto = new At$1(this, this.logger, e2 == null ? void 0 : e2.keychain), this.history = new jt$2(this, this.logger), this.expirer = new Gt$1(this, this.logger), this.storage = e2 != null && e2.storage ? e2.storage : new h$5(Wt$3(Wt$3({}, tt$1), e2 == null ? void 0 : e2.storageOptions)), this.relayer = new kt$1({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new qt(this, this.logger), this.verify = new Yt$2(this.projectId || "", this.logger), this.echoClient = new Ht$3(this.projectId || "", this.logger); } - exports2.connection.onSessionDelete(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - exports2.connection.onSessionExpire(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + static async init(e2) { + const t2 = new ie2(e2); + await t2.initialize(); + const i2 = await t2.crypto.getClientId(); + return await t2.storage.setItem(bt$1, i2), t2; } - if (typeof window !== "undefined") { - window.puzzleSdkConnection = exports2.connection; + get context() { + return y$3(this.logger); } - return exports2.connection; - } - async function disconnectOnVersionChange(connection2, onDisconnect) { - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (session) { - console.log("Disconnecting session", session); - onDisconnect && onDisconnect(); - connection2.disconnect({ - topic: session.topic, - reason: U$3("USER_DISCONNECTED") - }); + async start() { + this.initialized || await this.initialize(); } - } - async function getWalletConnectModalSignClient() { - return new Promise((resolve) => { - if (exports2.connection) { - resolve(exports2.connection); - } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { - resolve(window.puzzleSdkConnection); - } else { - const interval = setInterval(() => { - if (exports2.connection) { - clearInterval(interval); - resolve(exports2.connection); + async getLogsBlob() { + var e2; + return (e2 = this.logChunkController) == null ? void 0 : e2.logsToBlob({ clientId: await this.crypto.getClientId() }); + } + 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.initialized = true, this.logger.info("Core Initialization Success"); + } catch (e2) { + throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`, e2), this.logger.error(e2.message), e2; + } + } + }; + const Br = ie$3; + const Se$1 = "wc", Ee$1 = 2, _e$1 = "client", se$2 = `${Se$1}@${Ee$1}:${_e$1}:`, ie$2 = { name: _e$1, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, Re$2 = "WALLETCONNECT_DEEPLINK_CHOICE", Ke$1 = "proposal", Ue$1 = "Proposal expired", Ge$1 = "session", L$4 = cjs$3.SEVEN_DAYS, ke$1 = "engine", q$1 = { wc_sessionPropose: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1114 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1115 } }, wc_sessionAuthenticate: { req: { ttl: cjs$3.ONE_HOUR, prompt: true, tag: 1116 }, res: { ttl: cjs$3.ONE_HOUR, prompt: false, tag: 1117 } } }, re$2 = { min: cjs$3.FIVE_MINUTES, max: cjs$3.SEVEN_DAYS }, A$2 = { idle: "IDLE", active: "ACTIVE" }, Fe$1 = "request", je$1 = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"], Qe$1 = "wc", ze$1 = "auth", He$1 = "authKeys", Ye$1 = "pairingTopics", Xe$1 = "requests", X$1 = `${Qe$1}@${1.5}:${ze$1}:`, J$1 = `${X$1}:PUB_KEY`; + var Ht$2 = Object.defineProperty, Yt$1 = Object.defineProperties, Xt$2 = Object.getOwnPropertyDescriptors, Je = Object.getOwnPropertySymbols, Jt$2 = Object.prototype.hasOwnProperty, Bt$1 = Object.prototype.propertyIsEnumerable, Be$2 = (S2, n2, t2) => n2 in S2 ? Ht$2(S2, n2, { enumerable: true, configurable: true, writable: true, value: t2 }) : S2[n2] = t2, m$1 = (S2, n2) => { + for (var t2 in n2 || (n2 = {})) + Jt$2.call(n2, t2) && Be$2(S2, t2, n2[t2]); + if (Je) + for (var t2 of Je(n2)) + Bt$1.call(n2, t2) && Be$2(S2, t2, n2[t2]); + return S2; + }, F = (S2, n2) => Yt$1(S2, Xt$2(n2)); + let Wt$2 = class Wt extends w$3 { + constructor(n2) { + super(n2), this.name = ke$1, this.events = new EventEmitter$1(), this.initialized = false, this.requestQueue = { state: A$2.idle, queue: [] }, this.sessionRequestQueue = { state: A$2.idle, queue: [] }, this.requestQueueDelay = cjs$3.ONE_SECOND, this.expectedPairingMethodMap = /* @__PURE__ */ new Map(), this.recentlyDeletedMap = /* @__PURE__ */ new Map(), this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(q$1) }), this.initialized = true, setTimeout(() => { + this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay))); + }, this.connect = async (t2) => { + await this.isInitialized(); + const e2 = F(m$1({}, t2), { requiredNamespaces: t2.requiredNamespaces || {}, optionalNamespaces: t2.optionalNamespaces || {} }); + await this.isValidConnect(e2); + const { pairingTopic: s2, requiredNamespaces: i2, optionalNamespaces: r2, sessionProperties: o2, relays: a2 } = e2; + let c2 = s2, d2, p2 = false; + try { + c2 && (p2 = this.client.core.pairing.pairings.get(c2).active); + } catch (f2) { + throw this.client.logger.error(`connect() -> pairing.get(${c2}) failed`), f2; + } + if (!c2 || !p2) { + const { topic: f2, uri: v2 } = await this.client.core.pairing.create(); + c2 = f2, d2 = v2; + } + if (!c2) { + const { message: f2 } = xe$1("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); + throw new Error(f2); + } + const g2 = await this.client.core.crypto.generateKeyPair(), h2 = q$1.wc_sessionPropose.req.ttl || cjs$3.FIVE_MINUTES, y2 = d0(h2), w2 = m$1({ requiredNamespaces: i2, optionalNamespaces: r2, relays: a2 ?? [{ protocol: lt$1 }], proposer: { publicKey: g2, metadata: this.client.metadata }, expiryTimestamp: y2 }, o2 && { sessionProperties: o2 }), { reject: I2, resolve: D2, done: E2 } = a0(h2, Ue$1); + this.events.once(v0("session_connect"), async ({ error: f2, session: v2 }) => { + if (f2) + I2(f2); + else if (v2) { + v2.self.publicKey = g2; + const j2 = F(m$1({}, v2), { requiredNamespaces: w2.requiredNamespaces, optionalNamespaces: w2.optionalNamespaces }); + await this.client.session.set(v2.topic, j2), await this.setExpiry(v2.topic, v2.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: v2.peer.metadata }), D2(j2); + } + }); + const P2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: w2, throwOnFailedPublish: true }); + return await this.setProposal(P2, m$1({ id: P2 }, w2)), { uri: d2, approval: E2 }; + }, this.pair = async (t2) => { + await this.isInitialized(); + try { + return await this.client.core.pairing.pair(t2); + } catch (e2) { + throw this.client.logger.error("pair() failed"), e2; + } + }, this.approve = async (t2) => { + await this.isInitialized(); + try { + await this.isValidApprove(t2); + } catch (E2) { + throw this.client.logger.error("approve() -> isValidApprove() failed"), E2; + } + const { id: e2, relayProtocol: s2, namespaces: i2, sessionProperties: r2, sessionConfig: o2 } = t2; + let a2; + try { + a2 = this.client.proposal.get(e2); + } catch (E2) { + throw this.client.logger.error(`approve() -> proposal.get(${e2}) failed`), E2; + } + let { pairingTopic: c2, proposer: d2, requiredNamespaces: p2, optionalNamespaces: g2 } = a2; + c2 = c2 || ""; + const h2 = await this.client.core.crypto.generateKeyPair(), y2 = d2.publicKey, w2 = await this.client.core.crypto.generateSharedKey(h2, y2), I2 = m$1(m$1({ relay: { protocol: s2 ?? "irn" }, namespaces: i2, pairingTopic: c2, controller: { publicKey: h2, metadata: this.client.metadata }, expiry: d0(L$4) }, r2 && { sessionProperties: r2 }), o2 && { sessionConfig: o2 }); + await this.client.core.relayer.subscribe(w2); + const D2 = F(m$1({}, I2), { topic: w2, requiredNamespaces: p2, optionalNamespaces: g2, pairingTopic: c2, acknowledged: false, self: I2.controller, peer: { publicKey: d2.publicKey, metadata: d2.metadata }, controller: h2 }); + await this.client.session.set(w2, D2); + try { + await this.sendResult({ id: e2, topic: c2, result: { relay: { protocol: s2 ?? "irn" }, responderPublicKey: h2 }, throwOnFailedPublish: true }), await this.sendRequest({ topic: w2, method: "wc_sessionSettle", params: I2, throwOnFailedPublish: true }); + } catch (E2) { + throw this.client.logger.error(E2), this.client.session.delete(w2, tr$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(w2), E2; + } + return await this.client.core.pairing.updateMetadata({ topic: c2, metadata: d2.metadata }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: c2 }), await this.setExpiry(w2, d0(L$4)), { topic: w2, acknowledged: () => new Promise((E2) => setTimeout(() => E2(this.client.session.get(w2)), 500)) }; + }, this.reject = async (t2) => { + await this.isInitialized(); + try { + await this.isValidReject(t2); + } catch (r2) { + throw this.client.logger.error("reject() -> isValidReject() failed"), r2; + } + const { id: e2, reason: s2 } = t2; + let i2; + try { + i2 = this.client.proposal.get(e2).pairingTopic; + } catch (r2) { + throw this.client.logger.error(`reject() -> proposal.get(${e2}) failed`), r2; + } + i2 && (await this.sendError({ id: e2, topic: i2, error: s2 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED"))); + }, this.update = async (t2) => { + await this.isInitialized(); + try { + await this.isValidUpdate(t2); + } catch (p2) { + throw this.client.logger.error("update() -> isValidUpdate() failed"), p2; + } + const { topic: e2, namespaces: s2 } = t2, { done: i2, resolve: r2, reject: o2 } = a0(), a2 = payloadId(), c2 = getBigIntRpcId().toString(), d2 = this.client.session.get(e2).namespaces; + return this.events.once(v0("session_update", a2), ({ error: p2 }) => { + p2 ? o2(p2) : r2(); + }), await this.client.session.update(e2, { namespaces: s2 }), this.sendRequest({ topic: e2, method: "wc_sessionUpdate", params: { namespaces: s2 }, throwOnFailedPublish: true, clientRpcId: a2, relayRpcId: c2 }).catch((p2) => { + this.client.logger.error(p2), this.client.session.update(e2, { namespaces: d2 }), o2(p2); + }), { acknowledged: i2 }; + }, this.extend = async (t2) => { + await this.isInitialized(); + try { + await this.isValidExtend(t2); + } catch (a2) { + throw this.client.logger.error("extend() -> isValidExtend() failed"), a2; + } + const { topic: e2 } = t2, s2 = payloadId(), { done: i2, resolve: r2, reject: o2 } = a0(); + return this.events.once(v0("session_extend", s2), ({ error: a2 }) => { + a2 ? o2(a2) : r2(); + }), await this.setExpiry(e2, d0(L$4)), this.sendRequest({ topic: e2, method: "wc_sessionExtend", params: {}, clientRpcId: s2, throwOnFailedPublish: true }).catch((a2) => { + o2(a2); + }), { acknowledged: i2 }; + }, this.request = async (t2) => { + await this.isInitialized(); + try { + await this.isValidRequest(t2); + } catch (h2) { + throw this.client.logger.error("request() -> isValidRequest() failed"), h2; + } + const { chainId: e2, request: s2, topic: i2, expiry: r2 = q$1.wc_sessionRequest.req.ttl } = t2, o2 = this.client.session.get(i2), a2 = payloadId(), c2 = getBigIntRpcId().toString(), { done: d2, resolve: p2, reject: g2 } = a0(r2, "Request expired. Please try again."); + return this.events.once(v0("session_request", a2), ({ error: h2, result: y2 }) => { + h2 ? g2(h2) : p2(y2); + }), await Promise.all([new Promise(async (h2) => { + await this.sendRequest({ clientRpcId: a2, relayRpcId: c2, topic: i2, method: "wc_sessionRequest", params: { request: F(m$1({}, s2), { expiryTimestamp: d0(r2) }), chainId: e2 }, expiry: r2, throwOnFailedPublish: true }).catch((y2) => g2(y2)), this.client.events.emit("session_request_sent", { topic: i2, request: s2, chainId: e2, id: a2 }), h2(); + }), new Promise(async (h2) => { + var y2; + if (!((y2 = o2.sessionConfig) != null && y2.disableDeepLink)) { + const w2 = await g0(this.client.core.storage, Re$2); + m0({ id: a2, topic: i2, wcDeepLink: w2 }); + } + h2(); + }), d2()]).then((h2) => h2[2]); + }, this.respond = async (t2) => { + await this.isInitialized(), await this.isValidRespond(t2); + const { topic: e2, response: s2 } = t2, { id: i2 } = s2; + isJsonRpcResult(s2) ? await this.sendResult({ id: i2, topic: e2, result: s2.result, throwOnFailedPublish: true }) : isJsonRpcError(s2) && await this.sendError({ id: i2, topic: e2, error: s2.error }), this.cleanupAfterResponse(t2); + }, this.ping = async (t2) => { + await this.isInitialized(); + try { + await this.isValidPing(t2); + } catch (s2) { + throw this.client.logger.error("ping() -> isValidPing() failed"), s2; + } + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) { + const s2 = payloadId(), i2 = getBigIntRpcId().toString(), { done: r2, resolve: o2, reject: a2 } = a0(); + this.events.once(v0("session_ping", s2), ({ error: c2 }) => { + c2 ? a2(c2) : o2(); + }), await Promise.all([this.sendRequest({ topic: e2, method: "wc_sessionPing", params: {}, throwOnFailedPublish: true, clientRpcId: s2, relayRpcId: i2 }), r2()]); + } else + this.client.core.pairing.pairings.keys.includes(e2) && await this.client.core.pairing.ping({ topic: e2 }); + }, this.emit = async (t2) => { + await this.isInitialized(), await this.isValidEmit(t2); + const { topic: e2, event: s2, chainId: i2 } = t2, r2 = getBigIntRpcId().toString(); + await this.sendRequest({ topic: e2, method: "wc_sessionEvent", params: { event: s2, chainId: i2 }, throwOnFailedPublish: true, relayRpcId: r2 }); + }, this.disconnect = async (t2) => { + await this.isInitialized(), await this.isValidDisconnect(t2); + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) + await this.sendRequest({ topic: e2, method: "wc_sessionDelete", params: tr$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: e2, emitEvent: false }); + else if (this.client.core.pairing.pairings.keys.includes(e2)) + await this.client.core.pairing.disconnect({ topic: e2 }); + else { + const { message: s2 } = xe$1("MISMATCHED_TOPIC", `Session or pairing topic not found: ${e2}`); + throw new Error(s2); + } + }, this.find = (t2) => (this.isInitialized(), this.client.session.getAll().filter((e2) => Qu(e2, t2))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (t2) => { + this.isInitialized(), this.isValidAuthenticate(t2); + const { chains: e2, statement: s2 = "", uri: i2, domain: r2, nonce: o2, type: a2, exp: c2, nbf: d2, methods: p2 = [] } = t2, g2 = [...t2.resources || []], { topic: h2, uri: y2 } = await this.client.core.pairing.create({ methods: ["wc_sessionAuthenticate"] }); + this.client.logger.info({ message: "Generated new pairing", pairing: { topic: h2, uri: y2 } }); + const w2 = await this.client.core.crypto.generateKeyPair(), I2 = bu(w2); + if (await Promise.all([this.client.auth.authKeys.set(J$1, { responseTopic: I2, publicKey: w2 }), this.client.auth.pairingTopics.set(I2, { topic: I2, pairingTopic: h2 })]), await this.client.core.relayer.subscribe(I2), this.client.logger.info(`sending request to new pairing topic: ${h2}`), p2.length > 0) { + const { namespace: O2 } = dn(e2[0]); + let _2 = cu(O2, "request", p2); + Qr(g2) && (_2 = lu(_2, g2.pop())), g2.push(_2); + } + const D2 = d0(q$1.wc_sessionPropose.req.ttl), E2 = { authPayload: { type: a2 ?? "caip122", chains: e2, statement: s2, aud: i2, domain: r2, version: "1", nonce: o2, iat: (/* @__PURE__ */ new Date()).toISOString(), exp: c2, nbf: d2, resources: g2 }, requester: { publicKey: w2, metadata: this.client.metadata }, expiryTimestamp: D2 }, P2 = { eip155: { chains: e2, methods: [.../* @__PURE__ */ new Set(["personal_sign", ...p2])], events: ["chainChanged", "accountsChanged"] } }, f2 = { requiredNamespaces: {}, optionalNamespaces: P2, relays: [{ protocol: "irn" }], proposer: { publicKey: w2, metadata: this.client.metadata }, expiryTimestamp: D2 }, { done: v2, resolve: j2, reject: oe2 } = a0(q$1.wc_sessionAuthenticate.req.ttl, "Request expired"), B2 = async ({ error: O2, session: _2 }) => { + if (this.events.off(v0("session_request", M2), ae2), O2) + oe2(O2); + else if (_2) { + _2.self.publicKey = w2, await this.client.session.set(_2.topic, _2), await this.setExpiry(_2.topic, _2.expiry), h2 && await this.client.core.pairing.updateMetadata({ topic: h2, metadata: _2.peer.metadata }); + const Q2 = this.client.session.get(_2.topic); + j2({ session: Q2 }); + } + }, ae2 = async (O2) => { + if (O2.error) { + const z2 = tr$2("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate"); + return O2.error.code === z2.code ? void 0 : (this.events.off(v0("session_connect"), B2), oe2(O2.error.message)); + } + this.events.off(v0("session_connect"), B2); + const { cacaos: _2, responder: Q2 } = O2.result, le2 = [], Ie2 = []; + for (const z2 of _2) { + await ou({ cacao: z2, projectId: this.client.core.projectId }) || (this.client.logger.error(z2, "Signature verification failed"), oe2(tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"))); + const { p: he2 } = z2, pe2 = Qr(he2.resources), fe2 = [fu(he2.iss)], Ze2 = Li(he2.iss); + if (pe2) { + const de2 = du(pe2), et2 = pu(pe2); + le2.push(...de2), fe2.push(...et2); + } + for (const de2 of fe2) + Ie2.push(`${de2}:${Ze2}`); + } + const W2 = await this.client.core.crypto.generateSharedKey(w2, Q2.publicKey); + let Z2; + le2.length > 0 && (Z2 = { topic: W2, acknowledged: true, self: { publicKey: w2, metadata: this.client.metadata }, peer: Q2, controller: Q2.publicKey, expiry: d0(L$4), requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: h2, namespaces: ju([...new Set(le2)], [...new Set(Ie2)]) }, await this.client.core.relayer.subscribe(W2), await this.client.session.set(W2, Z2), Z2 = this.client.session.get(W2)), j2({ auths: _2, session: Z2 }); + }, M2 = payloadId(), ce2 = payloadId(); + this.events.once(v0("session_connect"), B2), this.events.once(v0("session_request", M2), ae2); + try { + await Promise.all([this.sendRequest({ topic: h2, method: "wc_sessionAuthenticate", params: E2, expiry: t2.expiry, throwOnFailedPublish: true, clientRpcId: M2 }), this.sendRequest({ topic: h2, method: "wc_sessionPropose", params: f2, expiry: q$1.wc_sessionPropose.req.ttl, throwOnFailedPublish: true, clientRpcId: ce2 })]); + } catch (O2) { + throw this.events.off(v0("session_connect"), B2), this.events.off(v0("session_request", M2), ae2), O2; + } + return await this.setProposal(ce2, m$1({ id: ce2 }, f2)), await this.client.auth.requests.set(M2, { authPayload: E2.authPayload, requester: E2.requester, expiryTimestamp: D2, id: M2, pairingTopic: h2, verifyContext: {} }), { uri: y2, response: v2 }; + }, this.approveSessionAuthenticate = async (t2) => { + this.isInitialized(); + const { id: e2, auths: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r2 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a2 = bu(r2), c2 = { type: lr$1, receiverPublicKey: r2, senderPublicKey: o2 }, d2 = [], p2 = []; + for (const y2 of s2) { + if (!await ou({ cacao: y2, projectId: this.client.core.projectId })) { + const P2 = tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"); + throw await this.sendError({ id: e2, topic: a2, error: P2, encodeOpts: c2 }), new Error(P2.message); + } + const { p: w2 } = y2, I2 = Qr(w2.resources), D2 = [fu(w2.iss)], E2 = Li(w2.iss); + if (I2) { + const P2 = du(I2), f2 = pu(I2); + d2.push(...P2), D2.push(...f2); + } + for (const P2 of D2) + p2.push(`${P2}:${E2}`); + } + const g2 = await this.client.core.crypto.generateSharedKey(o2, r2); + let h2; + return (d2 == null ? void 0 : d2.length) > 0 && (h2 = { topic: g2, acknowledged: true, self: { publicKey: o2, metadata: this.client.metadata }, peer: { publicKey: r2, metadata: i2.requester.metadata }, controller: r2, expiry: d0(L$4), authentication: s2, requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: "", namespaces: ju([...new Set(d2)], [...new Set(p2)]) }, await this.client.core.relayer.subscribe(g2), await this.client.session.set(g2, h2)), await this.sendResult({ topic: a2, id: e2, result: { cacaos: s2, responder: { publicKey: o2, metadata: this.client.metadata } }, encodeOpts: c2, throwOnFailedPublish: true }), await this.client.auth.requests.delete(e2, { message: "fullfilled", code: 0 }), await this.client.core.pairing.activate({ topic: i2.pairingTopic }), { session: h2 }; + }, this.rejectSessionAuthenticate = async (t2) => { + await this.isInitialized(); + const { id: e2, reason: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r2 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a2 = bu(r2), c2 = { type: lr$1, receiverPublicKey: r2, senderPublicKey: o2 }; + await this.sendError({ id: e2, topic: a2, error: s2, encodeOpts: c2 }), await this.client.auth.requests.delete(e2, { message: "rejected", code: 0 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")); + }, this.formatAuthMessage = (t2) => { + this.isInitialized(); + const { request: e2, iss: s2 } = t2; + return zf(e2, s2); + }, this.cleanupDuplicatePairings = async (t2) => { + if (t2.pairingTopic) + try { + const e2 = this.client.core.pairing.pairings.get(t2.pairingTopic), s2 = this.client.core.pairing.pairings.getAll().filter((i2) => { + var r2, o2; + return ((r2 = i2.peerMetadata) == null ? void 0 : r2.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === t2.peer.metadata.url && i2.topic && i2.topic !== e2.topic; + }); + if (s2.length === 0) + return; + this.client.logger.info(`Cleaning up ${s2.length} duplicate pairing(s)`), await Promise.all(s2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.deleteSession = async (t2) => { + const { topic: e2, expirerHasDeleted: s2 = false, emitEvent: i2 = true, id: r2 = 0 } = t2, { self: o2 } = this.client.session.get(e2); + await this.client.core.relayer.unsubscribe(e2), await this.client.session.delete(e2, tr$2("USER_DISCONNECTED")), this.addToRecentlyDeleted(e2, "session"), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(e2) && await this.client.core.crypto.deleteSymKey(e2), s2 || this.client.core.expirer.del(e2), this.client.core.storage.removeItem(Re$2).catch((a2) => this.client.logger.warn(a2)), this.getPendingSessionRequests().forEach((a2) => { + a2.topic === e2 && this.deletePendingSessionRequest(a2.id, tr$2("USER_DISCONNECTED")); + }), i2 && this.client.events.emit("session_delete", { id: r2, topic: e2 }); + }, this.deleteProposal = async (t2, e2) => { + await Promise.all([this.client.proposal.delete(t2, tr$2("USER_DISCONNECTED")), e2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "proposal"); + }, this.deletePendingSessionRequest = async (t2, e2, s2 = false) => { + await Promise.all([this.client.pendingRequest.delete(t2, e2), s2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== t2), s2 && (this.sessionRequestQueue.state = A$2.idle, this.client.events.emit("session_request_expire", { id: t2 })); + }, this.setExpiry = async (t2, e2) => { + this.client.session.keys.includes(t2) && await this.client.session.update(t2, { expiry: e2 }), this.client.core.expirer.set(t2, e2); + }, this.setProposal = async (t2, e2) => { + await this.client.proposal.set(t2, e2), this.client.core.expirer.set(t2, d0(q$1.wc_sessionPropose.req.ttl)); + }, this.setPendingSessionRequest = async (t2) => { + const { id: e2, topic: s2, params: i2, verifyContext: r2 } = t2, o2 = i2.request.expiryTimestamp || d0(q$1.wc_sessionRequest.req.ttl); + await this.client.pendingRequest.set(e2, { id: e2, topic: s2, params: i2, verifyContext: r2 }), o2 && this.client.core.expirer.set(e2, o2); + }, this.sendRequest = async (t2) => { + const { topic: e2, method: s2, params: i2, expiry: r2, relayRpcId: o2, clientRpcId: a2, throwOnFailedPublish: c2 } = t2, d2 = formatJsonRpcRequest(s2, i2, a2); + if (pr$1() && je$1.includes(s2)) { + const h2 = yu(JSON.stringify(d2)); + this.client.core.verify.register({ attestationId: h2 }); + } + let p2; + try { + p2 = await this.client.core.crypto.encode(e2, d2); + } catch (h2) { + throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e2} failed`), h2; + } + const g2 = q$1[s2].req; + return r2 && (g2.ttl = r2), o2 && (g2.id = o2), this.client.core.history.set(e2, d2), c2 ? (g2.internal = F(m$1({}, g2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(e2, p2, g2)) : this.client.core.relayer.publish(e2, p2, g2).catch((h2) => this.client.logger.error(h2)), d2.id; + }, this.sendResult = async (t2) => { + const { id: e2, topic: s2, result: i2, throwOnFailedPublish: r2, encodeOpts: o2 } = t2, a2 = formatJsonRpcResult(e2, i2); + let c2; + try { + c2 = await this.client.core.crypto.encode(s2, a2, o2); + } catch (g2) { + throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s2} failed`), g2; + } + let d2; + try { + d2 = await this.client.core.history.get(s2, e2); + } catch (g2) { + throw this.client.logger.error(`sendResult() -> history.get(${s2}, ${e2}) failed`), g2; + } + const p2 = q$1[d2.request.method].res; + r2 ? (p2.internal = F(m$1({}, p2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, c2, p2)) : this.client.core.relayer.publish(s2, c2, p2).catch((g2) => this.client.logger.error(g2)), await this.client.core.history.resolve(a2); + }, this.sendError = async (t2) => { + const { id: e2, topic: s2, error: i2, encodeOpts: r2 } = t2, o2 = formatJsonRpcError(e2, i2); + let a2; + try { + a2 = await this.client.core.crypto.encode(s2, o2, r2); + } catch (p2) { + throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s2} failed`), p2; + } + let c2; + try { + c2 = await this.client.core.history.get(s2, e2); + } catch (p2) { + throw this.client.logger.error(`sendError() -> history.get(${s2}, ${e2}) failed`), p2; + } + const d2 = q$1[c2.request.method].res; + this.client.core.relayer.publish(s2, a2, d2), await this.client.core.history.resolve(o2); + }, this.cleanup = async () => { + const t2 = [], e2 = []; + this.client.session.getAll().forEach((s2) => { + let i2 = false; + p0(s2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(s2.topic) || (i2 = true), i2 && t2.push(s2.topic); + }), this.client.proposal.getAll().forEach((s2) => { + p0(s2.expiryTimestamp) && e2.push(s2.id); + }), await Promise.all([...t2.map((s2) => this.deleteSession({ topic: s2 })), ...e2.map((s2) => this.deleteProposal(s2))]); + }, this.onRelayEventRequest = async (t2) => { + this.requestQueue.queue.push(t2), await this.processRequestsQueue(); + }, this.processRequestsQueue = async () => { + if (this.requestQueue.state === A$2.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 = A$2.active; + const t2 = this.requestQueue.queue.shift(); + if (t2) + try { + this.processRequest(t2), await new Promise((e2) => setTimeout(e2, 300)); + } catch (e2) { + this.client.logger.warn(e2); + } + } + this.requestQueue.state = A$2.idle; + }, this.processRequest = (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = s2.method; + if (!this.shouldIgnorePairingRequest({ topic: e2, requestMethod: i2 })) + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeRequest(e2, s2); + case "wc_sessionSettle": + return this.onSessionSettleRequest(e2, s2); + case "wc_sessionUpdate": + return this.onSessionUpdateRequest(e2, s2); + case "wc_sessionExtend": + return this.onSessionExtendRequest(e2, s2); + case "wc_sessionPing": + return this.onSessionPingRequest(e2, s2); + case "wc_sessionDelete": + return this.onSessionDeleteRequest(e2, s2); + case "wc_sessionRequest": + return this.onSessionRequest(e2, s2); + case "wc_sessionEvent": + return this.onSessionEventRequest(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateRequest(e2, s2); + default: + return this.client.logger.info(`Unsupported request method ${i2}`); + } + }, this.onRelayEventResponse = async (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = (await this.client.core.history.get(e2, s2.id)).request.method; + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeResponse(e2, s2); + case "wc_sessionSettle": + return this.onSessionSettleResponse(e2, s2); + case "wc_sessionUpdate": + return this.onSessionUpdateResponse(e2, s2); + case "wc_sessionExtend": + return this.onSessionExtendResponse(e2, s2); + case "wc_sessionPing": + return this.onSessionPingResponse(e2, s2); + case "wc_sessionRequest": + return this.onSessionRequestResponse(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateResponse(e2, s2); + default: + return this.client.logger.info(`Unsupported response method ${i2}`); + } + }, this.onRelayEventUnknownPayload = (t2) => { + const { topic: e2 } = t2, { message: s2 } = xe$1("MISSING_OR_INVALID", `Decoded payload on topic ${e2} is not identifiable as a JSON-RPC request or a response.`); + throw new Error(s2); + }, this.shouldIgnorePairingRequest = (t2) => { + const { topic: e2, requestMethod: s2 } = t2, i2 = this.expectedPairingMethodMap.get(e2); + return !i2 || i2.includes(s2) ? false : !!(i2.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0); + }, this.onSessionProposeRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; + try { + this.isValidConnect(m$1({}, e2.params)); + const r2 = s2.expiryTimestamp || d0(q$1.wc_sessionPropose.req.ttl), o2 = m$1({ id: i2, pairingTopic: t2, expiryTimestamp: r2 }, s2); + await this.setProposal(i2, o2); + const a2 = yu(JSON.stringify(e2)), c2 = await this.getVerifyContext(a2, o2.proposer.metadata); + this.client.events.emit("session_proposal", { id: i2, params: o2, verifyContext: c2 }); + } catch (r2) { + await this.sendError({ id: i2, topic: t2, error: r2 }), this.client.logger.error(r2); + } + }, this.onSessionProposeResponse = async (t2, e2) => { + const { id: s2 } = e2; + if (isJsonRpcResult(e2)) { + const { result: i2 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); + const r2 = this.client.proposal.get(s2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: r2 }); + const o2 = r2.proposer.publicKey; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o2 }); + const a2 = i2.responderPublicKey; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a2 }); + const c2 = await this.client.core.crypto.generateSharedKey(o2, a2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); + const d2 = await this.client.core.relayer.subscribe(c2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: d2 }), await this.client.core.pairing.activate({ topic: t2 }); + } else if (isJsonRpcError(e2)) { + await this.client.proposal.delete(s2, tr$2("USER_DISCONNECTED")); + const i2 = v0("session_connect"); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners, 954`); + this.events.emit(v0("session_connect"), { error: e2.error }); + } + }, this.onSessionSettleRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + this.isValidSessionSettleRequest(i2); + const { relay: r2, controller: o2, expiry: a2, namespaces: c2, sessionProperties: d2, pairingTopic: p2, sessionConfig: g2 } = e2.params, h2 = m$1(m$1({ topic: t2, relay: r2, expiry: a2, namespaces: c2, acknowledged: true, pairingTopic: p2, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, d2 && { sessionProperties: d2 }), g2 && { sessionConfig: g2 }); + await this.sendResult({ id: e2.id, topic: t2, result: true, throwOnFailedPublish: true }); + const y2 = v0("session_connect"); + if (this.events.listenerCount(y2) === 0) + throw new Error(`emitting ${y2} without any listeners 997`); + this.events.emit(v0("session_connect"), { session: h2 }), this.cleanupDuplicatePairings(h2); + } catch (r2) { + await this.sendError({ id: s2, topic: t2, error: r2 }), this.client.logger.error(r2); + } + }, this.onSessionSettleResponse = async (t2, e2) => { + const { id: s2 } = e2; + isJsonRpcResult(e2) ? (await this.client.session.update(t2, { acknowledged: true }), this.events.emit(v0("session_approve", s2), {})) : isJsonRpcError(e2) && (await this.client.session.delete(t2, tr$2("USER_DISCONNECTED")), this.events.emit(v0("session_approve", s2), { error: e2.error })); + }, this.onSessionUpdateRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; + try { + const r2 = `${t2}_session_update`, o2 = lh.get(r2); + if (o2 && this.isRequestOutOfSync(o2, i2)) { + this.client.logger.info(`Discarding out of sync request - ${i2}`), this.sendError({ id: i2, topic: t2, error: tr$2("INVALID_UPDATE_REQUEST") }); + return; + } + this.isValidUpdate(m$1({ topic: t2 }, s2)); + try { + lh.set(r2, i2), await this.client.session.update(t2, { namespaces: s2.namespaces }), await this.sendResult({ id: i2, topic: t2, result: true, throwOnFailedPublish: true }); + } catch (a2) { + throw lh.delete(r2), a2; + } + this.client.events.emit("session_update", { id: i2, topic: t2, params: s2 }); + } catch (r2) { + await this.sendError({ id: i2, topic: t2, error: r2 }), this.client.logger.error(r2); + } + }, this.isRequestOutOfSync = (t2, e2) => parseInt(e2.toString().slice(0, -3)) <= parseInt(t2.toString().slice(0, -3)), this.onSessionUpdateResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_update", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_update", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_update", s2), { error: e2.error }); + }, this.onSessionExtendRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidExtend({ topic: t2 }), await this.setExpiry(t2, d0(L$4)), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_extend", { id: s2, topic: t2 }); + } catch (i2) { + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionExtendResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_extend", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_extend", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_extend", s2), { error: e2.error }); + }, this.onSessionPingRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidPing({ topic: t2 }), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_ping", { id: s2, topic: t2 }); + } catch (i2) { + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionPingResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_ping", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + setTimeout(() => { + isJsonRpcResult(e2) ? this.events.emit(v0("session_ping", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_ping", s2), { error: e2.error }); + }, 500); + }, this.onSessionDeleteRequest = async (t2, e2) => { + const { id: s2 } = e2; + try { + this.isValidDisconnect({ topic: t2, reason: e2.params }), await Promise.all([new Promise((i2) => { + this.client.core.relayer.once(v$1.publish, async () => { + i2(await this.deleteSession({ topic: t2, id: s2 })); + }); + }), this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.cleanupPendingSentRequestsForTopic({ topic: t2, error: tr$2("USER_DISCONNECTED") })]); + } catch (i2) { + this.client.logger.error(i2); + } + }, this.onSessionRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + await this.isValidRequest(m$1({ topic: t2 }, i2)); + const r2 = yu(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, s2))), o2 = this.client.session.get(t2), a2 = await this.getVerifyContext(r2, o2.peer.metadata), c2 = { id: s2, topic: t2, params: i2, verifyContext: a2 }; + await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); + } catch (r2) { + await this.sendError({ id: s2, topic: t2, error: r2 }), this.client.logger.error(r2); + } + }, this.onSessionRequestResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_request", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionEventRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; + try { + const r2 = `${t2}_session_event_${i2.event.name}`, o2 = lh.get(r2); + if (o2 && this.isRequestOutOfSync(o2, s2)) { + this.client.logger.info(`Discarding out of sync request - ${s2}`); + return; + } + this.isValidEmit(m$1({ topic: t2 }, i2)), this.client.events.emit("session_event", { id: s2, topic: t2, params: i2 }), lh.set(r2, s2); + } catch (r2) { + await this.sendError({ id: s2, topic: t2, error: r2 }), this.client.logger.error(r2); + } + }, this.onSessionAuthenticateResponse = (t2, e2) => { + const { id: s2 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionAuthenticateResponse", topic: t2, payload: e2 }), isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionAuthenticateRequest = async (t2, e2) => { + const { requester: s2, authPayload: i2, expiryTimestamp: r2 } = e2.params, o2 = yu(JSON.stringify(e2)), a2 = await this.getVerifyContext(o2, this.client.metadata), c2 = { requester: s2, pairingTopic: t2, id: e2.id, authPayload: i2, verifyContext: a2, expiryTimestamp: r2 }; + await this.client.auth.requests.set(e2.id, c2), this.client.events.emit("session_authenticate", { topic: t2, params: e2.params, id: e2.id }); + }, this.addSessionRequestToSessionRequestQueue = (t2) => { + this.sessionRequestQueue.queue.push(t2); + }, this.cleanupAfterResponse = (t2) => { + this.deletePendingSessionRequest(t2.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { + this.sessionRequestQueue.state = A$2.idle, this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay)); + }, this.cleanupPendingSentRequestsForTopic = ({ topic: t2, error: e2 }) => { + const s2 = this.client.core.history.pending; + s2.length > 0 && s2.filter((i2) => i2.topic === t2 && i2.request.method === "wc_sessionRequest").forEach((i2) => { + const r2 = i2.request.id, o2 = v0("session_request", r2); + if (this.events.listenerCount(o2) === 0) + throw new Error(`emitting ${o2} without any listeners`); + this.events.emit(v0("session_request", i2.request.id), { error: e2 }); + }); + }, this.processSessionRequestQueue = () => { + if (this.sessionRequestQueue.state === A$2.active) { + this.client.logger.info("session request queue is already active."); + return; + } + const t2 = this.sessionRequestQueue.queue[0]; + if (!t2) { + this.client.logger.info("session request queue is empty."); + return; + } + try { + this.sessionRequestQueue.state = A$2.active, this.client.events.emit("session_request", t2); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.onPairingCreated = (t2) => { + if (t2.methods && this.expectedPairingMethodMap.set(t2.topic, t2.methods), t2.active) + return; + const e2 = this.client.proposal.getAll().find((s2) => s2.pairingTopic === t2.topic); + e2 && this.onSessionProposeRequest(t2.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: e2.requiredNamespaces, optionalNamespaces: e2.optionalNamespaces, relays: e2.relays, proposer: e2.proposer, sessionProperties: e2.sessionProperties }, e2.id)); + }, this.isValidConnect = async (t2) => { + if (!$u(t2)) { + const { message: a2 } = xe$1("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(t2)}`); + throw new Error(a2); + } + const { pairingTopic: e2, requiredNamespaces: s2, optionalNamespaces: i2, sessionProperties: r2, relays: o2 } = t2; + if (Pe$1(e2) || await this.isValidPairingTopic(e2), !Xu(o2)) { + const { message: a2 } = xe$1("MISSING_OR_INVALID", `connect() relays: ${o2}`); + throw new Error(a2); + } + !Pe$1(s2) && Yr(s2) !== 0 && this.validateNamespaces(s2, "requiredNamespaces"), !Pe$1(i2) && Yr(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), Pe$1(r2) || this.validateSessionProps(r2, "sessionProperties"); + }, this.validateNamespaces = (t2, e2) => { + const s2 = Wu(t2, "connect()", e2); + if (s2) + throw new Error(s2.message); + }, this.isValidApprove = async (t2) => { + if (!$u(t2)) + throw new Error(xe$1("MISSING_OR_INVALID", `approve() params: ${t2}`).message); + const { id: e2, namespaces: s2, relayProtocol: i2, sessionProperties: r2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2); + const o2 = this.client.proposal.get(e2), a2 = So(s2, "approve()"); + if (a2) + throw new Error(a2.message); + const c2 = Io(o2.requiredNamespaces, s2, "approve()"); + if (c2) + throw new Error(c2.message); + if (!Gt$2(i2, true)) { + const { message: d2 } = xe$1("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); + throw new Error(d2); + } + Pe$1(r2) || this.validateSessionProps(r2, "sessionProperties"); + }, this.isValidReject = async (t2) => { + if (!$u(t2)) { + const { message: i2 } = xe$1("MISSING_OR_INVALID", `reject() params: ${t2}`); + throw new Error(i2); + } + const { id: e2, reason: s2 } = t2; + if (this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2), !th(s2)) { + const { message: i2 } = xe$1("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(s2)}`); + throw new Error(i2); + } + }, this.isValidSessionSettleRequest = (t2) => { + if (!$u(t2)) { + const { message: c2 } = xe$1("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${t2}`); + throw new Error(c2); + } + const { relay: e2, controller: s2, namespaces: i2, expiry: r2 } = t2; + if (!No$1(e2)) { + const { message: c2 } = xe$1("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); + throw new Error(c2); + } + const o2 = Vu(s2, "onSessionSettleRequest()"); + if (o2) + throw new Error(o2.message); + const a2 = So(i2, "onSessionSettleRequest()"); + if (a2) + throw new Error(a2.message); + if (p0(r2)) { + const { message: c2 } = xe$1("EXPIRED", "onSessionSettleRequest()"); + throw new Error(c2); + } + }, this.isValidUpdate = async (t2) => { + if (!$u(t2)) { + const { message: a2 } = xe$1("MISSING_OR_INVALID", `update() params: ${t2}`); + throw new Error(a2); + } + const { topic: e2, namespaces: s2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const i2 = this.client.session.get(e2), r2 = So(s2, "update()"); + if (r2) + throw new Error(r2.message); + const o2 = Io(i2.requiredNamespaces, s2, "update()"); + if (o2) + throw new Error(o2.message); + }, this.isValidExtend = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe$1("MISSING_OR_INVALID", `extend() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + }, this.isValidRequest = async (t2) => { + if (!$u(t2)) { + const { message: a2 } = xe$1("MISSING_OR_INVALID", `request() params: ${t2}`); + throw new Error(a2); + } + const { topic: e2, request: s2, chainId: i2, expiry: r2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const { namespaces: o2 } = this.client.session.get(e2); + if (!nh(o2, i2)) { + const { message: a2 } = xe$1("MISSING_OR_INVALID", `request() chainId: ${i2}`); + throw new Error(a2); + } + if (!eh(s2)) { + const { message: a2 } = xe$1("MISSING_OR_INVALID", `request() ${JSON.stringify(s2)}`); + throw new Error(a2); + } + if (!fh(o2, i2, s2.method)) { + const { message: a2 } = xe$1("MISSING_OR_INVALID", `request() method: ${s2.method}`); + throw new Error(a2); + } + if (r2 && !uh(r2, re$2)) { + const { message: a2 } = xe$1("MISSING_OR_INVALID", `request() expiry: ${r2}. Expiry must be a number (in seconds) between ${re$2.min} and ${re$2.max}`); + throw new Error(a2); + } + }, this.isValidRespond = async (t2) => { + var e2; + if (!$u(t2)) { + const { message: r2 } = xe$1("MISSING_OR_INVALID", `respond() params: ${t2}`); + throw new Error(r2); + } + const { topic: s2, response: i2 } = t2; + try { + await this.isValidSessionTopic(s2); + } catch (r2) { + throw (e2 = t2 == null ? void 0 : t2.response) != null && e2.id && this.cleanupAfterResponse(t2), r2; + } + if (!rh(i2)) { + const { message: r2 } = xe$1("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); + throw new Error(r2); + } + }, this.isValidPing = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe$1("MISSING_OR_INVALID", `ping() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidEmit = async (t2) => { + if (!$u(t2)) { + const { message: o2 } = xe$1("MISSING_OR_INVALID", `emit() params: ${t2}`); + throw new Error(o2); + } + const { topic: e2, event: s2, chainId: i2 } = t2; + await this.isValidSessionTopic(e2); + const { namespaces: r2 } = this.client.session.get(e2); + if (!nh(r2, i2)) { + const { message: o2 } = xe$1("MISSING_OR_INVALID", `emit() chainId: ${i2}`); + throw new Error(o2); + } + if (!ih(s2)) { + const { message: o2 } = xe$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); + throw new Error(o2); + } + if (!oh(r2, i2, s2.name)) { + const { message: o2 } = xe$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); + throw new Error(o2); + } + }, this.isValidDisconnect = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe$1("MISSING_OR_INVALID", `disconnect() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidAuthenticate = (t2) => { + const { chains: e2, uri: s2, domain: i2, nonce: r2 } = t2; + if (!Array.isArray(e2) || e2.length === 0) + throw new Error("chains is required and must be a non-empty array"); + if (!Gt$2(s2, false)) + throw new Error("uri is required parameter"); + if (!Gt$2(i2, false)) + throw new Error("domain is required parameter"); + if (!Gt$2(r2, false)) + throw new Error("nonce is required parameter"); + if ([...new Set(e2.map((a2) => dn(a2).namespace))].length > 1) + throw new Error("Multi-namespace requests are not supported. Please request single namespace only."); + const { namespace: o2 } = dn(e2[0]); + if (o2 !== "eip155") + throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains."); + }, this.getVerifyContext = async (t2, e2) => { + const s2 = { verified: { verifyUrl: e2.verifyUrl || k$2, validation: "UNKNOWN", origin: e2.url || "" } }; + try { + const i2 = await this.client.core.verify.resolve({ attestationId: t2, verifyUrl: e2.verifyUrl }); + i2 && (s2.verified.origin = i2.origin, s2.verified.isScam = i2.isScam, s2.verified.validation = i2.origin === new URL(e2.url).origin ? "VALID" : "INVALID"); + } catch (i2) { + this.client.logger.info(i2); + } + return this.client.logger.info(`Verify context: ${JSON.stringify(s2)}`), s2; + }, this.validateSessionProps = (t2, e2) => { + Object.values(t2).forEach((s2) => { + if (!Gt$2(s2, false)) { + const { message: i2 } = xe$1("MISSING_OR_INVALID", `${e2} must be in Record format. Received: ${JSON.stringify(s2)}`); + throw new Error(i2); + } + }); + }, this.getPendingAuthRequest = (t2) => { + const e2 = this.client.auth.requests.get(t2); + return typeof e2 == "object" ? e2 : void 0; + }, this.addToRecentlyDeleted = (t2, e2) => { + if (this.recentlyDeletedMap.set(t2, e2), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) { + let s2 = 0; + const i2 = this.recentlyDeletedLimit / 2; + for (const r2 of this.recentlyDeletedMap.keys()) { + if (s2++ >= i2) + break; + this.recentlyDeletedMap.delete(r2); } - }, 200); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - }); - } - const checkForDesktopConnection = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - try { - const res = await window.aleo.puzzleWalletClient.isConnected.query( - { sessionTopic } - ); - if (res) { - localStorage.setItem("puzzle-hasInjectedConnection", "true"); - return true; - } else { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - } catch (e2) { - console.warn(e2); - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - }; - const hasInjectedConnection = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - return false; - } - const puzzleHasDesktopConnection = localStorage.getItem( - "puzzle-hasInjectedConnection" - ); - return puzzleHasDesktopConnection === "true"; - }; - const getAccount = async () => { - const connection = await getWalletConnectModalSignClient(); - const session = await connection.getSession(); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getSelectedAccount" - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getSelectedAccount.query(query); - return response; - } catch (e2) { - console.error("getAccount error", e2); - return { error: e2.message }; - } - } - try { - const response = await connection.request(query); - return response; - } catch (e2) { - console.error("getAccount error", e2); - const error = e2.message; - return { error }; - } - }; - const getBalance = async ({ - address - }) => { - const connection = await getWalletConnectModalSignClient(); - const session = await connection.getSession(); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getBalance", - params: { - assetId: void 0, - address } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getBalance.query(query); - return response; - } catch (e2) { - const error = e2.message; - console.error("getBalance error", e2); - return { error }; - } - } - try { - const response = await connection.request(query); - return response; - } catch (e2) { - const error = e2.message; - console.error("getBalance error", e2); - return { error }; - } - }; - const connect = async () => { - const connection = await getWalletConnectModalSignClient(); - if (!connection) { - throw new Error("call setConnection() first!"); + }, this.checkRecentlyDeleted = (t2) => { + const e2 = this.recentlyDeletedMap.get(t2); + if (e2) { + const { message: s2 } = xe$1("MISSING_OR_INVALID", `Record was recently deleted - ${e2}: ${t2}`); + throw new Error(s2); + } + }; } - const existingSession = await connection.getSession(); - if (existingSession) { - console.log("Already connected!", existingSession); - return existingSession; + async isInitialized() { + if (!this.initialized) { + const { message: n2 } = xe$1("NOT_INITIALIZED", this.name); + throw new Error(n2); + } + await this.client.core.relayer.confirmOnlineStateOrThrow(); } - try { - const newSession = await connection.connect({ - requiredNamespaces: { - aleo: { - methods: wc_aleo_methods, - chains: wc_aleo_chains, - events: wc_events - } + registerRelayerEvents() { + this.client.core.relayer.on(v$1.message, async (n2) => { + const { topic: t2, message: e2 } = n2, { publicKey: s2 } = this.client.auth.authKeys.keys.includes(J$1) ? this.client.auth.authKeys.get(J$1) : { responseTopic: void 0, publicKey: void 0 }, i2 = await this.client.core.crypto.decode(t2, e2, { receiverPublicKey: s2 }); + try { + isJsonRpcRequest(i2) ? (this.client.core.history.set(t2, i2), this.onRelayEventRequest({ topic: t2, payload: i2 })) : isJsonRpcResponse(i2) ? (await this.client.core.history.resolve(i2), await this.onRelayEventResponse({ topic: t2, payload: i2 }), this.client.core.history.delete(t2, i2.id)) : this.onRelayEventUnknownPayload({ topic: t2, payload: i2 }); + } catch (r2) { + this.client.logger.error(r2); } }); - emitter.emit("session_change"); - if (newSession) { - await checkForDesktopConnection(newSession.topic); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - return newSession; - } catch (e2) { - console.error("connect error", e2); } - }; - const requestCreateEvent = async (requestData) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { - if (typeof input === "string") { - return input; - } - return input.plaintext; - }); - try { - const response = await connection.request({ - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "requestCreateEvent", - params: { - ...requestData, - inputs - } - } + registerExpirerEvents() { + this.client.core.expirer.on(C$1.expired, async (n2) => { + const { topic: t2, id: e2 } = l0(n2.target); + if (e2 && this.client.pendingRequest.keys.includes(e2)) + return await this.deletePendingSessionRequest(e2, xe$1("EXPIRED"), true); + t2 ? this.client.session.keys.includes(t2) && (await this.deleteSession({ topic: t2, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: t2 })) : e2 && (await this.deleteProposal(e2, true), this.client.events.emit("proposal_expire", { id: e2 })); }); - return response; - } catch (e2) { - console.error("createEvent error", e2); - const error = e2.message; - return { error }; } - }; - const createSharedState = async () => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; + registerPairingEvents() { + this.client.core.pairing.events.on(V$2.create, (n2) => this.onPairingCreated(n2)), this.client.core.pairing.events.on(V$2.delete, (n2) => { + this.addToRecentlyDeleted(n2.topic, "pairing"); + }); } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "createSharedState", - params: {} - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.createSharedState.mutate( - query - ); - return response; - } catch (e2) { - console.error("createSharedState error", e2); - const error = e2.message; - return { error }; + isValidPairingTopic(n2) { + if (!Gt$2(n2, false)) { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `pairing topic should be a string: ${n2}`); + throw new Error(t2); } - } - try { - const response = await connection.request(query); - return response; - } catch (e2) { - console.error("createSharedState error", e2); - const error = e2.message; - return { error }; - } - }; - const decrypt = async (ciphertexts) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "decrypt", - params: { - ciphertexts - } + if (!this.client.core.pairing.pairings.keys.includes(n2)) { + const { message: t2 } = xe$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${n2}`); + throw new Error(t2); } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.decrypt.query(query); - return response; - } catch (e2) { - const error = e2.message; - console.error("decrypt error", e2); - return { error }; + if (p0(this.client.core.pairing.pairings.get(n2).expiry)) { + const { message: t2 } = xe$1("EXPIRED", `pairing topic: ${n2}`); + throw new Error(t2); } } - try { - const response = await connection.request(query); - return response; - } catch (e2) { - console.error("decrypt error", e2); - return { error: e2.message }; - } - }; - const disconnect = async () => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; - } - try { - try { - await connection.disconnect({ - reason: U$3("USER_DISCONNECTED"), - topic: session.topic - }); - localStorage.removeItem("puzzle-hasInjectedConnection"); - emitter.emit("session_change"); - } catch (e2) { - console.warn(e2); + async isValidSessionTopic(n2) { + if (!Gt$2(n2, false)) { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `session topic should be a string: ${n2}`); + throw new Error(t2); + } + if (this.checkRecentlyDeleted(n2), !this.client.session.keys.includes(n2)) { + const { message: t2 } = xe$1("NO_MATCHING_KEY", `session topic doesn't exist: ${n2}`); + throw new Error(t2); + } + if (p0(this.client.session.get(n2).expiry)) { + await this.deleteSession({ topic: n2 }); + const { message: t2 } = xe$1("EXPIRED", `session topic: ${n2}`); + throw new Error(t2); + } + if (!this.client.core.crypto.keychain.has(n2)) { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `session topic does not exist in keychain: ${n2}`); + throw await this.deleteSession({ topic: n2 }), new Error(t2); } - return {}; - } catch (e2) { - console.error("error disconnecting", e2); - const error = e2.message; - return { error }; } - }; - const getEvent = async ({ - id, - address - }) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { event: void 0, error: "no session or connection" }; + async isValidSessionOrPairingTopic(n2) { + if (this.checkRecentlyDeleted(n2), this.client.session.keys.includes(n2)) + await this.isValidSessionTopic(n2); + else if (this.client.core.pairing.pairings.keys.includes(n2)) + this.isValidPairingTopic(n2); + else if (Gt$2(n2, false)) { + const { message: t2 } = xe$1("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${n2}`); + throw new Error(t2); + } else { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `session or pairing topic should be a string: ${n2}`); + throw new Error(t2); + } } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getEvent", - params: { - id, - address - } + async isValidProposalId(n2) { + if (!Zu(n2)) { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `proposal id should be a number: ${n2}`); + throw new Error(t2); } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getEvent.query(query); - return response; - } catch (e2) { - console.error("getEvent error", e2); - const error = e2.message; - return { error }; + if (!this.client.proposal.keys.includes(n2)) { + const { message: t2 } = xe$1("NO_MATCHING_KEY", `proposal id doesn't exist: ${n2}`); + throw new Error(t2); + } + if (p0(this.client.proposal.get(n2).expiryTimestamp)) { + await this.deleteProposal(n2); + const { message: t2 } = xe$1("EXPIRED", `proposal id: ${n2}`); + throw new Error(t2); } } - const fetchEvent = async () => { - const response = await connection.request(query); - return response; - }; - try { - const response = await fetchEvent(); - return response; - } catch (e2) { - console.error("getEvents error", e2); - const error = e2.message; - return { error }; + }; + let Zt$2 = class Zt extends Vt { + constructor(n2, t2) { + super(n2, t2, Ke$1, se$2), this.core = n2, this.logger = t2; } }; - const getEvents = async (filter) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { events: void 0, error: "no session or connection" }; + let We$1 = class We extends Vt { + constructor(n2, t2) { + super(n2, t2, Ge$1, se$2), this.core = n2, this.logger = t2; } - if ((filter == null ? void 0 : filter.programId) === "") { - filter.programId = void 0; + }; + class es extends Vt { + constructor(n2, t2) { + super(n2, t2, Fe$1, se$2, (e2) => e2.id), this.core = n2, this.logger = t2; } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getEvents", - params: { - filter, - page: 0 - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getEvents.query(query); - return response; - } catch (e2) { - console.error("getEvents error", e2); - const error = e2.message; - return { error }; - } + } + class ts extends Vt { + constructor(n2, t2) { + super(n2, t2, He$1, X$1, () => J$1), this.core = n2, this.logger = t2; } - const fetchPage = async (page = 0) => { - const response = await connection.request(query); - return response; - }; - try { - const response = await fetchPage(); - return response; - } catch (e2) { - console.error("getEvents error", e2); - const error = e2.message; - return { error }; + } + let ss$1 = class ss extends Vt { + constructor(n2, t2) { + super(n2, t2, Ye$1, X$1), this.core = n2, this.logger = t2; } }; - const importSharedState = async (seed) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; + class is extends Vt { + constructor(n2, t2) { + super(n2, t2, Xe$1, X$1, (e2) => e2.id), this.core = n2, this.logger = t2; } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "importSharedState", - params: { - seed + } + class rs { + constructor(n2, t2) { + this.core = n2, this.logger = t2, this.authKeys = new ts(this.core, this.logger), this.pairingTopics = new ss$1(this.core, this.logger), this.requests = new is(this.core, this.logger); + } + async init() { + await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init(); + } + } + let ne$2 = class ne2 extends b$3 { + constructor(n2) { + super(n2), this.protocol = Se$1, this.version = Ee$1, this.name = ie$2.name, this.events = new eventsExports.EventEmitter(), this.on = (e2, s2) => this.events.on(e2, s2), this.once = (e2, s2) => this.events.once(e2, s2), this.off = (e2, s2) => this.events.off(e2, s2), this.removeListener = (e2, s2) => this.events.removeListener(e2, s2), this.removeAllListeners = (e2) => this.events.removeAllListeners(e2), this.connect = async (e2) => { + try { + return await this.engine.connect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; } - } - }; - if (hasInjectedConnection()) { + }, this.pair = async (e2) => { + try { + return await this.engine.pair(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approve = async (e2) => { + try { + return await this.engine.approve(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.reject = async (e2) => { + try { + return await this.engine.reject(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.update = async (e2) => { + try { + return await this.engine.update(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.extend = async (e2) => { + try { + return await this.engine.extend(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.request = async (e2) => { + try { + return await this.engine.request(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.respond = async (e2) => { + try { + return await this.engine.respond(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.ping = async (e2) => { + try { + return await this.engine.ping(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.emit = async (e2) => { + try { + return await this.engine.emit(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.disconnect = async (e2) => { + try { + return await this.engine.disconnect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.find = (e2) => { + try { + return this.engine.find(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.getPendingSessionRequests = () => { + try { + return this.engine.getPendingSessionRequests(); + } catch (e2) { + throw this.logger.error(e2.message), e2; + } + }, this.authenticate = async (e2) => { + try { + return await this.engine.authenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.formatAuthMessage = (e2) => { + try { + return this.engine.formatAuthMessage(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approveSessionAuthenticate = async (e2) => { + try { + return await this.engine.approveSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.rejectSessionAuthenticate = async (e2) => { + try { + return await this.engine.rejectSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.name = (n2 == null ? void 0 : n2.name) || ie$2.name, this.metadata = (n2 == null ? void 0 : n2.metadata) || Xo$1(); + const t2 = typeof (n2 == null ? void 0 : n2.logger) < "u" && typeof (n2 == null ? void 0 : n2.logger) != "string" ? n2.logger : nt$2(k$3({ level: (n2 == null ? void 0 : n2.logger) || ie$2.logger })); + this.core = (n2 == null ? void 0 : n2.core) || new Br(n2), this.logger = E$2(t2, this.name), this.session = new We$1(this.core, this.logger), this.proposal = new Zt$2(this.core, this.logger), this.pendingRequest = new es(this.core, this.logger), this.engine = new Wt$2(this), this.auth = new rs(this.core, this.logger); + } + static async init(n2) { + const t2 = new ne2(n2); + return await t2.initialize(), t2; + } + get context() { + return y$3(this.logger); + } + get pairing() { + return this.core.pairing.pairings; + } + async initialize() { + this.logger.trace("Initialized"); try { - const response = await window.aleo.puzzleWalletClient.importSharedState.mutate(query); - return response; - } catch (e2) { - console.error("importSharedState error", e2); - const error = e2.message; - return { error }; + await this.core.start(), await this.session.init(), await this.proposal.init(), await this.pendingRequest.init(), await this.engine.init(), await this.auth.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); + } catch (n2) { + throw this.logger.info("SignClient Initialization Failure"), this.logger.error(n2.message), n2; } } - try { - const response = await connection.request(query); - return response; - } catch (e2) { - console.error("importSharedState error", e2); - const error = e2.message; - return { error }; - } }; - const getRecords = async ({ - address, - filter, - page = 0 - }) => { - const connection = await getWalletConnectModalSignClient(); - const session = await (connection == null ? void 0 : connection.getSession()); - if (!session || !connection) { - return { error: "no session or connection" }; + var N$2 = Object.defineProperty, T$1 = Object.defineProperties, U$1 = Object.getOwnPropertyDescriptors, I$1 = Object.getOwnPropertySymbols, A$1 = Object.prototype.hasOwnProperty, D$2 = Object.prototype.propertyIsEnumerable, M$1 = (e2, t2, a2) => t2 in e2 ? N$2(e2, t2, { enumerable: true, configurable: true, writable: true, value: a2 }) : e2[t2] = a2, q = (e2, t2) => { + for (var a2 in t2 || (t2 = {})) + A$1.call(t2, a2) && M$1(e2, a2, t2[a2]); + if (I$1) + for (var a2 of I$1(t2)) + D$2.call(t2, a2) && M$1(e2, a2, t2[a2]); + return e2; + }, L$3 = (e2, t2) => T$1(e2, U$1(t2)), g$1 = (e2, t2, a2) => { + if (!t2.has(e2)) + throw TypeError("Cannot " + a2); + }, s$5 = (e2, t2, a2) => (g$1(e2, t2, "read from private field"), a2 ? a2.call(e2) : t2.get(e2)), d$2 = (e2, t2, a2) => { + if (t2.has(e2)) + throw TypeError("Cannot add the same private member more than once"); + t2 instanceof WeakSet ? t2.add(e2) : t2.set(e2, a2); + }, S$3 = (e2, t2, a2, h2) => (g$1(e2, t2, "write to private field"), t2.set(e2, a2), a2), n$6 = (e2, t2, a2) => (g$1(e2, t2, "access private method"), a2), w$1, f$1, u$2, o$5, O, k$1, r$3, c$2, j$1, P$2; + let G$1 = class G { + constructor(t2) { + d$2(this, O), d$2(this, r$3), d$2(this, j$1), d$2(this, w$1, void 0), d$2(this, f$1, void 0), d$2(this, u$2, void 0), d$2(this, o$5, void 0), S$3(this, w$1, t2), S$3(this, f$1, n$6(this, O, k$1).call(this)), n$6(this, r$3, c$2).call(this); + } + async connect(t2, a2 = true) { + const { requiredNamespaces: h2, optionalNamespaces: y2 } = t2; + return new Promise(async (W2, E2) => { + var _2, C2; + if (await n$6(this, r$3, c$2).call(this), a2) { + const p2 = s$5(this, f$1).subscribeModal((i2) => { + i2.open || (p2(), E2(new Error("Modal closed"))); + }), { uri: v2, approval: m2 } = await s$5(this, o$5).connect(t2); + if (v2) { + const i2 = /* @__PURE__ */ new Set(); + h2 && Object.values(h2).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b2) => i2.add(b2)); + }), y2 && Object.values(y2).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b2) => i2.add(b2)); + }), await s$5(this, f$1).openModal({ uri: v2, chains: Array.from(i2) }); + } + try { + const i2 = await m2(); + W2(i2); + } catch (i2) { + E2(i2); + } finally { + p2(), s$5(this, f$1).closeModal(); + } + } else { + const { uri: p2, approval: v2 } = await s$5(this, o$5).connect(t2); + if (p2) { + const m2 = /* @__PURE__ */ new Set(); + h2 && Object.values(h2).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m2.add(l2)); + }), y2 && Object.values(y2).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m2.add(l2)); + }); + try { + if ((_2 = window == null ? void 0 : window.aleo) != null && _2.connectPuzzle) { + (C2 = window == null ? void 0 : window.aleo) == null || C2.connectPuzzle({ wc: { uri: p2 } }); + const i2 = await v2(); + W2(i2); + } else + throw new Error("window.aleo.connectPuzzle is undefined! Set showModal to true."); + } catch (i2) { + console.error(i2), E2(i2); + } + } + } + }); + } + async disconnect(t2) { + await n$6(this, r$3, c$2).call(this), await s$5(this, o$5).disconnect(t2); + } + async request(t2) { + return await n$6(this, r$3, c$2).call(this), await s$5(this, o$5).request(t2); + } + async getSessions() { + return await n$6(this, r$3, c$2).call(this), s$5(this, o$5).session.getAll(); + } + async getSession() { + return await n$6(this, r$3, c$2).call(this), s$5(this, o$5).session.getAll().at(-1); + } + async onSessionEvent(t2) { + await n$6(this, r$3, c$2).call(this), s$5(this, o$5).on("session_event", t2); + } + async offSessionEvent(t2) { + await n$6(this, r$3, c$2).call(this), s$5(this, o$5).off("session_event", t2); + } + async onSessionUpdate(t2) { + await n$6(this, r$3, c$2).call(this), s$5(this, o$5).on("session_update", t2); + } + async offSessionUpdate(t2) { + await n$6(this, r$3, c$2).call(this), s$5(this, o$5).off("session_update", t2); + } + async onSessionDelete(t2) { + await n$6(this, r$3, c$2).call(this), s$5(this, o$5).on("session_delete", t2); } - const query = { - topic: session.topic, - chainId: "aleo:1", - request: { - jsonrpc: "2.0", - method: "getRecords", - params: { - address, - filter, - page - } - } - }; - if (hasInjectedConnection()) { - try { - const response = await window.aleo.puzzleWalletClient.getRecords.query(query); - return response; - } catch (e2) { - console.error("getRecords error", e2); - const error = e2.message; - return { error }; - } + async offSessionDelete(t2) { + await n$6(this, r$3, c$2).call(this), s$5(this, o$5).off("session_delete", t2); } - const fetchPage = async (page2 = 0) => { - const response = await connection.request(query); - return response; - }; + async onSessionExpire(t2) { + await n$6(this, r$3, c$2).call(this), s$5(this, o$5).on("session_expire", t2); + } + async offSessionExpire(t2) { + await n$6(this, r$3, c$2).call(this), s$5(this, o$5).off("session_expire", t2); + } + }; + w$1 = /* @__PURE__ */ new WeakMap(), f$1 = /* @__PURE__ */ new WeakMap(), u$2 = /* @__PURE__ */ new WeakMap(), o$5 = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakSet(), k$1 = function() { + const { modalOptions: e2, projectId: t2 } = s$5(this, w$1); + return new d$5(L$3(q({}, e2), { projectId: t2 })); + }, r$3 = /* @__PURE__ */ new WeakSet(), c$2 = async function() { + return s$5(this, o$5) ? true : (!s$5(this, u$2) && typeof window < "u" && S$3(this, u$2, n$6(this, j$1, P$2).call(this)), s$5(this, u$2)); + }, j$1 = /* @__PURE__ */ new WeakSet(), P$2 = async function() { + S$3(this, o$5, await ne$2.init({ metadata: s$5(this, w$1).metadata, projectId: s$5(this, w$1).projectId, relayUrl: s$5(this, w$1).relayUrl })); + const e2 = await s$5(this, o$5).core.crypto.getClientId(); try { - const response = await fetchPage(); - return response; - } catch (e2) { - console.error("getRecords error", e2); - const error = e2.message; - return { error }; + localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e2); + } catch { + console.info("Unable to set client id"); } }; var util; @@ -13821,11 +16995,11 @@ throw result.error; } safeParse(data2, params) { - var _a; + var _a2; const ctx = { common: { issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap }, path: (params === null || params === void 0 ? void 0 : params.path) || [], @@ -14181,7 +17355,7 @@ } else if (check.kind === "url") { try { new URL(input.data); - } catch (_a) { + } catch (_a2) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext(ctx, { validation: "url", @@ -14296,7 +17470,7 @@ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); } datetime(options) { - var _a; + var _a2; if (typeof options === "string") { return this._addCheck({ kind: "datetime", @@ -14308,7 +17482,7 @@ return this._addCheck({ kind: "datetime", precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) }); } @@ -14341,109 +17515,339 @@ ...errorUtil.errToObj(message) }); } - min(minLength, message) { + min(minLength, message) { + return this._addCheck({ + kind: "min", + value: minLength, + ...errorUtil.errToObj(message) + }); + } + max(maxLength, message) { + return this._addCheck({ + kind: "max", + value: maxLength, + ...errorUtil.errToObj(message) + }); + } + length(len, message) { + return this._addCheck({ + kind: "length", + value: len, + ...errorUtil.errToObj(message) + }); + } + get isDatetime() { + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); + } + get isEmail() { + return !!this._def.checks.find((ch2) => ch2.kind === "email"); + } + get isURL() { + return !!this._def.checks.find((ch2) => ch2.kind === "url"); + } + get isEmoji() { + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); + } + get isUUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); + } + get isCUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); + } + get isCUID2() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); + } + get isULID() { + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); + } + get isIP() { + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); + } + get minLength() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxLength() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } + } + ZodString.create = (params) => { + var _a2; + return new ZodString({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodString, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams(params) + }); + }; + function floatSafeRemainder(val, step) { + const valDecCount = (val.toString().split(".")[1] || "").length; + const stepDecCount = (step.toString().split(".")[1] || "").length; + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; + const valInt = parseInt(val.toFixed(decCount).replace(".", "")); + const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); + return valInt % stepInt / Math.pow(10, decCount); + } + class ZodNumber extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + this.step = this.multipleOf; + } + _parse(input) { + if (this._def.coerce) { + input.data = Number(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.number) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.number, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "int") { + if (!util.isInteger(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: "integer", + received: "float", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (floatSafeRemainder(input.data, check.value) !== 0) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "finite") { + if (!Number.isFinite(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_finite, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodNumber({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodNumber({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + int(message) { + return this._addCheck({ + kind: "int", + message: errorUtil.toString(message) + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: false, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: false, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: true, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { return this._addCheck({ kind: "min", - value: minLength, - ...errorUtil.errToObj(message) + value: 0, + inclusive: true, + message: errorUtil.toString(message) }); } - max(maxLength, message) { + multipleOf(value, message) { return this._addCheck({ - kind: "max", - value: maxLength, - ...errorUtil.errToObj(message) + kind: "multipleOf", + value, + message: errorUtil.toString(message) }); } - length(len, message) { + finite(message) { return this._addCheck({ - kind: "length", - value: len, - ...errorUtil.errToObj(message) + kind: "finite", + message: errorUtil.toString(message) }); } - get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); - } - get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); - } - get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); - } - get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); - } - get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); - } - get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); - } - get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); - } - get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); - } - get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); + safe(message) { + return this._addCheck({ + kind: "min", + inclusive: true, + value: Number.MIN_SAFE_INTEGER, + message: errorUtil.toString(message) + })._addCheck({ + kind: "max", + inclusive: true, + value: Number.MAX_SAFE_INTEGER, + message: errorUtil.toString(message) + }); } - get minLength() { + get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } - get maxLength() { + get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } + get isInt() { + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util.isInteger(ch2.value)); + } + get isFinite() { + let max = null, min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { + return true; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return Number.isFinite(min) && Number.isFinite(max); + } } - ZodString.create = (params) => { - var _a; - return new ZodString({ + ZodNumber.create = (params) => { + return new ZodNumber({ checks: [], - typeName: ZodFirstPartyTypeKind.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + typeName: ZodFirstPartyTypeKind.ZodNumber, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, ...processCreateParams(params) }); }; - function floatSafeRemainder(val, step) { - const valDecCount = (val.toString().split(".")[1] || "").length; - const stepDecCount = (step.toString().split(".")[1] || "").length; - const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; - const valInt = parseInt(val.toFixed(decCount).replace(".", "")); - const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); - return valInt % stepInt / Math.pow(10, decCount); - } - class ZodNumber extends ZodType { + class ZodBigInt extends ZodType { constructor() { super(...arguments); this.min = this.gte; this.max = this.lte; - this.step = this.multipleOf; } _parse(input) { if (this._def.coerce) { - input.data = Number(input.data); + input.data = BigInt(input.data); } const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.number) { + if (parsedType !== ZodParsedType.bigint) { const ctx2 = this._getOrReturnCtx(input); addIssueToContext(ctx2, { code: ZodIssueCode.invalid_type, - expected: ZodParsedType.number, + expected: ZodParsedType.bigint, received: ctx2.parsedType }); return INVALID; @@ -14451,27 +17855,15 @@ let ctx = void 0; const status = new ParseStatus(); for (const check of this._def.checks) { - if (check.kind === "int") { - if (!util.isInteger(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: "integer", - received: "float", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "min") { + if (check.kind === "min") { const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; if (tooSmall) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext(ctx, { code: ZodIssueCode.too_small, + type: "bigint", minimum: check.value, - type: "number", inclusive: check.inclusive, - exact: false, message: check.message }); status.dirty(); @@ -14482,16 +17874,15 @@ ctx = this._getOrReturnCtx(input, ctx); addIssueToContext(ctx, { code: ZodIssueCode.too_big, + type: "bigint", maximum: check.value, - type: "number", inclusive: check.inclusive, - exact: false, message: check.message }); status.dirty(); } } else if (check.kind === "multipleOf") { - if (floatSafeRemainder(input.data, check.value) !== 0) { + if (input.data % check.value !== BigInt(0)) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext(ctx, { code: ZodIssueCode.not_multiple_of, @@ -14500,15 +17891,6 @@ }); status.dirty(); } - } else if (check.kind === "finite") { - if (!Number.isFinite(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.not_finite, - message: check.message - }); - status.dirty(); - } } else { util.assertNever(check); } @@ -14528,7 +17910,7 @@ return this.setLimit("max", value, false, errorUtil.toString(message)); } setLimit(kind, value, inclusive, message) { - return new ZodNumber({ + return new ZodBigInt({ ...this._def, checks: [ ...this._def.checks, @@ -14542,21 +17924,15 @@ }); } _addCheck(check) { - return new ZodNumber({ + return new ZodBigInt({ ...this._def, checks: [...this._def.checks, check] }); } - int(message) { - return this._addCheck({ - kind: "int", - message: errorUtil.toString(message) - }); - } positive(message) { return this._addCheck({ kind: "min", - value: 0, + value: BigInt(0), inclusive: false, message: errorUtil.toString(message) }); @@ -14564,7 +17940,7 @@ negative(message) { return this._addCheck({ kind: "max", - value: 0, + value: BigInt(0), inclusive: false, message: errorUtil.toString(message) }); @@ -14572,2434 +17948,6230 @@ nonpositive(message) { return this._addCheck({ kind: "max", - value: 0, + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), inclusive: true, message: errorUtil.toString(message) }); } - nonnegative(message) { + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } + } + ZodBigInt.create = (params) => { + var _a2; + return new ZodBigInt({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodBigInt, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams(params) + }); + }; + class ZodBoolean extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = Boolean(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.boolean) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.boolean, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + } + ZodBoolean.create = (params) => { + return new ZodBoolean({ + typeName: ZodFirstPartyTypeKind.ZodBoolean, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); + }; + class ZodDate extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = new Date(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.date) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.date, + received: ctx2.parsedType + }); + return INVALID; + } + if (isNaN(input.data.getTime())) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_date + }); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.getTime() < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + message: check.message, + inclusive: true, + exact: false, + minimum: check.value, + type: "date" + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.getTime() > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + message: check.message, + inclusive: true, + exact: false, + maximum: check.value, + type: "date" + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { + status: status.value, + value: new Date(input.data.getTime()) + }; + } + _addCheck(check) { + return new ZodDate({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + min(minDate, message) { return this._addCheck({ kind: "min", - value: 0, - inclusive: true, + value: minDate.getTime(), message: errorUtil.toString(message) }); } - multipleOf(value, message) { + max(maxDate, message) { return this._addCheck({ - kind: "multipleOf", - value, + kind: "max", + value: maxDate.getTime(), message: errorUtil.toString(message) }); } - finite(message) { - return this._addCheck({ - kind: "finite", - message: errorUtil.toString(message) - }); + get minDate() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min != null ? new Date(min) : null; } - safe(message) { - return this._addCheck({ - kind: "min", - inclusive: true, - value: Number.MIN_SAFE_INTEGER, - message: errorUtil.toString(message) - })._addCheck({ - kind: "max", - inclusive: true, - value: Number.MAX_SAFE_INTEGER, - message: errorUtil.toString(message) + get maxDate() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max != null ? new Date(max) : null; + } + } + ZodDate.create = (params) => { + return new ZodDate({ + checks: [], + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + typeName: ZodFirstPartyTypeKind.ZodDate, + ...processCreateParams(params) + }); + }; + class ZodSymbol extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.symbol) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.symbol, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + } + ZodSymbol.create = (params) => { + return new ZodSymbol({ + typeName: ZodFirstPartyTypeKind.ZodSymbol, + ...processCreateParams(params) + }); + }; + class ZodUndefined extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.undefined, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + } + ZodUndefined.create = (params) => { + return new ZodUndefined({ + typeName: ZodFirstPartyTypeKind.ZodUndefined, + ...processCreateParams(params) + }); + }; + class ZodNull extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.null) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.null, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + } + ZodNull.create = (params) => { + return new ZodNull({ + typeName: ZodFirstPartyTypeKind.ZodNull, + ...processCreateParams(params) + }); + }; + class ZodAny extends ZodType { + constructor() { + super(...arguments); + this._any = true; + } + _parse(input) { + return OK(input.data); + } + } + ZodAny.create = (params) => { + return new ZodAny({ + typeName: ZodFirstPartyTypeKind.ZodAny, + ...processCreateParams(params) + }); + }; + class ZodUnknown extends ZodType { + constructor() { + super(...arguments); + this._unknown = true; + } + _parse(input) { + return OK(input.data); + } + } + ZodUnknown.create = (params) => { + return new ZodUnknown({ + typeName: ZodFirstPartyTypeKind.ZodUnknown, + ...processCreateParams(params) + }); + }; + class ZodNever extends ZodType { + _parse(input) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.never, + received: ctx.parsedType }); + return INVALID; } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + } + ZodNever.create = (params) => { + return new ZodNever({ + typeName: ZodFirstPartyTypeKind.ZodNever, + ...processCreateParams(params) + }); + }; + class ZodVoid extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.void, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + } + ZodVoid.create = (params) => { + return new ZodVoid({ + typeName: ZodFirstPartyTypeKind.ZodVoid, + ...processCreateParams(params) + }); + }; + class ZodArray extends ZodType { + _parse(input) { + const { ctx, status } = this._processInputParams(input); + const def = this._def; + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (def.exactLength !== null) { + const tooBig = ctx.data.length > def.exactLength.value; + const tooSmall = ctx.data.length < def.exactLength.value; + if (tooBig || tooSmall) { + addIssueToContext(ctx, { + code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, + minimum: tooSmall ? def.exactLength.value : void 0, + maximum: tooBig ? def.exactLength.value : void 0, + type: "array", + inclusive: true, + exact: true, + message: def.exactLength.message + }); + status.dirty(); } } - return min; + if (def.minLength !== null) { + if (ctx.data.length < def.minLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.minLength.message + }); + status.dirty(); + } + } + if (def.maxLength !== null) { + if (ctx.data.length > def.maxLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.maxLength.message + }); + status.dirty(); + } + } + if (ctx.common.async) { + return Promise.all([...ctx.data].map((item, i2) => { + return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); + })).then((result2) => { + return ParseStatus.mergeArray(status, result2); + }); + } + const result = [...ctx.data].map((item, i2) => { + return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); + }); + return ParseStatus.mergeArray(status, result); + } + get element() { + return this._def.type; + } + min(minLength, message) { + return new ZodArray({ + ...this._def, + minLength: { value: minLength, message: errorUtil.toString(message) } + }); } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; + max(maxLength, message) { + return new ZodArray({ + ...this._def, + maxLength: { value: maxLength, message: errorUtil.toString(message) } + }); } - get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); + length(len, message) { + return new ZodArray({ + ...this._def, + exactLength: { value: len, message: errorUtil.toString(message) } + }); } - get isFinite() { - let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { - return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return Number.isFinite(min) && Number.isFinite(max); + nonempty(message) { + return this.min(1, message); } } - ZodNumber.create = (params) => { - return new ZodNumber({ - checks: [], - typeName: ZodFirstPartyTypeKind.ZodNumber, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ZodArray.create = (schema, params) => { + return new ZodArray({ + type: schema, + minLength: null, + maxLength: null, + exactLength: null, + typeName: ZodFirstPartyTypeKind.ZodArray, ...processCreateParams(params) }); }; - class ZodBigInt extends ZodType { + function deepPartialify(schema) { + if (schema instanceof ZodObject) { + const newShape = {}; + for (const key in schema.shape) { + const fieldSchema = schema.shape[key]; + newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); + } + return new ZodObject({ + ...schema._def, + shape: () => newShape + }); + } else if (schema instanceof ZodArray) { + return new ZodArray({ + ...schema._def, + type: deepPartialify(schema.element) + }); + } else if (schema instanceof ZodOptional) { + return ZodOptional.create(deepPartialify(schema.unwrap())); + } else if (schema instanceof ZodNullable) { + return ZodNullable.create(deepPartialify(schema.unwrap())); + } else if (schema instanceof ZodTuple) { + return ZodTuple.create(schema.items.map((item) => deepPartialify(item))); + } else { + return schema; + } + } + class ZodObject extends ZodType { constructor() { super(...arguments); - this.min = this.gte; - this.max = this.lte; + this._cached = null; + this.nonstrict = this.passthrough; + this.augment = this.extend; + } + _getCached() { + if (this._cached !== null) + return this._cached; + const shape = this._def.shape(); + const keys2 = util.objectKeys(shape); + return this._cached = { shape, keys: keys2 }; } _parse(input) { - if (this._def.coerce) { - input.data = BigInt(input.data); - } const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.bigint) { + if (parsedType !== ZodParsedType.object) { const ctx2 = this._getOrReturnCtx(input); addIssueToContext(ctx2, { code: ZodIssueCode.invalid_type, - expected: ZodParsedType.bigint, + expected: ZodParsedType.object, received: ctx2.parsedType }); return INVALID; } - let ctx = void 0; - const status = new ParseStatus(); - for (const check of this._def.checks) { - if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - type: "bigint", - minimum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); + const { status, ctx } = this._processInputParams(input); + const { shape, keys: shapeKeys } = this._getCached(); + const extraKeys = []; + if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - type: "bigint", - maximum: check.value, - inclusive: check.inclusive, - message: check.message + } + } + const pairs = []; + for (const key of shapeKeys) { + const keyValidator = shape[key]; + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), + alwaysSet: key in ctx.data + }); + } + if (this._def.catchall instanceof ZodNever) { + const unknownKeys = this._def.unknownKeys; + if (unknownKeys === "passthrough") { + for (const key of extraKeys) { + pairs.push({ + key: { status: "valid", value: key }, + value: { status: "valid", value: ctx.data[key] } }); - status.dirty(); } - } else if (check.kind === "multipleOf") { - if (input.data % check.value !== BigInt(0)) { - ctx = this._getOrReturnCtx(input, ctx); + } else if (unknownKeys === "strict") { + if (extraKeys.length > 0) { addIssueToContext(ctx, { - code: ZodIssueCode.not_multiple_of, - multipleOf: check.value, - message: check.message + code: ZodIssueCode.unrecognized_keys, + keys: extraKeys }); status.dirty(); } - } else { - util.assertNever(check); + } else if (unknownKeys === "strip") + ; + else { + throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); + } + } else { + const catchall = this._def.catchall; + for (const key of extraKeys) { + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: catchall._parse( + new ParseInputLazyPath(ctx, value, ctx.path, key) + //, ctx.child(key), value, getParsedType(value) + ), + alwaysSet: key in ctx.data + }); } } - return { status: status.value, value: input.data }; + if (ctx.common.async) { + return Promise.resolve().then(async () => { + const syncPairs = []; + for (const pair of pairs) { + const key = await pair.key; + syncPairs.push({ + key, + value: await pair.value, + alwaysSet: pair.alwaysSet + }); + } + return syncPairs; + }).then((syncPairs) => { + return ParseStatus.mergeObjectSync(status, syncPairs); + }); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil.toString(message)); + get shape() { + return this._def.shape(); } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil.toString(message)); + strict(message) { + errorUtil.errToObj; + return new ZodObject({ + ...this._def, + unknownKeys: "strict", + ...message !== void 0 ? { + errorMap: (issue, ctx) => { + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + if (issue.code === "unrecognized_keys") + return { + message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError + }; + return { + message: defaultError + }; + } + } : {} + }); } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil.toString(message)); + strip() { + return new ZodObject({ + ...this._def, + unknownKeys: "strip" + }); + } + passthrough() { + return new ZodObject({ + ...this._def, + unknownKeys: "passthrough" + }); + } + // const AugmentFactory = + // (def: Def) => + // ( + // augmentation: Augmentation + // ): ZodObject< + // extendShape, Augmentation>, + // Def["unknownKeys"], + // Def["catchall"] + // > => { + // return new ZodObject({ + // ...def, + // shape: () => ({ + // ...def.shape(), + // ...augmentation, + // }), + // }) as any; + // }; + extend(augmentation) { + return new ZodObject({ + ...this._def, + shape: () => ({ + ...this._def.shape(), + ...augmentation + }) + }); + } + /** + * Prior to zod@1.0.12 there was a bug in the + * inferred type of merged objects. Please + * upgrade if you are experiencing issues. + */ + merge(merging) { + const merged = new ZodObject({ + unknownKeys: merging._def.unknownKeys, + catchall: merging._def.catchall, + shape: () => ({ + ...this._def.shape(), + ...merging._def.shape() + }), + typeName: ZodFirstPartyTypeKind.ZodObject + }); + return merged; } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil.toString(message)); + // merge< + // Incoming extends AnyZodObject, + // Augmentation extends Incoming["shape"], + // NewOutput extends { + // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation + // ? Augmentation[k]["_output"] + // : k extends keyof Output + // ? Output[k] + // : never; + // }, + // NewInput extends { + // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation + // ? Augmentation[k]["_input"] + // : k extends keyof Input + // ? Input[k] + // : never; + // } + // >( + // merging: Incoming + // ): ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"], + // NewOutput, + // NewInput + // > { + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + setKey(key, schema) { + return this.augment({ [key]: schema }); } - setLimit(kind, value, inclusive, message) { - return new ZodBigInt({ + // merge( + // merging: Incoming + // ): //ZodObject = (merging) => { + // ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"] + // > { + // // const mergedShape = objectUtil.mergeShapes( + // // this._def.shape(), + // // merging._def.shape() + // // ); + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + catchall(index2) { + return new ZodObject({ ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil.toString(message) - } - ] + catchall: index2 }); } - _addCheck(check) { - return new ZodBigInt({ + pick(mask) { + const shape = {}; + util.objectKeys(mask).forEach((key) => { + if (mask[key] && this.shape[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ ...this._def, - checks: [...this._def.checks, check] + shape: () => shape }); } - positive(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: false, - message: errorUtil.toString(message) + omit(mask) { + const shape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (!mask[key]) { + shape[key] = this.shape[key]; + } }); - } - negative(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: false, - message: errorUtil.toString(message) + return new ZodObject({ + ...this._def, + shape: () => shape }); } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: true, - message: errorUtil.toString(message) - }); + /** + * @deprecated + */ + deepPartial() { + return deepPartialify(this); } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: true, - message: errorUtil.toString(message) + partial(mask) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + const fieldSchema = this.shape[key]; + if (mask && !mask[key]) { + newShape[key] = fieldSchema; + } else { + newShape[key] = fieldSchema.optional(); + } + }); + return new ZodObject({ + ...this._def, + shape: () => newShape }); } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil.toString(message) + required(mask) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (mask && !mask[key]) { + newShape[key] = this.shape[key]; + } else { + const fieldSchema = this.shape[key]; + let newField = fieldSchema; + while (newField instanceof ZodOptional) { + newField = newField._def.innerType; + } + newShape[key] = newField; + } + }); + return new ZodObject({ + ...this._def, + shape: () => newShape }); } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + keyof() { + return createZodEnum(util.objectKeys(this.shape)); + } + } + ZodObject.create = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); + }; + ZodObject.strictCreate = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strict", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); + }; + ZodObject.lazycreate = (shape, params) => { + return new ZodObject({ + shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); + }; + class ZodUnion extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const options = this._def.options; + function handleResults(results2) { + for (const result of results2) { + if (result.result.status === "valid") { + return result.result; + } + } + for (const result of results2) { + if (result.result.status === "dirty") { + ctx.common.issues.push(...result.ctx.common.issues); + return result.result; + } + } + const unionErrors = results2.map((result) => new ZodError(result.ctx.common.issues)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + if (ctx.common.async) { + return Promise.all(options.map(async (option) => { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + return { + result: await option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }), + ctx: childCtx + }; + })).then(handleResults); + } else { + let dirty = void 0; + const issues = []; + for (const option of options) { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + const result = option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }); + if (result.status === "valid") { + return result; + } else if (result.status === "dirty" && !dirty) { + dirty = { result, ctx: childCtx }; + } + if (childCtx.common.issues.length) { + issues.push(childCtx.common.issues); + } } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + if (dirty) { + ctx.common.issues.push(...dirty.ctx.common.issues); + return dirty.result; } - } - return max; - } - } - ZodBigInt.create = (params) => { - var _a; - return new ZodBigInt({ - checks: [], - typeName: ZodFirstPartyTypeKind.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, - ...processCreateParams(params) - }); - }; - class ZodBoolean extends ZodType { - _parse(input) { - if (this._def.coerce) { - input.data = Boolean(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.boolean) { - const ctx = this._getOrReturnCtx(input); + const unionErrors = issues.map((issues2) => new ZodError(issues2)); addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.boolean, - received: ctx.parsedType + code: ZodIssueCode.invalid_union, + unionErrors }); return INVALID; } - return OK(input.data); + } + get options() { + return this._def.options; } } - ZodBoolean.create = (params) => { - return new ZodBoolean({ - typeName: ZodFirstPartyTypeKind.ZodBoolean, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ZodUnion.create = (types2, params) => { + return new ZodUnion({ + options: types2, + typeName: ZodFirstPartyTypeKind.ZodUnion, ...processCreateParams(params) }); }; - class ZodDate extends ZodType { + const getDiscriminator = (type2) => { + if (type2 instanceof ZodLazy) { + return getDiscriminator(type2.schema); + } else if (type2 instanceof ZodEffects) { + return getDiscriminator(type2.innerType()); + } else if (type2 instanceof ZodLiteral) { + return [type2.value]; + } else if (type2 instanceof ZodEnum) { + return type2.options; + } else if (type2 instanceof ZodNativeEnum) { + return Object.keys(type2.enum); + } else if (type2 instanceof ZodDefault) { + return getDiscriminator(type2._def.innerType); + } else if (type2 instanceof ZodUndefined) { + return [void 0]; + } else if (type2 instanceof ZodNull) { + return [null]; + } else { + return null; + } + }; + class ZodDiscriminatedUnion extends ZodType { _parse(input) { - if (this._def.coerce) { - input.data = new Date(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.date) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { code: ZodIssueCode.invalid_type, - expected: ZodParsedType.date, - received: ctx2.parsedType + expected: ZodParsedType.object, + received: ctx.parsedType }); return INVALID; } - if (isNaN(input.data.getTime())) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_date + const discriminator = this.discriminator; + const discriminatorValue = ctx.data[discriminator]; + const option = this.optionsMap.get(discriminatorValue); + if (!option) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union_discriminator, + options: Array.from(this.optionsMap.keys()), + path: [discriminator] }); return INVALID; } - const status = new ParseStatus(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.getTime() < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - message: check.message, - inclusive: true, - exact: false, - minimum: check.value, - type: "date" - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.getTime() > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - message: check.message, - inclusive: true, - exact: false, - maximum: check.value, - type: "date" - }); - status.dirty(); - } - } else { - util.assertNever(check); - } + if (ctx.common.async) { + return option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } else { + return option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); } - return { - status: status.value, - value: new Date(input.data.getTime()) - }; } - _addCheck(check) { - return new ZodDate({ - ...this._def, - checks: [...this._def.checks, check] - }); + get discriminator() { + return this._def.discriminator; } - min(minDate, message) { - return this._addCheck({ - kind: "min", - value: minDate.getTime(), - message: errorUtil.toString(message) - }); + get options() { + return this._def.options; } - max(maxDate, message) { - return this._addCheck({ - kind: "max", - value: maxDate.getTime(), - message: errorUtil.toString(message) + get optionsMap() { + return this._def.optionsMap; + } + /** + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must + * have a different value for each object in the union. + * @param discriminator the name of the discriminator property + * @param types an array of object schemas + * @param params + */ + static create(discriminator, options, params) { + const optionsMap = /* @__PURE__ */ new Map(); + for (const type2 of options) { + const discriminatorValues = getDiscriminator(type2.shape[discriminator]); + if (!discriminatorValues) { + throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); + } + for (const value of discriminatorValues) { + if (optionsMap.has(value)) { + throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); + } + optionsMap.set(value, type2); + } + } + return new ZodDiscriminatedUnion({ + typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, + discriminator, + options, + optionsMap, + ...processCreateParams(params) }); } - get minDate() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + } + function mergeValues(a2, b2) { + const aType = getParsedType(a2); + const bType = getParsedType(b2); + if (a2 === b2) { + return { valid: true, data: a2 }; + } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) { + const bKeys = util.objectKeys(b2); + const sharedKeys = util.objectKeys(a2).filter((key) => bKeys.indexOf(key) !== -1); + const newObj = { ...a2, ...b2 }; + for (const key of sharedKeys) { + const sharedValue = mergeValues(a2[key], b2[key]); + if (!sharedValue.valid) { + return { valid: false }; } + newObj[key] = sharedValue.data; } - return min != null ? new Date(min) : null; + return { valid: true, data: newObj }; + } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { + if (a2.length !== b2.length) { + return { valid: false }; + } + const newArray = []; + for (let index2 = 0; index2 < a2.length; index2++) { + const itemA = a2[index2]; + const itemB = b2[index2]; + const sharedValue = mergeValues(itemA, itemB); + if (!sharedValue.valid) { + return { valid: false }; + } + newArray.push(sharedValue.data); + } + return { valid: true, data: newArray }; + } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a2 === +b2) { + return { valid: true, data: a2 }; + } else { + return { valid: false }; } - get maxDate() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + } + class ZodIntersection extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const handleParsed = (parsedLeft, parsedRight) => { + if (isAborted(parsedLeft) || isAborted(parsedRight)) { + return INVALID; + } + const merged = mergeValues(parsedLeft.value, parsedRight.value); + if (!merged.valid) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_intersection_types + }); + return INVALID; + } + if (isDirty(parsedLeft) || isDirty(parsedRight)) { + status.dirty(); } + return { status: status.value, value: merged.data }; + }; + if (ctx.common.async) { + return Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)); + } else { + return handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); } - return max != null ? new Date(max) : null; } } - ZodDate.create = (params) => { - return new ZodDate({ - checks: [], - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - typeName: ZodFirstPartyTypeKind.ZodDate, + ZodIntersection.create = (left, right, params) => { + return new ZodIntersection({ + left, + right, + typeName: ZodFirstPartyTypeKind.ZodIntersection, ...processCreateParams(params) }); }; - class ZodSymbol extends ZodType { + class ZodTuple extends ZodType { _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.symbol) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.array) { addIssueToContext(ctx, { code: ZodIssueCode.invalid_type, - expected: ZodParsedType.symbol, + expected: ZodParsedType.array, received: ctx.parsedType }); return INVALID; } - return OK(input.data); - } - } - ZodSymbol.create = (params) => { - return new ZodSymbol({ - typeName: ZodFirstPartyTypeKind.ZodSymbol, - ...processCreateParams(params) - }); - }; - class ZodUndefined extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.undefined) { - const ctx = this._getOrReturnCtx(input); + if (ctx.data.length < this._def.items.length) { addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.undefined, - received: ctx.parsedType + code: ZodIssueCode.too_small, + minimum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" }); return INVALID; } - return OK(input.data); + const rest = this._def.rest; + if (!rest && ctx.data.length > this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + status.dirty(); + } + const items = [...ctx.data].map((item, itemIndex) => { + const schema = this._def.items[itemIndex] || this._def.rest; + if (!schema) + return null; + return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)); + }).filter((x2) => !!x2); + if (ctx.common.async) { + return Promise.all(items).then((results2) => { + return ParseStatus.mergeArray(status, results2); + }); + } else { + return ParseStatus.mergeArray(status, items); + } + } + get items() { + return this._def.items; + } + rest(rest) { + return new ZodTuple({ + ...this._def, + rest + }); } } - ZodUndefined.create = (params) => { - return new ZodUndefined({ - typeName: ZodFirstPartyTypeKind.ZodUndefined, + ZodTuple.create = (schemas, params) => { + if (!Array.isArray(schemas)) { + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + } + return new ZodTuple({ + items: schemas, + typeName: ZodFirstPartyTypeKind.ZodTuple, + rest: null, ...processCreateParams(params) }); }; - class ZodNull extends ZodType { + class ZodRecord extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.null) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { addIssueToContext(ctx, { code: ZodIssueCode.invalid_type, - expected: ZodParsedType.null, + expected: ZodParsedType.object, received: ctx.parsedType }); return INVALID; } - return OK(input.data); - } - } - ZodNull.create = (params) => { - return new ZodNull({ - typeName: ZodFirstPartyTypeKind.ZodNull, - ...processCreateParams(params) - }); - }; - class ZodAny extends ZodType { - constructor() { - super(...arguments); - this._any = true; - } - _parse(input) { - return OK(input.data); - } - } - ZodAny.create = (params) => { - return new ZodAny({ - typeName: ZodFirstPartyTypeKind.ZodAny, - ...processCreateParams(params) - }); - }; - class ZodUnknown extends ZodType { - constructor() { - super(...arguments); - this._unknown = true; + const pairs = []; + const keyType = this._def.keyType; + const valueType = this._def.valueType; + for (const key in ctx.data) { + pairs.push({ + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) + }); + } + if (ctx.common.async) { + return ParseStatus.mergeObjectAsync(status, pairs); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } } - _parse(input) { - return OK(input.data); + get element() { + return this._def.valueType; } - } - ZodUnknown.create = (params) => { - return new ZodUnknown({ - typeName: ZodFirstPartyTypeKind.ZodUnknown, - ...processCreateParams(params) - }); - }; - class ZodNever extends ZodType { - _parse(input) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.never, - received: ctx.parsedType + static create(first, second, third) { + if (second instanceof ZodType) { + return new ZodRecord({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(third) + }); + } + return new ZodRecord({ + keyType: ZodString.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(second) }); - return INVALID; } } - ZodNever.create = (params) => { - return new ZodNever({ - typeName: ZodFirstPartyTypeKind.ZodNever, - ...processCreateParams(params) - }); - }; - class ZodVoid extends ZodType { + class ZodMap extends ZodType { _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.undefined) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.map) { addIssueToContext(ctx, { code: ZodIssueCode.invalid_type, - expected: ZodParsedType.void, + expected: ZodParsedType.map, received: ctx.parsedType }); return INVALID; } - return OK(input.data); + const keyType = this._def.keyType; + const valueType = this._def.valueType; + const pairs = [...ctx.data.entries()].map(([key, value], index2) => { + return { + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index2, "key"])), + value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index2, "value"])) + }; + }); + if (ctx.common.async) { + const finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (const pair of pairs) { + const key = await pair.key; + const value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + const finalMap = /* @__PURE__ */ new Map(); + for (const pair of pairs) { + const key = pair.key; + const value = pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } } } - ZodVoid.create = (params) => { - return new ZodVoid({ - typeName: ZodFirstPartyTypeKind.ZodVoid, + ZodMap.create = (keyType, valueType, params) => { + return new ZodMap({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind.ZodMap, ...processCreateParams(params) }); }; - class ZodArray extends ZodType { + class ZodSet extends ZodType { _parse(input) { - const { ctx, status } = this._processInputParams(input); - const def = this._def; - if (ctx.parsedType !== ZodParsedType.array) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.set) { addIssueToContext(ctx, { code: ZodIssueCode.invalid_type, - expected: ZodParsedType.array, + expected: ZodParsedType.set, received: ctx.parsedType }); return INVALID; } - if (def.exactLength !== null) { - const tooBig = ctx.data.length > def.exactLength.value; - const tooSmall = ctx.data.length < def.exactLength.value; - if (tooBig || tooSmall) { - addIssueToContext(ctx, { - code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, - minimum: tooSmall ? def.exactLength.value : void 0, - maximum: tooBig ? def.exactLength.value : void 0, - type: "array", - inclusive: true, - exact: true, - message: def.exactLength.message - }); - status.dirty(); - } - } - if (def.minLength !== null) { - if (ctx.data.length < def.minLength.value) { + const def = this._def; + if (def.minSize !== null) { + if (ctx.data.size < def.minSize.value) { addIssueToContext(ctx, { code: ZodIssueCode.too_small, - minimum: def.minLength.value, - type: "array", + minimum: def.minSize.value, + type: "set", inclusive: true, exact: false, - message: def.minLength.message + message: def.minSize.message }); status.dirty(); } } - if (def.maxLength !== null) { - if (ctx.data.length > def.maxLength.value) { + if (def.maxSize !== null) { + if (ctx.data.size > def.maxSize.value) { addIssueToContext(ctx, { code: ZodIssueCode.too_big, - maximum: def.maxLength.value, - type: "array", + maximum: def.maxSize.value, + type: "set", inclusive: true, exact: false, - message: def.maxLength.message + message: def.maxSize.message }); status.dirty(); } } + const valueType = this._def.valueType; + function finalizeSet(elements2) { + const parsedSet = /* @__PURE__ */ new Set(); + for (const element of elements2) { + if (element.status === "aborted") + return INVALID; + if (element.status === "dirty") + status.dirty(); + parsedSet.add(element.value); + } + return { status: status.value, value: parsedSet }; + } + const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2))); if (ctx.common.async) { - return Promise.all([...ctx.data].map((item, i2) => { - return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); - })).then((result2) => { - return ParseStatus.mergeArray(status, result2); - }); + return Promise.all(elements).then((elements2) => finalizeSet(elements2)); + } else { + return finalizeSet(elements); } - const result = [...ctx.data].map((item, i2) => { - return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2)); - }); - return ParseStatus.mergeArray(status, result); - } - get element() { - return this._def.type; } - min(minLength, message) { - return new ZodArray({ + min(minSize, message) { + return new ZodSet({ ...this._def, - minLength: { value: minLength, message: errorUtil.toString(message) } + minSize: { value: minSize, message: errorUtil.toString(message) } }); } - max(maxLength, message) { - return new ZodArray({ + max(maxSize, message) { + return new ZodSet({ ...this._def, - maxLength: { value: maxLength, message: errorUtil.toString(message) } + maxSize: { value: maxSize, message: errorUtil.toString(message) } }); } - length(len, message) { - return new ZodArray({ - ...this._def, - exactLength: { value: len, message: errorUtil.toString(message) } - }); + size(size, message) { + return this.min(size, message).max(size, message); } nonempty(message) { return this.min(1, message); } } - ZodArray.create = (schema, params) => { - return new ZodArray({ - type: schema, - minLength: null, - maxLength: null, - exactLength: null, - typeName: ZodFirstPartyTypeKind.ZodArray, + ZodSet.create = (valueType, params) => { + return new ZodSet({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind.ZodSet, ...processCreateParams(params) }); }; - function deepPartialify(schema) { - if (schema instanceof ZodObject) { - const newShape = {}; - for (const key in schema.shape) { - const fieldSchema = schema.shape[key]; - newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); + class ZodFunction extends ZodType { + constructor() { + super(...arguments); + this.validate = this.implement; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.function) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.function, + received: ctx.parsedType + }); + return INVALID; } - return new ZodObject({ - ...schema._def, - shape: () => newShape + function makeArgsIssue(args, error) { + return makeIssue({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode.invalid_arguments, + argumentsError: error + } + }); + } + function makeReturnsIssue(returns, error) { + return makeIssue({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode.invalid_return_type, + returnTypeError: error + } + }); + } + const params = { errorMap: ctx.common.contextualErrorMap }; + const fn = ctx.data; + if (this._def.returns instanceof ZodPromise) { + return OK(async (...args) => { + const error = new ZodError([]); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { + error.addIssue(makeArgsIssue(args, e2)); + throw error; + }); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { + error.addIssue(makeReturnsIssue(result, e2)); + throw error; + }); + return parsedReturns; + }); + } else { + return OK((...args) => { + const parsedArgs = this._def.args.safeParse(args, params); + if (!parsedArgs.success) { + throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); + } + const result = fn(...parsedArgs.data); + const parsedReturns = this._def.returns.safeParse(result, params); + if (!parsedReturns.success) { + throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); + } + return parsedReturns.data; + }); + } + } + parameters() { + return this._def.args; + } + returnType() { + return this._def.returns; + } + args(...items) { + return new ZodFunction({ + ...this._def, + args: ZodTuple.create(items).rest(ZodUnknown.create()) }); - } else if (schema instanceof ZodArray) { - return new ZodArray({ - ...schema._def, - type: deepPartialify(schema.element) + } + returns(returnType) { + return new ZodFunction({ + ...this._def, + returns: returnType + }); + } + implement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + strictImplement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + static create(args, returns, params) { + return new ZodFunction({ + args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()), + returns: returns || ZodUnknown.create(), + typeName: ZodFirstPartyTypeKind.ZodFunction, + ...processCreateParams(params) }); - } else if (schema instanceof ZodOptional) { - return ZodOptional.create(deepPartialify(schema.unwrap())); - } else if (schema instanceof ZodNullable) { - return ZodNullable.create(deepPartialify(schema.unwrap())); - } else if (schema instanceof ZodTuple) { - return ZodTuple.create(schema.items.map((item) => deepPartialify(item))); - } else { - return schema; } } - class ZodObject extends ZodType { - constructor() { - super(...arguments); - this._cached = null; - this.nonstrict = this.passthrough; - this.augment = this.extend; + class ZodLazy extends ZodType { + get schema() { + return this._def.getter(); } - _getCached() { - if (this._cached !== null) - return this._cached; - const shape = this._def.shape(); - const keys2 = util.objectKeys(shape); - return this._cached = { shape, keys: keys2 }; + _parse(input) { + const { ctx } = this._processInputParams(input); + const lazySchema = this._def.getter(); + return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); } + } + ZodLazy.create = (getter, params) => { + return new ZodLazy({ + getter, + typeName: ZodFirstPartyTypeKind.ZodLazy, + ...processCreateParams(params) + }); + }; + class ZodLiteral extends ZodType { _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.object) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext(ctx2, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, - received: ctx2.parsedType + if (input.data !== this._def.value) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_literal, + expected: this._def.value }); return INVALID; } - const { status, ctx } = this._processInputParams(input); - const { shape, keys: shapeKeys } = this._getCached(); - const extraKeys = []; - if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { - for (const key in ctx.data) { - if (!shapeKeys.includes(key)) { - extraKeys.push(key); - } - } - } - const pairs = []; - for (const key of shapeKeys) { - const keyValidator = shape[key]; - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), - alwaysSet: key in ctx.data + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } + } + ZodLiteral.create = (value, params) => { + return new ZodLiteral({ + value, + typeName: ZodFirstPartyTypeKind.ZodLiteral, + ...processCreateParams(params) + }); + }; + function createZodEnum(values, params) { + return new ZodEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodEnum, + ...processCreateParams(params) + }); + } + class ZodEnum extends ZodType { + _parse(input) { + if (typeof input.data !== "string") { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type }); + return INVALID; } - if (this._def.catchall instanceof ZodNever) { - const unknownKeys = this._def.unknownKeys; - if (unknownKeys === "passthrough") { - for (const key of extraKeys) { - pairs.push({ - key: { status: "valid", value: key }, - value: { status: "valid", value: ctx.data[key] } - }); - } - } else if (unknownKeys === "strict") { - if (extraKeys.length > 0) { - addIssueToContext(ctx, { - code: ZodIssueCode.unrecognized_keys, - keys: extraKeys - }); - status.dirty(); - } - } else if (unknownKeys === "strip") - ; - else { - throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); - } - } else { - const catchall = this._def.catchall; - for (const key of extraKeys) { - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: catchall._parse( - new ParseInputLazyPath(ctx, value, ctx.path, key) - //, ctx.child(key), value, getParsedType(value) - ), - alwaysSet: key in ctx.data - }); - } - } - if (ctx.common.async) { - return Promise.resolve().then(async () => { - const syncPairs = []; - for (const pair of pairs) { - const key = await pair.key; - syncPairs.push({ - key, - value: await pair.value, - alwaysSet: pair.alwaysSet - }); - } - return syncPairs; - }).then((syncPairs) => { - return ParseStatus.mergeObjectSync(status, syncPairs); + if (this._def.values.indexOf(input.data) === -1) { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues }); - } else { - return ParseStatus.mergeObjectSync(status, pairs); + return INVALID; } + return OK(input.data); } - get shape() { - return this._def.shape(); + get options() { + return this._def.values; } - strict(message) { - errorUtil.errToObj; - return new ZodObject({ - ...this._def, - unknownKeys: "strict", - ...message !== void 0 ? { - errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; - if (issue.code === "unrecognized_keys") - return { - message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError - }; - return { - message: defaultError - }; - } - } : {} - }); + get enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; } - strip() { - return new ZodObject({ - ...this._def, - unknownKeys: "strip" - }); + get Values() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; } - passthrough() { - return new ZodObject({ - ...this._def, - unknownKeys: "passthrough" - }); + get Enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; } - // const AugmentFactory = - // (def: Def) => - // ( - // augmentation: Augmentation - // ): ZodObject< - // extendShape, Augmentation>, - // Def["unknownKeys"], - // Def["catchall"] - // > => { - // return new ZodObject({ - // ...def, - // shape: () => ({ - // ...def.shape(), - // ...augmentation, - // }), - // }) as any; - // }; - extend(augmentation) { - return new ZodObject({ - ...this._def, - shape: () => ({ - ...this._def.shape(), - ...augmentation - }) - }); + extract(values) { + return ZodEnum.create(values); } - /** - * Prior to zod@1.0.12 there was a bug in the - * inferred type of merged objects. Please - * upgrade if you are experiencing issues. - */ - merge(merging) { - const merged = new ZodObject({ - unknownKeys: merging._def.unknownKeys, - catchall: merging._def.catchall, - shape: () => ({ - ...this._def.shape(), - ...merging._def.shape() - }), - typeName: ZodFirstPartyTypeKind.ZodObject - }); - return merged; + exclude(values) { + return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + } + } + ZodEnum.create = createZodEnum; + class ZodNativeEnum extends ZodType { + _parse(input) { + const nativeEnumValues = util.getValidEnumValues(this._def.values); + const ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (nativeEnumValues.indexOf(input.data) === -1) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); } - // merge< - // Incoming extends AnyZodObject, - // Augmentation extends Incoming["shape"], - // NewOutput extends { - // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation - // ? Augmentation[k]["_output"] - // : k extends keyof Output - // ? Output[k] - // : never; - // }, - // NewInput extends { - // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation - // ? Augmentation[k]["_input"] - // : k extends keyof Input - // ? Input[k] - // : never; - // } - // >( - // merging: Incoming - // ): ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"], - // NewOutput, - // NewInput - // > { - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - setKey(key, schema) { - return this.augment({ [key]: schema }); + get enum() { + return this._def.values; } - // merge( - // merging: Incoming - // ): //ZodObject = (merging) => { - // ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"] - // > { - // // const mergedShape = objectUtil.mergeShapes( - // // this._def.shape(), - // // merging._def.shape() - // // ); - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - catchall(index2) { - return new ZodObject({ - ...this._def, - catchall: index2 - }); + } + ZodNativeEnum.create = (values, params) => { + return new ZodNativeEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodNativeEnum, + ...processCreateParams(params) + }); + }; + class ZodPromise extends ZodType { + unwrap() { + return this._def.type; } - pick(mask) { - const shape = {}; - util.objectKeys(mask).forEach((key) => { - if (mask[key] && this.shape[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ - ...this._def, - shape: () => shape - }); + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.promise, + received: ctx.parsedType + }); + return INVALID; + } + const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); + return OK(promisified.then((data2) => { + return this._def.type.parseAsync(data2, { + path: ctx.path, + errorMap: ctx.common.contextualErrorMap + }); + })); } - omit(mask) { - const shape = {}; - util.objectKeys(this.shape).forEach((key) => { - if (!mask[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ - ...this._def, - shape: () => shape - }); + } + ZodPromise.create = (schema, params) => { + return new ZodPromise({ + type: schema, + typeName: ZodFirstPartyTypeKind.ZodPromise, + ...processCreateParams(params) + }); + }; + class ZodEffects extends ZodType { + innerType() { + return this._def.schema; } - /** - * @deprecated - */ - deepPartial() { - return deepPartialify(this); + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; } - partial(mask) { - const newShape = {}; - util.objectKeys(this.shape).forEach((key) => { - const fieldSchema = this.shape[key]; - if (mask && !mask[key]) { - newShape[key] = fieldSchema; + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const effect = this._def.effect || null; + if (effect.type === "preprocess") { + const processed = effect.transform(ctx.data); + if (ctx.common.async) { + return Promise.resolve(processed).then((processed2) => { + return this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + }); + }); } else { - newShape[key] = fieldSchema.optional(); + return this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx + }); } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape - }); - } - required(mask) { - const newShape = {}; - util.objectKeys(this.shape).forEach((key) => { - if (mask && !mask[key]) { - newShape[key] = this.shape[key]; + } + const checkCtx = { + addIssue: (arg) => { + addIssueToContext(ctx, arg); + if (arg.fatal) { + status.abort(); + } else { + status.dirty(); + } + }, + get path() { + return ctx.path; + } + }; + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); + if (effect.type === "refinement") { + const executeRefinement = (acc) => { + const result = effect.refinement(acc, checkCtx); + if (ctx.common.async) { + return Promise.resolve(result); + } + if (result instanceof Promise) { + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + } + return acc; + }; + if (ctx.common.async === false) { + const inner = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + executeRefinement(inner.value); + return { status: status.value, value: inner.value }; } else { - const fieldSchema = this.shape[key]; - let newField = fieldSchema; - while (newField instanceof ZodOptional) { - newField = newField._def.innerType; + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + return executeRefinement(inner.value).then(() => { + return { status: status.value, value: inner.value }; + }); + }); + } + } + if (effect.type === "transform") { + if (ctx.common.async === false) { + const base3 = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (!isValid(base3)) + return base3; + const result = effect.transform(base3.value, checkCtx); + if (result instanceof Promise) { + throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); } - newShape[key] = newField; + return { status: status.value, value: result }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { + if (!isValid(base3)) + return base3; + return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); + }); } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape - }); + } + util.assertNever(effect); + } + } + ZodEffects.create = (schema, effect, params) => { + return new ZodEffects({ + schema, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect, + ...processCreateParams(params) + }); + }; + ZodEffects.createWithPreprocess = (preprocess, schema, params) => { + return new ZodEffects({ + schema, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind.ZodEffects, + ...processCreateParams(params) + }); + }; + class ZodOptional extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.undefined) { + return OK(void 0); + } + return this._def.innerType._parse(input); } - keyof() { - return createZodEnum(util.objectKeys(this.shape)); + unwrap() { + return this._def.innerType; } } - ZodObject.create = (shape, params) => { - return new ZodObject({ - shape: () => shape, - unknownKeys: "strip", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, + ZodOptional.create = (type2, params) => { + return new ZodOptional({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodOptional, ...processCreateParams(params) }); }; - ZodObject.strictCreate = (shape, params) => { - return new ZodObject({ - shape: () => shape, - unknownKeys: "strict", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, + class ZodNullable extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.null) { + return OK(null); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } + } + ZodNullable.create = (type2, params) => { + return new ZodNullable({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodNullable, ...processCreateParams(params) }); }; - ZodObject.lazycreate = (shape, params) => { - return new ZodObject({ - shape, - unknownKeys: "strip", - catchall: ZodNever.create(), - typeName: ZodFirstPartyTypeKind.ZodObject, + class ZodDefault extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + let data2 = ctx.data; + if (ctx.parsedType === ZodParsedType.undefined) { + data2 = this._def.defaultValue(); + } + return this._def.innerType._parse({ + data: data2, + path: ctx.path, + parent: ctx + }); + } + removeDefault() { + return this._def.innerType; + } + } + ZodDefault.create = (type2, params) => { + return new ZodDefault({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodDefault, + defaultValue: typeof params.default === "function" ? params.default : () => params.default, ...processCreateParams(params) }); }; - class ZodUnion extends ZodType { + class ZodCatch extends ZodType { _parse(input) { const { ctx } = this._processInputParams(input); - const options = this._def.options; - function handleResults(results2) { - for (const result of results2) { - if (result.result.status === "valid") { - return result.result; - } + const newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] } - for (const result of results2) { - if (result.result.status === "dirty") { - ctx.common.issues.push(...result.ctx.common.issues); - return result.result; - } + }; + const result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx } - const unionErrors = results2.map((result) => new ZodError(result.ctx.common.issues)); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union, - unionErrors - }); - return INVALID; - } - if (ctx.common.async) { - return Promise.all(options.map(async (option) => { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; + }); + if (isAsync(result)) { + return result.then((result2) => { return { - result: await option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }), - ctx: childCtx - }; - })).then(handleResults); - } else { - let dirty = void 0; - const issues = []; - for (const option of options) { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + } + }) }; - const result = option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }); - if (result.status === "valid") { - return result; - } else if (result.status === "dirty" && !dirty) { - dirty = { result, ctx: childCtx }; - } - if (childCtx.common.issues.length) { - issues.push(childCtx.common.issues); - } - } - if (dirty) { - ctx.common.issues.push(...dirty.ctx.common.issues); - return dirty.result; - } - const unionErrors = issues.map((issues2) => new ZodError(issues2)); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union, - unionErrors }); - return INVALID; + } else { + return { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + } + }) + }; } } - get options() { - return this._def.options; + removeCatch() { + return this._def.innerType; } } - ZodUnion.create = (types2, params) => { - return new ZodUnion({ - options: types2, - typeName: ZodFirstPartyTypeKind.ZodUnion, + ZodCatch.create = (type2, params) => { + return new ZodCatch({ + innerType: type2, + typeName: ZodFirstPartyTypeKind.ZodCatch, + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, ...processCreateParams(params) }); }; - const getDiscriminator = (type2) => { - if (type2 instanceof ZodLazy) { - return getDiscriminator(type2.schema); - } else if (type2 instanceof ZodEffects) { - return getDiscriminator(type2.innerType()); - } else if (type2 instanceof ZodLiteral) { - return [type2.value]; - } else if (type2 instanceof ZodEnum) { - return type2.options; - } else if (type2 instanceof ZodNativeEnum) { - return Object.keys(type2.enum); - } else if (type2 instanceof ZodDefault) { - return getDiscriminator(type2._def.innerType); - } else if (type2 instanceof ZodUndefined) { - return [void 0]; - } else if (type2 instanceof ZodNull) { - return [null]; - } else { - return null; - } - }; - class ZodDiscriminatedUnion extends ZodType { + class ZodNaN extends ZodType { _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.object) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.nan) { + const ctx = this._getOrReturnCtx(input); addIssueToContext(ctx, { code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, + expected: ZodParsedType.nan, received: ctx.parsedType }); - return INVALID; - } - const discriminator = this.discriminator; - const discriminatorValue = ctx.data[discriminator]; - const option = this.optionsMap.get(discriminatorValue); - if (!option) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_union_discriminator, - options: Array.from(this.optionsMap.keys()), - path: [discriminator] - }); - return INVALID; - } - if (ctx.common.async) { - return option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } else { - return option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); + return INVALID; } + return { status: "valid", value: input.data }; } - get discriminator() { - return this._def.discriminator; - } - get options() { - return this._def.options; - } - get optionsMap() { - return this._def.optionsMap; - } - /** - * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. - * However, it only allows a union of objects, all of which need to share a discriminator property. This property must - * have a different value for each object in the union. - * @param discriminator the name of the discriminator property - * @param types an array of object schemas - * @param params - */ - static create(discriminator, options, params) { - const optionsMap = /* @__PURE__ */ new Map(); - for (const type2 of options) { - const discriminatorValues = getDiscriminator(type2.shape[discriminator]); - if (!discriminatorValues) { - throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); - } - for (const value of discriminatorValues) { - if (optionsMap.has(value)) { - throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); - } - optionsMap.set(value, type2); - } - } - return new ZodDiscriminatedUnion({ - typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, - discriminator, - options, - optionsMap, - ...processCreateParams(params) + } + ZodNaN.create = (params) => { + return new ZodNaN({ + typeName: ZodFirstPartyTypeKind.ZodNaN, + ...processCreateParams(params) + }); + }; + const BRAND = Symbol("zod_brand"); + class ZodBranded extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const data2 = ctx.data; + return this._def.type._parse({ + data: data2, + path: ctx.path, + parent: ctx }); } - } - function mergeValues(a2, b2) { - const aType = getParsedType(a2); - const bType = getParsedType(b2); - if (a2 === b2) { - return { valid: true, data: a2 }; - } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) { - const bKeys = util.objectKeys(b2); - const sharedKeys = util.objectKeys(a2).filter((key) => bKeys.indexOf(key) !== -1); - const newObj = { ...a2, ...b2 }; - for (const key of sharedKeys) { - const sharedValue = mergeValues(a2[key], b2[key]); - if (!sharedValue.valid) { - return { valid: false }; - } - newObj[key] = sharedValue.data; - } - return { valid: true, data: newObj }; - } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { - if (a2.length !== b2.length) { - return { valid: false }; - } - const newArray = []; - for (let index2 = 0; index2 < a2.length; index2++) { - const itemA = a2[index2]; - const itemB = b2[index2]; - const sharedValue = mergeValues(itemA, itemB); - if (!sharedValue.valid) { - return { valid: false }; - } - newArray.push(sharedValue.data); - } - return { valid: true, data: newArray }; - } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a2 === +b2) { - return { valid: true, data: a2 }; - } else { - return { valid: false }; + unwrap() { + return this._def.type; } } - class ZodIntersection extends ZodType { + class ZodPipeline extends ZodType { _parse(input) { const { status, ctx } = this._processInputParams(input); - const handleParsed = (parsedLeft, parsedRight) => { - if (isAborted(parsedLeft) || isAborted(parsedRight)) { - return INVALID; - } - const merged = mergeValues(parsedLeft.value, parsedRight.value); - if (!merged.valid) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_intersection_types - }); - return INVALID; - } - if (isDirty(parsedLeft) || isDirty(parsedRight)) { - status.dirty(); - } - return { status: status.value, value: merged.data }; - }; if (ctx.common.async) { - return Promise.all([ - this._def.left._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), - this._def.right._parseAsync({ + const handleAsync = async () => { + const inResult = await this._def.in._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx - }) - ]).then(([left, right]) => handleParsed(left, right)); + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return DIRTY(inResult.value); + } else { + return this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + }; + return handleAsync(); } else { - return handleParsed(this._def.left._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), this._def.right._parseSync({ + const inResult = this._def.in._parseSync({ data: ctx.data, path: ctx.path, parent: ctx - })); + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return { + status: "dirty", + value: inResult.value + }; + } else { + return this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } } } + static create(a2, b2) { + return new ZodPipeline({ + in: a2, + out: b2, + typeName: ZodFirstPartyTypeKind.ZodPipeline + }); + } } - ZodIntersection.create = (left, right, params) => { - return new ZodIntersection({ - left, - right, - typeName: ZodFirstPartyTypeKind.ZodIntersection, - ...processCreateParams(params) - }); + const custom = (check, params = {}, fatal) => { + if (check) + return ZodAny.create().superRefine((data2, ctx) => { + var _a2, _b; + if (!check(data2)) { + const p2 = typeof params === "function" ? params(data2) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; + ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); + } + }); + return ZodAny.create(); + }; + const late = { + object: ZodObject.lazycreate + }; + var ZodFirstPartyTypeKind; + (function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; + ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; + ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; + ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; + ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; + ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; + ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; + ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; + ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; + ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; + ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; + ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; + ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; + ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; + ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; + ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; + ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; + ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; + ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; + ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; + ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; + ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; + ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; + ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; + ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; + ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; + ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; + ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; + ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; + ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; + ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; + ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; + ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; + ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; + ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; + })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); + const instanceOfType = (cls, params = { + message: `Input not instance of ${cls.name}` + }) => custom((data2) => data2 instanceof cls, params); + const stringType = ZodString.create; + const numberType = ZodNumber.create; + const nanType = ZodNaN.create; + const bigIntType = ZodBigInt.create; + const booleanType = ZodBoolean.create; + const dateType = ZodDate.create; + const symbolType = ZodSymbol.create; + const undefinedType = ZodUndefined.create; + const nullType = ZodNull.create; + const anyType = ZodAny.create; + const unknownType = ZodUnknown.create; + const neverType = ZodNever.create; + const voidType = ZodVoid.create; + const arrayType = ZodArray.create; + const objectType = ZodObject.create; + const strictObjectType = ZodObject.strictCreate; + const unionType = ZodUnion.create; + const discriminatedUnionType = ZodDiscriminatedUnion.create; + const intersectionType = ZodIntersection.create; + const tupleType = ZodTuple.create; + const recordType = ZodRecord.create; + const mapType = ZodMap.create; + const setType = ZodSet.create; + const functionType = ZodFunction.create; + const lazyType = ZodLazy.create; + const literalType = ZodLiteral.create; + const enumType = ZodEnum.create; + const nativeEnumType = ZodNativeEnum.create; + const promiseType = ZodPromise.create; + const effectsType = ZodEffects.create; + const optionalType = ZodOptional.create; + const nullableType = ZodNullable.create; + const preprocessType = ZodEffects.createWithPreprocess; + const pipelineType = ZodPipeline.create; + const ostring = () => stringType().optional(); + const onumber = () => numberType().optional(); + const oboolean = () => booleanType().optional(); + const coerce = { + string: (arg) => ZodString.create({ ...arg, coerce: true }), + number: (arg) => ZodNumber.create({ ...arg, coerce: true }), + boolean: (arg) => ZodBoolean.create({ + ...arg, + coerce: true + }), + bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }), + date: (arg) => ZodDate.create({ ...arg, coerce: true }) }; - class ZodTuple extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.array) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.array, - received: ctx.parsedType - }); - return INVALID; - } - if (ctx.data.length < this._def.items.length) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - return INVALID; - } - const rest = this._def.rest; - if (!rest && ctx.data.length > this._def.items.length) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - status.dirty(); - } - const items = [...ctx.data].map((item, itemIndex) => { - const schema = this._def.items[itemIndex] || this._def.rest; - if (!schema) - return null; - return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)); - }).filter((x2) => !!x2); - if (ctx.common.async) { - return Promise.all(items).then((results2) => { - return ParseStatus.mergeArray(status, results2); - }); - } else { - return ParseStatus.mergeArray(status, items); - } - } - get items() { - return this._def.items; - } - rest(rest) { - return new ZodTuple({ - ...this._def, - rest - }); + const NEVER = INVALID; + var z$1 = /* @__PURE__ */ Object.freeze({ + __proto__: null, + defaultErrorMap: errorMap, + setErrorMap, + getErrorMap, + makeIssue, + EMPTY_PATH, + addIssueToContext, + ParseStatus, + INVALID, + DIRTY, + OK, + isAborted, + isDirty, + isValid, + isAsync, + get util() { + return util; + }, + get objectUtil() { + return objectUtil; + }, + ZodParsedType, + getParsedType, + ZodType, + ZodString, + ZodNumber, + ZodBigInt, + ZodBoolean, + ZodDate, + ZodSymbol, + ZodUndefined, + ZodNull, + ZodAny, + ZodUnknown, + ZodNever, + ZodVoid, + ZodArray, + ZodObject, + ZodUnion, + ZodDiscriminatedUnion, + ZodIntersection, + ZodTuple, + ZodRecord, + ZodMap, + ZodSet, + ZodFunction, + ZodLazy, + ZodLiteral, + ZodEnum, + ZodNativeEnum, + ZodPromise, + ZodEffects, + ZodTransformer: ZodEffects, + ZodOptional, + ZodNullable, + ZodDefault, + ZodCatch, + ZodNaN, + BRAND, + ZodBranded, + ZodPipeline, + custom, + Schema: ZodType, + ZodSchema: ZodType, + late, + get ZodFirstPartyTypeKind() { + return ZodFirstPartyTypeKind; + }, + coerce, + any: anyType, + array: arrayType, + bigint: bigIntType, + boolean: booleanType, + date: dateType, + discriminatedUnion: discriminatedUnionType, + effect: effectsType, + "enum": enumType, + "function": functionType, + "instanceof": instanceOfType, + intersection: intersectionType, + lazy: lazyType, + literal: literalType, + map: mapType, + nan: nanType, + nativeEnum: nativeEnumType, + never: neverType, + "null": nullType, + nullable: nullableType, + number: numberType, + object: objectType, + oboolean, + onumber, + optional: optionalType, + ostring, + pipeline: pipelineType, + preprocess: preprocessType, + promise: promiseType, + record: recordType, + set: setType, + strictObject: strictObjectType, + string: stringType, + symbol: symbolType, + transformer: effectsType, + tuple: tupleType, + "undefined": undefinedType, + union: unionType, + unknown: unknownType, + "void": voidType, + NEVER, + ZodIssueCode, + quotelessJson, + ZodError + }); + const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; + const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; + const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; + const aleoTransitionIdRegex = /^au1[a-z0-9]{58}$/i; + const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; + const aleoFieldRegex = /^\d+field$/; + const aleoU32 = /^\d+u32$/; + const aleoU64 = /^\d+u64$/; + const zodAddress = z$1.string().regex(aleoAddressRegex); + const zodViewKey = z$1.string().regex(aleoViewKeyRegex); + const zodPrivateKey = z$1.string().regex(aleoPrivateKeyRegex); + z$1.string().regex(aleoTransitionIdRegex); + const zodTransactionId = z$1.string().regex(aleoTransactionIdRegex); + const zodField = z$1.string().regex(aleoFieldRegex); + const zodU32 = z$1.string().regex(aleoU32); + const zodU64 = z$1.string().regex(aleoU64); + var InputOutputType; + (function(InputOutputType2) { + InputOutputType2["Record"] = "record"; + InputOutputType2["OutputRecord"] = "outputRecord"; + InputOutputType2["Public"] = "public"; + InputOutputType2["Private"] = "private"; + InputOutputType2["Constant"] = "constant"; + InputOutputType2["Future"] = "future"; + InputOutputType2["ExternalRecord"] = "external_record"; + })(InputOutputType || (InputOutputType = {})); + exports2.EventType = void 0; + (function(EventType) { + EventType["Deploy"] = "Deploy"; + EventType["Execute"] = "Execute"; + EventType["Send"] = "Send"; + EventType["Receive"] = "Receive"; + EventType["Join"] = "Join"; + EventType["Split"] = "Split"; + EventType["Shield"] = "Shield"; + EventType["Unshield"] = "Unshield"; + EventType["Referral"] = "Referral"; + EventType["Points"] = "Points"; + EventType["Raffle"] = "Raffle"; + })(exports2.EventType || (exports2.EventType = {})); + exports2.EventStatus = void 0; + (function(EventStatus) { + EventStatus["Creating"] = "Creating"; + EventStatus["Pending"] = "Pending"; + EventStatus["Settled"] = "Settled"; + EventStatus["Failed"] = "Failed"; + })(exports2.EventStatus || (exports2.EventStatus = {})); + exports2.Visibility = void 0; + (function(Visibility) { + Visibility["Private"] = "Private"; + Visibility["Public"] = "Public"; + })(exports2.Visibility || (exports2.Visibility = {})); + exports2.Network = void 0; + (function(Network) { + Network["AleoTestnet"] = "AleoTestnet"; + Network["AleoCanarynet"] = "AleoCanarynet"; + Network["AleoMainnet"] = "AleoMainnet"; + })(exports2.Network || (exports2.Network = {})); + const zodEventType = z$1.nativeEnum(exports2.EventType); + const zodEventStatus = z$1.nativeEnum(exports2.EventStatus); + const zodNetwork = z$1.nativeEnum(exports2.Network); + const zodVisibility = z$1.nativeEnum(exports2.Visibility); + const wc_aleo_methods = [ + "decrypt", + "disconnect", + "getSelectedAccount", + "getBalance", + "getRecords", + "requestCreateEvent", + "getEvent", + "getEvents", + "createSharedState", + "importSharedState", + "requestSignature" + ]; + const wc_required_aleo_chains = ["aleo:1"]; + const wc_optional_aleo_chains = [ + "aleo:0" + // for eventual mainnet + ]; + const wc_aleo_chains = [ + ...wc_required_aleo_chains, + ...wc_optional_aleo_chains + ]; + const wc_events = [ + "chainChanged", + "accountSelected", + "selectedAccountSynced", + "sharedAccountSynced" + ]; + const projectId = "f0aaeffe71b636da453fce042d79d723"; + function isAndroid() { + if (typeof navigator === "undefined") { + return false; } + return /Android/i.test(navigator.userAgent); } - ZodTuple.create = (schemas, params) => { - if (!Array.isArray(schemas)) { - throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + const web3modal_puzzle_props_android = { + projectId, + chains: wc_aleo_chains, + enableExplorer: true, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png" } - return new ZodTuple({ - items: schemas, - typeName: ZodFirstPartyTypeKind.ZodTuple, - rest: null, - ...processCreateParams(params) - }); }; - class ZodRecord extends ZodType { - get keySchema() { - return this._def.keyType; - } - get valueSchema() { - return this._def.valueType; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.object) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.object, - received: ctx.parsedType - }); - return INVALID; + const web3modal_puzzle_props_default = { + projectId, + chains: wc_aleo_chains, + enableExplorer: false, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } } - const pairs = []; - const keyType = this._def.keyType; - const valueType = this._def.valueType; - for (const key in ctx.data) { - pairs.push({ - key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), - value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) - }); + ], + desktopWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "", + universal: "https://walletconnect.puzzle.online/" + } + }, + { + id: "avail", + name: "Avail Wallet", + links: { + native: "avail://", + universal: "https://avail.global" + } } - if (ctx.common.async) { - return ParseStatus.mergeObjectAsync(status, pairs); - } else { - return ParseStatus.mergeObjectSync(status, pairs); + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png", + avail: "https://i.imgur.com/GxNn8BO.png" + } + }; + const web3modal_puzzle_props = isAndroid() ? web3modal_puzzle_props_android : web3modal_puzzle_props_default; + const signClient_puzzleProps = { + requiredNamespaces: { + aleo: { + methods: wc_aleo_methods, + chains: web3modal_puzzle_props.chains, + events: wc_events } } - get element() { - return this._def.valueType; + }; + const networkToChainId = (network, includePrefix = true) => { + let chain; + switch (network) { + case exports2.Network.AleoMainnet: + chain = "aleo:0"; + break; + case exports2.Network.AleoCanarynet: + chain = "aleo:0"; + break; + case exports2.Network.AleoTestnet: + chain = "aleo:1"; + break; } - static create(first, second, third) { - if (second instanceof ZodType) { - return new ZodRecord({ - keyType: first, - valueType: second, - typeName: ZodFirstPartyTypeKind.ZodRecord, - ...processCreateParams(third) - }); - } - return new ZodRecord({ - keyType: ZodString.create(), - valueType: first, - typeName: ZodFirstPartyTypeKind.ZodRecord, - ...processCreateParams(second) - }); + return includePrefix ? chain : chain.replace("aleo:", ""); + }; + const chainIdToNetwork = (chainId) => { + switch (chainId) { + case "aleo:0": + return exports2.Network.AleoCanarynet; + case "aleo:1": + return exports2.Network.AleoTestnet; + } + }; + const name = "@puzzlehq/sdk-core"; + const displayName = "Puzzle SDK"; + const version$1 = "0.4.0"; + const description = "Your portal to privacy"; + const main = "./dist/puzzle.cjs.js"; + const module2 = "./dist/puzzle.es.js"; + const browser$2 = "./dist/puzzle.umd.js"; + const types = "./dist/types/src/index.d.ts"; + const exports$1 = { + ".": { + "import": "./dist/puzzle.es.js", + require: "./dist/puzzle.cjs.js", + browser: "./dist/puzzle.umd.js", + types: "./dist/types/src/index.d.ts" } + }; + const type = "module"; + const scripts = { + "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", + "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, + build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", + "type-check": "tsc --noEmit" + }; + const repository = { + type: "git", + url: "git+https://github.com/puzzlehq/puzzle-sdk.git" + }; + const dependencies = { + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", + "@walletconnect/types": "^2.11.2", + "@walletconnect/utils": "^2.11.2", + debug: "^4.3.4", + events: "^3.3.0", + ws: "^8.16.0" + }; + const peerDependencies = { + buffer: "^6.0.3" + }; + const keywords = [ + "puzzle", + "cryptocurrency wallet", + "privacy", + "aleo", + "web3", + "crypto", + "typescript" + ]; + const author = "Puzzle"; + const license = "ISC"; + const bugs = { + url: "https://github.com/puzzlehq/puzzle-sdk/issues" + }; + const homepage = "https://github.com/puzzlehq/puzzle-sdk#readme"; + const pkg = { + name, + displayName, + version: version$1, + description, + main, + module: module2, + browser: browser$2, + types, + "private": false, + exports: exports$1, + type, + scripts, + repository, + dependencies, + peerDependencies, + keywords, + author, + license, + bugs, + homepage + }; + var On = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; + function A0(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r2 = function() { + return t2.apply(this, arguments); + }; + r2.prototype = t2.prototype; + } else + r2 = {}; + return Object.defineProperty(r2, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n2 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r2, i2, n2.get ? n2 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r2; } - class ZodMap extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.map) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.map, - received: ctx.parsedType - }); - return INVALID; - } - const keyType = this._def.keyType; - const valueType = this._def.valueType; - const pairs = [...ctx.data.entries()].map(([key, value], index2) => { - return { - key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index2, "key"])), - value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index2, "value"])) - }; - }); - if (ctx.common.async) { - const finalMap = /* @__PURE__ */ new Map(); - return Promise.resolve().then(async () => { - for (const pair of pairs) { - const key = await pair.key; - const value = await pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - }); - } else { - const finalMap = /* @__PURE__ */ new Map(); - for (const pair of pairs) { - const key = pair.key; - const value = pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); + var Pn = { exports: {} }; + /** + * [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 + */ + (function(e2) { + (function() { + var t2 = "input is invalid type", r2 = "finalize already called", i2 = typeof window == "object", n2 = i2 ? window : {}; + n2.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h2 = !n2.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h2 ? n2 = On : o2 && (n2 = self); + var p2 = !n2.JS_SHA3_NO_COMMON_JS && true && e2.exports, b2 = !n2.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m2 = "0123456789abcdef".split(""), w2 = [31, 7936, 2031616, 520093696], y2 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n2.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u2) { + return Object.prototype.toString.call(u2) === "[object Array]"; + }), b2 && (n2.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u2) { + return typeof u2 == "object" && u2.buffer && u2.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u2, E2, _2) { + return function(B2) { + return new s2(u2, E2, u2).update(B2)[_2](); + }; + }, H2 = function(u2, E2, _2) { + return function(B2, R2) { + return new s2(u2, E2, R2).update(B2)[_2](); + }; + }, z2 = function(u2, E2, _2) { + return function(B2, R2, T2, P2) { + return f2["cshake" + u2].update(B2, R2, T2, P2)[_2](); + }; + }, Pt2 = function(u2, E2, _2) { + return function(B2, R2, T2, P2) { + return f2["kmac" + u2].update(B2, R2, T2, P2)[_2](); + }; + }, W2 = function(u2, E2, _2, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u2[T2] = E2(_2, B2, T2); + } + return u2; + }, Rt2 = function(u2, E2) { + var _2 = G2(u2, E2, "hex"); + return _2.create = function() { + return new s2(u2, E2, u2); + }, _2.update = function(B2) { + return _2.create().update(B2); + }, W2(_2, G2, u2, E2); + }, Yt2 = function(u2, E2) { + var _2 = H2(u2, E2, "hex"); + return _2.create = function(B2) { + return new s2(u2, E2, B2); + }, _2.update = function(B2, R2) { + return _2.create(R2).update(B2); + }, W2(_2, H2, u2, E2); + }, Y2 = function(u2, E2) { + var _2 = Bt2[u2], B2 = z2(u2, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f2["shake" + u2].create(R2) : new s2(u2, E2, R2).bytepad([T2, P2], _2); + }, B2.update = function(R2, T2, P2, O2) { + return B2.create(T2, P2, O2).update(R2); + }, W2(B2, z2, u2, E2); + }, Vt2 = function(u2, E2) { + var _2 = Bt2[u2], B2 = Pt2(u2, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v2(u2, E2, T2).bytepad(["KMAC", P2], _2).bytepad([R2], _2); + }, B2.update = function(R2, T2, P2, O2) { + return B2.create(R2, P2, O2).update(T2); + }, W2(B2, Pt2, u2, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w2, bits: U2, createMethod: Yt2 }, { name: "cshake", padding: y2, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y2, bits: U2, createMethod: Vt2 }], f2 = {}, a2 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d2 = A2[c2], g2 = d2.bits, x2 = 0; x2 < g2.length; ++x2) { + var M2 = d2.name + "_" + g2[x2]; + if (a2.push(M2), f2[M2] = d2.createMethod(g2[x2], d2.padding), d2.name !== "sha3") { + var l2 = d2.name + g2[x2]; + a2.push(l2), f2[l2] = f2[M2]; } - finalMap.set(key.value, value.value); } - return { status: status.value, value: finalMap }; - } - } - } - ZodMap.create = (keyType, valueType, params) => { - return new ZodMap({ - valueType, - keyType, - typeName: ZodFirstPartyTypeKind.ZodMap, - ...processCreateParams(params) - }); - }; - class ZodSet extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.set) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.set, - received: ctx.parsedType - }); - return INVALID; + function s2(u2, E2, _2) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _2, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u2 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _2 >> 5, this.extraBytes = (_2 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; } - const def = this._def; - if (def.minSize !== null) { - if (ctx.data.size < def.minSize.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_small, - minimum: def.minSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.minSize.message - }); - status.dirty(); + s2.prototype.update = function(u2) { + if (this.finalized) + throw new Error(r2); + var E2, _2 = typeof u2; + if (_2 !== "string") { + if (_2 === "object") { + if (u2 === null) + throw new Error(t2); + if (b2 && u2.constructor === ArrayBuffer) + u2 = new Uint8Array(u2); + else if (!Array.isArray(u2) && (!b2 || !ArrayBuffer.isView(u2))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u2.length, P2 = this.blockCount, O2 = 0, Ct2 = this.s, D2, q2; O2 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O2 < T2 && D2 < R2; ++O2) + B2[D2 >> 2] |= u2[O2] << N2[D2++ & 3]; + else + for (D2 = this.start; O2 < T2 && D2 < R2; ++O2) + q2 = u2.charCodeAt(O2), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u2.charCodeAt(++O2) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; } + return this; + }, s2.prototype.encode = function(u2, E2) { + var _2 = u2 & 255, B2 = 1, R2 = [_2]; + for (u2 = u2 >> 8, _2 = u2 & 255; _2 > 0; ) + R2.unshift(_2), u2 = u2 >> 8, _2 = u2 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u2) { + var E2, _2 = typeof u2; + if (_2 !== "string") { + if (_2 === "object") { + if (u2 === null) + throw new Error(t2); + if (b2 && u2.constructor === ArrayBuffer) + u2 = new Uint8Array(u2); + else if (!Array.isArray(u2) && (!b2 || !ArrayBuffer.isView(u2))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u2.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u2.length; ++T2) { + var P2 = u2.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u2.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u2), B2; + }, s2.prototype.bytepad = function(u2, E2) { + for (var _2 = this.encode(E2), B2 = 0; B2 < u2.length; ++B2) + _2 += this.encodeString(u2[B2]); + var R2 = E2 - _2 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u2 = this.blocks, E2 = this.lastByteIndex, _2 = this.blockCount, B2 = this.s; + if (u2[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u2[0] = u2[_2], E2 = 1; E2 < _2 + 1; ++E2) + u2[E2] = 0; + for (u2[_2 - 1] |= 2147483648, E2 = 0; E2 < _2; ++E2) + B2[E2] ^= u2[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u2 = this.blockCount, E2 = this.s, _2 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O2; T2 < _2; ) { + for (R2 = 0; R2 < u2 && T2 < _2; ++R2, ++T2) + O2 = E2[R2], P2 += m2[O2 >> 4 & 15] + m2[O2 & 15] + m2[O2 >> 12 & 15] + m2[O2 >> 8 & 15] + m2[O2 >> 20 & 15] + m2[O2 >> 16 & 15] + m2[O2 >> 28 & 15] + m2[O2 >> 24 & 15]; + T2 % u2 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O2 = E2[R2], P2 += m2[O2 >> 4 & 15] + m2[O2 & 15], B2 > 1 && (P2 += m2[O2 >> 12 & 15] + m2[O2 >> 8 & 15]), B2 > 2 && (P2 += m2[O2 >> 20 & 15] + m2[O2 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u2 = this.blockCount, E2 = this.s, _2 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O2; + B2 ? O2 = new ArrayBuffer(_2 + 1 << 2) : O2 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O2); T2 < _2; ) { + for (R2 = 0; R2 < u2 && T2 < _2; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u2 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O2 = O2.slice(0, P2)), O2; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u2 = this.blockCount, E2 = this.s, _2 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O2, Ct2; T2 < _2; ) { + for (R2 = 0; R2 < u2 && T2 < _2; ++R2, ++T2) + O2 = T2 << 2, Ct2 = E2[R2], P2[O2] = Ct2 & 255, P2[O2 + 1] = Ct2 >> 8 & 255, P2[O2 + 2] = Ct2 >> 16 & 255, P2[O2 + 3] = Ct2 >> 24 & 255; + T2 % u2 === 0 && k2(E2); + } + return B2 && (O2 = T2 << 2, Ct2 = E2[R2], P2[O2] = Ct2 & 255, B2 > 1 && (P2[O2 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O2 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v2(u2, E2, _2) { + s2.call(this, u2, E2, _2); } - if (def.maxSize !== null) { - if (ctx.data.size > def.maxSize.value) { - addIssueToContext(ctx, { - code: ZodIssueCode.too_big, - maximum: def.maxSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.maxSize.message - }); - status.dirty(); + v2.prototype = new s2(), v2.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u2) { + var E2, _2, B2, R2, T2, P2, O2, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te2, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le2, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne2, Ie2; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u2[0] ^ u2[10] ^ u2[20] ^ u2[30] ^ u2[40], T2 = u2[1] ^ u2[11] ^ u2[21] ^ u2[31] ^ u2[41], P2 = u2[2] ^ u2[12] ^ u2[22] ^ u2[32] ^ u2[42], O2 = u2[3] ^ u2[13] ^ u2[23] ^ u2[33] ^ u2[43], Ct2 = u2[4] ^ u2[14] ^ u2[24] ^ u2[34] ^ u2[44], D2 = u2[5] ^ u2[15] ^ u2[25] ^ u2[35] ^ u2[45], q2 = u2[6] ^ u2[16] ^ u2[26] ^ u2[36] ^ u2[46], De2 = u2[7] ^ u2[17] ^ u2[27] ^ u2[37] ^ u2[47], X2 = u2[8] ^ u2[18] ^ u2[28] ^ u2[38] ^ u2[48], Z2 = u2[9] ^ u2[19] ^ u2[29] ^ u2[39] ^ u2[49], E2 = X2 ^ (P2 << 1 | O2 >>> 31), _2 = Z2 ^ (O2 << 1 | P2 >>> 31), u2[0] ^= E2, u2[1] ^= _2, u2[10] ^= E2, u2[11] ^= _2, u2[20] ^= E2, u2[21] ^= _2, u2[30] ^= E2, u2[31] ^= _2, u2[40] ^= E2, u2[41] ^= _2, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _2 = T2 ^ (D2 << 1 | Ct2 >>> 31), u2[2] ^= E2, u2[3] ^= _2, u2[12] ^= E2, u2[13] ^= _2, u2[22] ^= E2, u2[23] ^= _2, u2[32] ^= E2, u2[33] ^= _2, u2[42] ^= E2, u2[43] ^= _2, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _2 = O2 ^ (De2 << 1 | q2 >>> 31), u2[4] ^= E2, u2[5] ^= _2, u2[14] ^= E2, u2[15] ^= _2, u2[24] ^= E2, u2[25] ^= _2, u2[34] ^= E2, u2[35] ^= _2, u2[44] ^= E2, u2[45] ^= _2, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _2 = D2 ^ (Z2 << 1 | X2 >>> 31), u2[6] ^= E2, u2[7] ^= _2, u2[16] ^= E2, u2[17] ^= _2, u2[26] ^= E2, u2[27] ^= _2, u2[36] ^= E2, u2[37] ^= _2, u2[46] ^= E2, u2[47] ^= _2, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _2 = De2 ^ (T2 << 1 | R2 >>> 31), u2[8] ^= E2, u2[9] ^= _2, u2[18] ^= E2, u2[19] ^= _2, u2[28] ^= E2, u2[29] ^= _2, u2[38] ^= E2, u2[39] ^= _2, u2[48] ^= E2, u2[49] ^= _2, Fe2 = u2[0], $2 = u2[1], yt2 = u2[11] << 4 | u2[10] >>> 28, Je2 = u2[10] << 4 | u2[11] >>> 28, at2 = u2[20] << 3 | u2[21] >>> 29, Ke2 = u2[21] << 3 | u2[20] >>> 29, Ee2 = u2[31] << 9 | u2[30] >>> 23, Se2 = u2[30] << 9 | u2[31] >>> 23, gt2 = u2[40] << 18 | u2[41] >>> 14, At2 = u2[41] << 18 | u2[40] >>> 14, lt2 = u2[2] << 1 | u2[3] >>> 31, ze2 = u2[3] << 1 | u2[2] >>> 31, tt2 = u2[13] << 12 | u2[12] >>> 20, Te2 = u2[12] << 12 | u2[13] >>> 20, wt2 = u2[22] << 10 | u2[23] >>> 22, xt2 = u2[23] << 10 | u2[22] >>> 22, ut2 = u2[33] << 13 | u2[32] >>> 19, ht2 = u2[32] << 13 | u2[33] >>> 19, Ne2 = u2[42] << 2 | u2[43] >>> 30, Ie2 = u2[43] << 2 | u2[42] >>> 30, St2 = u2[5] << 30 | u2[4] >>> 2, Nt2 = u2[4] << 30 | u2[5] >>> 2, dt2 = u2[14] << 6 | u2[15] >>> 26, pt2 = u2[15] << 6 | u2[14] >>> 26, et2 = u2[25] << 11 | u2[24] >>> 21, rt2 = u2[24] << 11 | u2[25] >>> 21, Ge2 = u2[34] << 15 | u2[35] >>> 17, Mt2 = u2[35] << 15 | u2[34] >>> 17, He2 = u2[45] << 29 | u2[44] >>> 3, ct2 = u2[44] << 29 | u2[45] >>> 3, ft2 = u2[6] << 28 | u2[7] >>> 4, ot2 = u2[7] << 28 | u2[6] >>> 4, Ve2 = u2[17] << 23 | u2[16] >>> 9, It2 = u2[16] << 23 | u2[17] >>> 9, Le2 = u2[26] << 25 | u2[27] >>> 7, vt2 = u2[27] << 25 | u2[26] >>> 7, Ue2 = u2[36] << 21 | u2[37] >>> 11, it2 = u2[37] << 21 | u2[36] >>> 11, Et2 = u2[47] << 24 | u2[46] >>> 8, Ye2 = u2[46] << 24 | u2[47] >>> 8, Qe2 = u2[8] << 27 | u2[9] >>> 5, bt2 = u2[9] << 27 | u2[8] >>> 5, qe2 = u2[18] << 20 | u2[19] >>> 12, st2 = u2[19] << 20 | u2[18] >>> 12, _t2 = u2[29] << 7 | u2[28] >>> 25, Me2 = u2[28] << 7 | u2[29] >>> 25, mt2 = u2[38] << 8 | u2[39] >>> 24, je2 = u2[39] << 8 | u2[38] >>> 24, nt2 = u2[48] << 14 | u2[49] >>> 18, ke2 = u2[49] << 14 | u2[48] >>> 18, u2[0] = Fe2 ^ ~tt2 & et2, u2[1] = $2 ^ ~Te2 & rt2, u2[10] = ft2 ^ ~qe2 & at2, u2[11] = ot2 ^ ~st2 & Ke2, u2[20] = lt2 ^ ~dt2 & Le2, u2[21] = ze2 ^ ~pt2 & vt2, u2[30] = Qe2 ^ ~yt2 & wt2, u2[31] = bt2 ^ ~Je2 & xt2, u2[40] = St2 ^ ~Ve2 & _t2, u2[41] = Nt2 ^ ~It2 & Me2, u2[2] = tt2 ^ ~et2 & Ue2, u2[3] = Te2 ^ ~rt2 & it2, u2[12] = qe2 ^ ~at2 & ut2, u2[13] = st2 ^ ~Ke2 & ht2, u2[22] = dt2 ^ ~Le2 & mt2, u2[23] = pt2 ^ ~vt2 & je2, u2[32] = yt2 ^ ~wt2 & Ge2, u2[33] = Je2 ^ ~xt2 & Mt2, u2[42] = Ve2 ^ ~_t2 & Ee2, u2[43] = It2 ^ ~Me2 & Se2, u2[4] = et2 ^ ~Ue2 & nt2, u2[5] = rt2 ^ ~it2 & ke2, u2[14] = at2 ^ ~ut2 & He2, u2[15] = Ke2 ^ ~ht2 & ct2, u2[24] = Le2 ^ ~mt2 & gt2, u2[25] = vt2 ^ ~je2 & At2, u2[34] = wt2 ^ ~Ge2 & Et2, u2[35] = xt2 ^ ~Mt2 & Ye2, u2[44] = _t2 ^ ~Ee2 & Ne2, u2[45] = Me2 ^ ~Se2 & Ie2, u2[6] = Ue2 ^ ~nt2 & Fe2, u2[7] = it2 ^ ~ke2 & $2, u2[16] = ut2 ^ ~He2 & ft2, u2[17] = ht2 ^ ~ct2 & ot2, u2[26] = mt2 ^ ~gt2 & lt2, u2[27] = je2 ^ ~At2 & ze2, u2[36] = Ge2 ^ ~Et2 & Qe2, u2[37] = Mt2 ^ ~Ye2 & bt2, u2[46] = Ee2 ^ ~Ne2 & St2, u2[47] = Se2 ^ ~Ie2 & Nt2, u2[8] = nt2 ^ ~Fe2 & tt2, u2[9] = ke2 ^ ~$2 & Te2, u2[18] = He2 ^ ~ft2 & qe2, u2[19] = ct2 ^ ~ot2 & st2, u2[28] = gt2 ^ ~lt2 & dt2, u2[29] = At2 ^ ~ze2 & pt2, u2[38] = Et2 ^ ~Qe2 & yt2, u2[39] = Ye2 ^ ~bt2 & Je2, u2[48] = Ne2 ^ ~St2 & Ve2, u2[49] = Ie2 ^ ~Nt2 & It2, u2[0] ^= C2[B2], u2[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f2; + else + for (c2 = 0; c2 < a2.length; ++c2) + n2[a2[c2]] = f2[a2[c2]]; + })(); + })(Pn); + const y0 = "logger/5.7.0"; + let Dn = false, Fn = false; + const Cr = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; + let Tn = Cr.default, gi = null; + function w0() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); } - } - const valueType = this._def.valueType; - function finalizeSet(elements2) { - const parsedSet = /* @__PURE__ */ new Set(); - for (const element of elements2) { - if (element.status === "aborted") - return INVALID; - if (element.status === "dirty") - status.dirty(); - parsedSet.add(element.value); + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; + } + return null; + } + const Un = w0(); + var Ai; + (function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; + })(Ai || (Ai = {})); + var re$1; + (function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; + })(re$1 || (re$1 = {})); + const kn = "0123456789abcdef"; + let L$2 = class L2 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); + } + _log(t2, r2) { + const i2 = t2.toLowerCase(); + Cr[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn > Cr[i2]) && console.log.apply(console, r2); + } + debug(...t2) { + this._log(L2.levels.DEBUG, t2); + } + info(...t2) { + this._log(L2.levels.INFO, t2); + } + warn(...t2) { + this._log(L2.levels.WARNING, t2); + } + makeError(t2, r2, i2) { + if (Fn) + return this.makeError("censored error", r2, {}); + r2 || (r2 = L2.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n2 = []; + Object.keys(i2).forEach((b2) => { + const m2 = i2[b2]; + try { + if (m2 instanceof Uint8Array) { + let w2 = ""; + for (let y2 = 0; y2 < m2.length; y2++) + w2 += kn[m2[y2] >> 4], w2 += kn[m2[y2] & 15]; + n2.push(b2 + "=Uint8Array(0x" + w2 + ")"); + } else + n2.push(b2 + "=" + JSON.stringify(m2)); + } catch { + n2.push(b2 + "=" + JSON.stringify(i2[b2].toString())); + } + }), n2.push(`code=${r2}`), n2.push(`version=${this.version}`); + const o2 = t2; + let h2 = ""; + switch (r2) { + case re$1.NUMERIC_FAULT: { + h2 = "NUMERIC_FAULT"; + const b2 = t2; + switch (b2) { + case "overflow": + case "underflow": + case "division-by-zero": + h2 += "-" + b2; + break; + case "negative-power": + case "negative-width": + h2 += "-unsupported"; + break; + case "unbound-bitwise-result": + h2 += "-unbound-result"; + break; + } + break; } - return { status: status.value, value: parsedSet }; - } - const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2))); - if (ctx.common.async) { - return Promise.all(elements).then((elements2) => finalizeSet(elements2)); - } else { - return finalizeSet(elements); + case re$1.CALL_EXCEPTION: + case re$1.INSUFFICIENT_FUNDS: + case re$1.MISSING_NEW: + case re$1.NONCE_EXPIRED: + case re$1.REPLACEMENT_UNDERPRICED: + case re$1.TRANSACTION_REPLACED: + case re$1.UNPREDICTABLE_GAS_LIMIT: + h2 = r2; + break; } + h2 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h2 + " ]"), n2.length && (t2 += " (" + n2.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r2, Object.keys(i2).forEach(function(b2) { + p2[b2] = i2[b2]; + }), p2; } - min(minSize, message) { - return new ZodSet({ - ...this._def, - minSize: { value: minSize, message: errorUtil.toString(message) } - }); + throwError(t2, r2, i2) { + throw this.makeError(t2, r2, i2); } - max(maxSize, message) { - return new ZodSet({ - ...this._def, - maxSize: { value: maxSize, message: errorUtil.toString(message) } - }); + throwArgumentError(t2, r2, i2) { + return this.throwError(t2, L2.errors.INVALID_ARGUMENT, { argument: r2, value: i2 }); } - size(size, message) { - return this.min(size, message).max(size, message); + assert(t2, r2, i2, n2) { + t2 || this.throwError(r2, i2, n2); } - nonempty(message) { - return this.min(1, message); + assertArgument(t2, r2, i2, n2) { + t2 || this.throwArgumentError(r2, i2, n2); + } + checkNormalize(t2) { + Un && this.throwError("platform missing String.prototype.normalize", L2.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un }); + } + checkSafeUint53(t2, r2) { + typeof t2 == "number" && (r2 == null && (r2 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r2, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r2, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); + } + checkArgumentCount(t2, r2, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r2 && this.throwError("missing argument" + i2, L2.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r2 }), t2 > r2 && this.throwError("too many arguments" + i2, L2.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r2 }); + } + checkNew(t2, r2) { + (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r2.name }); + } + checkAbstract(t2, r2) { + t2 === r2 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r2.name) + " directly; use a sub-class", L2.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r2.name }); + } + static globalLogger() { + return gi || (gi = new L2(y0)), gi; + } + static setCensorship(t2, r2) { + if (!t2 && r2 && this.globalLogger().throwError("cannot permanently disable censorship", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); + } + Fn = !!t2, Dn = !!r2; + } + static setLogLevel(t2) { + const r2 = Cr[t2.toLowerCase()]; + if (r2 == null) { + L2.globalLogger().warn("invalid log level - " + t2); + return; + } + Tn = r2; + } + static from(t2) { + return new L2(t2); } - } - ZodSet.create = (valueType, params) => { - return new ZodSet({ - valueType, - minSize: null, - maxSize: null, - typeName: ZodFirstPartyTypeKind.ZodSet, - ...processCreateParams(params) - }); }; - class ZodFunction extends ZodType { - constructor() { - super(...arguments); - this.validate = this.implement; + L$2.errors = re$1, L$2.levels = Ai; + const x0 = "bytes/5.7.0", Dt$1 = new L$2(x0); + function qn(e2) { + return !!e2.toHexString; + } + function rr$1(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr$1(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; + } + function Kn(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; + } + function ir$1(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r2 = e2[t2]; + if (!Kn(r2) || r2 < 0 || r2 >= 256) + return false; } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.function) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.function, - received: ctx.parsedType - }); - return INVALID; + return true; + } + function Ot$1(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$1.checkSafeUint53(e2, "invalid arrayify value"); + const r2 = []; + for (; e2; ) + r2.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r2.length === 0 && r2.push(0), rr$1(new Uint8Array(r2)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2) && (e2 = e2.toHexString()), Qt$1(e2)) { + let r2 = e2.substring(2); + r2.length % 2 && (t2.hexPad === "left" ? r2 = "0" + r2 : t2.hexPad === "right" ? r2 += "0" : Dt$1.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n2 = 0; n2 < r2.length; n2 += 2) + i2.push(parseInt(r2.substring(n2, n2 + 2), 16)); + return rr$1(new Uint8Array(i2)); + } + return ir$1(e2) ? rr$1(new Uint8Array(e2)) : Dt$1.throwArgumentError("invalid arrayify value", "value", e2); + } + function Qt$1(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2); + } + const bi = "0123456789abcdef"; + function Kt$1(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$1.checkSafeUint53(e2, "invalid hexlify value"); + let r2 = ""; + for (; e2; ) + r2 = bi[e2 & 15] + r2, e2 = Math.floor(e2 / 16); + return r2.length ? (r2.length % 2 && (r2 = "0" + r2), "0x" + r2) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2)) + return e2.toHexString(); + if (Qt$1(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt$1.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir$1(e2)) { + let r2 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n2 = e2[i2]; + r2 += bi[(n2 & 240) >> 4] + bi[n2 & 15]; } - function makeArgsIssue(args, error) { - return makeIssue({ - data: args, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap(), - errorMap - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode.invalid_arguments, - argumentsError: error - } - }); + return r2; + } + return Dt$1.throwArgumentError("invalid hexlify value", "value", e2); + } + function oe(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt$1(e2) : Qt$1(e2) || Dt$1.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt$1.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; + } + var Ln = { exports: {} }, I0 = {}, _0 = Object.freeze({ __proto__: null, default: I0 }), B0 = A0(_0); + (function(e2) { + (function(t2, r2) { + function i2(A2, f2) { + if (!A2) + throw new Error(f2 || "Assertion failed"); } - function makeReturnsIssue(returns, error) { - return makeIssue({ - data: returns, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap(), - errorMap - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode.invalid_return_type, - returnTypeError: error + function n2(A2, f2) { + A2.super_ = f2; + var a2 = function() { + }; + a2.prototype = f2.prototype, A2.prototype = new a2(), A2.prototype.constructor = A2; + } + function o2(A2, f2, a2) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f2 === "le" || f2 === "be") && (a2 = f2, f2 = 10), this._init(A2 || 0, f2 || 10, a2 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r2.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h2; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h2 = window.Buffer : h2 = B0.Buffer; + } catch { + } + o2.isBN = function(f2) { + return f2 instanceof o2 ? true : f2 !== null && typeof f2 == "object" && f2.constructor.wordSize === o2.wordSize && Array.isArray(f2.words); + }, o2.max = function(f2, a2) { + return f2.cmp(a2) > 0 ? f2 : a2; + }, o2.min = function(f2, a2) { + return f2.cmp(a2) < 0 ? f2 : a2; + }, o2.prototype._init = function(f2, a2, c2) { + if (typeof f2 == "number") + return this._initNumber(f2, a2, c2); + if (typeof f2 == "object") + return this._initArray(f2, a2, c2); + a2 === "hex" && (a2 = 16), i2(a2 === (a2 | 0) && a2 >= 2 && a2 <= 36), f2 = f2.toString().replace(/\s+/g, ""); + var d2 = 0; + f2[0] === "-" && (d2++, this.negative = 1), d2 < f2.length && (a2 === 16 ? this._parseHex(f2, d2, c2) : (this._parseBase(f2, a2, d2), c2 === "le" && this._initArray(this.toArray(), a2, c2))); + }, o2.prototype._initNumber = function(f2, a2, c2) { + f2 < 0 && (this.negative = 1, f2 = -f2), f2 < 67108864 ? (this.words = [f2 & 67108863], this.length = 1) : f2 < 4503599627370496 ? (this.words = [f2 & 67108863, f2 / 67108864 & 67108863], this.length = 2) : (i2(f2 < 9007199254740992), this.words = [f2 & 67108863, f2 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a2, c2); + }, o2.prototype._initArray = function(f2, a2, c2) { + if (i2(typeof f2.length == "number"), f2.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f2.length / 3), this.words = new Array(this.length); + for (var d2 = 0; d2 < this.length; d2++) + this.words[d2] = 0; + var g2, x2, M2 = 0; + if (c2 === "be") + for (d2 = f2.length - 1, g2 = 0; d2 >= 0; d2 -= 3) + x2 = f2[d2] | f2[d2 - 1] << 8 | f2[d2 - 2] << 16, this.words[g2] |= x2 << M2 & 67108863, this.words[g2 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g2++); + else if (c2 === "le") + for (d2 = 0, g2 = 0; d2 < f2.length; d2 += 3) + x2 = f2[d2] | f2[d2 + 1] << 8 | f2[d2 + 2] << 16, this.words[g2] |= x2 << M2 & 67108863, this.words[g2 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g2++); + return this._strip(); + }; + function p2(A2, f2) { + var a2 = A2.charCodeAt(f2); + if (a2 >= 48 && a2 <= 57) + return a2 - 48; + if (a2 >= 65 && a2 <= 70) + return a2 - 55; + if (a2 >= 97 && a2 <= 102) + return a2 - 87; + i2(false, "Invalid character in " + A2); + } + function b2(A2, f2, a2) { + var c2 = p2(A2, a2); + return a2 - 1 >= f2 && (c2 |= p2(A2, a2 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f2, a2, c2) { + this.length = Math.ceil((f2.length - a2) / 6), this.words = new Array(this.length); + for (var d2 = 0; d2 < this.length; d2++) + this.words[d2] = 0; + var g2 = 0, x2 = 0, M2; + if (c2 === "be") + for (d2 = f2.length - 1; d2 >= a2; d2 -= 2) + M2 = b2(f2, a2, d2) << g2, this.words[x2] |= M2 & 67108863, g2 >= 18 ? (g2 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g2 += 8; + else { + var l2 = f2.length - a2; + for (d2 = l2 % 2 === 0 ? a2 + 1 : a2; d2 < f2.length; d2 += 2) + M2 = b2(f2, a2, d2) << g2, this.words[x2] |= M2 & 67108863, g2 >= 18 ? (g2 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g2 += 8; + } + this._strip(); + }; + function m2(A2, f2, a2, c2) { + for (var d2 = 0, g2 = 0, x2 = Math.min(A2.length, a2), M2 = f2; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d2 *= c2, l2 >= 49 ? g2 = l2 - 49 + 10 : l2 >= 17 ? g2 = l2 - 17 + 10 : g2 = l2, i2(l2 >= 0 && g2 < c2, "Invalid character"), d2 += g2; + } + return d2; + } + o2.prototype._parseBase = function(f2, a2, c2) { + this.words = [0], this.length = 1; + for (var d2 = 0, g2 = 1; g2 <= 67108863; g2 *= a2) + d2++; + d2--, g2 = g2 / a2 | 0; + for (var x2 = f2.length - c2, M2 = x2 % d2, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v2 = c2; v2 < l2; v2 += d2) + s2 = m2(f2, v2, v2 + d2, a2), this.imuln(g2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m2(f2, v2, f2.length, a2), v2 = 0; v2 < M2; v2++) + k2 *= a2; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f2) { + f2.words = new Array(this.length); + for (var a2 = 0; a2 < this.length; a2++) + f2.words[a2] = this.words[a2]; + f2.length = this.length, f2.negative = this.negative, f2.red = this.red; + }; + function w2(A2, f2) { + A2.words = f2.words, A2.length = f2.length, A2.negative = f2.negative, A2.red = f2.red; + } + if (o2.prototype._move = function(f2) { + w2(f2, this); + }, o2.prototype.clone = function() { + var f2 = new o2(null); + return this.copy(f2), f2; + }, o2.prototype._expand = function(f2) { + for (; this.length < f2; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y2; + } catch { + o2.prototype.inspect = y2; + } + else + o2.prototype.inspect = y2; + function y2() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f2, a2) { + f2 = f2 || 10, a2 = a2 | 0 || 1; + var c2; + if (f2 === 16 || f2 === "hex") { + c2 = ""; + for (var d2 = 0, g2 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d2 | g2) & 16777215).toString(16); + g2 = M2 >>> 24 - d2 & 16777215, d2 += 2, d2 >= 26 && (d2 -= 26, x2--), g2 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; } - }); + for (g2 !== 0 && (c2 = g2.toString(16) + c2); c2.length % a2 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f2 === (f2 | 0) && f2 >= 2 && f2 <= 36) { + var s2 = I2[f2], v2 = N2[f2]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u2 = k2.modrn(v2).toString(f2); + k2 = k2.idivn(v2), k2.isZero() ? c2 = u2 + c2 : c2 = S2[s2 - u2.length] + u2 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a2 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f2 = this.words[0]; + return this.length === 2 ? f2 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f2 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f2 : f2; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h2 && (o2.prototype.toBuffer = function(f2, a2) { + return this.toArrayLike(h2, f2, a2); + }), o2.prototype.toArray = function(f2, a2) { + return this.toArrayLike(Array, f2, a2); + }; + var C2 = function(f2, a2) { + return f2.allocUnsafe ? f2.allocUnsafe(a2) : new f2(a2); + }; + o2.prototype.toArrayLike = function(f2, a2, c2) { + this._strip(); + var d2 = this.byteLength(), g2 = c2 || Math.max(1, d2); + i2(d2 <= g2, "byte array longer than desired length"), i2(g2 > 0, "Requested array length <= 0"); + var x2 = C2(f2, g2), M2 = a2 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d2), x2; + }, o2.prototype._toArrayLikeLE = function(f2, a2) { + for (var c2 = 0, d2 = 0, g2 = 0, x2 = 0; g2 < this.length; g2++) { + var M2 = this.words[g2] << x2 | d2; + f2[c2++] = M2 & 255, c2 < f2.length && (f2[c2++] = M2 >> 8 & 255), c2 < f2.length && (f2[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f2.length && (f2[c2++] = M2 >> 24 & 255), d2 = 0, x2 = 0) : (d2 = M2 >>> 24, x2 += 2); + } + if (c2 < f2.length) + for (f2[c2++] = d2; c2 < f2.length; ) + f2[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f2, a2) { + for (var c2 = f2.length - 1, d2 = 0, g2 = 0, x2 = 0; g2 < this.length; g2++) { + var M2 = this.words[g2] << x2 | d2; + f2[c2--] = M2 & 255, c2 >= 0 && (f2[c2--] = M2 >> 8 & 255), c2 >= 0 && (f2[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f2[c2--] = M2 >> 24 & 255), d2 = 0, x2 = 0) : (d2 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f2[c2--] = d2; c2 >= 0; ) + f2[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f2) { + return 32 - Math.clz32(f2); + } : o2.prototype._countBits = function(f2) { + var a2 = f2, c2 = 0; + return a2 >= 4096 && (c2 += 13, a2 >>>= 13), a2 >= 64 && (c2 += 7, a2 >>>= 7), a2 >= 8 && (c2 += 4, a2 >>>= 4), a2 >= 2 && (c2 += 2, a2 >>>= 2), c2 + a2; + }, o2.prototype._zeroBits = function(f2) { + if (f2 === 0) + return 26; + var a2 = f2, c2 = 0; + return a2 & 8191 || (c2 += 13, a2 >>>= 13), a2 & 127 || (c2 += 7, a2 >>>= 7), a2 & 15 || (c2 += 4, a2 >>>= 4), a2 & 3 || (c2 += 2, a2 >>>= 2), a2 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f2 = this.words[this.length - 1], a2 = this._countBits(f2); + return (this.length - 1) * 26 + a2; + }; + function F2(A2) { + for (var f2 = new Array(A2.bitLength()), a2 = 0; a2 < f2.length; a2++) { + var c2 = a2 / 26 | 0, d2 = a2 % 26; + f2[a2] = A2.words[c2] >>> d2 & 1; + } + return f2; } - const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; - if (this._def.returns instanceof ZodPromise) { - return OK(async (...args) => { - const error = new ZodError([]); - const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { - error.addIssue(makeArgsIssue(args, e2)); - throw error; - }); - const result = await fn2(...parsedArgs); - const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { - error.addIssue(makeReturnsIssue(result, e2)); - throw error; - }); - return parsedReturns; - }); - } else { - return OK((...args) => { - const parsedArgs = this._def.args.safeParse(args, params); - if (!parsedArgs.success) { - throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f2 = 0, a2 = 0; a2 < this.length; a2++) { + var c2 = this._zeroBits(this.words[a2]); + if (f2 += c2, c2 !== 26) + break; + } + return f2; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f2) { + return this.negative !== 0 ? this.abs().inotn(f2).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f2) { + return this.testn(f2 - 1) ? this.notn(f2).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f2) { + for (; this.length < f2.length; ) + this.words[this.length++] = 0; + for (var a2 = 0; a2 < f2.length; a2++) + this.words[a2] = this.words[a2] | f2.words[a2]; + return this._strip(); + }, o2.prototype.ior = function(f2) { + return i2((this.negative | f2.negative) === 0), this.iuor(f2); + }, o2.prototype.or = function(f2) { + return this.length > f2.length ? this.clone().ior(f2) : f2.clone().ior(this); + }, o2.prototype.uor = function(f2) { + return this.length > f2.length ? this.clone().iuor(f2) : f2.clone().iuor(this); + }, o2.prototype.iuand = function(f2) { + var a2; + this.length > f2.length ? a2 = f2 : a2 = this; + for (var c2 = 0; c2 < a2.length; c2++) + this.words[c2] = this.words[c2] & f2.words[c2]; + return this.length = a2.length, this._strip(); + }, o2.prototype.iand = function(f2) { + return i2((this.negative | f2.negative) === 0), this.iuand(f2); + }, o2.prototype.and = function(f2) { + return this.length > f2.length ? this.clone().iand(f2) : f2.clone().iand(this); + }, o2.prototype.uand = function(f2) { + return this.length > f2.length ? this.clone().iuand(f2) : f2.clone().iuand(this); + }, o2.prototype.iuxor = function(f2) { + var a2, c2; + this.length > f2.length ? (a2 = this, c2 = f2) : (a2 = f2, c2 = this); + for (var d2 = 0; d2 < c2.length; d2++) + this.words[d2] = a2.words[d2] ^ c2.words[d2]; + if (this !== a2) + for (; d2 < a2.length; d2++) + this.words[d2] = a2.words[d2]; + return this.length = a2.length, this._strip(); + }, o2.prototype.ixor = function(f2) { + return i2((this.negative | f2.negative) === 0), this.iuxor(f2); + }, o2.prototype.xor = function(f2) { + return this.length > f2.length ? this.clone().ixor(f2) : f2.clone().ixor(this); + }, o2.prototype.uxor = function(f2) { + return this.length > f2.length ? this.clone().iuxor(f2) : f2.clone().iuxor(this); + }, o2.prototype.inotn = function(f2) { + i2(typeof f2 == "number" && f2 >= 0); + var a2 = Math.ceil(f2 / 26) | 0, c2 = f2 % 26; + this._expand(a2), c2 > 0 && a2--; + for (var d2 = 0; d2 < a2; d2++) + this.words[d2] = ~this.words[d2] & 67108863; + return c2 > 0 && (this.words[d2] = ~this.words[d2] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f2) { + return this.clone().inotn(f2); + }, o2.prototype.setn = function(f2, a2) { + i2(typeof f2 == "number" && f2 >= 0); + var c2 = f2 / 26 | 0, d2 = f2 % 26; + return this._expand(c2 + 1), a2 ? this.words[c2] = this.words[c2] | 1 << d2 : this.words[c2] = this.words[c2] & ~(1 << d2), this._strip(); + }, o2.prototype.iadd = function(f2) { + var a2; + if (this.negative !== 0 && f2.negative === 0) + return this.negative = 0, a2 = this.isub(f2), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f2.negative !== 0) + return f2.negative = 0, a2 = this.isub(f2), f2.negative = 1, a2._normSign(); + var c2, d2; + this.length > f2.length ? (c2 = this, d2 = f2) : (c2 = f2, d2 = this); + for (var g2 = 0, x2 = 0; x2 < d2.length; x2++) + a2 = (c2.words[x2] | 0) + (d2.words[x2] | 0) + g2, this.words[x2] = a2 & 67108863, g2 = a2 >>> 26; + for (; g2 !== 0 && x2 < c2.length; x2++) + a2 = (c2.words[x2] | 0) + g2, this.words[x2] = a2 & 67108863, g2 = a2 >>> 26; + if (this.length = c2.length, g2 !== 0) + this.words[this.length] = g2, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f2) { + var a2; + return f2.negative !== 0 && this.negative === 0 ? (f2.negative = 0, a2 = this.sub(f2), f2.negative ^= 1, a2) : f2.negative === 0 && this.negative !== 0 ? (this.negative = 0, a2 = f2.sub(this), this.negative = 1, a2) : this.length > f2.length ? this.clone().iadd(f2) : f2.clone().iadd(this); + }, o2.prototype.isub = function(f2) { + if (f2.negative !== 0) { + f2.negative = 0; + var a2 = this.iadd(f2); + return f2.negative = 1, a2._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f2), this.negative = 1, this._normSign(); + var c2 = this.cmp(f2); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d2, g2; + c2 > 0 ? (d2 = this, g2 = f2) : (d2 = f2, g2 = this); + for (var x2 = 0, M2 = 0; M2 < g2.length; M2++) + a2 = (d2.words[M2] | 0) - (g2.words[M2] | 0) + x2, x2 = a2 >> 26, this.words[M2] = a2 & 67108863; + for (; x2 !== 0 && M2 < d2.length; M2++) + a2 = (d2.words[M2] | 0) + x2, x2 = a2 >> 26, this.words[M2] = a2 & 67108863; + if (x2 === 0 && M2 < d2.length && d2 !== this) + for (; M2 < d2.length; M2++) + this.words[M2] = d2.words[M2]; + return this.length = Math.max(this.length, M2), d2 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f2) { + return this.clone().isub(f2); + }; + function U2(A2, f2, a2) { + a2.negative = f2.negative ^ A2.negative; + var c2 = A2.length + f2.length | 0; + a2.length = c2, c2 = c2 - 1 | 0; + var d2 = A2.words[0] | 0, g2 = f2.words[0] | 0, x2 = d2 * g2, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a2.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v2 = l2 >>> 26, k2 = l2 & 67108863, u2 = Math.min(s2, f2.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u2; E2++) { + var _2 = s2 - E2 | 0; + d2 = A2.words[_2] | 0, g2 = f2.words[E2] | 0, x2 = d2 * g2 + k2, v2 += x2 / 67108864 | 0, k2 = x2 & 67108863; } - const result = fn2(...parsedArgs.data); - const parsedReturns = this._def.returns.safeParse(result, params); - if (!parsedReturns.success) { - throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); + a2.words[s2] = k2 | 0, l2 = v2 | 0; + } + return l2 !== 0 ? a2.words[s2] = l2 | 0 : a2.length--, a2._strip(); + } + var J2 = function(f2, a2, c2) { + var d2 = f2.words, g2 = a2.words, x2 = c2.words, M2 = 0, l2, s2, v2, k2 = d2[0] | 0, u2 = k2 & 8191, E2 = k2 >>> 13, _2 = d2[1] | 0, B2 = _2 & 8191, R2 = _2 >>> 13, T2 = d2[2] | 0, P2 = T2 & 8191, O2 = T2 >>> 13, Ct2 = d2[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d2[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d2[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te2 = d2[6] | 0, et2 = Te2 & 8191, rt2 = Te2 >>> 13, Ue2 = d2[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d2[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d2[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g2[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g2[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g2[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le2 = g2[3] | 0, vt2 = Le2 & 8191, mt2 = Le2 >>> 13, je2 = g2[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g2[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g2[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g2[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g2[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g2[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f2.negative ^ a2.negative, c2.length = 19, l2 = Math.imul(u2, ut2), s2 = Math.imul(u2, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v2 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v2 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u2, ct2) | 0, s2 = s2 + Math.imul(u2, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v2 = v2 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O2, ut2) | 0, v2 = Math.imul(O2, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v2 = v2 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u2, dt2) | 0, s2 = s2 + Math.imul(u2, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v2 = v2 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v2 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O2, ct2) | 0, v2 = v2 + Math.imul(O2, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v2 = v2 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u2, vt2) | 0, s2 = s2 + Math.imul(u2, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v2 = v2 + Math.imul(E2, mt2) | 0; + var Ne2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Ne2 >>> 26) | 0, Ne2 &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v2 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v2 = v2 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O2, dt2) | 0, v2 = v2 + Math.imul(O2, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v2 = v2 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u2, gt2) | 0, s2 = s2 + Math.imul(u2, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v2 = v2 + Math.imul(E2, At2) | 0; + var Ie2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Ie2 >>> 26) | 0, Ie2 &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v2 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v2 = v2 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v2 = v2 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O2, vt2) | 0, v2 = v2 + Math.imul(O2, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v2 = v2 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u2, bt2) | 0, s2 = s2 + Math.imul(u2, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v2 = v2 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v2 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v2 = v2 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v2 = v2 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v2 = v2 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O2, gt2) | 0, v2 = v2 + Math.imul(O2, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v2 = v2 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u2, wt2) | 0, s2 = s2 + Math.imul(u2, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v2 = v2 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v2 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v2 = v2 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v2 = v2 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v2 = v2 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v2 = v2 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O2, bt2) | 0, v2 = v2 + Math.imul(O2, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v2 = v2 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u2, Mt2) | 0, s2 = s2 + Math.imul(u2, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v2 = v2 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v2 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v2 = v2 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v2 = v2 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v2 = v2 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v2 = v2 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v2 = v2 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O2, wt2) | 0, v2 = v2 + Math.imul(O2, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v2 = v2 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u2, St2) | 0, s2 = s2 + Math.imul(u2, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v2 = v2 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v2 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v2 = v2 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v2 = v2 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v2 = v2 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v2 = v2 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v2 = v2 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v2 = v2 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O2, Mt2) | 0, v2 = v2 + Math.imul(O2, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v2 = v2 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u2, It2) | 0, s2 = s2 + Math.imul(u2, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v2 = v2 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v2 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v2 = v2 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v2 = v2 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v2 = v2 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v2 = v2 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v2 = v2 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v2 = v2 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O2, St2) | 0, v2 = v2 + Math.imul(O2, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v2 = v2 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v2 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v2 = v2 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v2 = v2 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v2 = v2 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v2 = v2 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v2 = v2 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v2 = v2 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O2, It2) | 0, v2 = v2 + Math.imul(O2, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v2 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v2 = v2 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v2 = v2 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v2 = v2 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v2 = v2 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v2 = v2 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v2 = v2 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v2 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v2 = v2 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v2 = v2 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v2 = v2 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v2 = v2 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v2 = v2 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v2 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v2 = v2 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v2 = v2 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v2 = v2 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v2 = v2 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v2 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v2 = v2 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v2 = v2 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v2 = v2 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v2 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v2 = v2 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v2 = v2 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v2 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v2 = v2 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v2 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v2 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v2 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne2, x2[4] = Ie2, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f2, a2) { + a2.negative = f2.negative ^ A2.negative, a2.length = A2.length + f2.length; + for (var c2 = 0, d2 = 0, g2 = 0; g2 < a2.length - 1; g2++) { + var x2 = d2; + d2 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g2, f2.length - 1), s2 = Math.max(0, g2 - A2.length + 1); s2 <= l2; s2++) { + var v2 = g2 - s2, k2 = A2.words[v2] | 0, u2 = f2.words[s2] | 0, E2 = k2 * u2, _2 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _2 = _2 + M2 | 0, M2 = _2 & 67108863, x2 = x2 + (_2 >>> 26) | 0, d2 += x2 >>> 26, x2 &= 67108863; + } + a2.words[g2] = M2, c2 = x2, x2 = d2; + } + return c2 !== 0 ? a2.words[g2] = c2 : a2.length--, a2._strip(); + } + function G2(A2, f2, a2) { + return Bt2(A2, f2, a2); + } + o2.prototype.mulTo = function(f2, a2) { + var c2, d2 = this.length + f2.length; + return this.length === 10 && f2.length === 10 ? c2 = J2(this, f2, a2) : d2 < 63 ? c2 = U2(this, f2, a2) : d2 < 1024 ? c2 = Bt2(this, f2, a2) : c2 = G2(this, f2, a2), c2; + }, o2.prototype.mul = function(f2) { + var a2 = new o2(null); + return a2.words = new Array(this.length + f2.length), this.mulTo(f2, a2); + }, o2.prototype.mulf = function(f2) { + var a2 = new o2(null); + return a2.words = new Array(this.length + f2.length), G2(this, f2, a2); + }, o2.prototype.imul = function(f2) { + return this.clone().mulTo(f2, this); + }, o2.prototype.imuln = function(f2) { + var a2 = f2 < 0; + a2 && (f2 = -f2), i2(typeof f2 == "number"), i2(f2 < 67108864); + for (var c2 = 0, d2 = 0; d2 < this.length; d2++) { + var g2 = (this.words[d2] | 0) * f2, x2 = (g2 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g2 / 67108864 | 0, c2 += x2 >>> 26, this.words[d2] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d2] = c2, this.length++), a2 ? this.ineg() : this; + }, o2.prototype.muln = function(f2) { + return this.clone().imuln(f2); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f2) { + var a2 = F2(f2); + if (a2.length === 0) + return new o2(1); + for (var c2 = this, d2 = 0; d2 < a2.length && a2[d2] === 0; d2++, c2 = c2.sqr()) + ; + if (++d2 < a2.length) + for (var g2 = c2.sqr(); d2 < a2.length; d2++, g2 = g2.sqr()) + a2[d2] !== 0 && (c2 = c2.mul(g2)); + return c2; + }, o2.prototype.iushln = function(f2) { + i2(typeof f2 == "number" && f2 >= 0); + var a2 = f2 % 26, c2 = (f2 - a2) / 26, d2 = 67108863 >>> 26 - a2 << 26 - a2, g2; + if (a2 !== 0) { + var x2 = 0; + for (g2 = 0; g2 < this.length; g2++) { + var M2 = this.words[g2] & d2, l2 = (this.words[g2] | 0) - M2 << a2; + this.words[g2] = l2 | x2, x2 = M2 >>> 26 - a2; + } + x2 && (this.words[g2] = x2, this.length++); + } + if (c2 !== 0) { + for (g2 = this.length - 1; g2 >= 0; g2--) + this.words[g2 + c2] = this.words[g2]; + for (g2 = 0; g2 < c2; g2++) + this.words[g2] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f2) { + return i2(this.negative === 0), this.iushln(f2); + }, o2.prototype.iushrn = function(f2, a2, c2) { + i2(typeof f2 == "number" && f2 >= 0); + var d2; + a2 ? d2 = (a2 - a2 % 26) / 26 : d2 = 0; + var g2 = f2 % 26, x2 = Math.min((f2 - g2) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g2 << g2, l2 = c2; + if (d2 -= x2, d2 = Math.max(0, d2), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v2 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v2 !== 0 || s2 >= d2); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v2 << 26 - g2 | k2 >>> g2, v2 = k2 & M2; + } + return l2 && v2 !== 0 && (l2.words[l2.length++] = v2), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f2, a2, c2) { + return i2(this.negative === 0), this.iushrn(f2, a2, c2); + }, o2.prototype.shln = function(f2) { + return this.clone().ishln(f2); + }, o2.prototype.ushln = function(f2) { + return this.clone().iushln(f2); + }, o2.prototype.shrn = function(f2) { + return this.clone().ishrn(f2); + }, o2.prototype.ushrn = function(f2) { + return this.clone().iushrn(f2); + }, o2.prototype.testn = function(f2) { + i2(typeof f2 == "number" && f2 >= 0); + var a2 = f2 % 26, c2 = (f2 - a2) / 26, d2 = 1 << a2; + if (this.length <= c2) + return false; + var g2 = this.words[c2]; + return !!(g2 & d2); + }, o2.prototype.imaskn = function(f2) { + i2(typeof f2 == "number" && f2 >= 0); + var a2 = f2 % 26, c2 = (f2 - a2) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a2 !== 0 && c2++, this.length = Math.min(c2, this.length), a2 !== 0) { + var d2 = 67108863 ^ 67108863 >>> a2 << a2; + this.words[this.length - 1] &= d2; + } + return this._strip(); + }, o2.prototype.maskn = function(f2) { + return this.clone().imaskn(f2); + }, o2.prototype.iaddn = function(f2) { + return i2(typeof f2 == "number"), i2(f2 < 67108864), f2 < 0 ? this.isubn(-f2) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f2 ? (this.words[0] = f2 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f2), this.negative = 1, this) : this._iaddn(f2); + }, o2.prototype._iaddn = function(f2) { + this.words[0] += f2; + for (var a2 = 0; a2 < this.length && this.words[a2] >= 67108864; a2++) + this.words[a2] -= 67108864, a2 === this.length - 1 ? this.words[a2 + 1] = 1 : this.words[a2 + 1]++; + return this.length = Math.max(this.length, a2 + 1), this; + }, o2.prototype.isubn = function(f2) { + if (i2(typeof f2 == "number"), i2(f2 < 67108864), f2 < 0) + return this.iaddn(-f2); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f2), this.negative = 1, this; + if (this.words[0] -= f2, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a2 = 0; a2 < this.length && this.words[a2] < 0; a2++) + this.words[a2] += 67108864, this.words[a2 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f2) { + return this.clone().iaddn(f2); + }, o2.prototype.subn = function(f2) { + return this.clone().isubn(f2); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f2, a2, c2) { + var d2 = f2.length + c2, g2; + this._expand(d2); + var x2, M2 = 0; + for (g2 = 0; g2 < f2.length; g2++) { + x2 = (this.words[g2 + c2] | 0) + M2; + var l2 = (f2.words[g2] | 0) * a2; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g2 + c2] = x2 & 67108863; + } + for (; g2 < this.length - c2; g2++) + x2 = (this.words[g2 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g2 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g2 = 0; g2 < this.length; g2++) + x2 = -(this.words[g2] | 0) + M2, M2 = x2 >> 26, this.words[g2] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f2, a2) { + var c2 = this.length - f2.length, d2 = this.clone(), g2 = f2, x2 = g2.words[g2.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g2 = g2.ushln(c2), d2.iushln(c2), x2 = g2.words[g2.length - 1] | 0); + var l2 = d2.length - g2.length, s2; + if (a2 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v2 = 0; v2 < s2.length; v2++) + s2.words[v2] = 0; + } + var k2 = d2.clone()._ishlnsubmul(g2, 1, l2); + k2.negative === 0 && (d2 = k2, s2 && (s2.words[l2] = 1)); + for (var u2 = l2 - 1; u2 >= 0; u2--) { + var E2 = (d2.words[g2.length + u2] | 0) * 67108864 + (d2.words[g2.length + u2 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d2._ishlnsubmul(g2, E2, u2); d2.negative !== 0; ) + E2--, d2.negative = 0, d2._ishlnsubmul(g2, 1, u2), d2.isZero() || (d2.negative ^= 1); + s2 && (s2.words[u2] = E2); + } + return s2 && s2._strip(), d2._strip(), a2 !== "div" && c2 !== 0 && d2.iushrn(c2), { div: s2 || null, mod: d2 }; + }, o2.prototype.divmod = function(f2, a2, c2) { + if (i2(!f2.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d2, g2, x2; + return this.negative !== 0 && f2.negative === 0 ? (x2 = this.neg().divmod(f2, a2), a2 !== "mod" && (d2 = x2.div.neg()), a2 !== "div" && (g2 = x2.mod.neg(), c2 && g2.negative !== 0 && g2.iadd(f2)), { div: d2, mod: g2 }) : this.negative === 0 && f2.negative !== 0 ? (x2 = this.divmod(f2.neg(), a2), a2 !== "mod" && (d2 = x2.div.neg()), { div: d2, mod: x2.mod }) : this.negative & f2.negative ? (x2 = this.neg().divmod(f2.neg(), a2), a2 !== "div" && (g2 = x2.mod.neg(), c2 && g2.negative !== 0 && g2.isub(f2)), { div: x2.div, mod: g2 }) : f2.length > this.length || this.cmp(f2) < 0 ? { div: new o2(0), mod: this } : f2.length === 1 ? a2 === "div" ? { div: this.divn(f2.words[0]), mod: null } : a2 === "mod" ? { div: null, mod: new o2(this.modrn(f2.words[0])) } : { div: this.divn(f2.words[0]), mod: new o2(this.modrn(f2.words[0])) } : this._wordDiv(f2, a2); + }, o2.prototype.div = function(f2) { + return this.divmod(f2, "div", false).div; + }, o2.prototype.mod = function(f2) { + return this.divmod(f2, "mod", false).mod; + }, o2.prototype.umod = function(f2) { + return this.divmod(f2, "mod", true).mod; + }, o2.prototype.divRound = function(f2) { + var a2 = this.divmod(f2); + if (a2.mod.isZero()) + return a2.div; + var c2 = a2.div.negative !== 0 ? a2.mod.isub(f2) : a2.mod, d2 = f2.ushrn(1), g2 = f2.andln(1), x2 = c2.cmp(d2); + return x2 < 0 || g2 === 1 && x2 === 0 ? a2.div : a2.div.negative !== 0 ? a2.div.isubn(1) : a2.div.iaddn(1); + }, o2.prototype.modrn = function(f2) { + var a2 = f2 < 0; + a2 && (f2 = -f2), i2(f2 <= 67108863); + for (var c2 = (1 << 26) % f2, d2 = 0, g2 = this.length - 1; g2 >= 0; g2--) + d2 = (c2 * d2 + (this.words[g2] | 0)) % f2; + return a2 ? -d2 : d2; + }, o2.prototype.modn = function(f2) { + return this.modrn(f2); + }, o2.prototype.idivn = function(f2) { + var a2 = f2 < 0; + a2 && (f2 = -f2), i2(f2 <= 67108863); + for (var c2 = 0, d2 = this.length - 1; d2 >= 0; d2--) { + var g2 = (this.words[d2] | 0) + c2 * 67108864; + this.words[d2] = g2 / f2 | 0, c2 = g2 % f2; + } + return this._strip(), a2 ? this.ineg() : this; + }, o2.prototype.divn = function(f2) { + return this.clone().idivn(f2); + }, o2.prototype.egcd = function(f2) { + i2(f2.negative === 0), i2(!f2.isZero()); + var a2 = this, c2 = f2.clone(); + a2.negative !== 0 ? a2 = a2.umod(f2) : a2 = a2.clone(); + for (var d2 = new o2(1), g2 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a2.isEven() && c2.isEven(); ) + a2.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v2 = a2.clone(); !a2.isZero(); ) { + for (var k2 = 0, u2 = 1; !(a2.words[0] & u2) && k2 < 26; ++k2, u2 <<= 1) + ; + if (k2 > 0) + for (a2.iushrn(k2); k2-- > 0; ) + (d2.isOdd() || g2.isOdd()) && (d2.iadd(s2), g2.isub(v2)), d2.iushrn(1), g2.iushrn(1); + for (var E2 = 0, _2 = 1; !(c2.words[0] & _2) && E2 < 26; ++E2, _2 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v2)), x2.iushrn(1), M2.iushrn(1); + a2.cmp(c2) >= 0 ? (a2.isub(c2), d2.isub(x2), g2.isub(M2)) : (c2.isub(a2), x2.isub(d2), M2.isub(g2)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f2) { + i2(f2.negative === 0), i2(!f2.isZero()); + var a2 = this, c2 = f2.clone(); + a2.negative !== 0 ? a2 = a2.umod(f2) : a2 = a2.clone(); + for (var d2 = new o2(1), g2 = new o2(0), x2 = c2.clone(); a2.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a2.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a2.iushrn(M2); M2-- > 0; ) + d2.isOdd() && d2.iadd(x2), d2.iushrn(1); + for (var s2 = 0, v2 = 1; !(c2.words[0] & v2) && s2 < 26; ++s2, v2 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g2.isOdd() && g2.iadd(x2), g2.iushrn(1); + a2.cmp(c2) >= 0 ? (a2.isub(c2), d2.isub(g2)) : (c2.isub(a2), g2.isub(d2)); + } + var k2; + return a2.cmpn(1) === 0 ? k2 = d2 : k2 = g2, k2.cmpn(0) < 0 && k2.iadd(f2), k2; + }, o2.prototype.gcd = function(f2) { + if (this.isZero()) + return f2.abs(); + if (f2.isZero()) + return this.abs(); + var a2 = this.clone(), c2 = f2.clone(); + a2.negative = 0, c2.negative = 0; + for (var d2 = 0; a2.isEven() && c2.isEven(); d2++) + a2.iushrn(1), c2.iushrn(1); + do { + for (; a2.isEven(); ) + a2.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g2 = a2.cmp(c2); + if (g2 < 0) { + var x2 = a2; + a2 = c2, c2 = x2; + } else if (g2 === 0 || c2.cmpn(1) === 0) + break; + a2.isub(c2); + } while (true); + return c2.iushln(d2); + }, o2.prototype.invm = function(f2) { + return this.egcd(f2).a.umod(f2); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f2) { + return this.words[0] & f2; + }, o2.prototype.bincn = function(f2) { + i2(typeof f2 == "number"); + var a2 = f2 % 26, c2 = (f2 - a2) / 26, d2 = 1 << a2; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d2, this; + for (var g2 = d2, x2 = c2; g2 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g2, g2 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g2 !== 0 && (this.words[x2] = g2, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f2) { + var a2 = f2 < 0; + if (this.negative !== 0 && !a2) + return -1; + if (this.negative === 0 && a2) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a2 && (f2 = -f2), i2(f2 <= 67108863, "Number is too big"); + var d2 = this.words[0] | 0; + c2 = d2 === f2 ? 0 : d2 < f2 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f2) { + if (this.negative !== 0 && f2.negative === 0) + return -1; + if (this.negative === 0 && f2.negative !== 0) + return 1; + var a2 = this.ucmp(f2); + return this.negative !== 0 ? -a2 | 0 : a2; + }, o2.prototype.ucmp = function(f2) { + if (this.length > f2.length) + return 1; + if (this.length < f2.length) + return -1; + for (var a2 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d2 = this.words[c2] | 0, g2 = f2.words[c2] | 0; + if (d2 !== g2) { + d2 < g2 ? a2 = -1 : d2 > g2 && (a2 = 1); + break; } - return parsedReturns.data; - }); - } + } + return a2; + }, o2.prototype.gtn = function(f2) { + return this.cmpn(f2) === 1; + }, o2.prototype.gt = function(f2) { + return this.cmp(f2) === 1; + }, o2.prototype.gten = function(f2) { + return this.cmpn(f2) >= 0; + }, o2.prototype.gte = function(f2) { + return this.cmp(f2) >= 0; + }, o2.prototype.ltn = function(f2) { + return this.cmpn(f2) === -1; + }, o2.prototype.lt = function(f2) { + return this.cmp(f2) === -1; + }, o2.prototype.lten = function(f2) { + return this.cmpn(f2) <= 0; + }, o2.prototype.lte = function(f2) { + return this.cmp(f2) <= 0; + }, o2.prototype.eqn = function(f2) { + return this.cmpn(f2) === 0; + }, o2.prototype.eq = function(f2) { + return this.cmp(f2) === 0; + }, o2.red = function(f2) { + return new Y2(f2); + }, o2.prototype.toRed = function(f2) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f2.convertTo(this)._forceRed(f2); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f2) { + return this.red = f2, this; + }, o2.prototype.forceRed = function(f2) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f2); + }, o2.prototype.redAdd = function(f2) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f2); + }, o2.prototype.redIAdd = function(f2) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f2); + }, o2.prototype.redSub = function(f2) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f2); + }, o2.prototype.redISub = function(f2) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f2); + }, o2.prototype.redShl = function(f2) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f2); + }, o2.prototype.redMul = function(f2) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f2), this.red.mul(this, f2); + }, o2.prototype.redIMul = function(f2) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f2), this.red.imul(this, f2); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f2) { + return i2(this.red && !f2.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f2); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f2) { + this.name = A2, this.p = new o2(f2, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f2 = new o2(null); + return f2.words = new Array(Math.ceil(this.n / 13)), f2; + }, z2.prototype.ireduce = function(f2) { + var a2 = f2, c2; + do + this.split(a2, this.tmp), a2 = this.imulK(a2), a2 = a2.iadd(this.tmp), c2 = a2.bitLength(); + while (c2 > this.n); + var d2 = c2 < this.n ? -1 : a2.ucmp(this.p); + return d2 === 0 ? (a2.words[0] = 0, a2.length = 1) : d2 > 0 ? a2.isub(this.p) : a2.strip !== void 0 ? a2.strip() : a2._strip(), a2; + }, z2.prototype.split = function(f2, a2) { + f2.iushrn(this.n, 0, a2); + }, z2.prototype.imulK = function(f2) { + return f2.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n2(Pt2, z2), Pt2.prototype.split = function(f2, a2) { + for (var c2 = 4194303, d2 = Math.min(f2.length, 9), g2 = 0; g2 < d2; g2++) + a2.words[g2] = f2.words[g2]; + if (a2.length = d2, f2.length <= 9) { + f2.words[0] = 0, f2.length = 1; + return; + } + var x2 = f2.words[9]; + for (a2.words[a2.length++] = x2 & c2, g2 = 10; g2 < f2.length; g2++) { + var M2 = f2.words[g2] | 0; + f2.words[g2 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f2.words[g2 - 10] = x2, x2 === 0 && f2.length > 10 ? f2.length -= 10 : f2.length -= 9; + }, Pt2.prototype.imulK = function(f2) { + f2.words[f2.length] = 0, f2.words[f2.length + 1] = 0, f2.length += 2; + for (var a2 = 0, c2 = 0; c2 < f2.length; c2++) { + var d2 = f2.words[c2] | 0; + a2 += d2 * 977, f2.words[c2] = a2 & 67108863, a2 = d2 * 64 + (a2 / 67108864 | 0); + } + return f2.words[f2.length - 1] === 0 && (f2.length--, f2.words[f2.length - 1] === 0 && f2.length--), f2; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n2(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n2(Rt2, z2); + function Yt2() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n2(Yt2, z2), Yt2.prototype.imulK = function(f2) { + for (var a2 = 0, c2 = 0; c2 < f2.length; c2++) { + var d2 = (f2.words[c2] | 0) * 19 + a2, g2 = d2 & 67108863; + d2 >>>= 26, f2.words[c2] = g2, a2 = d2; + } + return a2 !== 0 && (f2.words[f2.length++] = a2), f2; + }, o2._prime = function(f2) { + if (H2[f2]) + return H2[f2]; + var a2; + if (f2 === "k256") + a2 = new Pt2(); + else if (f2 === "p224") + a2 = new W2(); + else if (f2 === "p192") + a2 = new Rt2(); + else if (f2 === "p25519") + a2 = new Yt2(); + else + throw new Error("Unknown prime " + f2); + return H2[f2] = a2, a2; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f2 = o2._prime(A2); + this.m = f2.p, this.prime = f2; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f2) { + i2(f2.negative === 0, "red works only with positives"), i2(f2.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f2, a2) { + i2((f2.negative | a2.negative) === 0, "red works only with positives"), i2(f2.red && f2.red === a2.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f2) { + return this.prime ? this.prime.ireduce(f2)._forceRed(this) : (w2(f2, f2.umod(this.m)._forceRed(this)), f2); + }, Y2.prototype.neg = function(f2) { + return f2.isZero() ? f2.clone() : this.m.sub(f2)._forceRed(this); + }, Y2.prototype.add = function(f2, a2) { + this._verify2(f2, a2); + var c2 = f2.add(a2); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f2, a2) { + this._verify2(f2, a2); + var c2 = f2.iadd(a2); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f2, a2) { + this._verify2(f2, a2); + var c2 = f2.sub(a2); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f2, a2) { + this._verify2(f2, a2); + var c2 = f2.isub(a2); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f2, a2) { + return this._verify1(f2), this.imod(f2.ushln(a2)); + }, Y2.prototype.imul = function(f2, a2) { + return this._verify2(f2, a2), this.imod(f2.imul(a2)); + }, Y2.prototype.mul = function(f2, a2) { + return this._verify2(f2, a2), this.imod(f2.mul(a2)); + }, Y2.prototype.isqr = function(f2) { + return this.imul(f2, f2.clone()); + }, Y2.prototype.sqr = function(f2) { + return this.mul(f2, f2); + }, Y2.prototype.sqrt = function(f2) { + if (f2.isZero()) + return f2.clone(); + var a2 = this.m.andln(3); + if (i2(a2 % 2 === 1), a2 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f2, c2); + } + for (var d2 = this.m.subn(1), g2 = 0; !d2.isZero() && d2.andln(1) === 0; ) + g2++, d2.iushrn(1); + i2(!d2.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v2 = this.pow(s2, d2), k2 = this.pow(f2, d2.addn(1).iushrn(1)), u2 = this.pow(f2, d2), E2 = g2; u2.cmp(x2) !== 0; ) { + for (var _2 = u2, B2 = 0; _2.cmp(x2) !== 0; B2++) + _2 = _2.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v2, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v2 = R2.redSqr(), u2 = u2.redMul(v2), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f2) { + var a2 = f2._invmp(this.m); + return a2.negative !== 0 ? (a2.negative = 0, this.imod(a2).redNeg()) : this.imod(a2); + }, Y2.prototype.pow = function(f2, a2) { + if (a2.isZero()) + return new o2(1).toRed(this); + if (a2.cmpn(1) === 0) + return f2.clone(); + var c2 = 4, d2 = new Array(1 << c2); + d2[0] = new o2(1).toRed(this), d2[1] = f2; + for (var g2 = 2; g2 < d2.length; g2++) + d2[g2] = this.mul(d2[g2 - 1], f2); + var x2 = d2[0], M2 = 0, l2 = 0, s2 = a2.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g2 = a2.length - 1; g2 >= 0; g2--) { + for (var v2 = a2.words[g2], k2 = s2 - 1; k2 >= 0; k2--) { + var u2 = v2 >> k2 & 1; + if (x2 !== d2[0] && (x2 = this.sqr(x2)), u2 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u2, l2++, !(l2 !== c2 && (g2 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d2[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f2) { + var a2 = f2.umod(this.m); + return a2 === f2 ? a2.clone() : a2; + }, Y2.prototype.convertFrom = function(f2) { + var a2 = f2.clone(); + return a2.red = null, a2; + }, o2.mont = function(f2) { + return new Vt2(f2); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n2(Vt2, Y2), Vt2.prototype.convertTo = function(f2) { + return this.imod(f2.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f2) { + var a2 = this.imod(f2.mul(this.rinv)); + return a2.red = null, a2; + }, Vt2.prototype.imul = function(f2, a2) { + if (f2.isZero() || a2.isZero()) + return f2.words[0] = 0, f2.length = 1, f2; + var c2 = f2.imul(a2), d2 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g2 = c2.isub(d2).iushrn(this.shift), x2 = g2; + return g2.cmp(this.m) >= 0 ? x2 = g2.isub(this.m) : g2.cmpn(0) < 0 && (x2 = g2.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f2, a2) { + if (f2.isZero() || a2.isZero()) + return new o2(0)._forceRed(this); + var c2 = f2.mul(a2), d2 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g2 = c2.isub(d2).iushrn(this.shift), x2 = g2; + return g2.cmp(this.m) >= 0 ? x2 = g2.isub(this.m) : g2.cmpn(0) < 0 && (x2 = g2.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f2) { + var a2 = this.imod(f2._invmp(this.m).mul(this.r2)); + return a2._forceRed(this); + }; + })(e2, On); + })(Ln); + var K$1 = Ln.exports; + const jn = "bignumber/5.7.0"; + var Rr = K$1.BN; + const Ae$1 = new L$2(jn), wi = {}, Qn = 9007199254740991; + function C0(e2) { + return e2 != null && (V$1.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt$1(e2) || typeof e2 == "bigint" || ir$1(e2)); + } + let Jn = false; + let V$1 = class V2 { + constructor(t2, r2) { + t2 !== wi && Ae$1.throwError("cannot call constructor directly; use BigNumber.from", L$2.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r2, this._isBigNumber = true, Object.freeze(this); } - parameters() { - return this._def.args; + fromTwos(t2) { + return Lt$1(j(this).fromTwos(t2)); } - returnType() { - return this._def.returns; + toTwos(t2) { + return Lt$1(j(this).toTwos(t2)); } - args(...items) { - return new ZodFunction({ - ...this._def, - args: ZodTuple.create(items).rest(ZodUnknown.create()) - }); + abs() { + return this._hex[0] === "-" ? V2.from(this._hex.substring(1)) : this; } - returns(returnType) { - return new ZodFunction({ - ...this._def, - returns: returnType - }); + add(t2) { + return Lt$1(j(this).add(j(t2))); } - implement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; + sub(t2) { + return Lt$1(j(this).sub(j(t2))); } - strictImplement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; + div(t2) { + return V2.from(t2).isZero() && Wt$1("division-by-zero", "div"), Lt$1(j(this).div(j(t2))); } - static create(args, returns, params) { - return new ZodFunction({ - args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()), - returns: returns || ZodUnknown.create(), - typeName: ZodFirstPartyTypeKind.ZodFunction, - ...processCreateParams(params) - }); + mul(t2) { + return Lt$1(j(this).mul(j(t2))); } - } - class ZodLazy extends ZodType { - get schema() { - return this._def.getter(); + mod(t2) { + const r2 = j(t2); + return r2.isNeg() && Wt$1("division-by-zero", "mod"), Lt$1(j(this).umod(r2)); } - _parse(input) { - const { ctx } = this._processInputParams(input); - const lazySchema = this._def.getter(); - return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + pow(t2) { + const r2 = j(t2); + return r2.isNeg() && Wt$1("negative-power", "pow"), Lt$1(j(this).pow(r2)); + } + and(t2) { + const r2 = j(t2); + return (this.isNegative() || r2.isNeg()) && Wt$1("unbound-bitwise-result", "and"), Lt$1(j(this).and(r2)); + } + or(t2) { + const r2 = j(t2); + return (this.isNegative() || r2.isNeg()) && Wt$1("unbound-bitwise-result", "or"), Lt$1(j(this).or(r2)); + } + xor(t2) { + const r2 = j(t2); + return (this.isNegative() || r2.isNeg()) && Wt$1("unbound-bitwise-result", "xor"), Lt$1(j(this).xor(r2)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt$1("negative-width", "mask"), Lt$1(j(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt$1("negative-width", "shl"), Lt$1(j(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt$1("negative-width", "shr"), Lt$1(j(this).shrn(t2)); + } + eq(t2) { + return j(this).eq(j(t2)); + } + lt(t2) { + return j(this).lt(j(t2)); + } + lte(t2) { + return j(this).lte(j(t2)); + } + gt(t2) { + return j(this).gt(j(t2)); + } + gte(t2) { + return j(this).gte(j(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j(this).isZero(); + } + toNumber() { + try { + return j(this).toNumber(); + } catch { + Wt$1("overflow", "toNumber", this.toString()); + } + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { + } + return Ae$1.throwError("this platform does not support BigInt", L$2.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn || (Jn = true, Ae$1.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae$1.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L$2.errors.UNEXPECTED_ARGUMENT, {}) : Ae$1.throwError("BigNumber.toString does not accept parameters", L$2.errors.UNEXPECTED_ARGUMENT, {})), j(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V2) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V2(wi, vr(t2)) : t2.match(/^-?[0-9]+$/) ? new V2(wi, vr(new Rr(t2))) : Ae$1.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt$1("underflow", "BigNumber.from", t2), (t2 >= Qn || t2 <= -Qn) && Wt$1("overflow", "BigNumber.from", t2), V2.from(String(t2)); + const r2 = t2; + if (typeof r2 == "bigint") + return V2.from(r2.toString()); + if (ir$1(r2)) + return V2.from(Kt$1(r2)); + if (r2) + if (r2.toHexString) { + const i2 = r2.toHexString(); + if (typeof i2 == "string") + return V2.from(i2); + } else { + let i2 = r2._hex; + if (i2 == null && r2.type === "BigNumber" && (i2 = r2.hex), typeof i2 == "string" && (Qt$1(i2) || i2[0] === "-" && Qt$1(i2.substring(1)))) + return V2.from(i2); + } + return Ae$1.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); } - } - ZodLazy.create = (getter, params) => { - return new ZodLazy({ - getter, - typeName: ZodFirstPartyTypeKind.ZodLazy, - ...processCreateParams(params) - }); }; - class ZodLiteral extends ZodType { - _parse(input) { - if (input.data !== this._def.value) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_literal, - expected: this._def.value - }); - return INVALID; + function vr(e2) { + if (typeof e2 != "string") + return vr(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae$1.throwArgumentError("invalid hex", "value", e2), e2 = vr(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; + } + function Lt$1(e2) { + return V$1.from(vr(e2)); + } + function j(e2) { + const t2 = V$1.from(e2).toHexString(); + return t2[0] === "-" ? new Rr("-" + t2.substring(3), 16) : new Rr(t2.substring(2), 16); + } + function Wt$1(e2, t2, r2) { + const i2 = { fault: e2, operation: t2 }; + return r2 != null && (i2.value = r2), Ae$1.throwError(e2, L$2.errors.NUMERIC_FAULT, i2); + } + const Ht$1 = new L$2(jn), mr$1 = {}, Gn = V$1.from(0), Yn = V$1.from(-1); + function Vn(e2, t2, r2, i2) { + const n2 = { fault: t2, operation: r2 }; + return i2 !== void 0 && (n2.value = i2), Ht$1.throwError(e2, L$2.errors.NUMERIC_FAULT, n2); + } + let gr = "0"; + for (; gr.length < 256; ) + gr += gr; + function xi(e2) { + if (typeof e2 != "number") + try { + e2 = V$1.from(e2).toNumber(); + } catch { } - return { status: "valid", value: input.data }; + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr.substring(0, e2) : Ht$1.throwArgumentError("invalid decimal size", "decimals", e2); + } + function Mi(e2, t2) { + t2 == null && (t2 = 0); + const r2 = xi(t2); + e2 = V$1.from(e2); + const i2 = e2.lt(Gn); + i2 && (e2 = e2.mul(Yn)); + let n2 = e2.mod(r2).toString(); + for (; n2.length < r2.length - 1; ) + n2 = "0" + n2; + n2 = n2.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r2).toString(); + return r2.length === 1 ? e2 = o2 : e2 = o2 + "." + n2, i2 && (e2 = "-" + e2), e2; + } + function be(e2, t2) { + t2 == null && (t2 = 0); + const r2 = xi(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht$1.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht$1.throwArgumentError("missing value", "value", e2); + const n2 = e2.split("."); + n2.length > 2 && Ht$1.throwArgumentError("too many decimal points", "value", e2); + let o2 = n2[0], h2 = n2[1]; + for (o2 || (o2 = "0"), h2 || (h2 = "0"); h2[h2.length - 1] === "0"; ) + h2 = h2.substring(0, h2.length - 1); + for (h2.length > r2.length - 1 && Vn("fractional component exceeds decimals", "underflow", "parseFixed"), h2 === "" && (h2 = "0"); h2.length < r2.length - 1; ) + h2 += "0"; + const p2 = V$1.from(o2), b2 = V$1.from(h2); + let m2 = p2.mul(r2).add(b2); + return i2 && (m2 = m2.mul(Yn)), m2; + } + let dr$1 = class dr2 { + constructor(t2, r2, i2, n2) { + t2 !== mr$1 && Ht$1.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L$2.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r2, this.width = i2, this.decimals = n2, this.name = (r2 ? "" : "u") + "fixed" + String(i2) + "x" + String(n2), this._multiplier = xi(n2), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr2) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r2 = true, i2 = 128, n2 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r2 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht$1.throwArgumentError("invalid fixed format", "format", t2), r2 = o2[1] !== "u", i2 = parseInt(o2[2]), n2 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h2, p2, b2) => t2[h2] == null ? b2 : (typeof t2[h2] !== p2 && Ht$1.throwArgumentError("invalid fixed format (" + h2 + " not " + p2 + ")", "format." + h2, t2[h2]), t2[h2]); + r2 = o2("signed", "boolean", r2), i2 = o2("width", "number", i2), n2 = o2("decimals", "number", n2); + } + return i2 % 8 && Ht$1.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n2 > 80 && Ht$1.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n2), new dr2(mr$1, r2, i2, n2); + } + }; + let Ut$1 = class Ut2 { + constructor(t2, r2, i2, n2) { + t2 !== mr$1 && Ht$1.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L$2.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n2, this._hex = r2, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht$1.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r2 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut2.fromValue(r2.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r2 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut2.fromValue(r2.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r2 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut2.fromValue(r2.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r2 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut2.fromValue(r2.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r2 = Ut2.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r2 = r2.subUnsafe(Wn.toFormat(r2.format))), r2; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r2 = Ut2.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r2 = r2.addUnsafe(Wn.toFormat(r2.format))), r2; + } + round(t2) { + t2 == null && (t2 = 0); + const r2 = this.toString().split("."); + if (r2.length === 1 && r2.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht$1.throwArgumentError("invalid decimal count", "decimals", t2), r2[1].length <= t2) + return this; + const i2 = Ut2.from("1" + gr.substring(0, t2), this.format), n2 = O0.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n2).floor().divUnsafe(i2); } - get value() { - return this._def.value; + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht$1.throwArgumentError("invalid byte width", "width", t2); + const r2 = V$1.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe(r2, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut2.fromString(this._value, t2); + } + static fromValue(t2, r2, i2) { + return i2 == null && r2 != null && !C0(r2) && (i2 = r2, r2 = null), r2 == null && (r2 = 0), i2 == null && (i2 = "fixed"), Ut2.fromString(Mi(t2, r2), dr$1.from(i2)); + } + static fromString(t2, r2) { + r2 == null && (r2 = "fixed"); + const i2 = dr$1.from(r2), n2 = be(t2, i2.decimals); + !i2.signed && n2.lt(Gn) && Vn("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n2.toTwos(i2.width).toHexString() : (o2 = n2.toHexString(), o2 = oe(o2, i2.width / 8)); + const h2 = Mi(n2, i2.decimals); + return new Ut2(mr$1, o2, h2, i2); + } + static fromBytes(t2, r2) { + r2 == null && (r2 = "fixed"); + const i2 = dr$1.from(r2); + if (Ot$1(t2).length > i2.width / 8) + throw new Error("overflow"); + let n2 = V$1.from(t2); + i2.signed && (n2 = n2.fromTwos(i2.width)); + const o2 = n2.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h2 = Mi(n2, i2.decimals); + return new Ut2(mr$1, o2, h2, i2); + } + static from(t2, r2) { + if (typeof t2 == "string") + return Ut2.fromString(t2, r2); + if (ir$1(t2)) + return Ut2.fromBytes(t2, r2); + try { + return Ut2.fromValue(t2, 0, r2); + } catch (i2) { + if (i2.code !== L$2.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht$1.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } + }; + const Wn = Ut$1.from(1), O0 = Ut$1.from("0.5"); + var Or; + (function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; + })(Or || (Or = {})); + var nr$1; + (function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; + })(nr$1 || (nr$1 = {})); + function T0(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r2 = 0; r2 < e2.length; r2 += 4) + t2.push(parseInt(e2.substring(r2, r2 + 4), 16)); + return t2; } - ZodLiteral.create = (value, params) => { - return new ZodLiteral({ - value, - typeName: ZodFirstPartyTypeKind.ZodLiteral, - ...processCreateParams(params) + function Si(e2, t2) { + t2 || (t2 = function(n2) { + return [parseInt(n2, 16)]; }); - }; - function createZodEnum(values, params) { - return new ZodEnum({ - values, - typeName: ZodFirstPartyTypeKind.ZodEnum, - ...processCreateParams(params) + let r2 = 0, i2 = {}; + return e2.split(",").forEach((n2) => { + let o2 = n2.split(":"); + r2 += parseInt(o2[0], 16), i2[r2] = t2(o2[1]); + }), i2; + } + function $n(e2) { + let t2 = 0; + return e2.split(",").map((r2) => { + let i2 = r2.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n2 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n2, h: t2 }; }); } - class ZodEnum extends ZodType { - _parse(input) { - if (typeof input.data !== "string") { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext(ctx, { - expected: util.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode.invalid_type - }); - return INVALID; - } - if (this._def.values.indexOf(input.data) === -1) { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_enum_value, - options: expectedValues - }); - return INVALID; + $n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0), $n("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); + function U0(e2) { + e2 = atob(e2); + const t2 = []; + for (let r2 = 0; r2 < e2.length; r2++) + t2.push(e2.charCodeAt(r2)); + return Ot$1(t2); + } + function ef(e2, t2) { + t2 == null && (t2 = 1); + const r2 = [], i2 = r2.forEach, n2 = function(o2, h2) { + i2.call(o2, function(p2) { + h2 > 0 && Array.isArray(p2) ? n2(p2, h2 - 1) : r2.push(p2); + }); + }; + return n2(e2, t2), r2; + } + function k0(e2) { + const t2 = {}; + for (let r2 = 0; r2 < e2.length; r2++) { + const i2 = e2[r2]; + t2[i2[0]] = i2[1]; + } + return t2; + } + function q0(e2) { + let t2 = 0; + function r2() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r2(), n2 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n2 += r2()); + let h2 = r2(), p2 = t2; + t2 += h2; + let b2 = 0, m2 = 0; + function w2() { + return b2 == 0 && (m2 = m2 << 8 | e2[t2++], b2 = 8), m2 >> --b2 & 1; + } + const y2 = 31, S2 = Math.pow(2, y2), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y2; H2++) + F2 = F2 << 1 | w2(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n2 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt2 = z2 + Pt2 >>> 1; + H2 < o2[Yt2] ? Pt2 = Yt2 : z2 = Yt2; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n2), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n2) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w2(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w2(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; } - return OK(input.data); + }); + } + function K0(e2) { + let t2 = 0; + return () => e2[t2++]; + } + function H0(e2) { + return K0(q0(e2)); + } + function z0(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; + } + function L0(e2, t2) { + let r2 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r2[i2] = 1 + t2(); + return r2; + } + function rf(e2, t2) { + let r2 = Array(e2); + for (let i2 = 0, n2 = -1; i2 < e2; i2++) + r2[i2] = n2 += 1 + t2(); + return r2; + } + function j0(e2, t2) { + let r2 = Array(e2); + for (let i2 = 0, n2 = 0; i2 < e2; i2++) + r2[i2] = n2 += z0(t2()); + return r2; + } + function Pr(e2, t2) { + let r2 = rf(e2(), e2), i2 = e2(), n2 = rf(i2, e2), o2 = L0(i2, e2); + for (let h2 = 0; h2 < i2; h2++) + for (let p2 = 0; p2 < o2[h2]; p2++) + r2.push(n2[h2] + p2); + return t2 ? r2.map((h2) => t2[h2]) : r2; + } + function Q0(e2) { + let t2 = []; + for (; ; ) { + let r2 = e2(); + if (r2 == 0) + break; + t2.push(G0(r2, e2)); } - get options() { - return this._def.values; + for (; ; ) { + let r2 = e2() - 1; + if (r2 < 0) + break; + t2.push(Y0(r2, e2)); } - get enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + return k0(ef(t2)); + } + function J0(e2) { + let t2 = []; + for (; ; ) { + let r2 = e2(); + if (r2 == 0) + break; + t2.push(r2); } - get Values() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + return t2; + } + function nf(e2, t2, r2) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n2 = 0; n2 < t2; n2++) + j0(e2, r2).forEach((o2, h2) => i2[h2].push(o2)); + return i2; + } + function G0(e2, t2) { + let r2 = 1 + t2(), i2 = t2(), n2 = J0(t2), o2 = nf(n2.length, 1 + e2, t2); + return ef(o2.map((h2, p2) => { + const b2 = h2[0], m2 = h2.slice(1); + return Array(n2[p2]).fill(void 0).map((w2, y2) => { + let S2 = y2 * i2; + return [b2 + y2 * r2, m2.map((I2) => I2 + S2)]; + }); + })); + } + function Y0(e2, t2) { + let r2 = 1 + t2(); + return nf(r2, 1 + e2, t2).map((n2) => [n2[0], n2.slice(1)]); + } + function V0(e2) { + let t2 = Pr(e2).sort((i2, n2) => i2 - n2); + return r2(); + function r2() { + let i2 = []; + for (; ; ) { + let m2 = Pr(e2, t2); + if (m2.length == 0) + break; + i2.push({ set: new Set(m2), node: r2() }); + } + i2.sort((m2, w2) => w2.set.size - m2.set.size); + let n2 = e2(), o2 = n2 % 3; + n2 = n2 / 3 | 0; + let h2 = !!(n2 & 1); + n2 >>= 1; + let p2 = n2 == 1, b2 = n2 == 2; + return { branches: i2, valid: o2, fe0f: h2, save: p2, check: b2 }; + } + } + function W0() { + return H0(U0("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); + } + const Dr = W0(); + new Set(Pr(Dr)), new Set(Pr(Dr)), Q0(Dr), V0(Dr); + const X0 = new Uint8Array(32); + X0.fill(0); + const os = new Uint8Array(32); + os.fill(0), V$1.from(-1); + const ss = V$1.from(0), as = V$1.from(1); + V$1.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe(as.toHexString(), 32), oe(ss.toHexString(), 32); + var se$1 = {}, Q = {}, yr = af; + function af(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); + } + af.equal = function(t2, r2, i2) { + if (t2 != r2) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r2); + }; + var Ii = { exports: {} }; + typeof Object.create == "function" ? Ii.exports = function(t2, r2) { + r2 && (t2.super_ = r2, t2.prototype = Object.create(r2.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); + } : Ii.exports = function(t2, r2) { + if (r2) { + t2.super_ = r2; + var i2 = function() { + }; + i2.prototype = r2.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; } - get Enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + }; + var us = yr, hs = Ii.exports; + Q.inherits = hs; + function cs(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; + } + function ls(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r2 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n2 = 0; n2 < e2.length; n2 += 2) + r2.push(parseInt(e2[n2] + e2[n2 + 1], 16)); + } else + for (var i2 = 0, n2 = 0; n2 < e2.length; n2++) { + var o2 = e2.charCodeAt(n2); + o2 < 128 ? r2[i2++] = o2 : o2 < 2048 ? (r2[i2++] = o2 >> 6 | 192, r2[i2++] = o2 & 63 | 128) : cs(e2, n2) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n2) & 1023), r2[i2++] = o2 >> 18 | 240, r2[i2++] = o2 >> 12 & 63 | 128, r2[i2++] = o2 >> 6 & 63 | 128, r2[i2++] = o2 & 63 | 128) : (r2[i2++] = o2 >> 12 | 224, r2[i2++] = o2 >> 6 & 63 | 128, r2[i2++] = o2 & 63 | 128); + } + else + for (n2 = 0; n2 < e2.length; n2++) + r2[n2] = e2[n2] | 0; + return r2; + } + Q.toArray = ls; + function ds(e2) { + for (var t2 = "", r2 = 0; r2 < e2.length; r2++) + t2 += hf(e2[r2].toString(16)); + return t2; + } + Q.toHex = ds; + function uf(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; + } + Q.htonl = uf; + function ps(e2, t2) { + for (var r2 = "", i2 = 0; i2 < e2.length; i2++) { + var n2 = e2[i2]; + t2 === "little" && (n2 = uf(n2)), r2 += cf(n2.toString(16)); } - extract(values) { - return ZodEnum.create(values); + return r2; + } + Q.toHex32 = ps; + function hf(e2) { + return e2.length === 1 ? "0" + e2 : e2; + } + Q.zero2 = hf; + function cf(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; + } + Q.zero8 = cf; + function vs(e2, t2, r2, i2) { + var n2 = r2 - t2; + us(n2 % 4 === 0); + for (var o2 = new Array(n2 / 4), h2 = 0, p2 = t2; h2 < o2.length; h2++, p2 += 4) { + var b2; + i2 === "big" ? b2 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b2 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h2] = b2 >>> 0; } - exclude(values) { - return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + return o2; + } + Q.join32 = vs; + function ms$1(e2, t2) { + for (var r2 = new Array(e2.length * 4), i2 = 0, n2 = 0; i2 < e2.length; i2++, n2 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r2[n2] = o2 >>> 24, r2[n2 + 1] = o2 >>> 16 & 255, r2[n2 + 2] = o2 >>> 8 & 255, r2[n2 + 3] = o2 & 255) : (r2[n2 + 3] = o2 >>> 24, r2[n2 + 2] = o2 >>> 16 & 255, r2[n2 + 1] = o2 >>> 8 & 255, r2[n2] = o2 & 255); } + return r2; } - ZodEnum.create = createZodEnum; - class ZodNativeEnum extends ZodType { - _parse(input) { - const nativeEnumValues = util.getValidEnumValues(this._def.values); - const ctx = this._getOrReturnCtx(input); - if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { - const expectedValues = util.objectValues(nativeEnumValues); - addIssueToContext(ctx, { - expected: util.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode.invalid_type - }); - return INVALID; + Q.split32 = ms$1; + function gs(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; + } + Q.rotr32 = gs; + function As(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; + } + Q.rotl32 = As; + function bs(e2, t2) { + return e2 + t2 >>> 0; + } + Q.sum32 = bs; + function ys(e2, t2, r2) { + return e2 + t2 + r2 >>> 0; + } + Q.sum32_3 = ys; + function ws(e2, t2, r2, i2) { + return e2 + t2 + r2 + i2 >>> 0; + } + Q.sum32_4 = ws; + function xs(e2, t2, r2, i2, n2) { + return e2 + t2 + r2 + i2 + n2 >>> 0; + } + Q.sum32_5 = xs; + function Ms(e2, t2, r2, i2) { + var n2 = e2[t2], o2 = e2[t2 + 1], h2 = i2 + o2 >>> 0, p2 = (h2 < i2 ? 1 : 0) + r2 + n2; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h2; + } + Q.sum64 = Ms; + function Es(e2, t2, r2, i2) { + var n2 = t2 + i2 >>> 0, o2 = (n2 < t2 ? 1 : 0) + e2 + r2; + return o2 >>> 0; + } + Q.sum64_hi = Es; + function Ss(e2, t2, r2, i2) { + var n2 = t2 + i2; + return n2 >>> 0; + } + Q.sum64_lo = Ss; + function Ns(e2, t2, r2, i2, n2, o2, h2, p2) { + var b2 = 0, m2 = t2; + m2 = m2 + i2 >>> 0, b2 += m2 < t2 ? 1 : 0, m2 = m2 + o2 >>> 0, b2 += m2 < o2 ? 1 : 0, m2 = m2 + p2 >>> 0, b2 += m2 < p2 ? 1 : 0; + var w2 = e2 + r2 + n2 + h2 + b2; + return w2 >>> 0; + } + Q.sum64_4_hi = Ns; + function Is(e2, t2, r2, i2, n2, o2, h2, p2) { + var b2 = t2 + i2 + o2 + p2; + return b2 >>> 0; + } + Q.sum64_4_lo = Is; + function _s(e2, t2, r2, i2, n2, o2, h2, p2, b2, m2) { + var w2 = 0, y2 = t2; + y2 = y2 + i2 >>> 0, w2 += y2 < t2 ? 1 : 0, y2 = y2 + o2 >>> 0, w2 += y2 < o2 ? 1 : 0, y2 = y2 + p2 >>> 0, w2 += y2 < p2 ? 1 : 0, y2 = y2 + m2 >>> 0, w2 += y2 < m2 ? 1 : 0; + var S2 = e2 + r2 + n2 + h2 + b2 + w2; + return S2 >>> 0; + } + Q.sum64_5_hi = _s; + function Bs(e2, t2, r2, i2, n2, o2, h2, p2, b2, m2) { + var w2 = t2 + i2 + o2 + p2 + m2; + return w2 >>> 0; + } + Q.sum64_5_lo = Bs; + function Cs(e2, t2, r2) { + var i2 = t2 << 32 - r2 | e2 >>> r2; + return i2 >>> 0; + } + Q.rotr64_hi = Cs; + function Rs(e2, t2, r2) { + var i2 = e2 << 32 - r2 | t2 >>> r2; + return i2 >>> 0; + } + Q.rotr64_lo = Rs; + function Os(e2, t2, r2) { + return e2 >>> r2; + } + Q.shr64_hi = Os; + function Ps(e2, t2, r2) { + var i2 = e2 << 32 - r2 | t2 >>> r2; + return i2 >>> 0; + } + Q.shr64_lo = Ps; + var fr = {}, lf = Q, Ds = yr; + function Fr() { + 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; + } + fr.BlockHash = Fr, Fr.prototype.update = function(t2, r2) { + if (t2 = lf.toArray(t2, r2), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf.join32(t2, 0, t2.length - i2, this.endian); + for (var n2 = 0; n2 < t2.length; n2 += this._delta32) + this._update(t2, n2, n2 + this._delta32); + } + return this; + }, Fr.prototype.digest = function(t2) { + return this.update(this._pad()), Ds(this.pending === null), this._digest(t2); + }, Fr.prototype._pad = function() { + var t2 = this.pendingTotal, r2 = this._delta8, i2 = r2 - (t2 + this.padLength) % r2, n2 = new Array(i2 + this.padLength); + n2[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n2[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h2 = 8; h2 < this.padLength; h2++) + n2[o2++] = 0; + n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = t2 >>> 24 & 255, n2[o2++] = t2 >>> 16 & 255, n2[o2++] = t2 >>> 8 & 255, n2[o2++] = t2 & 255; + } else + for (n2[o2++] = t2 & 255, n2[o2++] = t2 >>> 8 & 255, n2[o2++] = t2 >>> 16 & 255, n2[o2++] = t2 >>> 24 & 255, n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = 0, n2[o2++] = 0, h2 = 8; h2 < this.padLength; h2++) + n2[o2++] = 0; + return n2; + }; + var or = {}, ae$1 = {}, Fs = Q, ue = Fs.rotr32; + function Ts(e2, t2, r2, i2) { + if (e2 === 0) + return df(t2, r2, i2); + if (e2 === 1 || e2 === 3) + return vf(t2, r2, i2); + if (e2 === 2) + return pf(t2, r2, i2); + } + ae$1.ft_1 = Ts; + function df(e2, t2, r2) { + return e2 & t2 ^ ~e2 & r2; + } + ae$1.ch32 = df; + function pf(e2, t2, r2) { + return e2 & t2 ^ e2 & r2 ^ t2 & r2; + } + ae$1.maj32 = pf; + function vf(e2, t2, r2) { + return e2 ^ t2 ^ r2; + } + ae$1.p32 = vf; + function Us(e2) { + return ue(e2, 2) ^ ue(e2, 13) ^ ue(e2, 22); + } + ae$1.s0_256 = Us; + function ks(e2) { + return ue(e2, 6) ^ ue(e2, 11) ^ ue(e2, 25); + } + ae$1.s1_256 = ks; + function qs(e2) { + return ue(e2, 7) ^ ue(e2, 18) ^ e2 >>> 3; + } + ae$1.g0_256 = qs; + function Ks(e2) { + return ue(e2, 17) ^ ue(e2, 19) ^ e2 >>> 10; + } + ae$1.g1_256 = Ks; + var sr$1 = Q, Hs = fr, zs = ae$1, _i = sr$1.rotl32, wr$1 = sr$1.sum32, Ls = sr$1.sum32_5, js = zs.ft_1, mf = Hs.BlockHash, Qs = [1518500249, 1859775393, 2400959708, 3395469782]; + function he$1() { + if (!(this instanceof he$1)) + return new he$1(); + mf.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); + } + sr$1.inherits(he$1, mf); + var Js = he$1; + he$1.blockSize = 512, he$1.outSize = 160, he$1.hmacStrength = 80, he$1.padLength = 64, he$1.prototype._update = function(t2, r2) { + for (var i2 = this.W, n2 = 0; n2 < 16; n2++) + i2[n2] = t2[r2 + n2]; + for (; n2 < i2.length; n2++) + i2[n2] = _i(i2[n2 - 3] ^ i2[n2 - 8] ^ i2[n2 - 14] ^ i2[n2 - 16], 1); + var o2 = this.h[0], h2 = this.h[1], p2 = this.h[2], b2 = this.h[3], m2 = this.h[4]; + for (n2 = 0; n2 < i2.length; n2++) { + var w2 = ~~(n2 / 20), y2 = Ls(_i(o2, 5), js(w2, h2, p2, b2), m2, i2[n2], Qs[w2]); + m2 = b2, b2 = p2, p2 = _i(h2, 30), h2 = o2, o2 = y2; + } + this.h[0] = wr$1(this.h[0], o2), this.h[1] = wr$1(this.h[1], h2), this.h[2] = wr$1(this.h[2], p2), this.h[3] = wr$1(this.h[3], b2), this.h[4] = wr$1(this.h[4], m2); + }, he$1.prototype._digest = function(t2) { + return t2 === "hex" ? sr$1.toHex32(this.h, "big") : sr$1.split32(this.h, "big"); + }; + var ar = Q, Gs = fr, ur = ae$1, Ys = yr, ie$1 = ar.sum32, Vs = ar.sum32_4, Ws = ar.sum32_5, Xs = ur.ch32, Zs = ur.maj32, $s = ur.s0_256, ta = ur.s1_256, ea = ur.g0_256, ra = ur.g1_256, gf = Gs.BlockHash, ia = [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 ce$1() { + if (!(this instanceof ce$1)) + return new ce$1(); + gf.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia, this.W = new Array(64); + } + ar.inherits(ce$1, gf); + var Af = ce$1; + ce$1.blockSize = 512, ce$1.outSize = 256, ce$1.hmacStrength = 192, ce$1.padLength = 64, ce$1.prototype._update = function(t2, r2) { + for (var i2 = this.W, n2 = 0; n2 < 16; n2++) + i2[n2] = t2[r2 + n2]; + for (; n2 < i2.length; n2++) + i2[n2] = Vs(ra(i2[n2 - 2]), i2[n2 - 7], ea(i2[n2 - 15]), i2[n2 - 16]); + var o2 = this.h[0], h2 = this.h[1], p2 = this.h[2], b2 = this.h[3], m2 = this.h[4], w2 = this.h[5], y2 = this.h[6], S2 = this.h[7]; + for (Ys(this.k.length === i2.length), n2 = 0; n2 < i2.length; n2++) { + var I2 = Ws(S2, ta(m2), Xs(m2, w2, y2), this.k[n2], i2[n2]), N2 = ie$1($s(o2), Zs(o2, h2, p2)); + S2 = y2, y2 = w2, w2 = m2, m2 = ie$1(b2, I2), b2 = p2, p2 = h2, h2 = o2, o2 = ie$1(I2, N2); + } + this.h[0] = ie$1(this.h[0], o2), this.h[1] = ie$1(this.h[1], h2), this.h[2] = ie$1(this.h[2], p2), this.h[3] = ie$1(this.h[3], b2), this.h[4] = ie$1(this.h[4], m2), this.h[5] = ie$1(this.h[5], w2), this.h[6] = ie$1(this.h[6], y2), this.h[7] = ie$1(this.h[7], S2); + }, ce$1.prototype._digest = function(t2) { + return t2 === "hex" ? ar.toHex32(this.h, "big") : ar.split32(this.h, "big"); + }; + var Bi = Q, bf = Af; + function ye$1() { + if (!(this instanceof ye$1)) + return new ye$1(); + bf.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; + } + Bi.inherits(ye$1, bf); + var na = ye$1; + ye$1.blockSize = 512, ye$1.outSize = 224, ye$1.hmacStrength = 192, ye$1.padLength = 64, ye$1.prototype._digest = function(t2) { + return t2 === "hex" ? Bi.toHex32(this.h.slice(0, 7), "big") : Bi.split32(this.h.slice(0, 7), "big"); + }; + var jt$1 = Q, fa = fr, oa = yr, le$1 = jt$1.rotr64_hi, de$1 = jt$1.rotr64_lo, yf = jt$1.shr64_hi, wf = jt$1.shr64_lo, Be$1 = jt$1.sum64, Ci = jt$1.sum64_hi, Ri = jt$1.sum64_lo, sa = jt$1.sum64_4_hi, aa = jt$1.sum64_4_lo, ua = jt$1.sum64_5_hi, ha = jt$1.sum64_5_lo, xf = fa.BlockHash, ca = [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 ne$1() { + if (!(this instanceof ne$1)) + return new ne$1(); + xf.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca, this.W = new Array(160); + } + jt$1.inherits(ne$1, xf); + var Mf = ne$1; + ne$1.blockSize = 1024, ne$1.outSize = 512, ne$1.hmacStrength = 192, ne$1.padLength = 128, ne$1.prototype._prepareBlock = function(t2, r2) { + for (var i2 = this.W, n2 = 0; n2 < 32; n2++) + i2[n2] = t2[r2 + n2]; + for (; n2 < i2.length; n2 += 2) { + var o2 = xa(i2[n2 - 4], i2[n2 - 3]), h2 = Ma(i2[n2 - 4], i2[n2 - 3]), p2 = i2[n2 - 14], b2 = i2[n2 - 13], m2 = ya(i2[n2 - 30], i2[n2 - 29]), w2 = wa(i2[n2 - 30], i2[n2 - 29]), y2 = i2[n2 - 32], S2 = i2[n2 - 31]; + i2[n2] = sa(o2, h2, p2, b2, m2, w2, y2, S2), i2[n2 + 1] = aa(o2, h2, p2, b2, m2, w2, y2, S2); + } + }, ne$1.prototype._update = function(t2, r2) { + this._prepareBlock(t2, r2); + var i2 = this.W, n2 = this.h[0], o2 = this.h[1], h2 = this.h[2], p2 = this.h[3], b2 = this.h[4], m2 = this.h[5], w2 = this.h[6], y2 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa(S2, I2), W2 = ba(S2, I2), Rt2 = la(S2, I2, N2, C2, F2), Yt2 = da(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f2 = i2[G2 + 1], a2 = ua(H2, z2, Pt2, W2, Rt2, Yt2, Y2, Vt2, A2, f2), c2 = ha(H2, z2, Pt2, W2, Rt2, Yt2, Y2, Vt2, A2, f2); + H2 = ma(n2, o2), z2 = ga(n2, o2), Pt2 = pa(n2, o2, h2, p2, b2), W2 = va(n2, o2, h2, p2, b2, m2); + var d2 = Ci(H2, z2, Pt2, W2), g2 = Ri(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci(w2, y2, a2, c2), I2 = Ri(y2, y2, a2, c2), w2 = b2, y2 = m2, b2 = h2, m2 = p2, h2 = n2, p2 = o2, n2 = Ci(a2, c2, d2, g2), o2 = Ri(a2, c2, d2, g2); + } + Be$1(this.h, 0, n2, o2), Be$1(this.h, 2, h2, p2), Be$1(this.h, 4, b2, m2), Be$1(this.h, 6, w2, y2), Be$1(this.h, 8, S2, I2), Be$1(this.h, 10, N2, C2), Be$1(this.h, 12, F2, U2), Be$1(this.h, 14, J2, Bt2); + }, ne$1.prototype._digest = function(t2) { + return t2 === "hex" ? jt$1.toHex32(this.h, "big") : jt$1.split32(this.h, "big"); + }; + function la(e2, t2, r2, i2, n2) { + var o2 = e2 & r2 ^ ~e2 & n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function da(e2, t2, r2, i2, n2, o2) { + var h2 = t2 & i2 ^ ~t2 & o2; + return h2 < 0 && (h2 += 4294967296), h2; + } + function pa(e2, t2, r2, i2, n2) { + var o2 = e2 & r2 ^ e2 & n2 ^ r2 & n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function va(e2, t2, r2, i2, n2, o2) { + var h2 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h2 < 0 && (h2 += 4294967296), h2; + } + function ma(e2, t2) { + var r2 = le$1(e2, t2, 28), i2 = le$1(t2, e2, 2), n2 = le$1(t2, e2, 7), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function ga(e2, t2) { + var r2 = de$1(e2, t2, 28), i2 = de$1(t2, e2, 2), n2 = de$1(t2, e2, 7), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function Aa(e2, t2) { + var r2 = le$1(e2, t2, 14), i2 = le$1(e2, t2, 18), n2 = le$1(t2, e2, 9), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function ba(e2, t2) { + var r2 = de$1(e2, t2, 14), i2 = de$1(e2, t2, 18), n2 = de$1(t2, e2, 9), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function ya(e2, t2) { + var r2 = le$1(e2, t2, 1), i2 = le$1(e2, t2, 8), n2 = yf(e2, t2, 7), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function wa(e2, t2) { + var r2 = de$1(e2, t2, 1), i2 = de$1(e2, t2, 8), n2 = wf(e2, t2, 7), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function xa(e2, t2) { + var r2 = le$1(e2, t2, 19), i2 = le$1(t2, e2, 29), n2 = yf(e2, t2, 6), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + function Ma(e2, t2) { + var r2 = de$1(e2, t2, 19), i2 = de$1(t2, e2, 29), n2 = wf(e2, t2, 6), o2 = r2 ^ i2 ^ n2; + return o2 < 0 && (o2 += 4294967296), o2; + } + var Oi = Q, Ef = Mf; + function we$1() { + if (!(this instanceof we$1)) + return new we$1(); + Ef.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; + } + Oi.inherits(we$1, Ef); + var Ea = we$1; + we$1.blockSize = 1024, we$1.outSize = 384, we$1.hmacStrength = 192, we$1.padLength = 128, we$1.prototype._digest = function(t2) { + return t2 === "hex" ? Oi.toHex32(this.h.slice(0, 12), "big") : Oi.split32(this.h.slice(0, 12), "big"); + }, or.sha1 = Js, or.sha224 = na, or.sha256 = Af, or.sha384 = Ea, or.sha512 = Mf; + var Sf = {}, Xe = Q, Sa = fr, Tr = Xe.rotl32, Nf = Xe.sum32, xr = Xe.sum32_3, If = Xe.sum32_4, _f = Sa.BlockHash; + function pe$1() { + if (!(this instanceof pe$1)) + return new pe$1(); + _f.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; + } + Xe.inherits(pe$1, _f), Sf.ripemd160 = pe$1, pe$1.blockSize = 512, pe$1.outSize = 160, pe$1.hmacStrength = 192, pe$1.padLength = 64, pe$1.prototype._update = function(t2, r2) { + for (var i2 = this.h[0], n2 = this.h[1], o2 = this.h[2], h2 = this.h[3], p2 = this.h[4], b2 = i2, m2 = n2, w2 = o2, y2 = h2, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf(Tr(If(i2, Bf(I2, n2, o2, h2), t2[_a[I2] + r2], Na(I2)), Ca[I2]), p2); + i2 = p2, p2 = h2, h2 = Tr(o2, 10), o2 = n2, n2 = N2, N2 = Nf(Tr(If(b2, Bf(79 - I2, m2, w2, y2), t2[Ba[I2] + r2], Ia(I2)), Ra[I2]), S2), b2 = S2, S2 = y2, y2 = Tr(w2, 10), w2 = m2, m2 = N2; + } + N2 = xr(this.h[1], o2, y2), this.h[1] = xr(this.h[2], h2, S2), this.h[2] = xr(this.h[3], p2, b2), this.h[3] = xr(this.h[4], i2, m2), this.h[4] = xr(this.h[0], n2, w2), this.h[0] = N2; + }, pe$1.prototype._digest = function(t2) { + return t2 === "hex" ? Xe.toHex32(this.h, "little") : Xe.split32(this.h, "little"); + }; + function Bf(e2, t2, r2, i2) { + return e2 <= 15 ? t2 ^ r2 ^ i2 : e2 <= 31 ? t2 & r2 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r2) ^ i2 : e2 <= 63 ? t2 & i2 | r2 & ~i2 : t2 ^ (r2 | ~i2); + } + function Na(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; + } + function Ia(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; + } + var _a = [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], Ba = [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], Ca = [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], Ra = [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], Oa = Q, Pa = yr; + function hr(e2, t2, r2) { + if (!(this instanceof hr)) + return new hr(e2, t2, r2); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa.toArray(t2, r2)); + } + var Da = hr; + hr.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa(t2.length <= this.blockSize); + for (var r2 = t2.length; r2 < this.blockSize; r2++) + t2.push(0); + for (r2 = 0; r2 < t2.length; r2++) + t2[r2] ^= 54; + for (this.inner = new this.Hash().update(t2), r2 = 0; r2 < t2.length; r2++) + t2[r2] ^= 106; + this.outer = new this.Hash().update(t2); + }, hr.prototype.update = function(t2, r2) { + return this.inner.update(t2, r2), this; + }, hr.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); + }, function(e2) { + var t2 = e2; + t2.utils = Q, t2.common = fr, t2.sha = or, t2.ripemd = Sf, t2.hmac = Da, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; + }(se$1); + function cr$1(e2, t2, r2) { + return r2 = { path: t2, exports: {}, require: function(i2, n2) { + return Fa(i2, n2 ?? r2.path); + } }, e2(r2, r2.exports), r2.exports; + } + function Fa() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); + } + var Pi = Cf; + function Cf(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); + } + Cf.equal = function(t2, r2, i2) { + if (t2 != r2) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r2); + }; + var fe$1 = cr$1(function(e2, t2) { + var r2 = t2; + function i2(h2, p2) { + if (Array.isArray(h2)) + return h2.slice(); + if (!h2) + return []; + var b2 = []; + if (typeof h2 != "string") { + for (var m2 = 0; m2 < h2.length; m2++) + b2[m2] = h2[m2] | 0; + return b2; + } + if (p2 === "hex") { + h2 = h2.replace(/[^a-z0-9]+/ig, ""), h2.length % 2 !== 0 && (h2 = "0" + h2); + for (var m2 = 0; m2 < h2.length; m2 += 2) + b2.push(parseInt(h2[m2] + h2[m2 + 1], 16)); + } else + for (var m2 = 0; m2 < h2.length; m2++) { + var w2 = h2.charCodeAt(m2), y2 = w2 >> 8, S2 = w2 & 255; + y2 ? b2.push(y2, S2) : b2.push(S2); + } + return b2; + } + r2.toArray = i2; + function n2(h2) { + return h2.length === 1 ? "0" + h2 : h2; + } + r2.zero2 = n2; + function o2(h2) { + for (var p2 = "", b2 = 0; b2 < h2.length; b2++) + p2 += n2(h2[b2].toString(16)); + return p2; + } + r2.toHex = o2, r2.encode = function(p2, b2) { + return b2 === "hex" ? o2(p2) : p2; + }; + }), Jt$1 = cr$1(function(e2, t2) { + var r2 = t2; + r2.assert = Pi, r2.toArray = fe$1.toArray, r2.zero2 = fe$1.zero2, r2.toHex = fe$1.toHex, r2.encode = fe$1.encode; + function i2(b2, m2, w2) { + var y2 = new Array(Math.max(b2.bitLength(), w2) + 1); + y2.fill(0); + for (var S2 = 1 << m2 + 1, I2 = b2.clone(), N2 = 0; N2 < y2.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y2[N2] = C2, I2.iushrn(1); + } + return y2; + } + r2.getNAF = i2; + function n2(b2, m2) { + var w2 = [[], []]; + b2 = b2.clone(), m2 = m2.clone(); + for (var y2 = 0, S2 = 0, I2; b2.cmpn(-y2) > 0 || m2.cmpn(-S2) > 0; ) { + var N2 = b2.andln(3) + y2 & 3, C2 = m2.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b2.andln(7) + y2 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w2[0].push(F2); + var U2; + C2 & 1 ? (I2 = m2.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w2[1].push(U2), 2 * y2 === F2 + 1 && (y2 = 1 - y2), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b2.iushrn(1), m2.iushrn(1); + } + return w2; + } + r2.getJSF = n2; + function o2(b2, m2, w2) { + var y2 = "_" + m2; + b2.prototype[m2] = function() { + return this[y2] !== void 0 ? this[y2] : this[y2] = w2.call(this); + }; + } + r2.cachedProperty = o2; + function h2(b2) { + return typeof b2 == "string" ? r2.toArray(b2, "hex") : b2; + } + r2.parseBytes = h2; + function p2(b2) { + return new K$1(b2, "hex", "le"); + } + r2.intFromLE = p2; + }), Ur = Jt$1.getNAF, Ta = Jt$1.getJSF, kr = Jt$1.assert; + function Ce$1(e2, t2) { + this.type = e2, this.p = new K$1(t2.p, 16), this.red = t2.prime ? K$1.red(t2.prime) : K$1.mont(this.p), this.zero = new K$1(0).toRed(this.red), this.one = new K$1(1).toRed(this.red), this.two = new K$1(2).toRed(this.red), this.n = t2.n && new K$1(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r2 = this.n && this.p.div(this.n); + !r2 || r2.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); + } + var Ze$1 = Ce$1; + Ce$1.prototype.point = function() { + throw new Error("Not implemented"); + }, Ce$1.prototype.validate = function() { + throw new Error("Not implemented"); + }, Ce$1.prototype._fixedNafMul = function(t2, r2) { + kr(t2.precomputed); + var i2 = t2._getDoubles(), n2 = Ur(r2, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h2 = [], p2, b2; + for (p2 = 0; p2 < n2.length; p2 += i2.step) { + b2 = 0; + for (var m2 = p2 + i2.step - 1; m2 >= p2; m2--) + b2 = (b2 << 1) + n2[m2]; + h2.push(b2); + } + for (var w2 = this.jpoint(null, null, null), y2 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h2.length; p2++) + b2 = h2[p2], b2 === S2 ? y2 = y2.mixedAdd(i2.points[p2]) : b2 === -S2 && (y2 = y2.mixedAdd(i2.points[p2].neg())); + w2 = w2.add(y2); + } + return w2.toP(); + }, Ce$1.prototype._wnafMul = function(t2, r2) { + var i2 = 4, n2 = t2._getNAFPoints(i2); + i2 = n2.wnd; + for (var o2 = n2.points, h2 = Ur(r2, i2, this._bitLength), p2 = this.jpoint(null, null, null), b2 = h2.length - 1; b2 >= 0; b2--) { + for (var m2 = 0; b2 >= 0 && h2[b2] === 0; b2--) + m2++; + if (b2 >= 0 && m2++, p2 = p2.dblp(m2), b2 < 0) + break; + var w2 = h2[b2]; + kr(w2 !== 0), t2.type === "affine" ? w2 > 0 ? p2 = p2.mixedAdd(o2[w2 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w2 - 1 >> 1].neg()) : w2 > 0 ? p2 = p2.add(o2[w2 - 1 >> 1]) : p2 = p2.add(o2[-w2 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; + }, Ce$1.prototype._wnafMulAdd = function(t2, r2, i2, n2, o2) { + var h2 = this._wnafT1, p2 = this._wnafT2, b2 = this._wnafT3, m2 = 0, w2, y2, S2; + for (w2 = 0; w2 < n2; w2++) { + S2 = r2[w2]; + var I2 = S2._getNAFPoints(t2); + h2[w2] = I2.wnd, p2[w2] = I2.points; + } + for (w2 = n2 - 1; w2 >= 1; w2 -= 2) { + var N2 = w2 - 1, C2 = w2; + if (h2[N2] !== 1 || h2[C2] !== 1) { + b2[N2] = Ur(i2[N2], h2[N2], this._bitLength), b2[C2] = Ur(i2[C2], h2[C2], this._bitLength), m2 = Math.max(b2[N2].length, m2), m2 = Math.max(b2[C2].length, m2); + continue; + } + var F2 = [r2[N2], null, null, r2[C2]]; + r2[N2].y.cmp(r2[C2].y) === 0 ? (F2[1] = r2[N2].add(r2[C2]), F2[2] = r2[N2].toJ().mixedAdd(r2[C2].neg())) : r2[N2].y.cmp(r2[C2].y.redNeg()) === 0 ? (F2[1] = r2[N2].toJ().mixedAdd(r2[C2]), F2[2] = r2[N2].add(r2[C2].neg())) : (F2[1] = r2[N2].toJ().mixedAdd(r2[C2]), F2[2] = r2[N2].toJ().mixedAdd(r2[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta(i2[N2], i2[C2]); + for (m2 = Math.max(J2[0].length, m2), b2[N2] = new Array(m2), b2[C2] = new Array(m2), y2 = 0; y2 < m2; y2++) { + var Bt2 = J2[0][y2] | 0, G2 = J2[1][y2] | 0; + b2[N2][y2] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b2[C2][y2] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w2 = m2; w2 >= 0; w2--) { + for (var Pt2 = 0; w2 >= 0; ) { + var W2 = true; + for (y2 = 0; y2 < n2; y2++) + z2[y2] = b2[y2][w2] | 0, z2[y2] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w2--; } - if (nativeEnumValues.indexOf(input.data) === -1) { - const expectedValues = util.objectValues(nativeEnumValues); - addIssueToContext(ctx, { - received: ctx.data, - code: ZodIssueCode.invalid_enum_value, - options: expectedValues - }); - return INVALID; + if (w2 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w2 < 0) + break; + for (y2 = 0; y2 < n2; y2++) { + var Rt2 = z2[y2]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y2][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y2][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w2 = 0; w2 < n2; w2++) + p2[w2] = null; + return o2 ? H2 : H2.toP(); + }; + function Xt$1(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; + } + Ce$1.BasePoint = Xt$1, Xt$1.prototype.eq = function() { + throw new Error("Not implemented"); + }, Xt$1.prototype.validate = function() { + return this.curve.validate(this); + }, Ce$1.prototype.decodePoint = function(t2, r2) { + t2 = Jt$1.toArray(t2, r2); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr(t2[t2.length - 1] % 2 === 1); + var n2 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n2; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); + }, Xt$1.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); + }, Xt$1.prototype._encode = function(t2) { + var r2 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r2); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r2)); + }, Xt$1.prototype.encode = function(t2, r2) { + return Jt$1.encode(this._encode(r2), t2); + }, Xt$1.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r2 = { doubles: null, naf: null, beta: null }; + return r2.naf = this._getNAFPoints(8), r2.doubles = this._getDoubles(4, t2), r2.beta = this._getBeta(), this.precomputed = r2, this; + }, Xt$1.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r2 = this.precomputed.doubles; + return r2 ? r2.points.length >= Math.ceil((t2.bitLength() + 1) / r2.step) : false; + }, Xt$1.prototype._getDoubles = function(t2, r2) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n2 = this, o2 = 0; o2 < r2; o2 += t2) { + for (var h2 = 0; h2 < t2; h2++) + n2 = n2.dbl(); + i2.push(n2); + } + return { step: t2, points: i2 }; + }, Xt$1.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r2 = [this], i2 = (1 << t2) - 1, n2 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r2[o2] = r2[o2 - 1].add(n2); + return { wnd: t2, points: r2 }; + }, Xt$1.prototype._getBeta = function() { + return null; + }, Xt$1.prototype.dblp = function(t2) { + for (var r2 = this, i2 = 0; i2 < t2; i2++) + r2 = r2.dbl(); + return r2; + }; + var Di = cr$1(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r2, i2) { + i2 && (r2.super_ = i2, r2.prototype = Object.create(i2.prototype, { constructor: { value: r2, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r2, i2) { + if (i2) { + r2.super_ = i2; + var n2 = function() { + }; + n2.prototype = i2.prototype, r2.prototype = new n2(), r2.prototype.constructor = r2; } - return OK(input.data); + }; + }), Ua = Jt$1.assert; + function Zt$1(e2) { + Ze$1.call(this, "short", e2), this.a = new K$1(e2.a, 16).toRed(this.red), this.b = new K$1(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); + } + Di(Zt$1, Ze$1); + var ka = Zt$1; + Zt$1.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r2, i2; + if (t2.beta) + r2 = new K$1(t2.beta, 16).toRed(this.red); + else { + var n2 = this._getEndoRoots(this.p); + r2 = n2[0].cmp(n2[1]) < 0 ? n2[0] : n2[1], r2 = r2.toRed(this.red); + } + if (t2.lambda) + i2 = new K$1(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r2)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua(this.g.mul(i2).x.cmp(this.g.x.redMul(r2)) === 0)); + } + var h2; + return t2.basis ? h2 = t2.basis.map(function(p2) { + return { a: new K$1(p2.a, 16), b: new K$1(p2.b, 16) }; + }) : h2 = this._getEndoBasis(i2), { beta: r2, lambda: i2, basis: h2 }; + } + }, Zt$1.prototype._getEndoRoots = function(t2) { + var r2 = t2 === this.p ? this.red : K$1.mont(t2), i2 = new K$1(2).toRed(r2).redInvm(), n2 = i2.redNeg(), o2 = new K$1(3).toRed(r2).redNeg().redSqrt().redMul(i2), h2 = n2.redAdd(o2).fromRed(), p2 = n2.redSub(o2).fromRed(); + return [h2, p2]; + }, Zt$1.prototype._getEndoBasis = function(t2) { + for (var r2 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n2 = this.n.clone(), o2 = new K$1(1), h2 = new K$1(0), p2 = new K$1(0), b2 = new K$1(1), m2, w2, y2, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n2.div(i2); + U2 = n2.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b2.sub(Bt2.mul(h2)); + if (!y2 && U2.cmp(r2) < 0) + m2 = C2.neg(), w2 = o2, y2 = U2.neg(), S2 = J2; + else if (y2 && ++F2 === 2) + break; + C2 = U2, n2 = i2, i2 = U2, p2 = o2, o2 = J2, b2 = h2, h2 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y2.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m2, N2 = w2), y2.negative && (y2 = y2.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y2, b: S2 }, { a: I2, b: N2 }]; + }, Zt$1.prototype._endoSplit = function(t2) { + var r2 = this.endo.basis, i2 = r2[0], n2 = r2[1], o2 = n2.b.mul(t2).divRound(this.n), h2 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b2 = h2.mul(n2.a), m2 = o2.mul(i2.b), w2 = h2.mul(n2.b), y2 = t2.sub(p2).sub(b2), S2 = m2.add(w2).neg(); + return { k1: y2, k2: S2 }; + }, Zt$1.prototype.pointFromX = function(t2, r2) { + t2 = new K$1(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n2 = i2.redSqrt(); + if (n2.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n2.fromRed().isOdd(); + return (r2 && !o2 || !r2 && o2) && (n2 = n2.redNeg()), this.point(t2, n2); + }, Zt$1.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r2 = t2.x, i2 = t2.y, n2 = this.a.redMul(r2), o2 = r2.redSqr().redMul(r2).redIAdd(n2).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; + }, Zt$1.prototype._endoWnafMulAdd = function(t2, r2, i2) { + for (var n2 = this._endoWnafT1, o2 = this._endoWnafT2, h2 = 0; h2 < t2.length; h2++) { + var p2 = this._endoSplit(r2[h2]), b2 = t2[h2], m2 = b2._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b2 = b2.neg(true)), p2.k2.negative && (p2.k2.ineg(), m2 = m2.neg(true)), n2[h2 * 2] = b2, n2[h2 * 2 + 1] = m2, o2[h2 * 2] = p2.k1, o2[h2 * 2 + 1] = p2.k2; + } + for (var w2 = this._wnafMulAdd(1, n2, o2, h2 * 2, i2), y2 = 0; y2 < h2 * 2; y2++) + n2[y2] = null, o2[y2] = null; + return w2; + }; + function Ft$1(e2, t2, r2, i2) { + Ze$1.BasePoint.call(this, e2, "affine"), t2 === null && r2 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K$1(t2, 16), this.y = new K$1(r2, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); + } + Di(Ft$1, Ze$1.BasePoint), Zt$1.prototype.point = function(t2, r2, i2) { + return new Ft$1(this, t2, r2, i2); + }, Zt$1.prototype.pointFromJSON = function(t2, r2) { + return Ft$1.fromJSON(this, t2, r2); + }, Ft$1.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r2 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n2 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r2, r2.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n2) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n2) } }; + } + return r2; } - get enum() { - return this._def.values; + }, Ft$1.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; + }, Ft$1.fromJSON = function(t2, r2, i2) { + typeof r2 == "string" && (r2 = JSON.parse(r2)); + var n2 = t2.point(r2[0], r2[1], i2); + if (!r2[2]) + return n2; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h2 = r2[2]; + return n2.precomputed = { beta: null, doubles: h2.doubles && { step: h2.doubles.step, points: [n2].concat(h2.doubles.points.map(o2)) }, naf: h2.naf && { wnd: h2.naf.wnd, points: [n2].concat(h2.naf.points.map(o2)) } }, n2; + }, Ft$1.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, Ft$1.prototype.isInfinity = function() { + return this.inf; + }, Ft$1.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r2 = this.y.redSub(t2.y); + r2.cmpn(0) !== 0 && (r2 = r2.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r2.redSqr().redISub(this.x).redISub(t2.x), n2 = r2.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n2); + }, Ft$1.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r2 = this.curve.a, i2 = this.x.redSqr(), n2 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r2).redMul(n2), h2 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h2)).redISub(this.y); + return this.curve.point(h2, p2); + }, Ft$1.prototype.getX = function() { + return this.x.fromRed(); + }, Ft$1.prototype.getY = function() { + return this.y.fromRed(); + }, Ft$1.prototype.mul = function(t2) { + return t2 = new K$1(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); + }, Ft$1.prototype.mulAdd = function(t2, r2, i2) { + var n2 = [this, r2], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n2, o2) : this.curve._wnafMulAdd(1, n2, o2, 2); + }, Ft$1.prototype.jmulAdd = function(t2, r2, i2) { + var n2 = [this, r2], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n2, o2, true) : this.curve._wnafMulAdd(1, n2, o2, 2, true); + }, Ft$1.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); + }, Ft$1.prototype.neg = function(t2) { + if (this.inf) + return this; + var r2 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n2 = function(o2) { + return o2.neg(); + }; + r2.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n2) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n2) } }; } - } - ZodNativeEnum.create = (values, params) => { - return new ZodNativeEnum({ - values, - typeName: ZodFirstPartyTypeKind.ZodNativeEnum, - ...processCreateParams(params) - }); + return r2; + }, Ft$1.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; }; - class ZodPromise extends ZodType { - unwrap() { - return this._def.type; + function Tt$1(e2, t2, r2, i2) { + Ze$1.BasePoint.call(this, e2, "jacobian"), t2 === null && r2 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K$1(0)) : (this.x = new K$1(t2, 16), this.y = new K$1(r2, 16), this.z = new K$1(i2, 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; + } + Di(Tt$1, Ze$1.BasePoint), Zt$1.prototype.jpoint = function(t2, r2, i2) { + return new Tt$1(this, t2, r2, i2); + }, Tt$1.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r2 = t2.redSqr(), i2 = this.x.redMul(r2), n2 = this.y.redMul(r2).redMul(t2); + return this.curve.point(i2, n2); + }, Tt$1.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }, Tt$1.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r2 = t2.z.redSqr(), i2 = this.z.redSqr(), n2 = this.x.redMul(r2), o2 = t2.x.redMul(i2), h2 = this.y.redMul(r2.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b2 = n2.redSub(o2), m2 = h2.redSub(p2); + if (b2.cmpn(0) === 0) + return m2.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w2 = b2.redSqr(), y2 = w2.redMul(b2), S2 = n2.redMul(w2), I2 = m2.redSqr().redIAdd(y2).redISub(S2).redISub(S2), N2 = m2.redMul(S2.redISub(I2)).redISub(h2.redMul(y2)), C2 = this.z.redMul(t2.z).redMul(b2); + return this.curve.jpoint(I2, N2, C2); + }, Tt$1.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r2 = this.z.redSqr(), i2 = this.x, n2 = t2.x.redMul(r2), o2 = this.y, h2 = t2.y.redMul(r2).redMul(this.z), p2 = i2.redSub(n2), b2 = o2.redSub(h2); + if (p2.cmpn(0) === 0) + return b2.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m2 = p2.redSqr(), w2 = m2.redMul(p2), y2 = i2.redMul(m2), S2 = b2.redSqr().redIAdd(w2).redISub(y2).redISub(y2), I2 = b2.redMul(y2.redISub(S2)).redISub(o2.redMul(w2)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); + }, Tt$1.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r2; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r2 = 0; r2 < t2; r2++) + i2 = i2.dbl(); + return i2; } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) { - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.promise, - received: ctx.parsedType - }); - return INVALID; - } - const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); - return OK(promisified.then((data2) => { - return this._def.type.parseAsync(data2, { - path: ctx.path, - errorMap: ctx.common.contextualErrorMap - }); - })); + var n2 = this.curve.a, o2 = this.curve.tinv, h2 = this.x, p2 = this.y, b2 = this.z, m2 = b2.redSqr().redSqr(), w2 = p2.redAdd(p2); + for (r2 = 0; r2 < t2; r2++) { + var y2 = h2.redSqr(), S2 = w2.redSqr(), I2 = S2.redSqr(), N2 = y2.redAdd(y2).redIAdd(y2).redIAdd(n2.redMul(m2)), C2 = h2.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w2.redMul(b2); + r2 + 1 < t2 && (m2 = m2.redMul(I2)), h2 = F2, b2 = Bt2, w2 = J2; + } + return this.curve.jpoint(h2, w2.redMul(o2), b2); + }, Tt$1.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); + }, Tt$1.prototype._zeroDbl = function() { + var t2, r2, i2; + if (this.zOne) { + var n2 = this.x.redSqr(), o2 = this.y.redSqr(), h2 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n2).redISub(h2); + p2 = p2.redIAdd(p2); + var b2 = n2.redAdd(n2).redIAdd(n2), m2 = b2.redSqr().redISub(p2).redISub(p2), w2 = h2.redIAdd(h2); + w2 = w2.redIAdd(w2), w2 = w2.redIAdd(w2), t2 = m2, r2 = b2.redMul(p2.redISub(m2)).redISub(w2), i2 = this.y.redAdd(this.y); + } else { + var y2 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y2).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y2.redAdd(y2).redIAdd(y2), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r2 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r2, i2); + }, Tt$1.prototype._threeDbl = function() { + var t2, r2, i2; + if (this.zOne) { + var n2 = this.x.redSqr(), o2 = this.y.redSqr(), h2 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n2).redISub(h2); + p2 = p2.redIAdd(p2); + var b2 = n2.redAdd(n2).redIAdd(n2).redIAdd(this.curve.a), m2 = b2.redSqr().redISub(p2).redISub(p2); + t2 = m2; + var w2 = h2.redIAdd(h2); + w2 = w2.redIAdd(w2), w2 = w2.redIAdd(w2), r2 = b2.redMul(p2.redISub(m2)).redISub(w2), i2 = this.y.redAdd(this.y); + } else { + var y2 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y2).redMul(this.x.redAdd(y2)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y2); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r2 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r2, i2); + }, Tt$1.prototype._dbl = function() { + var t2 = this.curve.a, r2 = this.x, i2 = this.y, n2 = this.z, o2 = n2.redSqr().redSqr(), h2 = r2.redSqr(), p2 = i2.redSqr(), b2 = h2.redAdd(h2).redIAdd(h2).redIAdd(t2.redMul(o2)), m2 = r2.redAdd(r2); + m2 = m2.redIAdd(m2); + var w2 = m2.redMul(p2), y2 = b2.redSqr().redISub(w2.redAdd(w2)), S2 = w2.redISub(y2), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b2.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n2); + return this.curve.jpoint(y2, N2, C2); + }, Tt$1.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r2 = this.y.redSqr(), i2 = this.z.redSqr(), n2 = r2.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h2 = o2.redSqr(), p2 = this.x.redAdd(r2).redSqr().redISub(t2).redISub(n2); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h2); + var b2 = p2.redSqr(), m2 = n2.redIAdd(n2); + m2 = m2.redIAdd(m2), m2 = m2.redIAdd(m2), m2 = m2.redIAdd(m2); + var w2 = o2.redIAdd(p2).redSqr().redISub(h2).redISub(b2).redISub(m2), y2 = r2.redMul(w2); + y2 = y2.redIAdd(y2), y2 = y2.redIAdd(y2); + var S2 = this.x.redMul(b2).redISub(y2); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w2.redMul(m2.redISub(w2)).redISub(p2.redMul(b2))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b2); + return this.curve.jpoint(S2, I2, N2); + }, Tt$1.prototype.mul = function(t2, r2) { + return t2 = new K$1(t2, r2), this.curve._wnafMul(this, t2); + }, Tt$1.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r2 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r2)).cmpn(0) !== 0) + return false; + var n2 = r2.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n2)).cmpn(0) === 0; + }, Tt$1.prototype.eqXToP = function(t2) { + var r2 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r2); + if (this.x.cmp(i2) === 0) + return true; + for (var n2 = t2.clone(), o2 = this.curve.redN.redMul(r2); ; ) { + if (n2.iadd(this.curve.n), n2.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; } - } - ZodPromise.create = (schema, params) => { - return new ZodPromise({ - type: schema, - typeName: ZodFirstPartyTypeKind.ZodPromise, - ...processCreateParams(params) - }); - }; - class ZodEffects extends ZodType { - innerType() { - return this._def.schema; + }, Tt$1.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, Tt$1.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; + }; + var qr = cr$1(function(e2, t2) { + var r2 = t2; + r2.base = Ze$1, r2.short = ka, r2.mont = null, r2.edwards = null; + }), Kr = cr$1(function(e2, t2) { + var r2 = t2, i2 = Jt$1.assert; + function n2(p2) { + p2.type === "short" ? this.curve = new qr.short(p2) : p2.type === "edwards" ? this.curve = new qr.edwards(p2) : this.curve = new qr.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r2.PresetCurve = n2; + function o2(p2, b2) { + Object.defineProperty(r2, p2, { configurable: true, enumerable: true, get: function() { + var m2 = new n2(b2); + return Object.defineProperty(r2, p2, { configurable: true, enumerable: true, value: m2 }), m2; + } }); + } + o2("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: se$1.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se$1.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se$1.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se$1.sha384, gRed: false, 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"] }), o2("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: se$1.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se$1.sha256, gRed: false, g: ["9"] }), o2("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: se$1.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h2; + try { + h2 = null.crash(); + } catch { + h2 = void 0; } - sourceType() { - return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + o2("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: se$1.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h2] }); + }); + function Re$1(e2) { + if (!(this instanceof Re$1)) + return new Re$1(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe$1.toArray(e2.entropy, e2.entropyEnc || "hex"), r2 = fe$1.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe$1.toArray(e2.pers, e2.persEnc || "hex"); + Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r2, i2); + } + var Rf = Re$1; + Re$1.prototype._init = function(t2, r2, i2) { + var n2 = t2.concat(r2).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n2), this._reseed = 1, this.reseedInterval = 281474976710656; + }, Re$1.prototype._hmac = function() { + return new se$1.hmac(this.hash, this.K); + }, Re$1.prototype._update = function(t2) { + var r2 = this._hmac().update(this.V).update([0]); + t2 && (r2 = r2.update(t2)), this.K = r2.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); + }, Re$1.prototype.reseed = function(t2, r2, i2, n2) { + typeof r2 != "string" && (n2 = i2, i2 = r2, r2 = null), t2 = fe$1.toArray(t2, r2), i2 = fe$1.toArray(i2, n2), Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; + }, Re$1.prototype.generate = function(t2, r2, i2, n2) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r2 != "string" && (n2 = i2, i2 = r2, r2 = null), i2 && (i2 = fe$1.toArray(i2, n2 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h2 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe$1.encode(h2, r2); + }; + var Fi = Jt$1.assert; + function kt(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); + } + var Ti = kt; + kt.fromPublic = function(t2, r2, i2) { + return r2 instanceof kt ? r2 : new kt(t2, { pub: r2, pubEnc: i2 }); + }, kt.fromPrivate = function(t2, r2, i2) { + return r2 instanceof kt ? r2 : new kt(t2, { priv: r2, privEnc: i2 }); + }, kt.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; + }, kt.prototype.getPublic = function(t2, r2) { + return typeof t2 == "string" && (r2 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r2 ? this.pub.encode(r2, t2) : this.pub; + }, kt.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; + }, kt.prototype._importPrivate = function(t2, r2) { + this.priv = new K$1(t2, r2 || 16), this.priv = this.priv.umod(this.ec.curve.n); + }, kt.prototype._importPublic = function(t2, r2) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const effect = this._def.effect || null; - if (effect.type === "preprocess") { - const processed = effect.transform(ctx.data); - if (ctx.common.async) { - return Promise.resolve(processed).then((processed2) => { - return this._def.schema._parseAsync({ - data: processed2, - path: ctx.path, - parent: ctx - }); - }); - } else { - return this._def.schema._parseSync({ - data: processed, - path: ctx.path, - parent: ctx - }); - } - } - const checkCtx = { - addIssue: (arg) => { - addIssueToContext(ctx, arg); - if (arg.fatal) { - status.abort(); - } else { - status.dirty(); - } - }, - get path() { - return ctx.path; - } - }; - checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); - if (effect.type === "refinement") { - const executeRefinement = (acc) => { - const result = effect.refinement(acc, checkCtx); - if (ctx.common.async) { - return Promise.resolve(result); - } - if (result instanceof Promise) { - throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + this.pub = this.ec.curve.decodePoint(t2, r2); + }, kt.prototype.derive = function(t2) { + return t2.validate() || Fi(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); + }, kt.prototype.sign = function(t2, r2, i2) { + return this.ec.sign(t2, this, r2, i2); + }, kt.prototype.verify = function(t2, r2) { + return this.ec.verify(t2, r2, this); + }, kt.prototype.inspect = function() { + return ""; + }; + var qa = Jt$1.assert; + function Hr(e2, t2) { + if (e2 instanceof Hr) + return e2; + this._importDER(e2, t2) || (qa(e2.r && e2.s, "Signature without r or s"), this.r = new K$1(e2.r, 16), this.s = new K$1(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); + } + var zr = Hr; + function Ka() { + this.place = 0; + } + function Ui(e2, t2) { + var r2 = e2[t2.place++]; + if (!(r2 & 128)) + return r2; + var i2 = r2 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n2 = 0, o2 = 0, h2 = t2.place; o2 < i2; o2++, h2++) + n2 <<= 8, n2 |= e2[h2], n2 >>>= 0; + return n2 <= 127 ? false : (t2.place = h2, n2); + } + function Of(e2) { + for (var t2 = 0, r2 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r2; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); + } + Hr.prototype._importDER = function(t2, r2) { + t2 = Jt$1.toArray(t2, r2); + var i2 = new Ka(); + if (t2[i2.place++] !== 48) + return false; + var n2 = Ui(t2, i2); + if (n2 === false || n2 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui(t2, i2); + if (o2 === false) + return false; + var h2 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b2 = t2.slice(i2.place, p2 + i2.place); + if (h2[0] === 0) + if (h2[1] & 128) + h2 = h2.slice(1); + else + return false; + if (b2[0] === 0) + if (b2[1] & 128) + b2 = b2.slice(1); + else + return false; + return this.r = new K$1(h2), this.s = new K$1(b2), this.recoveryParam = null, true; + }; + function ki(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r2 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r2 | 128); --r2; ) + e2.push(t2 >>> (r2 << 3) & 255); + e2.push(t2); + } + Hr.prototype.toDER = function(t2) { + var r2 = this.r.toArray(), i2 = this.s.toArray(); + for (r2[0] & 128 && (r2 = [0].concat(r2)), i2[0] & 128 && (i2 = [0].concat(i2)), r2 = Of(r2), i2 = Of(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n2 = [2]; + ki(n2, r2.length), n2 = n2.concat(r2), n2.push(2), ki(n2, i2.length); + var o2 = n2.concat(i2), h2 = [48]; + return ki(h2, o2.length), h2 = h2.concat(o2), Jt$1.encode(h2, t2); + }; + var Ha = function() { + throw new Error("unsupported"); + }, Pf = Jt$1.assert; + function $t$1(e2) { + if (!(this instanceof $t$1)) + return new $t$1(e2); + typeof e2 == "string" && (Pf(Object.prototype.hasOwnProperty.call(Kr, e2), "Unknown curve " + e2), e2 = Kr[e2]), e2 instanceof Kr.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; + } + var za = $t$1; + $t$1.prototype.keyPair = function(t2) { + return new Ti(this, t2); + }, $t$1.prototype.keyFromPrivate = function(t2, r2) { + return Ti.fromPrivate(this, t2, r2); + }, $t$1.prototype.keyFromPublic = function(t2, r2) { + return Ti.fromPublic(this, t2, r2); + }, $t$1.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r2 = new Rf({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n2 = this.n.sub(new K$1(2)); ; ) { + var o2 = new K$1(r2.generate(i2)); + if (!(o2.cmp(n2) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } + }, $t$1.prototype._truncateToN = function(t2, r2) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r2 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; + }, $t$1.prototype.sign = function(t2, r2, i2, n2) { + typeof i2 == "object" && (n2 = i2, i2 = null), n2 || (n2 = {}), r2 = this.keyFromPrivate(r2, i2), t2 = this._truncateToN(new K$1(t2, 16)); + for (var o2 = this.n.byteLength(), h2 = r2.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b2 = new Rf({ hash: this.hash, entropy: h2, nonce: p2, pers: n2.pers, persEnc: n2.persEnc || "utf8" }), m2 = this.n.sub(new K$1(1)), w2 = 0; ; w2++) { + var y2 = n2.k ? n2.k(w2) : new K$1(b2.generate(this.n.byteLength())); + if (y2 = this._truncateToN(y2, true), !(y2.cmpn(1) <= 0 || y2.cmp(m2) >= 0)) { + var S2 = this.g.mul(y2); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y2.invm(this.n).mul(N2.mul(r2.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n2.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr({ r: N2, s: C2, recoveryParam: F2 }); + } } - return acc; - }; - if (ctx.common.async === false) { - const inner = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inner.status === "aborted") - return INVALID; - if (inner.status === "dirty") - status.dirty(); - executeRefinement(inner.value); - return { status: status.value, value: inner.value }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { - if (inner.status === "aborted") - return INVALID; - if (inner.status === "dirty") - status.dirty(); - return executeRefinement(inner.value).then(() => { - return { status: status.value, value: inner.value }; - }); - }); } } - if (effect.type === "transform") { - if (ctx.common.async === false) { - const base3 = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (!isValid(base3)) - return base3; - const result = effect.transform(base3.value, checkCtx); - if (result instanceof Promise) { - throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); - } - return { status: status.value, value: result }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { - if (!isValid(base3)) - return base3; - return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); - }); - } + } + }, $t$1.prototype.verify = function(t2, r2, i2, n2) { + t2 = this._truncateToN(new K$1(t2, 16)), i2 = this.keyFromPublic(i2, n2), r2 = new zr(r2, "hex"); + var o2 = r2.r, h2 = r2.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h2.cmpn(1) < 0 || h2.cmp(this.n) >= 0) + return false; + var p2 = h2.invm(this.n), b2 = p2.mul(t2).umod(this.n), m2 = p2.mul(o2).umod(this.n), w2; + return this.curve._maxwellTrick ? (w2 = this.g.jmulAdd(b2, i2.getPublic(), m2), w2.isInfinity() ? false : w2.eqXToP(o2)) : (w2 = this.g.mulAdd(b2, i2.getPublic(), m2), w2.isInfinity() ? false : w2.getX().umod(this.n).cmp(o2) === 0); + }, $t$1.prototype.recoverPubKey = function(e2, t2, r2, i2) { + Pf((3 & r2) === r2, "The recovery param is more than two bits"), t2 = new zr(t2, i2); + var n2 = this.n, o2 = new K$1(e2), h2 = t2.r, p2 = t2.s, b2 = r2 & 1, m2 = r2 >> 1; + if (h2.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m2) + throw new Error("Unable to find sencond key candinate"); + m2 ? h2 = this.curve.pointFromX(h2.add(this.curve.n), b2) : h2 = this.curve.pointFromX(h2, b2); + var w2 = t2.r.invm(n2), y2 = n2.sub(o2).mul(w2).umod(n2), S2 = p2.mul(w2).umod(n2); + return this.g.mulAdd(y2, h2, S2); + }, $t$1.prototype.getKeyRecoveryParam = function(e2, t2, r2, i2) { + if (t2 = new zr(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n2 = 0; n2 < 4; n2++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n2); + } catch { + continue; } - util.assertNever(effect); + if (o2.eq(r2)) + return n2; } - } - ZodEffects.create = (schema, effect, params) => { - return new ZodEffects({ - schema, - typeName: ZodFirstPartyTypeKind.ZodEffects, - effect, - ...processCreateParams(params) - }); + throw new Error("Unable to find valid recovery factor"); }; - ZodEffects.createWithPreprocess = (preprocess, schema, params) => { - return new ZodEffects({ - schema, - effect: { type: "preprocess", transform: preprocess }, - typeName: ZodFirstPartyTypeKind.ZodEffects, - ...processCreateParams(params) + var La = cr$1(function(e2, t2) { + var r2 = t2; + r2.version = "6.5.4", r2.utils = Jt$1, r2.rand = function() { + throw new Error("unsupported"); + }, r2.curve = qr, r2.curves = Kr, r2.ec = za, r2.eddsa = null; + }); + La.ec; + var Ff; + (function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; + })(Ff || (Ff = {})); + const go$1 = { 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 } }; + function tr(e2, t2) { + const { message: r2, code: i2 } = go$1[e2]; + return { message: t2 ? `${r2} ${t2}` : r2, code: i2 }; + } + const emitter = new EventEmitter$1(); + exports2.connection = void 0; + async function configureConnection(options) { + let disconnectSessions = false; + const thisVersion = pkg.version; + const prevVersion = localStorage.getItem("puzzle_sdk_version"); + if (thisVersion !== prevVersion) { + console.log( + `${pkg.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" + ); + localStorage.setItem("puzzle_sdk_version", thisVersion); + disconnectSessions = true; + } + exports2.connection = new G$1({ + projectId: options.projectId ?? projectId, + metadata: { + name: options.dAppName, + description: options.dAppDescription, + url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", + icons: [options.dAppIconURL] + }, + modalOptions: { ...web3modal_puzzle_props } }); - }; - class ZodOptional extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType.undefined) { - return OK(void 0); + if (disconnectSessions) { + localStorage.removeItem("puzzle-hasInjectedConnection"); + try { + disconnectOnVersionChange(exports2.connection, options.onDisconnect); + } catch (e2) { + console.error(e2); } - return this._def.innerType._parse(input); } - unwrap() { - return this._def.innerType; + exports2.connection.onSessionDelete(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + exports2.connection.onSessionExpire(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + if (typeof window !== "undefined") { + window.puzzleSdkConnection = exports2.connection; } + return exports2.connection; } - ZodOptional.create = (type2, params) => { - return new ZodOptional({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodOptional, - ...processCreateParams(params) + async function disconnectOnVersionChange(connection2, onDisconnect) { + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (session) { + console.log("Disconnecting session", session); + onDisconnect && onDisconnect(); + connection2.disconnect({ + topic: session.topic, + reason: tr("USER_DISCONNECTED") + }); + } + } + async function getWalletConnectModalSignClient() { + return new Promise((resolve) => { + if (exports2.connection) { + resolve(exports2.connection); + } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { + resolve(window.puzzleSdkConnection); + } else { + const interval = setInterval(() => { + if (exports2.connection) { + clearInterval(interval); + resolve(exports2.connection); + } + }, 200); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } }); - }; - class ZodNullable extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType.null) { - return OK(null); + } + const checkForDesktopConnection = async (sessionTopic) => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + try { + const res = await window.aleo.puzzleWalletClient.isConnected.query( + { sessionTopic } + ); + if (res) { + localStorage.setItem("puzzle-hasInjectedConnection", "true"); + return true; + } else { + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; } - return this._def.innerType._parse(input); + } catch (e2) { + console.warn(e2); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; } - unwrap() { - return this._def.innerType; + }; + const hasInjectedConnection = () => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + return false; } - } - ZodNullable.create = (type2, params) => { - return new ZodNullable({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodNullable, - ...processCreateParams(params) - }); + const puzzleHasDesktopConnection = localStorage.getItem( + "puzzle-hasInjectedConnection" + ); + return puzzleHasDesktopConnection === "true"; }; - class ZodDefault extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - let data2 = ctx.data; - if (ctx.parsedType === ZodParsedType.undefined) { - data2 = this._def.defaultValue(); + const getAccount = async (network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await connection.getSession(); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getSelectedAccount" + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getSelectedAccount.query(query); + return response; + } catch (e2) { + console.error("getAccount error", e2); + return { error: e2.message }; } - return this._def.innerType._parse({ - data: data2, - path: ctx.path, - parent: ctx - }); } - removeDefault() { - return this._def.innerType; + try { + const response = await connection.request(query); + return response; + } catch (e2) { + console.error("getAccount error", e2); + const error = e2.message; + return { error }; } - } - ZodDefault.create = (type2, params) => { - return new ZodDefault({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodDefault, - defaultValue: typeof params.default === "function" ? params.default : () => params.default, - ...processCreateParams(params) - }); }; - class ZodCatch extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - const newCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - } - }; - const result = this._def.innerType._parse({ - data: newCtx.data, - path: newCtx.path, - parent: { - ...newCtx + const getBalance = async ({ + address, + network + }) => { + const connection = await getWalletConnectModalSignClient(); + const session = await connection.getSession(); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getBalance", + params: { + address } - }); - if (isAsync(result)) { - return result.then((result2) => { - return { - status: "valid", - value: result2.status === "valid" ? result2.value : this._def.catchValue({ - get error() { - return new ZodError(newCtx.common.issues); - } - }) - }; - }); - } else { - return { - status: "valid", - value: result.status === "valid" ? result.value : this._def.catchValue({ - get error() { - return new ZodError(newCtx.common.issues); - } - }) - }; + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getBalance.query(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); + return { error }; } } - removeCatch() { - return this._def.innerType; + try { + const response = await connection.request(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); + return { error }; } - } - ZodCatch.create = (type2, params) => { - return new ZodCatch({ - innerType: type2, - typeName: ZodFirstPartyTypeKind.ZodCatch, - catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, - ...processCreateParams(params) - }); }; - class ZodNaN extends ZodType { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType.nan) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext(ctx, { - code: ZodIssueCode.invalid_type, - expected: ZodParsedType.nan, - received: ctx.parsedType - }); - return INVALID; + const connect = async (showModal = true) => { + const connection = await getWalletConnectModalSignClient(); + if (!connection) { + throw new Error("call configureConnection() first!"); + } + const existingSession = await connection.getSession(); + if (existingSession) { + console.log("Already connected!", existingSession); + return existingSession; + } + try { + const newSession = await connection.connect({ + requiredNamespaces: { + aleo: { + methods: wc_aleo_methods, + chains: wc_required_aleo_chains, + events: wc_events + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains, + methods: wc_aleo_methods, + events: wc_events + } + } + }, showModal); + emitter.emit("session_change"); + if (newSession) { + await checkForDesktopConnection(newSession.topic); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); } - return { status: "valid", value: input.data }; + return newSession; + } catch (e2) { + console.error("connect error", e2); } - } - ZodNaN.create = (params) => { - return new ZodNaN({ - typeName: ZodFirstPartyTypeKind.ZodNaN, - ...processCreateParams(params) - }); }; - const BRAND = Symbol("zod_brand"); - class ZodBranded extends ZodType { - _parse(input) { - const { ctx } = this._processInputParams(input); - const data2 = ctx.data; - return this._def.type._parse({ - data: data2, - path: ctx.path, - parent: ctx - }); + const requestCreateEvent = async (requestData, network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; } - unwrap() { - return this._def.type; + const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { + if (typeof input === "string") { + return input; + } + return input.plaintext; + }); + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; } - } - class ZodPipeline extends ZodType { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.common.async) { - const handleAsync = async () => { - const inResult = await this._def.in._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID; - if (inResult.status === "dirty") { - status.dirty(); - return DIRTY(inResult.value); - } else { - return this._def.out._parseAsync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); + try { + const response = await connection.request({ + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "requestCreateEvent", + params: { + ...requestData, + inputs } - }; - return handleAsync(); - } else { - const inResult = this._def.in._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID; - if (inResult.status === "dirty") { - status.dirty(); - return { - status: "dirty", - value: inResult.value - }; - } else { - return this._def.out._parseSync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); } - } - } - static create(a2, b2) { - return new ZodPipeline({ - in: a2, - out: b2, - typeName: ZodFirstPartyTypeKind.ZodPipeline }); + return response; + } catch (e2) { + console.error("createEvent error", e2); + const error = e2.message; + return { error }; } - } - const custom = (check, params = {}, fatal) => { - if (check) - return ZodAny.create().superRefine((data2, ctx) => { - var _a, _b; - if (!check(data2)) { - const p2 = typeof params === "function" ? params(data2) : params; - const _fatal = (_b = (_a = p2.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p2 === "string" ? { message: p2 } : p2; - ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); - } - }); - return ZodAny.create(); }; - const late = { - object: ZodObject.lazycreate + const createSharedState = async (network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "createSharedState", + params: {} + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.createSharedState.mutate(query); + return response; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; + return { error }; + } + } + try { + const response = await connection.request(query); + return response; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; + return { error }; + } }; - var ZodFirstPartyTypeKind; - (function(ZodFirstPartyTypeKind2) { - ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; - ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; - ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; - ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; - ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; - ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; - ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; - ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; - ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; - ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; - ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; - ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; - ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; - ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; - ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; - ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; - ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; - ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; - ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; - ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; - ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; - ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; - ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; - ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; - ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; - ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; - ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; - ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; - ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; - ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; - ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; - ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; - ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; - ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; - ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; - })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); - const instanceOfType = (cls, params = { - message: `Input not instance of ${cls.name}` - }) => custom((data2) => data2 instanceof cls, params); - const stringType = ZodString.create; - const numberType = ZodNumber.create; - const nanType = ZodNaN.create; - const bigIntType = ZodBigInt.create; - const booleanType = ZodBoolean.create; - const dateType = ZodDate.create; - const symbolType = ZodSymbol.create; - const undefinedType = ZodUndefined.create; - const nullType = ZodNull.create; - const anyType = ZodAny.create; - const unknownType = ZodUnknown.create; - const neverType = ZodNever.create; - const voidType = ZodVoid.create; - const arrayType = ZodArray.create; - const objectType = ZodObject.create; - const strictObjectType = ZodObject.strictCreate; - const unionType = ZodUnion.create; - const discriminatedUnionType = ZodDiscriminatedUnion.create; - const intersectionType = ZodIntersection.create; - const tupleType = ZodTuple.create; - const recordType = ZodRecord.create; - const mapType = ZodMap.create; - const setType = ZodSet.create; - const functionType = ZodFunction.create; - const lazyType = ZodLazy.create; - const literalType = ZodLiteral.create; - const enumType = ZodEnum.create; - const nativeEnumType = ZodNativeEnum.create; - const promiseType = ZodPromise.create; - const effectsType = ZodEffects.create; - const optionalType = ZodOptional.create; - const nullableType = ZodNullable.create; - const preprocessType = ZodEffects.createWithPreprocess; - const pipelineType = ZodPipeline.create; - const ostring = () => stringType().optional(); - const onumber = () => numberType().optional(); - const oboolean = () => booleanType().optional(); - const coerce = { - string: (arg) => ZodString.create({ ...arg, coerce: true }), - number: (arg) => ZodNumber.create({ ...arg, coerce: true }), - boolean: (arg) => ZodBoolean.create({ - ...arg, - coerce: true - }), - bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }), - date: (arg) => ZodDate.create({ ...arg, coerce: true }) + const decrypt = async (ciphertexts, network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "decrypt", + params: { + ciphertexts + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.decrypt.query(query); + return response; + } catch (e2) { + const error = e2.message; + console.error("decrypt error", e2); + return { error }; + } + } + try { + const response = await connection.request(query); + return response; + } catch (e2) { + console.error("decrypt error", e2); + return { error: e2.message }; + } + }; + const disconnect = async () => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + try { + try { + await connection.disconnect({ + reason: tr("USER_DISCONNECTED"), + topic: session.topic + }); + localStorage.removeItem("puzzle-hasInjectedConnection"); + emitter.emit("session_change"); + } catch (e2) { + console.warn(e2); + } + return {}; + } catch (e2) { + console.error("error disconnecting", e2); + const error = e2.message; + return { error }; + } + }; + const getEvent = async ({ + id, + address, + network + }) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { event: void 0, error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getEvent", + params: { + id, + address + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getEvent.query(query); + return response; + } catch (e2) { + console.error("getEvent error", e2); + const error = e2.message; + return { error }; + } + } + const fetchEvent = async () => { + const response = await connection.request(query); + return response; + }; + try { + const response = await fetchEvent(); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } + }; + const getEvents = async (filter, network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { events: void 0, error: "no session or connection" }; + } + if ((filter == null ? void 0 : filter.programId) === "") { + filter.programId = void 0; + } + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getEvents", + params: { + filter, + page: 0 + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getEvents.query(query); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } + } + const fetchPage = async (page = 0) => { + const response = await connection.request(query); + return response; + }; + try { + const response = await fetchPage(); + return response; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; + return { error }; + } + }; + const importSharedState = async (seed, network) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "importSharedState", + params: { + seed + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.importSharedState.mutate(query); + return response; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; + return { error }; + } + } + try { + const response = await connection.request(query); + return response; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; + return { error }; + } + }; + const getRecords = async ({ + address, + filter, + page = 0, + network + }) => { + const connection = await getWalletConnectModalSignClient(); + const session = await (connection == null ? void 0 : connection.getSession()); + if (!session || !connection) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } + const query = { + topic: session.topic, + chainId: network ?? "aleo:1", + request: { + jsonrpc: "2.0", + method: "getRecords", + params: { + address, + filter, + page + } + } + }; + if (hasInjectedConnection()) { + try { + const response = await window.aleo.puzzleWalletClient.getRecords.query(query); + return response; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; + return { error }; + } + } + const fetchPage = async (page2 = 0) => { + const response = await connection.request(query); + return response; + }; + try { + const response = await fetchPage(); + return response; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; + return { error }; + } }; - const NEVER = INVALID; - var z$1 = /* @__PURE__ */ Object.freeze({ - __proto__: null, - defaultErrorMap: errorMap, - setErrorMap, - getErrorMap, - makeIssue, - EMPTY_PATH, - addIssueToContext, - ParseStatus, - INVALID, - DIRTY, - OK, - isAborted, - isDirty, - isValid, - isAsync, - get util() { - return util; - }, - get objectUtil() { - return objectUtil; - }, - ZodParsedType, - getParsedType, - ZodType, - ZodString, - ZodNumber, - ZodBigInt, - ZodBoolean, - ZodDate, - ZodSymbol, - ZodUndefined, - ZodNull, - ZodAny, - ZodUnknown, - ZodNever, - ZodVoid, - ZodArray, - ZodObject, - ZodUnion, - ZodDiscriminatedUnion, - ZodIntersection, - ZodTuple, - ZodRecord, - ZodMap, - ZodSet, - ZodFunction, - ZodLazy, - ZodLiteral, - ZodEnum, - ZodNativeEnum, - ZodPromise, - ZodEffects, - ZodTransformer: ZodEffects, - ZodOptional, - ZodNullable, - ZodDefault, - ZodCatch, - ZodNaN, - BRAND, - ZodBranded, - ZodPipeline, - custom, - Schema: ZodType, - ZodSchema: ZodType, - late, - get ZodFirstPartyTypeKind() { - return ZodFirstPartyTypeKind; - }, - coerce, - any: anyType, - array: arrayType, - bigint: bigIntType, - boolean: booleanType, - date: dateType, - discriminatedUnion: discriminatedUnionType, - effect: effectsType, - "enum": enumType, - "function": functionType, - "instanceof": instanceOfType, - intersection: intersectionType, - lazy: lazyType, - literal: literalType, - map: mapType, - nan: nanType, - nativeEnum: nativeEnumType, - never: neverType, - "null": nullType, - nullable: nullableType, - number: numberType, - object: objectType, - oboolean, - onumber, - optional: optionalType, - ostring, - pipeline: pipelineType, - preprocess: preprocessType, - promise: promiseType, - record: recordType, - set: setType, - strictObject: strictObjectType, - string: stringType, - symbol: symbolType, - transformer: effectsType, - tuple: tupleType, - "undefined": undefinedType, - union: unionType, - unknown: unknownType, - "void": voidType, - NEVER, - ZodIssueCode, - quotelessJson, - ZodError - }); - const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; - const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; - const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; - const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; - const aleoFieldRegex = /^\d+field$/; - const aleoU32 = /^\d+u32$/; - const aleoU64 = /^\d+u64$/; - const zodAddress = z$1.string().regex(aleoAddressRegex); - const zodViewKey = z$1.string().regex(aleoViewKeyRegex); - const zodPrivateKey = z$1.string().regex(aleoPrivateKeyRegex); - const zodTransactionId = z$1.string().regex(aleoTransactionIdRegex); - const zodField = z$1.string().regex(aleoFieldRegex); - const zodU32 = z$1.string().regex(aleoU32); - const zodU64 = z$1.string().regex(aleoU64); - var InputOutputType; - (function(InputOutputType2) { - InputOutputType2["Record"] = "record"; - InputOutputType2["OutputRecord"] = "outputRecord"; - InputOutputType2["Public"] = "public"; - InputOutputType2["Private"] = "private"; - InputOutputType2["Constant"] = "constant"; - InputOutputType2["Future"] = "future"; - InputOutputType2["ExternalRecord"] = "external_record"; - })(InputOutputType || (InputOutputType = {})); - exports2.EventType = void 0; - (function(EventType) { - EventType["Deploy"] = "Deploy"; - EventType["Execute"] = "Execute"; - EventType["Send"] = "Send"; - EventType["Receive"] = "Receive"; - EventType["Join"] = "Join"; - EventType["Split"] = "Split"; - EventType["Shield"] = "Shield"; - EventType["Unshield"] = "Unshield"; - })(exports2.EventType || (exports2.EventType = {})); - exports2.EventStatus = void 0; - (function(EventStatus) { - EventStatus["Creating"] = "Creating"; - EventStatus["Pending"] = "Pending"; - EventStatus["Settled"] = "Settled"; - EventStatus["Failed"] = "Failed"; - })(exports2.EventStatus || (exports2.EventStatus = {})); - exports2.Visibility = void 0; - (function(Visibility) { - Visibility["Private"] = "Private"; - Visibility["Public"] = "Public"; - })(exports2.Visibility || (exports2.Visibility = {})); - exports2.Network = void 0; - (function(Network) { - Network["AleoTestnet"] = "AleoTestnet"; - Network["AleoMainnet"] = "AleoMainnet"; - })(exports2.Network || (exports2.Network = {})); - exports2.AssetType = void 0; - (function(AssetType) { - AssetType[AssetType["ALEO"] = 0] = "ALEO"; - })(exports2.AssetType || (exports2.AssetType = {})); - const zodEventType = z$1.nativeEnum(exports2.EventType); - const zodEventStatus = z$1.nativeEnum(exports2.EventStatus); - const zodNetwork = z$1.nativeEnum(exports2.Network); - const zodVisibility = z$1.nativeEnum(exports2.Visibility); const requestSignature = async ({ message, - address + address, + network, + method }) => { const connection = await getWalletConnectModalSignClient(); const session = await (connection == null ? void 0 : connection.getSession()); if (!session || !connection) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } try { const response = await connection.request({ topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "requestSignature", params: { message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method } } }); @@ -17175,12 +24347,12 @@ args.unshift("%O"); } let index2 = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => { if (match === "%%") { return "%"; } index2++; - const formatter = createDebug.formatters[format]; + const formatter = createDebug.formatters[format2]; if (typeof formatter === "function") { const val = args[index2]; match = formatter.call(self2, val); @@ -17461,10 +24633,10 @@ * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ - const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$3 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); + const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$4 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); let o$4 = class o { constructor(t2, e2, n2) { - if (this._$cssResult$ = true, n2 !== s$3) + if (this._$cssResult$ = true, n2 !== s$4) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t2, this.t = e2; } @@ -17481,7 +24653,7 @@ return this.cssText; } }; - const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), i$3 = (t2, ...e2) => { + const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$4), i$3 = (t2, ...e2) => { const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s2, n3) => e3 + ((t3) => { if (true === t3._$cssResult$) return t3.cssText; @@ -17489,13 +24661,13 @@ return t3; throw Error("Value passed to 'css' function must be a 'css' function result: " + t3 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); })(s2) + t2[n3 + 1], t2[0]); - return new o$4(n2, t2, s$3); + return new o$4(n2, t2, s$4); }, S$2 = (s2, n2) => { e$5 ? s2.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { const n3 = document.createElement("style"), o2 = t$3.litNonce; void 0 !== o2 && n3.setAttribute("nonce", o2), n3.textContent = e2.cssText, s2.appendChild(n3); }); - }, c$2 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { + }, c$1 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { let e2 = ""; for (const s2 of t3.cssRules) e2 += s2.cssText; @@ -17506,7 +24678,7 @@ * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ - var s$2; + var s$3; const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$3 = e$4.reactiveElementPolyfillSupport, n$4 = { toAttribute(t2, i2) { switch (i2) { case Boolean: @@ -17586,9 +24758,9 @@ if (Array.isArray(i2)) { const e2 = new Set(i2.flat(1 / 0).reverse()); for (const i3 of e2) - s2.unshift(c$2(i3)); + s2.unshift(c$1(i3)); } else - void 0 !== i2 && s2.push(c$2(i2)); + void 0 !== i2 && s2.push(c$1(i2)); return s2; } static _$Ep(t2, i2) { @@ -17715,16 +24887,16 @@ firstUpdated(t2) { } }; - u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$2 = e$4.reactiveElementVersions) && void 0 !== s$2 ? s$2 : e$4.reactiveElementVersions = []).push("1.6.3"); + u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$3 = e$4.reactiveElementVersions) && void 0 !== s$3 ? s$3 : e$4.reactiveElementVersions = []).push("1.6.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var t$2; - const i$2 = window, s$1 = i$2.trustedTypes, e$3 = s$1 ? s$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c$1 = Array.isArray, v$1 = (t2) => c$1(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), b = w(2), T$1 = Symbol.for("lit-noChange"), A$1 = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); - function P(t2, i2) { + const i$2 = window, s$2 = i$2.trustedTypes, e$3 = s$2 ? s$2.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), b$1 = w(2), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); + function P$1(t2, i2) { if (!Array.isArray(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array"); return void 0 !== e$3 ? e$3.createHTML(i2) : i2; @@ -17740,15 +24912,15 @@ const w2 = u2 === p && t2[i3 + 1].startsWith("/>") ? " " : ""; r2 += u2 === f ? s3 + h$1 : v2 >= 0 ? (e2.push(d2), s3.slice(0, v2) + o$2 + s3.slice(v2) + n$3 + w2) : s3 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); } - return [P(t2, r2 + (t2[s2] || "") + (2 === i2 ? "" : "")), e2]; + return [P$1(t2, r2 + (t2[s2] || "") + (2 === i2 ? "" : "")), e2]; }; - class N { + let N$1 = class N2 { constructor({ strings: t2, _$litType$: i2 }, e2) { let h2; this.parts = []; let r2 = 0, d2 = 0; const c2 = t2.length - 1, v2 = this.parts, [a2, f2] = V(t2, i2); - if (this.el = N.createElement(a2, e2), C.currentNode = this.el.content, 2 === i2) { + if (this.el = N2.createElement(a2, e2), C.currentNode = this.el.content, 2 === i2) { const t3 = this.el.content, i3 = t3.firstChild; i3.remove(), t3.append(...i3.childNodes); } @@ -17761,7 +24933,7 @@ const s2 = f2[d2++]; if (t3.push(i3), void 0 !== s2) { const t4 = h2.getAttribute(s2.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s2); - v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); + v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H$1 : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); } else v2.push({ type: 6, index: r2 }); } @@ -17771,7 +24943,7 @@ if (y.test(h2.tagName)) { const t3 = h2.textContent.split(n$3), i3 = t3.length - 1; if (i3 > 0) { - h2.textContent = s$1 ? s$1.emptyScript : ""; + h2.textContent = s$2 ? s$2.emptyScript : ""; for (let s2 = 0; s2 < i3; s2++) h2.append(t3[s2], u()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); h2.append(t3[i3], u()); @@ -17792,10 +24964,10 @@ const s2 = r.createElement("template"); return s2.innerHTML = t2, s2; } - } + }; function S$1(t2, i2, s2 = t2, e2) { var o2, n2, l2, h2; - if (i2 === T$1) + if (i2 === T) return i2; let r2 = void 0 !== e2 ? null === (o2 = s2._$Co) || void 0 === o2 ? void 0 : o2[e2] : s2._$Cl; const u2 = d(i2) ? void 0 : i2._$litDirective$; @@ -17834,7 +25006,7 @@ class R { constructor(t2, i2, s2, e2) { var o2; - this.type = 2, this._$AH = A$1, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o2 = null == e2 ? void 0 : e2.isConnected) || void 0 === o2 || o2; + this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o2 = null == e2 ? void 0 : e2.isConnected) || void 0 === o2 || o2; } get _$AU() { var t2, i2; @@ -17852,7 +25024,7 @@ return this._$AB; } _$AI(t2, i2 = this) { - t2 = S$1(this, t2, i2), d(t2) ? t2 === A$1 || null == t2 || "" === t2 ? (this._$AH !== A$1 && this._$AR(), this._$AH = A$1) : t2 !== this._$AH && t2 !== T$1 && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v$1(t2) ? this.T(t2) : this._(t2); + t2 = S$1(this, t2, i2), d(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v(t2) ? this.T(t2) : this._(t2); } k(t2) { return this._$AA.parentNode.insertBefore(t2, this._$AB); @@ -17861,11 +25033,11 @@ this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2)); } _(t2) { - this._$AH !== A$1 && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; + this._$AH !== A && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; } g(t2) { var i2; - const { values: s2, _$litType$: e2 } = t2, o2 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N.createElement(P(e2.h, e2.h[0]), this.options)), e2); + const { values: s2, _$litType$: e2 } = t2, o2 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N$1.createElement(P$1(e2.h, e2.h[0]), this.options)), e2); if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o2) this._$AH.v(s2); else { @@ -17875,10 +25047,10 @@ } _$AC(t2) { let i2 = E.get(t2.strings); - return void 0 === i2 && E.set(t2.strings, i2 = new N(t2)), i2; + return void 0 === i2 && E.set(t2.strings, i2 = new N$1(t2)), i2; } T(t2) { - c$1(this._$AH) || (this._$AH = [], this._$AR()); + c(this._$AH) || (this._$AH = [], this._$AR()); const i2 = this._$AH; let s2, e2 = 0; for (const o2 of t2) @@ -17899,7 +25071,7 @@ } class k { constructor(t2, i2, s2, e2, o2) { - this.type = 1, this._$AH = A$1, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o2, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = A$1; + this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o2, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = A; } get tagName() { return this.element.tagName; @@ -17911,34 +25083,34 @@ const o2 = this.strings; let n2 = false; if (void 0 === o2) - t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T$1, n2 && (this._$AH = t2); + t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T, n2 && (this._$AH = t2); else { const e3 = t2; let l2, h2; for (t2 = o2[0], l2 = 0; l2 < o2.length - 1; l2++) - h2 = S$1(this, e3[s2 + l2], i2, l2), h2 === T$1 && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A$1 ? t2 = A$1 : t2 !== A$1 && (t2 += (null != h2 ? h2 : "") + o2[l2 + 1]), this._$AH[l2] = h2; + h2 = S$1(this, e3[s2 + l2], i2, l2), h2 === T && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A ? t2 = A : t2 !== A && (t2 += (null != h2 ? h2 : "") + o2[l2 + 1]), this._$AH[l2] = h2; } n2 && !e2 && this.j(t2); } j(t2) { - t2 === A$1 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); + t2 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); } } - class H extends k { + let H$1 = class H extends k { constructor() { super(...arguments), this.type = 3; } j(t2) { - this.element[this.name] = t2 === A$1 ? void 0 : t2; + this.element[this.name] = t2 === A ? void 0 : t2; } - } - const I = s$1 ? s$1.emptyScript : ""; + }; + const I = s$2 ? s$2.emptyScript : ""; let L$1 = class L extends k { constructor() { super(...arguments), this.type = 4; } j(t2) { - t2 && t2 !== A$1 ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); + t2 && t2 !== A ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); } }; class z extends k { @@ -17947,9 +25119,9 @@ } _$AI(t2, i2 = this) { var s2; - if ((t2 = null !== (s2 = S$1(this, t2, i2, 0)) && void 0 !== s2 ? s2 : A$1) === T$1) + if ((t2 = null !== (s2 = S$1(this, t2, i2, 0)) && void 0 !== s2 ? s2 : A) === T) return; - const e2 = this._$AH, o2 = t2 === A$1 && e2 !== A$1 || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A$1 && (e2 === A$1 || o2); + const e2 = this._$AH, o2 = t2 === A && e2 !== A || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A && (e2 === A || o2); o2 && this.element.removeEventListener(this.name, this, e2), n2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2; } handleEvent(t2) { @@ -17969,7 +25141,7 @@ } }; const B$1 = i$2.litHtmlPolyfillSupport; - null == B$1 || B$1(N, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); + null == B$1 || B$1(N$1, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); const D$1 = (t2, i2, s2) => { var e2, o2; const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2; @@ -17986,7 +25158,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ var l$1, o$1; - class s extends u$1 { + let s$1 = class s extends u$1 { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } @@ -18008,12 +25180,12 @@ super.disconnectedCallback(), null === (t2 = this._$Do) || void 0 === t2 || t2.setConnected(false); } render() { - return T$1; + return T; } - } - s.finalized = true, s._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s }); + }; + s$1.finalized = true, s$1._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s$1 }); const n$2 = globalThis.litElementPolyfillSupport; - null == n$2 || n$2({ LitElement: s }); + null == n$2 || n$2({ LitElement: s$1 }); (null !== (o$1 = globalThis.litElementVersions) && void 0 !== o$1 ? o$1 : globalThis.litElementVersions = []).push("3.3.3"); /** * @license @@ -18110,7 +25282,7 @@ const i3 = !!s2[t2]; i3 === this.it.has(t2) || (null === (o2 = this.nt) || void 0 === o2 ? void 0 : o2.has(t2)) || (i3 ? (e2.add(t2), this.it.add(t2)) : (e2.remove(t2), this.it.delete(t2))); } - return T$1; + return T; } }); function addUniqueItem(array, item) { @@ -18254,7 +25426,7 @@ this.updateDuration(initialDuration); const interpolate$1 = interpolate(keyframes, offset, isEasingList(easing) ? easing.map(getEasingFunction) : noopReturn); this.tick = (timestamp) => { - var _a; + var _a2; delay2 = delay2; let t2 = 0; if (this.pauseTime !== void 0) { @@ -18285,7 +25457,7 @@ const isAnimationFinished = this.pauseTime === void 0 && (this.playState === "finished" || t2 >= this.totalDuration + endDelay); if (isAnimationFinished) { this.playState = "finished"; - (_a = this.resolve) === null || _a === void 0 ? void 0 : _a.call(this, latest); + (_a2 = this.resolve) === null || _a2 === void 0 ? void 0 : _a2.call(this, latest); } else if (this.playState !== "idle") { this.frameRequestId = requestAnimationFrame(this.tick); } @@ -18314,12 +25486,12 @@ this.tick(0); } stop() { - var _a; + var _a2; this.playState = "idle"; if (this.frameRequestId !== void 0) { cancelAnimationFrame(this.frameRequestId); } - (_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, false); + (_a2 = this.reject) === null || _a2 === void 0 ? void 0 : _a2.call(this, false); } cancel() { this.stop(); @@ -18546,11 +25718,11 @@ } } function getUnitConverter(keyframes, definition) { - var _a; + var _a2; let toUnit = (definition === null || definition === void 0 ? void 0 : definition.toDefaultUnit) || noopReturn; const finalKeyframe = keyframes[keyframes.length - 1]; if (isString(finalKeyframe)) { - const unit = ((_a = finalKeyframe.match(/(-?[\d.]+)([a-z%]*)/)) === null || _a === void 0 ? void 0 : _a[2]) || ""; + const unit = ((_a2 = finalKeyframe.match(/(-?[\d.]+)([a-z%]*)/)) === null || _a2 === void 0 ? void 0 : _a2[2]) || ""; if (unit) toUnit = (value) => value + unit; } @@ -18574,8 +25746,8 @@ stopAnimation(motionValue.animation, !(isEasingGenerator(easing) && motionValue.generator) && options.record !== false); return () => { const readInitialValue = () => { - var _a, _b; - return (_b = (_a = style.get(element, name2)) !== null && _a !== void 0 ? _a : definition === null || definition === void 0 ? void 0 : definition.initialValue) !== null && _b !== void 0 ? _b : 0; + var _a2, _b; + return (_b = (_a2 = style.get(element, name2)) !== null && _a2 !== void 0 ? _a2 : definition === null || definition === void 0 ? void 0 : definition.initialValue) !== null && _b !== void 0 ? _b : 0; }; let keyframes = hydrateKeyframes(keyframesList(keyframesDefinition), readInitialValue); const toUnit = getUnitConverter(keyframes, definition); @@ -18670,12 +25842,8 @@ options[key] ? Object.assign(Object.assign({}, options), options[key]) : Object.assign({}, options) ); function resolveElements(elements, selectorCache) { - var _a; if (typeof elements === "string") { - if (selectorCache) { - (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : selectorCache[elements] = document.querySelectorAll(elements); - elements = selectorCache[elements]; - } else { + { elements = document.querySelectorAll(elements); } } else if (elements instanceof Element) { @@ -18789,7 +25957,7 @@ * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ - const l = (l2) => null != l2 ? l2 : A$1; + const l = (l2) => null != l2 ? l2 : A; var browser = {}; var canPromise$1 = function() { return typeof Promise === "function" && Promise.prototype && Promise.prototype.then; @@ -20621,9 +27789,9 @@ const scale = exports3.getScale(qrSize, opts); return Math.floor((qrSize + opts.margin * 2) * scale); }; - exports3.qrToImageData = function qrToImageData(imgData, qr, opts) { - const size = qr.modules.size; - const data2 = qr.modules.data; + exports3.qrToImageData = function qrToImageData(imgData, qr2, opts) { + const size = qr2.modules.size; + const data2 = qr2.modules.data; const scale = exports3.getScale(size, opts); const symbolSize = Math.floor((size + opts.margin * 2) * scale); const scaledMargin = opts.margin * scale; @@ -20815,150 +27983,54 @@ browser.toString = renderCanvas.bind(null, function(data2, _2, opts) { return SvgRenderer.render(data2, opts); }); - var et = Object.defineProperty, Be = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Ue = (e2, o2, r2) => o2 in e2 ? et(e2, o2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o2] = r2, ve = (e2, o2) => { + var et = Object.defineProperty, Se = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Be = (e2, o2, r2) => o2 in e2 ? et(e2, o2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o2] = r2, fe = (e2, o2) => { for (var r2 in o2 || (o2 = {})) - tt.call(o2, r2) && Ue(e2, r2, o2[r2]); - if (Be) - for (var r2 of Be(o2)) - ot.call(o2, r2) && Ue(e2, r2, o2[r2]); + tt.call(o2, r2) && Be(e2, r2, o2[r2]); + if (Se) + for (var r2 of Se(o2)) + ot.call(o2, r2) && Be(e2, r2, o2[r2]); return e2; }; function rt() { var e2; - const o2 = (e2 = ne$1.state.themeMode) != null ? e2 : "dark", r2 = { - light: { - foreground: { - 1: "rgb(20,20,20)", - 2: "rgb(121,134,134)", - 3: "rgb(158,169,169)" - }, - background: { - 1: "rgb(255,255,255)", - 2: "rgb(241,243,243)", - 3: "rgb(228,231,231)" - }, - overlay: "rgba(0,0,0,0.1)" - }, - dark: { - foreground: { - 1: "rgb(228,231,231)", - 2: "rgb(148,158,158)", - 3: "rgb(110,119,119)" - }, - background: { - 1: "rgb(20,20,20)", - 2: "rgb(39,42,42)", - 3: "rgb(59,64,64)" - }, - overlay: "rgba(255,255,255,0.1)" - } - }[o2]; - return { - "--wcm-color-fg-1": r2.foreground[1], - "--wcm-color-fg-2": r2.foreground[2], - "--wcm-color-fg-3": r2.foreground[3], - "--wcm-color-bg-1": r2.background[1], - "--wcm-color-bg-2": r2.background[2], - "--wcm-color-bg-3": r2.background[3], - "--wcm-color-overlay": r2.overlay - }; - } - function He() { - return { - "--wcm-accent-color": "#3396FF", - "--wcm-accent-fill-color": "#FFFFFF", - "--wcm-z-index": "89", - "--wcm-background-color": "#3396FF", - "--wcm-background-border-radius": "8px", - "--wcm-container-border-radius": "30px", - "--wcm-wallet-icon-border-radius": "15px", - "--wcm-wallet-icon-large-border-radius": "30px", - "--wcm-wallet-icon-small-border-radius": "7px", - "--wcm-input-border-radius": "28px", - "--wcm-button-border-radius": "10px", - "--wcm-notification-border-radius": "36px", - "--wcm-secondary-button-border-radius": "28px", - "--wcm-icon-button-border-radius": "50%", - "--wcm-button-hover-highlight-border-radius": "10px", - "--wcm-text-big-bold-size": "20px", - "--wcm-text-big-bold-weight": "600", - "--wcm-text-big-bold-line-height": "24px", - "--wcm-text-big-bold-letter-spacing": "-0.03em", - "--wcm-text-big-bold-text-transform": "none", - "--wcm-text-xsmall-bold-size": "10px", - "--wcm-text-xsmall-bold-weight": "700", - "--wcm-text-xsmall-bold-line-height": "12px", - "--wcm-text-xsmall-bold-letter-spacing": "0.02em", - "--wcm-text-xsmall-bold-text-transform": "uppercase", - "--wcm-text-xsmall-regular-size": "12px", - "--wcm-text-xsmall-regular-weight": "600", - "--wcm-text-xsmall-regular-line-height": "14px", - "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", - "--wcm-text-xsmall-regular-text-transform": "none", - "--wcm-text-small-thin-size": "14px", - "--wcm-text-small-thin-weight": "500", - "--wcm-text-small-thin-line-height": "16px", - "--wcm-text-small-thin-letter-spacing": "-0.03em", - "--wcm-text-small-thin-text-transform": "none", - "--wcm-text-small-regular-size": "14px", - "--wcm-text-small-regular-weight": "600", - "--wcm-text-small-regular-line-height": "16px", - "--wcm-text-small-regular-letter-spacing": "-0.03em", - "--wcm-text-small-regular-text-transform": "none", - "--wcm-text-medium-regular-size": "16px", - "--wcm-text-medium-regular-weight": "600", - "--wcm-text-medium-regular-line-height": "20px", - "--wcm-text-medium-regular-letter-spacing": "-0.03em", - "--wcm-text-medium-regular-text-transform": "none", - "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", - "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", - "--wcm-success-color": "rgb(38,181,98)", - "--wcm-error-color": "rgb(242, 90, 103)", - "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", - "--wcm-overlay-backdrop-filter": "none" - }; - } - const h = { - getPreset(e2) { - return He()[e2]; - }, - setTheme() { - const e2 = document.querySelector(":root"), { themeVariables: o2 } = ne$1.state; - if (e2) { - const r2 = ve(ve(ve({}, rt()), He()), o2); - Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); - } - }, - globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` - }, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; - var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, F = (e2, o2, r2, a2) => { + const o2 = (e2 = ne$4.state.themeMode) != null ? e2 : "dark", r2 = { light: { foreground: { 1: "rgb(20,20,20)", 2: "rgb(121,134,134)", 3: "rgb(158,169,169)" }, background: { 1: "rgb(255,255,255)", 2: "rgb(241,243,243)", 3: "rgb(228,231,231)" }, overlay: "rgba(0,0,0,0.1)" }, dark: { foreground: { 1: "rgb(228,231,231)", 2: "rgb(148,158,158)", 3: "rgb(110,119,119)" }, background: { 1: "rgb(20,20,20)", 2: "rgb(39,42,42)", 3: "rgb(59,64,64)" }, overlay: "rgba(255,255,255,0.1)" } }[o2]; + return { "--wcm-color-fg-1": r2.foreground[1], "--wcm-color-fg-2": r2.foreground[2], "--wcm-color-fg-3": r2.foreground[3], "--wcm-color-bg-1": r2.background[1], "--wcm-color-bg-2": r2.background[2], "--wcm-color-bg-3": r2.background[3], "--wcm-color-overlay": r2.overlay }; + } + function Ue() { + return { "--wcm-accent-color": "#3396FF", "--wcm-accent-fill-color": "#FFFFFF", "--wcm-z-index": "89", "--wcm-background-color": "#3396FF", "--wcm-background-border-radius": "8px", "--wcm-container-border-radius": "30px", "--wcm-wallet-icon-border-radius": "15px", "--wcm-wallet-icon-large-border-radius": "30px", "--wcm-wallet-icon-small-border-radius": "7px", "--wcm-input-border-radius": "28px", "--wcm-button-border-radius": "10px", "--wcm-notification-border-radius": "36px", "--wcm-secondary-button-border-radius": "28px", "--wcm-icon-button-border-radius": "50%", "--wcm-button-hover-highlight-border-radius": "10px", "--wcm-text-big-bold-size": "20px", "--wcm-text-big-bold-weight": "600", "--wcm-text-big-bold-line-height": "24px", "--wcm-text-big-bold-letter-spacing": "-0.03em", "--wcm-text-big-bold-text-transform": "none", "--wcm-text-xsmall-bold-size": "10px", "--wcm-text-xsmall-bold-weight": "700", "--wcm-text-xsmall-bold-line-height": "12px", "--wcm-text-xsmall-bold-letter-spacing": "0.02em", "--wcm-text-xsmall-bold-text-transform": "uppercase", "--wcm-text-xsmall-regular-size": "12px", "--wcm-text-xsmall-regular-weight": "600", "--wcm-text-xsmall-regular-line-height": "14px", "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", "--wcm-text-xsmall-regular-text-transform": "none", "--wcm-text-small-thin-size": "14px", "--wcm-text-small-thin-weight": "500", "--wcm-text-small-thin-line-height": "16px", "--wcm-text-small-thin-letter-spacing": "-0.03em", "--wcm-text-small-thin-text-transform": "none", "--wcm-text-small-regular-size": "14px", "--wcm-text-small-regular-weight": "600", "--wcm-text-small-regular-line-height": "16px", "--wcm-text-small-regular-letter-spacing": "-0.03em", "--wcm-text-small-regular-text-transform": "none", "--wcm-text-medium-regular-size": "16px", "--wcm-text-medium-regular-weight": "600", "--wcm-text-medium-regular-line-height": "20px", "--wcm-text-medium-regular-letter-spacing": "-0.03em", "--wcm-text-medium-regular-text-transform": "none", "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", "--wcm-success-color": "rgb(38,181,98)", "--wcm-error-color": "rgb(242, 90, 103)", "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", "--wcm-overlay-backdrop-filter": "none" }; + } + const h = { getPreset(e2) { + return Ue()[e2]; + }, setTheme() { + const e2 = document.querySelector(":root"), { themeVariables: o2 } = ne$4.state; + if (e2) { + const r2 = fe(fe(fe({}, rt()), Ue()), o2); + Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); + } + }, globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` }, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; + var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, K = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? it(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && lt(o2, r2, t2), t2; }; - let T = class extends s { + let _ = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.iconLeft = void 0, this.iconRight = void 0, this.onClick = () => null, this.variant = "default"; } render() { - const e2 = { - "wcm-icon-left": this.iconLeft !== void 0, - "wcm-icon-right": this.iconRight !== void 0, - "wcm-ghost": this.variant === "ghost", - "wcm-outline": this.variant === "outline" - }; + const e2 = { "wcm-icon-left": this.iconLeft !== void 0, "wcm-icon-right": this.iconRight !== void 0, "wcm-ghost": this.variant === "ghost", "wcm-outline": this.variant === "outline" }; let o$12 = "inverse"; return this.variant === "ghost" && (o$12 = "secondary"), this.variant === "outline" && (o$12 = "accent"), x``; } }; - T.styles = [h.globalCss, at], F([n$1({ type: Boolean })], T.prototype, "disabled", 2), F([n$1()], T.prototype, "iconLeft", 2), F([n$1()], T.prototype, "iconRight", 2), F([n$1()], T.prototype, "onClick", 2), F([n$1()], T.prototype, "variant", 2), T = F([e$2("wcm-button")], T); + _.styles = [h.globalCss, at], K([n$1({ type: Boolean })], _.prototype, "disabled", 2), K([n$1()], _.prototype, "iconLeft", 2), K([n$1()], _.prototype, "iconRight", 2), K([n$1()], _.prototype, "onClick", 2), K([n$1()], _.prototype, "variant", 2), _ = K([e$2("wcm-button")], _); const nt = i$3`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`; - var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, ue = (e2, o2, r2, a2) => { + var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, xe = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? st(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && ct(o2, r2, t2), t2; }; - let ee = class extends s { + let re = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.variant = "primary"; } @@ -20967,86 +28039,67 @@ return x``; } }; - ee.styles = [h.globalCss, nt], ue([n$1({ type: Boolean })], ee.prototype, "disabled", 2), ue([n$1()], ee.prototype, "variant", 2), ee = ue([e$2("wcm-button-big")], ee); + re.styles = [h.globalCss, nt], xe([n$1({ type: Boolean })], re.prototype, "disabled", 2), xe([n$1()], re.prototype, "variant", 2), re = xe([e$2("wcm-button-big")], re); const dt = i$3`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`; - var mt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, wt = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? ht(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && mt(o2, r2, t2), t2; + var ht = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let be = class extends s { + let ye = class extends s$1 { render() { return x`
`; } }; - be.styles = [h.globalCss, dt], be = wt([e$2("wcm-info-footer")], be); - const v = { - CROSS_ICON: b``, - WALLET_CONNECT_LOGO: b``, - WALLET_CONNECT_ICON: b``, - WALLET_CONNECT_ICON_COLORED: b``, - BACK_ICON: b``, - COPY_ICON: b``, - RETRY_ICON: b``, - DESKTOP_ICON: b``, - MOBILE_ICON: b``, - ARROW_DOWN_ICON: b``, - ARROW_UP_RIGHT_ICON: b``, - ARROW_RIGHT_ICON: b``, - QRCODE_ICON: b``, - SCAN_ICON: b``, - CHECKMARK_ICON: b``, - SEARCH_ICON: b``, - WALLET_PLACEHOLDER: b``, - GLOBE_ICON: b`` - }, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; - var gt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, ut = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? vt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && gt(o2, r2, t2), t2; + ye.styles = [h.globalCss, dt], ye = ht([e$2("wcm-info-footer")], ye); + const b = { CROSS_ICON: b$1``, WALLET_CONNECT_LOGO: b$1``, WALLET_CONNECT_ICON: b$1``, WALLET_CONNECT_ICON_COLORED: b$1``, BACK_ICON: b$1``, COPY_ICON: b$1``, RETRY_ICON: b$1``, DESKTOP_ICON: b$1``, MOBILE_ICON: b$1``, ARROW_DOWN_ICON: b$1``, ARROW_UP_RIGHT_ICON: b$1``, ARROW_RIGHT_ICON: b$1``, QRCODE_ICON: b$1``, SCAN_ICON: b$1``, CHECKMARK_ICON: b$1``, SEARCH_ICON: b$1``, WALLET_PLACEHOLDER: b$1``, GLOBE_ICON: b$1`` }, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; + var ut = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let fe = class extends s { + let $e = class extends s$1 { render() { - return x`
${v.WALLET_CONNECT_LOGO}
`; + return x`
${b.WALLET_CONNECT_LOGO}
`; } }; - fe.styles = [h.globalCss, pt], fe = ut([e$2("wcm-modal-backcard")], fe); + $e.styles = [h.globalCss, pt], $e = ut([e$2("wcm-modal-backcard")], $e); const bt = i$3`main{padding:20px;padding-top:0;width:100%}`; - var ft = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, yt = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? xt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ft(o2, r2, t2), t2; + var yt = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let xe = class extends s { + let Ce = class extends s$1 { render() { return x`
`; } }; - xe.styles = [h.globalCss, bt], xe = yt([e$2("wcm-modal-content")], xe); + Ce.styles = [h.globalCss, bt], Ce = yt([e$2("wcm-modal-content")], Ce); const $t = i$3`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`; - var Ct = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, Ot = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? kt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ct(o2, r2, t2), t2; + var Ot = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let ye = class extends s { + let ke = class extends s$1 { render() { return x`
`; } }; - ye.styles = [h.globalCss, $t], ye = Ot([e$2("wcm-modal-footer")], ye); - const Wt = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; - var It = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, te = (e2, o2, r2, a2) => { + ke.styles = [h.globalCss, $t], ke = Ot([e$2("wcm-modal-footer")], ke); + const It = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; + var Wt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, ae = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Et(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && It(o2, r2, t2), t2; + return a2 && t2 && Wt(o2, r2, t2), t2; }; - let S = class extends s { + let B = class extends s$1 { constructor() { super(...arguments), this.title = "", this.onAction = void 0, this.actionIcon = void 0, this.border = false; } backBtnTemplate() { - return x``; + return x``; } actionBtnTemplate() { return x``; @@ -21056,112 +28109,87 @@ return x`
${o$12 ? this.backBtnTemplate() : null} ${r2} ${this.onAction ? this.actionBtnTemplate() : null}
`; } }; - S.styles = [h.globalCss, Wt], te([n$1()], S.prototype, "title", 2), te([n$1()], S.prototype, "onAction", 2), te([n$1()], S.prototype, "actionIcon", 2), te([n$1({ type: Boolean })], S.prototype, "border", 2), S = te([e$2("wcm-modal-header")], S); - const c = { - MOBILE_BREAKPOINT: 600, - WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", - EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", - getShadowRootElement(e2, o2) { - const r2 = e2.renderRoot.querySelector(o2); - if (!r2) - throw new Error(`${o2} not found`); - return r2; - }, - getWalletIcon({ id: e2, image_id: o2 }) { - const { walletImages: r2 } = y$4.state; - return r2 != null && r2[e2] ? r2[e2] : o2 ? te$3.getWalletImageUrl(o2) : ""; - }, - getWalletName(e2, o2 = false) { - return o2 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; - }, - isMobileAnimation() { - return window.innerWidth <= c.MOBILE_BREAKPOINT; - }, - async preloadImage(e2) { - const o2 = new Promise((r2, a2) => { - const t2 = new Image(); - t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; - }); - return Promise.race([o2, a$5.wait(3e3)]); - }, - getErrorMessage(e2) { - return e2 instanceof Error ? e2.message : "Unknown Error"; - }, - debounce(e2, o2 = 500) { - let r2; - return (...a2) => { - function t2() { - e2(...a2); - } - r2 && clearTimeout(r2), r2 = setTimeout(t2, o2); - }; - }, - handleMobileLinking(e2) { - const { walletConnectUri: o2 } = p$4.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - c.setRecentWallet(e2); - function i2(s2) { - let $2 = ""; - t2 ? $2 = a$5.formatUniversalUrl(t2, s2, a2) : l2 && ($2 = a$5.formatNativeUrl(l2, s2, a2)), a$5.openHref($2, "_self"); - } - o2 && i2(o2); - }, - async handleUriCopy() { - const { walletConnectUri: e2 } = p$4.state; - if (e2) - try { - await navigator.clipboard.writeText(e2), oe$2.openToast("Link copied", "success"); - } catch { - oe$2.openToast("Failed to copy", "error"); - } - }, - getCustomImageUrls() { - const { walletImages: e2 } = y$4.state, o2 = Object.values(e2 ?? {}); - return Object.values(o2); - }, - truncate(e2, o2 = 8) { - return e2.length <= o2 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; - }, - setRecentWallet(e2) { - try { - localStorage.setItem(c.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); - } catch { - console.info("Unable to set recent wallet"); - } - }, - getRecentWallet() { + B.styles = [h.globalCss, It], ae([n$1()], B.prototype, "title", 2), ae([n$1()], B.prototype, "onAction", 2), ae([n$1()], B.prototype, "actionIcon", 2), ae([n$1({ type: Boolean })], B.prototype, "border", 2), B = ae([e$2("wcm-modal-header")], B); + const s = { MOBILE_BREAKPOINT: 600, WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", getShadowRootElement(e2, o2) { + const r2 = e2.renderRoot.querySelector(o2); + if (!r2) + throw new Error(`${o2} not found`); + return r2; + }, getWalletIcon({ id: e2, image_id: o2 }) { + const { walletImages: r2 } = y$5.state; + return r2 != null && r2[e2] ? r2[e2] : o2 ? te$1.getWalletImageUrl(o2) : ""; + }, getWalletName(e2, o2 = false) { + return o2 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; + }, isMobileAnimation() { + return window.innerWidth <= s.MOBILE_BREAKPOINT; + }, async preloadImage(e2) { + const o2 = new Promise((r2, a2) => { + const t2 = new Image(); + t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; + }); + return Promise.race([o2, i$5.wait(3e3)]); + }, getErrorMessage(e2) { + return e2 instanceof Error ? e2.message : "Unknown Error"; + }, debounce(e2, o2 = 500) { + let r2; + return (...a2) => { + function t2() { + e2(...a2); + } + r2 && clearTimeout(r2), r2 = setTimeout(t2, o2); + }; + }, handleMobileLinking(e2) { + const { walletConnectUri: o2 } = p$3.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; + s.setRecentWallet(e2); + function i2(c2) { + let u2 = ""; + t2 ? u2 = i$5.formatUniversalUrl(t2, c2, a2) : l2 && (u2 = i$5.formatNativeUrl(l2, c2, a2)), i$5.openHref(u2, "_self"); + } + o2 && i2(o2); + }, async handleUriCopy() { + const { walletConnectUri: e2 } = p$3.state; + if (e2) try { - const e2 = localStorage.getItem(c.WCM_RECENT_WALLET_DATA); - return e2 ? JSON.parse(e2) : void 0; + await navigator.clipboard.writeText(e2), oe$2.openToast("Link copied", "success"); } catch { - console.info("Unable to get recent wallet"); - } - }, - caseSafeIncludes(e2, o2) { - return e2.toUpperCase().includes(o2.toUpperCase()); - }, - openWalletExplorerUrl() { - a$5.openHref(c.EXPLORER_WALLET_URL, "_blank"); - }, - getCachedRouterWalletPlatforms() { - const { desktop: e2, mobile: o2 } = a$5.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o2 == null ? void 0 : o2.native) || Boolean(o2 == null ? void 0 : o2.universal); - return { isDesktop: r2, isMobile: t2, isWeb: a2 }; - }, - goToConnectingView(e2) { - T$3.setData({ Wallet: e2 }); - const o2 = a$5.isMobile(), { - isDesktop: r2, - isWeb: a2, - isMobile: t2 - } = c.getCachedRouterWalletPlatforms(); - o2 ? t2 ? T$3.push("MobileConnecting") : a2 ? T$3.push("WebConnecting") : T$3.push("InstallWallet") : r2 ? T$3.push("DesktopConnecting") : a2 ? T$3.push("WebConnecting") : t2 ? T$3.push("MobileQrcodeConnecting") : T$3.push("InstallWallet"); - } - }, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; - var Lt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, $e = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Rt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + oe$2.openToast("Failed to copy", "error"); + } + }, getCustomImageUrls() { + const { walletImages: e2 } = y$5.state, o2 = Object.values(e2 ?? {}); + return Object.values(o2); + }, truncate(e2, o2 = 8) { + return e2.length <= o2 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; + }, setRecentWallet(e2) { + try { + localStorage.setItem(s.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); + } catch { + console.info("Unable to set recent wallet"); + } + }, getRecentWallet() { + try { + const e2 = localStorage.getItem(s.WCM_RECENT_WALLET_DATA); + return e2 ? JSON.parse(e2) : void 0; + } catch { + console.info("Unable to get recent wallet"); + } + }, caseSafeIncludes(e2, o2) { + return e2.toUpperCase().includes(o2.toUpperCase()); + }, openWalletExplorerUrl() { + i$5.openHref(s.EXPLORER_WALLET_URL, "_blank"); + }, getCachedRouterWalletPlatforms() { + const { desktop: e2, mobile: o2 } = i$5.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o2 == null ? void 0 : o2.native) || Boolean(o2 == null ? void 0 : o2.universal); + return { isDesktop: r2, isMobile: t2, isWeb: a2 }; + }, goToConnectingView(e2) { + T$3.setData({ Wallet: e2 }); + const o2 = i$5.isMobile(), { isDesktop: r2, isWeb: a2, isMobile: t2 } = s.getCachedRouterWalletPlatforms(); + o2 ? t2 ? T$3.push("MobileConnecting") : a2 ? T$3.push("WebConnecting") : T$3.push("InstallWallet") : r2 ? T$3.push("DesktopConnecting") : a2 ? T$3.push("WebConnecting") : t2 ? T$3.push("MobileQrcodeConnecting") : T$3.push("InstallWallet"); + } }, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; + var Pt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, Oe = (e2, o2, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Lt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Lt(o2, r2, t2), t2; + return a2 && t2 && Pt(o2, r2, t2), t2; }; - let oe = class extends s { + let le = class extends s$1 { constructor() { super(), this.view = T$3.state.view, this.prevView = T$3.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = T$3.subscribe((e2) => { this.view !== e2.view && this.onChangeRoute(); @@ -21178,10 +28206,10 @@ (e2 = this.unsubscribe) == null || e2.call(this), (o2 = this.resizeObserver) == null || o2.disconnect(); } get routerEl() { - return c.getShadowRootElement(this, ".wcm-router"); + return s.getShadowRootElement(this, ".wcm-router"); } get contentEl() { - return c.getShadowRootElement(this, ".wcm-content"); + return s.getShadowRootElement(this, ".wcm-content"); } viewTemplate() { switch (this.view) { @@ -21206,28 +28234,20 @@ } } async onChangeRoute() { - await animate( - this.routerEl, - { opacity: [1, 0], scale: [1, 1.02] }, - { duration: 0.15, delay: 0.1 } - ).finished, this.view = T$3.state.view, animate( - this.routerEl, - { opacity: [0, 1], scale: [0.99, 1] }, - { duration: 0.37, delay: 0.05 } - ); + await animate(this.routerEl, { opacity: [1, 0], scale: [1, 1.02] }, { duration: 0.15, delay: 0.1 }).finished, this.view = T$3.state.view, animate(this.routerEl, { opacity: [0, 1], scale: [0.99, 1] }, { duration: 0.37, delay: 0.05 }); } render() { return x`
${this.viewTemplate()}
`; } }; - oe.styles = [h.globalCss, Mt], $e([t$1()], oe.prototype, "view", 2), $e([t$1()], oe.prototype, "prevView", 2), oe = $e([e$2("wcm-modal-router")], oe); - const At = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; - var Pt = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, ze = (e2, o2, r2, a2) => { + le.styles = [h.globalCss, Mt], Oe([t$1()], le.prototype, "view", 2), Oe([t$1()], le.prototype, "prevView", 2), le = Oe([e$2("wcm-modal-router")], le); + const Rt = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; + var At = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, He = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Tt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Pt(o2, r2, t2), t2; + return a2 && t2 && At(o2, r2, t2), t2; }; - let ne = class extends s { + let de = class extends s$1 { constructor() { super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = oe$2.subscribe((e2) => { e2.open ? (this.open = true, this.timeout = setTimeout(() => oe$2.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); @@ -21239,163 +28259,132 @@ } render() { const { message: e2, variant: o$12 } = oe$2.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; - return this.open ? x`
${o$12 === "success" ? v.CHECKMARK_ICON : null} ${o$12 === "error" ? v.CROSS_ICON : null}${e2}
` : null; + return this.open ? x`
${o$12 === "success" ? b.CHECKMARK_ICON : null} ${o$12 === "error" ? b.CROSS_ICON : null}${e2}
` : null; } }; - ne.styles = [h.globalCss, At], ze([t$1()], ne.prototype, "open", 2), ne = ze([e$2("wcm-modal-toast")], ne); - const jt = 0.1, Ve = 2.5, A = 7; - function Ce(e2, o2, r2) { + de.styles = [h.globalCss, Rt], He([t$1()], de.prototype, "open", 2), de = He([e$2("wcm-modal-toast")], de); + const jt = 0.1, Ve = 2.5, L = 7; + function Ie(e2, o2, r2) { return e2 === o2 ? false : (e2 - o2 < 0 ? o2 - e2 : e2 - o2) <= r2 + jt; } function _t(e2, o2) { - const r2 = Array.prototype.slice.call( - browser.create(e2, { errorCorrectionLevel: o2 }).modules.data, - 0 - ), a2 = Math.sqrt(r2.length); - return r2.reduce( - (t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, - [] - ); + const r2 = Array.prototype.slice.call(browser.create(e2, { errorCorrectionLevel: o2 }).modules.data, 0), a2 = Math.sqrt(r2.length); + return r2.reduce((t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, []); } - const Dt = { - generate(e2, o2, r2) { - const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), s2 = o2 / i2.length, $2 = [ - { x: 0, y: 0 }, - { x: 1, y: 0 }, - { x: 0, y: 1 } - ]; - $2.forEach(({ x: y2, y: u2 }) => { - const O2 = (i2.length - A) * s2 * y2, b$12 = (i2.length - A) * s2 * u2, E2 = 0.45; - for (let M2 = 0; M2 < $2.length; M2 += 1) { - const V2 = s2 * (A - M2 * 2); - l2.push( - b`` - ); + const Dt = { generate(e2, o2, r2) { + const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), c2 = o2 / i2.length, u2 = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }]; + u2.forEach(({ x: $2, y: f2 }) => { + const O2 = (i2.length - L) * c2 * $2, x2 = (i2.length - L) * c2 * f2, E2 = 0.45; + for (let M2 = 0; M2 < u2.length; M2 += 1) { + const Q2 = c2 * (L - M2 * 2); + l2.push(b$1``); + } + }); + const w2 = Math.floor((r2 + 25) / c2), F2 = i2.length / 2 - w2 / 2, T2 = i2.length / 2 + w2 / 2 - 1, j2 = []; + i2.forEach(($2, f2) => { + $2.forEach((O2, x2) => { + if (i2[f2][x2] && !(f2 < L && x2 < L || f2 > i2.length - (L + 1) && x2 < L || f2 < L && x2 > i2.length - (L + 1)) && !(f2 > F2 && f2 < T2 && x2 > F2 && x2 < T2)) { + const E2 = f2 * c2 + c2 / 2, M2 = x2 * c2 + c2 / 2; + j2.push([E2, M2]); } }); - const f2 = Math.floor((r2 + 25) / s2), Ne2 = i2.length / 2 - f2 / 2, Ze2 = i2.length / 2 + f2 / 2 - 1, Se = []; - i2.forEach((y2, u2) => { - y2.forEach((O2, b2) => { - if (i2[u2][b2] && !(u2 < A && b2 < A || u2 > i2.length - (A + 1) && b2 < A || u2 < A && b2 > i2.length - (A + 1)) && !(u2 > Ne2 && u2 < Ze2 && b2 > Ne2 && b2 < Ze2)) { - const E2 = u2 * s2 + s2 / 2, M2 = b2 * s2 + s2 / 2; - Se.push([E2, M2]); - } - }); + }); + const oe2 = {}; + return j2.forEach(([$2, f2]) => { + oe2[$2] ? oe2[$2].push(f2) : oe2[$2] = [f2]; + }), Object.entries(oe2).map(([$2, f2]) => { + const O2 = f2.filter((x2) => f2.every((E2) => !Ie(x2, E2, c2))); + return [Number($2), O2]; + }).forEach(([$2, f2]) => { + f2.forEach((O2) => { + l2.push(b$1``); }); - const J2 = {}; - return Se.forEach(([y2, u2]) => { - J2[y2] ? J2[y2].push(u2) : J2[y2] = [u2]; - }), Object.entries(J2).map(([y2, u2]) => { - const O2 = u2.filter((b2) => u2.every((E2) => !Ce(b2, E2, s2))); - return [Number(y2), O2]; - }).forEach(([y2, u2]) => { - u2.forEach((O2) => { - l2.push( - b`` - ); - }); - }), Object.entries(J2).filter(([y2, u2]) => u2.length > 1).map(([y2, u2]) => { - const O2 = u2.filter((b2) => u2.some((E2) => Ce(b2, E2, s2))); - return [Number(y2), O2]; - }).map(([y2, u2]) => { - u2.sort((b2, E2) => b2 < E2 ? -1 : 1); - const O2 = []; - for (const b2 of u2) { - const E2 = O2.find((M2) => M2.some((V2) => Ce(b2, V2, s2))); - E2 ? E2.push(b2) : O2.push([b2]); - } - return [y2, O2.map((b2) => [b2[0], b2[b2.length - 1]])]; - }).forEach(([y2, u2]) => { - u2.forEach(([O2, b$12]) => { - l2.push( - b`` - ); - }); - }), l2; - } - }, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; - var Zt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, q = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? St(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + }), Object.entries(oe2).filter(([$2, f2]) => f2.length > 1).map(([$2, f2]) => { + const O2 = f2.filter((x2) => f2.some((E2) => Ie(x2, E2, c2))); + return [Number($2), O2]; + }).map(([$2, f2]) => { + f2.sort((x2, E2) => x2 < E2 ? -1 : 1); + const O2 = []; + for (const x2 of f2) { + const E2 = O2.find((M2) => M2.some((Q2) => Ie(x2, Q2, c2))); + E2 ? E2.push(x2) : O2.push([x2]); + } + return [$2, O2.map((x2) => [x2[0], x2[x2.length - 1]])]; + }).forEach(([$2, f2]) => { + f2.forEach(([O2, x2]) => { + l2.push(b$1``); + }); + }), l2; + } }, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; + var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Y = (e2, o2, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zt(o2, r2, t2), t2; }; - let j = class extends s { + let D = class extends s$1 { constructor() { super(...arguments), this.uri = "", this.size = 0, this.imageId = void 0, this.walletId = void 0, this.imageUrl = void 0; } svgTemplate() { - const e2 = ne$1.state.themeMode === "light" ? this.size : this.size - 36; - return b`${Dt.generate(this.uri, e2, e2 / 4)}`; + const e2 = ne$4.state.themeMode === "light" ? this.size : this.size - 36; + return b$1`${Dt.generate(this.uri, e2, e2 / 4)}`; } render() { - const e2 = { "wcm-dark": ne$1.state.themeMode === "dark" }; - return x`
${this.walletId || this.imageUrl ? x`` : v.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; + const e2 = { "wcm-dark": ne$4.state.themeMode === "dark" }; + return x`
${this.walletId || this.imageUrl ? x`` : b.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; } }; - j.styles = [h.globalCss, Nt], q([n$1()], j.prototype, "uri", 2), q([n$1({ type: Number })], j.prototype, "size", 2), q([n$1()], j.prototype, "imageId", 2), q([n$1()], j.prototype, "walletId", 2), q([n$1()], j.prototype, "imageUrl", 2), j = q([e$2("wcm-qrcode")], j); - const Bt = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; - var Ut = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Fe = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ht(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + D.styles = [h.globalCss, Nt], Y([n$1()], D.prototype, "uri", 2), Y([n$1({ type: Number })], D.prototype, "size", 2), Y([n$1()], D.prototype, "imageId", 2), Y([n$1()], D.prototype, "walletId", 2), Y([n$1()], D.prototype, "imageUrl", 2), D = Y([e$2("wcm-qrcode")], D); + const St = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; + var Bt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, qe = (e2, o2, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ut(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ut(o2, r2, t2), t2; + return a2 && t2 && Bt(o2, r2, t2), t2; }; - let ce = class extends s { + let me = class extends s$1 { constructor() { super(...arguments), this.onChange = () => null; } render() { - return x` ${v.SEARCH_ICON}`; + return x` ${b.SEARCH_ICON}`; } }; - ce.styles = [h.globalCss, Bt], Fe([n$1()], ce.prototype, "onChange", 2), ce = Fe([e$2("wcm-search-input")], ce); - const zt = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; - var Vt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, qt = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ft(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Vt(o2, r2, t2), t2; + me.styles = [h.globalCss, St], qe([n$1()], me.prototype, "onChange", 2), me = qe([e$2("wcm-search-input")], me); + const Ht = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; + var Ft = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let ke = class extends s { + let We = class extends s$1 { render() { return x``; } }; - ke.styles = [h.globalCss, zt], ke = qt([e$2("wcm-spinner")], ke); + We.styles = [h.globalCss, Ht], We = Ft([e$2("wcm-spinner")], We); const Qt = i$3`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`; - var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Oe = (e2, o2, r2, a2) => { + var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Ee = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Yt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && Kt(o2, r2, t2), t2; }; - let re = class extends s { + let ie = class extends s$1 { constructor() { super(...arguments), this.variant = "medium-regular", this.color = "primary"; } render() { - const e2 = { - "wcm-big-bold": this.variant === "big-bold", - "wcm-medium-regular": this.variant === "medium-regular", - "wcm-small-regular": this.variant === "small-regular", - "wcm-small-thin": this.variant === "small-thin", - "wcm-xsmall-regular": this.variant === "xsmall-regular", - "wcm-xsmall-bold": this.variant === "xsmall-bold", - "wcm-color-primary": this.color === "primary", - "wcm-color-secondary": this.color === "secondary", - "wcm-color-tertiary": this.color === "tertiary", - "wcm-color-inverse": this.color === "inverse", - "wcm-color-accnt": this.color === "accent", - "wcm-color-error": this.color === "error" - }; + const e2 = { "wcm-big-bold": this.variant === "big-bold", "wcm-medium-regular": this.variant === "medium-regular", "wcm-small-regular": this.variant === "small-regular", "wcm-small-thin": this.variant === "small-thin", "wcm-xsmall-regular": this.variant === "xsmall-regular", "wcm-xsmall-bold": this.variant === "xsmall-bold", "wcm-color-primary": this.color === "primary", "wcm-color-secondary": this.color === "secondary", "wcm-color-tertiary": this.color === "tertiary", "wcm-color-inverse": this.color === "inverse", "wcm-color-accnt": this.color === "accent", "wcm-color-error": this.color === "error" }; return x``; } }; - re.styles = [h.globalCss, Qt], Oe([n$1()], re.prototype, "variant", 2), Oe([n$1()], re.prototype, "color", 2), re = Oe([e$2("wcm-text")], re); + ie.styles = [h.globalCss, Qt], Ee([n$1()], ie.prototype, "variant", 2), Ee([n$1()], ie.prototype, "color", 2), ie = Ee([e$2("wcm-text")], ie); const Gt = i$3`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`; - var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, _ = (e2, o2, r2, a2) => { + var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, N = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jt(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xt(o2, r2, t2), t2; }; - let L = class extends s { + let P = class extends s$1 { constructor() { super(...arguments), this.onClick = () => null, this.name = "", this.walletId = "", this.label = void 0, this.imageId = void 0, this.installed = false, this.recent = false; } @@ -21403,79 +28392,76 @@ return this.recent ? x`RECENT` : this.installed ? x`INSTALLED` : null; } handleClick() { - R$5.click({ name: "WALLET_BUTTON", walletId: this.walletId }), this.onClick(); + R$2.click({ name: "WALLET_BUTTON", walletId: this.walletId }), this.onClick(); } render() { var e2; - return x``; + return x``; } }; - L.styles = [h.globalCss, Gt], _([n$1()], L.prototype, "onClick", 2), _([n$1()], L.prototype, "name", 2), _([n$1()], L.prototype, "walletId", 2), _([n$1()], L.prototype, "label", 2), _([n$1()], L.prototype, "imageId", 2), _([n$1({ type: Boolean })], L.prototype, "installed", 2), _([n$1({ type: Boolean })], L.prototype, "recent", 2), L = _([e$2("wcm-wallet-button")], L); + P.styles = [h.globalCss, Gt], N([n$1()], P.prototype, "onClick", 2), N([n$1()], P.prototype, "name", 2), N([n$1()], P.prototype, "walletId", 2), N([n$1()], P.prototype, "label", 2), N([n$1()], P.prototype, "imageId", 2), N([n$1({ type: Boolean })], P.prototype, "installed", 2), N([n$1({ type: Boolean })], P.prototype, "recent", 2), P = N([e$2("wcm-wallet-button")], P); const eo = i$3`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; - var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, se = (e2, o2, r2, a2) => { + var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, we = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? oo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && to(o2, r2, t2), t2; }; - let Q = class extends s { + let G = class extends s$1 { constructor() { super(...arguments), this.walletId = "", this.imageId = void 0, this.imageUrl = void 0; } render() { var e2; - const o2 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : c.getWalletIcon({ id: this.walletId, image_id: this.imageId }); - return x`${o2.length ? x`
${this.id}
` : v.WALLET_PLACEHOLDER}`; + const o2 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : s.getWalletIcon({ id: this.walletId, image_id: this.imageId }); + return x`${o2.length ? x`
${this.id}
` : b.WALLET_PLACEHOLDER}`; } }; - Q.styles = [h.globalCss, eo], se([n$1()], Q.prototype, "walletId", 2), se([n$1()], Q.prototype, "imageId", 2), se([n$1()], Q.prototype, "imageUrl", 2), Q = se([e$2("wcm-wallet-image")], Q); - var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, qe = (e2, o2, r2, a2) => { + G.styles = [h.globalCss, eo], we([n$1()], G.prototype, "walletId", 2), we([n$1()], G.prototype, "imageId", 2), we([n$1()], G.prototype, "imageUrl", 2), G = we([e$2("wcm-wallet-image")], G); + var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, Fe = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? ao(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && ro(o2, r2, t2), t2; }; - let We = class extends s { + let Me = class extends s$1 { constructor() { super(), this.preload = true, this.preloadData(); } async loadImages(e2) { try { - e2 != null && e2.length && await Promise.all(e2.map(async (o2) => c.preloadImage(o2))); + e2 != null && e2.length && await Promise.all(e2.map(async (o2) => s.preloadImage(o2))); } catch { console.info("Unsuccessful attempt at preloading some images", e2); } } async preloadListings() { - if (y$4.state.enableExplorer) { - await te$3.getRecomendedWallets(), p$4.setIsDataLoaded(true); - const { recomendedWallets: e2 } = te$3.state, o2 = e2.map((r2) => c.getWalletIcon(r2)); + if (y$5.state.enableExplorer) { + await te$1.getRecomendedWallets(), p$3.setIsDataLoaded(true); + const { recomendedWallets: e2 } = te$1.state, o2 = e2.map((r2) => s.getWalletIcon(r2)); await this.loadImages(o2); } else - p$4.setIsDataLoaded(true); + p$3.setIsDataLoaded(true); } async preloadCustomImages() { - const e2 = c.getCustomImageUrls(); + const e2 = s.getCustomImageUrls(); await this.loadImages(e2); } async preloadData() { try { - this.preload && (this.preload = false, await Promise.all([ - this.preloadListings(), - this.preloadCustomImages() - ])); + this.preload && (this.preload = false, await Promise.all([this.preloadListings(), this.preloadCustomImages()])); } catch (e2) { console.error(e2), oe$2.openToast("Failed preloading", "error"); } } }; - qe([t$1()], We.prototype, "preload", 2), We = qe([e$2("wcm-explorer-context")], We); - var lo = Object.defineProperty, io = Object.getOwnPropertyDescriptor, no = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? io(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && lo(o2, r2, t2), t2; + Fe([t$1()], Me.prototype, "preload", 2), Me = Fe([e$2("wcm-explorer-context")], Me); + var no = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Qe = class extends s { + let Qe = class extends s$1 { constructor() { - super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = ne$1.subscribe(h.setTheme); + super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = ne$4.subscribe(h.setTheme); } disconnectedCallback() { var e2; @@ -21484,42 +28470,40 @@ }; Qe = no([e$2("wcm-theme-context")], Qe); const co = i$3`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; - var so = Object.defineProperty, mo = Object.getOwnPropertyDescriptor, ho = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? mo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && so(o2, r2, t2), t2; + var wo = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Ie = class extends s { + let Pe = class extends s$1 { onConnect(e2) { - a$5.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + i$5.isAndroid() ? s.handleMobileLinking(e2) : s.goToConnectingView(e2); } onGoToQrcode() { T$3.push("Qrcode"); } render() { - const { recomendedWallets: e2 } = te$3.state, o2 = [...e2, ...e2], r2 = a$5.RECOMMENDED_WALLET_AMOUNT * 2; - return x`
${v.MOBILE_ICON}WalletConnect
${[ - ...Array(r2) - ].map((a2, t2) => { + const { recomendedWallets: e2 } = te$1.state, o2 = [...e2, ...e2], r2 = i$5.RECOMMENDED_WALLET_AMOUNT * 2; + return x`
${b.MOBILE_ICON}WalletConnect
${[...Array(r2)].map((a2, t2) => { const l2 = o2[t2 % o2.length]; - return l2 ? x`` : v.WALLET_PLACEHOLDER; + return l2 ? x`` : b.WALLET_PLACEHOLDER; })}
Select Wallet
Choose WalletConnect to see supported apps on your device`; } }; - Ie.styles = [h.globalCss, co], Ie = ho([e$2("wcm-android-wallet-selection")], Ie); - const wo = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; - var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, K = (e2, o2, r2, a2) => { + Pe.styles = [h.globalCss, co], Pe = wo([e$2("wcm-android-wallet-selection")], Pe); + const ho = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; + var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, X = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? go(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && po(o2, r2, t2), t2; }; - let D = class extends s { + let Z = class extends s$1 { constructor() { super(...arguments), this.walletId = void 0, this.imageId = void 0, this.isError = false, this.isStale = false, this.label = ""; } svgLoaderTemplate() { var e2, o2; - const r2 = (o2 = (e2 = ne$1.state.themeVariables) == null ? void 0 : e2["--wcm-wallet-icon-large-border-radius"]) != null ? o2 : h.getPreset("--wcm-wallet-icon-large-border-radius"); + const r2 = (o2 = (e2 = ne$4.state.themeVariables) == null ? void 0 : e2["--wcm-wallet-icon-large-border-radius"]) != null ? o2 : h.getPreset("--wcm-wallet-icon-large-border-radius"); let a2 = 0; r2.includes("%") ? a2 = 88 / 100 * parseInt(r2, 10) : a2 = parseInt(r2, 10), a2 *= 1.17; const t2 = 317 - a2 * 1.57, l2 = 425 - a2 * 1.8; @@ -21530,113 +28514,90 @@ return x`
${this.svgLoaderTemplate()}
${this.isError ? "Connection declined" : this.label}`; } }; - D.styles = [h.globalCss, wo], K([n$1()], D.prototype, "walletId", 2), K([n$1()], D.prototype, "imageId", 2), K([n$1({ type: Boolean })], D.prototype, "isError", 2), K([n$1({ type: Boolean })], D.prototype, "isStale", 2), K([n$1()], D.prototype, "label", 2), D = K([e$2("wcm-connector-waiting")], D); - const G = { - manualWallets() { - var e2, o2; - const { mobileWallets: r2, desktopWallets: a2 } = y$4.state, t2 = (e2 = G.recentWallet()) == null ? void 0 : e2.id, l2 = a$5.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((s2) => t2 !== s2.id); - return (o2 = a$5.isMobile() ? i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - mobile: f2, - links: f2 - })) : i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - desktop: f2, - links: f2 - }))) != null ? o2 : []; - }, - recentWallet() { - return c.getRecentWallet(); - }, - recomendedWallets(e2 = false) { - var o2; - const r2 = e2 || (o2 = G.recentWallet()) == null ? void 0 : o2.id, { recomendedWallets: a2 } = te$3.state; - return a2.filter((t2) => r2 !== t2.id); - } - }, Z = { - onConnecting(e2) { - c.goToConnectingView(e2); - }, - manualWalletsTemplate() { - return G.manualWallets().map( - (e2) => x`` - ); - }, - recomendedWalletsTemplate(e2 = false) { - return G.recomendedWallets(e2).map( - (o2) => x`` - ); - }, - recentWalletTemplate() { - const e2 = G.recentWallet(); - if (e2) - return x``; - } - }, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; - var uo = Object.defineProperty, bo = Object.getOwnPropertyDescriptor, fo = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? bo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && uo(o2, r2, t2), t2; + Z.styles = [h.globalCss, ho], X([n$1()], Z.prototype, "walletId", 2), X([n$1()], Z.prototype, "imageId", 2), X([n$1({ type: Boolean })], Z.prototype, "isError", 2), X([n$1({ type: Boolean })], Z.prototype, "isStale", 2), X([n$1()], Z.prototype, "label", 2), Z = X([e$2("wcm-connector-waiting")], Z); + const ee = { manualWallets() { + var e2, o2; + const { mobileWallets: r2, desktopWallets: a2 } = y$5.state, t2 = (e2 = ee.recentWallet()) == null ? void 0 : e2.id, l2 = i$5.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((c2) => t2 !== c2.id); + return (o2 = i$5.isMobile() ? i2 == null ? void 0 : i2.map(({ id: c2, name: u2, links: w2 }) => ({ id: c2, name: u2, mobile: w2, links: w2 })) : i2 == null ? void 0 : i2.map(({ id: c2, name: u2, links: w2 }) => ({ id: c2, name: u2, desktop: w2, links: w2 }))) != null ? o2 : []; + }, recentWallet() { + return s.getRecentWallet(); + }, recomendedWallets(e2 = false) { + var o2; + const r2 = e2 || (o2 = ee.recentWallet()) == null ? void 0 : o2.id, { recomendedWallets: a2 } = te$1.state; + return a2.filter((t2) => r2 !== t2.id); + } }, S = { onConnecting(e2) { + s.goToConnectingView(e2); + }, manualWalletsTemplate() { + return ee.manualWallets().map((e2) => x``); + }, recomendedWalletsTemplate(e2 = false) { + return ee.recomendedWallets(e2).map((o2) => x``); + }, recentWalletTemplate() { + const e2 = ee.recentWallet(); + if (e2) + return x``; + } }, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; + var fo = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Ee = class extends s { + let Le = class extends s$1 { render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o2 } = y$4.state, r2 = e2 !== "ALL" && o2, a2 = Z.manualWalletsTemplate(), t2 = Z.recomendedWalletsTemplate(); - let l2 = [Z.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o2 } = y$5.state, r2 = e2 !== "ALL" && o2, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 4 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 3) : s2 = l2; - const $2 = Boolean(s2.length); - return x`
${v.MOBILE_ICON}Mobile
${v.SCAN_ICON}Scan with your wallet
${$2 ? x`
${v.DESKTOP_ICON}Desktop
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 3) : c2 = l2; + const u2 = Boolean(c2.length); + return x`
${b.MOBILE_ICON}Mobile
${b.SCAN_ICON}Scan with your wallet
${u2 ? x`
${b.DESKTOP_ICON}Desktop
${c2} ${i2 ? x`` : null}
` : null}`; } }; - Ee.styles = [h.globalCss, vo], Ee = fo([e$2("wcm-desktop-wallet-selection")], Ee); + Le.styles = [h.globalCss, vo], Le = fo([e$2("wcm-desktop-wallet-selection")], Le); const xo = i$3`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`; - var yo = Object.defineProperty, $o = Object.getOwnPropertyDescriptor, Co = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? $o(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && yo(o2, r2, t2), t2; + var Co = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Me = class extends s { + let Re = class extends s$1 { render() { - const { termsOfServiceUrl: e2, privacyPolicyUrl: o2 } = y$4.state; + const { termsOfServiceUrl: e2, privacyPolicyUrl: o2 } = y$5.state; return e2 ?? o2 ? x`
By connecting your wallet to this app, you agree to the app's ${e2 ? x`Terms of Service` : null} ${e2 && o2 ? "and" : null} ${o2 ? x`Privacy Policy` : null}
` : null; } }; - Me.styles = [h.globalCss, xo], Me = Co([e$2("wcm-legal-notice")], Me); + Re.styles = [h.globalCss, xo], Re = Co([e$2("wcm-legal-notice")], Re); const ko = i$3`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`; - var Oo = Object.defineProperty, Wo = Object.getOwnPropertyDescriptor, Io = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Wo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Oo(o2, r2, t2), t2; + var Wo = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Le = class extends s { + let Ae = class extends s$1 { onQrcode() { T$3.push("Qrcode"); } render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o2 } = y$4.state, r2 = e2 !== "ALL" && o2, a2 = Z.manualWalletsTemplate(), t2 = Z.recomendedWalletsTemplate(); - let l2 = [Z.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o2 } = y$5.state, r2 = e2 !== "ALL" && o2, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 8 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 7) : s2 = l2; - const $2 = Boolean(s2.length); - return x`${$2 ? x`
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 7) : c2 = l2; + const u2 = Boolean(c2.length); + return x`${u2 ? x`
${c2} ${i2 ? x`` : null}
` : null}`; } }; - Le.styles = [h.globalCss, ko], Le = Io([e$2("wcm-mobile-wallet-selection")], Le); + Ae.styles = [h.globalCss, ko], Ae = Wo([e$2("wcm-mobile-wallet-selection")], Ae); const Eo = i$3`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`; - var Mo = Object.defineProperty, Lo = Object.getOwnPropertyDescriptor, Re = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Lo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + var Mo = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, Te = (e2, o2, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && Mo(o2, r2, t2), t2; }; - let ae = class extends s { + let ne = class extends s$1 { constructor() { - super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = se$1.subscribe((e2) => { + super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = se$4.subscribe((e2) => { e2.open ? this.onOpenModalEvent() : this.onCloseModalEvent(); }); } @@ -21645,10 +28606,10 @@ (e2 = this.unsubscribeModal) == null || e2.call(this); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-overlay"); + return s.getShadowRootElement(this, ".wcm-overlay"); } get containerEl() { - return c.getShadowRootElement(this, ".wcm-container"); + return s.getShadowRootElement(this, ".wcm-container"); } toggleBodyScroll(e2) { if (document.querySelector("body")) @@ -21656,40 +28617,27 @@ const o2 = document.getElementById("wcm-styles"); o2 == null ? void 0 : o2.remove(); } else - document.head.insertAdjacentHTML( - "beforeend", - '' - ); + document.head.insertAdjacentHTML("beforeend", ''); } onCloseModal(e2) { - e2.target === e2.currentTarget && se$1.close(); + e2.target === e2.currentTarget && se$4.close(); } onOpenModalEvent() { this.toggleBodyScroll(false), this.addKeyboardEvents(), this.open = true, setTimeout(async () => { - const e2 = c.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o2 = 0.1, r2 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [0, 1] }, { delay: o2, duration: r2 }).finished, - animate(this.containerEl, e2, { delay: o2, duration: r2 }).finished - ]), this.active = true; + const e2 = s.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o2 = 0.1, r2 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [0, 1] }, { delay: o2, duration: r2 }).finished, animate(this.containerEl, e2, { delay: o2, duration: r2 }).finished]), this.active = true; }, 0); } async onCloseModalEvent() { this.toggleBodyScroll(true), this.removeKeyboardEvents(); - const e2 = c.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o2 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [1, 0] }, { duration: o2 }).finished, - animate(this.containerEl, e2, { duration: o2 }).finished - ]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; + const e2 = s.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o2 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [1, 0] }, { duration: o2 }).finished, animate(this.containerEl, e2, { duration: o2 }).finished]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; } addKeyboardEvents() { - this.abortController = new AbortController(), window.addEventListener( - "keydown", - (e2) => { - var o2; - e2.key === "Escape" ? se$1.close() : e2.key === "Tab" && ((o2 = e2.target) != null && o2.tagName.includes("wcm-") || this.containerEl.focus()); - }, - this.abortController - ), this.containerEl.focus(); + this.abortController = new AbortController(), window.addEventListener("keydown", (e2) => { + var o2; + e2.key === "Escape" ? se$4.close() : e2.key === "Tab" && ((o2 = e2.target) != null && o2.tagName.includes("wcm-") || this.containerEl.focus()); + }, this.abortController), this.containerEl.focus(); } removeKeyboardEvents() { var e2; @@ -21700,19 +28648,19 @@ return x`
${this.open ? x`
` : null}
`; } }; - ae.styles = [h.globalCss, Eo], Re([t$1()], ae.prototype, "open", 2), Re([t$1()], ae.prototype, "active", 2), ae = Re([e$2("wcm-modal")], ae); - const Ro = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; - var Ao = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, le = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + ne.styles = [h.globalCss, Eo], Te([t$1()], ne.prototype, "open", 2), Te([t$1()], ne.prototype, "active", 2), ne = Te([e$2("wcm-modal")], ne); + const Lo = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; + var Ro = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, ce = (e2, o2, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ao(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ao(o2, r2, t2), t2; + return a2 && t2 && Ro(o2, r2, t2), t2; }; - let B = class extends s { + let U = class extends s$1 { constructor() { super(...arguments), this.isMobile = false, this.isDesktop = false, this.isWeb = false, this.isRetry = false; } onMobile() { - a$5.isMobile() ? T$3.replace("MobileConnecting") : T$3.replace("MobileQrcodeConnecting"); + i$5.isMobile() ? T$3.replace("MobileConnecting") : T$3.replace("MobileQrcodeConnecting"); } onDesktop() { T$3.replace("DesktopConnecting"); @@ -21721,191 +28669,192 @@ T$3.replace("WebConnecting"); } render() { - return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; + return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; } }; - B.styles = [h.globalCss, Ro], le([n$1({ type: Boolean })], B.prototype, "isMobile", 2), le([n$1({ type: Boolean })], B.prototype, "isDesktop", 2), le([n$1({ type: Boolean })], B.prototype, "isWeb", 2), le([n$1({ type: Boolean })], B.prototype, "isRetry", 2), B = le([e$2("wcm-platform-selection")], B); + U.styles = [h.globalCss, Lo], ce([n$1({ type: Boolean })], U.prototype, "isMobile", 2), ce([n$1({ type: Boolean })], U.prototype, "isDesktop", 2), ce([n$1({ type: Boolean })], U.prototype, "isWeb", 2), ce([n$1({ type: Boolean })], U.prototype, "isRetry", 2), U = ce([e$2("wcm-platform-selection")], U); const To = i$3`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; - var jo = Object.defineProperty, _o = Object.getOwnPropertyDescriptor, Do = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? _o(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && jo(o2, r2, t2), t2; + var Do = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Ae = class extends s { + let je = class extends s$1 { onClick() { T$3.push("WalletExplorer"); } render() { - const { recomendedWallets: e2 } = te$3.state, o2 = G.manualWallets(), r2 = [...e2, ...o2].reverse().slice(0, 4); - return x``; + const { recomendedWallets: e2 } = te$1.state, o2 = ee.manualWallets(), r2 = [...e2, ...o2].reverse().slice(0, 4); + return x``; } }; - Ae.styles = [h.globalCss, To], Ae = Do([e$2("wcm-view-all-wallets-button")], Ae); + je.styles = [h.globalCss, To], je = Do([e$2("wcm-view-all-wallets-button")], je); const No = i$3`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`; - var Zo = Object.defineProperty, So = Object.getOwnPropertyDescriptor, de = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? So(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + var Zo = Object.defineProperty, zo = Object.getOwnPropertyDescriptor, he = (e2, o2, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zo(o2, r2, t2), t2; }; - let Y = class extends s { + let J = class extends s$1 { constructor() { super(), this.walletId = "", this.imageId = "", this.uri = "", setTimeout(() => { - const { walletConnectUri: e2 } = p$4.state; + const { walletConnectUri: e2 } = p$3.state; this.uri = e2; }, 0); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-qr-container"); + return s.getShadowRootElement(this, ".wcm-qr-container"); } render() { return x`
${this.uri ? x`` : x``}
`; } }; - Y.styles = [h.globalCss, No], de([n$1()], Y.prototype, "walletId", 2), de([n$1()], Y.prototype, "imageId", 2), de([t$1()], Y.prototype, "uri", 2), Y = de([e$2("wcm-walletconnect-qr")], Y); - var Bo = Object.defineProperty, Uo = Object.getOwnPropertyDescriptor, Ho = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Uo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Bo(o2, r2, t2), t2; + J.styles = [h.globalCss, No], he([n$1()], J.prototype, "walletId", 2), he([n$1()], J.prototype, "imageId", 2), he([t$1()], J.prototype, "uri", 2), J = he([e$2("wcm-walletconnect-qr")], J); + var Uo = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Pe = class extends s { + let _e = class extends s$1 { viewTemplate() { - return a$5.isAndroid() ? x`` : a$5.isMobile() ? x`` : x``; + return i$5.isAndroid() ? x`` : i$5.isMobile() ? x`` : x``; } render() { return x`${this.viewTemplate()}`; } }; - Pe.styles = [h.globalCss], Pe = Ho([e$2("wcm-connect-wallet-view")], Pe); - const zo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; - var Vo = Object.defineProperty, Fo = Object.getOwnPropertyDescriptor, Ke = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Fo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + _e.styles = [h.globalCss], _e = Uo([e$2("wcm-connect-wallet-view")], _e); + const Ho = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; + var Vo = Object.defineProperty, qo = Object.getOwnPropertyDescriptor, Ke = (e2, o2, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? qo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && Vo(o2, r2, t2), t2; }; - let me = class extends s { + let pe = class extends s$1 { constructor() { super(), this.isError = false, this.openDesktopApp(); } onFormatAndRedirect(e2) { - const { desktop: o2, name: r2 } = a$5.getWalletRouterData(), a2 = o2 == null ? void 0 : o2.native; - if (a2) { - const t2 = a$5.formatNativeUrl(a2, e2, r2); - a$5.openHref(t2, "_self"); + var o2; + const { desktop: r2, name: a2 } = i$5.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native; + if (t2) { + const l2 = i$5.formatNativeUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o2 = window == null ? void 0 : window.aleo) != null && o2.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u2 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u2 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + i$5.openHref(l2, "_self"); } } openDesktopApp() { - const { walletConnectUri: e2 } = p$4.state, o2 = a$5.getWalletRouterData(); - c.setRecentWallet(o2), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = p$3.state, o2 = i$5.getWalletRouterData(); + s.setRecentWallet(o2), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o2, image_id: r2 } = a$5.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; + const { name: e2, id: o2, image_id: r2 } = i$5.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = s.getCachedRouterWalletPlatforms(); + return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; } }; - me.styles = [h.globalCss, zo], Ke([t$1()], me.prototype, "isError", 2), me = Ke([e$2("wcm-desktop-connecting-view")], me); - const qo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; - var Qo = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, Yo = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ko(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Qo(o2, r2, t2), t2; + pe.styles = [h.globalCss, Ho], Ke([t$1()], pe.prototype, "isError", 2), pe = Ke([e$2("wcm-desktop-connecting-view")], pe); + const Fo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; + var Yo = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Te = class extends s { + let De = class extends s$1 { onInstall(e2) { - e2 && a$5.openHref(e2, "_blank"); + e2 && i$5.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o2, - image_id: r2, - homepage: a2 - } = a$5.getWalletRouterData(); - return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; + const { name: e2, id: o2, image_id: r2, homepage: a2 } = i$5.getWalletRouterData(); + return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; } }; - Te.styles = [h.globalCss, qo], Te = Yo([e$2("wcm-install-wallet-view")], Te); + De.styles = [h.globalCss, Fo], De = Yo([e$2("wcm-install-wallet-view")], De); const Go = i$3`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`; var Xo = Object.defineProperty, Jo = Object.getOwnPropertyDescriptor, Ye = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jo(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xo(o2, r2, t2), t2; }; - let he = class extends s { + let ge = class extends s$1 { constructor() { super(), this.isError = false, this.openMobileApp(); } onFormatAndRedirect(e2, o2 = false) { - const { mobile: r2, name: a2 } = a$5.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - if (t2 && !o2) { - const i2 = a$5.formatNativeUrl(t2, e2, a2); - a$5.openHref(i2, "_self"); - } else if (l2) { - const i2 = a$5.formatUniversalUrl(l2, e2, a2); - a$5.openHref(i2, "_self"); + var r2, a2; + const { mobile: t2, name: l2 } = i$5.getWalletRouterData(), i2 = t2 == null ? void 0 : t2.native, c2 = t2 == null ? void 0 : t2.universal; + if (i2 && !o2) { + const u2 = i$5.formatNativeUrl(i2, e2, l2); + if (l2 === "Puzzle Wallet" && (r2 = window == null ? void 0 : window.aleo) != null && r2.connectPuzzle) { + const w2 = new URL(u2).searchParams, F2 = w2.get("uri"), T2 = w2.get("requestId"), j2 = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F2, requestId: T2 ?? void 0, sessionTopic: j2 ?? void 0 } }); + } else + i$5.openHref(u2, "_self"); + } else if (c2) { + const u2 = i$5.formatUniversalUrl(c2, e2, l2); + if (l2 === "Puzzle Wallet" && (a2 = window == null ? void 0 : window.aleo) != null && a2.connectPuzzle) { + const w2 = new URL(u2).searchParams, F2 = w2.get("uri"), T2 = w2.get("requestId"), j2 = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F2, requestId: T2 ?? void 0, sessionTopic: j2 ?? void 0 } }); + } else + i$5.openHref(u2, "_self"); } } openMobileApp(e2 = false) { - const { walletConnectUri: o2 } = p$4.state, r2 = a$5.getWalletRouterData(); - c.setRecentWallet(r2), o2 && this.onFormatAndRedirect(o2, e2); + const { walletConnectUri: o2 } = p$3.state, r2 = i$5.getWalletRouterData(); + s.setRecentWallet(r2), o2 && this.onFormatAndRedirect(o2, e2); } onGoToAppStore(e2) { - e2 && a$5.openHref(e2, "_blank"); + e2 && i$5.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o2, - image_id: r2, - app: a2, - mobile: t2 - } = a$5.getWalletRouterData(), { isWeb: l$12 } = c.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, s2 = t2 == null ? void 0 : t2.universal; - return x`Retry${s2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; + const { name: e2, id: o2, image_id: r2, app: a2, mobile: t2 } = i$5.getWalletRouterData(), { isWeb: l$12 } = s.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, c2 = t2 == null ? void 0 : t2.universal; + return x`Retry${c2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; } }; - he.styles = [h.globalCss, Go], Ye([t$1()], he.prototype, "isError", 2), he = Ye([e$2("wcm-mobile-connecting-view")], he); + ge.styles = [h.globalCss, Go], Ye([t$1()], ge.prototype, "isError", 2), ge = Ye([e$2("wcm-mobile-connecting-view")], ge); const er = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; - var tr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, rr = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? or(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && tr(o2, r2, t2), t2; + var rr = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let je = class extends s { + let Ne = class extends s$1 { render() { - const { name: e2, id: o2, image_id: r2 } = a$5.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; + const { name: e2, id: o2, image_id: r2 } = i$5.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = s.getCachedRouterWalletPlatforms(); + return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; } }; - je.styles = [h.globalCss, er], je = rr([e$2("wcm-mobile-qr-connecting-view")], je); - var ar = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, ir = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? lr(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ar(o2, r2, t2), t2; + Ne.styles = [h.globalCss, er], Ne = rr([e$2("wcm-mobile-qr-connecting-view")], Ne); + var ir = (e2, o2, r2, a2) => { + for (var t2 = o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let _e = class extends s { + let Ze = class extends s$1 { render() { - return x``; + return x``; } }; - _e.styles = [h.globalCss], _e = ir([e$2("wcm-qrcode-view")], _e); + Ze.styles = [h.globalCss], Ze = ir([e$2("wcm-qrcode-view")], Ze); const nr = i$3`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`; - var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, ie = (e2, o2, r2, a2) => { + var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, se = (e2, o2, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? sr(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && cr(o2, r2, t2), t2; }; - const De = 40; - let U = class extends s { + const ze = 40; + let H = class extends s$1 { constructor() { - super(...arguments), this.loading = !te$3.state.wallets.listings.length, this.firstFetch = !te$3.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = c.debounce((e2) => { - e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, te$3.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), te$3.resetSearch()); + super(...arguments), this.loading = !te$1.state.wallets.listings.length, this.firstFetch = !te$1.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = s.debounce((e2) => { + e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, te$1.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), te$1.resetSearch()); }); } firstUpdated() { @@ -21916,7 +28865,7 @@ (e2 = this.intersectionObserver) == null || e2.disconnect(); } get placeholderEl() { - return c.getShadowRootElement(this, ".wcm-placeholder-block"); + return s.getShadowRootElement(this, ".wcm-placeholder-block"); } createPaginationObserver() { this.intersectionObserver = new IntersectionObserver(([e2]) => { @@ -21924,102 +28873,78 @@ }), this.intersectionObserver.observe(this.placeholderEl); } isLastPage() { - const { wallets: e2, search: o2 } = te$3.state, { listings: r2, total: a2 } = this.search ? o2 : e2; - return a2 <= De || r2.length >= a2; + const { wallets: e2, search: o2 } = te$1.state, { listings: r2, total: a2 } = this.search ? o2 : e2; + return a2 <= ze || r2.length >= a2; } async fetchWallets() { var e2; - const { wallets: o2, search: r2 } = te$3.state, { listings: a2, total: t2, page: l2 } = this.search ? r2 : o2; - if (!this.endReached && (this.firstFetch || t2 > De && a2.length < t2)) + const { wallets: o2, search: r2 } = te$1.state, { listings: a2, total: t2, page: l2 } = this.search ? r2 : o2; + if (!this.endReached && (this.firstFetch || t2 > ze && a2.length < t2)) try { this.loading = true; - const i2 = (e2 = p$4.state.chains) == null ? void 0 : e2.join(","), { listings: s2 } = await te$3.getWallets({ - page: this.firstFetch ? 1 : l2 + 1, - entries: De, - search: this.search, - version: 2, - chains: i2 - }), $2 = s2.map((f2) => c.getWalletIcon(f2)); - await Promise.all([ - ...$2.map(async (f2) => c.preloadImage(f2)), - a$5.wait(300) - ]), this.endReached = this.isLastPage(); + const i2 = (e2 = p$3.state.chains) == null ? void 0 : e2.join(","), { listings: c2 } = await te$1.getWallets({ page: this.firstFetch ? 1 : l2 + 1, entries: ze, search: this.search, version: 2, chains: i2 }), u2 = c2.map((w2) => s.getWalletIcon(w2)); + await Promise.all([...u2.map(async (w2) => s.preloadImage(w2)), i$5.wait(300)]), this.endReached = this.isLastPage(); } catch (i2) { - console.error(i2), oe$2.openToast(c.getErrorMessage(i2), "error"); + console.error(i2), oe$2.openToast(s.getErrorMessage(i2), "error"); } finally { this.loading = false, this.firstFetch = false; } } onConnect(e2) { - a$5.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + i$5.isAndroid() ? s.handleMobileLinking(e2) : s.goToConnectingView(e2); } onSearchChange(e2) { const { value: o2 } = e2.target; this.searchDebounce(o2); } render() { - const { wallets: e2, search: o$12 } = te$3.state, { listings: r2 } = this.search ? o$12 : e2, a2 = this.loading && !r2.length, t2 = this.search.length >= 3; - let l2 = Z.manualWalletsTemplate(), i2 = Z.recomendedWalletsTemplate(true); - t2 && (l2 = l2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search)), i2 = i2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search))); - const s2 = !this.loading && !r2.length && !i2.length, $2 = { - "wcm-loading": a2, - "wcm-end-reached": this.endReached || !this.loading, - "wcm-empty": s2 - }; - return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((f2) => x`${f2 ? x`` : null}`)}
${s2 ? x`No results found` : null} ${!s2 && this.loading ? x`` : null}
`; + const { wallets: e2, search: o$12 } = te$1.state, { listings: r2 } = this.search ? o$12 : e2, a2 = this.loading && !r2.length, t2 = this.search.length >= 3; + let l2 = S.manualWalletsTemplate(), i2 = S.recomendedWalletsTemplate(true); + t2 && (l2 = l2.filter(({ values: w2 }) => s.caseSafeIncludes(w2[0], this.search)), i2 = i2.filter(({ values: w2 }) => s.caseSafeIncludes(w2[0], this.search))); + const c2 = !this.loading && !r2.length && !i2.length, u2 = { "wcm-loading": a2, "wcm-end-reached": this.endReached || !this.loading, "wcm-empty": c2 }; + return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((w2) => x`${w2 ? x`` : null}`)}
${c2 ? x`No results found` : null} ${!c2 && this.loading ? x`` : null}
`; } }; - U.styles = [h.globalCss, nr], ie([t$1()], U.prototype, "loading", 2), ie([t$1()], U.prototype, "firstFetch", 2), ie([t$1()], U.prototype, "search", 2), ie([t$1()], U.prototype, "endReached", 2), U = ie([e$2("wcm-wallet-explorer-view")], U); + H.styles = [h.globalCss, nr], se([t$1()], H.prototype, "loading", 2), se([t$1()], H.prototype, "firstFetch", 2), se([t$1()], H.prototype, "search", 2), se([t$1()], H.prototype, "endReached", 2), H = se([e$2("wcm-wallet-explorer-view")], H); const dr = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; - var mr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Ge = (e2, o2, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? hr(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) + var mr = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, Ge = (e2, o2, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? wr(o2, r2) : o2, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o2, r2, t2) : i2(t2)) || t2); return a2 && t2 && mr(o2, r2, t2), t2; }; - let we = class extends s { + let ve = class extends s$1 { constructor() { super(), this.isError = false, this.openWebWallet(); } onFormatAndRedirect(e2) { - var _a; - const { desktop: o2, name: r2 } = a$5.getWalletRouterData(), a2 = o2 == null ? void 0 : o2.universal; - if (a2) { - const t2 = a$5.formatUniversalUrl(a2, e2, r2); - if (r2 === "Puzzle Wallet" && window && ((_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient)) { - const url = new URL(t2); - const params = url.searchParams; - const wcUri = params.get("uri"); - const requestId = params.get("requestId"); - const sessionTopic = params.get("sessionTopic"); - void window.aleo.connectPuzzle({ - wc: { - uri: wcUri, - requestId: requestId ?? void 0, - sessionTopic: sessionTopic ?? void 0 - } - }); - } else { - a$5.openHref(t2, "_blank"); - } + var o2; + const { desktop: r2, name: a2 } = i$5.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.universal; + if (t2) { + const l2 = i$5.formatUniversalUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o2 = window == null ? void 0 : window.aleo) != null && o2.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u2 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u2 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + i$5.openHref(l2, "_blank"); } } openWebWallet() { - const { walletConnectUri: e2 } = p$4.state, o2 = a$5.getWalletRouterData(); - c.setRecentWallet(o2), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = p$3.state, o2 = i$5.getWalletRouterData(); + s.setRecentWallet(o2), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o2, image_id: r2 } = a$5.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = c.getCachedRouterWalletPlatforms(), l$12 = a$5.isMobile(); - return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; + const { name: e2, id: o2, image_id: r2 } = i$5.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = s.getCachedRouterWalletPlatforms(), l$12 = i$5.isMobile(); + return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; } }; - we.styles = [h.globalCss, dr], Ge([t$1()], we.prototype, "isError", 2), we = Ge([e$2("wcm-web-connecting-view")], we); + ve.styles = [h.globalCss, dr], Ge([t$1()], ve.prototype, "isError", 2), ve = Ge([e$2("wcm-web-connecting-view")], ve); const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, get WcmModal() { - return ae; + return ne; }, get WcmQrCode() { - return j; + return D; } }, Symbol.toStringTag, { value: "Module" })); exports2.PAGE_SIZE = PAGE_SIZE; @@ -22030,6 +28955,7 @@ exports2.aleoU32 = aleoU32; exports2.aleoU64 = aleoU64; exports2.aleoViewKeyRegex = aleoViewKeyRegex; + exports2.chainIdToNetwork = chainIdToNetwork; exports2.checkForDesktopConnection = checkForDesktopConnection; exports2.configureConnection = configureConnection; exports2.connect = connect; @@ -22046,6 +28972,7 @@ exports2.hasInjectedConnection = hasInjectedConnection; exports2.importSharedState = importSharedState; exports2.log_sdk = log_sdk; + exports2.networkToChainId = networkToChainId; exports2.projectId = projectId; exports2.requestCreateEvent = requestCreateEvent; exports2.requestSignature = requestSignature; @@ -22053,6 +28980,8 @@ exports2.wc_aleo_chains = wc_aleo_chains; exports2.wc_aleo_methods = wc_aleo_methods; exports2.wc_events = wc_events; + exports2.wc_optional_aleo_chains = wc_optional_aleo_chains; + exports2.wc_required_aleo_chains = wc_required_aleo_chains; exports2.web3modal_puzzle_props = web3modal_puzzle_props; exports2.web3modal_puzzle_props_android = web3modal_puzzle_props_android; exports2.web3modal_puzzle_props_default = web3modal_puzzle_props_default; diff --git a/packages/core/dist/types/src/client.d.ts b/packages/core/dist/types/src/client.d.ts index 0ed98d2b..74cb5058 100644 --- a/packages/core/dist/types/src/client.d.ts +++ b/packages/core/dist/types/src/client.d.ts @@ -1,7 +1,7 @@ /// -import { WalletConnectModalSign } from '@walletconnect/modal-sign-html'; +import { WalletConnectModalSign } from '@puzzlehq/walletconnect-modal-sign-html'; import EventEmitter from 'events'; -export declare const emitter: EventEmitter; +export declare const emitter: EventEmitter<[never]>; export declare let connection: WalletConnectModalSign | undefined; export type WalletConnectModalSignInstance = InstanceType; export declare function configureConnection(options: { diff --git a/packages/core/dist/types/src/data/events.d.ts b/packages/core/dist/types/src/data/events.d.ts index dca910ad..4a571ee4 100644 --- a/packages/core/dist/types/src/data/events.d.ts +++ b/packages/core/dist/types/src/data/events.d.ts @@ -1,4 +1,4 @@ -import { Balance } from '../messages/balance.js'; +import { Balance } from '@puzzlehq/types'; export type AccountSelectedResponse = { address: string; balances: Balance[]; diff --git a/packages/core/dist/types/src/data/walletconnect.d.ts b/packages/core/dist/types/src/data/walletconnect.d.ts index 4a092294..2199ffe2 100644 --- a/packages/core/dist/types/src/data/walletconnect.d.ts +++ b/packages/core/dist/types/src/data/walletconnect.d.ts @@ -1,4 +1,7 @@ +import { Network } from '@puzzlehq/types'; export declare const wc_aleo_methods: string[]; +export declare const wc_required_aleo_chains: string[]; +export declare const wc_optional_aleo_chains: string[]; export declare const wc_aleo_chains: string[]; export declare const wc_events: string[]; export declare const projectId = "f0aaeffe71b636da453fce042d79d723"; @@ -71,3 +74,5 @@ export declare const signClient_puzzleProps: { }; }; }; +export declare const networkToChainId: (network: Network, includePrefix?: boolean) => string; +export declare const chainIdToNetwork: (chainId: 'aleo:0' | 'aleo:1') => Network.AleoTestnet | Network.AleoCanarynet; diff --git a/packages/core/dist/types/src/index.d.ts b/packages/core/dist/types/src/index.d.ts index 008738d0..cc88a3fa 100644 --- a/packages/core/dist/types/src/index.d.ts +++ b/packages/core/dist/types/src/index.d.ts @@ -5,5 +5,7 @@ export * from './data/walletconnect.js'; export * from './utils/logger.js'; export * from './utils/clientInfo.js'; export * from './client.js'; -import { type Account, type Asset, AssetType, type AssetValue, type Event, type EventCreate, EventStatus, EventType, Network, type Record, type RecordWithPlaintext, Visibility, aleoAddressRegex, aleoFieldRegex, aleoPrivateKeyRegex, aleoTransactionIdRegex, aleoU32, aleoU64, aleoViewKeyRegex, zodAddress, zodEventStatus, zodEventType, zodField, zodNetwork, zodPrivateKey, zodTransactionId, zodU32, zodU64, zodViewKey, zodVisibility } from '@puzzlehq/types'; -export { type Account, type Asset, AssetType, type AssetValue, type Event, type EventCreate, EventStatus, EventType, Network, type Record, type RecordWithPlaintext, Visibility, aleoAddressRegex, aleoFieldRegex, aleoPrivateKeyRegex, aleoTransactionIdRegex, aleoU32, aleoU64, aleoViewKeyRegex, zodAddress, zodEventStatus, zodEventType, zodField, zodNetwork, zodPrivateKey, zodTransactionId, zodU32, zodU64, zodViewKey, zodVisibility, }; +import { type SessionTypes } from '@walletconnect/types'; +import { type Account, type Event, type EventCreate, EventStatus, EventType, Network, type Record, type RecordWithPlaintext, Visibility, aleoAddressRegex, aleoFieldRegex, aleoPrivateKeyRegex, aleoTransactionIdRegex, aleoU32, aleoU64, aleoViewKeyRegex, zodAddress, zodEventStatus, zodEventType, zodField, zodNetwork, zodPrivateKey, zodTransactionId, zodU32, zodU64, zodViewKey, zodVisibility } from '@puzzlehq/types'; +export { SessionTypes }; +export { type Account, type Event, type EventCreate, EventStatus, EventType, Network, type Record, type RecordWithPlaintext, Visibility, aleoAddressRegex, aleoFieldRegex, aleoPrivateKeyRegex, aleoTransactionIdRegex, aleoU32, aleoU64, aleoViewKeyRegex, zodAddress, zodEventStatus, zodEventType, zodField, zodNetwork, zodPrivateKey, zodTransactionId, zodU32, zodU64, zodViewKey, zodVisibility, }; diff --git a/packages/core/dist/types/src/messages/account.d.ts b/packages/core/dist/types/src/messages/account.d.ts index 36f9cc2d..e2de7b9c 100644 --- a/packages/core/dist/types/src/messages/account.d.ts +++ b/packages/core/dist/types/src/messages/account.d.ts @@ -3,4 +3,4 @@ export type GetSelectedAccountResponse = { account?: PuzzleAccount; error?: string; }; -export declare const getAccount: () => Promise; +export declare const getAccount: (network?: string) => Promise; diff --git a/packages/core/dist/types/src/messages/balance.d.ts b/packages/core/dist/types/src/messages/balance.d.ts index 74ed07c7..1cb7803c 100644 --- a/packages/core/dist/types/src/messages/balance.d.ts +++ b/packages/core/dist/types/src/messages/balance.d.ts @@ -1,15 +1,12 @@ +import { Balance } from '@puzzlehq/types'; export type GetBalancesRequest = { - assetId?: string; address?: string; }; -export type Balance = { - private: number; - public: number; -}; export type GetBalancesResponse = { balances?: Balance[]; error?: string; }; -export declare const getBalance: ({ address, }: { +export declare const getBalance: ({ address, network, }: { address?: string | undefined; + network?: string | undefined; }) => Promise; diff --git a/packages/core/dist/types/src/messages/connect.d.ts b/packages/core/dist/types/src/messages/connect.d.ts index 11f29e03..b1ea24b4 100644 --- a/packages/core/dist/types/src/messages/connect.d.ts +++ b/packages/core/dist/types/src/messages/connect.d.ts @@ -1,2 +1,2 @@ import { SessionTypes } from '@walletconnect/types'; -export declare const connect: () => Promise; +export declare const connect: (showModal?: boolean) => Promise; diff --git a/packages/core/dist/types/src/messages/createEvent.d.ts b/packages/core/dist/types/src/messages/createEvent.d.ts index 2e8821e7..21c15edc 100644 --- a/packages/core/dist/types/src/messages/createEvent.d.ts +++ b/packages/core/dist/types/src/messages/createEvent.d.ts @@ -20,4 +20,4 @@ export type CreateEventResponse = { eventId?: string; error?: string; }; -export declare const requestCreateEvent: (requestData?: CreateEventRequestData) => Promise; +export declare const requestCreateEvent: (requestData: CreateEventRequestData, network?: string) => Promise; diff --git a/packages/core/dist/types/src/messages/createSharedState.d.ts b/packages/core/dist/types/src/messages/createSharedState.d.ts index dc24cf35..13050df4 100644 --- a/packages/core/dist/types/src/messages/createSharedState.d.ts +++ b/packages/core/dist/types/src/messages/createSharedState.d.ts @@ -5,4 +5,4 @@ export type CreateSharedStateResponse = { }; error?: string; }; -export declare const createSharedState: () => Promise; +export declare const createSharedState: (network?: string) => Promise; diff --git a/packages/core/dist/types/src/messages/decrypt.d.ts b/packages/core/dist/types/src/messages/decrypt.d.ts index 1465b9ff..c9da5d80 100644 --- a/packages/core/dist/types/src/messages/decrypt.d.ts +++ b/packages/core/dist/types/src/messages/decrypt.d.ts @@ -5,4 +5,4 @@ export type DecryptResponse = { plaintexts?: string[]; error?: string; }; -export declare const decrypt: (ciphertexts?: string[]) => Promise; +export declare const decrypt: (ciphertexts?: string[], network?: string) => Promise; diff --git a/packages/core/dist/types/src/messages/event.d.ts b/packages/core/dist/types/src/messages/event.d.ts index e981d17e..59f644f5 100644 --- a/packages/core/dist/types/src/messages/event.d.ts +++ b/packages/core/dist/types/src/messages/event.d.ts @@ -2,9 +2,10 @@ import { Event } from '../index.js'; export type GetEventRequest = { id: string; address?: string; + network?: string; }; export type GetEventResponse = { event?: Event; error?: string; }; -export declare const getEvent: ({ id, address, }: GetEventRequest) => Promise; +export declare const getEvent: ({ id, address, network, }: GetEventRequest) => Promise; diff --git a/packages/core/dist/types/src/messages/events.d.ts b/packages/core/dist/types/src/messages/events.d.ts index b0cd6761..931f8684 100644 --- a/packages/core/dist/types/src/messages/events.d.ts +++ b/packages/core/dist/types/src/messages/events.d.ts @@ -13,4 +13,4 @@ export type GetEventsResponse = { pageCount?: number; error?: string; }; -export declare const getEvents: (filter: EventsFilter) => Promise; +export declare const getEvents: (filter: EventsFilter, network?: string) => Promise; diff --git a/packages/core/dist/types/src/messages/importSharedState.d.ts b/packages/core/dist/types/src/messages/importSharedState.d.ts index bd152d8a..9294eea8 100644 --- a/packages/core/dist/types/src/messages/importSharedState.d.ts +++ b/packages/core/dist/types/src/messages/importSharedState.d.ts @@ -8,4 +8,4 @@ export type ImportSharedStateResponse = { }; error?: string; }; -export declare const importSharedState: (seed: string) => Promise; +export declare const importSharedState: (seed: string, network?: string) => Promise; diff --git a/packages/core/dist/types/src/messages/records.d.ts b/packages/core/dist/types/src/messages/records.d.ts index fe5db9dc..38a460d8 100644 --- a/packages/core/dist/types/src/messages/records.d.ts +++ b/packages/core/dist/types/src/messages/records.d.ts @@ -2,17 +2,18 @@ import { type RecordWithPlaintext } from '@puzzlehq/types'; export type RecordsFilter = { programIds?: string[]; functionId?: string; - type: 'all' | 'spent' | 'unspent'; + type: 'all' | 'spent' | 'unspent' | 'pending'; names?: string[]; }; export type GetRecordsRequest = { address?: string; filter?: RecordsFilter; page?: number; + network?: string; }; export type GetRecordsResponse = { records?: RecordWithPlaintext[]; pageCount?: number; error?: string; }; -export declare const getRecords: ({ address, filter, page, }: GetRecordsRequest) => Promise; +export declare const getRecords: ({ address, filter, page, network, }: GetRecordsRequest) => Promise; diff --git a/packages/core/dist/types/src/messages/requestSignature.d.ts b/packages/core/dist/types/src/messages/requestSignature.d.ts index 2964fb72..89acb250 100644 --- a/packages/core/dist/types/src/messages/requestSignature.d.ts +++ b/packages/core/dist/types/src/messages/requestSignature.d.ts @@ -1,10 +1,12 @@ export type SignatureRequest = { message: string; address?: string; + network?: string; + method?: 'aleo' | 'puzzle'; }; export type SignatureResponse = { signature?: string; messageFields?: string; error?: string; }; -export declare const requestSignature: ({ message, address, }: SignatureRequest) => Promise; +export declare const requestSignature: ({ message, address, network, method }: SignatureRequest) => Promise; diff --git a/packages/core/package.json b/packages/core/package.json index 3e553530..5a89d6b0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@puzzlehq/sdk-core", "displayName": "Puzzle SDK", - "version": "0.3.1", + "version": "0.4.0", "description": "Your portal to privacy", "main": "./dist/puzzle.cjs.js", "module": "./dist/puzzle.es.js", @@ -28,8 +28,8 @@ "url": "git+https://github.com/puzzlehq/puzzle-sdk.git" }, "dependencies": { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", "@walletconnect/types": "^2.11.2", "@walletconnect/utils": "^2.11.2", "debug": "^4.3.4", diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 3bceb80c..73d27cee 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -1,4 +1,4 @@ -import { WalletConnectModalSign } from '@walletconnect/modal-sign-html'; +import { WalletConnectModalSign } from '@puzzlehq/walletconnect-modal-sign-html'; import { projectId as puzzleProjectId, web3modal_puzzle_props, @@ -101,10 +101,10 @@ export async function getWalletConnectModalSignClient(): Promise { if (connection) { resolve(connection); - // @ts-ignore-next-line + // @ts-ignore-next-line } else if (typeof window !== 'undefined' && window?.puzzleSdkConnection) { // @ts-ignore-next-line - resolve(window.puzzleSdkConnection) + resolve(window.puzzleSdkConnection); } else { const interval = setInterval(() => { if (connection) { diff --git a/packages/core/src/data/events.ts b/packages/core/src/data/events.ts index 7e08ba78..038add92 100644 --- a/packages/core/src/data/events.ts +++ b/packages/core/src/data/events.ts @@ -1,4 +1,4 @@ -import { Balance } from '../messages/balance.js'; +import { Balance } from '@puzzlehq/types'; export type AccountSelectedResponse = { address: string; diff --git a/packages/core/src/data/walletconnect.ts b/packages/core/src/data/walletconnect.ts index b1844e40..5ee55855 100644 --- a/packages/core/src/data/walletconnect.ts +++ b/packages/core/src/data/walletconnect.ts @@ -1,3 +1,5 @@ +import { Network } from '@puzzlehq/types'; + // methods called from dApp export const wc_aleo_methods = [ 'decrypt', @@ -12,7 +14,16 @@ export const wc_aleo_methods = [ 'importSharedState', 'requestSignature', ]; -export const wc_aleo_chains = ['aleo:1']; + +export const wc_required_aleo_chains = ['aleo:1']; +export const wc_optional_aleo_chains = [ + 'aleo:0', // for eventual mainnet +]; + +export const wc_aleo_chains = [ + ...wc_required_aleo_chains, + ...wc_optional_aleo_chains, +]; // events originating from wallet export const wc_events = [ @@ -25,7 +36,7 @@ export const wc_events = [ export const projectId = 'f0aaeffe71b636da453fce042d79d723'; function isAndroid() { - if (!navigator) { + if (typeof navigator === 'undefined') { return false; } return /Android/i.test(navigator.userAgent); @@ -33,16 +44,18 @@ function isAndroid() { export const web3modal_puzzle_props_android = { projectId, - chains: ['aleo:3'], + chains: wc_aleo_chains, enableExplorer: true, - explorerRecommendedWalletIds: ['7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a'], + explorerRecommendedWalletIds: [ + '7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a', + ], mobileWallets: [ { id: 'puzzle', name: 'Puzzle Wallet', links: { native: 'puzzleapp://', - universal: '' + universal: '', }, }, ], @@ -55,14 +68,16 @@ export const web3modal_puzzle_props_default = { projectId, chains: wc_aleo_chains, enableExplorer: false, - explorerRecommendedWalletIds: ['7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a'], + explorerRecommendedWalletIds: [ + '7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a', + ], mobileWallets: [ { id: 'puzzle', name: 'Puzzle Wallet', links: { native: 'puzzleapp://', - universal: '' + universal: '', }, }, ], @@ -90,7 +105,9 @@ export const web3modal_puzzle_props_default = { }, }; -export const web3modal_puzzle_props = isAndroid() ? web3modal_puzzle_props_android : web3modal_puzzle_props_default +export const web3modal_puzzle_props = isAndroid() + ? web3modal_puzzle_props_android + : web3modal_puzzle_props_default; export const signClient_puzzleProps = { requiredNamespaces: { @@ -101,3 +118,30 @@ export const signClient_puzzleProps = { }, }, }; + +export const networkToChainId = (network: Network, includePrefix: boolean = true) => { + let chain: string; + switch (network) { + case Network.AleoMainnet: + chain = 'aleo:0'; + break; + case Network.AleoCanarynet: + chain = 'aleo:0'; + break; + case Network.AleoTestnet: + chain = 'aleo:1' + break; + } + return includePrefix ? chain : chain.replace('aleo:', ''); +}; + +export const chainIdToNetwork = ( + chainId: 'aleo:0' | 'aleo:1' +) => { + switch (chainId) { + case 'aleo:0': + return Network.AleoCanarynet; + case 'aleo:1': + return Network.AleoTestnet; + } +}; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index cb944b7b..206496ca 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -6,11 +6,12 @@ export * from './utils/logger.js'; export * from './utils/clientInfo.js'; export * from './client.js'; +import { + type SessionTypes +} from '@walletconnect/types' + import { type Account, - type Asset, - AssetType, - type AssetValue, type Event, type EventCreate, EventStatus, @@ -38,11 +39,13 @@ import { zodViewKey, zodVisibility, } from '@puzzlehq/types'; + +export { + SessionTypes +} + export { type Account, - type Asset, - AssetType, - type AssetValue, type Event, type EventCreate, EventStatus, diff --git a/packages/core/src/messages/account.ts b/packages/core/src/messages/account.ts index 3570638a..737ae246 100644 --- a/packages/core/src/messages/account.ts +++ b/packages/core/src/messages/account.ts @@ -2,13 +2,16 @@ import { PuzzleAccount } from '../data/types.js'; import { getWalletConnectModalSignClient } from '../client.js'; import { SessionTypes } from '@walletconnect/types'; import { hasInjectedConnection } from '../utils/clientInfo.js'; +import { wc_aleo_chains } from '../data/walletconnect.js'; export type GetSelectedAccountResponse = { account?: PuzzleAccount; error?: string; }; -export const getAccount = async (): Promise => { +export const getAccount = async ( + network?: string, +): Promise => { const connection = await getWalletConnectModalSignClient(); const session: SessionTypes.Struct | undefined = await connection.getSession(); @@ -17,9 +20,13 @@ export const getAccount = async (): Promise => { return { error: 'no session or connection' }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } + const query = { topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'getSelectedAccount', diff --git a/packages/core/src/messages/balance.ts b/packages/core/src/messages/balance.ts index 333171b1..7e3d05e2 100644 --- a/packages/core/src/messages/balance.ts +++ b/packages/core/src/messages/balance.ts @@ -1,26 +1,24 @@ import { SessionTypes } from '@walletconnect/types'; import { getWalletConnectModalSignClient } from '../client.js'; import { hasInjectedConnection } from '../utils/clientInfo.js'; +import { wc_aleo_chains } from '../data/walletconnect.js'; +import { Balance } from '@puzzlehq/types'; export type GetBalancesRequest = { - assetId?: string; address?: string; }; -export type Balance = { - private: number; - public: number; -}; - export type GetBalancesResponse = { - balances?: Balance[]; // [ALEO, PIECES]; + balances?: Balance[]; error?: string; }; export const getBalance = async ({ address, + network, }: { address?: string; + network?: string; }): Promise => { const connection = await getWalletConnectModalSignClient(); const session: SessionTypes.Struct | undefined = @@ -30,14 +28,17 @@ export const getBalance = async ({ return { error: 'no session or connection' }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } + const query = { topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'getBalance', params: { - assetId: undefined, address, } as GetBalancesRequest, }, diff --git a/packages/core/src/messages/connect.ts b/packages/core/src/messages/connect.ts index 35684e1b..c8a24ddb 100644 --- a/packages/core/src/messages/connect.ts +++ b/packages/core/src/messages/connect.ts @@ -1,16 +1,17 @@ import { - wc_aleo_chains, wc_aleo_methods, wc_events, + wc_optional_aleo_chains, + wc_required_aleo_chains, } from '../data/walletconnect.js'; import { getWalletConnectModalSignClient, emitter } from '../client.js'; import { SessionTypes } from '@walletconnect/types'; import { checkForDesktopConnection } from '../utils/clientInfo.js'; -export const connect = async () => { +export const connect = async (showModal = true) => { const connection = await getWalletConnectModalSignClient(); if (!connection) { - throw new Error('call setConnection() first!'); + throw new Error('call configureConnection() first!'); } const existingSession: SessionTypes.Struct | undefined = @@ -26,11 +27,18 @@ export const connect = async () => { requiredNamespaces: { aleo: { methods: wc_aleo_methods, - chains: wc_aleo_chains, + chains: wc_required_aleo_chains, events: wc_events, }, }, - }); + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains, + methods: wc_aleo_methods, + events: wc_events, + } + }, + }, showModal); emitter.emit('session_change'); if (newSession) { diff --git a/packages/core/src/messages/createEvent.ts b/packages/core/src/messages/createEvent.ts index a5eba3ab..e4180dd3 100644 --- a/packages/core/src/messages/createEvent.ts +++ b/packages/core/src/messages/createEvent.ts @@ -1,4 +1,4 @@ -import { EventType } from '../index.js'; +import { EventType, wc_aleo_chains } from '../index.js'; import { getWalletConnectModalSignClient } from '../client.js'; import { SessionTypes } from '@walletconnect/types'; import { type RecordWithPlaintext } from '@puzzlehq/types'; @@ -31,7 +31,8 @@ export type CreateEventResponse = { }; export const requestCreateEvent = async ( - requestData?: CreateEventRequestData, + requestData: CreateEventRequestData, + network?: string, ): Promise => { const connection = await getWalletConnectModalSignClient(); const session: SessionTypes.Struct | undefined = @@ -48,10 +49,14 @@ export const requestCreateEvent = async ( return input.plaintext; }); + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } + try { const response: CreateEventResponse = await connection.request({ topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'requestCreateEvent', diff --git a/packages/core/src/messages/createSharedState.ts b/packages/core/src/messages/createSharedState.ts index 65c5134b..b1533ef2 100644 --- a/packages/core/src/messages/createSharedState.ts +++ b/packages/core/src/messages/createSharedState.ts @@ -1,6 +1,7 @@ import { SessionTypes } from '@walletconnect/types'; import { getWalletConnectModalSignClient } from '../client.js'; import { hasInjectedConnection } from '../utils/clientInfo.js'; +import { wc_aleo_chains } from '../data/walletconnect.js'; export type CreateSharedStateResponse = { data?: { @@ -10,47 +11,48 @@ export type CreateSharedStateResponse = { error?: string; }; -export const createSharedState = - async (): Promise => { - const connection = await getWalletConnectModalSignClient(); - const session: SessionTypes.Struct | undefined = - await connection?.getSession(); +export const createSharedState = async ( + network?: string, +): Promise => { + const connection = await getWalletConnectModalSignClient(); + const session: SessionTypes.Struct | undefined = + await connection?.getSession(); - if (!session || !connection) { - return { error: 'no session or connection' }; - } - - const query = { - topic: session.topic, - chainId: 'aleo:1', - request: { - jsonrpc: '2.0', - method: 'createSharedState', - params: {}, - }, - }; + if (!session || !connection) { + return { error: 'no session or connection' }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } - if (hasInjectedConnection()) { - try { - const response: CreateSharedStateResponse = - await window.aleo.puzzleWalletClient.createSharedState.mutate( - query, - ); - return response; - } catch (e) { - console.error('createSharedState error', e); - const error = (e as Error).message; - return { error }; - } - } + const query = { + topic: session.topic, + chainId: network ?? 'aleo:1', + request: { + jsonrpc: '2.0', + method: 'createSharedState', + params: {}, + }, + }; + if (hasInjectedConnection()) { try { const response: CreateSharedStateResponse = - await connection.request(query); + await window.aleo.puzzleWalletClient.createSharedState.mutate(query); return response; } catch (e) { console.error('createSharedState error', e); const error = (e as Error).message; return { error }; } - }; + } + + try { + const response: CreateSharedStateResponse = await connection.request(query); + return response; + } catch (e) { + console.error('createSharedState error', e); + const error = (e as Error).message; + return { error }; + } +}; diff --git a/packages/core/src/messages/decrypt.ts b/packages/core/src/messages/decrypt.ts index c20a3a6b..d5b0f0e4 100644 --- a/packages/core/src/messages/decrypt.ts +++ b/packages/core/src/messages/decrypt.ts @@ -1,6 +1,7 @@ import { SessionTypes } from '@walletconnect/types'; import { getWalletConnectModalSignClient } from '../client.js'; import { hasInjectedConnection } from '../utils/clientInfo.js'; +import { wc_aleo_chains } from '../data/walletconnect.js'; export type DecryptRequest = { ciphertexts: string[]; @@ -13,6 +14,7 @@ export type DecryptResponse = { export const decrypt = async ( ciphertexts?: string[], + network?: string, ): Promise => { const connection = await getWalletConnectModalSignClient(); const session: SessionTypes.Struct | undefined = @@ -21,10 +23,13 @@ export const decrypt = async ( if (!session || !connection) { return { error: 'no session or connection' }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } const query = { topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'decrypt', diff --git a/packages/core/src/messages/event.ts b/packages/core/src/messages/event.ts index d37fa584..710ab7fd 100644 --- a/packages/core/src/messages/event.ts +++ b/packages/core/src/messages/event.ts @@ -1,4 +1,4 @@ -import { Event } from '../index.js'; +import { Event, wc_aleo_chains } from '../index.js'; import { getWalletConnectModalSignClient } from '../client.js'; import { SessionTypes } from '@walletconnect/types'; import { hasInjectedConnection } from '../utils/clientInfo.js'; @@ -6,6 +6,7 @@ import { hasInjectedConnection } from '../utils/clientInfo.js'; export type GetEventRequest = { id: string; address?: string; + network?: string; }; export type GetEventResponse = { @@ -16,6 +17,7 @@ export type GetEventResponse = { export const getEvent = async ({ id, address, + network, }: GetEventRequest): Promise => { const connection = await getWalletConnectModalSignClient(); @@ -26,9 +28,13 @@ export const getEvent = async ({ return { event: undefined, error: 'no session or connection' }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } + const query = { topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'getEvent', diff --git a/packages/core/src/messages/events.ts b/packages/core/src/messages/events.ts index 08b8e586..ece86b64 100644 --- a/packages/core/src/messages/events.ts +++ b/packages/core/src/messages/events.ts @@ -1,4 +1,4 @@ -import { Event, EventType } from '../index.js'; +import { Event, EventType, wc_aleo_chains } from '../index.js'; import { getWalletConnectModalSignClient } from '../client.js'; import { SessionTypes } from '@walletconnect/types'; import { hasInjectedConnection } from '../utils/clientInfo.js'; @@ -22,6 +22,7 @@ export type GetEventsResponse = { export const getEvents = async ( filter: EventsFilter, + network?: string, ): Promise => { const connection = await getWalletConnectModalSignClient(); @@ -35,10 +36,16 @@ export const getEvents = async ( if (filter?.programId === '') { filter.programId = undefined; } + if (!session || !connection) { + return { error: 'no session or connection' }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } const query = { topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'getEvents', diff --git a/packages/core/src/messages/importSharedState.ts b/packages/core/src/messages/importSharedState.ts index 2137e0f4..86cae066 100644 --- a/packages/core/src/messages/importSharedState.ts +++ b/packages/core/src/messages/importSharedState.ts @@ -1,6 +1,7 @@ import { SessionTypes } from '@walletconnect/types'; import { getWalletConnectModalSignClient } from '../client.js'; import { hasInjectedConnection } from '../utils/clientInfo.js'; +import { wc_aleo_chains } from '../data/walletconnect.js'; export type ImportSharedStateRequest = { seed: string; @@ -16,6 +17,7 @@ export type ImportSharedStateResponse = { export const importSharedState = async ( seed: string, + network?: string, ): Promise => { const connection = await getWalletConnectModalSignClient(); @@ -25,10 +27,13 @@ export const importSharedState = async ( if (!session || !connection) { return { error: 'no session or connection' }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } const query = { topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'importSharedState', diff --git a/packages/core/src/messages/records.ts b/packages/core/src/messages/records.ts index 6620609b..55fe0a35 100644 --- a/packages/core/src/messages/records.ts +++ b/packages/core/src/messages/records.ts @@ -2,11 +2,12 @@ import { type RecordWithPlaintext } from '@puzzlehq/types'; import { getWalletConnectModalSignClient } from '../client.js'; import { SessionTypes } from '@walletconnect/types'; import { hasInjectedConnection } from '../utils/clientInfo.js'; +import { wc_aleo_chains } from '../data/walletconnect.js'; export type RecordsFilter = { programIds?: string[]; functionId?: string; - type: 'all' | 'spent' | 'unspent'; + type: 'all' | 'spent' | 'unspent' | 'pending'; names?: string[]; }; @@ -14,6 +15,7 @@ export type GetRecordsRequest = { address?: string; filter?: RecordsFilter; page?: number; + network?: string; }; export type GetRecordsResponse = { @@ -26,6 +28,7 @@ export const getRecords = async ({ address, filter, page = 0, + network, }: GetRecordsRequest): Promise => { const connection = await getWalletConnectModalSignClient(); @@ -35,10 +38,13 @@ export const getRecords = async ({ if (!session || !connection) { return { error: 'no session or connection' }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } const query = { topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'getRecords', diff --git a/packages/core/src/messages/requestSignature.ts b/packages/core/src/messages/requestSignature.ts index 6ccaed98..ce3bc1d2 100644 --- a/packages/core/src/messages/requestSignature.ts +++ b/packages/core/src/messages/requestSignature.ts @@ -1,10 +1,13 @@ import { SessionTypes } from '@walletconnect/types'; import { getWalletConnectModalSignClient } from '../client.js'; import { aleoAddressRegex } from '@puzzlehq/types'; +import { wc_aleo_chains } from '../data/walletconnect.js'; export type SignatureRequest = { message: string; address?: string; + network?: string; + method?: 'aleo' | 'puzzle' }; export type SignatureResponse = { @@ -16,6 +19,8 @@ export type SignatureResponse = { export const requestSignature = async ({ message, address, + network, + method }: SignatureRequest): Promise => { const connection = await getWalletConnectModalSignClient(); @@ -26,16 +31,21 @@ export const requestSignature = async ({ return { error: 'no session or connection' }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: 'network not in wc_aleo_chains' }; + } + try { const response: SignatureResponse = await connection.request({ topic: session.topic, - chainId: 'aleo:1', + chainId: network ?? 'aleo:1', request: { jsonrpc: '2.0', method: 'requestSignature', params: { message, address: aleoAddressRegex.test(address ?? '') ? address : undefined, + method } as SignatureRequest, }, }); diff --git a/packages/core/src/utils/clientInfo.ts b/packages/core/src/utils/clientInfo.ts index 5229cd6b..1ee9bec6 100644 --- a/packages/core/src/utils/clientInfo.ts +++ b/packages/core/src/utils/clientInfo.ts @@ -1,6 +1,7 @@ export const checkForDesktopConnection = async (sessionTopic: string) => { - const extensionDownloaded = !!window?.aleo?.puzzleWalletClient; - if (!extensionDownloaded) { + const injectedConnection = !!window?.aleo?.puzzleWalletClient; + if (!injectedConnection) { + console.log('!!window?.aleo?.puzzleWalletClient', injectedConnection); localStorage.setItem('puzzle-hasInjectedConnection', 'false'); return false; } @@ -24,8 +25,8 @@ export const checkForDesktopConnection = async (sessionTopic: string) => { }; export const hasInjectedConnection = () => { - const extensionDownloaded = !!window?.aleo?.puzzleWalletClient; - if (!extensionDownloaded) { + const injectedConnection = !!window?.aleo?.puzzleWalletClient; + if (!injectedConnection) { return false; } diff --git a/packages/core/vite.config.js b/packages/core/vite.config.js index 9093db76..89ab4ae1 100644 --- a/packages/core/vite.config.js +++ b/packages/core/vite.config.js @@ -26,7 +26,7 @@ export default defineConfig({ rollupOptions: { external: packages, globals: { - '@walletconnect/modal-sign-html': 'modalSignHtml', + '@puzzlehq/walletconnect-modal-sign-html': 'modalSignHtml', events: 'EventEmitter', '@walletconnect/utils': 'utils', debug: 'debug', diff --git a/packages/react/dist/index-DbX1yfTB.cjs b/packages/react/dist/index-BHOVivr9.cjs similarity index 53% rename from packages/react/dist/index-DbX1yfTB.cjs rename to packages/react/dist/index-BHOVivr9.cjs index 4ecdc8f7..42da6cad 100644 --- a/packages/react/dist/index-DbX1yfTB.cjs +++ b/packages/react/dist/index-BHOVivr9.cjs @@ -3,30 +3,30 @@ const React = require("react"); const zustand = require("zustand"); const reactQuery = require("@tanstack/react-query"); const EventEmitter$2 = require("events"); -const utils$2 = require("@walletconnect/utils"); +const utils$1 = require("@walletconnect/utils"); const useDebounce = require("use-debounce"); -const modalSignHtml = require("@walletconnect/modal-sign-html"); +const walletconnectModalSignHtml = require("@puzzlehq/walletconnect-modal-sign-html"); const debug$1 = require("debug"); -function _interopNamespaceDefault(e) { - const n3 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } }); - if (e) { - for (const k2 in e) { +function _interopNamespaceDefault(e2) { + const n4 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } }); + if (e2) { + for (const k2 in e2) { if (k2 !== "default") { - const d3 = Object.getOwnPropertyDescriptor(e, k2); - Object.defineProperty(n3, k2, d3.get ? d3 : { + const d5 = Object.getOwnPropertyDescriptor(e2, k2); + Object.defineProperty(n4, k2, d5.get ? d5 : { enumerable: true, - get: () => e[k2] + get: () => e2[k2] }); } } } - n3.default = e; - return Object.freeze(n3); + n4.default = e2; + return Object.freeze(n4); } const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React); const t = Symbol(); -const s = Object.getPrototypeOf, c$2 = /* @__PURE__ */ new WeakMap(), l$2 = (e) => e && (c$2.has(e) ? c$2.get(e) : s(e) === Object.prototype || s(e) === Array.prototype), y$4 = (e) => l$2(e) && e[t] || null, h$4 = (e, t2 = true) => { - c$2.set(e, t2); +const s$1 = Object.getPrototypeOf, c$4 = /* @__PURE__ */ new WeakMap(), l$2 = (e2) => e2 && (c$4.has(e2) ? c$4.get(e2) : s$1(e2) === Object.prototype || s$1(e2) === Array.prototype), y$5 = (e2) => l$2(e2) && e2[t] || null, h$3 = (e2, t2 = true) => { + c$4.set(e2, t2); }; var define_import_meta_env_default$1 = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false }; const isObject = (x2) => typeof x2 === "object" && x2 !== null; @@ -47,7 +47,7 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = return cache[1]; } const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); - h$4(snap, true); + h$3(snap, true); snapCache.set(target, [version2, snap]); Reflect.ownKeys(target).forEach((key) => { if (Object.getOwnPropertyDescriptor(snap, key)) { @@ -62,7 +62,7 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = configurable: true }; if (refSet.has(value)) { - h$4(value, false); + h$3(value, false); } else if (value instanceof Promise) { delete desc.value; desc.get = () => handlePromise(value); @@ -126,11 +126,11 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = } }; const removePropListener = (prop) => { - var _a; + var _a2; const entry = propProxyStates.get(prop); if (entry) { propProxyStates.delete(prop); - (_a = entry[1]) == null ? void 0 : _a.call(entry); + (_a2 = entry[1]) == null ? void 0 : _a2.call(entry); } }; const addListener2 = (listener) => { @@ -176,7 +176,7 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = } removePropListener(prop); if (isObject(value)) { - value = y$4(value) || value; + value = y$5(value) || value; } let nextValue = value; if (value instanceof Promise) { @@ -184,10 +184,10 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = value.status = "fulfilled"; value.value = v3; notifyUpdate(["resolve", [prop], v3]); - }).catch((e) => { + }).catch((e2) => { value.status = "rejected"; - value.reason = e; - notifyUpdate(["reject", [prop], e]); + value.reason = e2; + notifyUpdate(["reject", [prop], e2]); }); } else { if (!proxyStateMap.has(value) && canProxy(value)) { @@ -256,10 +256,6 @@ function subscribe(proxyObject, callback, notifyInSync) { let isListenerActive = false; const listener = (op) => { ops.push(op); - if (notifyInSync) { - callback(ops.splice(0)); - return; - } if (!promise) { promise = Promise.resolve().then(() => { promise = void 0; @@ -284,388 +280,240 @@ function snapshot(proxyObject, handlePromise) { const [target, ensureVersion, createSnapshot] = proxyState; return createSnapshot(target, ensureVersion(), handlePromise); } -const o$1 = proxy({ - history: ["ConnectWallet"], - view: "ConnectWallet", - data: void 0 -}), T$1 = { - state: o$1, - subscribe(e) { - return subscribe(o$1, () => e(o$1)); - }, - push(e, t2) { - e !== o$1.view && (o$1.view = e, t2 && (o$1.data = t2), o$1.history.push(e)); - }, - reset(e) { - o$1.view = e, o$1.history = [e]; - }, - replace(e) { - o$1.history.length > 1 && (o$1.history[o$1.history.length - 1] = e, o$1.view = e); - }, - goBack() { - if (o$1.history.length > 1) { - o$1.history.pop(); - const [e] = o$1.history.slice(-1); - o$1.view = e; - } - }, - setData(e) { - o$1.data = e; - } -}, a$3 = { - WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", - WCM_VERSION: "WCM_VERSION", - RECOMMENDED_WALLET_AMOUNT: 9, - isMobile() { - return typeof window < "u" ? Boolean( - window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test( - navigator.userAgent - ) - ) : false; - }, - isAndroid() { - return a$3.isMobile() && navigator.userAgent.toLowerCase().includes("android"); - }, - isIos() { - const e = navigator.userAgent.toLowerCase(); - return a$3.isMobile() && (e.includes("iphone") || e.includes("ipad")); - }, - isHttpUrl(e) { - return e.startsWith("http://") || e.startsWith("https://"); - }, - isArray(e) { - return Array.isArray(e) && e.length > 0; - }, - formatNativeUrl(e, t2, s2) { - if (a$3.isHttpUrl(e)) - return this.formatUniversalUrl(e, t2, s2); - let n3 = e; - n3.includes("://") || (n3 = e.replaceAll("/", "").replaceAll(":", ""), n3 = `${n3}://`), n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - formatUniversalUrl(e, t2, s2) { - if (!a$3.isHttpUrl(e)) - return this.formatNativeUrl(e, t2, s2); - let n3 = e; - n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - async wait(e) { - return new Promise((t2) => { - setTimeout(t2, e); - }); - }, - openHref(e, t2) { - window.open(e, t2, "noreferrer noopener"); - }, - setWalletConnectDeepLink(e, t2) { - try { - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: e, name: t2 }) - ); - } catch { - console.info("Unable to set WalletConnect deep link"); - } - }, - setWalletConnectAndroidDeepLink(e) { - try { - const [t2] = e.split("?"); - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: t2, name: "Android" }) - ); - } catch { - console.info("Unable to set WalletConnect android deep link"); - } - }, - removeWalletConnectDeepLink() { - try { - localStorage.removeItem(a$3.WALLETCONNECT_DEEPLINK_CHOICE); - } catch { - console.info("Unable to remove WalletConnect deep link"); - } - }, - setModalVersionInStorage() { - try { - typeof localStorage < "u" && localStorage.setItem(a$3.WCM_VERSION, "2.6.2"); - } catch { - console.info("Unable to set Web3Modal version in storage"); - } - }, - getWalletRouterData() { - var e; - const t2 = (e = T$1.state.data) == null ? void 0 : e.Wallet; - if (!t2) - throw new Error('Missing "Wallet" view data'); - return t2; - } -}, _$3 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), r$1 = proxy({ - enabled: _$3, - userSessionId: "", - events: [], - connectedWalletId: void 0 -}), R$4 = { - state: r$1, - subscribe(e) { - return subscribe(r$1.events, () => e(snapshot(r$1.events[r$1.events.length - 1]))); - }, - initialize() { - r$1.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (r$1.userSessionId = crypto.randomUUID()); - }, - setConnectedWalletId(e) { - r$1.connectedWalletId = e; - }, - click(e) { - if (r$1.enabled) { - const t2 = { - type: "CLICK", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - }, - track(e) { - if (r$1.enabled) { - const t2 = { - type: "TRACK", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - }, - view(e) { - if (r$1.enabled) { - const t2 = { - type: "VIEW", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - } -}, c$1 = proxy({ - chains: void 0, - walletConnectUri: void 0, - isAuth: false, - isCustomDesktop: false, - isCustomMobile: false, - isDataLoaded: false, - isUiLoaded: false -}), p$3 = { - state: c$1, - subscribe(e) { - return subscribe(c$1, () => e(c$1)); - }, - setChains(e) { - c$1.chains = e; - }, - setWalletConnectUri(e) { - c$1.walletConnectUri = e; - }, - setIsCustomDesktop(e) { - c$1.isCustomDesktop = e; - }, - setIsCustomMobile(e) { - c$1.isCustomMobile = e; - }, - setIsDataLoaded(e) { - c$1.isDataLoaded = e; - }, - setIsUiLoaded(e) { - c$1.isUiLoaded = e; - }, - setIsAuth(e) { - c$1.isAuth = e; - } -}, W$2 = proxy({ - projectId: "", - mobileWallets: void 0, - desktopWallets: void 0, - walletImages: void 0, - chains: void 0, - enableAuthMode: false, - enableExplorer: true, - explorerExcludedWalletIds: void 0, - explorerRecommendedWalletIds: void 0, - termsOfServiceUrl: void 0, - privacyPolicyUrl: void 0 -}), y$3 = { - state: W$2, - subscribe(e) { - return subscribe(W$2, () => e(W$2)); - }, - setConfig(e) { - var t2, s2; - R$4.initialize(), p$3.setChains(e.chains), p$3.setIsAuth(Boolean(e.enableAuthMode)), p$3.setIsCustomMobile( - Boolean((t2 = e.mobileWallets) == null ? void 0 : t2.length) - ), p$3.setIsCustomDesktop( - Boolean((s2 = e.desktopWallets) == null ? void 0 : s2.length) - ), a$3.setModalVersionInStorage(), Object.assign(W$2, e); +const o$1 = proxy({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), T$2 = { state: o$1, subscribe(e2) { + return subscribe(o$1, () => e2(o$1)); +}, push(e2, t2) { + e2 !== o$1.view && (o$1.view = e2, t2 && (o$1.data = t2), o$1.history.push(e2)); +}, reset(e2) { + o$1.view = e2, o$1.history = [e2]; +}, replace(e2) { + o$1.history.length > 1 && (o$1.history[o$1.history.length - 1] = e2, o$1.view = e2); +}, goBack() { + if (o$1.history.length > 1) { + o$1.history.pop(); + const [e2] = o$1.history.slice(-1); + o$1.view = e2; + } +}, setData(e2) { + o$1.data = e2; +} }, i$1 = { WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", WCM_VERSION: "WCM_VERSION", RECOMMENDED_WALLET_AMOUNT: 9, isMobile() { + return typeof window < "u" ? Boolean(window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : false; +}, isAndroid() { + return i$1.isMobile() && navigator.userAgent.toLowerCase().includes("android"); +}, isIos() { + const e2 = navigator.userAgent.toLowerCase(); + return i$1.isMobile() && (e2.includes("iphone") || e2.includes("ipad")); +}, isHttpUrl(e2) { + return e2.startsWith("http://") || e2.startsWith("https://"); +}, isArray(e2) { + return Array.isArray(e2) && e2.length > 0; +}, formatNativeUrl(e2, t2, s2) { + if (i$1.isHttpUrl(e2)) + return this.formatUniversalUrl(e2, t2, s2); + let n4 = e2; + n4.includes("://") || (n4 = e2.replaceAll("/", "").replaceAll(":", ""), n4 = `${n4}://`), n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s2); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; +}, formatUniversalUrl(e2, t2, s2) { + if (!i$1.isHttpUrl(e2)) + return this.formatNativeUrl(e2, t2, s2); + let n4 = e2; + n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s2); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; +}, async wait(e2) { + return new Promise((t2) => { + setTimeout(t2, e2); + }); +}, openHref(e2, t2) { + window.open(e2, t2, "noreferrer noopener"); +}, setWalletConnectDeepLink(e2, t2) { + try { + localStorage.setItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: e2, name: t2 })); + } catch { + console.info("Unable to set WalletConnect deep link"); } -}; -var V$2 = Object.defineProperty, D$4 = Object.getOwnPropertySymbols, H$2 = Object.prototype.hasOwnProperty, B$2 = Object.prototype.propertyIsEnumerable, M$1 = (e, t2, s2) => t2 in e ? V$2(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, K$1 = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - H$2.call(t2, s2) && M$1(e, s2, t2[s2]); - if (D$4) - for (var s2 of D$4(t2)) - B$2.call(t2, s2) && M$1(e, s2, t2[s2]); - return e; -}; -const L$2 = "https://explorer-api.walletconnect.com", E$2 = "wcm", O$3 = "js-2.6.2"; -async function w$5(e, t2) { - const s2 = K$1({ sdkType: E$2, sdkVersion: O$3 }, t2), n3 = new URL(e, L$2); - return n3.searchParams.append("projectId", y$3.state.projectId), Object.entries(s2).forEach(([i2, l2]) => { - l2 && n3.searchParams.append(i2, String(l2)); - }), (await fetch(n3)).json(); -} -const m$2 = { - async getDesktopListings(e) { - return w$5("/w3m/v1/getDesktopListings", e); - }, - async getMobileListings(e) { - return w$5("/w3m/v1/getMobileListings", e); - }, - async getInjectedListings(e) { - return w$5("/w3m/v1/getInjectedListings", e); - }, - async getAllListings(e) { - return w$5("/w3m/v1/getAllListings", e); - }, - getWalletImageUrl(e) { - return `${L$2}/w3m/v1/getWalletImage/${e}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; - }, - getAssetImageUrl(e) { - return `${L$2}/w3m/v1/getAssetImage/${e}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; +}, setWalletConnectAndroidDeepLink(e2) { + try { + const [t2] = e2.split("?"); + localStorage.setItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: t2, name: "Android" })); + } catch { + console.info("Unable to set WalletConnect android deep link"); } -}; -var z$3 = Object.defineProperty, j$3 = Object.getOwnPropertySymbols, J$2 = Object.prototype.hasOwnProperty, q$2 = Object.prototype.propertyIsEnumerable, k$2 = (e, t2, s2) => t2 in e ? z$3(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, F$3 = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - J$2.call(t2, s2) && k$2(e, s2, t2[s2]); - if (j$3) - for (var s2 of j$3(t2)) - q$2.call(t2, s2) && k$2(e, s2, t2[s2]); - return e; -}; -const N$3 = a$3.isMobile(), d$2 = proxy({ - wallets: { listings: [], total: 0, page: 1 }, - search: { listings: [], total: 0, page: 1 }, - recomendedWallets: [] -}), te$2 = { - state: d$2, - async getRecomendedWallets() { - const { explorerRecommendedWalletIds: e, explorerExcludedWalletIds: t2 } = y$3.state; - if (e === "NONE" || t2 === "ALL" && !e) - return d$2.recomendedWallets; - if (a$3.isArray(e)) { - const s2 = { recommendedIds: e.join(",") }, { listings: n3 } = await m$2.getAllListings(s2), i2 = Object.values(n3); - i2.sort && i2.sort((l2, v3) => { - const b3 = e.indexOf(l2.id), f2 = e.indexOf(v3.id); - return b3 - f2; - }), d$2.recomendedWallets = i2; - } else { - const { chains: s2, isAuth: n3 } = p$3.state, i2 = s2 == null ? void 0 : s2.join(","), l2 = a$3.isArray(t2), v3 = { - page: 1, - sdks: n3 ? "auth_v1" : void 0, - entries: a$3.RECOMMENDED_WALLET_AMOUNT, - chains: i2, - version: 2, - excludedIds: l2 ? t2.join(",") : void 0 - }, { listings: b3 } = N$3 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); - d$2.recomendedWallets = Object.values(b3); - } - return d$2.recomendedWallets; - }, - async getWallets(e) { - const t2 = F$3({}, e), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n3 } = y$3.state, { recomendedWallets: i2 } = d$2; - if (n3 === "ALL") - return d$2.wallets; - i2.length ? t2.excludedIds = i2.map((x2) => x2.id).join(",") : a$3.isArray(s2) && (t2.excludedIds = s2.join(",")), a$3.isArray(n3) && (t2.excludedIds = [t2.excludedIds, n3].filter(Boolean).join(",")), p$3.state.isAuth && (t2.sdks = "auth_v1"); - const { page: l2, search: v3 } = e, { listings: b3, total: f2 } = N$3 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; - return d$2[U2] = { listings: [...d$2[U2].listings, ...A2], total: f2, page: l2 ?? 1 }, { listings: A2, total: f2 }; - }, - getWalletImageUrl(e) { - return m$2.getWalletImageUrl(e); - }, - getAssetImageUrl(e) { - return m$2.getAssetImageUrl(e); - }, - resetSearch() { - d$2.search = { listings: [], total: 0, page: 1 }; +}, removeWalletConnectDeepLink() { + try { + localStorage.removeItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE); + } catch { + console.info("Unable to remove WalletConnect deep link"); } -}, I$1 = proxy({ open: false }), se = { - state: I$1, - subscribe(e) { - return subscribe(I$1, () => e(I$1)); - }, - async open(e) { - return new Promise((t2) => { - const { isUiLoaded: s2, isDataLoaded: n3 } = p$3.state; - if (a$3.removeWalletConnectDeepLink(), p$3.setWalletConnectUri(e == null ? void 0 : e.uri), p$3.setChains(e == null ? void 0 : e.chains), T$1.reset("ConnectWallet"), s2 && n3) - I$1.open = true, t2(); - else { - const i2 = setInterval(() => { - const l2 = p$3.state; - l2.isUiLoaded && l2.isDataLoaded && (clearInterval(i2), I$1.open = true, t2()); - }, 200); - } - }); - }, - close() { - I$1.open = false; +}, setModalVersionInStorage() { + try { + typeof localStorage < "u" && localStorage.setItem(i$1.WCM_VERSION, "0.0.6"); + } catch { + console.info("Unable to set Web3Modal version in storage"); } -}; -var G$2 = Object.defineProperty, $$2 = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$2 = Object.prototype.propertyIsEnumerable, S$2 = (e, t2, s2) => t2 in e ? G$2(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, Y = (e, t2) => { +}, getWalletRouterData() { + var e2; + const t2 = (e2 = T$2.state.data) == null ? void 0 : e2.Wallet; + if (!t2) + throw new Error('Missing "Wallet" view data'); + return t2; +} }, _$2 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), a$2 = proxy({ enabled: _$2, userSessionId: "", events: [], connectedWalletId: void 0 }), R$1 = { state: a$2, subscribe(e2) { + return subscribe(a$2.events, () => e2(snapshot(a$2.events[a$2.events.length - 1]))); +}, initialize() { + a$2.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (a$2.userSessionId = crypto.randomUUID()); +}, setConnectedWalletId(e2) { + a$2.connectedWalletId = e2; +}, click(e2) { + if (a$2.enabled) { + const t2 = { type: "CLICK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +}, track(e2) { + if (a$2.enabled) { + const t2 = { type: "TRACK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +}, view(e2) { + if (a$2.enabled) { + const t2 = { type: "VIEW", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +} }, c$3 = proxy({ chains: void 0, walletConnectUri: void 0, isAuth: false, isCustomDesktop: false, isCustomMobile: false, isDataLoaded: false, isUiLoaded: false }), p$2 = { state: c$3, subscribe(e2) { + return subscribe(c$3, () => e2(c$3)); +}, setChains(e2) { + c$3.chains = e2; +}, setWalletConnectUri(e2) { + c$3.walletConnectUri = e2; +}, setIsCustomDesktop(e2) { + c$3.isCustomDesktop = e2; +}, setIsCustomMobile(e2) { + c$3.isCustomMobile = e2; +}, setIsDataLoaded(e2) { + c$3.isDataLoaded = e2; +}, setIsUiLoaded(e2) { + c$3.isUiLoaded = e2; +}, setIsAuth(e2) { + c$3.isAuth = e2; +} }, W = proxy({ projectId: "", mobileWallets: void 0, desktopWallets: void 0, walletImages: void 0, chains: void 0, enableAuthMode: false, enableExplorer: true, explorerExcludedWalletIds: void 0, explorerRecommendedWalletIds: void 0, termsOfServiceUrl: void 0, privacyPolicyUrl: void 0 }), y$4 = { state: W, subscribe(e2) { + return subscribe(W, () => e2(W)); +}, setConfig(e2) { + var t2, s2; + R$1.initialize(), p$2.setChains(e2.chains), p$2.setIsAuth(Boolean(e2.enableAuthMode)), p$2.setIsCustomMobile(Boolean((t2 = e2.mobileWallets) == null ? void 0 : t2.length)), p$2.setIsCustomDesktop(Boolean((s2 = e2.desktopWallets) == null ? void 0 : s2.length)), i$1.setModalVersionInStorage(), Object.assign(W, e2); +} }; +var V$3 = Object.defineProperty, D$2 = Object.getOwnPropertySymbols, H = Object.prototype.hasOwnProperty, B$1 = Object.prototype.propertyIsEnumerable, M$1 = (e2, t2, s2) => t2 in e2 ? V$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, K$4 = (e2, t2) => { for (var s2 in t2 || (t2 = {})) - Q$3.call(t2, s2) && S$2(e, s2, t2[s2]); - if ($$2) - for (var s2 of $$2(t2)) - X$2.call(t2, s2) && S$2(e, s2, t2[s2]); - return e; + H.call(t2, s2) && M$1(e2, s2, t2[s2]); + if (D$2) + for (var s2 of D$2(t2)) + B$1.call(t2, s2) && M$1(e2, s2, t2[s2]); + return e2; +}; +const L$5 = "https://explorer-api.walletconnect.com", E$3 = "wcm", O$3 = "js-0.0.6"; +async function w$4(e2, t2) { + const s2 = K$4({ sdkType: E$3, sdkVersion: O$3 }, t2), n4 = new URL(e2, L$5); + return n4.searchParams.append("projectId", y$4.state.projectId), Object.entries(s2).forEach(([r3, l2]) => { + l2 && n4.searchParams.append(r3, String(l2)); + }), (await fetch(n4)).json(); +} +const m$2 = { async getDesktopListings(e2) { + return w$4("/w3m/v1/getDesktopListings", e2); +}, async getMobileListings(e2) { + return w$4("/w3m/v1/getMobileListings", e2); +}, async getInjectedListings(e2) { + return w$4("/w3m/v1/getInjectedListings", e2); +}, async getAllListings(e2) { + return w$4("/w3m/v1/getAllListings", e2); +}, getWalletImageUrl(e2) { + return `${L$5}/w3m/v1/getWalletImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; +}, getAssetImageUrl(e2) { + return `${L$5}/w3m/v1/getAssetImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; +} }; +var z$4 = Object.defineProperty, j$4 = Object.getOwnPropertySymbols, J$1 = Object.prototype.hasOwnProperty, q$3 = Object.prototype.propertyIsEnumerable, k$4 = (e2, t2, s2) => t2 in e2 ? z$4(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, F$2 = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + J$1.call(t2, s2) && k$4(e2, s2, t2[s2]); + if (j$4) + for (var s2 of j$4(t2)) + q$3.call(t2, s2) && k$4(e2, s2, t2[s2]); + return e2; +}; +const N$2 = i$1.isMobile(), d$4 = proxy({ wallets: { listings: [], total: 0, page: 1 }, search: { listings: [], total: 0, page: 1 }, recomendedWallets: [] }), te$1 = { state: d$4, async getRecomendedWallets() { + const { explorerRecommendedWalletIds: e2, explorerExcludedWalletIds: t2 } = y$4.state; + if (e2 === "NONE" || t2 === "ALL" && !e2) + return d$4.recomendedWallets; + if (i$1.isArray(e2)) { + const s2 = { recommendedIds: e2.join(",") }, { listings: n4 } = await m$2.getAllListings(s2), r3 = Object.values(n4); + n4 && r3.sort && r3.sort((l2, v3) => { + const b3 = e2.indexOf(l2.id), f3 = e2.indexOf(v3.id); + return b3 - f3; + }), d$4.recomendedWallets = r3; + } else { + const { chains: s2, isAuth: n4 } = p$2.state, r3 = s2 == null ? void 0 : s2.join(","), l2 = i$1.isArray(t2), v3 = { page: 1, sdks: n4 ? "auth_v1" : void 0, entries: i$1.RECOMMENDED_WALLET_AMOUNT, chains: r3, version: 2, excludedIds: l2 ? t2.join(",") : void 0 }, { listings: b3 } = N$2 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); + d$4.recomendedWallets = Object.values(b3); + } + return d$4.recomendedWallets; +}, async getWallets(e2) { + const t2 = F$2({}, e2), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n4 } = y$4.state, { recomendedWallets: r3 } = d$4; + if (n4 === "ALL") + return d$4.wallets; + r3.length ? t2.excludedIds = r3.map((x2) => x2.id).join(",") : i$1.isArray(s2) && (t2.excludedIds = s2.join(",")), i$1.isArray(n4) && (t2.excludedIds = [t2.excludedIds, n4].filter(Boolean).join(",")), p$2.state.isAuth && (t2.sdks = "auth_v1"); + const { page: l2, search: v3 } = e2, { listings: b3, total: f3 } = N$2 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; + return d$4[U2] = { listings: [...d$4[U2].listings, ...A2], total: f3, page: l2 ?? 1 }, { listings: A2, total: f3 }; +}, getWalletImageUrl(e2) { + return m$2.getWalletImageUrl(e2); +}, getAssetImageUrl(e2) { + return m$2.getAssetImageUrl(e2); +}, resetSearch() { + d$4.search = { listings: [], total: 0, page: 1 }; +} }, I$3 = proxy({ open: false }), se$3 = { state: I$3, subscribe(e2) { + return subscribe(I$3, () => e2(I$3)); +}, async open(e2) { + return new Promise((t2) => { + const { isUiLoaded: s2, isDataLoaded: n4 } = p$2.state; + if (i$1.removeWalletConnectDeepLink(), p$2.setWalletConnectUri(e2 == null ? void 0 : e2.uri), p$2.setChains(e2 == null ? void 0 : e2.chains), T$2.reset("ConnectWallet"), s2 && n4) + I$3.open = true, t2(); + else { + const r3 = setInterval(() => { + const l2 = p$2.state; + l2.isUiLoaded && l2.isDataLoaded && (clearInterval(r3), I$3.open = true, t2()); + }, 200); + } + }); +}, close() { + I$3.open = false; +} }; +var G$1 = Object.defineProperty, $ = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$1 = Object.prototype.propertyIsEnumerable, S$4 = (e2, t2, s2) => t2 in e2 ? G$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, Y = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + Q$3.call(t2, s2) && S$4(e2, s2, t2[s2]); + if ($) + for (var s2 of $(t2)) + X$1.call(t2, s2) && S$4(e2, s2, t2[s2]); + return e2; }; -function Z$2() { +function Z$1() { return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; } -const C = proxy({ themeMode: Z$2() ? "dark" : "light" }), ne = { - state: C, - subscribe(e) { - return subscribe(C, () => e(C)); - }, - setThemeConfig(e) { - const { themeMode: t2, themeVariables: s2 } = e; - t2 && (C.themeMode = t2), s2 && (C.themeVariables = Y({}, s2)); - } -}, g$5 = proxy({ open: false, message: "", variant: "success" }), oe$1 = { - state: g$5, - subscribe(e) { - return subscribe(g$5, () => e(g$5)); - }, - openToast(e, t2) { - g$5.open = true, g$5.message = e, g$5.variant = t2; - }, - closeToast() { - g$5.open = false; - } -}; -let d$1 = class d { - constructor(e) { - this.openModal = se.open, this.closeModal = se.close, this.subscribeModal = se.subscribe, this.setTheme = ne.setThemeConfig, ne.setThemeConfig(e), y$3.setConfig(e), this.initUi(); +const C$3 = proxy({ themeMode: Z$1() ? "dark" : "light" }), ne$3 = { state: C$3, subscribe(e2) { + return subscribe(C$3, () => e2(C$3)); +}, setThemeConfig(e2) { + const { themeMode: t2, themeVariables: s2 } = e2; + t2 && (C$3.themeMode = t2), s2 && (C$3.themeVariables = Y({}, s2)); +} }, g$3 = proxy({ open: false, message: "", variant: "success" }), oe$2 = { state: g$3, subscribe(e2) { + return subscribe(g$3, () => e2(g$3)); +}, openToast(e2, t2) { + g$3.open = true, g$3.message = e2, g$3.variant = t2; +}, closeToast() { + g$3.open = false; +} }; +let d$3 = class d { + constructor(e2) { + this.openModal = se$3.open, this.closeModal = se$3.close, this.subscribeModal = se$3.subscribe, this.setTheme = ne$3.setThemeConfig, ne$3.setThemeConfig(e2), y$4.setConfig(e2), this.initUi(); } async initUi() { if (typeof window < "u") { - await Promise.resolve().then(() => require("./index-B2etef5O-ugHUcay-.cjs")); - const e = document.createElement("wcm-modal"); - document.body.insertAdjacentElement("beforeend", e), p$3.setIsUiLoaded(true); + await Promise.resolve().then(() => require("./index-f3LbIFb5-BkegnaCo.cjs")); + const e2 = document.createElement("wcm-modal"); + document.body.insertAdjacentElement("beforeend", e2), p$2.setIsUiLoaded(true); } } }; @@ -673,40 +521,40 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win function getDefaultExportFromCjs(x2) { return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; } -function getAugmentedNamespace(n3) { - if (n3.__esModule) - return n3; - var f2 = n3.default; - if (typeof f2 == "function") { +function getAugmentedNamespace(n4) { + if (n4.__esModule) + return n4; + var f3 = n4.default; + if (typeof f3 == "function") { var a3 = function a4() { if (this instanceof a4) { - return Reflect.construct(f2, arguments, this.constructor); + return Reflect.construct(f3, arguments, this.constructor); } - return f2.apply(this, arguments); + return f3.apply(this, arguments); }; - a3.prototype = f2.prototype; + a3.prototype = f3.prototype; } else a3 = {}; Object.defineProperty(a3, "__esModule", { value: true }); - Object.keys(n3).forEach(function(k2) { - var d3 = Object.getOwnPropertyDescriptor(n3, k2); - Object.defineProperty(a3, k2, d3.get ? d3 : { + Object.keys(n4).forEach(function(k2) { + var d5 = Object.getOwnPropertyDescriptor(n4, k2); + Object.defineProperty(a3, k2, d5.get ? d5 : { enumerable: true, get: function() { - return n3[k2]; + return n4[k2]; } }); }); return a3; } var events = { exports: {} }; -var R$3 = typeof Reflect === "object" ? Reflect : null; -var ReflectApply = R$3 && typeof R$3.apply === "function" ? R$3.apply : function ReflectApply2(target, receiver, args) { +var R = typeof Reflect === "object" ? Reflect : null; +var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args) { return Function.prototype.apply.call(target, receiver, args); }; var ReflectOwnKeys; -if (R$3 && typeof R$3.ownKeys === "function") { - ReflectOwnKeys = R$3.ownKeys; +if (R && typeof R.ownKeys === "function") { + ReflectOwnKeys = R.ownKeys; } else if (Object.getOwnPropertySymbols) { ReflectOwnKeys = function ReflectOwnKeys2(target) { return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); @@ -757,11 +605,11 @@ EventEmitter.init = function() { } this._maxListeners = this._maxListeners || void 0; }; -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n3) { - if (typeof n3 !== "number" || n3 < 0 || NumberIsNaN(n3)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n3 + "."); +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n4) { + if (typeof n4 !== "number" || n4 < 0 || NumberIsNaN(n4)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n4 + "."); } - this._maxListeners = n3; + this._maxListeners = n4; return this; }; function _getMaxListeners(that) { @@ -807,7 +655,7 @@ EventEmitter.prototype.emit = function emit(type2) { return true; }; function _addListener(target, type2, listener, prepend) { - var m2; + var m3; var events2; var existing; checkListener(listener); @@ -837,8 +685,8 @@ function _addListener(target, type2, listener, prepend) { } else { existing.push(listener); } - m2 = _getMaxListeners(target); - if (m2 > 0 && existing.length > m2 && !existing.warned) { + m3 = _getMaxListeners(target); + if (m3 > 0 && existing.length > m3 && !existing.warned) { existing.warned = true; var w3 = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type2) + " listeners added. Use emitter.setMaxListeners() to increase limit"); w3.name = "MaxListenersExceededWarning"; @@ -1005,9 +853,9 @@ function listenerCount(type2) { EventEmitter.prototype.eventNames = function eventNames() { return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; }; -function arrayClone(arr, n3) { - var copy2 = new Array(n3); - for (var i2 = 0; i2 < n3; ++i2) +function arrayClone(arr, n4) { + var copy2 = new Array(n4); + for (var i2 = 0; i2 < n4; ++i2) copy2[i2] = arr[i2]; return copy2; } @@ -1336,7 +1184,7 @@ function createStorage(options = {}) { }); } return Promise.all([...batches.values()].map((batch) => cb(batch))).then( - (r2) => r2.flat() + (r3) => r3.flat() ); }; const storage = { @@ -1364,7 +1212,7 @@ function createStorage(options = {}) { })), commonOptions ).then( - (r2) => r2.map((item) => ({ + (r3) => r3.map((item) => ({ key: joinKeys(batch.base, item.key), value: destr(item.value) })) @@ -1411,7 +1259,7 @@ function createStorage(options = {}) { async setItems(items, commonOptions) { await runBatch(items, commonOptions, async (batch) => { if (batch.driver.setItems) { - await asyncCall( + return asyncCall( batch.driver.setItems, batch.items.map((item) => ({ key: item.relativeKey, @@ -1517,11 +1365,11 @@ function createStorage(options = {}) { mount.relativeBase, opts ); - const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p3) => key.startsWith(p3))); + const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p2) => key.startsWith(p2))); allKeys.push(...keys2); maskedMounts = [ mount.mountpoint, - ...maskedMounts.filter((p3) => !p3.startsWith(mount.mountpoint)) + ...maskedMounts.filter((p2) => !p2.startsWith(mount.mountpoint)) ]; } return base3 ? allKeys.filter((key) => key.startsWith(base3) && !key.endsWith("$")) : allKeys.filter((key) => !key.endsWith("$")); @@ -1530,14 +1378,14 @@ function createStorage(options = {}) { async clear(base3, opts = {}) { base3 = normalizeBaseKey(base3); await Promise.all( - getMounts(base3, false).map(async (m2) => { - if (m2.driver.clear) { - return asyncCall(m2.driver.clear, m2.relativeBase, opts); + getMounts(base3, false).map(async (m3) => { + if (m3.driver.clear) { + return asyncCall(m3.driver.clear, m3.relativeBase, opts); } - if (m2.driver.removeItem) { - const keys2 = await m2.driver.getKeys(m2.relativeBase || "", opts); + if (m3.driver.removeItem) { + const keys2 = await m3.driver.getKeys(m3.relativeBase || "", opts); return Promise.all( - keys2.map((key) => m2.driver.removeItem(key, opts)) + keys2.map((key) => m3.driver.removeItem(key, opts)) ); } }) @@ -1599,18 +1447,18 @@ function createStorage(options = {}) { }, getMount(key = "") { key = normalizeKey(key) + ":"; - const m2 = getMount(key); + const m3 = getMount(key); return { - driver: m2.driver, - base: m2.base + driver: m3.driver, + base: m3.base }; }, getMounts(base3 = "", opts = {}) { base3 = normalizeKey(base3); const mounts = getMounts(base3, opts.parents); - return mounts.map((m2) => ({ - driver: m2.driver, - base: m2.mountpoint + return mounts.map((m3) => ({ + driver: m3.driver, + base: m3.mountpoint })); } }; @@ -1647,7 +1495,7 @@ function defaultGetStore() { function get(key, customStore = defaultGetStore()) { return customStore("readonly", (store) => promisifyRequest(store.get(key))); } -function set(key, value, customStore = defaultGetStore()) { +function set$1(key, value, customStore = defaultGetStore()) { return customStore("readwrite", (store) => { store.put(value, key); return promisifyRequest(store.transaction); @@ -1700,7 +1548,7 @@ function safeJsonParse(value) { } try { return JSONParse(value); - } catch (_a) { + } catch (_a2) { return value; } } @@ -1708,27 +1556,27 @@ function safeJsonStringify(value) { return typeof value === "string" ? value : JSONStringify(value) || ""; } const x$1 = "idb-keyval"; -var z$2 = (i2 = {}) => { - const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e = (s2) => t2 + s2; - let n3; - return i2.dbName && i2.storeName && (n3 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { - return !(typeof await get(e(s2), n3) > "u"); +var z$3 = (i2 = {}) => { + const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e2 = (s2) => t2 + s2; + let n4; + return i2.dbName && i2.storeName && (n4 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { + return !(typeof await get(e2(s2), n4) > "u"); }, async getItem(s2) { - return await get(e(s2), n3) ?? null; + return await get(e2(s2), n4) ?? null; }, setItem(s2, a3) { - return set(e(s2), a3, n3); + return set$1(e2(s2), a3, n4); }, removeItem(s2) { - return del(e(s2), n3); + return del(e2(s2), n4); }, getKeys() { - return keys(n3); + return keys(n4); }, clear() { - return clear(n3); + return clear(n4); } }; }; -const D$3 = "WALLET_CONNECT_V2_INDEXED_DB", E$1 = "keyvaluestorage"; -let _$2 = class _ { +const D$1 = "WALLET_CONNECT_V2_INDEXED_DB", E$2 = "keyvaluestorage"; +let _$1 = class _ { constructor() { - this.indexedDb = createStorage({ driver: z$2({ dbName: D$3, storeName: E$1 }) }); + this.indexedDb = createStorage({ driver: z$3({ dbName: D$1, storeName: E$2 }) }); } async getKeys() { return this.indexedDb.getKeys(); @@ -1737,103 +1585,103 @@ let _$2 = class _ { return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((t2) => [t2.key, t2.value]); } async getItem(t2) { - const e = await this.indexedDb.getItem(t2); - if (e !== null) - return e; + const e2 = await this.indexedDb.getItem(t2); + if (e2 !== null) + return e2; } - async setItem(t2, e) { - await this.indexedDb.setItem(t2, safeJsonStringify(e)); + async setItem(t2, e2) { + await this.indexedDb.setItem(t2, safeJsonStringify(e2)); } async removeItem(t2) { await this.indexedDb.removeItem(t2); } }; -var l$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c = { exports: {} }; +var l$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c$2 = { exports: {} }; (function() { let i2; function t2() { } - i2 = t2, i2.prototype.getItem = function(e) { - return this.hasOwnProperty(e) ? String(this[e]) : null; - }, i2.prototype.setItem = function(e, n3) { - this[e] = String(n3); - }, i2.prototype.removeItem = function(e) { - delete this[e]; + i2 = t2, i2.prototype.getItem = function(e2) { + return this.hasOwnProperty(e2) ? String(this[e2]) : null; + }, i2.prototype.setItem = function(e2, n4) { + this[e2] = String(n4); + }, i2.prototype.removeItem = function(e2) { + delete this[e2]; }, i2.prototype.clear = function() { - const e = this; - Object.keys(e).forEach(function(n3) { - e[n3] = void 0, delete e[n3]; + const e2 = this; + Object.keys(e2).forEach(function(n4) { + e2[n4] = void 0, delete e2[n4]; }); - }, i2.prototype.key = function(e) { - return e = e || 0, Object.keys(this)[e]; + }, i2.prototype.key = function(e2) { + return e2 = e2 || 0, Object.keys(this)[e2]; }, i2.prototype.__defineGetter__("length", function() { return Object.keys(this).length; - }), typeof l$1 < "u" && l$1.localStorage ? c.exports = l$1.localStorage : typeof window < "u" && window.localStorage ? c.exports = window.localStorage : c.exports = new t2(); + }), typeof l$1 < "u" && l$1.localStorage ? c$2.exports = l$1.localStorage : typeof window < "u" && window.localStorage ? c$2.exports = window.localStorage : c$2.exports = new t2(); })(); -function k$1(i2) { +function k$3(i2) { var t2; return [i2[0], safeJsonParse((t2 = i2[1]) != null ? t2 : "")]; } -class K { +let K$3 = class K { constructor() { - this.localStorage = c.exports; + this.localStorage = c$2.exports; } async getKeys() { return Object.keys(this.localStorage); } async getEntries() { - return Object.entries(this.localStorage).map(k$1); + return Object.entries(this.localStorage).map(k$3); } async getItem(t2) { - const e = this.localStorage.getItem(t2); - if (e !== null) - return safeJsonParse(e); + const e2 = this.localStorage.getItem(t2); + if (e2 !== null) + return safeJsonParse(e2); } - async setItem(t2, e) { - this.localStorage.setItem(t2, safeJsonStringify(e)); + async setItem(t2, e2) { + this.localStorage.setItem(t2, safeJsonStringify(e2)); } async removeItem(t2) { this.localStorage.removeItem(t2); } -} -const N$2 = "wc_storage_version", y$2 = 1, O$2 = async (i2, t2, e) => { - const n3 = N$2, s2 = await t2.getItem(n3); - if (s2 && s2 >= y$2) { - e(t2); +}; +const N$1 = "wc_storage_version", y$3 = 1, O$2 = async (i2, t2, e2) => { + const n4 = N$1, s2 = await t2.getItem(n4); + if (s2 && s2 >= y$3) { + e2(t2); return; } const a3 = await i2.getKeys(); if (!a3.length) { - e(t2); + e2(t2); return; } - const m2 = []; + const m3 = []; for (; a3.length; ) { - const r2 = a3.shift(); - if (!r2) + const r3 = a3.shift(); + if (!r3) continue; - const o2 = r2.toLowerCase(); + const o2 = r3.toLowerCase(); if (o2.includes("wc@") || o2.includes("walletconnect") || o2.includes("wc_") || o2.includes("wallet_connect")) { - const f2 = await i2.getItem(r2); - await t2.setItem(r2, f2), m2.push(r2); + const f3 = await i2.getItem(r3); + await t2.setItem(r3, f3), m3.push(r3); } } - await t2.setItem(n3, y$2), e(t2), j$2(i2, m2); -}, j$2 = async (i2, t2) => { - t2.length && t2.forEach(async (e) => { - await i2.removeItem(e); + await t2.setItem(n4, y$3), e2(t2), j$3(i2, m3); +}, j$3 = async (i2, t2) => { + t2.length && t2.forEach(async (e2) => { + await i2.removeItem(e2); }); }; -let h$3 = class h { +let h$2 = class h { constructor() { - this.initialized = false, this.setInitialized = (e) => { - this.storage = e, this.initialized = true; + this.initialized = false, this.setInitialized = (e2) => { + this.storage = e2, this.initialized = true; }; - const t2 = new K(); + const t2 = new K$3(); this.storage = t2; try { - const e = new _$2(); - O$2(t2, e, this.setInitialized); + const e2 = new _$1(); + O$2(t2, e2, this.setInitialized); } catch { this.initialized = true; } @@ -1847,21 +1695,21 @@ let h$3 = class h { async getItem(t2) { return await this.initialize(), this.storage.getItem(t2); } - async setItem(t2, e) { - return await this.initialize(), this.storage.setItem(t2, e); + async setItem(t2, e2) { + return await this.initialize(), this.storage.setItem(t2, e2); } async removeItem(t2) { return await this.initialize(), this.storage.removeItem(t2); } async initialize() { this.initialized || await new Promise((t2) => { - const e = setInterval(() => { - this.initialized && (clearInterval(e), t2()); + const e2 = setInterval(() => { + this.initialized && (clearInterval(e2), t2()); }, 20); }); } }; -var cjs$5 = {}; +var cjs$4 = {}; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. @@ -1876,56 +1724,56 @@ 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. ***************************************************************************** */ -var extendStatics = function(d3, b3) { - extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { - d4.__proto__ = b4; - } || function(d4, b4) { - for (var p3 in b4) - if (b4.hasOwnProperty(p3)) - d4[p3] = b4[p3]; +var extendStatics = function(d5, b3) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d6, b4) { + d6.__proto__ = b4; + } || function(d6, b4) { + for (var p2 in b4) + if (b4.hasOwnProperty(p2)) + d6[p2] = b4[p2]; }; - return extendStatics(d3, b3); + return extendStatics(d5, b3); }; -function __extends$1(d3, b3) { - extendStatics(d3, b3); +function __extends$1(d5, b3) { + extendStatics(d5, b3); function __() { - this.constructor = d3; + this.constructor = d5; } - d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); + d5.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); } var __assign$2 = function() { __assign$2 = Object.assign || function __assign2(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { + for (var s2, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2)) + t2[p2] = s2[p2]; } return t2; }; return __assign$2.apply(this, arguments); }; -function __rest(s2, e) { +function __rest(s2, e2) { var t2 = {}; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3) && e.indexOf(p3) < 0) - t2[p3] = s2[p3]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0) + t2[p2] = s2[p2]; if (s2 != null && typeof Object.getOwnPropertySymbols === "function") - for (var i2 = 0, p3 = Object.getOwnPropertySymbols(s2); i2 < p3.length; i2++) { - if (e.indexOf(p3[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p3[i2])) - t2[p3[i2]] = s2[p3[i2]]; + for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++) { + if (e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i2])) + t2[p2[i2]] = s2[p2[i2]]; } return t2; } function __decorate(decorators, target, key, desc) { - var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3; + var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d5; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r2 = Reflect.decorate(decorators, target, key, desc); + r3 = Reflect.decorate(decorators, target, key, desc); else for (var i2 = decorators.length - 1; i2 >= 0; i2--) - if (d3 = decorators[i2]) - r2 = (c2 < 3 ? d3(r2) : c2 > 3 ? d3(target, key, r2) : d3(target, key)) || r2; - return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2; + if (d5 = decorators[i2]) + r3 = (c2 < 3 ? d5(r3) : c2 > 3 ? d5(target, key, r3) : d5(target, key)) || r3; + return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3; } function __param(paramIndex, decorator) { return function(target, key) { @@ -1946,15 +1794,15 @@ function __awaiter(thisArg, _arguments, P2, generator) { function fulfilled(value) { try { step(generator.next(value)); - } catch (e) { - reject(e); + } catch (e2) { + reject(e2); } } function rejected(value) { try { step(generator["throw"](value)); - } catch (e) { - reject(e); + } catch (e2) { + reject(e2); } } function step(result) { @@ -1968,21 +1816,21 @@ function __generator(thisArg, body) { if (t2[0] & 1) throw t2[1]; return t2[1]; - }, trys: [], ops: [] }, f2, y3, t2, g3; + }, trys: [], ops: [] }, f3, y3, t2, g3; return g3 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() { return this; }), g3; - function verb(n3) { + function verb(n4) { return function(v3) { - return step([n3, v3]); + return step([n4, v3]); }; } function step(op) { - if (f2) + if (f3) throw new TypeError("Generator is already executing."); while (_3) try { - if (f2 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) + if (f3 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) return t2; if (y3 = 0, t2) op = [op[0] & 2, t2.value]; @@ -2028,31 +1876,31 @@ function __generator(thisArg, body) { continue; } op = body.call(thisArg, _3); - } catch (e) { - op = [6, e]; + } catch (e2) { + op = [6, e2]; y3 = 0; } finally { - f2 = t2 = 0; + f3 = t2 = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } -function __createBinding(o2, m2, k2, k22) { +function __createBinding(o2, m3, k2, k22) { if (k22 === void 0) k22 = k2; - o2[k22] = m2[k2]; + o2[k22] = m3[k2]; } -function __exportStar(m2, exports2) { - for (var p3 in m2) - if (p3 !== "default" && !exports2.hasOwnProperty(p3)) - exports2[p3] = m2[p3]; +function __exportStar(m3, exports2) { + for (var p2 in m3) + if (p2 !== "default" && !exports2.hasOwnProperty(p2)) + exports2[p2] = m3[p2]; } function __values(o2) { - var s2 = typeof Symbol === "function" && Symbol.iterator, m2 = s2 && o2[s2], i2 = 0; - if (m2) - return m2.call(o2); + var s2 = typeof Symbol === "function" && Symbol.iterator, m3 = s2 && o2[s2], i2 = 0; + if (m3) + return m3.call(o2); if (o2 && typeof o2.length === "number") return { next: function() { @@ -2063,39 +1911,39 @@ function __values(o2) { }; throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined."); } -function __read$4(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +function __read$4(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; } function __spread() { - for (var ar2 = [], i2 = 0; i2 < arguments.length; i2++) - ar2 = ar2.concat(__read$4(arguments[i2])); - return ar2; + for (var ar3 = [], i2 = 0; i2 < arguments.length; i2++) + ar3 = ar3.concat(__read$4(arguments[i2])); + return ar3; } function __spreadArrays() { for (var s2 = 0, i2 = 0, il = arguments.length; i2 < il; i2++) s2 += arguments[i2].length; - for (var r2 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) + for (var r3 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) for (var a3 = arguments[i2], j2 = 0, jl = a3.length; j2 < jl; j2++, k2++) - r2[k2] = a3[j2]; - return r2; + r3[k2] = a3[j2]; + return r3; } function __await(v3) { return this instanceof __await ? (this.v = v3, this) : new __await(v3); @@ -2107,23 +1955,23 @@ function __asyncGenerator(thisArg, _arguments, generator) { return i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { return this; }, i2; - function verb(n3) { - if (g3[n3]) - i2[n3] = function(v3) { + function verb(n4) { + if (g3[n4]) + i2[n4] = function(v3) { return new Promise(function(a3, b3) { - q2.push([n3, v3, a3, b3]) > 1 || resume(n3, v3); + q2.push([n4, v3, a3, b3]) > 1 || resume(n4, v3); }); }; } - function resume(n3, v3) { + function resume(n4, v3) { try { - step(g3[n3](v3)); - } catch (e) { - settle(q2[0][3], e); + step(g3[n4](v3)); + } catch (e2) { + settle(q2[0][3], e2); } } - function step(r2) { - r2.value instanceof __await ? Promise.resolve(r2.value.v).then(fulfill, reject) : settle(q2[0][2], r2); + function step(r3) { + r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q2[0][2], r3); } function fulfill(value) { resume("next", value); @@ -2131,41 +1979,41 @@ function __asyncGenerator(thisArg, _arguments, generator) { function reject(value) { resume("throw", value); } - function settle(f2, v3) { - if (f2(v3), q2.shift(), q2.length) + function settle(f3, v3) { + if (f3(v3), q2.shift(), q2.length) resume(q2[0][0], q2[0][1]); } } function __asyncDelegator(o2) { - var i2, p3; - return i2 = {}, verb("next"), verb("throw", function(e) { - throw e; + var i2, p2; + return i2 = {}, verb("next"), verb("throw", function(e2) { + throw e2; }), verb("return"), i2[Symbol.iterator] = function() { return this; }, i2; - function verb(n3, f2) { - i2[n3] = o2[n3] ? function(v3) { - return (p3 = !p3) ? { value: __await(o2[n3](v3)), done: n3 === "return" } : f2 ? f2(v3) : v3; - } : f2; + function verb(n4, f3) { + i2[n4] = o2[n4] ? function(v3) { + return (p2 = !p2) ? { value: __await(o2[n4](v3)), done: n4 === "return" } : f3 ? f3(v3) : v3; + } : f3; } } function __asyncValues(o2) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m2 = o2[Symbol.asyncIterator], i2; - return m2 ? m2.call(o2) : (o2 = typeof __values === "function" ? __values(o2) : o2[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { + var m3 = o2[Symbol.asyncIterator], i2; + return m3 ? m3.call(o2) : (o2 = typeof __values === "function" ? __values(o2) : o2[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { return this; }, i2); - function verb(n3) { - i2[n3] = o2[n3] && function(v3) { + function verb(n4) { + i2[n4] = o2[n4] && function(v3) { return new Promise(function(resolve, reject) { - v3 = o2[n3](v3), settle(resolve, reject, v3.done, v3.value); + v3 = o2[n4](v3), settle(resolve, reject, v3.done, v3.value); }); }; } - function settle(resolve, reject, d3, v3) { + function settle(resolve, reject, d5, v3) { Promise.resolve(v3).then(function(v4) { - resolve({ value: v4, done: d3 }); + resolve({ value: v4, done: d5 }); }, reject); } } @@ -2235,8 +2083,8 @@ const tslib_es6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro }, Symbol.toStringTag, { value: "Module" })); const require$$0$2 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6); var heartbeat$2 = {}; -var cjs$4 = {}; -var utils$1 = {}; +var cjs$3 = {}; +var utils = {}; var delay = {}; var hasRequiredDelay; function requireDelay() { @@ -2256,7 +2104,7 @@ function requireDelay() { return delay; } var convert = {}; -var constants$2 = {}; +var constants$1 = {}; var misc = {}; var hasRequiredMisc; function requireMisc() { @@ -2306,18 +2154,18 @@ function requireTime() { })(time); return time; } -var hasRequiredConstants$2; -function requireConstants$2() { - if (hasRequiredConstants$2) - return constants$2; - hasRequiredConstants$2 = 1; +var hasRequiredConstants$1; +function requireConstants$1() { + if (hasRequiredConstants$1) + return constants$1; + hasRequiredConstants$1 = 1; (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireMisc(), exports2); tslib_1.__exportStar(requireTime(), exports2); - })(constants$2); - return constants$2; + })(constants$1); + return constants$1; } var hasRequiredConvert; function requireConvert() { @@ -2326,7 +2174,7 @@ function requireConvert() { hasRequiredConvert = 1; Object.defineProperty(convert, "__esModule", { value: true }); convert.fromMiliseconds = convert.toMiliseconds = void 0; - const constants_1 = requireConstants$2(); + const constants_1 = requireConstants$1(); function toMiliseconds(seconds) { return seconds * constants_1.ONE_THOUSAND; } @@ -2337,18 +2185,18 @@ function requireConvert() { convert.fromMiliseconds = fromMiliseconds; return convert; } -var hasRequiredUtils$1; -function requireUtils$1() { - if (hasRequiredUtils$1) - return utils$1; - hasRequiredUtils$1 = 1; +var hasRequiredUtils; +function requireUtils() { + if (hasRequiredUtils) + return utils; + hasRequiredUtils = 1; (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireDelay(), exports2); tslib_1.__exportStar(requireConvert(), exports2); - })(utils$1); - return utils$1; + })(utils); + return utils; } var watch$1 = {}; var hasRequiredWatch$1; @@ -2422,18 +2270,18 @@ function requireTypes$1() { (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireUtils$1(), exports2); + tslib_1.__exportStar(requireUtils(), exports2); tslib_1.__exportStar(requireWatch$1(), exports2); tslib_1.__exportStar(requireTypes$1(), exports2); - tslib_1.__exportStar(requireConstants$2(), exports2); -})(cjs$4); + tslib_1.__exportStar(requireConstants$1(), exports2); +})(cjs$3); var types$1 = {}; var heartbeat$1 = {}; -let IEvents$1 = class IEvents { -}; +class IEvents { +} const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, - IEvents: IEvents$1 + IEvents }, Symbol.toStringTag, { value: "Module" })); const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(esm); var hasRequiredHeartbeat$2; @@ -2464,7 +2312,7 @@ function requireTypes() { })(types$1); return types$1; } -var constants$1 = {}; +var constants = {}; var heartbeat = {}; var hasRequiredHeartbeat$1; function requireHeartbeat$1() { @@ -2473,24 +2321,24 @@ function requireHeartbeat$1() { hasRequiredHeartbeat$1 = 1; Object.defineProperty(heartbeat, "__esModule", { value: true }); heartbeat.HEARTBEAT_EVENTS = heartbeat.HEARTBEAT_INTERVAL = void 0; - const time_1 = cjs$4; + const time_1 = cjs$3; heartbeat.HEARTBEAT_INTERVAL = time_1.FIVE_SECONDS; heartbeat.HEARTBEAT_EVENTS = { pulse: "heartbeat_pulse" }; return heartbeat; } -var hasRequiredConstants$1; -function requireConstants$1() { - if (hasRequiredConstants$1) - return constants$1; - hasRequiredConstants$1 = 1; +var hasRequiredConstants; +function requireConstants() { + if (hasRequiredConstants) + return constants; + hasRequiredConstants = 1; (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireHeartbeat$1(), exports2); - })(constants$1); - return constants$1; + })(constants); + return constants; } var hasRequiredHeartbeat; function requireHeartbeat() { @@ -2501,9 +2349,9 @@ function requireHeartbeat() { heartbeat$2.HeartBeat = void 0; const tslib_1 = require$$0$2; const events_1 = eventsExports; - const time_1 = cjs$4; + const time_1 = cjs$3; const types_1 = requireTypes(); - const constants_1 = requireConstants$1(); + const constants_1 = requireConstants(); class HeartBeat extends types_1.IHeartBeat { constructor(opts) { super(opts); @@ -2555,573 +2403,654 @@ function requireHeartbeat() { const tslib_1 = require$$0$2; tslib_1.__exportStar(requireHeartbeat(), exports2); tslib_1.__exportStar(requireTypes(), exports2); - tslib_1.__exportStar(requireConstants$1(), exports2); -})(cjs$5); -var cjs$3 = {}; -var quickFormatUnescaped; -var hasRequiredQuickFormatUnescaped; -function requireQuickFormatUnescaped() { - if (hasRequiredQuickFormatUnescaped) - return quickFormatUnescaped; - hasRequiredQuickFormatUnescaped = 1; - function tryStringify(o2) { - try { - return JSON.stringify(o2); - } catch (e) { - return '"[Circular]"'; - } - } - quickFormatUnescaped = format; - function format(f2, args, opts) { - var ss2 = opts && opts.stringify || tryStringify; - var offset = 1; - if (typeof f2 === "object" && f2 !== null) { - var len = args.length + offset; - if (len === 1) - return f2; - var objects = new Array(len); - objects[0] = ss2(f2); - for (var index = 1; index < len; index++) { - objects[index] = ss2(args[index]); - } - return objects.join(" "); - } - if (typeof f2 !== "string") { - return f2; - } - var argLen = args.length; - if (argLen === 0) - return f2; - var str = ""; - var a3 = 1 - offset; - var lastPos = -1; - var flen = f2 && f2.length || 0; - for (var i2 = 0; i2 < flen; ) { - if (f2.charCodeAt(i2) === 37 && i2 + 1 < flen) { - lastPos = lastPos > -1 ? lastPos : 0; - switch (f2.charCodeAt(i2 + 1)) { - case 100: - case 102: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Number(args[a3]); - lastPos = i2 + 2; - i2++; + tslib_1.__exportStar(requireConstants(), exports2); +})(cjs$4); +function tryStringify(o2) { + try { + return JSON.stringify(o2); + } catch (e2) { + return '"[Circular]"'; + } +} +var quickFormatUnescaped = format$1; +function format$1(f3, args, opts) { + var ss4 = opts && opts.stringify || tryStringify; + var offset = 1; + if (typeof f3 === "object" && f3 !== null) { + var len = args.length + offset; + if (len === 1) + return f3; + var objects = new Array(len); + objects[0] = ss4(f3); + for (var index = 1; index < len; index++) { + objects[index] = ss4(args[index]); + } + return objects.join(" "); + } + if (typeof f3 !== "string") { + return f3; + } + var argLen = args.length; + if (argLen === 0) + return f3; + var str = ""; + var a3 = 1 - offset; + var lastPos = -1; + var flen = f3 && f3.length || 0; + for (var i2 = 0; i2 < flen; ) { + if (f3.charCodeAt(i2) === 37 && i2 + 1 < flen) { + lastPos = lastPos > -1 ? lastPos : 0; + switch (f3.charCodeAt(i2 + 1)) { + case 100: + case 102: + if (a3 >= argLen) break; - case 105: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Math.floor(Number(args[a3])); - lastPos = i2 + 2; - i2++; + if (args[a3] == null) break; - case 79: - case 111: - case 106: - if (a3 >= argLen) - break; - if (args[a3] === void 0) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - var type2 = typeof args[a3]; - if (type2 === "string") { - str += "'" + args[a3] + "'"; - lastPos = i2 + 2; - i2++; - break; - } - if (type2 === "function") { - str += args[a3].name || ""; - lastPos = i2 + 2; - i2++; - break; - } - str += ss2(args[a3]); - lastPos = i2 + 2; - i2++; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Number(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 105: + if (a3 >= argLen) break; - case 115: - if (a3 >= argLen) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += String(args[a3]); + if (args[a3] == null) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Math.floor(Number(args[a3])); + lastPos = i2 + 2; + i2++; + break; + case 79: + case 111: + case 106: + if (a3 >= argLen) + break; + if (args[a3] === void 0) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + var type2 = typeof args[a3]; + if (type2 === "string") { + str += "'" + args[a3] + "'"; lastPos = i2 + 2; i2++; break; - case 37: - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += "%"; + } + if (type2 === "function") { + str += args[a3].name || ""; lastPos = i2 + 2; i2++; - a3--; break; - } - ++a3; + } + str += ss4(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 115: + if (a3 >= argLen) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += String(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 37: + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += "%"; + lastPos = i2 + 2; + i2++; + a3--; + break; } - ++i2; - } - if (lastPos === -1) - return f2; - else if (lastPos < flen) { - str += f2.slice(lastPos); - } - return str; + ++a3; + } + ++i2; + } + if (lastPos === -1) + return f3; + else if (lastPos < flen) { + str += f3.slice(lastPos); + } + return str; +} +const format = quickFormatUnescaped; +var browser$4 = pino; +const _console = pfGlobalThisOrFallback().console || {}; +const stdSerializers = { + mapHttpRequest: mock, + mapHttpResponse: mock, + wrapRequestSerializer: passthrough, + wrapResponseSerializer: passthrough, + wrapErrorSerializer: passthrough, + req: mock, + res: mock, + err: asErrValue +}; +function shouldSerialize(serialize, serializers) { + if (Array.isArray(serialize)) { + const hasToFilter = serialize.filter(function(k2) { + return k2 !== "!stdSerializers.err"; + }); + return hasToFilter; + } else if (serialize === true) { + return Object.keys(serializers); } - return quickFormatUnescaped; -} -var browser$4; -var hasRequiredBrowser; -function requireBrowser() { - if (hasRequiredBrowser) - return browser$4; - hasRequiredBrowser = 1; - const format = requireQuickFormatUnescaped(); - browser$4 = pino; - const _console = pfGlobalThisOrFallback().console || {}; - const stdSerializers = { - mapHttpRequest: mock, - mapHttpResponse: mock, - wrapRequestSerializer: passthrough, - wrapResponseSerializer: passthrough, - wrapErrorSerializer: passthrough, - req: mock, - res: mock, - err: asErrValue + return false; +} +function pino(opts) { + opts = opts || {}; + opts.browser = opts.browser || {}; + const transmit2 = opts.browser.transmit; + if (transmit2 && typeof transmit2.send !== "function") { + throw Error("pino: transmit option must have a send function"); + } + const proto = opts.browser.write || _console; + if (opts.browser.write) + opts.browser.asObject = true; + const serializers = opts.serializers || {}; + const serialize = shouldSerialize(opts.browser.serialize, serializers); + let stdErrSerialize = opts.browser.serialize; + if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) + stdErrSerialize = false; + const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; + if (typeof proto === "function") { + proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; + } + if (opts.enabled === false) + opts.level = "silent"; + const level = opts.level || "info"; + const logger = Object.create(proto); + if (!logger.log) + logger.log = noop$1; + Object.defineProperty(logger, "levelVal", { + get: getLevelVal + }); + Object.defineProperty(logger, "level", { + get: getLevel, + set: setLevel + }); + const setOpts = { + transmit: transmit2, + serialize, + asObject: opts.browser.asObject, + levels, + timestamp: getTimeFunction(opts) }; - function shouldSerialize(serialize, serializers) { - if (Array.isArray(serialize)) { - const hasToFilter = serialize.filter(function(k2) { - return k2 !== "!stdSerializers.err"; - }); - return hasToFilter; - } else if (serialize === true) { - return Object.keys(serializers); + logger.levels = pino.levels; + logger.level = level; + logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop$1; + logger.serializers = serializers; + logger._serialize = serialize; + logger._stdErrSerialize = stdErrSerialize; + logger.child = child; + if (transmit2) + logger._logEvent = createLogEventShape(); + function getLevelVal() { + return this.level === "silent" ? Infinity : this.levels.values[this.level]; + } + function getLevel() { + return this._level; + } + function setLevel(level2) { + if (level2 !== "silent" && !this.levels.values[level2]) { + throw Error("unknown level " + level2); + } + this._level = level2; + set(setOpts, logger, "error", "log"); + set(setOpts, logger, "fatal", "error"); + set(setOpts, logger, "warn", "error"); + set(setOpts, logger, "info", "log"); + set(setOpts, logger, "debug", "log"); + set(setOpts, logger, "trace", "log"); + } + function child(bindings, childOptions) { + if (!bindings) { + throw new Error("missing bindings for child Pino"); + } + childOptions = childOptions || {}; + if (serialize && bindings.serializers) { + childOptions.serializers = bindings.serializers; + } + const childOptionsSerializers = childOptions.serializers; + if (serialize && childOptionsSerializers) { + var childSerializers = Object.assign({}, serializers, childOptionsSerializers); + var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; + delete bindings.serializers; + applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); + } + function Child(parent) { + this._childLevel = (parent._childLevel | 0) + 1; + this.error = bind(parent, bindings, "error"); + this.fatal = bind(parent, bindings, "fatal"); + this.warn = bind(parent, bindings, "warn"); + this.info = bind(parent, bindings, "info"); + this.debug = bind(parent, bindings, "debug"); + this.trace = bind(parent, bindings, "trace"); + if (childSerializers) { + this.serializers = childSerializers; + this._serialize = childSerialize; + } + if (transmit2) { + this._logEvent = createLogEventShape( + [].concat(parent._logEvent.bindings, bindings) + ); + } } - return false; + Child.prototype = this; + return new Child(this); } - function pino(opts) { - opts = opts || {}; - opts.browser = opts.browser || {}; - const transmit2 = opts.browser.transmit; - if (transmit2 && typeof transmit2.send !== "function") { - throw Error("pino: transmit option must have a send function"); - } - const proto = opts.browser.write || _console; - if (opts.browser.write) - opts.browser.asObject = true; - const serializers = opts.serializers || {}; - const serialize = shouldSerialize(opts.browser.serialize, serializers); - let stdErrSerialize = opts.browser.serialize; - if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) - stdErrSerialize = false; - const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; - if (typeof proto === "function") { - proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; - } - if (opts.enabled === false) - opts.level = "silent"; - const level = opts.level || "info"; - const logger = Object.create(proto); - if (!logger.log) - logger.log = noop2; - Object.defineProperty(logger, "levelVal", { - get: getLevelVal - }); - Object.defineProperty(logger, "level", { - get: getLevel, - set: setLevel - }); - const setOpts = { - transmit: transmit2, - serialize, - asObject: opts.browser.asObject, - levels, - timestamp: getTimeFunction(opts) + return logger; +} +pino.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" + } +}; +pino.stdSerializers = stdSerializers; +pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); +function set(opts, logger, level, fallback) { + const proto = Object.getPrototypeOf(logger); + logger[level] = logger.levelVal > logger.levels.values[level] ? noop$1 : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop$1; + wrap(opts, logger, level); +} +function wrap(opts, logger, level) { + if (!opts.transmit && logger[level] === noop$1) + return; + logger[level] = /* @__PURE__ */ function(write) { + return function LOG() { + const ts3 = opts.timestamp(); + const args = new Array(arguments.length); + const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; + for (var i2 = 0; i2 < args.length; i2++) + args[i2] = arguments[i2]; + if (opts.serialize && !opts.asObject) { + applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); + } + if (opts.asObject) + write.call(proto, asObject(this, level, args, ts3)); + else + write.apply(proto, args); + if (opts.transmit) { + const transmitLevel = opts.transmit.level || logger.level; + const transmitValue = pino.levels.values[transmitLevel]; + const methodValue = pino.levels.values[level]; + if (methodValue < transmitValue) + return; + transmit(this, { + ts: ts3, + methodLevel: level, + methodValue, + transmitLevel, + transmitValue: pino.levels.values[opts.transmit.level || logger.level], + send: opts.transmit.send, + val: logger.levelVal + }, args); + } }; - logger.levels = pino.levels; - logger.level = level; - logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop2; - logger.serializers = serializers; - logger._serialize = serialize; - logger._stdErrSerialize = stdErrSerialize; - logger.child = child; - if (transmit2) - logger._logEvent = createLogEventShape(); - function getLevelVal() { - return this.level === "silent" ? Infinity : this.levels.values[this.level]; - } - function getLevel() { - return this._level; - } - function setLevel(level2) { - if (level2 !== "silent" && !this.levels.values[level2]) { - throw Error("unknown level " + level2); - } - this._level = level2; - set2(setOpts, logger, "error", "log"); - set2(setOpts, logger, "fatal", "error"); - set2(setOpts, logger, "warn", "error"); - set2(setOpts, logger, "info", "log"); - set2(setOpts, logger, "debug", "log"); - set2(setOpts, logger, "trace", "log"); - } - function child(bindings, childOptions) { - if (!bindings) { - throw new Error("missing bindings for child Pino"); - } - childOptions = childOptions || {}; - if (serialize && bindings.serializers) { - childOptions.serializers = bindings.serializers; - } - const childOptionsSerializers = childOptions.serializers; - if (serialize && childOptionsSerializers) { - var childSerializers = Object.assign({}, serializers, childOptionsSerializers); - var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; - delete bindings.serializers; - applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); - } - function Child(parent) { - this._childLevel = (parent._childLevel | 0) + 1; - this.error = bind(parent, bindings, "error"); - this.fatal = bind(parent, bindings, "fatal"); - this.warn = bind(parent, bindings, "warn"); - this.info = bind(parent, bindings, "info"); - this.debug = bind(parent, bindings, "debug"); - this.trace = bind(parent, bindings, "trace"); - if (childSerializers) { - this.serializers = childSerializers; - this._serialize = childSerialize; - } - if (transmit2) { - this._logEvent = createLogEventShape( - [].concat(parent._logEvent.bindings, bindings) - ); + }(logger[level]); +} +function asObject(logger, level, args, ts3) { + if (logger._serialize) + applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); + const argsCloned = args.slice(); + let msg = argsCloned[0]; + const o2 = {}; + if (ts3) { + o2.time = ts3; + } + o2.level = pino.levels.values[level]; + let lvl = (logger._childLevel | 0) + 1; + if (lvl < 1) + lvl = 1; + if (msg !== null && typeof msg === "object") { + while (lvl-- && typeof argsCloned[0] === "object") { + Object.assign(o2, argsCloned.shift()); + } + msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; + } else if (typeof msg === "string") + msg = format(argsCloned.shift(), argsCloned); + if (msg !== void 0) + o2.msg = msg; + return o2; +} +function applySerializers(args, serialize, serializers, stdErrSerialize) { + for (const i2 in args) { + if (stdErrSerialize && args[i2] instanceof Error) { + args[i2] = pino.stdSerializers.err(args[i2]); + } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { + for (const k2 in args[i2]) { + if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { + args[i2][k2] = serializers[k2](args[i2][k2]); } } - Child.prototype = this; - return new Child(this); } - return logger; } - pino.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" +} +function bind(parent, bindings, level) { + return function() { + const args = new Array(1 + arguments.length); + args[0] = bindings; + for (var i2 = 1; i2 < args.length; i2++) { + args[i2] = arguments[i2 - 1]; } + return parent[level].apply(this, args); }; - pino.stdSerializers = stdSerializers; - pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); - function set2(opts, logger, level, fallback) { - const proto = Object.getPrototypeOf(logger); - logger[level] = logger.levelVal > logger.levels.values[level] ? noop2 : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop2; - wrap(opts, logger, level); - } - function wrap(opts, logger, level) { - if (!opts.transmit && logger[level] === noop2) - return; - logger[level] = /* @__PURE__ */ function(write) { - return function LOG() { - const ts2 = opts.timestamp(); - const args = new Array(arguments.length); - const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; - for (var i2 = 0; i2 < args.length; i2++) - args[i2] = arguments[i2]; - if (opts.serialize && !opts.asObject) { - applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); - } - if (opts.asObject) - write.call(proto, asObject(this, level, args, ts2)); - else - write.apply(proto, args); - if (opts.transmit) { - const transmitLevel = opts.transmit.level || logger.level; - const transmitValue = pino.levels.values[transmitLevel]; - const methodValue = pino.levels.values[level]; - if (methodValue < transmitValue) - return; - transmit(this, { - ts: ts2, - methodLevel: level, - methodValue, - transmitLevel, - transmitValue: pino.levels.values[opts.transmit.level || logger.level], - send: opts.transmit.send, - val: logger.levelVal - }, args); - } - }; - }(logger[level]); - } - function asObject(logger, level, args, ts2) { - if (logger._serialize) - applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); - const argsCloned = args.slice(); - let msg = argsCloned[0]; - const o2 = {}; - if (ts2) { - o2.time = ts2; - } - o2.level = pino.levels.values[level]; - let lvl = (logger._childLevel | 0) + 1; - if (lvl < 1) - lvl = 1; - if (msg !== null && typeof msg === "object") { - while (lvl-- && typeof argsCloned[0] === "object") { - Object.assign(o2, argsCloned.shift()); - } - msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; - } else if (typeof msg === "string") - msg = format(argsCloned.shift(), argsCloned); - if (msg !== void 0) - o2.msg = msg; - return o2; - } - function applySerializers(args, serialize, serializers, stdErrSerialize) { - for (const i2 in args) { - if (stdErrSerialize && args[i2] instanceof Error) { - args[i2] = pino.stdSerializers.err(args[i2]); - } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { - for (const k2 in args[i2]) { - if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { - args[i2][k2] = serializers[k2](args[i2][k2]); - } - } - } +} +function transmit(logger, opts, args) { + const send = opts.send; + const ts3 = opts.ts; + const methodLevel = opts.methodLevel; + const methodValue = opts.methodValue; + const val = opts.val; + const bindings = logger._logEvent.bindings; + applySerializers( + args, + logger._serialize || Object.keys(logger.serializers), + logger.serializers, + logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize + ); + logger._logEvent.ts = ts3; + logger._logEvent.messages = args.filter(function(arg) { + return bindings.indexOf(arg) === -1; + }); + logger._logEvent.level.label = methodLevel; + logger._logEvent.level.value = methodValue; + send(methodLevel, logger._logEvent, val); + logger._logEvent = createLogEventShape(bindings); +} +function createLogEventShape(bindings) { + return { + ts: 0, + messages: [], + bindings: bindings || [], + level: { label: "", value: 0 } + }; +} +function asErrValue(err) { + const obj = { + type: err.constructor.name, + msg: err.message, + stack: err.stack + }; + for (const key in err) { + if (obj[key] === void 0) { + obj[key] = err[key]; } } - function bind(parent, bindings, level) { - return function() { - const args = new Array(1 + arguments.length); - args[0] = bindings; - for (var i2 = 1; i2 < args.length; i2++) { - args[i2] = arguments[i2 - 1]; - } - return parent[level].apply(this, args); - }; + return obj; +} +function getTimeFunction(opts) { + if (typeof opts.timestamp === "function") { + return opts.timestamp; } - function transmit(logger, opts, args) { - const send = opts.send; - const ts2 = opts.ts; - const methodLevel = opts.methodLevel; - const methodValue = opts.methodValue; - const val = opts.val; - const bindings = logger._logEvent.bindings; - applySerializers( - args, - logger._serialize || Object.keys(logger.serializers), - logger.serializers, - logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize - ); - logger._logEvent.ts = ts2; - logger._logEvent.messages = args.filter(function(arg) { - return bindings.indexOf(arg) === -1; - }); - logger._logEvent.level.label = methodLevel; - logger._logEvent.level.value = methodValue; - send(methodLevel, logger._logEvent, val); - logger._logEvent = createLogEventShape(bindings); + if (opts.timestamp === false) { + return nullTime; } - function createLogEventShape(bindings) { - return { - ts: 0, - messages: [], - bindings: bindings || [], - level: { label: "", value: 0 } - }; + return epochTime; +} +function mock() { + return {}; +} +function passthrough(a3) { + return a3; +} +function noop$1() { +} +function nullTime() { + return false; +} +function epochTime() { + return Date.now(); +} +function unixTime() { + return Math.round(Date.now() / 1e3); +} +function isoTime() { + return new Date(Date.now()).toISOString(); +} +function pfGlobalThisOrFallback() { + function defd(o2) { + return typeof o2 !== "undefined" && o2; } - function asErrValue(err) { - const obj = { - type: err.constructor.name, - msg: err.message, - stack: err.stack - }; - for (const key in err) { - if (obj[key] === void 0) { - obj[key] = err[key]; - } - } - return obj; + try { + if (typeof globalThis !== "undefined") + return globalThis; + Object.defineProperty(Object.prototype, "globalThis", { + get: function() { + delete Object.prototype.globalThis; + return this.globalThis = this; + }, + configurable: true + }); + return globalThis; + } catch (e2) { + return defd(self) || defd(window) || defd(this) || {}; } - function getTimeFunction(opts) { - if (typeof opts.timestamp === "function") { - return opts.timestamp; - } - if (opts.timestamp === false) { - return nullTime; - } - return epochTime; +} +const nt$1 = /* @__PURE__ */ getDefaultExportFromCjs(browser$4); +const c$1 = { level: "info" }, n$3 = "custom_context", l = 1e3 * 1024; +let O$1 = class O { + constructor(e2) { + this.nodeValue = e2, this.sizeInBytes = new TextEncoder().encode(this.nodeValue).length, this.next = null; } - function mock() { - return {}; + get value() { + return this.nodeValue; } - function passthrough(a3) { - return a3; + get size() { + return this.sizeInBytes; } - function noop2() { +}; +let d$2 = class d2 { + constructor(e2) { + this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e2, this.sizeInBytes = 0; } - function nullTime() { - return false; + append(e2) { + const t2 = new O$1(e2); + if (t2.size > this.maxSizeInBytes) + throw new Error(`[LinkedList] Value too big to insert into list: ${e2} with size ${t2.size}`); + for (; this.size + t2.size > this.maxSizeInBytes; ) + this.shift(); + this.head ? (this.tail && (this.tail.next = t2), this.tail = t2) : (this.head = t2, this.tail = t2), this.lengthInNodes++, this.sizeInBytes += t2.size; } - function epochTime() { - return Date.now(); + shift() { + if (!this.head) + return; + const e2 = this.head; + this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e2.size; } - function unixTime() { - return Math.round(Date.now() / 1e3); + toArray() { + const e2 = []; + let t2 = this.head; + for (; t2 !== null; ) + e2.push(t2.value), t2 = t2.next; + return e2; } - function isoTime() { - return new Date(Date.now()).toISOString(); + get length() { + return this.lengthInNodes; } - function pfGlobalThisOrFallback() { - function defd(o2) { - return typeof o2 !== "undefined" && o2; - } - try { - if (typeof globalThis !== "undefined") - return globalThis; - Object.defineProperty(Object.prototype, "globalThis", { - get: function() { - delete Object.prototype.globalThis; - return this.globalThis = this; - }, - configurable: true - }); - return globalThis; - } catch (e) { - return defd(self) || defd(window) || defd(this) || {}; - } + get size() { + return this.sizeInBytes; } - return browser$4; -} -var constants = {}; -var hasRequiredConstants; -function requireConstants() { - if (hasRequiredConstants) - return constants; - hasRequiredConstants = 1; - Object.defineProperty(constants, "__esModule", { value: true }); - constants.PINO_CUSTOM_CONTEXT_KEY = constants.PINO_LOGGER_DEFAULTS = void 0; - constants.PINO_LOGGER_DEFAULTS = { - level: "info" - }; - constants.PINO_CUSTOM_CONTEXT_KEY = "custom_context"; - return constants; -} -var utils = {}; -var hasRequiredUtils; -function requireUtils() { - if (hasRequiredUtils) - return utils; - hasRequiredUtils = 1; - Object.defineProperty(utils, "__esModule", { value: true }); - utils.generateChildLogger = utils.formatChildLoggerContext = utils.getLoggerContext = utils.setBrowserLoggerContext = utils.getBrowserLoggerContext = utils.getDefaultLoggerOptions = void 0; - const constants_1 = requireConstants(); - function getDefaultLoggerOptions(opts) { - return Object.assign(Object.assign({}, opts), { level: (opts === null || opts === void 0 ? void 0 : opts.level) || constants_1.PINO_LOGGER_DEFAULTS.level }); - } - utils.getDefaultLoggerOptions = getDefaultLoggerOptions; - function getBrowserLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - return logger[customContextKey] || ""; - } - utils.getBrowserLoggerContext = getBrowserLoggerContext; - function setBrowserLoggerContext(logger, context, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - logger[customContextKey] = context; - return logger; - } - utils.setBrowserLoggerContext = setBrowserLoggerContext; - function getLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - let context = ""; - if (typeof logger.bindings === "undefined") { - context = getBrowserLoggerContext(logger, customContextKey); - } else { - context = logger.bindings().context || ""; - } - return context; + toOrderedArray() { + return Array.from(this); + } + [Symbol.iterator]() { + let e2 = this.head; + return { next: () => { + if (!e2) + return { done: true, value: null }; + const t2 = e2.value; + return e2 = e2.next, { done: false, value: t2 }; + } }; } - utils.getLoggerContext = getLoggerContext; - function formatChildLoggerContext(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const parentContext = getLoggerContext(logger, customContextKey); - const context = parentContext.trim() ? `${parentContext}/${childContext}` : childContext; - return context; +}; +let L$4 = class L { + constructor(e2, t2 = l) { + this.level = e2 ?? "error", this.levelValue = browser$4.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = t2, this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); } - utils.formatChildLoggerContext = formatChildLoggerContext; - function generateChildLogger(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const context = formatChildLoggerContext(logger, childContext, customContextKey); - const child = logger.child({ context }); - return setBrowserLoggerContext(child, context, customContextKey); + forwardToConsole(e2, t2) { + t2 === browser$4.levels.values.error ? console.error(e2) : t2 === browser$4.levels.values.warn ? console.warn(e2) : t2 === browser$4.levels.values.debug ? console.debug(e2) : t2 === browser$4.levels.values.trace ? console.trace(e2) : console.log(e2); + } + appendToLogs(e2) { + this.logs.append(safeJsonStringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: e2 })); + const t2 = typeof e2 == "string" ? JSON.parse(e2).level : e2.level; + t2 >= this.levelValue && this.forwardToConsole(e2, t2); + } + getLogs() { + return this.logs; + } + clearLogs() { + this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); + } + getLogArray() { + return Array.from(this.logs); + } + logsToBlob(e2) { + const t2 = this.getLogArray(); + return t2.push(safeJsonStringify({ extraMetadata: e2 })), new Blob(t2, { type: "application/json" }); + } +}; +let m$1 = class m { + constructor(e2, t2 = l) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } + downloadLogsBlobInBrowser(e2) { + const t2 = URL.createObjectURL(this.logsToBlob(e2)), o2 = document.createElement("a"); + o2.href = t2, o2.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(o2), o2.click(), document.body.removeChild(o2), URL.revokeObjectURL(t2); + } +}; +class B { + constructor(e2, t2 = l) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); } - utils.generateChildLogger = generateChildLogger; - return utils; } -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.pino = void 0; - const tslib_1 = require$$0$2; - const pino_1 = tslib_1.__importDefault(requireBrowser()); - Object.defineProperty(exports2, "pino", { enumerable: true, get: function() { - return pino_1.default; - } }); - tslib_1.__exportStar(requireConstants(), exports2); - tslib_1.__exportStar(requireUtils(), exports2); -})(cjs$3); -let n$1 = class n extends IEvents$1 { +var x = Object.defineProperty, S$3 = Object.defineProperties, _2 = Object.getOwnPropertyDescriptors, p$1 = Object.getOwnPropertySymbols, T$1 = Object.prototype.hasOwnProperty, z$2 = Object.prototype.propertyIsEnumerable, f$3 = (r3, e2, t2) => e2 in r3 ? x(r3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : r3[e2] = t2, i = (r3, e2) => { + for (var t2 in e2 || (e2 = {})) + T$1.call(e2, t2) && f$3(r3, t2, e2[t2]); + if (p$1) + for (var t2 of p$1(e2)) + z$2.call(e2, t2) && f$3(r3, t2, e2[t2]); + return r3; +}, g$2 = (r3, e2) => S$3(r3, _2(e2)); +function k$2(r3) { + return g$2(i({}, r3), { level: (r3 == null ? void 0 : r3.level) || c$1.level }); +} +function v$2(r3, e2 = n$3) { + return r3[e2] || ""; +} +function b$2(r3, e2, t2 = n$3) { + return r3[t2] = e2, r3; +} +function y$2(r3, e2 = n$3) { + let t2 = ""; + return typeof r3.bindings > "u" ? t2 = v$2(r3, e2) : t2 = r3.bindings().context || "", t2; +} +function w$3(r3, e2, t2 = n$3) { + const o2 = y$2(r3, t2); + return o2.trim() ? `${o2}/${e2}` : e2; +} +function E$1(r3, e2, t2 = n$3) { + const o2 = w$3(r3, e2, t2), a3 = r3.child({ context: o2 }); + return b$2(a3, o2, t2); +} +function C$2(r3) { + var e2, t2; + const o2 = new m$1((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i({}, r3.opts), { level: "trace", browser: g$2(i({}, (t2 = r3.opts) == null ? void 0 : t2.browser), { write: (a3) => o2.write(a3) }) })), chunkLoggerController: o2 }; +} +function I$2(r3) { + var e2; + const t2 = new B((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i({}, r3.opts), { level: "trace" }), t2), chunkLoggerController: t2 }; +} +function A$2(r3) { + return typeof r3.loggerOverride < "u" && typeof r3.loggerOverride != "string" ? { logger: r3.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? C$2(r3) : I$2(r3); +} +let n$2 = class n extends IEvents { constructor(s2) { super(), this.opts = s2, this.protocol = "wc", this.version = 2; } }; -let h$2 = class h2 extends IEvents$1 { +let h$1 = class h2 extends IEvents { constructor(s2, t2) { super(), this.core = s2, this.logger = t2, this.records = /* @__PURE__ */ new Map(); } }; -let a$2 = class a { +let a$1 = class a { constructor(s2, t2) { this.logger = s2, this.core = t2; } }; -let u$1 = class u extends IEvents$1 { +let u$1 = class u extends IEvents { constructor(s2, t2) { super(), this.relayer = s2, this.logger = t2; } }; -let g$4 = class g extends IEvents$1 { +let g$1 = class g extends IEvents { constructor(s2) { super(); } }; -let p$2 = class p { +class p { constructor(s2, t2, o2, M2) { this.core = s2, this.logger = t2, this.name = o2; } -}; -class d2 extends IEvents$1 { +} +let d$1 = class d3 extends IEvents { constructor(s2, t2) { super(), this.relayer = s2, this.logger = t2; } -} -class E extends IEvents$1 { +}; +class E extends IEvents { constructor(s2, t2) { super(), this.core = s2, this.logger = t2; } @@ -3141,7 +3070,7 @@ let b$1 = class b { this.opts = s2, this.protocol = "wc", this.version = 2; } }; -let w$4 = class w { +let w$2 = class w { constructor(s2) { this.client = s2; } @@ -3262,9 +3191,9 @@ var int = {}; (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); function imulShim(a3, b3) { - var ah = a3 >>> 16 & 65535, al = a3 & 65535; + var ah2 = a3 >>> 16 & 65535, al = a3 & 65535; var bh = b3 >>> 16 & 65535, bl = b3 & 65535; - return al * bl + (ah * bl + al * bh << 16 >>> 0) | 0; + return al * bl + (ah2 * bl + al * bh << 16 >>> 0) | 0; } exports2.mul = Math.imul || imulShim; function add(a3, b3) { @@ -3275,21 +3204,21 @@ var int = {}; return a3 - b3 | 0; } exports2.sub = sub; - function rotl(x2, n3) { - return x2 << n3 | x2 >>> 32 - n3; + function rotl(x2, n4) { + return x2 << n4 | x2 >>> 32 - n4; } exports2.rotl = rotl; - function rotr(x2, n3) { - return x2 << 32 - n3 | x2 >>> n3; + function rotr(x2, n4) { + return x2 << 32 - n4 | x2 >>> n4; } exports2.rotr = rotr; - function isIntegerShim(n3) { - return typeof n3 === "number" && isFinite(n3) && Math.floor(n3) === n3; + function isIntegerShim(n4) { + return typeof n4 === "number" && isFinite(n4) && Math.floor(n4) === n4; } exports2.isInteger = Number.isInteger || isIntegerShim; exports2.MAX_SAFE_INTEGER = 9007199254740991; - exports2.isSafeInteger = function(n3) { - return exports2.isInteger(n3) && (n3 >= -exports2.MAX_SAFE_INTEGER && n3 <= exports2.MAX_SAFE_INTEGER); + exports2.isSafeInteger = function(n4) { + return exports2.isInteger(n4) && (n4 >= -exports2.MAX_SAFE_INTEGER && n4 <= exports2.MAX_SAFE_INTEGER); }; })(int); Object.defineProperty(binary, "__esModule", { value: true }); @@ -3411,8 +3340,8 @@ function readInt64BE(array, offset) { offset = 0; } var hi = readInt32BE(array, offset); - var lo = readInt32BE(array, offset + 4); - return hi * 4294967296 + lo - (lo >> 31) * 4294967296; + var lo2 = readInt32BE(array, offset + 4); + return hi * 4294967296 + lo2 - (lo2 >> 31) * 4294967296; } binary.readInt64BE = readInt64BE; function readUint64BE(array, offset) { @@ -3420,26 +3349,26 @@ function readUint64BE(array, offset) { offset = 0; } var hi = readUint32BE(array, offset); - var lo = readUint32BE(array, offset + 4); - return hi * 4294967296 + lo; + var lo2 = readUint32BE(array, offset + 4); + return hi * 4294967296 + lo2; } binary.readUint64BE = readUint64BE; function readInt64LE(array, offset) { if (offset === void 0) { offset = 0; } - var lo = readInt32LE(array, offset); + var lo2 = readInt32LE(array, offset); var hi = readInt32LE(array, offset + 4); - return hi * 4294967296 + lo - (lo >> 31) * 4294967296; + return hi * 4294967296 + lo2 - (lo2 >> 31) * 4294967296; } binary.readInt64LE = readInt64LE; function readUint64LE(array, offset) { if (offset === void 0) { offset = 0; } - var lo = readUint32LE(array, offset); + var lo2 = readUint32LE(array, offset); var hi = readUint32LE(array, offset + 4); - return hi * 4294967296 + lo; + return hi * 4294967296 + lo2; } binary.readUint64LE = readUint64LE; function writeUint64BE(value, out, offset) { @@ -3823,7 +3752,7 @@ var sha512 = {}; }() ); exports2.SHA512 = SHA512; - var K2 = new Int32Array([ + var K3 = new Int32Array([ 1116352408, 3609767458, 1899447441, @@ -3985,16 +3914,16 @@ var sha512 = {}; 1816402316, 1246189591 ]); - function hashBlocks(wh, wl, hh, hl, m2, pos, len) { - var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; + function hashBlocks(wh, wl, hh2, hl, m3, pos, len) { + var ah0 = hh2[0], ah1 = hh2[1], ah2 = hh2[2], ah3 = hh2[3], ah4 = hh2[4], ah5 = hh2[5], ah6 = hh2[6], ah7 = hh2[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; var h4, l2; - var th, tl; - var a3, b3, c2, d3; + var th2, tl; + var a3, b3, c2, d5; while (len >= 128) { for (var i2 = 0; i2 < 16; i2++) { var j2 = 8 * i2 + pos; - wh[i2] = binary_12.readUint32BE(m2, j2); - wl[i2] = binary_12.readUint32BE(m2, j2 + 4); + wh[i2] = binary_12.readUint32BE(m3, j2); + wl[i2] = binary_12.readUint32BE(m3, j2 + 4); } for (var i2 = 0; i2 < 80; i2++) { var bh0 = ah0; @@ -4018,75 +3947,75 @@ var sha512 = {}; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32)); l2 = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32)); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = ah4 & ah5 ^ ~ah4 & ah6; l2 = al4 & al5 ^ ~al4 & al6; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = K2[i2 * 2]; - l2 = K2[i2 * 2 + 1]; + d5 += h4 >>> 16; + h4 = K3[i2 * 2]; + l2 = K3[i2 * 2 + 1]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = wh[i2 % 16]; l2 = wl[i2 % 16]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - th = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + th2 = c2 & 65535 | d5 << 16; tl = a3 & 65535 | b3 << 16; - h4 = th; + h4 = th2; l2 = tl; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32)); l2 = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32)); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2; l2 = al0 & al1 ^ al0 & al2 ^ al1 & al2; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh7 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + bh7 = c2 & 65535 | d5 << 16; bl7 = a3 & 65535 | b3 << 16; h4 = bh3; l2 = bl3; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = th; + d5 = h4 >>> 16; + h4 = th2; l2 = tl; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh3 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + bh3 = c2 & 65535 | d5 << 16; bl3 = a3 & 65535 | b3 << 16; ah1 = bh0; ah2 = bh1; @@ -4111,33 +4040,33 @@ var sha512 = {}; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = wh[(j2 + 9) % 16]; l2 = wl[(j2 + 9) % 16]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 1) % 16]; + d5 += h4 >>> 16; + th2 = wh[(j2 + 1) % 16]; tl = wl[(j2 + 1) % 16]; - h4 = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7; - l2 = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7); + h4 = (th2 >>> 1 | tl << 32 - 1) ^ (th2 >>> 8 | tl << 32 - 8) ^ th2 >>> 7; + l2 = (tl >>> 1 | th2 << 32 - 1) ^ (tl >>> 8 | th2 << 32 - 8) ^ (tl >>> 7 | th2 << 32 - 7); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 14) % 16]; + d5 += h4 >>> 16; + th2 = wh[(j2 + 14) % 16]; tl = wl[(j2 + 14) % 16]; - h4 = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6; - l2 = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6); + h4 = (th2 >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th2 << 32 - (61 - 32)) ^ th2 >>> 6; + l2 = (tl >>> 19 | th2 << 32 - 19) ^ (th2 >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th2 << 32 - 6); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - wh[j2] = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + wh[j2] = c2 & 65535 | d5 << 16; wl[j2] = a3 & 65535 | b3 << 16; } } @@ -4147,136 +4076,136 @@ var sha512 = {}; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[0]; + d5 = h4 >>> 16; + h4 = hh2[0]; l2 = hl[0]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[0] = ah0 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[0] = ah0 = c2 & 65535 | d5 << 16; hl[0] = al0 = a3 & 65535 | b3 << 16; h4 = ah1; l2 = al1; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[1]; + d5 = h4 >>> 16; + h4 = hh2[1]; l2 = hl[1]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[1] = ah1 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[1] = ah1 = c2 & 65535 | d5 << 16; hl[1] = al1 = a3 & 65535 | b3 << 16; h4 = ah2; l2 = al2; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[2]; + d5 = h4 >>> 16; + h4 = hh2[2]; l2 = hl[2]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[2] = ah2 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[2] = ah2 = c2 & 65535 | d5 << 16; hl[2] = al2 = a3 & 65535 | b3 << 16; h4 = ah3; l2 = al3; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[3]; + d5 = h4 >>> 16; + h4 = hh2[3]; l2 = hl[3]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[3] = ah3 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[3] = ah3 = c2 & 65535 | d5 << 16; hl[3] = al3 = a3 & 65535 | b3 << 16; h4 = ah4; l2 = al4; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[4]; + d5 = h4 >>> 16; + h4 = hh2[4]; l2 = hl[4]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[4] = ah4 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[4] = ah4 = c2 & 65535 | d5 << 16; hl[4] = al4 = a3 & 65535 | b3 << 16; h4 = ah5; l2 = al5; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[5]; + d5 = h4 >>> 16; + h4 = hh2[5]; l2 = hl[5]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[5] = ah5 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[5] = ah5 = c2 & 65535 | d5 << 16; hl[5] = al5 = a3 & 65535 | b3 << 16; h4 = ah6; l2 = al6; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[6]; + d5 = h4 >>> 16; + h4 = hh2[6]; l2 = hl[6]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[6] = ah6 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[6] = ah6 = c2 & 65535 | d5 << 16; hl[6] = al6 = a3 & 65535 | b3 << 16; h4 = ah7; l2 = al7; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[7]; + d5 = h4 >>> 16; + h4 = hh2[7]; l2 = hl[7]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[7] = ah7 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[7] = ah7 = c2 & 65535 | d5 << 16; hl[7] = al7 = a3 & 65535 | b3 << 16; pos += 128; len -= 128; @@ -4302,20 +4231,20 @@ var sha512 = {}; exports2.PUBLIC_KEY_LENGTH = 32; exports2.SECRET_KEY_LENGTH = 64; exports2.SEED_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); + function gf2(init) { + const r3 = new Float64Array(16); if (init) { for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; + r3[i2] = init[i2]; } } - return r2; + return r3; } const _9 = new Uint8Array(32); _9[0] = 9; - const gf0 = gf(); - const gf1 = gf([1]); - const D2 = gf([ + const gf0 = gf2(); + const gf1 = gf2([1]); + const D2 = gf2([ 30883, 4953, 19914, @@ -4333,7 +4262,7 @@ var sha512 = {}; 27886, 20995 ]); - const D22 = gf([ + const D22 = gf2([ 61785, 9906, 39828, @@ -4351,7 +4280,7 @@ var sha512 = {}; 55772, 9222 ]); - const X2 = gf([ + const X2 = gf2([ 54554, 36645, 11616, @@ -4369,7 +4298,7 @@ var sha512 = {}; 14035, 8553 ]); - const Y2 = gf([ + const Y2 = gf2([ 26200, 26214, 26214, @@ -4387,7 +4316,7 @@ var sha512 = {}; 26214, 26214 ]); - const I2 = gf([ + const I2 = gf2([ 41136, 18958, 6951, @@ -4405,9 +4334,9 @@ var sha512 = {}; 9344, 11139 ]); - function set25519(r2, a3) { + function set25519(r3, a3) { for (let i2 = 0; i2 < 16; i2++) { - r2[i2] = a3[i2] | 0; + r3[i2] = a3[i2] | 0; } } function car25519(o2) { @@ -4419,33 +4348,33 @@ var sha512 = {}; } o2[0] += c2 - 1 + 37 * (c2 - 1); } - function sel25519(p3, q2, b3) { + function sel25519(p2, q2, b3) { const c2 = ~(b3 - 1); for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; q2[i2] ^= t2; } } - function pack25519(o2, n3) { - const m2 = gf(); - const t2 = gf(); + function pack25519(o2, n4) { + const m3 = gf2(); + const t2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; + t2[i2] = n4[i2]; } car25519(t2); car25519(t2); car25519(t2); for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; + m3[0] = t2[0] - 65517; for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); } for (let i2 = 0; i2 < 16; i2++) { o2[2 * i2] = t2[i2] & 255; @@ -4453,27 +4382,27 @@ var sha512 = {}; } } function verify32(x2, y3) { - let d3 = 0; + let d5 = 0; for (let i2 = 0; i2 < 32; i2++) { - d3 |= x2[i2] ^ y3[i2]; + d5 |= x2[i2] ^ y3[i2]; } - return (1 & d3 - 1 >>> 8) - 1; + return (1 & d5 - 1 >>> 8) - 1; } function neq25519(a3, b3) { const c2 = new Uint8Array(32); - const d3 = new Uint8Array(32); + const d5 = new Uint8Array(32); pack25519(c2, a3); - pack25519(d3, b3); - return verify32(c2, d3); + pack25519(d5, b3); + return verify32(c2, d5); } function par25519(a3) { - const d3 = new Uint8Array(32); - pack25519(d3, a3); - return d3[0] & 1; + const d5 = new Uint8Array(32); + pack25519(d5, a3); + return d5[0] & 1; } - function unpack25519(o2, n3) { + function unpack25519(o2, n4) { for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); + o2[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); } o2[15] &= 32767; } @@ -4488,9 +4417,9 @@ var sha512 = {}; } } function mul(o2, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; v3 = a3[0]; - t0 += v3 * b0; + t0 += v3 * b02; t1 += v3 * b1; t2 += v3 * b22; t3 += v3 * b32; @@ -4507,7 +4436,7 @@ var sha512 = {}; t14 += v3 * b14; t15 += v3 * b15; v3 = a3[1]; - t1 += v3 * b0; + t1 += v3 * b02; t2 += v3 * b1; t3 += v3 * b22; t4 += v3 * b32; @@ -4524,7 +4453,7 @@ var sha512 = {}; t15 += v3 * b14; t16 += v3 * b15; v3 = a3[2]; - t2 += v3 * b0; + t2 += v3 * b02; t3 += v3 * b1; t4 += v3 * b22; t5 += v3 * b32; @@ -4541,7 +4470,7 @@ var sha512 = {}; t16 += v3 * b14; t17 += v3 * b15; v3 = a3[3]; - t3 += v3 * b0; + t3 += v3 * b02; t4 += v3 * b1; t5 += v3 * b22; t6 += v3 * b32; @@ -4558,7 +4487,7 @@ var sha512 = {}; t17 += v3 * b14; t18 += v3 * b15; v3 = a3[4]; - t4 += v3 * b0; + t4 += v3 * b02; t5 += v3 * b1; t6 += v3 * b22; t7 += v3 * b32; @@ -4575,7 +4504,7 @@ var sha512 = {}; t18 += v3 * b14; t19 += v3 * b15; v3 = a3[5]; - t5 += v3 * b0; + t5 += v3 * b02; t6 += v3 * b1; t7 += v3 * b22; t8 += v3 * b32; @@ -4592,7 +4521,7 @@ var sha512 = {}; t19 += v3 * b14; t20 += v3 * b15; v3 = a3[6]; - t6 += v3 * b0; + t6 += v3 * b02; t7 += v3 * b1; t8 += v3 * b22; t9 += v3 * b32; @@ -4609,7 +4538,7 @@ var sha512 = {}; t20 += v3 * b14; t21 += v3 * b15; v3 = a3[7]; - t7 += v3 * b0; + t7 += v3 * b02; t8 += v3 * b1; t9 += v3 * b22; t10 += v3 * b32; @@ -4626,7 +4555,7 @@ var sha512 = {}; t21 += v3 * b14; t22 += v3 * b15; v3 = a3[8]; - t8 += v3 * b0; + t8 += v3 * b02; t9 += v3 * b1; t10 += v3 * b22; t11 += v3 * b32; @@ -4643,7 +4572,7 @@ var sha512 = {}; t22 += v3 * b14; t23 += v3 * b15; v3 = a3[9]; - t9 += v3 * b0; + t9 += v3 * b02; t10 += v3 * b1; t11 += v3 * b22; t12 += v3 * b32; @@ -4660,7 +4589,7 @@ var sha512 = {}; t23 += v3 * b14; t24 += v3 * b15; v3 = a3[10]; - t10 += v3 * b0; + t10 += v3 * b02; t11 += v3 * b1; t12 += v3 * b22; t13 += v3 * b32; @@ -4677,7 +4606,7 @@ var sha512 = {}; t24 += v3 * b14; t25 += v3 * b15; v3 = a3[11]; - t11 += v3 * b0; + t11 += v3 * b02; t12 += v3 * b1; t13 += v3 * b22; t14 += v3 * b32; @@ -4694,7 +4623,7 @@ var sha512 = {}; t25 += v3 * b14; t26 += v3 * b15; v3 = a3[12]; - t12 += v3 * b0; + t12 += v3 * b02; t13 += v3 * b1; t14 += v3 * b22; t15 += v3 * b32; @@ -4711,7 +4640,7 @@ var sha512 = {}; t26 += v3 * b14; t27 += v3 * b15; v3 = a3[13]; - t13 += v3 * b0; + t13 += v3 * b02; t14 += v3 * b1; t15 += v3 * b22; t16 += v3 * b32; @@ -4728,7 +4657,7 @@ var sha512 = {}; t27 += v3 * b14; t28 += v3 * b15; v3 = a3[14]; - t14 += v3 * b0; + t14 += v3 * b02; t15 += v3 * b1; t16 += v3 * b22; t17 += v3 * b32; @@ -4745,7 +4674,7 @@ var sha512 = {}; t28 += v3 * b14; t29 += v3 * b15; v3 = a3[15]; - t15 += v3 * b0; + t15 += v3 * b02; t16 += v3 * b1; t17 += v3 * b22; t18 += v3 * b32; @@ -4897,7 +4826,7 @@ var sha512 = {}; mul(o2, a3, a3); } function inv25519(o2, i2) { - const c2 = gf(); + const c2 = gf2(); let a3; for (a3 = 0; a3 < 16; a3++) { c2[a3] = i2[a3]; @@ -4913,7 +4842,7 @@ var sha512 = {}; } } function pow2523(o2, i2) { - const c2 = gf(); + const c2 = gf2(); let a3; for (a3 = 0; a3 < 16; a3++) { c2[a3] = i2[a3]; @@ -4928,73 +4857,73 @@ var sha512 = {}; o2[a3] = c2[a3]; } } - function edadd(p3, q2) { - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e = gf(), f2 = gf(), g3 = gf(), h4 = gf(), t2 = gf(); - sub(a3, p3[1], p3[0]); + function edadd(p2, q2) { + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(), g3 = gf2(), h4 = gf2(), t2 = gf2(); + sub(a3, p2[1], p2[0]); sub(t2, q2[1], q2[0]); mul(a3, a3, t2); - add(b3, p3[0], p3[1]); + add(b3, p2[0], p2[1]); add(t2, q2[0], q2[1]); mul(b3, b3, t2); - mul(c2, p3[3], q2[3]); + mul(c2, p2[3], q2[3]); mul(c2, c2, D22); - mul(d3, p3[2], q2[2]); - add(d3, d3, d3); - sub(e, b3, a3); - sub(f2, d3, c2); - add(g3, d3, c2); + mul(d5, p2[2], q2[2]); + add(d5, d5, d5); + sub(e2, b3, a3); + sub(f3, d5, c2); + add(g3, d5, c2); add(h4, b3, a3); - mul(p3[0], e, f2); - mul(p3[1], h4, g3); - mul(p3[2], g3, f2); - mul(p3[3], e, h4); + mul(p2[0], e2, f3); + mul(p2[1], h4, g3); + mul(p2[2], g3, f3); + mul(p2[3], e2, h4); } - function cswap(p3, q2, b3) { + function cswap(p2, q2, b3) { for (let i2 = 0; i2 < 4; i2++) { - sel25519(p3[i2], q2[i2], b3); - } - } - function pack(r2, p3) { - const tx = gf(), ty = gf(), zi = gf(); - inv25519(zi, p3[2]); - mul(tx, p3[0], zi); - mul(ty, p3[1], zi); - pack25519(r2, ty); - r2[31] ^= par25519(tx) << 7; - } - function scalarmult(p3, q2, s2) { - set25519(p3[0], gf0); - set25519(p3[1], gf1); - set25519(p3[2], gf1); - set25519(p3[3], gf0); + sel25519(p2[i2], q2[i2], b3); + } + } + function pack(r3, p2) { + const tx = gf2(), ty = gf2(), zi2 = gf2(); + inv25519(zi2, p2[2]); + mul(tx, p2[0], zi2); + mul(ty, p2[1], zi2); + pack25519(r3, ty); + r3[31] ^= par25519(tx) << 7; + } + function scalarmult(p2, q2, s2) { + set25519(p2[0], gf0); + set25519(p2[1], gf1); + set25519(p2[2], gf1); + set25519(p2[3], gf0); for (let i2 = 255; i2 >= 0; --i2) { const b3 = s2[i2 / 8 | 0] >> (i2 & 7) & 1; - cswap(p3, q2, b3); - edadd(q2, p3); - edadd(p3, p3); - cswap(p3, q2, b3); + cswap(p2, q2, b3); + edadd(q2, p2); + edadd(p2, p2); + cswap(p2, q2, b3); } } - function scalarbase(p3, s2) { - const q2 = [gf(), gf(), gf(), gf()]; + function scalarbase(p2, s2) { + const q2 = [gf2(), gf2(), gf2(), gf2()]; set25519(q2[0], X2); set25519(q2[1], Y2); set25519(q2[2], gf1); mul(q2[3], X2, Y2); - scalarmult(p3, q2, s2); + scalarmult(p2, q2, s2); } function generateKeyPairFromSeed(seed) { if (seed.length !== exports2.SEED_LENGTH) { throw new Error(`ed25519: seed must be ${exports2.SEED_LENGTH} bytes`); } - const d3 = (0, sha512_1.hash)(seed); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; + const d5 = (0, sha512_1.hash)(seed); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; const publicKey = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - scalarbase(p3, d3); - pack(publicKey, p3); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + scalarbase(p2, d5); + pack(publicKey, p2); const secretKey = new Uint8Array(64); secretKey.set(seed); secretKey.set(publicKey, 32); @@ -5018,7 +4947,7 @@ var sha512 = {}; return new Uint8Array(secretKey.subarray(32)); } exports2.extractPublicKeyFromSecretKey = extractPublicKeyFromSecretKey; - const L2 = new Float64Array([ + const L4 = new Float64Array([ 237, 211, 245, @@ -5052,7 +4981,7 @@ var sha512 = {}; 0, 16 ]); - function modL(r2, x2) { + function modL(r3, x2) { let carry; let i2; let j2; @@ -5060,7 +4989,7 @@ var sha512 = {}; for (i2 = 63; i2 >= 32; --i2) { carry = 0; for (j2 = i2 - 32, k2 = i2 - 12; j2 < k2; ++j2) { - x2[j2] += carry - 16 * x2[i2] * L2[j2 - (i2 - 32)]; + x2[j2] += carry - 16 * x2[i2] * L4[j2 - (i2 - 32)]; carry = Math.floor((x2[j2] + 128) / 256); x2[j2] -= carry * 256; } @@ -5069,45 +4998,45 @@ var sha512 = {}; } carry = 0; for (j2 = 0; j2 < 32; j2++) { - x2[j2] += carry - (x2[31] >> 4) * L2[j2]; + x2[j2] += carry - (x2[31] >> 4) * L4[j2]; carry = x2[j2] >> 8; x2[j2] &= 255; } for (j2 = 0; j2 < 32; j2++) { - x2[j2] -= carry * L2[j2]; + x2[j2] -= carry * L4[j2]; } for (i2 = 0; i2 < 32; i2++) { x2[i2 + 1] += x2[i2] >> 8; - r2[i2] = x2[i2] & 255; + r3[i2] = x2[i2] & 255; } } - function reduce(r2) { + function reduce(r3) { const x2 = new Float64Array(64); for (let i2 = 0; i2 < 64; i2++) { - x2[i2] = r2[i2]; + x2[i2] = r3[i2]; } for (let i2 = 0; i2 < 64; i2++) { - r2[i2] = 0; + r3[i2] = 0; } - modL(r2, x2); + modL(r3, x2); } function sign(secretKey, message) { const x2 = new Float64Array(64); - const p3 = [gf(), gf(), gf(), gf()]; - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; const signature = new Uint8Array(64); - signature.set(d3.subarray(32), 32); + signature.set(d5.subarray(32), 32); const hs2 = new sha512_1.SHA512(); hs2.update(signature.subarray(32)); hs2.update(message); - const r2 = hs2.digest(); + const r3 = hs2.digest(); hs2.clean(); - reduce(r2); - scalarbase(p3, r2); - pack(signature, p3); + reduce(r3); + scalarbase(p2, r3); + pack(signature, p2); hs2.reset(); hs2.update(signature.subarray(0, 32)); hs2.update(secretKey.subarray(32)); @@ -5115,25 +5044,25 @@ var sha512 = {}; const h4 = hs2.digest(); reduce(h4); for (let i2 = 0; i2 < 32; i2++) { - x2[i2] = r2[i2]; + x2[i2] = r3[i2]; } for (let i2 = 0; i2 < 32; i2++) { for (let j2 = 0; j2 < 32; j2++) { - x2[i2 + j2] += h4[i2] * d3[j2]; + x2[i2 + j2] += h4[i2] * d5[j2]; } } modL(signature.subarray(32), x2); return signature; } exports2.sign = sign; - function unpackneg(r2, p3) { - const t2 = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf(); - set25519(r2[2], gf1); - unpack25519(r2[1], p3); - square(num, r2[1]); + function unpackneg(r3, p2) { + const t2 = gf2(), chk = gf2(), num = gf2(), den = gf2(), den2 = gf2(), den4 = gf2(), den6 = gf2(); + set25519(r3[2], gf1); + unpack25519(r3[1], p2); + square(num, r3[1]); mul(den, num, D2); - sub(num, num, r2[2]); - add(den, r2[2], den); + sub(num, num, r3[2]); + add(den, r3[2], den); square(den2, den); square(den4, den2); mul(den6, den4, den2); @@ -5143,27 +5072,27 @@ var sha512 = {}; mul(t2, t2, num); mul(t2, t2, den); mul(t2, t2, den); - mul(r2[0], t2, den); - square(chk, r2[0]); + mul(r3[0], t2, den); + square(chk, r3[0]); mul(chk, chk, den); if (neq25519(chk, num)) { - mul(r2[0], r2[0], I2); + mul(r3[0], r3[0], I2); } - square(chk, r2[0]); + square(chk, r3[0]); mul(chk, chk, den); if (neq25519(chk, num)) { return -1; } - if (par25519(r2[0]) === p3[31] >> 7) { - sub(r2[0], gf0, r2[0]); + if (par25519(r3[0]) === p2[31] >> 7) { + sub(r3[0], gf0, r3[0]); } - mul(r2[3], r2[0], r2[1]); + mul(r3[3], r3[0], r3[1]); return 0; } function verify(publicKey, message, signature) { const t2 = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - const q2 = [gf(), gf(), gf(), gf()]; + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const q2 = [gf2(), gf2(), gf2(), gf2()]; if (signature.length !== exports2.SIGNATURE_LENGTH) { throw new Error(`ed25519: signature must be ${exports2.SIGNATURE_LENGTH} bytes`); } @@ -5176,10 +5105,10 @@ var sha512 = {}; hs2.update(message); const h4 = hs2.digest(); reduce(h4); - scalarmult(p3, q2, h4); + scalarmult(p2, q2, h4); scalarbase(q2, signature.subarray(32)); - edadd(p3, q2); - pack(t2, p3); + edadd(p2, q2); + pack(t2, p2); if (verify32(signature, t2)) { return false; } @@ -5187,29 +5116,29 @@ var sha512 = {}; } exports2.verify = verify; function convertPublicKeyToX25519(publicKey) { - let q2 = [gf(), gf(), gf(), gf()]; + let q2 = [gf2(), gf2(), gf2(), gf2()]; if (unpackneg(q2, publicKey)) { throw new Error("Ed25519: invalid public key"); } - let a3 = gf(); - let b3 = gf(); + let a3 = gf2(); + let b3 = gf2(); let y3 = q2[1]; add(a3, gf1, y3); sub(b3, gf1, y3); inv25519(b3, b3); mul(a3, a3, b3); - let z32 = new Uint8Array(32); - pack25519(z32, a3); - return z32; + let z2 = new Uint8Array(32); + pack25519(z2, a3); + return z2; } exports2.convertPublicKeyToX25519 = convertPublicKeyToX25519; function convertSecretKeyToX25519(secretKey) { - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const o2 = new Uint8Array(d3.subarray(0, 32)); - (0, wipe_12.wipe)(d3); + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const o2 = new Uint8Array(d5.subarray(0, 32)); + (0, wipe_12.wipe)(d5); return o2; } exports2.convertSecretKeyToX25519 = convertSecretKeyToX25519; @@ -5431,7 +5360,7 @@ class Decoder { } } or(decoder) { - return or$2(this, decoder); + return or$3(this, decoder); } } class ComposedDecoder { @@ -5439,7 +5368,7 @@ class ComposedDecoder { this.decoders = decoders; } or(decoder) { - return or$2(this, decoder); + return or$3(this, decoder); } decode(input) { const prefix = input[0]; @@ -5451,7 +5380,7 @@ class ComposedDecoder { } } } -const or$2 = (left, right) => new ComposedDecoder({ +const or$3 = (left, right) => new ComposedDecoder({ ...left.decoders || { [left.prefix]: left }, ...right.decoders || { [right.prefix]: right } }); @@ -5731,18 +5660,18 @@ const base64$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp base64urlpad }, Symbol.toStringTag, { value: "Module" })); const alphabet = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"); -const alphabetBytesToChars = alphabet.reduce((p3, c2, i2) => { - p3[i2] = c2; - return p3; +const alphabetBytesToChars = alphabet.reduce((p2, c2, i2) => { + p2[i2] = c2; + return p2; }, []); -const alphabetCharsToBytes = alphabet.reduce((p3, c2, i2) => { - p3[c2.codePointAt(0)] = i2; - return p3; +const alphabetCharsToBytes = alphabet.reduce((p2, c2, i2) => { + p2[c2.codePointAt(0)] = i2; + return p2; }, []); function encode(data) { - return data.reduce((p3, c2) => { - p3 += alphabetBytesToChars[c2]; - return p3; + return data.reduce((p2, c2) => { + p2 += alphabetBytesToChars[c2]; + return p2; }, ""); } function decode$1(str) { @@ -5866,7 +5795,7 @@ function encodeJWT(params) { function generateKeyPair(seed = random.randomBytes(KEY_PAIR_SEED_LENGTH)) { return ed25519.generateKeyPairFromSeed(seed); } -async function signJWT(sub, aud, ttl, keyPair, iat = cjs$4.fromMiliseconds(Date.now())) { +async function signJWT(sub, aud, ttl, keyPair, iat = cjs$3.fromMiliseconds(Date.now())) { const header = { alg: JWT_IRIDIUM_ALG, typ: JWT_IRIDIUM_TYP }; const iss = encodeIss(keyPair.publicKey); const exp = iat + ttl; @@ -5875,1334 +5804,2132 @@ async function signJWT(sub, aud, ttl, keyPair, iat = cjs$4.fromMiliseconds(Date. const signature = ed25519.sign(keyPair.secretKey, data); return encodeJWT({ header, payload, signature }); } -var chacha20poly1305 = {}; -var chacha = {}; -Object.defineProperty(chacha, "__esModule", { value: true }); -var binary_1 = binary; -var wipe_1$2 = wipe$1; -var ROUNDS = 20; -function core(out, input, key) { - var j0 = 1634760805; - var j1 = 857760878; - var j2 = 2036477234; - var j3 = 1797285236; - var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; - var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; - var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; - var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; - var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; - var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; - var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; - var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; - var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; - var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; - var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; - var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; - var x0 = j0; - var x1 = j1; - var x2 = j2; - var x3 = j3; - var x4 = j4; - var x5 = j5; - var x6 = j6; - var x7 = j7; - var x8 = j8; - var x9 = j9; - var x10 = j10; - var x11 = j11; - var x12 = j12; - var x13 = j13; - var x14 = j14; - var x15 = j15; - for (var i2 = 0; i2 < ROUNDS; i2 += 2) { - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 16 | x12 << 16; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 12 | x4 << 12; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 16 | x13 << 16; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 12 | x5 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 16 | x14 << 16; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 12 | x6 << 12; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 16 | x15 << 16; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 12 | x7 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 8 | x14 << 8; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 7 | x6 << 7; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 8 | x15 << 8; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 7 | x7 << 7; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 8 | x13 << 8; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 7 | x5 << 7; - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 8 | x12 << 8; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 7 | x4 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 16 | x15 << 16; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 12 | x5 << 12; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 16 | x12 << 16; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 12 | x6 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 16 | x13 << 16; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 12 | x7 << 12; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 16 | x14 << 16; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 12 | x4 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 8 | x13 << 8; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 7 | x7 << 7; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 8 | x14 << 8; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 7 | x4 << 7; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 8 | x12 << 8; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 7 | x6 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 8 | x15 << 8; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 7 | x5 << 7; - } - binary_1.writeUint32LE(x0 + j0 | 0, out, 0); - binary_1.writeUint32LE(x1 + j1 | 0, out, 4); - binary_1.writeUint32LE(x2 + j2 | 0, out, 8); - binary_1.writeUint32LE(x3 + j3 | 0, out, 12); - binary_1.writeUint32LE(x4 + j4 | 0, out, 16); - binary_1.writeUint32LE(x5 + j5 | 0, out, 20); - binary_1.writeUint32LE(x6 + j6 | 0, out, 24); - binary_1.writeUint32LE(x7 + j7 | 0, out, 28); - binary_1.writeUint32LE(x8 + j8 | 0, out, 32); - binary_1.writeUint32LE(x9 + j9 | 0, out, 36); - binary_1.writeUint32LE(x10 + j10 | 0, out, 40); - binary_1.writeUint32LE(x11 + j11 | 0, out, 44); - binary_1.writeUint32LE(x12 + j12 | 0, out, 48); - binary_1.writeUint32LE(x13 + j13 | 0, out, 52); - binary_1.writeUint32LE(x14 + j14 | 0, out, 56); - binary_1.writeUint32LE(x15 + j15 | 0, out, 60); -} -function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - if (key.length !== 32) { - throw new Error("ChaCha: key size must be 32 bytes"); - } - if (dst.length < src2.length) { - throw new Error("ChaCha: destination is shorter than source"); - } - var nc; - var counterLength; - if (nonceInplaceCounterLength === 0) { - if (nonce.length !== 8 && nonce.length !== 12) { - throw new Error("ChaCha nonce must be 8 or 12 bytes"); - } - nc = new Uint8Array(16); - counterLength = nc.length - nonce.length; - nc.set(nonce, counterLength); - } else { - if (nonce.length !== 16) { - throw new Error("ChaCha nonce with counter must be 16 bytes"); +var __spreadArray$3 = function(to2, from2, pack) { + for (var i2 = 0, l2 = from2.length, ar3; i2 < l2; i2++) { + if (ar3 || !(i2 in from2)) { + if (!ar3) + ar3 = Array.prototype.slice.call(from2, 0, i2); + ar3[i2] = from2[i2]; } - nc = nonce; - counterLength = nonceInplaceCounterLength; } - var block = new Uint8Array(64); - for (var i2 = 0; i2 < src2.length; i2 += 64) { - core(block, nc, key); - for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { - dst[j2] = src2[j2] ^ block[j2 - i2]; + return to2.concat(ar3 || Array.prototype.slice.call(from2)); +}; +var BrowserInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BrowserInfo2(name2, version2, os2) { + this.name = name2; + this.version = version2; + this.os = os2; + this.type = "browser"; } - incrementCounter(nc, 0, counterLength); - } - wipe_1$2.wipe(block); - if (nonceInplaceCounterLength === 0) { - wipe_1$2.wipe(nc); + return BrowserInfo2; + }() +); +var NodeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function NodeInfo2(version2) { + this.version = version2; + this.type = "node"; + this.name = "node"; + this.os = process.platform; + } + return NodeInfo2; + }() +); +var SearchBotDeviceInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function SearchBotDeviceInfo2(name2, version2, os2, bot) { + this.name = name2; + this.version = version2; + this.os = os2; + this.bot = bot; + this.type = "bot-device"; + } + return SearchBotDeviceInfo2; + }() +); +var BotInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BotInfo2() { + this.type = "bot"; + this.bot = true; + this.name = "bot"; + this.version = null; + this.os = null; + } + return BotInfo2; + }() +); +var ReactNativeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function ReactNativeInfo2() { + this.type = "react-native"; + this.name = "react-native"; + this.version = null; + this.os = null; + } + return ReactNativeInfo2; + }() +); +var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; +var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; +var REQUIRED_VERSION_PARTS = 3; +var userAgentRules = [ + ["aol", /AOLShield\/([0-9\._]+)/], + ["edge", /Edge\/([0-9\._]+)/], + ["edge-ios", /EdgiOS\/([0-9\._]+)/], + ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], + ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], + ["samsung", /SamsungBrowser\/([0-9\.]+)/], + ["silk", /\bSilk\/([0-9._-]+)\b/], + ["miui", /MiuiBrowser\/([0-9\.]+)$/], + ["beaker", /BeakerBrowser\/([0-9\.]+)/], + ["edge-chromium", /EdgA?\/([0-9\.]+)/], + [ + "chromium-webview", + /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ + ], + ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], + ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], + ["fxios", /FxiOS\/([0-9\.]+)/], + ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], + ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], + ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], + ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], + ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], + ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], + ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ["ie", /MSIE\s(7\.0)/], + ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], + ["android", /Android\s([0-9\.]+)/], + ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ["safari", /Version\/([0-9\._]+).*Safari/], + ["facebook", /FB[AS]V\/([0-9\.]+)/], + ["instagram", /Instagram\s([0-9\.]+)/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ["curl", /^curl\/([0-9\.]+)$/], + ["searchbot", SEARCHBOX_UA_REGEX] +]; +var operatingSystemRules = [ + ["iOS", /iP(hone|od|ad)/], + ["Android OS", /Android/], + ["BlackBerry OS", /BlackBerry|BB10/], + ["Windows Mobile", /IEMobile/], + ["Amazon OS", /Kindle/], + ["Windows 3.11", /Win16/], + ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], + ["Windows 98", /(Windows 98)|(Win98)/], + ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], + ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], + ["Windows Server 2003", /(Windows NT 5.2)/], + ["Windows Vista", /(Windows NT 6.0)/], + ["Windows 7", /(Windows NT 6.1)/], + ["Windows 8", /(Windows NT 6.2)/], + ["Windows 8.1", /(Windows NT 6.3)/], + ["Windows 10", /(Windows NT 10.0)/], + ["Windows ME", /Windows ME/], + ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], + ["Open BSD", /OpenBSD/], + ["Sun OS", /SunOS/], + ["Chrome OS", /CrOS/], + ["Linux", /(Linux)|(X11)/], + ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], + ["QNX", /QNX/], + ["BeOS", /BeOS/], + ["OS/2", /OS\/2/] +]; +function detect(userAgent) { + if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { + return new ReactNativeInfo(); } - return dst; -} -chacha.streamXOR = streamXOR; -function stream(key, nonce, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; + if (typeof navigator !== "undefined") { + return parseUserAgent(navigator.userAgent); } - wipe_1$2.wipe(dst); - return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); + return getNodeVersion(); } -chacha.stream = stream; -function incrementCounter(counter, pos, len) { - var carry = 1; - while (len--) { - carry = carry + (counter[pos] & 255) | 0; - counter[pos] = carry & 255; - carry >>>= 8; - pos++; +function matchUserAgent(ua2) { + return ua2 !== "" && userAgentRules.reduce(function(matched, _a2) { + var browser2 = _a2[0], regex = _a2[1]; + if (matched) { + return matched; + } + var uaMatch = regex.exec(ua2); + return !!uaMatch && [browser2, uaMatch]; + }, false); +} +function parseUserAgent(ua2) { + var matchedRule = matchUserAgent(ua2); + if (!matchedRule) { + return null; } - if (carry > 0) { - throw new Error("ChaCha: counter overflow"); + var name2 = matchedRule[0], match = matchedRule[1]; + if (name2 === "searchbot") { + return new BotInfo(); + } + var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); + if (versionParts) { + if (versionParts.length < REQUIRED_VERSION_PARTS) { + versionParts = __spreadArray$3(__spreadArray$3([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length)); + } + } else { + versionParts = []; + } + var version2 = versionParts.join("."); + var os2 = detectOS(ua2); + var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua2); + if (searchBotMatch && searchBotMatch[1]) { + return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); } + return new BrowserInfo(name2, version2, os2); } -var poly1305 = {}; -var constantTime = {}; -Object.defineProperty(constantTime, "__esModule", { value: true }); -function select(subject, resultIfOne, resultIfZero) { - return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; +function detectOS(ua2) { + for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { + var _a2 = operatingSystemRules[ii], os2 = _a2[0], regex = _a2[1]; + var match = regex.exec(ua2); + if (match) { + return os2; + } + } + return null; } -constantTime.select = select; -function lessOrEqual(a3, b3) { - return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; +function getNodeVersion() { + var isNode = typeof process !== "undefined" && process.version; + return isNode ? new NodeInfo(process.version.slice(1)) : null; } -constantTime.lessOrEqual = lessOrEqual; -function compare(a3, b3) { - if (a3.length !== b3.length) { - return 0; +function createVersionParts(count) { + var output = []; + for (var ii = 0; ii < count; ii++) { + output.push("0"); } - var result = 0; - for (var i2 = 0; i2 < a3.length; i2++) { - result |= a3[i2] ^ b3[i2]; + return output; +} +var cjs$2 = {}; +Object.defineProperty(cjs$2, "__esModule", { value: true }); +cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; +function getFromWindow(name2) { + let res = void 0; + if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { + res = window[name2]; } - return 1 & result - 1 >>> 8; + return res; } -constantTime.compare = compare; -function equal(a3, b3) { - if (a3.length === 0 || b3.length === 0) { - return false; +cjs$2.getFromWindow = getFromWindow; +function getFromWindowOrThrow(name2) { + const res = getFromWindow(name2); + if (!res) { + throw new Error(`${name2} is not defined in Window`); } - return compare(a3, b3) !== 0; + return res; } -constantTime.equal = equal; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var constant_time_12 = constantTime; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 16; - var Poly1305 = ( - /** @class */ - function() { - function Poly13052(key) { - this.digestLength = exports2.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 = false; - var t0 = key[0] | key[1] << 8; - this._r[0] = t0 & 8191; - var t1 = key[2] | key[3] << 8; - this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; - var t2 = key[4] | key[5] << 8; - this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; - var t3 = key[6] | key[7] << 8; - this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; - var t4 = key[8] | key[9] << 8; - this._r[4] = (t3 >>> 4 | t4 << 12) & 255; - this._r[5] = t4 >>> 1 & 8190; - var t5 = key[10] | key[11] << 8; - this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; - var t6 = key[12] | key[13] << 8; - this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; - var t7 = key[14] | key[15] << 8; - this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; - this._r[9] = t7 >>> 5 & 127; - this._pad[0] = key[16] | key[17] << 8; - this._pad[1] = key[18] | key[19] << 8; - this._pad[2] = key[20] | key[21] << 8; - this._pad[3] = key[22] | key[23] << 8; - this._pad[4] = key[24] | key[25] << 8; - this._pad[5] = key[26] | key[27] << 8; - this._pad[6] = key[28] | key[29] << 8; - this._pad[7] = key[30] | key[31] << 8; - } - Poly13052.prototype._blocks = function(m2, mpos, bytes) { - var hibit = this._fin ? 0 : 1 << 11; - var h0 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; - var r0 = this._r[0], r1 = this._r[1], r2 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; - while (bytes >= 16) { - var t0 = m2[mpos + 0] | m2[mpos + 1] << 8; - h0 += t0 & 8191; - var t1 = m2[mpos + 2] | m2[mpos + 3] << 8; - h1 += (t0 >>> 13 | t1 << 3) & 8191; - var t2 = m2[mpos + 4] | m2[mpos + 5] << 8; - h22 += (t1 >>> 10 | t2 << 6) & 8191; - var t3 = m2[mpos + 6] | m2[mpos + 7] << 8; - h32 += (t2 >>> 7 | t3 << 9) & 8191; - var t4 = m2[mpos + 8] | m2[mpos + 9] << 8; - h4 += (t3 >>> 4 | t4 << 12) & 8191; - h5 += t4 >>> 1 & 8191; - var t5 = m2[mpos + 10] | m2[mpos + 11] << 8; - h6 += (t4 >>> 14 | t5 << 2) & 8191; - var t6 = m2[mpos + 12] | m2[mpos + 13] << 8; - h7 += (t5 >>> 11 | t6 << 5) & 8191; - var t7 = m2[mpos + 14] | m2[mpos + 15] << 8; - h8 += (t6 >>> 8 | t7 << 8) & 8191; - h9 += t7 >>> 5 | hibit; - var c2 = 0; - var d0 = c2; - d0 += h0 * r0; - d0 += h1 * (5 * r9); - d0 += h22 * (5 * r8); - d0 += h32 * (5 * r7); - d0 += h4 * (5 * r6); - c2 = d0 >>> 13; - d0 &= 8191; - d0 += h5 * (5 * r5); - d0 += h6 * (5 * r4); - d0 += h7 * (5 * r3); - d0 += h8 * (5 * r2); - d0 += h9 * (5 * r1); - c2 += d0 >>> 13; - d0 &= 8191; - var d1 = c2; - d1 += h0 * r1; - d1 += h1 * r0; - d1 += h22 * (5 * r9); - d1 += h32 * (5 * r8); - d1 += h4 * (5 * r7); - c2 = d1 >>> 13; - d1 &= 8191; - d1 += h5 * (5 * r6); - d1 += h6 * (5 * r5); - d1 += h7 * (5 * r4); - d1 += h8 * (5 * r3); - d1 += h9 * (5 * r2); - c2 += d1 >>> 13; - d1 &= 8191; - var d22 = c2; - d22 += h0 * r2; - d22 += h1 * r1; - d22 += h22 * r0; - d22 += h32 * (5 * r9); - d22 += h4 * (5 * r8); - c2 = d22 >>> 13; - d22 &= 8191; - d22 += h5 * (5 * r7); - d22 += h6 * (5 * r6); - d22 += h7 * (5 * r5); - d22 += h8 * (5 * r4); - d22 += h9 * (5 * r3); - c2 += d22 >>> 13; - d22 &= 8191; - var d3 = c2; - d3 += h0 * r3; - d3 += h1 * r2; - d3 += h22 * r1; - d3 += h32 * r0; - d3 += h4 * (5 * r9); - c2 = d3 >>> 13; - d3 &= 8191; - d3 += h5 * (5 * r8); - d3 += h6 * (5 * r7); - d3 += h7 * (5 * r6); - d3 += h8 * (5 * r5); - d3 += h9 * (5 * r4); - c2 += d3 >>> 13; - d3 &= 8191; - var d4 = c2; - d4 += h0 * r4; - d4 += h1 * r3; - d4 += h22 * r2; - d4 += h32 * r1; - d4 += h4 * r0; - c2 = d4 >>> 13; - d4 &= 8191; - d4 += h5 * (5 * r9); - d4 += h6 * (5 * r8); - d4 += h7 * (5 * r7); - d4 += h8 * (5 * r6); - d4 += h9 * (5 * r5); - c2 += d4 >>> 13; - d4 &= 8191; - var d5 = c2; - d5 += h0 * r5; - d5 += h1 * r4; - d5 += h22 * r3; - d5 += h32 * r2; - d5 += h4 * r1; - c2 = d5 >>> 13; - d5 &= 8191; - d5 += h5 * r0; - d5 += h6 * (5 * r9); - d5 += h7 * (5 * r8); - d5 += h8 * (5 * r7); - d5 += h9 * (5 * r6); - c2 += d5 >>> 13; - d5 &= 8191; - var d6 = c2; - d6 += h0 * r6; - d6 += h1 * r5; - d6 += h22 * r4; - d6 += h32 * r3; - d6 += h4 * r2; - c2 = d6 >>> 13; - d6 &= 8191; - d6 += h5 * r1; - d6 += h6 * r0; - d6 += h7 * (5 * r9); - d6 += h8 * (5 * r8); - d6 += h9 * (5 * r7); - c2 += d6 >>> 13; - d6 &= 8191; - var d7 = c2; - d7 += h0 * r7; - d7 += h1 * r6; - d7 += h22 * r5; - d7 += h32 * r4; - d7 += h4 * r3; - c2 = d7 >>> 13; - d7 &= 8191; - d7 += h5 * r2; - d7 += h6 * r1; - d7 += h7 * r0; - d7 += h8 * (5 * r9); - d7 += h9 * (5 * r8); - c2 += d7 >>> 13; - d7 &= 8191; - var d8 = c2; - d8 += h0 * r8; - d8 += h1 * r7; - d8 += h22 * r6; - d8 += h32 * r5; - d8 += h4 * r4; - c2 = d8 >>> 13; - d8 &= 8191; - d8 += h5 * r3; - d8 += h6 * r2; - d8 += h7 * r1; - d8 += h8 * r0; - d8 += h9 * (5 * r9); - c2 += d8 >>> 13; - d8 &= 8191; - var d9 = c2; - d9 += h0 * r9; - d9 += h1 * r8; - d9 += h22 * r7; - d9 += h32 * r6; - d9 += h4 * r5; - c2 = d9 >>> 13; - d9 &= 8191; - d9 += h5 * r4; - d9 += h6 * r3; - d9 += h7 * r2; - d9 += h8 * r1; - d9 += h9 * r0; - c2 += d9 >>> 13; - d9 &= 8191; - c2 = (c2 << 2) + c2 | 0; - c2 = c2 + d0 | 0; - d0 = c2 & 8191; - c2 = c2 >>> 13; - d1 += c2; - h0 = d0; - h1 = d1; - h22 = d22; - h32 = d3; - h4 = d4; - h5 = d5; - h6 = d6; - h7 = d7; - h8 = d8; - h9 = d9; - mpos += 16; - bytes -= 16; - } - this._h[0] = h0; - this._h[1] = h1; - this._h[2] = h22; - this._h[3] = h32; - this._h[4] = h4; - this._h[5] = h5; - this._h[6] = h6; - this._h[7] = h7; - this._h[8] = h8; - this._h[9] = h9; - }; - Poly13052.prototype.finish = function(mac, macpos) { - if (macpos === void 0) { - macpos = 0; - } - var g3 = new Uint16Array(10); - var c2; - var mask; - var f2; - var i2; - if (this._leftover) { - i2 = this._leftover; - this._buffer[i2++] = 1; - for (; i2 < 16; i2++) { - this._buffer[i2] = 0; +cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; +function getDocumentOrThrow() { + return getFromWindowOrThrow("document"); +} +cjs$2.getDocumentOrThrow = getDocumentOrThrow; +function getDocument() { + return getFromWindow("document"); +} +var getDocument_1 = cjs$2.getDocument = getDocument; +function getNavigatorOrThrow() { + return getFromWindowOrThrow("navigator"); +} +cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; +function getNavigator() { + return getFromWindow("navigator"); +} +var getNavigator_1 = cjs$2.getNavigator = getNavigator; +function getLocationOrThrow() { + return getFromWindowOrThrow("location"); +} +cjs$2.getLocationOrThrow = getLocationOrThrow; +function getLocation() { + return getFromWindow("location"); +} +var getLocation_1 = cjs$2.getLocation = getLocation; +function getCryptoOrThrow() { + return getFromWindowOrThrow("crypto"); +} +cjs$2.getCryptoOrThrow = getCryptoOrThrow; +function getCrypto() { + return getFromWindow("crypto"); +} +cjs$2.getCrypto = getCrypto; +function getLocalStorageOrThrow() { + return getFromWindowOrThrow("localStorage"); +} +cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; +function getLocalStorage() { + return getFromWindow("localStorage"); +} +cjs$2.getLocalStorage = getLocalStorage; +var cjs$1 = {}; +Object.defineProperty(cjs$1, "__esModule", { value: true }); +var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; +const window_getters_1 = cjs$2; +function getWindowMetadata() { + let doc; + let loc; + try { + doc = window_getters_1.getDocumentOrThrow(); + loc = window_getters_1.getLocationOrThrow(); + } catch (e2) { + return null; + } + function getIcons() { + const links = doc.getElementsByTagName("link"); + const icons2 = []; + for (let i2 = 0; i2 < links.length; i2++) { + const link = links[i2]; + const rel = link.getAttribute("rel"); + if (rel) { + if (rel.toLowerCase().indexOf("icon") > -1) { + const href = link.getAttribute("href"); + if (href) { + if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { + let absoluteHref = loc.protocol + "//" + loc.host; + if (href.indexOf("/") === 0) { + absoluteHref += href; + } else { + const path = loc.pathname.split("/"); + path.pop(); + const finalPath = path.join("/"); + absoluteHref += finalPath + "/" + href; + } + icons2.push(absoluteHref); + } else if (href.indexOf("//") === 0) { + const absoluteUrl = loc.protocol + href; + icons2.push(absoluteUrl); + } else { + icons2.push(href); + } } - this._fin = 1; - this._blocks(this._buffer, 0, 16); } - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - for (i2 = 2; i2 < 10; i2++) { - this._h[i2] += c2; - c2 = this._h[i2] >>> 13; - this._h[i2] &= 8191; + } + } + return icons2; + } + function getWindowMetadataOfAny(...args) { + const metaTags = doc.getElementsByTagName("meta"); + for (let i2 = 0; i2 < metaTags.length; i2++) { + const tag = metaTags[i2]; + const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { + if (attr) { + return args.includes(attr); } - this._h[0] += c2 * 5; - c2 = this._h[0] >>> 13; - this._h[0] &= 8191; - this._h[1] += c2; - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - this._h[2] += c2; - g3[0] = this._h[0] + 5; - c2 = g3[0] >>> 13; - g3[0] &= 8191; - for (i2 = 1; i2 < 10; i2++) { - g3[i2] = this._h[i2] + c2; - c2 = g3[i2] >>> 13; - g3[i2] &= 8191; - } - g3[9] -= 1 << 13; - mask = (c2 ^ 1) - 1; - for (i2 = 0; i2 < 10; i2++) { - g3[i2] &= mask; - } - mask = ~mask; - for (i2 = 0; i2 < 10; i2++) { - this._h[i2] = this._h[i2] & mask | g3[i2]; - } - 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; - f2 = this._h[0] + this._pad[0]; - this._h[0] = f2 & 65535; - for (i2 = 1; i2 < 8; i2++) { - f2 = (this._h[i2] + this._pad[i2] | 0) + (f2 >>> 16) | 0; - this._h[i2] = f2 & 65535; - } - mac[macpos + 0] = this._h[0] >>> 0; - mac[macpos + 1] = this._h[0] >>> 8; - mac[macpos + 2] = this._h[1] >>> 0; - mac[macpos + 3] = this._h[1] >>> 8; - mac[macpos + 4] = this._h[2] >>> 0; - mac[macpos + 5] = this._h[2] >>> 8; - mac[macpos + 6] = this._h[3] >>> 0; - mac[macpos + 7] = this._h[3] >>> 8; - mac[macpos + 8] = this._h[4] >>> 0; - mac[macpos + 9] = this._h[4] >>> 8; - mac[macpos + 10] = this._h[5] >>> 0; - mac[macpos + 11] = this._h[5] >>> 8; - mac[macpos + 12] = this._h[6] >>> 0; - mac[macpos + 13] = this._h[6] >>> 8; - mac[macpos + 14] = this._h[7] >>> 0; - mac[macpos + 15] = this._h[7] >>> 8; - this._finished = true; - return this; - }; - Poly13052.prototype.update = function(m2) { - var mpos = 0; - var bytes = m2.length; - var want; - if (this._leftover) { - want = 16 - this._leftover; - if (want > bytes) { - want = bytes; - } - for (var i2 = 0; i2 < want; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; - } - bytes -= want; - mpos += want; - this._leftover += want; - if (this._leftover < 16) { - return this; - } - this._blocks(this._buffer, 0, 16); - this._leftover = 0; - } - if (bytes >= 16) { - want = bytes - bytes % 16; - this._blocks(m2, mpos, want); - mpos += want; - bytes -= want; - } - if (bytes) { - for (var i2 = 0; i2 < bytes; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; - } - this._leftover += bytes; - } - return this; - }; - Poly13052.prototype.digest = function() { - if (this._finished) { - throw new Error("Poly1305 was finished"); + return false; + }); + if (attributes.length && attributes) { + const content = tag.getAttribute("content"); + if (content) { + return content; } - var mac = new Uint8Array(16); - this.finish(mac); - return mac; - }; - Poly13052.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._r); - wipe_12.wipe(this._h); - wipe_12.wipe(this._pad); - this._leftover = 0; - this._fin = 0; - this._finished = true; - return this; - }; - return Poly13052; - }() - ); - exports2.Poly1305 = Poly1305; - function oneTimeAuth(key, data) { - var h4 = new Poly1305(key); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; + } + } + return ""; } - exports2.oneTimeAuth = oneTimeAuth; - function equal2(a3, b3) { - if (a3.length !== exports2.DIGEST_LENGTH || b3.length !== exports2.DIGEST_LENGTH) { - return false; + function getName() { + let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); + if (!name3) { + name3 = doc.title; } - return constant_time_12.equal(a3, b3); + return name3; } - exports2.equal = equal2; -})(poly1305); -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var chacha_1 = chacha; - var poly1305_1 = poly1305; - var wipe_12 = wipe$1; - var binary_12 = binary; - var constant_time_12 = constantTime; - exports2.KEY_LENGTH = 32; - exports2.NONCE_LENGTH = 12; - exports2.TAG_LENGTH = 16; - var ZEROS = new Uint8Array(16); - var ChaCha20Poly1305 = ( - /** @class */ - function() { - function ChaCha20Poly13052(key) { - this.nonceLength = exports2.NONCE_LENGTH; - this.tagLength = exports2.TAG_LENGTH; - if (key.length !== exports2.KEY_LENGTH) { - throw new Error("ChaCha20Poly1305 needs 32-byte key"); - } - this._key = new Uint8Array(key); + function getDescription() { + const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); + return description3; + } + const name2 = getName(); + const description2 = getDescription(); + const url = loc.origin; + const icons = getIcons(); + const meta = { + description: description2, + url, + icons, + name: name2 + }; + return meta; +} +getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; +var queryString = {}; +var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); +var token = "%[a-f0-9]{2}"; +var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); +var multiMatcher = new RegExp("(" + token + ")+", "gi"); +function decodeComponents(components, split) { + try { + return [decodeURIComponent(components.join(""))]; + } catch (err) { + } + if (components.length === 1) { + return components; + } + split = split || 1; + var left = components.slice(0, split); + var right = components.slice(split); + return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); +} +function decode(input) { + try { + return decodeURIComponent(input); + } catch (err) { + var tokens = input.match(singleMatcher) || []; + for (var i2 = 1; i2 < tokens.length; i2++) { + input = decodeComponents(tokens, i2).join(""); + tokens = input.match(singleMatcher) || []; + } + return input; + } +} +function customDecodeURIComponent(input) { + var replaceMap = { + "%FE%FF": "��", + "%FF%FE": "��" + }; + var match = multiMatcher.exec(input); + while (match) { + try { + replaceMap[match[0]] = decodeURIComponent(match[0]); + } catch (err) { + var result = decode(match[0]); + if (result !== match[0]) { + replaceMap[match[0]] = result; } - ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var resultLength = plaintext.length + this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); - } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, plaintext, result, 4); - this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - if (sealed.length < this.tagLength) { - return null; - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var calculatedTag = new Uint8Array(this.tagLength); - this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); - if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { - return null; - } - var resultLength = sealed.length - this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); - } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.clean = function() { - wipe_12.wipe(this._key); - return this; - }; - ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { - var h4 = new poly1305_1.Poly1305(authKey); - if (associatedData) { - h4.update(associatedData); - if (associatedData.length % 16 > 0) { - h4.update(ZEROS.subarray(associatedData.length % 16)); - } - } - h4.update(ciphertext); - if (ciphertext.length % 16 > 0) { - h4.update(ZEROS.subarray(ciphertext.length % 16)); - } - var length = new Uint8Array(8); - if (associatedData) { - binary_12.writeUint64LE(associatedData.length, length); - } - h4.update(length); - binary_12.writeUint64LE(ciphertext.length, length); - h4.update(length); - var tag = h4.digest(); - for (var i2 = 0; i2 < tag.length; i2++) { - tagOut[i2] = tag[i2]; - } - h4.clean(); - wipe_12.wipe(tag); - wipe_12.wipe(length); - }; - return ChaCha20Poly13052; - }() - ); - exports2.ChaCha20Poly1305 = ChaCha20Poly1305; -})(chacha20poly1305); -var hkdf = {}; -var hmac$1 = {}; -var hash = {}; -Object.defineProperty(hash, "__esModule", { value: true }); -function isSerializableHash(h4) { - return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; -} -hash.isSerializableHash = isSerializableHash; -Object.defineProperty(hmac$1, "__esModule", { value: true }); -var hash_1 = hash; -var constant_time_1 = constantTime; -var wipe_1$1 = wipe$1; -var HMAC = ( - /** @class */ - function() { - function HMAC2(hash2, key) { - this._finished = false; - this._inner = new hash2(); - this._outer = new hash2(); - this.blockSize = this._outer.blockSize; - this.digestLength = this._outer.digestLength; - var pad = new Uint8Array(this.blockSize); - if (key.length > this.blockSize) { - this._inner.update(key).finish(pad).clean(); - } else { - pad.set(key); - } - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54; - } - this._inner.update(pad); - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54 ^ 92; - } - this._outer.update(pad); - if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { - this._innerKeyedState = this._inner.saveState(); - this._outerKeyedState = this._outer.saveState(); - } - wipe_1$1.wipe(pad); } - HMAC2.prototype.reset = function() { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); - } - this._inner.restoreState(this._innerKeyedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.clean = function() { - if (hash_1.isSerializableHash(this._inner)) { - this._inner.cleanSavedState(this._innerKeyedState); - } - if (hash_1.isSerializableHash(this._outer)) { - this._outer.cleanSavedState(this._outerKeyedState); - } - this._inner.clean(); - this._outer.clean(); - }; - HMAC2.prototype.update = function(data) { - this._inner.update(data); - return this; - }; - HMAC2.prototype.finish = function(out) { - if (this._finished) { - this._outer.finish(out); - return this; - } - this._inner.finish(out); - this._outer.update(out.subarray(0, this.digestLength)).finish(out); - this._finished = true; - return this; - }; - HMAC2.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - HMAC2.prototype.saveState = function() { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't saveState() because hash doesn't implement it"); - } - return this._inner.saveState(); - }; - HMAC2.prototype.restoreState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't restoreState() because hash doesn't implement it"); - } - this._inner.restoreState(savedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.cleanSavedState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); - } - this._inner.cleanSavedState(savedState); - }; - return HMAC2; - }() -); -hmac$1.HMAC = HMAC; -function hmac(hash2, key, data) { - var h4 = new HMAC(hash2, key); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; + match = multiMatcher.exec(input); + } + replaceMap["%C2"] = "�"; + var entries = Object.keys(replaceMap); + for (var i2 = 0; i2 < entries.length; i2++) { + var key = entries[i2]; + input = input.replace(new RegExp(key, "g"), replaceMap[key]); + } + return input; } -hmac$1.hmac = hmac; -hmac$1.equal = constant_time_1.equal; -Object.defineProperty(hkdf, "__esModule", { value: true }); -var hmac_1 = hmac$1; -var wipe_1 = wipe$1; -var HKDF = ( - /** @class */ - function() { - function HKDF2(hash2, key, salt, info) { - if (salt === void 0) { - salt = new Uint8Array(0); - } - this._counter = new Uint8Array(1); - this._hash = hash2; - this._info = info; - var okm = hmac_1.hmac(this._hash, salt, key); - this._hmac = new hmac_1.HMAC(hash2, okm); - this._buffer = new Uint8Array(this._hmac.digestLength); - this._bufpos = this._buffer.length; +var decodeUriComponent = function(encodedURI) { + if (typeof encodedURI !== "string") { + throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + } + try { + encodedURI = encodedURI.replace(/\+/g, " "); + return decodeURIComponent(encodedURI); + } catch (err) { + return customDecodeURIComponent(encodedURI); + } +}; +var splitOnFirst = (string2, separator) => { + if (!(typeof string2 === "string" && typeof separator === "string")) { + throw new TypeError("Expected the arguments to be of type `string`"); + } + if (separator === "") { + return [string2]; + } + const separatorIndex = string2.indexOf(separator); + if (separatorIndex === -1) { + return [string2]; + } + return [ + string2.slice(0, separatorIndex), + string2.slice(separatorIndex + separator.length) + ]; +}; +var filterObj = function(obj, predicate) { + var ret = {}; + var keys2 = Object.keys(obj); + var isArr = Array.isArray(predicate); + for (var i2 = 0; i2 < keys2.length; i2++) { + var key = keys2[i2]; + var val = obj[key]; + if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { + ret[key] = val; } - HKDF2.prototype._fillBuffer = function() { - this._counter[0]++; - var ctr = this._counter[0]; - if (ctr === 0) { - throw new Error("hkdf: cannot expand more"); - } - this._hmac.reset(); - if (ctr > 1) { - this._hmac.update(this._buffer); - } - if (this._info) { - this._hmac.update(this._info); - } - this._hmac.update(this._counter); - this._hmac.finish(this._buffer); - this._bufpos = 0; - }; - HKDF2.prototype.expand = function(length) { - var out = new Uint8Array(length); - for (var i2 = 0; i2 < out.length; i2++) { - if (this._bufpos === this._buffer.length) { - this._fillBuffer(); - } - out[i2] = this._buffer[this._bufpos++]; - } - return out; - }; - HKDF2.prototype.clean = function() { - this._hmac.clean(); - wipe_1.wipe(this._buffer); - wipe_1.wipe(this._counter); - this._bufpos = 0; - }; - return HKDF2; - }() -); -var HKDF_1 = hkdf.HKDF = HKDF; -var sha256 = {}; + } + return ret; +}; (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var binary_12 = binary; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 32; - exports2.BLOCK_SIZE = 64; - var SHA256 = ( - /** @class */ - function() { - function SHA2562() { - this.digestLength = exports2.DIGEST_LENGTH; - this.blockSize = exports2.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 = false; - this.reset(); - } - SHA2562.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; - }; - SHA2562.prototype.reset = function() { - this._initState(); - this._bufferLength = 0; - this._bytesHashed = 0; - this._finished = false; - return this; - }; - SHA2562.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._temp); - this.reset(); - }; - SHA2562.prototype.update = function(data, dataLength) { - if (dataLength === void 0) { - dataLength = data.length; - } - if (this._finished) { - throw new Error("SHA256: can't update because hash was finished."); - } - var dataPos = 0; - this._bytesHashed += dataLength; - if (this._bufferLength > 0) { - while (this._bufferLength < this.blockSize && dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; + const strictUriEncode$1 = strictUriEncode; + const decodeComponent = decodeUriComponent; + const splitOnFirst$1 = splitOnFirst; + const filterObject = filterObj; + const isNullOrUndefined = (value) => value === null || value === void 0; + const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); + function encoderForArrayFormat(options) { + switch (options.arrayFormat) { + case "index": + return (key) => (result, value) => { + const index = result.length; + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; } - if (this._bufferLength === this.blockSize) { - hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); - this._bufferLength = 0; + if (value === null) { + return [...result, [encode2(key, options), "[", index, "]"].join("")]; } - } - if (dataLength >= this.blockSize) { - dataPos = hashBlocks(this._temp, this._state, data, dataPos, dataLength); - dataLength %= this.blockSize; - } - while (dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - return this; - }; - SHA2562.prototype.finish = function(out) { - if (!this._finished) { - var bytesHashed = this._bytesHashed; - var left = this._bufferLength; - var bitLenHi = bytesHashed / 536870912 | 0; - var bitLenLo = bytesHashed << 3; - var padLength = bytesHashed % 64 < 56 ? 64 : 128; - this._buffer[left] = 128; - for (var i2 = left + 1; i2 < padLength - 8; i2++) { - this._buffer[i2] = 0; + return [ + ...result, + [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") + ]; + }; + case "bracket": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; } - binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); - binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); - hashBlocks(this._temp, this._state, this._buffer, 0, padLength); - this._finished = true; - } - for (var i2 = 0; i2 < this.digestLength / 4; i2++) { - binary_12.writeUint32BE(this._state[i2], out, i2 * 4); - } - return this; - }; - SHA2562.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - SHA2562.prototype.saveState = function() { - if (this._finished) { - throw new Error("SHA256: cannot save finished state"); - } - return { - state: new Int32Array(this._state), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed + if (value === null) { + return [...result, [encode2(key, options), "[]"].join("")]; + } + return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; + }; + case "colon-list-separator": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), ":list="].join("")]; + } + return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; + }; + case "comma": + case "separator": + case "bracket-separator": { + const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + value = value === null ? "" : value; + if (result.length === 0) { + return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; + } + return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; }; - }; - SHA2562.prototype.restoreState = function(savedState) { - this._state.set(savedState.state); - this._bufferLength = savedState.bufferLength; - if (savedState.buffer) { - this._buffer.set(savedState.buffer); - } - this._bytesHashed = savedState.bytesHashed; - this._finished = false; - return this; - }; - SHA2562.prototype.cleanSavedState = function(savedState) { - wipe_12.wipe(savedState.state); - if (savedState.buffer) { - wipe_12.wipe(savedState.buffer); - } - savedState.bufferLength = 0; - savedState.bytesHashed = 0; - }; - return SHA2562; - }() - ); - exports2.SHA256 = SHA256; - var K2 = 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 hashBlocks(w3, v3, p3, pos, len) { - while (len >= 64) { - var a3 = v3[0]; - var b3 = v3[1]; - var c2 = v3[2]; - var d3 = v3[3]; - var e = v3[4]; - var f2 = v3[5]; - var g3 = v3[6]; - var h4 = v3[7]; - for (var i2 = 0; i2 < 16; i2++) { - var j2 = pos + i2 * 4; - w3[i2] = binary_12.readUint32BE(p3, j2); - } - for (var i2 = 16; i2 < 64; i2++) { - var u3 = w3[i2 - 2]; - var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; - u3 = w3[i2 - 15]; - var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; - w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); } - for (var i2 = 0; i2 < 64; i2++) { - var t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f2 ^ ~e & g3) | 0) + (h4 + (K2[i2] + w3[i2] | 0) | 0) | 0; - var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; - h4 = g3; - g3 = f2; - f2 = e; - e = d3 + t1 | 0; - d3 = c2; - c2 = b3; - b3 = a3; - a3 = t1 + t2 | 0; - } - v3[0] += a3; - v3[1] += b3; - v3[2] += c2; - v3[3] += d3; - v3[4] += e; - v3[5] += f2; - v3[6] += g3; - v3[7] += h4; - pos += 64; - len -= 64; + default: + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, encode2(key, options)]; + } + return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; + }; } - return pos; } - function hash2(data) { - var h4 = new SHA256(); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; + function parserForArrayFormat(options) { + let result; + switch (options.arrayFormat) { + case "index": + return (key, value, accumulator) => { + result = /\[(\d*)\]$/.exec(key); + key = key.replace(/\[\d*\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = {}; + } + accumulator[key][result[1]] = value; + }; + case "bracket": + return (key, value, accumulator) => { + result = /(\[\])$/.exec(key); + key = key.replace(/\[\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "colon-list-separator": + return (key, value, accumulator) => { + result = /(:list)$/.exec(key); + key = key.replace(/:list$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "comma": + case "separator": + return (key, value, accumulator) => { + const isArray2 = typeof value === "string" && value.includes(options.arrayFormatSeparator); + const isEncodedArray = typeof value === "string" && !isArray2 && decode2(value, options).includes(options.arrayFormatSeparator); + value = isEncodedArray ? decode2(value, options) : value; + const newValue = isArray2 || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); + accumulator[key] = newValue; + }; + case "bracket-separator": + return (key, value, accumulator) => { + const isArray2 = /(\[\])$/.test(key); + key = key.replace(/\[\]$/, ""); + if (!isArray2) { + accumulator[key] = value ? decode2(value, options) : value; + return; + } + const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); + if (accumulator[key] === void 0) { + accumulator[key] = arrayValue; + return; + } + accumulator[key] = [].concat(accumulator[key], arrayValue); + }; + default: + return (key, value, accumulator) => { + if (accumulator[key] === void 0) { + accumulator[key] = value; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + } } - exports2.hash = hash2; -})(sha256); -var x25519 = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.sharedKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.scalarMultBase = exports2.scalarMult = exports2.SHARED_KEY_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = void 0; - const random_1 = random; - const wipe_12 = wipe$1; - exports2.PUBLIC_KEY_LENGTH = 32; - exports2.SECRET_KEY_LENGTH = 32; - exports2.SHARED_KEY_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); - if (init) { - for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; - } + function validateArrayFormatSeparator(value) { + if (typeof value !== "string" || value.length !== 1) { + throw new TypeError("arrayFormatSeparator must be single character string"); } - return r2; } - const _9 = new Uint8Array(32); - _9[0] = 9; - const _121665 = gf([56129, 1]); - function car25519(o2) { - let c2 = 1; - for (let i2 = 0; i2 < 16; i2++) { - let v3 = o2[i2] + c2 + 65535; - c2 = Math.floor(v3 / 65536); - o2[i2] = v3 - c2 * 65536; + function encode2(value, options) { + if (options.encode) { + return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); } - o2[0] += c2 - 1 + 37 * (c2 - 1); + return value; } - function sel25519(p3, q2, b3) { - const c2 = ~(b3 - 1); - for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; - q2[i2] ^= t2; + function decode2(value, options) { + if (options.decode) { + return decodeComponent(value); } + return value; } - function pack25519(o2, n3) { - const m2 = gf(); - const t2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; + function keysSorter(input) { + if (Array.isArray(input)) { + return input.sort(); } - car25519(t2); - car25519(t2); - car25519(t2); - for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; - for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; - } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); + if (typeof input === "object") { + return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); } - for (let i2 = 0; i2 < 16; i2++) { - o2[2 * i2] = t2[i2] & 255; - o2[2 * i2 + 1] = t2[i2] >> 8; + return input; + } + function removeHash(input) { + const hashStart = input.indexOf("#"); + if (hashStart !== -1) { + input = input.slice(0, hashStart); } + return input; } - function unpack25519(o2, n3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); + function getHash(url) { + let hash2 = ""; + const hashStart = url.indexOf("#"); + if (hashStart !== -1) { + hash2 = url.slice(hashStart); } - o2[15] &= 32767; + return hash2; } - function add(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] + b3[i2]; + function extract(input) { + input = removeHash(input); + const queryStart = input.indexOf("?"); + if (queryStart === -1) { + return ""; } + return input.slice(queryStart + 1); } - function sub(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] - b3[i2]; + function parseValue(value, options) { + if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { + value = Number(value); + } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { + value = value.toLowerCase() === "true"; } + return value; } - function mul(o2, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; - v3 = a3[0]; - t0 += v3 * b0; - t1 += v3 * b1; - t2 += v3 * b22; - t3 += v3 * b32; - t4 += v3 * b4; - t5 += v3 * b5; - t6 += v3 * b6; - t7 += v3 * b7; - t8 += v3 * b8; - t9 += v3 * b9; - t10 += v3 * b10; - t11 += v3 * b11; - t12 += v3 * b12; - t13 += v3 * b13; - t14 += v3 * b14; - t15 += v3 * b15; - v3 = a3[1]; - t1 += v3 * b0; - t2 += v3 * b1; - t3 += v3 * b22; - t4 += v3 * b32; - t5 += v3 * b4; - t6 += v3 * b5; - t7 += v3 * b6; - t8 += v3 * b7; - t9 += v3 * b8; - t10 += v3 * b9; - t11 += v3 * b10; - t12 += v3 * b11; - t13 += v3 * b12; - t14 += v3 * b13; - t15 += v3 * b14; - t16 += v3 * b15; - v3 = a3[2]; - t2 += v3 * b0; - t3 += v3 * b1; - t4 += v3 * b22; - t5 += v3 * b32; - t6 += v3 * b4; - t7 += v3 * b5; - t8 += v3 * b6; - t9 += v3 * b7; - t10 += v3 * b8; - t11 += v3 * b9; - t12 += v3 * b10; - t13 += v3 * b11; - t14 += v3 * b12; - t15 += v3 * b13; - t16 += v3 * b14; - t17 += v3 * b15; - v3 = a3[3]; - t3 += v3 * b0; - t4 += v3 * b1; - t5 += v3 * b22; - t6 += v3 * b32; - t7 += v3 * b4; - t8 += v3 * b5; - t9 += v3 * b6; - t10 += v3 * b7; - t11 += v3 * b8; - t12 += v3 * b9; - t13 += v3 * b10; - t14 += v3 * b11; - t15 += v3 * b12; - t16 += v3 * b13; + function parse(query, options) { + options = Object.assign({ + decode: true, + sort: true, + arrayFormat: "none", + arrayFormatSeparator: ",", + parseNumbers: false, + parseBooleans: false + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const formatter = parserForArrayFormat(options); + const ret = /* @__PURE__ */ Object.create(null); + if (typeof query !== "string") { + return ret; + } + query = query.trim().replace(/^[?#&]/, ""); + if (!query) { + return ret; + } + for (const param of query.split("&")) { + if (param === "") { + continue; + } + let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); + value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); + formatter(decode2(key, options), value, ret); + } + for (const key of Object.keys(ret)) { + const value = ret[key]; + if (typeof value === "object" && value !== null) { + for (const k2 of Object.keys(value)) { + value[k2] = parseValue(value[k2], options); + } + } else { + ret[key] = parseValue(value, options); + } + } + if (options.sort === false) { + return ret; + } + return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { + const value = ret[key]; + if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { + result[key] = keysSorter(value); + } else { + result[key] = value; + } + return result; + }, /* @__PURE__ */ Object.create(null)); + } + exports2.extract = extract; + exports2.parse = parse; + exports2.stringify = (object, options) => { + if (!object) { + return ""; + } + options = Object.assign({ + encode: true, + strict: true, + arrayFormat: "none", + arrayFormatSeparator: "," + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; + const formatter = encoderForArrayFormat(options); + const objectCopy = {}; + for (const key of Object.keys(object)) { + if (!shouldFilter(key)) { + objectCopy[key] = object[key]; + } + } + const keys2 = Object.keys(objectCopy); + if (options.sort !== false) { + keys2.sort(options.sort); + } + return keys2.map((key) => { + const value = object[key]; + if (value === void 0) { + return ""; + } + if (value === null) { + return encode2(key, options); + } + if (Array.isArray(value)) { + if (value.length === 0 && options.arrayFormat === "bracket-separator") { + return encode2(key, options) + "[]"; + } + return value.reduce(formatter(key), []).join("&"); + } + return encode2(key, options) + "=" + encode2(value, options); + }).filter((x2) => x2.length > 0).join("&"); + }; + exports2.parseUrl = (url, options) => { + options = Object.assign({ + decode: true + }, options); + const [url_, hash2] = splitOnFirst$1(url, "#"); + return Object.assign( + { + url: url_.split("?")[0] || "", + query: parse(extract(url), options) + }, + options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} + ); + }; + exports2.stringifyUrl = (object, options) => { + options = Object.assign({ + encode: true, + strict: true, + [encodeFragmentIdentifier]: true + }, options); + const url = removeHash(object.url).split("?")[0] || ""; + const queryFromUrl = exports2.extract(object.url); + const parsedQueryFromUrl = exports2.parse(queryFromUrl, { sort: false }); + const query = Object.assign(parsedQueryFromUrl, object.query); + let queryString2 = exports2.stringify(query, options); + if (queryString2) { + queryString2 = `?${queryString2}`; + } + let hash2 = getHash(object.url); + if (object.fragmentIdentifier) { + hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + } + return `${url}${queryString2}${hash2}`; + }; + exports2.pick = (input, filter, options) => { + options = Object.assign({ + parseFragmentIdentifier: true, + [encodeFragmentIdentifier]: false + }, options); + const { url, query, fragmentIdentifier } = exports2.parseUrl(input, options); + return exports2.stringifyUrl({ + url, + query: filterObject(query, filter), + fragmentIdentifier + }, options); + }; + exports2.exclude = (input, filter, options) => { + const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); + return exports2.pick(input, exclusionFilter, options); + }; +})(queryString); +var chacha20poly1305 = {}; +var chacha = {}; +Object.defineProperty(chacha, "__esModule", { value: true }); +var binary_1 = binary; +var wipe_1$2 = wipe$1; +var ROUNDS = 20; +function core(out, input, key) { + var j02 = 1634760805; + var j1 = 857760878; + var j2 = 2036477234; + var j3 = 1797285236; + var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; + var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; + var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; + var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; + var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; + var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; + var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; + var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; + var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; + var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; + var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; + var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; + var x02 = j02; + var x1 = j1; + var x2 = j2; + var x3 = j3; + var x4 = j4; + var x5 = j5; + var x6 = j6; + var x7 = j7; + var x8 = j8; + var x9 = j9; + var x10 = j10; + var x11 = j11; + var x12 = j12; + var x13 = j13; + var x14 = j14; + var x15 = j15; + for (var i2 = 0; i2 < ROUNDS; i2 += 2) { + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 16 | x12 << 16; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 12 | x4 << 12; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 16 | x13 << 16; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 12 | x5 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 16 | x14 << 16; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 12 | x6 << 12; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 16 | x15 << 16; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 12 | x7 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 8 | x14 << 8; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 7 | x6 << 7; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 8 | x15 << 8; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 7 | x7 << 7; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 8 | x13 << 8; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 7 | x5 << 7; + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 8 | x12 << 8; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 7 | x4 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 16 | x15 << 16; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 12 | x5 << 12; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 16 | x12 << 16; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 12 | x6 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 16 | x13 << 16; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 12 | x7 << 12; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 16 | x14 << 16; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 12 | x4 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 8 | x13 << 8; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 7 | x7 << 7; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 8 | x14 << 8; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 7 | x4 << 7; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 8 | x12 << 8; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 7 | x6 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 8 | x15 << 8; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 7 | x5 << 7; + } + binary_1.writeUint32LE(x02 + j02 | 0, out, 0); + binary_1.writeUint32LE(x1 + j1 | 0, out, 4); + binary_1.writeUint32LE(x2 + j2 | 0, out, 8); + binary_1.writeUint32LE(x3 + j3 | 0, out, 12); + binary_1.writeUint32LE(x4 + j4 | 0, out, 16); + binary_1.writeUint32LE(x5 + j5 | 0, out, 20); + binary_1.writeUint32LE(x6 + j6 | 0, out, 24); + binary_1.writeUint32LE(x7 + j7 | 0, out, 28); + binary_1.writeUint32LE(x8 + j8 | 0, out, 32); + binary_1.writeUint32LE(x9 + j9 | 0, out, 36); + binary_1.writeUint32LE(x10 + j10 | 0, out, 40); + binary_1.writeUint32LE(x11 + j11 | 0, out, 44); + binary_1.writeUint32LE(x12 + j12 | 0, out, 48); + binary_1.writeUint32LE(x13 + j13 | 0, out, 52); + binary_1.writeUint32LE(x14 + j14 | 0, out, 56); + binary_1.writeUint32LE(x15 + j15 | 0, out, 60); +} +function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + if (key.length !== 32) { + throw new Error("ChaCha: key size must be 32 bytes"); + } + if (dst.length < src2.length) { + throw new Error("ChaCha: destination is shorter than source"); + } + var nc; + var counterLength; + if (nonceInplaceCounterLength === 0) { + if (nonce.length !== 8 && nonce.length !== 12) { + throw new Error("ChaCha nonce must be 8 or 12 bytes"); + } + nc = new Uint8Array(16); + counterLength = nc.length - nonce.length; + nc.set(nonce, counterLength); + } else { + if (nonce.length !== 16) { + throw new Error("ChaCha nonce with counter must be 16 bytes"); + } + nc = nonce; + counterLength = nonceInplaceCounterLength; + } + var block = new Uint8Array(64); + for (var i2 = 0; i2 < src2.length; i2 += 64) { + core(block, nc, key); + for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { + dst[j2] = src2[j2] ^ block[j2 - i2]; + } + incrementCounter(nc, 0, counterLength); + } + wipe_1$2.wipe(block); + if (nonceInplaceCounterLength === 0) { + wipe_1$2.wipe(nc); + } + return dst; +} +chacha.streamXOR = streamXOR; +function stream(key, nonce, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + wipe_1$2.wipe(dst); + return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); +} +chacha.stream = stream; +function incrementCounter(counter, pos, len) { + var carry = 1; + while (len--) { + carry = carry + (counter[pos] & 255) | 0; + counter[pos] = carry & 255; + carry >>>= 8; + pos++; + } + if (carry > 0) { + throw new Error("ChaCha: counter overflow"); + } +} +var poly1305 = {}; +var constantTime = {}; +Object.defineProperty(constantTime, "__esModule", { value: true }); +function select(subject, resultIfOne, resultIfZero) { + return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; +} +constantTime.select = select; +function lessOrEqual(a3, b3) { + return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; +} +constantTime.lessOrEqual = lessOrEqual; +function compare(a3, b3) { + if (a3.length !== b3.length) { + return 0; + } + var result = 0; + for (var i2 = 0; i2 < a3.length; i2++) { + result |= a3[i2] ^ b3[i2]; + } + return 1 & result - 1 >>> 8; +} +constantTime.compare = compare; +function equal(a3, b3) { + if (a3.length === 0 || b3.length === 0) { + return false; + } + return compare(a3, b3) !== 0; +} +constantTime.equal = equal; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var constant_time_12 = constantTime; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 16; + var Poly1305 = ( + /** @class */ + function() { + function Poly13052(key) { + this.digestLength = exports2.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 = false; + var t0 = key[0] | key[1] << 8; + this._r[0] = t0 & 8191; + var t1 = key[2] | key[3] << 8; + this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; + var t2 = key[4] | key[5] << 8; + this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; + var t3 = key[6] | key[7] << 8; + this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; + var t4 = key[8] | key[9] << 8; + this._r[4] = (t3 >>> 4 | t4 << 12) & 255; + this._r[5] = t4 >>> 1 & 8190; + var t5 = key[10] | key[11] << 8; + this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; + var t6 = key[12] | key[13] << 8; + this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; + var t7 = key[14] | key[15] << 8; + this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; + this._r[9] = t7 >>> 5 & 127; + this._pad[0] = key[16] | key[17] << 8; + this._pad[1] = key[18] | key[19] << 8; + this._pad[2] = key[20] | key[21] << 8; + this._pad[3] = key[22] | key[23] << 8; + this._pad[4] = key[24] | key[25] << 8; + this._pad[5] = key[26] | key[27] << 8; + this._pad[6] = key[28] | key[29] << 8; + this._pad[7] = key[30] | key[31] << 8; + } + Poly13052.prototype._blocks = function(m3, mpos, bytes) { + var hibit = this._fin ? 0 : 1 << 11; + var h02 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; + var r0 = this._r[0], r1 = this._r[1], r22 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; + while (bytes >= 16) { + var t0 = m3[mpos + 0] | m3[mpos + 1] << 8; + h02 += t0 & 8191; + var t1 = m3[mpos + 2] | m3[mpos + 3] << 8; + h1 += (t0 >>> 13 | t1 << 3) & 8191; + var t2 = m3[mpos + 4] | m3[mpos + 5] << 8; + h22 += (t1 >>> 10 | t2 << 6) & 8191; + var t3 = m3[mpos + 6] | m3[mpos + 7] << 8; + h32 += (t2 >>> 7 | t3 << 9) & 8191; + var t4 = m3[mpos + 8] | m3[mpos + 9] << 8; + h4 += (t3 >>> 4 | t4 << 12) & 8191; + h5 += t4 >>> 1 & 8191; + var t5 = m3[mpos + 10] | m3[mpos + 11] << 8; + h6 += (t4 >>> 14 | t5 << 2) & 8191; + var t6 = m3[mpos + 12] | m3[mpos + 13] << 8; + h7 += (t5 >>> 11 | t6 << 5) & 8191; + var t7 = m3[mpos + 14] | m3[mpos + 15] << 8; + h8 += (t6 >>> 8 | t7 << 8) & 8191; + h9 += t7 >>> 5 | hibit; + var c2 = 0; + var d02 = c2; + d02 += h02 * r0; + d02 += h1 * (5 * r9); + d02 += h22 * (5 * r8); + d02 += h32 * (5 * r7); + d02 += h4 * (5 * r6); + c2 = d02 >>> 13; + d02 &= 8191; + d02 += h5 * (5 * r5); + d02 += h6 * (5 * r4); + d02 += h7 * (5 * r3); + d02 += h8 * (5 * r22); + d02 += h9 * (5 * r1); + c2 += d02 >>> 13; + d02 &= 8191; + var d1 = c2; + d1 += h02 * r1; + d1 += h1 * r0; + d1 += h22 * (5 * r9); + d1 += h32 * (5 * r8); + d1 += h4 * (5 * r7); + c2 = d1 >>> 13; + d1 &= 8191; + d1 += h5 * (5 * r6); + d1 += h6 * (5 * r5); + d1 += h7 * (5 * r4); + d1 += h8 * (5 * r3); + d1 += h9 * (5 * r22); + c2 += d1 >>> 13; + d1 &= 8191; + var d22 = c2; + d22 += h02 * r22; + d22 += h1 * r1; + d22 += h22 * r0; + d22 += h32 * (5 * r9); + d22 += h4 * (5 * r8); + c2 = d22 >>> 13; + d22 &= 8191; + d22 += h5 * (5 * r7); + d22 += h6 * (5 * r6); + d22 += h7 * (5 * r5); + d22 += h8 * (5 * r4); + d22 += h9 * (5 * r3); + c2 += d22 >>> 13; + d22 &= 8191; + var d32 = c2; + d32 += h02 * r3; + d32 += h1 * r22; + d32 += h22 * r1; + d32 += h32 * r0; + d32 += h4 * (5 * r9); + c2 = d32 >>> 13; + d32 &= 8191; + d32 += h5 * (5 * r8); + d32 += h6 * (5 * r7); + d32 += h7 * (5 * r6); + d32 += h8 * (5 * r5); + d32 += h9 * (5 * r4); + c2 += d32 >>> 13; + d32 &= 8191; + var d42 = c2; + d42 += h02 * r4; + d42 += h1 * r3; + d42 += h22 * r22; + d42 += h32 * r1; + d42 += h4 * r0; + c2 = d42 >>> 13; + d42 &= 8191; + d42 += h5 * (5 * r9); + d42 += h6 * (5 * r8); + d42 += h7 * (5 * r7); + d42 += h8 * (5 * r6); + d42 += h9 * (5 * r5); + c2 += d42 >>> 13; + d42 &= 8191; + var d5 = c2; + d5 += h02 * r5; + d5 += h1 * r4; + d5 += h22 * r3; + d5 += h32 * r22; + d5 += h4 * r1; + c2 = d5 >>> 13; + d5 &= 8191; + d5 += h5 * r0; + d5 += h6 * (5 * r9); + d5 += h7 * (5 * r8); + d5 += h8 * (5 * r7); + d5 += h9 * (5 * r6); + c2 += d5 >>> 13; + d5 &= 8191; + var d6 = c2; + d6 += h02 * r6; + d6 += h1 * r5; + d6 += h22 * r4; + d6 += h32 * r3; + d6 += h4 * r22; + c2 = d6 >>> 13; + d6 &= 8191; + d6 += h5 * r1; + d6 += h6 * r0; + d6 += h7 * (5 * r9); + d6 += h8 * (5 * r8); + d6 += h9 * (5 * r7); + c2 += d6 >>> 13; + d6 &= 8191; + var d7 = c2; + d7 += h02 * r7; + d7 += h1 * r6; + d7 += h22 * r5; + d7 += h32 * r4; + d7 += h4 * r3; + c2 = d7 >>> 13; + d7 &= 8191; + d7 += h5 * r22; + d7 += h6 * r1; + d7 += h7 * r0; + d7 += h8 * (5 * r9); + d7 += h9 * (5 * r8); + c2 += d7 >>> 13; + d7 &= 8191; + var d8 = c2; + d8 += h02 * r8; + d8 += h1 * r7; + d8 += h22 * r6; + d8 += h32 * r5; + d8 += h4 * r4; + c2 = d8 >>> 13; + d8 &= 8191; + d8 += h5 * r3; + d8 += h6 * r22; + d8 += h7 * r1; + d8 += h8 * r0; + d8 += h9 * (5 * r9); + c2 += d8 >>> 13; + d8 &= 8191; + var d9 = c2; + d9 += h02 * r9; + d9 += h1 * r8; + d9 += h22 * r7; + d9 += h32 * r6; + d9 += h4 * r5; + c2 = d9 >>> 13; + d9 &= 8191; + d9 += h5 * r4; + d9 += h6 * r3; + d9 += h7 * r22; + d9 += h8 * r1; + d9 += h9 * r0; + c2 += d9 >>> 13; + d9 &= 8191; + c2 = (c2 << 2) + c2 | 0; + c2 = c2 + d02 | 0; + d02 = c2 & 8191; + c2 = c2 >>> 13; + d1 += c2; + h02 = d02; + h1 = d1; + h22 = d22; + h32 = d32; + h4 = d42; + h5 = d5; + h6 = d6; + h7 = d7; + h8 = d8; + h9 = d9; + mpos += 16; + bytes -= 16; + } + this._h[0] = h02; + this._h[1] = h1; + this._h[2] = h22; + this._h[3] = h32; + this._h[4] = h4; + this._h[5] = h5; + this._h[6] = h6; + this._h[7] = h7; + this._h[8] = h8; + this._h[9] = h9; + }; + Poly13052.prototype.finish = function(mac, macpos) { + if (macpos === void 0) { + macpos = 0; + } + var g3 = new Uint16Array(10); + var c2; + var mask; + var f3; + var i2; + if (this._leftover) { + i2 = this._leftover; + this._buffer[i2++] = 1; + for (; i2 < 16; i2++) { + this._buffer[i2] = 0; + } + this._fin = 1; + this._blocks(this._buffer, 0, 16); + } + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + for (i2 = 2; i2 < 10; i2++) { + this._h[i2] += c2; + c2 = this._h[i2] >>> 13; + this._h[i2] &= 8191; + } + this._h[0] += c2 * 5; + c2 = this._h[0] >>> 13; + this._h[0] &= 8191; + this._h[1] += c2; + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + this._h[2] += c2; + g3[0] = this._h[0] + 5; + c2 = g3[0] >>> 13; + g3[0] &= 8191; + for (i2 = 1; i2 < 10; i2++) { + g3[i2] = this._h[i2] + c2; + c2 = g3[i2] >>> 13; + g3[i2] &= 8191; + } + g3[9] -= 1 << 13; + mask = (c2 ^ 1) - 1; + for (i2 = 0; i2 < 10; i2++) { + g3[i2] &= mask; + } + mask = ~mask; + for (i2 = 0; i2 < 10; i2++) { + this._h[i2] = this._h[i2] & mask | g3[i2]; + } + 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; + f3 = this._h[0] + this._pad[0]; + this._h[0] = f3 & 65535; + for (i2 = 1; i2 < 8; i2++) { + f3 = (this._h[i2] + this._pad[i2] | 0) + (f3 >>> 16) | 0; + this._h[i2] = f3 & 65535; + } + mac[macpos + 0] = this._h[0] >>> 0; + mac[macpos + 1] = this._h[0] >>> 8; + mac[macpos + 2] = this._h[1] >>> 0; + mac[macpos + 3] = this._h[1] >>> 8; + mac[macpos + 4] = this._h[2] >>> 0; + mac[macpos + 5] = this._h[2] >>> 8; + mac[macpos + 6] = this._h[3] >>> 0; + mac[macpos + 7] = this._h[3] >>> 8; + mac[macpos + 8] = this._h[4] >>> 0; + mac[macpos + 9] = this._h[4] >>> 8; + mac[macpos + 10] = this._h[5] >>> 0; + mac[macpos + 11] = this._h[5] >>> 8; + mac[macpos + 12] = this._h[6] >>> 0; + mac[macpos + 13] = this._h[6] >>> 8; + mac[macpos + 14] = this._h[7] >>> 0; + mac[macpos + 15] = this._h[7] >>> 8; + this._finished = true; + return this; + }; + Poly13052.prototype.update = function(m3) { + var mpos = 0; + var bytes = m3.length; + var want; + if (this._leftover) { + want = 16 - this._leftover; + if (want > bytes) { + want = bytes; + } + for (var i2 = 0; i2 < want; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + bytes -= want; + mpos += want; + this._leftover += want; + if (this._leftover < 16) { + return this; + } + this._blocks(this._buffer, 0, 16); + this._leftover = 0; + } + if (bytes >= 16) { + want = bytes - bytes % 16; + this._blocks(m3, mpos, want); + mpos += want; + bytes -= want; + } + if (bytes) { + for (var i2 = 0; i2 < bytes; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + this._leftover += bytes; + } + return this; + }; + Poly13052.prototype.digest = function() { + if (this._finished) { + throw new Error("Poly1305 was finished"); + } + var mac = new Uint8Array(16); + this.finish(mac); + return mac; + }; + Poly13052.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._r); + wipe_12.wipe(this._h); + wipe_12.wipe(this._pad); + this._leftover = 0; + this._fin = 0; + this._finished = true; + return this; + }; + return Poly13052; + }() + ); + exports2.Poly1305 = Poly1305; + function oneTimeAuth(key, data) { + var h4 = new Poly1305(key); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.oneTimeAuth = oneTimeAuth; + function equal2(a3, b3) { + if (a3.length !== exports2.DIGEST_LENGTH || b3.length !== exports2.DIGEST_LENGTH) { + return false; + } + return constant_time_12.equal(a3, b3); + } + exports2.equal = equal2; +})(poly1305); +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var chacha_1 = chacha; + var poly1305_1 = poly1305; + var wipe_12 = wipe$1; + var binary_12 = binary; + var constant_time_12 = constantTime; + exports2.KEY_LENGTH = 32; + exports2.NONCE_LENGTH = 12; + exports2.TAG_LENGTH = 16; + var ZEROS = new Uint8Array(16); + var ChaCha20Poly1305 = ( + /** @class */ + function() { + function ChaCha20Poly13052(key) { + this.nonceLength = exports2.NONCE_LENGTH; + this.tagLength = exports2.TAG_LENGTH; + if (key.length !== exports2.KEY_LENGTH) { + throw new Error("ChaCha20Poly1305 needs 32-byte key"); + } + this._key = new Uint8Array(key); + } + ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var resultLength = plaintext.length + this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, plaintext, result, 4); + this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + if (sealed.length < this.tagLength) { + return null; + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var calculatedTag = new Uint8Array(this.tagLength); + this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); + if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { + return null; + } + var resultLength = sealed.length - this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.clean = function() { + wipe_12.wipe(this._key); + return this; + }; + ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { + var h4 = new poly1305_1.Poly1305(authKey); + if (associatedData) { + h4.update(associatedData); + if (associatedData.length % 16 > 0) { + h4.update(ZEROS.subarray(associatedData.length % 16)); + } + } + h4.update(ciphertext); + if (ciphertext.length % 16 > 0) { + h4.update(ZEROS.subarray(ciphertext.length % 16)); + } + var length = new Uint8Array(8); + if (associatedData) { + binary_12.writeUint64LE(associatedData.length, length); + } + h4.update(length); + binary_12.writeUint64LE(ciphertext.length, length); + h4.update(length); + var tag = h4.digest(); + for (var i2 = 0; i2 < tag.length; i2++) { + tagOut[i2] = tag[i2]; + } + h4.clean(); + wipe_12.wipe(tag); + wipe_12.wipe(length); + }; + return ChaCha20Poly13052; + }() + ); + exports2.ChaCha20Poly1305 = ChaCha20Poly1305; +})(chacha20poly1305); +var hkdf = {}; +var hmac$1 = {}; +var hash = {}; +Object.defineProperty(hash, "__esModule", { value: true }); +function isSerializableHash(h4) { + return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; +} +hash.isSerializableHash = isSerializableHash; +Object.defineProperty(hmac$1, "__esModule", { value: true }); +var hash_1 = hash; +var constant_time_1 = constantTime; +var wipe_1$1 = wipe$1; +var HMAC = ( + /** @class */ + function() { + function HMAC2(hash2, key) { + this._finished = false; + this._inner = new hash2(); + this._outer = new hash2(); + this.blockSize = this._outer.blockSize; + this.digestLength = this._outer.digestLength; + var pad = new Uint8Array(this.blockSize); + if (key.length > this.blockSize) { + this._inner.update(key).finish(pad).clean(); + } else { + pad.set(key); + } + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54; + } + this._inner.update(pad); + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54 ^ 92; + } + this._outer.update(pad); + if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { + this._innerKeyedState = this._inner.saveState(); + this._outerKeyedState = this._outer.saveState(); + } + wipe_1$1.wipe(pad); + } + HMAC2.prototype.reset = function() { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); + } + this._inner.restoreState(this._innerKeyedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.clean = function() { + if (hash_1.isSerializableHash(this._inner)) { + this._inner.cleanSavedState(this._innerKeyedState); + } + if (hash_1.isSerializableHash(this._outer)) { + this._outer.cleanSavedState(this._outerKeyedState); + } + this._inner.clean(); + this._outer.clean(); + }; + HMAC2.prototype.update = function(data) { + this._inner.update(data); + return this; + }; + HMAC2.prototype.finish = function(out) { + if (this._finished) { + this._outer.finish(out); + return this; + } + this._inner.finish(out); + this._outer.update(out.subarray(0, this.digestLength)).finish(out); + this._finished = true; + return this; + }; + HMAC2.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + HMAC2.prototype.saveState = function() { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't saveState() because hash doesn't implement it"); + } + return this._inner.saveState(); + }; + HMAC2.prototype.restoreState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't restoreState() because hash doesn't implement it"); + } + this._inner.restoreState(savedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.cleanSavedState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); + } + this._inner.cleanSavedState(savedState); + }; + return HMAC2; + }() +); +hmac$1.HMAC = HMAC; +function hmac(hash2, key, data) { + var h4 = new HMAC(hash2, key); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; +} +hmac$1.hmac = hmac; +hmac$1.equal = constant_time_1.equal; +Object.defineProperty(hkdf, "__esModule", { value: true }); +var hmac_1 = hmac$1; +var wipe_1 = wipe$1; +var HKDF = ( + /** @class */ + function() { + function HKDF2(hash2, key, salt, info) { + if (salt === void 0) { + salt = new Uint8Array(0); + } + this._counter = new Uint8Array(1); + this._hash = hash2; + this._info = info; + var okm = hmac_1.hmac(this._hash, salt, key); + this._hmac = new hmac_1.HMAC(hash2, okm); + this._buffer = new Uint8Array(this._hmac.digestLength); + this._bufpos = this._buffer.length; + } + HKDF2.prototype._fillBuffer = function() { + this._counter[0]++; + var ctr = this._counter[0]; + if (ctr === 0) { + throw new Error("hkdf: cannot expand more"); + } + this._hmac.reset(); + if (ctr > 1) { + this._hmac.update(this._buffer); + } + if (this._info) { + this._hmac.update(this._info); + } + this._hmac.update(this._counter); + this._hmac.finish(this._buffer); + this._bufpos = 0; + }; + HKDF2.prototype.expand = function(length) { + var out = new Uint8Array(length); + for (var i2 = 0; i2 < out.length; i2++) { + if (this._bufpos === this._buffer.length) { + this._fillBuffer(); + } + out[i2] = this._buffer[this._bufpos++]; + } + return out; + }; + HKDF2.prototype.clean = function() { + this._hmac.clean(); + wipe_1.wipe(this._buffer); + wipe_1.wipe(this._counter); + this._bufpos = 0; + }; + return HKDF2; + }() +); +var HKDF_1 = hkdf.HKDF = HKDF; +var sha256 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var binary_12 = binary; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 32; + exports2.BLOCK_SIZE = 64; + var SHA256 = ( + /** @class */ + function() { + function SHA2562() { + this.digestLength = exports2.DIGEST_LENGTH; + this.blockSize = exports2.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 = false; + this.reset(); + } + SHA2562.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; + }; + SHA2562.prototype.reset = function() { + this._initState(); + this._bufferLength = 0; + this._bytesHashed = 0; + this._finished = false; + return this; + }; + SHA2562.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._temp); + this.reset(); + }; + SHA2562.prototype.update = function(data, dataLength) { + if (dataLength === void 0) { + dataLength = data.length; + } + if (this._finished) { + throw new Error("SHA256: can't update because hash was finished."); + } + var dataPos = 0; + this._bytesHashed += dataLength; + if (this._bufferLength > 0) { + while (this._bufferLength < this.blockSize && dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + if (this._bufferLength === this.blockSize) { + hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); + this._bufferLength = 0; + } + } + if (dataLength >= this.blockSize) { + dataPos = hashBlocks(this._temp, this._state, data, dataPos, dataLength); + dataLength %= this.blockSize; + } + while (dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + return this; + }; + SHA2562.prototype.finish = function(out) { + if (!this._finished) { + var bytesHashed = this._bytesHashed; + var left = this._bufferLength; + var bitLenHi = bytesHashed / 536870912 | 0; + var bitLenLo = bytesHashed << 3; + var padLength = bytesHashed % 64 < 56 ? 64 : 128; + this._buffer[left] = 128; + for (var i2 = left + 1; i2 < padLength - 8; i2++) { + this._buffer[i2] = 0; + } + binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); + binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); + hashBlocks(this._temp, this._state, this._buffer, 0, padLength); + this._finished = true; + } + for (var i2 = 0; i2 < this.digestLength / 4; i2++) { + binary_12.writeUint32BE(this._state[i2], out, i2 * 4); + } + return this; + }; + SHA2562.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + SHA2562.prototype.saveState = function() { + if (this._finished) { + throw new Error("SHA256: cannot save finished state"); + } + return { + state: new Int32Array(this._state), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }; + SHA2562.prototype.restoreState = function(savedState) { + this._state.set(savedState.state); + this._bufferLength = savedState.bufferLength; + if (savedState.buffer) { + this._buffer.set(savedState.buffer); + } + this._bytesHashed = savedState.bytesHashed; + this._finished = false; + return this; + }; + SHA2562.prototype.cleanSavedState = function(savedState) { + wipe_12.wipe(savedState.state); + if (savedState.buffer) { + wipe_12.wipe(savedState.buffer); + } + savedState.bufferLength = 0; + savedState.bytesHashed = 0; + }; + return SHA2562; + }() + ); + exports2.SHA256 = SHA256; + var K3 = 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 hashBlocks(w3, v3, p2, pos, len) { + while (len >= 64) { + var a3 = v3[0]; + var b3 = v3[1]; + var c2 = v3[2]; + var d5 = v3[3]; + var e2 = v3[4]; + var f3 = v3[5]; + var g3 = v3[6]; + var h4 = v3[7]; + for (var i2 = 0; i2 < 16; i2++) { + var j2 = pos + i2 * 4; + w3[i2] = binary_12.readUint32BE(p2, j2); + } + for (var i2 = 16; i2 < 64; i2++) { + var u3 = w3[i2 - 2]; + var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; + u3 = w3[i2 - 15]; + var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; + w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); + } + for (var i2 = 0; i2 < 64; i2++) { + var t1 = (((e2 >>> 6 | e2 << 32 - 6) ^ (e2 >>> 11 | e2 << 32 - 11) ^ (e2 >>> 25 | e2 << 32 - 25)) + (e2 & f3 ^ ~e2 & g3) | 0) + (h4 + (K3[i2] + w3[i2] | 0) | 0) | 0; + var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; + h4 = g3; + g3 = f3; + f3 = e2; + e2 = d5 + t1 | 0; + d5 = c2; + c2 = b3; + b3 = a3; + a3 = t1 + t2 | 0; + } + v3[0] += a3; + v3[1] += b3; + v3[2] += c2; + v3[3] += d5; + v3[4] += e2; + v3[5] += f3; + v3[6] += g3; + v3[7] += h4; + pos += 64; + len -= 64; + } + return pos; + } + function hash2(data) { + var h4 = new SHA256(); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.hash = hash2; +})(sha256); +var x25519 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.sharedKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.scalarMultBase = exports2.scalarMult = exports2.SHARED_KEY_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = void 0; + const random_1 = random; + const wipe_12 = wipe$1; + exports2.PUBLIC_KEY_LENGTH = 32; + exports2.SECRET_KEY_LENGTH = 32; + exports2.SHARED_KEY_LENGTH = 32; + function gf2(init) { + const r3 = new Float64Array(16); + if (init) { + for (let i2 = 0; i2 < init.length; i2++) { + r3[i2] = init[i2]; + } + } + return r3; + } + const _9 = new Uint8Array(32); + _9[0] = 9; + const _121665 = gf2([56129, 1]); + function car25519(o2) { + let c2 = 1; + for (let i2 = 0; i2 < 16; i2++) { + let v3 = o2[i2] + c2 + 65535; + c2 = Math.floor(v3 / 65536); + o2[i2] = v3 - c2 * 65536; + } + o2[0] += c2 - 1 + 37 * (c2 - 1); + } + function sel25519(p2, q2, b3) { + const c2 = ~(b3 - 1); + for (let i2 = 0; i2 < 16; i2++) { + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; + q2[i2] ^= t2; + } + } + function pack25519(o2, n4) { + const m3 = gf2(); + const t2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + t2[i2] = n4[i2]; + } + car25519(t2); + car25519(t2); + car25519(t2); + for (let j2 = 0; j2 < 2; j2++) { + m3[0] = t2[0] - 65517; + for (let i2 = 1; i2 < 15; i2++) { + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; + } + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); + } + for (let i2 = 0; i2 < 16; i2++) { + o2[2 * i2] = t2[i2] & 255; + o2[2 * i2 + 1] = t2[i2] >> 8; + } + } + function unpack25519(o2, n4) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); + } + o2[15] &= 32767; + } + function add(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] + b3[i2]; + } + } + function sub(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] - b3[i2]; + } + } + function mul(o2, a3, b3) { + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + v3 = a3[0]; + t0 += v3 * b02; + t1 += v3 * b1; + t2 += v3 * b22; + t3 += v3 * b32; + t4 += v3 * b4; + t5 += v3 * b5; + t6 += v3 * b6; + t7 += v3 * b7; + t8 += v3 * b8; + t9 += v3 * b9; + t10 += v3 * b10; + t11 += v3 * b11; + t12 += v3 * b12; + t13 += v3 * b13; + t14 += v3 * b14; + t15 += v3 * b15; + v3 = a3[1]; + t1 += v3 * b02; + t2 += v3 * b1; + t3 += v3 * b22; + t4 += v3 * b32; + t5 += v3 * b4; + t6 += v3 * b5; + t7 += v3 * b6; + t8 += v3 * b7; + t9 += v3 * b8; + t10 += v3 * b9; + t11 += v3 * b10; + t12 += v3 * b11; + t13 += v3 * b12; + t14 += v3 * b13; + t15 += v3 * b14; + t16 += v3 * b15; + v3 = a3[2]; + t2 += v3 * b02; + t3 += v3 * b1; + t4 += v3 * b22; + t5 += v3 * b32; + t6 += v3 * b4; + t7 += v3 * b5; + t8 += v3 * b6; + t9 += v3 * b7; + t10 += v3 * b8; + t11 += v3 * b9; + t12 += v3 * b10; + t13 += v3 * b11; + t14 += v3 * b12; + t15 += v3 * b13; + t16 += v3 * b14; + t17 += v3 * b15; + v3 = a3[3]; + t3 += v3 * b02; + t4 += v3 * b1; + t5 += v3 * b22; + t6 += v3 * b32; + t7 += v3 * b4; + t8 += v3 * b5; + t9 += v3 * b6; + t10 += v3 * b7; + t11 += v3 * b8; + t12 += v3 * b9; + t13 += v3 * b10; + t14 += v3 * b11; + t15 += v3 * b12; + t16 += v3 * b13; t17 += v3 * b14; t18 += v3 * b15; v3 = a3[4]; - t4 += v3 * b0; + t4 += v3 * b02; t5 += v3 * b1; t6 += v3 * b22; t7 += v3 * b32; @@ -7219,7 +7946,7 @@ var x25519 = {}; t18 += v3 * b14; t19 += v3 * b15; v3 = a3[5]; - t5 += v3 * b0; + t5 += v3 * b02; t6 += v3 * b1; t7 += v3 * b22; t8 += v3 * b32; @@ -7236,7 +7963,7 @@ var x25519 = {}; t19 += v3 * b14; t20 += v3 * b15; v3 = a3[6]; - t6 += v3 * b0; + t6 += v3 * b02; t7 += v3 * b1; t8 += v3 * b22; t9 += v3 * b32; @@ -7253,7 +7980,7 @@ var x25519 = {}; t20 += v3 * b14; t21 += v3 * b15; v3 = a3[7]; - t7 += v3 * b0; + t7 += v3 * b02; t8 += v3 * b1; t9 += v3 * b22; t10 += v3 * b32; @@ -7270,7 +7997,7 @@ var x25519 = {}; t21 += v3 * b14; t22 += v3 * b15; v3 = a3[8]; - t8 += v3 * b0; + t8 += v3 * b02; t9 += v3 * b1; t10 += v3 * b22; t11 += v3 * b32; @@ -7287,7 +8014,7 @@ var x25519 = {}; t22 += v3 * b14; t23 += v3 * b15; v3 = a3[9]; - t9 += v3 * b0; + t9 += v3 * b02; t10 += v3 * b1; t11 += v3 * b22; t12 += v3 * b32; @@ -7304,7 +8031,7 @@ var x25519 = {}; t23 += v3 * b14; t24 += v3 * b15; v3 = a3[10]; - t10 += v3 * b0; + t10 += v3 * b02; t11 += v3 * b1; t12 += v3 * b22; t13 += v3 * b32; @@ -7321,7 +8048,7 @@ var x25519 = {}; t24 += v3 * b14; t25 += v3 * b15; v3 = a3[11]; - t11 += v3 * b0; + t11 += v3 * b02; t12 += v3 * b1; t13 += v3 * b22; t14 += v3 * b32; @@ -7338,7 +8065,7 @@ var x25519 = {}; t25 += v3 * b14; t26 += v3 * b15; v3 = a3[12]; - t12 += v3 * b0; + t12 += v3 * b02; t13 += v3 * b1; t14 += v3 * b22; t15 += v3 * b32; @@ -7355,7 +8082,7 @@ var x25519 = {}; t26 += v3 * b14; t27 += v3 * b15; v3 = a3[13]; - t13 += v3 * b0; + t13 += v3 * b02; t14 += v3 * b1; t15 += v3 * b22; t16 += v3 * b32; @@ -7372,7 +8099,7 @@ var x25519 = {}; t27 += v3 * b14; t28 += v3 * b15; v3 = a3[14]; - t14 += v3 * b0; + t14 += v3 * b02; t15 += v3 * b1; t16 += v3 * b22; t17 += v3 * b32; @@ -7389,7 +8116,7 @@ var x25519 = {}; t28 += v3 * b14; t29 += v3 * b15; v3 = a3[15]; - t15 += v3 * b0; + t15 += v3 * b02; t16 += v3 * b1; t17 += v3 * b22; t18 += v3 * b32; @@ -7541,7 +8268,7 @@ var x25519 = {}; mul(o2, a3, a3); } function inv25519(o2, inp) { - const c2 = gf(); + const c2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { c2[i2] = inp[i2]; } @@ -7555,50 +8282,50 @@ var x25519 = {}; o2[i2] = c2[i2]; } } - function scalarMult(n3, p3) { - const z32 = new Uint8Array(32); + function scalarMult(n4, p2) { + const z2 = new Uint8Array(32); const x2 = new Float64Array(80); - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e = gf(), f2 = gf(); + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(); for (let i2 = 0; i2 < 31; i2++) { - z32[i2] = n3[i2]; + z2[i2] = n4[i2]; } - z32[31] = n3[31] & 127 | 64; - z32[0] &= 248; - unpack25519(x2, p3); + z2[31] = n4[31] & 127 | 64; + z2[0] &= 248; + unpack25519(x2, p2); for (let i2 = 0; i2 < 16; i2++) { b3[i2] = x2[i2]; } - a3[0] = d3[0] = 1; + a3[0] = d5[0] = 1; for (let i2 = 254; i2 >= 0; --i2) { - const r2 = z32[i2 >>> 3] >>> (i2 & 7) & 1; - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); - add(e, a3, c2); + const r3 = z2[i2 >>> 3] >>> (i2 & 7) & 1; + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); + add(e2, a3, c2); sub(a3, a3, c2); - add(c2, b3, d3); - sub(b3, b3, d3); - square(d3, e); - square(f2, a3); + add(c2, b3, d5); + sub(b3, b3, d5); + square(d5, e2); + square(f3, a3); mul(a3, c2, a3); - mul(c2, b3, e); - add(e, a3, c2); + mul(c2, b3, e2); + add(e2, a3, c2); sub(a3, a3, c2); square(b3, a3); - sub(c2, d3, f2); + sub(c2, d5, f3); mul(a3, c2, _121665); - add(a3, a3, d3); + add(a3, a3, d5); mul(c2, c2, a3); - mul(a3, d3, f2); - mul(d3, b3, x2); - square(b3, e); - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); + mul(a3, d5, f3); + mul(d5, b3, x2); + square(b3, e2); + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); } for (let i2 = 0; i2 < 16; i2++) { x2[i2 + 16] = a3[i2]; x2[i2 + 32] = c2[i2]; x2[i2 + 48] = b3[i2]; - x2[i2 + 64] = d3[i2]; + x2[i2 + 64] = d5[i2]; } const x32 = x2.subarray(32); const x16 = x2.subarray(16); @@ -7609,8 +8336,8 @@ var x25519 = {}; return q2; } exports2.scalarMult = scalarMult; - function scalarMultBase(n3) { - return scalarMult(n3, _9); + function scalarMultBase(n4) { + return scalarMult(n4, _9); } exports2.scalarMultBase = scalarMultBase; function generateKeyPairFromSeed(seed) { @@ -7625,1442 +8352,4226 @@ var x25519 = {}; }; } exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; - function generateKeyPair2(prng) { - const seed = (0, random_1.randomBytes)(32, prng); - const result = generateKeyPairFromSeed(seed); - (0, wipe_12.wipe)(seed); - return result; - } - exports2.generateKeyPair = generateKeyPair2; - function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { - if (mySecretKey.length !== exports2.PUBLIC_KEY_LENGTH) { - throw new Error("X25519: incorrect secret key length"); - } - if (theirPublicKey.length !== exports2.PUBLIC_KEY_LENGTH) { - throw new Error("X25519: incorrect public key length"); - } - const result = scalarMult(mySecretKey, theirPublicKey); - if (rejectZero) { - let zeros = 0; - for (let i2 = 0; i2 < result.length; i2++) { - zeros |= result[i2]; - } - if (zeros === 0) { - throw new Error("X25519: invalid shared key"); - } - } - return result; - } - exports2.sharedKey = sharedKey; -})(x25519); -var __spreadArray$3 = function(to, from2, pack) { - if (pack || arguments.length === 2) - for (var i2 = 0, l2 = from2.length, ar2; i2 < l2; i2++) { - if (ar2 || !(i2 in from2)) { - if (!ar2) - ar2 = Array.prototype.slice.call(from2, 0, i2); - ar2[i2] = from2[i2]; - } - } - return to.concat(ar2 || Array.prototype.slice.call(from2)); -}; -var BrowserInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BrowserInfo2(name2, version2, os2) { - this.name = name2; - this.version = version2; - this.os = os2; - this.type = "browser"; - } - return BrowserInfo2; - }() -); -var NodeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function NodeInfo2(version2) { - this.version = version2; - this.type = "node"; - this.name = "node"; - this.os = process.platform; - } - return NodeInfo2; - }() -); -var SearchBotDeviceInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function SearchBotDeviceInfo2(name2, version2, os2, bot) { - this.name = name2; - this.version = version2; - this.os = os2; - this.bot = bot; - this.type = "bot-device"; - } - return SearchBotDeviceInfo2; - }() -); -var BotInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BotInfo2() { - this.type = "bot"; - this.bot = true; - this.name = "bot"; - this.version = null; - this.os = null; - } - return BotInfo2; - }() -); -var ReactNativeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function ReactNativeInfo2() { - this.type = "react-native"; - this.name = "react-native"; - this.version = null; - this.os = null; - } - return ReactNativeInfo2; - }() -); -var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; -var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; -var REQUIRED_VERSION_PARTS = 3; -var userAgentRules = [ - ["aol", /AOLShield\/([0-9\._]+)/], - ["edge", /Edge\/([0-9\._]+)/], - ["edge-ios", /EdgiOS\/([0-9\._]+)/], - ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], - ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], - ["samsung", /SamsungBrowser\/([0-9\.]+)/], - ["silk", /\bSilk\/([0-9._-]+)\b/], - ["miui", /MiuiBrowser\/([0-9\.]+)$/], - ["beaker", /BeakerBrowser\/([0-9\.]+)/], - ["edge-chromium", /EdgA?\/([0-9\.]+)/], - [ - "chromium-webview", - /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ - ], - ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], - ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], - ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], - ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], - ["fxios", /FxiOS\/([0-9\.]+)/], - ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], - ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], - ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], - ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], - ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], - ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], - ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], - ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], - ["ie", /MSIE\s(7\.0)/], - ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], - ["android", /Android\s([0-9\.]+)/], - ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], - ["safari", /Version\/([0-9\._]+).*Safari/], - ["facebook", /FB[AS]V\/([0-9\.]+)/], - ["instagram", /Instagram\s([0-9\.]+)/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], - ["curl", /^curl\/([0-9\.]+)$/], - ["searchbot", SEARCHBOX_UA_REGEX] -]; -var operatingSystemRules = [ - ["iOS", /iP(hone|od|ad)/], - ["Android OS", /Android/], - ["BlackBerry OS", /BlackBerry|BB10/], - ["Windows Mobile", /IEMobile/], - ["Amazon OS", /Kindle/], - ["Windows 3.11", /Win16/], - ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], - ["Windows 98", /(Windows 98)|(Win98)/], - ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], - ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], - ["Windows Server 2003", /(Windows NT 5.2)/], - ["Windows Vista", /(Windows NT 6.0)/], - ["Windows 7", /(Windows NT 6.1)/], - ["Windows 8", /(Windows NT 6.2)/], - ["Windows 8.1", /(Windows NT 6.3)/], - ["Windows 10", /(Windows NT 10.0)/], - ["Windows ME", /Windows ME/], - ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], - ["Open BSD", /OpenBSD/], - ["Sun OS", /SunOS/], - ["Chrome OS", /CrOS/], - ["Linux", /(Linux)|(X11)/], - ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], - ["QNX", /QNX/], - ["BeOS", /BeOS/], - ["OS/2", /OS\/2/] -]; -function detect(userAgent) { - if (!!userAgent) { - return parseUserAgent(userAgent); - } - if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { - return new ReactNativeInfo(); - } - if (typeof navigator !== "undefined") { - return parseUserAgent(navigator.userAgent); - } - return getNodeVersion(); -} -function matchUserAgent(ua) { - return ua !== "" && userAgentRules.reduce(function(matched, _a) { - var browser2 = _a[0], regex = _a[1]; - if (matched) { - return matched; - } - var uaMatch = regex.exec(ua); - return !!uaMatch && [browser2, uaMatch]; - }, false); -} -function parseUserAgent(ua) { - var matchedRule = matchUserAgent(ua); - if (!matchedRule) { - return null; - } - var name2 = matchedRule[0], match = matchedRule[1]; - if (name2 === "searchbot") { - return new BotInfo(); - } - var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); - if (versionParts) { - if (versionParts.length < REQUIRED_VERSION_PARTS) { - versionParts = __spreadArray$3(__spreadArray$3([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); - } - } else { - versionParts = []; - } - var version2 = versionParts.join("."); - var os2 = detectOS(ua); - var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua); - if (searchBotMatch && searchBotMatch[1]) { - return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); + function generateKeyPair2(prng) { + const seed = (0, random_1.randomBytes)(32, prng); + const result = generateKeyPairFromSeed(seed); + (0, wipe_12.wipe)(seed); + return result; } - return new BrowserInfo(name2, version2, os2); -} -function detectOS(ua) { - for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { - var _a = operatingSystemRules[ii], os2 = _a[0], regex = _a[1]; - var match = regex.exec(ua); - if (match) { - return os2; + exports2.generateKeyPair = generateKeyPair2; + function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { + if (mySecretKey.length !== exports2.PUBLIC_KEY_LENGTH) { + throw new Error("X25519: incorrect secret key length"); + } + if (theirPublicKey.length !== exports2.PUBLIC_KEY_LENGTH) { + throw new Error("X25519: incorrect public key length"); + } + const result = scalarMult(mySecretKey, theirPublicKey); + if (rejectZero) { + let zeros = 0; + for (let i2 = 0; i2 < result.length; i2++) { + zeros |= result[i2]; + } + if (zeros === 0) { + throw new Error("X25519: invalid shared key"); + } } + return result; } - return null; + exports2.sharedKey = sharedKey; +})(x25519); +const C$1 = { 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" } }; +const Ir$1 = ":"; +function dn(e2) { + const [t2, r3] = e2.split(Ir$1); + return { namespace: t2, reference: r3 }; +} +function _r$1(e2, t2) { + return e2.includes(":") ? [e2] : t2.chains || []; +} +var Qo = Object.defineProperty, bn = Object.getOwnPropertySymbols, Jo = Object.prototype.hasOwnProperty, Go = Object.prototype.propertyIsEnumerable, yn = (e2, t2, r3) => t2 in e2 ? Qo(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, wn = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Jo.call(t2, r3) && yn(e2, r3, t2[r3]); + if (bn) + for (var r3 of bn(t2)) + Go.call(t2, r3) && yn(e2, r3, t2[r3]); + return e2; +}; +const xn = "ReactNative", qt$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, En = "js"; +function pi() { + return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; } -function getNodeVersion() { - var isNode = typeof process !== "undefined" && process.version; - return isNode ? new NodeInfo(process.version.slice(1)) : null; +function er$1() { + return !getDocument_1() && !!getNavigator_1() && navigator.product === xn; } -function createVersionParts(count) { - var output = []; - for (var ii = 0; ii < count; ii++) { - output.push("0"); - } - return output; +function pr$1() { + return !pi() && !!getNavigator_1() && !!getDocument_1(); } -var cjs$2 = {}; -Object.defineProperty(cjs$2, "__esModule", { value: true }); -cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; -function getFromWindow(name2) { - let res = void 0; - if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { - res = window[name2]; +function We$2() { + return er$1() ? qt$1.reactNative : pi() ? qt$1.node : pr$1() ? qt$1.browser : qt$1.unknown; +} +function Wo() { + var e2; + try { + return er$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e2 = global.Application) == null ? void 0 : e2.applicationId : void 0; + } catch { + return; } - return res; } -cjs$2.getFromWindow = getFromWindow; -function getFromWindowOrThrow(name2) { - const res = getFromWindow(name2); - if (!res) { - throw new Error(`${name2} is not defined in Window`); +function Sn(e2, t2) { + let r3 = queryString.parse(e2); + return r3 = wn(wn({}, r3), t2), e2 = queryString.stringify(r3), e2; +} +function Xo() { + return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; +} +function Nn() { + if (We$2() === qt$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { + const { OS: r3, Version: i2 } = global.Platform; + return [r3, i2].join("-"); } - return res; + const e2 = detect(); + if (e2 === null) + return "unknown"; + const t2 = e2.os ? e2.os.replace(" ", "").toLowerCase() : "unknown"; + return e2.type === "browser" ? [t2, e2.name, e2.version].join("-") : [t2, e2.version].join("-"); +} +function In() { + var e2; + const t2 = We$2(); + return t2 === qt$1.browser ? [t2, ((e2 = getLocation_1()) == null ? void 0 : e2.host) || "unknown"].join(":") : t2; +} +function _n(e2, t2, r3) { + const i2 = Nn(), n4 = In(); + return [[e2, t2].join("-"), [En, r3].join("-"), i2, n4].join("/"); +} +function $o({ protocol: e2, version: t2, relayUrl: r3, sdkVersion: i2, auth: n4, projectId: o2, useOnCloseEvent: h4, bundleId: p2 }) { + const b3 = r3.split("?"), m3 = _n(e2, t2, i2), w3 = { auth: n4, ua: m3, projectId: o2, useOnCloseEvent: h4 || void 0, origin: p2 || void 0 }, y3 = Sn(b3[1] || "", w3); + return b3[0] + "?" + y3; +} +function _e$1(e2, t2) { + return e2.filter((r3) => t2.includes(r3)).length === e2.length; +} +function i0(e2) { + return Object.fromEntries(e2.entries()); +} +function n0(e2) { + return new Map(Object.entries(e2)); +} +function a0(e2 = cjs$3.FIVE_MINUTES, t2) { + const r3 = cjs$3.toMiliseconds(e2 || cjs$3.FIVE_MINUTES); + let i2, n4, o2; + return { resolve: (h4) => { + o2 && i2 && (clearTimeout(o2), i2(h4)); + }, reject: (h4) => { + o2 && n4 && (clearTimeout(o2), n4(h4)); + }, done: () => new Promise((h4, p2) => { + o2 = setTimeout(() => { + p2(new Error(t2)); + }, r3), i2 = h4, n4 = p2; + }) }; } -cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; -function getDocumentOrThrow() { - return getFromWindowOrThrow("document"); +function u0(e2, t2, r3) { + return new Promise(async (i2, n4) => { + const o2 = setTimeout(() => n4(new Error(r3)), t2); + try { + const h4 = await e2; + i2(h4); + } catch (h4) { + n4(h4); + } + clearTimeout(o2); + }); } -cjs$2.getDocumentOrThrow = getDocumentOrThrow; -function getDocument() { - return getFromWindow("document"); +function vi(e2, t2) { + if (typeof t2 == "string" && t2.startsWith(`${e2}:`)) + return t2; + if (e2.toLowerCase() === "topic") { + if (typeof t2 != "string") + throw new Error('Value must be "string" for expirer target type: topic'); + return `topic:${t2}`; + } else if (e2.toLowerCase() === "id") { + if (typeof t2 != "number") + throw new Error('Value must be "number" for expirer target type: id'); + return `id:${t2}`; + } + throw new Error(`Unknown expirer target type: ${e2}`); } -var getDocument_1 = cjs$2.getDocument = getDocument; -function getNavigatorOrThrow() { - return getFromWindowOrThrow("navigator"); +function h0(e2) { + return vi("topic", e2); } -cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; -function getNavigator() { - return getFromWindow("navigator"); +function c0(e2) { + return vi("id", e2); } -var getNavigator_1 = cjs$2.getNavigator = getNavigator; -function getLocationOrThrow() { - return getFromWindowOrThrow("location"); +function l0(e2) { + const [t2, r3] = e2.split(":"), i2 = { id: void 0, topic: void 0 }; + if (t2 === "topic" && typeof r3 == "string") + i2.topic = r3; + else if (t2 === "id" && Number.isInteger(Number(r3))) + i2.id = Number(r3); + else + throw new Error(`Invalid target, expected id:number or topic:string, got ${t2}:${r3}`); + return i2; } -cjs$2.getLocationOrThrow = getLocationOrThrow; -function getLocation() { - return getFromWindow("location"); +function d0(e2, t2) { + return cjs$3.fromMiliseconds(Date.now() + cjs$3.toMiliseconds(e2)); } -var getLocation_1 = cjs$2.getLocation = getLocation; -function getCryptoOrThrow() { - return getFromWindowOrThrow("crypto"); +function p0(e2) { + return Date.now() >= cjs$3.toMiliseconds(e2); } -cjs$2.getCryptoOrThrow = getCryptoOrThrow; -function getCrypto() { - return getFromWindow("crypto"); +function v0(e2, t2) { + return `${e2}${t2 ? `:${t2}` : ""}`; } -cjs$2.getCrypto = getCrypto; -function getLocalStorageOrThrow() { - return getFromWindowOrThrow("localStorage"); +function ge$1(e2 = [], t2 = []) { + return [.../* @__PURE__ */ new Set([...e2, ...t2])]; } -cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; -function getLocalStorage() { - return getFromWindow("localStorage"); +async function m0({ id: e2, topic: t2, wcDeepLink: r3 }) { + try { + if (!r3) + return; + const i2 = typeof r3 == "string" ? JSON.parse(r3) : r3; + let n4 = i2 == null ? void 0 : i2.href; + if (typeof n4 != "string") + return; + n4.endsWith("/") && (n4 = n4.slice(0, -1)); + const o2 = `${n4}/wc?requestId=${e2}&sessionTopic=${t2}`, h4 = We$2(); + h4 === qt$1.browser ? o2.startsWith("https://") || o2.startsWith("http://") ? window.open(o2, "_blank", "noreferrer noopener") : window.open(o2, "_self", "noreferrer noopener") : h4 === qt$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(o2); + } catch (i2) { + console.error(i2); + } } -cjs$2.getLocalStorage = getLocalStorage; -var cjs$1 = {}; -Object.defineProperty(cjs$1, "__esModule", { value: true }); -var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; -const window_getters_1 = cjs$2; -function getWindowMetadata() { - let doc; - let loc; +async function g0(e2, t2) { try { - doc = window_getters_1.getDocumentOrThrow(); - loc = window_getters_1.getLocationOrThrow(); - } catch (e) { - return null; + return await e2.getItem(t2) || (pr$1() ? localStorage.getItem(t2) : void 0); + } catch (r3) { + console.error(r3); } - function getIcons() { - const links = doc.getElementsByTagName("link"); - const icons2 = []; - for (let i2 = 0; i2 < links.length; i2++) { - const link = links[i2]; - const rel = link.getAttribute("rel"); - if (rel) { - if (rel.toLowerCase().indexOf("icon") > -1) { - const href = link.getAttribute("href"); - if (href) { - if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { - let absoluteHref = loc.protocol + "//" + loc.host; - if (href.indexOf("/") === 0) { - absoluteHref += href; - } else { - const path = loc.pathname.split("/"); - path.pop(); - const finalPath = path.join("/"); - absoluteHref += finalPath + "/" + href; - } - icons2.push(absoluteHref); - } else if (href.indexOf("//") === 0) { - const absoluteUrl = loc.protocol + href; - icons2.push(absoluteUrl); - } else { - icons2.push(href); - } - } - } +} +var On$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function A0$1(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; +} +var Pn$1 = { exports: {} }; +/** +* [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 +*/ +(function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On$1 : o2 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s2(u3, E2, u3).update(B2)[_3](); + }; + }, H2 = function(u3, E2, _3) { + return function(B2, R2) { + return new s2(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s2(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H2(u3, E2, "hex"); + return _3.create = function(B2) { + return new s2(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H2, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s2(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s2(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N2[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; } + return this; + }, s2.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s2.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s2.call(this, u3, E2, _3); } - return icons2; - } - function getWindowMetadataOfAny(...args) { - const metaTags = doc.getElementsByTagName("meta"); - for (let i2 = 0; i2 < metaTags.length; i2++) { - const tag = metaTags[i2]; - const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { - if (attr) { - return args.includes(attr); - } - return false; - }); - if (attributes.length && attributes) { - const content = tag.getAttribute("content"); - if (content) { - return content; - } + v3.prototype = new s2(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne, Ie; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z2 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z2 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _3 = D2 ^ (Z2 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne = u3[42] << 2 | u3[43] >>> 30, Ie = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne, u3[45] = Me2 ^ ~Se2 & Ie, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne & St2, u3[47] = Se2 ^ ~Ie & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne ^ ~St2 & Ve2, u3[49] = Ie ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); +})(Pn$1); +var b0 = Pn$1.exports; +const y0$1 = "logger/5.7.0"; +let Dn$1 = false, Fn$1 = false; +const Cr$2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let Tn$1 = Cr$2.default, gi$1 = null; +function w0$1() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); } - } - return ""; + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; } - function getName() { - let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); - if (!name3) { - name3 = doc.title; - } - return name3; + return null; +} +const Un$1 = w0$1(); +var Ai$1; +(function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; +})(Ai$1 || (Ai$1 = {})); +var re$2; +(function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; +})(re$2 || (re$2 = {})); +const kn$1 = "0123456789abcdef"; +let L$3 = class L2 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); } - function getDescription() { - const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); - return description3; + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr$2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn$1 > Cr$2[i2]) && console.log.apply(console, r3); } - const name2 = getName(); - const description2 = getDescription(); - const url = loc.origin; - const icons = getIcons(); - const meta = { - description: description2, - url, - icons, - name: name2 - }; - return meta; -} -getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; -var queryString = {}; -var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); -var token = "%[a-f0-9]{2}"; -var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); -var multiMatcher = new RegExp("(" + token + ")+", "gi"); -function decodeComponents(components, split) { - try { - return [decodeURIComponent(components.join(""))]; - } catch (err) { + debug(...t2) { + this._log(L2.levels.DEBUG, t2); } - if (components.length === 1) { - return components; + info(...t2) { + this._log(L2.levels.INFO, t2); } - split = split || 1; - var left = components.slice(0, split); - var right = components.slice(split); - return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); -} -function decode(input) { - try { - return decodeURIComponent(input); - } catch (err) { - var tokens = input.match(singleMatcher) || []; - for (var i2 = 1; i2 < tokens.length; i2++) { - input = decodeComponents(tokens, i2).join(""); - tokens = input.match(singleMatcher) || []; - } - return input; + warn(...t2) { + this._log(L2.levels.WARNING, t2); } -} -function customDecodeURIComponent(input) { - var replaceMap = { - "%FE%FF": "��", - "%FF%FE": "��" - }; - var match = multiMatcher.exec(input); - while (match) { - try { - replaceMap[match[0]] = decodeURIComponent(match[0]); - } catch (err) { - var result = decode(match[0]); - if (result !== match[0]) { - replaceMap[match[0]] = result; + makeError(t2, r3, i2) { + if (Fn$1) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L2.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn$1[m3[y3] >> 4], w3 += kn$1[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o2 = t2; + let h4 = ""; + switch (r3) { + case re$2.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; } + case re$2.CALL_EXCEPTION: + case re$2.INSUFFICIENT_FUNDS: + case re$2.MISSING_NEW: + case re$2.NONCE_EXPIRED: + case re$2.REPLACEMENT_UNDERPRICED: + case re$2.TRANSACTION_REPLACED: + case re$2.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; } - match = multiMatcher.exec(input); + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; } - replaceMap["%C2"] = "�"; - var entries = Object.keys(replaceMap); - for (var i2 = 0; i2 < entries.length; i2++) { - var key = entries[i2]; - input = input.replace(new RegExp(key, "g"), replaceMap[key]); + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); } - return input; -} -var decodeUriComponent = function(encodedURI) { - if (typeof encodedURI !== "string") { - throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L2.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); } - try { - encodedURI = encodedURI.replace(/\+/g, " "); - return decodeURIComponent(encodedURI); - } catch (err) { - return customDecodeURIComponent(encodedURI); + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); } -}; -var splitOnFirst = (string2, separator) => { - if (!(typeof string2 === "string" && typeof separator === "string")) { - throw new TypeError("Expected the arguments to be of type `string`"); + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); } - if (separator === "") { - return [string2]; + checkNormalize(t2) { + Un$1 && this.throwError("platform missing String.prototype.normalize", L2.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un$1 }); } - const separatorIndex = string2.indexOf(separator); - if (separatorIndex === -1) { - return [string2]; + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); } - return [ - string2.slice(0, separatorIndex), - string2.slice(separatorIndex + separator.length) - ]; -}; -var filterObj = function(obj, predicate) { - var ret = {}; - var keys2 = Object.keys(obj); - var isArr = Array.isArray(predicate); - for (var i2 = 0; i2 < keys2.length; i2++) { - var key = keys2[i2]; - var val = obj[key]; - if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { - ret[key] = val; + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L2.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L2.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); + } + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r3.name }); + } + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L2.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r3.name }); + } + static globalLogger() { + return gi$1 || (gi$1 = new L2(y0$1)), gi$1; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn$1) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } + Fn$1 = !!t2, Dn$1 = !!r3; } - return ret; -}; -(function(exports2) { - const strictUriEncode$1 = strictUriEncode; - const decodeComponent = decodeUriComponent; - const splitOnFirst$1 = splitOnFirst; - const filterObject = filterObj; - const isNullOrUndefined = (value) => value === null || value === void 0; - const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); - function encoderForArrayFormat(options) { - switch (options.arrayFormat) { - case "index": - return (key) => (result, value) => { - const index = result.length; - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[", index, "]"].join("")]; - } - return [ - ...result, - [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") - ]; - }; - case "bracket": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[]"].join("")]; - } - return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; - }; - case "colon-list-separator": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), ":list="].join("")]; - } - return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; - }; - case "comma": - case "separator": - case "bracket-separator": { - const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - value = value === null ? "" : value; - if (result.length === 0) { - return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; - } - return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; - }; - } - default: - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, encode2(key, options)]; - } - return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; - }; + static setLogLevel(t2) { + const r3 = Cr$2[t2.toLowerCase()]; + if (r3 == null) { + L2.globalLogger().warn("invalid log level - " + t2); + return; } + Tn$1 = r3; } - function parserForArrayFormat(options) { - let result; - switch (options.arrayFormat) { - case "index": - return (key, value, accumulator) => { - result = /\[(\d*)\]$/.exec(key); - key = key.replace(/\[\d*\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = {}; - } - accumulator[key][result[1]] = value; - }; - case "bracket": - return (key, value, accumulator) => { - result = /(\[\])$/.exec(key); - key = key.replace(/\[\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "colon-list-separator": - return (key, value, accumulator) => { - result = /(:list)$/.exec(key); - key = key.replace(/:list$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "comma": - case "separator": - return (key, value, accumulator) => { - const isArray2 = typeof value === "string" && value.includes(options.arrayFormatSeparator); - const isEncodedArray = typeof value === "string" && !isArray2 && decode2(value, options).includes(options.arrayFormatSeparator); - value = isEncodedArray ? decode2(value, options) : value; - const newValue = isArray2 || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); - accumulator[key] = newValue; - }; - case "bracket-separator": - return (key, value, accumulator) => { - const isArray2 = /(\[\])$/.test(key); - key = key.replace(/\[\]$/, ""); - if (!isArray2) { - accumulator[key] = value ? decode2(value, options) : value; - return; - } - const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); - if (accumulator[key] === void 0) { - accumulator[key] = arrayValue; - return; - } - accumulator[key] = [].concat(accumulator[key], arrayValue); - }; - default: - return (key, value, accumulator) => { - if (accumulator[key] === void 0) { - accumulator[key] = value; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; + static from(t2) { + return new L2(t2); + } +}; +L$3.errors = re$2, L$3.levels = Ai$1; +const x0$1 = "bytes/5.7.0", Dt$2 = new L$3(x0$1); +function qn$1(e2) { + return !!e2.toHexString; +} +function rr$2(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr$2(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; +} +function M0(e2) { + return Qt$1(e2) && !(e2.length % 2) || ir$2(e2); +} +function Kn$1(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; +} +function ir$2(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn$1(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn$1(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; +} +function Ot$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr$2(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2) && (e2 = e2.toHexString()), Qt$1(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr$2(new Uint8Array(i2)); + } + return ir$2(e2) ? rr$2(new Uint8Array(e2)) : Dt$2.throwArgumentError("invalid arrayify value", "value", e2); +} +function E0(e2) { + const t2 = e2.map((n4) => Ot$2(n4)), r3 = t2.reduce((n4, o2) => n4 + o2.length, 0), i2 = new Uint8Array(r3); + return t2.reduce((n4, o2) => (i2.set(o2, n4), n4 + o2.length), 0), rr$2(i2); +} +function S0(e2, t2) { + e2 = Ot$2(e2), e2.length > t2 && Dt$2.throwArgumentError("value out of range", "value", arguments[0]); + const r3 = new Uint8Array(t2); + return r3.set(e2, t2 - e2.length), rr$2(r3); +} +function Qt$1(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2 && e2.length !== 2 + 2 * t2); +} +const bi$1 = "0123456789abcdef"; +function Kt$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi$1[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2)) + return e2.toHexString(); + if (Qt$1(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir$2(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi$1[(n4 & 240) >> 4] + bi$1[n4 & 15]; + } + return r3; + } + return Dt$2.throwArgumentError("invalid hexlify value", "value", e2); +} +function N0(e2) { + if (typeof e2 != "string") + e2 = Kt$2(e2); + else if (!Qt$1(e2) || e2.length % 2) + return null; + return (e2.length - 2) / 2; +} +function Hn(e2, t2, r3) { + return typeof e2 != "string" ? e2 = Kt$2(e2) : (!Qt$1(e2) || e2.length % 2) && Dt$2.throwArgumentError("invalid hexData", "value", e2), t2 = 2 + 2 * t2, r3 != null ? "0x" + e2.substring(t2, 2 + 2 * r3) : "0x" + e2.substring(t2); +} +function oe$1(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt$2(e2) : Qt$1(e2) || Dt$2.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt$2.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; +} +function zn(e2) { + const t2 = { r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0, yParityAndS: "0x", compact: "0x" }; + if (M0(e2)) { + let r3 = Ot$2(e2); + r3.length === 64 ? (t2.v = 27 + (r3[32] >> 7), r3[32] &= 127, t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64))) : r3.length === 65 ? (t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64)), t2.v = r3[64]) : Dt$2.throwArgumentError("invalid signature string", "signature", e2), t2.v < 27 && (t2.v === 0 || t2.v === 1 ? t2.v += 27 : Dt$2.throwArgumentError("signature invalid v byte", "signature", e2)), t2.recoveryParam = 1 - t2.v % 2, t2.recoveryParam && (r3[32] |= 128), t2._vs = Kt$2(r3.slice(32, 64)); + } else { + if (t2.r = e2.r, t2.s = e2.s, t2.v = e2.v, t2.recoveryParam = e2.recoveryParam, t2._vs = e2._vs, t2._vs != null) { + const n4 = S0(Ot$2(t2._vs), 32); + t2._vs = Kt$2(n4); + const o2 = n4[0] >= 128 ? 1 : 0; + t2.recoveryParam == null ? t2.recoveryParam = o2 : t2.recoveryParam !== o2 && Dt$2.throwArgumentError("signature recoveryParam mismatch _vs", "signature", e2), n4[0] &= 127; + const h4 = Kt$2(n4); + t2.s == null ? t2.s = h4 : t2.s !== h4 && Dt$2.throwArgumentError("signature v mismatch _vs", "signature", e2); + } + if (t2.recoveryParam == null) + t2.v == null ? Dt$2.throwArgumentError("signature missing v and recoveryParam", "signature", e2) : t2.v === 0 || t2.v === 1 ? t2.recoveryParam = t2.v : t2.recoveryParam = 1 - t2.v % 2; + else if (t2.v == null) + t2.v = 27 + t2.recoveryParam; + else { + const n4 = t2.v === 0 || t2.v === 1 ? t2.v : 1 - t2.v % 2; + t2.recoveryParam !== n4 && Dt$2.throwArgumentError("signature recoveryParam mismatch v", "signature", e2); + } + t2.r == null || !Qt$1(t2.r) ? Dt$2.throwArgumentError("signature missing or invalid r", "signature", e2) : t2.r = oe$1(t2.r, 32), t2.s == null || !Qt$1(t2.s) ? Dt$2.throwArgumentError("signature missing or invalid s", "signature", e2) : t2.s = oe$1(t2.s, 32); + const r3 = Ot$2(t2.s); + r3[0] >= 128 && Dt$2.throwArgumentError("signature s out of range", "signature", e2), t2.recoveryParam && (r3[0] |= 128); + const i2 = Kt$2(r3); + t2._vs && (Qt$1(t2._vs) || Dt$2.throwArgumentError("signature invalid _vs", "signature", e2), t2._vs = oe$1(t2._vs, 32)), t2._vs == null ? t2._vs = i2 : t2._vs !== i2 && Dt$2.throwArgumentError("signature _vs mismatch v and s", "signature", e2); + } + return t2.yParityAndS = t2._vs, t2.compact = t2.r + t2.yParityAndS.substring(2), t2; +} +function yi(e2) { + return "0x" + b0.keccak_256(Ot$2(e2)); +} +var Ln$1 = { exports: {} }, I0$1 = {}, _0$1 = Object.freeze({ __proto__: null, default: I0$1 }), B0$1 = A0$1(_0$1); +(function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; + } + function o2(A2, f3, a3) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r3.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0$1.Buffer; + } catch { } + o2.isBN = function(f3) { + return f3 instanceof o2 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o2.wordSize && Array.isArray(f3.words); + }, o2.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o2.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o2.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o2.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o2.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + } + this._strip(); + }; + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o2.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v3 = c2; v3 < l2; v3 += d5) + s2 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o2.prototype._move = function(f3) { + w3(f3, this); + }, o2.prototype.clone = function() { + var f3 = new o2(null); + return this.copy(f3), f3; + }, o2.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o2.prototype.inspect = y3; + } + else + o2.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s2 = I2[f3], v3 = N2[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s2 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o2.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o2.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o2.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o2.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o2.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o2.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; + } + return f3; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o2.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o2.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o2.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o2.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o2.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o2.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o2.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o2.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o2.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o2.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o2.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o2.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o2.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o2.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o2.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s2, f3.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s2 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s2] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s2] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s2, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te = d5[6] | 0, et2 = Te & 8191, rt2 = Te >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le = g3[3] | 0, vt2 = Le & 8191, mt2 = Le >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s2 = Math.imul(u3, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s2 = s2 + Math.imul(u3, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s2 = s2 + Math.imul(u3, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s2 = s2 + Math.imul(u3, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ne >>> 26) | 0, Ne &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v3 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s2 = s2 + Math.imul(u3, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v3 = v3 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s2 = s2 + Math.imul(u3, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v3 = v3 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s2 = s2 + Math.imul(u3, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v3 = v3 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s2 = s2 + Math.imul(u3, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v3 = v3 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s2 = s2 + Math.imul(u3, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v3 = v3 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s2 = s2 + Math.imul(u3, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v3 = v3 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v3 = v3 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v3 = v3 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v3 = v3 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v3 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne, x2[4] = Ie, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s2 = Math.max(0, g3 - A2.length + 1); s2 <= l2; s2++) { + var v3 = g3 - s2, k2 = A2.words[v3] | 0, u3 = f3.words[s2] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o2.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o2.prototype.mul = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o2.prototype.mulf = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o2.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o2.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o2.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o2(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o2.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o2.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v3 !== 0 || s2 >= d5); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o2.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o2.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o2.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o2.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o2.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o2.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o2.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o2.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o2.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o2.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o2.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s2; + if (a3 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v3 = 0; v3 < s2.length; v3++) + s2.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s2 && (s2.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s2 && (s2.words[u3] = E2); + } + return s2 && s2._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s2 || null, mod: d5 }; + }, o2.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o2(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o2(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o2(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o2.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o2.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o2.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o2.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o2.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o2.prototype.modn = function(f3) { + return this.modrn(f3); + }, o2.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o2.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o2.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s2), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s2 = 0, v3 = 1; !(c2.words[0] & v3) && s2 < 26; ++s2, v3 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o2.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o2.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o2.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o2.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; + } + } + return a3; + }, o2.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o2.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o2.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o2.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o2.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o2.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o2.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o2.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o2.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o2.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o2.red = function(f3) { + return new Y2(f3); + }, o2.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o2.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o2.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o2.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o2.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o2.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o2.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o2.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o2.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o2(f3, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o2(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o2._prime = function(f3) { + if (H2[f3]) + return H2[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H2[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o2._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v3 = this.pow(s2, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o2(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o2(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s2 = a3.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s2 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o2.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o2(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On$1); +})(Ln$1); +var K$2 = Ln$1.exports; +const jn$1 = "bignumber/5.7.0"; +var Rr$2 = K$2.BN; +const Ae$1 = new L$3(jn$1), wi$1 = {}, Qn$1 = 9007199254740991; +function C0$1(e2) { + return e2 != null && (V$2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt$1(e2) || typeof e2 == "bigint" || ir$2(e2)); +} +let Jn$1 = false; +let V$2 = class V { + constructor(t2, r3) { + t2 !== wi$1 && Ae$1.throwError("cannot call constructor directly; use BigNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); } - function validateArrayFormatSeparator(value) { - if (typeof value !== "string" || value.length !== 1) { - throw new TypeError("arrayFormatSeparator must be single character string"); - } + fromTwos(t2) { + return Lt$2(j$2(this).fromTwos(t2)); } - function encode2(value, options) { - if (options.encode) { - return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); - } - return value; + toTwos(t2) { + return Lt$2(j$2(this).toTwos(t2)); } - function decode2(value, options) { - if (options.decode) { - return decodeComponent(value); - } - return value; + abs() { + return this._hex[0] === "-" ? V.from(this._hex.substring(1)) : this; } - function keysSorter(input) { - if (Array.isArray(input)) { - return input.sort(); - } - if (typeof input === "object") { - return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); - } - return input; + add(t2) { + return Lt$2(j$2(this).add(j$2(t2))); } - function removeHash(input) { - const hashStart = input.indexOf("#"); - if (hashStart !== -1) { - input = input.slice(0, hashStart); - } - return input; + sub(t2) { + return Lt$2(j$2(this).sub(j$2(t2))); } - function getHash(url) { - let hash2 = ""; - const hashStart = url.indexOf("#"); - if (hashStart !== -1) { - hash2 = url.slice(hashStart); - } - return hash2; + div(t2) { + return V.from(t2).isZero() && Wt$3("division-by-zero", "div"), Lt$2(j$2(this).div(j$2(t2))); } - function extract(input) { - input = removeHash(input); - const queryStart = input.indexOf("?"); - if (queryStart === -1) { - return ""; - } - return input.slice(queryStart + 1); + mul(t2) { + return Lt$2(j$2(this).mul(j$2(t2))); } - function parseValue(value, options) { - if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { - value = Number(value); - } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { - value = value.toLowerCase() === "true"; - } - return value; + mod(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("division-by-zero", "mod"), Lt$2(j$2(this).umod(r3)); } - function parse(query, options) { - options = Object.assign({ - decode: true, - sort: true, - arrayFormat: "none", - arrayFormatSeparator: ",", - parseNumbers: false, - parseBooleans: false - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const formatter = parserForArrayFormat(options); - const ret = /* @__PURE__ */ Object.create(null); - if (typeof query !== "string") { - return ret; - } - query = query.trim().replace(/^[?#&]/, ""); - if (!query) { - return ret; + pow(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("negative-power", "pow"), Lt$2(j$2(this).pow(r3)); + } + and(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "and"), Lt$2(j$2(this).and(r3)); + } + or(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "or"), Lt$2(j$2(this).or(r3)); + } + xor(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "xor"), Lt$2(j$2(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "mask"), Lt$2(j$2(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shl"), Lt$2(j$2(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shr"), Lt$2(j$2(this).shrn(t2)); + } + eq(t2) { + return j$2(this).eq(j$2(t2)); + } + lt(t2) { + return j$2(this).lt(j$2(t2)); + } + lte(t2) { + return j$2(this).lte(j$2(t2)); + } + gt(t2) { + return j$2(this).gt(j$2(t2)); + } + gte(t2) { + return j$2(this).gte(j$2(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j$2(this).isZero(); + } + toNumber() { + try { + return j$2(this).toNumber(); + } catch { + Wt$3("overflow", "toNumber", this.toString()); } - for (const param of query.split("&")) { - if (param === "") { - continue; - } - let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); - value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); - formatter(decode2(key, options), value, ret); + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { } - for (const key of Object.keys(ret)) { - const value = ret[key]; - if (typeof value === "object" && value !== null) { - for (const k2 of Object.keys(value)) { - value[k2] = parseValue(value[k2], options); - } + return Ae$1.throwError("this platform does not support BigInt", L$3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn$1 || (Jn$1 = true, Ae$1.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae$1.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L$3.errors.UNEXPECTED_ARGUMENT, {}) : Ae$1.throwError("BigNumber.toString does not accept parameters", L$3.errors.UNEXPECTED_ARGUMENT, {})), j$2(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V(wi$1, vr$1(t2)) : t2.match(/^-?[0-9]+$/) ? new V(wi$1, vr$1(new Rr$2(t2))) : Ae$1.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt$3("underflow", "BigNumber.from", t2), (t2 >= Qn$1 || t2 <= -Qn$1) && Wt$3("overflow", "BigNumber.from", t2), V.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V.from(r3.toString()); + if (ir$2(r3)) + return V.from(Kt$2(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V.from(i2); } else { - ret[key] = parseValue(value, options); - } + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt$1(i2) || i2[0] === "-" && Qt$1(i2.substring(1)))) + return V.from(i2); + } + return Ae$1.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } +}; +function vr$1(e2) { + if (typeof e2 != "string") + return vr$1(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae$1.throwArgumentError("invalid hex", "value", e2), e2 = vr$1(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; +} +function Lt$2(e2) { + return V$2.from(vr$1(e2)); +} +function j$2(e2) { + const t2 = V$2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr$2("-" + t2.substring(3), 16) : new Rr$2(t2.substring(2), 16); +} +function Wt$3(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae$1.throwError(e2, L$3.errors.NUMERIC_FAULT, i2); +} +function R0(e2) { + return new Rr$2(e2, 36).toString(16); +} +const Ht$3 = new L$3(jn$1), mr$2 = {}, Gn$1 = V$2.from(0), Yn$1 = V$2.from(-1); +function Vn$1(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht$3.throwError(e2, L$3.errors.NUMERIC_FAULT, n4); +} +let gr$2 = "0"; +for (; gr$2.length < 256; ) + gr$2 += gr$2; +function xi$1(e2) { + if (typeof e2 != "number") + try { + e2 = V$2.from(e2).toNumber(); + } catch { } - if (options.sort === false) { - return ret; + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr$2.substring(0, e2) : Ht$3.throwArgumentError("invalid decimal size", "decimals", e2); +} +function Mi$1(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + e2 = V$2.from(e2); + const i2 = e2.lt(Gn$1); + i2 && (e2 = e2.mul(Yn$1)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o2 : e2 = o2 + "." + n4, i2 && (e2 = "-" + e2), e2; +} +function be$2(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht$3.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht$3.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht$3.throwArgumentError("too many decimal points", "value", e2); + let o2 = n4[0], h4 = n4[1]; + for (o2 || (o2 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn$1("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V$2.from(o2), b3 = V$2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn$1)), m3; +} +let dr$2 = class dr { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi$1(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht$3.throwArgumentError("invalid fixed format", "format", t2), r3 = o2[1] !== "u", i2 = parseInt(o2[2]), n4 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht$3.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o2("signed", "boolean", r3), i2 = o2("width", "number", i2), n4 = o2("decimals", "number", n4); + } + return i2 % 8 && Ht$3.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht$3.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr(mr$2, r3, i2, n4); + } +}; +let Ut$2 = class Ut { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht$3.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn$1.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn$1.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht$3.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut.from("1" + gr$2.substring(0, t2), this.format), n4 = O0$1.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); + } + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht$3.throwArgumentError("invalid byte width", "width", t2); + const r3 = V$2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe$1(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0$1(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut.fromString(Mi$1(t2, r3), dr$2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3), n4 = be$2(t2, i2.decimals); + !i2.signed && n4.lt(Gn$1) && Vn$1("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n4.toTwos(i2.width).toHexString() : (o2 = n4.toHexString(), o2 = oe$1(o2, i2.width / 8)); + const h4 = Mi$1(n4, i2.decimals); + return new Ut(mr$2, o2, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3); + if (Ot$2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V$2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o2 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi$1(n4, i2.decimals); + return new Ut(mr$2, o2, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut.fromString(t2, r3); + if (ir$2(t2)) + return Ut.fromBytes(t2, r3); + try { + return Ut.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L$3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht$3.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } +}; +const Wn$1 = Ut$2.from(1), O0$1 = Ut$2.from("0.5"), P0 = "strings/5.7.0", Xn = new L$3(P0); +var Or$2; +(function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; +})(Or$2 || (Or$2 = {})); +var nr$2; +(function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; +})(nr$2 || (nr$2 = {})); +function Ei(e2, t2 = Or$2.current) { + t2 != Or$2.current && (Xn.checkNormalize(), e2 = e2.normalize(t2)); + let r3 = []; + for (let i2 = 0; i2 < e2.length; i2++) { + const n4 = e2.charCodeAt(i2); + if (n4 < 128) + r3.push(n4); + else if (n4 < 2048) + r3.push(n4 >> 6 | 192), r3.push(n4 & 63 | 128); + else if ((n4 & 64512) == 55296) { + i2++; + const o2 = e2.charCodeAt(i2); + if (i2 >= e2.length || (o2 & 64512) !== 56320) + throw new Error("invalid utf-8 string"); + const h4 = 65536 + ((n4 & 1023) << 10) + (o2 & 1023); + r3.push(h4 >> 18 | 240), r3.push(h4 >> 12 & 63 | 128), r3.push(h4 >> 6 & 63 | 128), r3.push(h4 & 63 | 128); + } else + r3.push(n4 >> 12 | 224), r3.push(n4 >> 6 & 63 | 128), r3.push(n4 & 63 | 128); + } + return Ot$2(r3); +} +function T0$1(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; +} +function Si$1(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; + }); + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o2 = n4.split(":"); + r3 += parseInt(o2[0], 16), i2[r3] = t2(o2[1]); + }), i2; +} +function $n$1(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); +} +$n$1("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si$1("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si$1("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si$1("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0$1), $n$1("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function U0$1(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot$2(t2); +} +function ef$1(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o2, h4) { + i2.call(o2, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); + }); + }; + return n4(e2, t2), r3; +} +function k0$1(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; +} +function q0$1(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y3; H2++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H2 < o2[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; } - return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { - const value = ret[key]; - if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { - result[key] = keysSorter(value); - } else { - result[key] = value; + }); +} +function K0$1(e2) { + let t2 = 0; + return () => e2[t2++]; +} +function H0$1(e2) { + return K0$1(q0$1(e2)); +} +function z0$1(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; +} +function L0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; +} +function rf$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; +} +function j0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0$1(t2()); + return r3; +} +function Pr$2(e2, t2) { + let r3 = rf$1(e2(), e2), i2 = e2(), n4 = rf$1(i2, e2), o2 = L0$1(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o2[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; +} +function Q0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0$1(r3, e2)); + } + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0$1(r3, e2)); + } + return k0$1(ef$1(t2)); +} +function J0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); + } + return t2; +} +function nf$1(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0$1(e2, r3).forEach((o2, h4) => i2[h4].push(o2)); + return i2; +} +function G0$1(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0$1(t2), o2 = nf$1(n4.length, 1 + e2, t2); + return ef$1(o2.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; + }); + })); +} +function Y0$1(e2, t2) { + let r3 = 1 + t2(); + return nf$1(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); +} +function V0$1(e2) { + let t2 = Pr$2(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr$2(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o2 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o2, fe0f: h4, save: p2, check: b3 }; + } +} +function W0$1() { + return H0$1(U0$1("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); +} +const Dr$2 = W0$1(); +new Set(Pr$2(Dr$2)), new Set(Pr$2(Dr$2)), Q0$1(Dr$2), V0$1(Dr$2); +const X0$1 = new Uint8Array(32); +X0$1.fill(0); +const Z0 = `Ethereum Signed Message: +`; +function ff(e2) { + return typeof e2 == "string" && (e2 = Ei(e2)), yi(E0([Ei(Z0), Ei(String(e2.length)), e2])); +} +const ts$2 = "address/5.7.0", Ar$1 = new L$3(ts$2); +function of(e2) { + Qt$1(e2, 20) || Ar$1.throwArgumentError("invalid address", "address", e2), e2 = e2.toLowerCase(); + const t2 = e2.substring(2).split(""), r3 = new Uint8Array(40); + for (let n4 = 0; n4 < 40; n4++) + r3[n4] = t2[n4].charCodeAt(0); + const i2 = Ot$2(yi(r3)); + for (let n4 = 0; n4 < 40; n4 += 2) + i2[n4 >> 1] >> 4 >= 8 && (t2[n4] = t2[n4].toUpperCase()), (i2[n4 >> 1] & 15) >= 8 && (t2[n4 + 1] = t2[n4 + 1].toUpperCase()); + return "0x" + t2.join(""); +} +const es$2 = 9007199254740991; +function rs$2(e2) { + return Math.log10 ? Math.log10(e2) : Math.log(e2) / Math.LN10; +} +const Ni = {}; +for (let e2 = 0; e2 < 10; e2++) + Ni[String(e2)] = String(e2); +for (let e2 = 0; e2 < 26; e2++) + Ni[String.fromCharCode(65 + e2)] = String(10 + e2); +const sf = Math.floor(rs$2(es$2)); +function is$2(e2) { + e2 = e2.toUpperCase(), e2 = e2.substring(4) + e2.substring(0, 2) + "00"; + let t2 = e2.split("").map((i2) => Ni[i2]).join(""); + for (; t2.length >= sf; ) { + let i2 = t2.substring(0, sf); + t2 = parseInt(i2, 10) % 97 + t2.substring(i2.length); + } + let r3 = String(98 - parseInt(t2, 10) % 97); + for (; r3.length < 2; ) + r3 = "0" + r3; + return r3; +} +function ns$1(e2) { + let t2 = null; + if (typeof e2 != "string" && Ar$1.throwArgumentError("invalid address", "address", e2), e2.match(/^(0x)?[0-9a-fA-F]{40}$/)) + e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), t2 = of(e2), e2.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && t2 !== e2 && Ar$1.throwArgumentError("bad address checksum", "address", e2); + else if (e2.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + for (e2.substring(2, 4) !== is$2(e2) && Ar$1.throwArgumentError("bad icap checksum", "address", e2), t2 = R0(e2.substring(4)); t2.length < 40; ) + t2 = "0" + t2; + t2 = of("0x" + t2); + } else + Ar$1.throwArgumentError("invalid address", "address", e2); + return t2; +} +function br$1(e2, t2, r3) { + Object.defineProperty(e2, t2, { enumerable: true, value: r3, writable: false }); +} +const os$2 = new Uint8Array(32); +os$2.fill(0), V$2.from(-1); +const ss$3 = V$2.from(0), as$2 = V$2.from(1); +V$2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe$1(as$2.toHexString(), 32), oe$1(ss$3.toHexString(), 32); +var se$2 = {}, Q$2 = {}, yr$2 = af$1; +function af$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +af$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var Ii$1 = { exports: {} }; +typeof Object.create == "function" ? Ii$1.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); +} : Ii$1.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; + } +}; +var us$2 = yr$2, hs$2 = Ii$1.exports; +Q$2.inherits = hs$2; +function cs$2(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; +} +function ls$2(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o2 = e2.charCodeAt(n4); + o2 < 128 ? r3[i2++] = o2 : o2 < 2048 ? (r3[i2++] = o2 >> 6 | 192, r3[i2++] = o2 & 63 | 128) : cs$2(e2, n4) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o2 >> 18 | 240, r3[i2++] = o2 >> 12 & 63 | 128, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128) : (r3[i2++] = o2 >> 12 | 224, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128); } - return result; - }, /* @__PURE__ */ Object.create(null)); + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; +} +Q$2.toArray = ls$2; +function ds$2(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf$1(e2[r3].toString(16)); + return t2; +} +Q$2.toHex = ds$2; +function uf$1(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; +} +Q$2.htonl = uf$1; +function ps$2(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf$1(n4)), r3 += cf$1(n4.toString(16)); } - exports2.extract = extract; - exports2.parse = parse; - exports2.stringify = (object, options) => { - if (!object) { - return ""; - } - options = Object.assign({ - encode: true, - strict: true, - arrayFormat: "none", - arrayFormatSeparator: "," - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; - const formatter = encoderForArrayFormat(options); - const objectCopy = {}; - for (const key of Object.keys(object)) { - if (!shouldFilter(key)) { - objectCopy[key] = object[key]; + return r3; +} +Q$2.toHex32 = ps$2; +function hf$1(e2) { + return e2.length === 1 ? "0" + e2 : e2; +} +Q$2.zero2 = hf$1; +function cf$1(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; +} +Q$2.zero8 = cf$1; +function vs$2(e2, t2, r3, i2) { + var n4 = r3 - t2; + us$2(n4 % 4 === 0); + for (var o2 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o2.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h4] = b3 >>> 0; + } + return o2; +} +Q$2.join32 = vs$2; +function ms$3(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r3[n4] = o2 >>> 24, r3[n4 + 1] = o2 >>> 16 & 255, r3[n4 + 2] = o2 >>> 8 & 255, r3[n4 + 3] = o2 & 255) : (r3[n4 + 3] = o2 >>> 24, r3[n4 + 2] = o2 >>> 16 & 255, r3[n4 + 1] = o2 >>> 8 & 255, r3[n4] = o2 & 255); + } + return r3; +} +Q$2.split32 = ms$3; +function gs$2(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; +} +Q$2.rotr32 = gs$2; +function As$2(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; +} +Q$2.rotl32 = As$2; +function bs$2(e2, t2) { + return e2 + t2 >>> 0; +} +Q$2.sum32 = bs$2; +function ys$2(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; +} +Q$2.sum32_3 = ys$2; +function ws$2(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; +} +Q$2.sum32_4 = ws$2; +function xs$2(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; +} +Q$2.sum32_5 = xs$2; +function Ms$2(e2, t2, r3, i2) { + var n4 = e2[t2], o2 = e2[t2 + 1], h4 = i2 + o2 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; +} +Q$2.sum64 = Ms$2; +function Es$2(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o2 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o2 >>> 0; +} +Q$2.sum64_hi = Es$2; +function Ss$2(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; +} +Q$2.sum64_lo = Ss$2; +function Ns$2(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o2 >>> 0, b3 += m3 < o2 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; +} +Q$2.sum64_4_hi = Ns$2; +function Is$2(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = t2 + i2 + o2 + p2; + return b3 >>> 0; +} +Q$2.sum64_4_lo = Is$2; +function _s$2(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o2 >>> 0, w3 += y3 < o2 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; +} +Q$2.sum64_5_hi = _s$2; +function Bs$2(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = t2 + i2 + o2 + p2 + m3; + return w3 >>> 0; +} +Q$2.sum64_5_lo = Bs$2; +function Cs$2(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; +} +Q$2.rotr64_hi = Cs$2; +function Rs$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q$2.rotr64_lo = Rs$2; +function Os$2(e2, t2, r3) { + return e2 >>> r3; +} +Q$2.shr64_hi = Os$2; +function Ps$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q$2.shr64_lo = Ps$2; +var fr$1 = {}, lf$1 = Q$2, Ds$2 = yr$2; +function Fr$2() { + 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; +} +fr$1.BlockHash = Fr$2, Fr$2.prototype.update = function(t2, r3) { + if (t2 = lf$1.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf$1.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; +}, Fr$2.prototype.digest = function(t2) { + return this.update(this._pad()), Ds$2(this.pending === null), this._digest(t2); +}, Fr$2.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n4[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 & 255; + } else + for (n4[o2++] = t2 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + return n4; +}; +var or$2 = {}, ae$1 = {}, Fs$2 = Q$2, ue$1 = Fs$2.rotr32; +function Ts$2(e2, t2, r3, i2) { + if (e2 === 0) + return df$1(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf$1(t2, r3, i2); + if (e2 === 2) + return pf$1(t2, r3, i2); +} +ae$1.ft_1 = Ts$2; +function df$1(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; +} +ae$1.ch32 = df$1; +function pf$1(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; +} +ae$1.maj32 = pf$1; +function vf$1(e2, t2, r3) { + return e2 ^ t2 ^ r3; +} +ae$1.p32 = vf$1; +function Us$2(e2) { + return ue$1(e2, 2) ^ ue$1(e2, 13) ^ ue$1(e2, 22); +} +ae$1.s0_256 = Us$2; +function ks$2(e2) { + return ue$1(e2, 6) ^ ue$1(e2, 11) ^ ue$1(e2, 25); +} +ae$1.s1_256 = ks$2; +function qs$2(e2) { + return ue$1(e2, 7) ^ ue$1(e2, 18) ^ e2 >>> 3; +} +ae$1.g0_256 = qs$2; +function Ks$2(e2) { + return ue$1(e2, 17) ^ ue$1(e2, 19) ^ e2 >>> 10; +} +ae$1.g1_256 = Ks$2; +var sr$2 = Q$2, Hs$2 = fr$1, zs$2 = ae$1, _i$1 = sr$2.rotl32, wr$1 = sr$2.sum32, Ls$2 = sr$2.sum32_5, js$2 = zs$2.ft_1, mf$1 = Hs$2.BlockHash, Qs$2 = [1518500249, 1859775393, 2400959708, 3395469782]; +function he$1() { + if (!(this instanceof he$1)) + return new he$1(); + mf$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); +} +sr$2.inherits(he$1, mf$1); +var Js$2 = he$1; +he$1.blockSize = 512, he$1.outSize = 160, he$1.hmacStrength = 80, he$1.padLength = 64, he$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i$1(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls$2(_i$1(o2, 5), js$2(w3, h4, p2, b3), m3, i2[n4], Qs$2[w3]); + m3 = b3, b3 = p2, p2 = _i$1(h4, 30), h4 = o2, o2 = y3; + } + this.h[0] = wr$1(this.h[0], o2), this.h[1] = wr$1(this.h[1], h4), this.h[2] = wr$1(this.h[2], p2), this.h[3] = wr$1(this.h[3], b3), this.h[4] = wr$1(this.h[4], m3); +}, he$1.prototype._digest = function(t2) { + return t2 === "hex" ? sr$2.toHex32(this.h, "big") : sr$2.split32(this.h, "big"); +}; +var ar$2 = Q$2, Gs$2 = fr$1, ur$2 = ae$1, Ys$2 = yr$2, ie$3 = ar$2.sum32, Vs$2 = ar$2.sum32_4, Ws$2 = ar$2.sum32_5, Xs$2 = ur$2.ch32, Zs$2 = ur$2.maj32, $s$2 = ur$2.s0_256, ta$1 = ur$2.s1_256, ea$1 = ur$2.g0_256, ra$1 = ur$2.g1_256, gf$1 = Gs$2.BlockHash, ia$1 = [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 ce$1() { + if (!(this instanceof ce$1)) + return new ce$1(); + gf$1.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia$1, this.W = new Array(64); +} +ar$2.inherits(ce$1, gf$1); +var Af$1 = ce$1; +ce$1.blockSize = 512, ce$1.outSize = 256, ce$1.hmacStrength = 192, ce$1.padLength = 64, ce$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs$2(ra$1(i2[n4 - 2]), i2[n4 - 7], ea$1(i2[n4 - 15]), i2[n4 - 16]); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys$2(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws$2(S2, ta$1(m3), Xs$2(m3, w3, y3), this.k[n4], i2[n4]), N2 = ie$3($s$2(o2), Zs$2(o2, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie$3(b3, I2), b3 = p2, p2 = h4, h4 = o2, o2 = ie$3(I2, N2); + } + this.h[0] = ie$3(this.h[0], o2), this.h[1] = ie$3(this.h[1], h4), this.h[2] = ie$3(this.h[2], p2), this.h[3] = ie$3(this.h[3], b3), this.h[4] = ie$3(this.h[4], m3), this.h[5] = ie$3(this.h[5], w3), this.h[6] = ie$3(this.h[6], y3), this.h[7] = ie$3(this.h[7], S2); +}, ce$1.prototype._digest = function(t2) { + return t2 === "hex" ? ar$2.toHex32(this.h, "big") : ar$2.split32(this.h, "big"); +}; +var Bi$1 = Q$2, bf$1 = Af$1; +function ye$2() { + if (!(this instanceof ye$2)) + return new ye$2(); + bf$1.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; +} +Bi$1.inherits(ye$2, bf$1); +var na$1 = ye$2; +ye$2.blockSize = 512, ye$2.outSize = 224, ye$2.hmacStrength = 192, ye$2.padLength = 64, ye$2.prototype._digest = function(t2) { + return t2 === "hex" ? Bi$1.toHex32(this.h.slice(0, 7), "big") : Bi$1.split32(this.h.slice(0, 7), "big"); +}; +var jt$2 = Q$2, fa$1 = fr$1, oa$1 = yr$2, le$1 = jt$2.rotr64_hi, de$2 = jt$2.rotr64_lo, yf$1 = jt$2.shr64_hi, wf$1 = jt$2.shr64_lo, Be$3 = jt$2.sum64, Ci$1 = jt$2.sum64_hi, Ri$1 = jt$2.sum64_lo, sa$1 = jt$2.sum64_4_hi, aa$1 = jt$2.sum64_4_lo, ua$1 = jt$2.sum64_5_hi, ha$1 = jt$2.sum64_5_lo, xf$1 = fa$1.BlockHash, ca$1 = [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 ne$2() { + if (!(this instanceof ne$2)) + return new ne$2(); + xf$1.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca$1, this.W = new Array(160); +} +jt$2.inherits(ne$2, xf$1); +var Mf$1 = ne$2; +ne$2.blockSize = 1024, ne$2.outSize = 512, ne$2.hmacStrength = 192, ne$2.padLength = 128, ne$2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o2 = xa$1(i2[n4 - 4], i2[n4 - 3]), h4 = Ma$1(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya$1(i2[n4 - 30], i2[n4 - 29]), w3 = wa$1(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa$1(o2, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa$1(o2, h4, p2, b3, m3, w3, y3, S2); + } +}, ne$2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o2 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa$1(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa$1(S2, I2), W2 = ba$1(S2, I2), Rt2 = la$1(S2, I2, N2, C2, F2), Yt3 = da$1(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua$1(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha$1(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H2 = ma$1(n4, o2), z2 = ga$1(n4, o2), Pt2 = pa$1(n4, o2, h4, p2, b3), W2 = va$1(n4, o2, h4, p2, b3, m3); + var d5 = Ci$1(H2, z2, Pt2, W2), g3 = Ri$1(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci$1(w3, y3, a3, c2), I2 = Ri$1(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o2, n4 = Ci$1(a3, c2, d5, g3), o2 = Ri$1(a3, c2, d5, g3); + } + Be$3(this.h, 0, n4, o2), Be$3(this.h, 2, h4, p2), Be$3(this.h, 4, b3, m3), Be$3(this.h, 6, w3, y3), Be$3(this.h, 8, S2, I2), Be$3(this.h, 10, N2, C2), Be$3(this.h, 12, F2, U2), Be$3(this.h, 14, J2, Bt2); +}, ne$2.prototype._digest = function(t2) { + return t2 === "hex" ? jt$2.toHex32(this.h, "big") : jt$2.split32(this.h, "big"); +}; +function la$1(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ ~e2 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function da$1(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ ~t2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function pa$1(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function va$1(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function ma$1(e2, t2) { + var r3 = le$1(e2, t2, 28), i2 = le$1(t2, e2, 2), n4 = le$1(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ga$1(e2, t2) { + var r3 = de$2(e2, t2, 28), i2 = de$2(t2, e2, 2), n4 = de$2(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Aa$1(e2, t2) { + var r3 = le$1(e2, t2, 14), i2 = le$1(e2, t2, 18), n4 = le$1(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ba$1(e2, t2) { + var r3 = de$2(e2, t2, 14), i2 = de$2(e2, t2, 18), n4 = de$2(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ya$1(e2, t2) { + var r3 = le$1(e2, t2, 1), i2 = le$1(e2, t2, 8), n4 = yf$1(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function wa$1(e2, t2) { + var r3 = de$2(e2, t2, 1), i2 = de$2(e2, t2, 8), n4 = wf$1(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function xa$1(e2, t2) { + var r3 = le$1(e2, t2, 19), i2 = le$1(t2, e2, 29), n4 = yf$1(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Ma$1(e2, t2) { + var r3 = de$2(e2, t2, 19), i2 = de$2(t2, e2, 29), n4 = wf$1(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +var Oi$1 = Q$2, Ef$1 = Mf$1; +function we$1() { + if (!(this instanceof we$1)) + return new we$1(); + Ef$1.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; +} +Oi$1.inherits(we$1, Ef$1); +var Ea$1 = we$1; +we$1.blockSize = 1024, we$1.outSize = 384, we$1.hmacStrength = 192, we$1.padLength = 128, we$1.prototype._digest = function(t2) { + return t2 === "hex" ? Oi$1.toHex32(this.h.slice(0, 12), "big") : Oi$1.split32(this.h.slice(0, 12), "big"); +}, or$2.sha1 = Js$2, or$2.sha224 = na$1, or$2.sha256 = Af$1, or$2.sha384 = Ea$1, or$2.sha512 = Mf$1; +var Sf$1 = {}, Xe$3 = Q$2, Sa$1 = fr$1, Tr$2 = Xe$3.rotl32, Nf$1 = Xe$3.sum32, xr$2 = Xe$3.sum32_3, If$1 = Xe$3.sum32_4, _f$1 = Sa$1.BlockHash; +function pe$2() { + if (!(this instanceof pe$2)) + return new pe$2(); + _f$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; +} +Xe$3.inherits(pe$2, _f$1), Sf$1.ripemd160 = pe$2, pe$2.blockSize = 512, pe$2.outSize = 160, pe$2.hmacStrength = 192, pe$2.padLength = 64, pe$2.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o2 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o2, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf$1(Tr$2(If$1(i2, Bf$1(I2, n4, o2, h4), t2[_a$1[I2] + r3], Na$1(I2)), Ca$1[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr$2(o2, 10), o2 = n4, n4 = N2, N2 = Nf$1(Tr$2(If$1(b3, Bf$1(79 - I2, m3, w3, y3), t2[Ba$1[I2] + r3], Ia$1(I2)), Ra$1[I2]), S2), b3 = S2, S2 = y3, y3 = Tr$2(w3, 10), w3 = m3, m3 = N2; + } + N2 = xr$2(this.h[1], o2, y3), this.h[1] = xr$2(this.h[2], h4, S2), this.h[2] = xr$2(this.h[3], p2, b3), this.h[3] = xr$2(this.h[4], i2, m3), this.h[4] = xr$2(this.h[0], n4, w3), this.h[0] = N2; +}, pe$2.prototype._digest = function(t2) { + return t2 === "hex" ? Xe$3.toHex32(this.h, "little") : Xe$3.split32(this.h, "little"); +}; +function Bf$1(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); +} +function Na$1(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; +} +function Ia$1(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; +} +var _a$1 = [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], Ba$1 = [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], Ca$1 = [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], Ra$1 = [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], Oa$1 = Q$2, Pa$1 = yr$2; +function hr$2(e2, t2, r3) { + if (!(this instanceof hr$2)) + return new hr$2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa$1.toArray(t2, r3)); +} +var Da$1 = hr$2; +hr$2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa$1(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); +}, hr$2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; +}, hr$2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); +}, function(e2) { + var t2 = e2; + t2.utils = Q$2, t2.common = fr$1, t2.sha = or$2, t2.ripemd = Sf$1, t2.hmac = Da$1, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; +}(se$2); +function cr$2(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa$1(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; +} +function Fa$1() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var Pi$1 = Cf$1; +function Cf$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +Cf$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var fe$2 = cr$2(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); } + return b3; + } + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; + } + r3.zero2 = n4; + function o2(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o2, r3.encode = function(p2, b3) { + return b3 === "hex" ? o2(p2) : p2; + }; +}), Jt$3 = cr$2(function(e2, t2) { + var r3 = t2; + r3.assert = Pi$1, r3.toArray = fe$2.toArray, r3.zero2 = fe$2.zero2, r3.toHex = fe$2.toHex, r3.encode = fe$2.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N2 = 0; N2 < y3.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N2] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N2 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o2(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o2; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K$2(b3, "hex", "le"); + } + r3.intFromLE = p2; +}), Ur$2 = Jt$3.getNAF, Ta$1 = Jt$3.getJSF, kr$2 = Jt$3.assert; +function Ce$1(e2, t2) { + this.type = e2, this.p = new K$2(t2.p, 16), this.red = t2.prime ? K$2.red(t2.prime) : K$2.mont(this.p), this.zero = new K$2(0).toRed(this.red), this.one = new K$2(1).toRed(this.red), this.two = new K$2(2).toRed(this.red), this.n = t2.n && new K$2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); +} +var Ze$2 = Ce$1; +Ce$1.prototype.point = function() { + throw new Error("Not implemented"); +}, Ce$1.prototype.validate = function() { + throw new Error("Not implemented"); +}, Ce$1.prototype._fixedNafMul = function(t2, r3) { + kr$2(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur$2(r3, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); +}, Ce$1.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o2 = n4.points, h4 = Ur$2(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr$2(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o2[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o2[w3 - 1 >> 1]) : p2 = p2.add(o2[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; +}, Ce$1.prototype._wnafMulAdd = function(t2, r3, i2, n4, o2) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N2 = w3 - 1, C2 = w3; + if (h4[N2] !== 1 || h4[C2] !== 1) { + b3[N2] = Ur$2(i2[N2], h4[N2], this._bitLength), b3[C2] = Ur$2(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N2].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; } - const keys2 = Object.keys(objectCopy); - if (options.sort !== false) { - keys2.sort(options.sort); + var F2 = [r3[N2], null, null, r3[C2]]; + r3[N2].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N2].add(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())) : r3[N2].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].add(r3[C2].neg())) : (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta$1(i2[N2], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N2] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N2][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; } - return keys2.map((key) => { - const value = object[key]; - if (value === void 0) { - return ""; - } - if (value === null) { - return encode2(key, options); - } - if (Array.isArray(value)) { - if (value.length === 0 && options.arrayFormat === "bracket-separator") { - return encode2(key, options) + "[]"; + if (w3 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o2 ? H2 : H2.toP(); +}; +function Xt$3(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; +} +Ce$1.BasePoint = Xt$3, Xt$3.prototype.eq = function() { + throw new Error("Not implemented"); +}, Xt$3.prototype.validate = function() { + return this.curve.validate(this); +}, Ce$1.prototype.decodePoint = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr$2(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr$2(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); +}, Xt$3.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); +}, Xt$3.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); +}, Xt$3.prototype.encode = function(t2, r3) { + return Jt$3.encode(this._encode(r3), t2); +}, Xt$3.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; +}, Xt$3.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; +}, Xt$3.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o2 = 0; o2 < r3; o2 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; +}, Xt$3.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r3[o2] = r3[o2 - 1].add(n4); + return { wnd: t2, points: r3 }; +}, Xt$3.prototype._getBeta = function() { + return null; +}, Xt$3.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; +}; +var Di$1 = cr$2(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; +}), Ua$1 = Jt$3.assert; +function Zt$2(e2) { + Ze$2.call(this, "short", e2), this.a = new K$2(e2.a, 16).toRed(this.red), this.b = new K$2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +Di$1(Zt$2, Ze$2); +var ka$1 = Zt$2; +Zt$2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K$2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K$2(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua$1(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K$2(p2.a, 16), b: new K$2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } +}, Zt$2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K$2.mont(t2), i2 = new K$2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o2 = new K$2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o2).fromRed(), p2 = n4.redSub(o2).fromRed(); + return [h4, p2]; +}, Zt$2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o2 = new K$2(1), h4 = new K$2(0), p2 = new K$2(0), b3 = new K$2(1), m3, w3, y3, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o2, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o2, o2 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m3, N2 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y3, b: S2 }, { a: I2, b: N2 }]; +}, Zt$2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o2 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b3 = h4.mul(n4.a), m3 = o2.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; +}, Zt$2.prototype.pointFromX = function(t2, r3) { + t2 = new K$2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n4.fromRed().isOdd(); + return (r3 && !o2 || !r3 && o2) && (n4 = n4.redNeg()), this.point(t2, n4); +}, Zt$2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o2 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; +}, Zt$2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o2 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o2[h4 * 2] = p2.k1, o2[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o2, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o2[y3] = null; + return w3; +}; +function Ft$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); +} +Di$1(Ft$2, Ze$2.BasePoint), Zt$2.prototype.point = function(t2, r3, i2) { + return new Ft$2(this, t2, r3, i2); +}, Zt$2.prototype.pointFromJSON = function(t2, r3) { + return Ft$2.fromJSON(this, t2, r3); +}, Ft$2.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } +}, Ft$2.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; +}, Ft$2.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o2)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o2)) } }, n4; +}, Ft$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Ft$2.prototype.isInfinity = function() { + return this.inf; +}, Ft$2.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); +}, Ft$2.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); +}, Ft$2.prototype.getX = function() { + return this.x.fromRed(); +}, Ft$2.prototype.getY = function() { + return this.y.fromRed(); +}, Ft$2.prototype.mul = function(t2) { + return t2 = new K$2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); +}, Ft$2.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2) : this.curve._wnafMulAdd(1, n4, o2, 2); +}, Ft$2.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2, true) : this.curve._wnafMulAdd(1, n4, o2, 2, true); +}, Ft$2.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); +}, Ft$2.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o2) { + return o2.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; +}, Ft$2.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; +}; +function Tt$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K$2(0)) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), this.z = new K$2(i2, 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; +} +Di$1(Tt$2, Ze$2.BasePoint), Zt$2.prototype.jpoint = function(t2, r3, i2) { + return new Tt$2(this, t2, r3, i2); +}, Tt$2.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); +}, Tt$2.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}, Tt$2.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o2 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o2), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N2 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N2, C2); +}, Tt$2.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o2 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o2.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o2.redMul(w3)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); +}, Tt$2.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o2 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N2 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o2), b3); +}, Tt$2.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}, Tt$2.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r3 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt$2.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt$2.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o2 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o2)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N2, C2); +}, Tt$2.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h4 = o2.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o2.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N2); +}, Tt$2.prototype.mul = function(t2, r3) { + return t2 = new K$2(t2, r3), this.curve._wnafMul(this, t2); +}, Tt$2.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n4)).cmpn(0) === 0; +}, Tt$2.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o2 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } +}, Tt$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Tt$2.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var qr$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.base = Ze$2, r3.short = ka$1, r3.mont = null, r3.edwards = null; +}), Kr$1 = cr$2(function(e2, t2) { + var r3 = t2, i2 = Jt$3.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr$1.short(p2) : p2.type === "edwards" ? this.curve = new qr$1.edwards(p2) : this.curve = new qr$1.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o2(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o2("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: se$2.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se$2.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se$2.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se$2.sha384, gRed: false, 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"] }), o2("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: se$2.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se$2.sha256, gRed: false, g: ["9"] }), o2("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: se$2.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o2("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: se$2.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); +}); +function Re$2(e2) { + if (!(this instanceof Re$2)) + return new Re$2(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe$2.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe$2.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe$2.toArray(e2.pers, e2.persEnc || "hex"); + Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); +} +var Rf$1 = Re$2; +Re$2.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; +}, Re$2.prototype._hmac = function() { + return new se$2.hmac(this.hash, this.K); +}, Re$2.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); +}, Re$2.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe$2.toArray(t2, r3), i2 = fe$2.toArray(i2, n4), Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; +}, Re$2.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe$2.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h4 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe$2.encode(h4, r3); +}; +var Fi$1 = Jt$3.assert; +function kt$2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); +} +var Ti$1 = kt$2; +kt$2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { pub: r3, pubEnc: i2 }); +}, kt$2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { priv: r3, privEnc: i2 }); +}, kt$2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; +}, kt$2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; +}, kt$2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; +}, kt$2.prototype._importPrivate = function(t2, r3) { + this.priv = new K$2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); +}, kt$2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi$1(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi$1(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); +}, kt$2.prototype.derive = function(t2) { + return t2.validate() || Fi$1(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); +}, kt$2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); +}, kt$2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); +}, kt$2.prototype.inspect = function() { + return ""; +}; +var qa$1 = Jt$3.assert; +function Hr$1(e2, t2) { + if (e2 instanceof Hr$1) + return e2; + this._importDER(e2, t2) || (qa$1(e2.r && e2.s, "Signature without r or s"), this.r = new K$2(e2.r, 16), this.s = new K$2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); +} +var zr$2 = Hr$1; +function Ka$1() { + this.place = 0; +} +function Ui$1(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o2 = 0, h4 = t2.place; o2 < i2; o2++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); +} +function Of$1(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); +} +Hr$1.prototype._importDER = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = new Ka$1(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui$1(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui$1(t2, i2); + if (o2 === false) + return false; + var h4 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui$1(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K$2(h4), this.s = new K$2(b3), this.recoveryParam = null, true; +}; +function ki$1(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); +} +Hr$1.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of$1(r3), i2 = Of$1(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki$1(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki$1(n4, i2.length); + var o2 = n4.concat(i2), h4 = [48]; + return ki$1(h4, o2.length), h4 = h4.concat(o2), Jt$3.encode(h4, t2); +}; +var Ha$1 = function() { + throw new Error("unsupported"); +}, Pf$1 = Jt$3.assert; +function $t$2(e2) { + if (!(this instanceof $t$2)) + return new $t$2(e2); + typeof e2 == "string" && (Pf$1(Object.prototype.hasOwnProperty.call(Kr$1, e2), "Unknown curve " + e2), e2 = Kr$1[e2]), e2 instanceof Kr$1.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; +} +var za$1 = $t$2; +$t$2.prototype.keyPair = function(t2) { + return new Ti$1(this, t2); +}, $t$2.prototype.keyFromPrivate = function(t2, r3) { + return Ti$1.fromPrivate(this, t2, r3); +}, $t$2.prototype.keyFromPublic = function(t2, r3) { + return Ti$1.fromPublic(this, t2, r3); +}, $t$2.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf$1({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha$1(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K$2(2)); ; ) { + var o2 = new K$2(r3.generate(i2)); + if (!(o2.cmp(n4) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } +}, $t$2.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; +}, $t$2.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K$2(t2, 16)); + for (var o2 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b3 = new Rf$1({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K$2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K$2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N2.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr$2({ r: N2, s: C2, recoveryParam: F2 }); + } } - return value.reduce(formatter(key), []).join("&"); } - return encode2(key, options) + "=" + encode2(value, options); - }).filter((x2) => x2.length > 0).join("&"); - }; - exports2.parseUrl = (url, options) => { - options = Object.assign({ - decode: true - }, options); - const [url_, hash2] = splitOnFirst$1(url, "#"); - return Object.assign( - { - url: url_.split("?")[0] || "", - query: parse(extract(url), options) - }, - options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} - ); - }; - exports2.stringifyUrl = (object, options) => { - options = Object.assign({ - encode: true, - strict: true, - [encodeFragmentIdentifier]: true - }, options); - const url = removeHash(object.url).split("?")[0] || ""; - const queryFromUrl = exports2.extract(object.url); - const parsedQueryFromUrl = exports2.parse(queryFromUrl, { sort: false }); - const query = Object.assign(parsedQueryFromUrl, object.query); - let queryString2 = exports2.stringify(query, options); - if (queryString2) { - queryString2 = `?${queryString2}`; } - let hash2 = getHash(object.url); - if (object.fragmentIdentifier) { - hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + } +}, $t$2.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K$2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr$2(r3, "hex"); + var o2 = r3.r, h4 = r3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o2).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o2)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o2) === 0); +}, $t$2.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf$1((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr$2(t2, i2); + var n4 = this.n, o2 = new K$2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o2).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); +}, $t$2.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr$2(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; } - return `${url}${queryString2}${hash2}`; - }; - exports2.pick = (input, filter, options) => { - options = Object.assign({ - parseFragmentIdentifier: true, - [encodeFragmentIdentifier]: false - }, options); - const { url, query, fragmentIdentifier } = exports2.parseUrl(input, options); - return exports2.stringifyUrl({ - url, - query: filterObject(query, filter), - fragmentIdentifier - }, options); - }; - exports2.exclude = (input, filter, options) => { - const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); - return exports2.pick(input, exclusionFilter, options); - }; -})(queryString); -const RELAY_JSONRPC = { - waku: { - publish: "waku_publish", - batchPublish: "waku_batchPublish", - subscribe: "waku_subscribe", - batchSubscribe: "waku_batchSubscribe", - subscription: "waku_subscription", - unsubscribe: "waku_unsubscribe", - batchUnsubscribe: "waku_batchUnsubscribe" - }, - irn: { - publish: "irn_publish", - batchPublish: "irn_batchPublish", - subscribe: "irn_subscribe", - batchSubscribe: "irn_batchSubscribe", - subscription: "irn_subscription", - unsubscribe: "irn_unsubscribe", - batchUnsubscribe: "irn_batchUnsubscribe" - }, - iridium: { - publish: "iridium_publish", - batchPublish: "iridium_batchPublish", - subscribe: "iridium_subscribe", - batchSubscribe: "iridium_batchSubscribe", - subscription: "iridium_subscription", - unsubscribe: "iridium_unsubscribe", - batchUnsubscribe: "iridium_batchUnsubscribe" + if (o2.eq(r3)) + return n4; } + throw new Error("Unable to find valid recovery factor"); }; -function L$1(e, n3) { - return e.includes(":") ? [e] : n3.chains || []; +var La$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt$3, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr$1, r3.curves = Kr$1, r3.ec = za$1, r3.eddsa = null; +}), ja = La$1.ec; +const Qa = "signing-key/5.7.0", qi = new L$3(Qa); +let Ki = null; +function ve() { + return Ki || (Ki = new ja("secp256k1")), Ki; } -const J$1 = "base10", p$1 = "base16", F$2 = "base64pad", H$1 = "utf8", Q$2 = 0, _$1 = 1, Dn = 0, Te = 1, Z$1 = 12, X$1 = 32; -function kn() { - const e = x25519.generateKeyPair(); - return { privateKey: toString(e.secretKey, p$1), publicKey: toString(e.publicKey, p$1) }; +class Ja { + constructor(t2) { + br$1(this, "curve", "secp256k1"), br$1(this, "privateKey", Kt$2(t2)), N0(this.privateKey) !== 32 && qi.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)); + br$1(this, "publicKey", "0x" + r3.getPublic(false, "hex")), br$1(this, "compressedPublicKey", "0x" + r3.getPublic(true, "hex")), br$1(this, "_isSigningKey", true); + } + _addPoint(t2) { + const r3 = ve().keyFromPublic(Ot$2(this.publicKey)), i2 = ve().keyFromPublic(Ot$2(t2)); + return "0x" + r3.pub.add(i2.pub).encodeCompressed("hex"); + } + signDigest(t2) { + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)), i2 = Ot$2(t2); + i2.length !== 32 && qi.throwArgumentError("bad digest length", "digest", t2); + const n4 = r3.sign(i2, { canonical: true }); + return zn({ recoveryParam: n4.recoveryParam, r: oe$1("0x" + n4.r.toString(16), 32), s: oe$1("0x" + n4.s.toString(16), 32) }); + } + computeSharedSecret(t2) { + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)), i2 = ve().keyFromPublic(Ot$2(Df(t2))); + return oe$1("0x" + r3.derive(i2.getPublic()).toString(16), 32); + } + static isSigningKey(t2) { + return !!(t2 && t2._isSigningKey); + } } -function Vn() { - const e = random.randomBytes(X$1); - return toString(e, p$1); +function Ga(e2, t2) { + const r3 = zn(t2), i2 = { r: Ot$2(r3.r), s: Ot$2(r3.s) }; + return "0x" + ve().recoverPubKey(Ot$2(e2), i2, r3.recoveryParam).encode("hex", false); } -function Mn(e, n3) { - const t2 = x25519.sharedKey(fromString(e, p$1), fromString(n3, p$1), true), r2 = new HKDF_1(sha256.SHA256, t2).expand(X$1); - return toString(r2, p$1); +function Df(e2, t2) { + const r3 = Ot$2(e2); + if (r3.length === 32) { + const i2 = new Ja(r3); + return i2.publicKey; + } else { + if (r3.length === 33) + return "0x" + ve().keyFromPublic(r3).getPublic(false, "hex"); + if (r3.length === 65) + return Kt$2(r3); + } + return qi.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} +var Ff$1; +(function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; +})(Ff$1 || (Ff$1 = {})); +function Va(e2) { + const t2 = Df(e2); + return ns$1(Hn(yi(Hn(t2, 1)), 12)); +} +function Wa(e2, t2) { + return Va(Ga(Ot$2(e2), t2)); +} +const Xa = "https://rpc.walletconnect.com/v1"; +async function Tf(e2, t2, r3, i2, n4, o2) { + switch (r3.t) { + case "eip191": + return Uf(e2, t2, r3.s); + case "eip1271": + return await kf(e2, t2, r3.s, i2, n4, o2); + default: + throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r3.t}`); + } } -function Kn(e) { - const n3 = sha256.hash(fromString(e, p$1)); - return toString(n3, p$1); +function Uf(e2, t2, r3) { + return Wa(ff(t2), r3).toLowerCase() === e2.toLowerCase(); } -function Ln(e) { - const n3 = sha256.hash(fromString(e, H$1)); - return toString(n3, p$1); +async function kf(e2, t2, r3, i2, n4, o2) { + try { + const h4 = "0x1626ba7e", p2 = "0000000000000000000000000000000000000000000000000000000000000040", b3 = "0000000000000000000000000000000000000000000000000000000000000041", m3 = r3.substring(2), w3 = ff(t2).substring(2), y3 = h4 + w3 + p2 + b3 + m3, S2 = await fetch(`${o2 || Xa}/?chainId=${i2}&projectId=${n4}`, { method: "POST", body: JSON.stringify({ id: Za(), jsonrpc: "2.0", method: "eth_call", params: [{ to: e2, data: y3 }, "latest"] }) }), { result: I2 } = await S2.json(); + return I2 ? I2.slice(0, h4.length).toLowerCase() === h4.toLowerCase() : false; + } catch (h4) { + return console.error("isValidEip1271Signature: ", h4), false; + } +} +function Za() { + return Date.now() + Math.floor(Math.random() * 1e3); +} +var $a = Object.defineProperty, tu = Object.defineProperties, eu = Object.getOwnPropertyDescriptors, qf = Object.getOwnPropertySymbols, ru = Object.prototype.hasOwnProperty, iu = Object.prototype.propertyIsEnumerable, Kf = (e2, t2, r3) => t2 in e2 ? $a(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, Hi$1 = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + ru.call(t2, r3) && Kf(e2, r3, t2[r3]); + if (qf) + for (var r3 of qf(t2)) + iu.call(t2, r3) && Kf(e2, r3, t2[r3]); + return e2; +}, Hf = (e2, t2) => tu(e2, eu(t2)); +const nu = "did:pkh:", Lr$1 = (e2) => e2 == null ? void 0 : e2.split(":"), zi = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return e2.includes(nu) ? t2[3] : t2[1]; +}, fu = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2[2] + ":" + t2[3]; +}, Li = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2.pop(); +}; +async function ou(e2) { + const { cacao: t2, projectId: r3 } = e2, { s: i2, p: n4 } = t2, o2 = zf(n4, n4.iss), h4 = Li(n4.iss); + return await Tf(h4, o2, i2, zi(n4.iss), r3); +} +const zf = (e2, t2) => { + const r3 = `${e2.domain} wants you to sign in with your Ethereum account:`, i2 = Li(t2); + if (!e2.aud && !e2.uri) + throw new Error("Either `aud` or `uri` is required to construct the message"); + let n4 = e2.statement || void 0; + const o2 = `URI: ${e2.aud || e2.uri}`, h4 = `Version: ${e2.version}`, p2 = `Chain ID: ${zi(t2)}`, b3 = `Nonce: ${e2.nonce}`, m3 = `Issued At: ${e2.iat}`, w3 = e2.resources ? `Resources:${e2.resources.map((S2) => ` +- ${S2}`).join("")}` : void 0, y3 = Qr(e2.resources); + if (y3) { + const S2 = Oe(y3); + n4 = Ji$1(n4, S2); + } + return [r3, i2, "", n4, "", o2, h4, p2, b3, m3, w3].filter((S2) => S2 != null).join(` +`); +}; +function Jf(e2) { + return Buffer.from(JSON.stringify(e2)).toString("base64"); +} +function Gf(e2) { + return JSON.parse(Buffer.from(e2, "base64").toString("utf-8")); +} +function me$1(e2) { + if (!e2) + throw new Error("No recap provided, value is undefined"); + if (!e2.att) + throw new Error("No `att` property found"); + const t2 = Object.keys(e2.att); + if (!(t2 != null && t2.length)) + throw new Error("No resources found in `att` property"); + t2.forEach((r3) => { + const i2 = e2.att[r3]; + if (Array.isArray(i2)) + throw new Error(`Resource must be an object: ${r3}`); + if (typeof i2 != "object") + throw new Error(`Resource must be an object: ${r3}`); + if (!Object.keys(i2).length) + throw new Error(`Resource object is empty: ${r3}`); + Object.keys(i2).forEach((n4) => { + const o2 = i2[n4]; + if (!Array.isArray(o2)) + throw new Error(`Ability limits ${n4} must be an array of objects, found: ${o2}`); + if (!o2.length) + throw new Error(`Value of ${n4} is empty array, must be an array with objects`); + o2.forEach((h4) => { + if (typeof h4 != "object") + throw new Error(`Ability limits (${n4}) must be an array of objects, found: ${h4}`); + }); + }); + }); } -function Pe(e) { - return fromString(`${e}`, J$1); +function Yf(e2, t2, r3, i2 = {}) { + return r3 == null ? void 0 : r3.sort((n4, o2) => n4.localeCompare(o2)), { att: { [e2]: ji(t2, r3, i2) } }; } -function j$1(e) { - return Number(toString(e, J$1)); +function ji(e2, t2, r3 = {}) { + t2 = t2 == null ? void 0 : t2.sort((n4, o2) => n4.localeCompare(o2)); + const i2 = t2.map((n4) => ({ [`${e2}/${n4}`]: [r3] })); + return Object.assign({}, ...i2); } -function xn(e) { - const n3 = Pe(typeof e.type < "u" ? e.type : Q$2); - if (j$1(n3) === _$1 && typeof e.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - const t2 = typeof e.senderPublicKey < "u" ? fromString(e.senderPublicKey, p$1) : void 0, r2 = typeof e.iv < "u" ? fromString(e.iv, p$1) : random.randomBytes(Z$1), o2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e.symKey, p$1)).seal(r2, fromString(e.message, H$1)); - return Re({ type: n3, sealed: o2, iv: r2, senderPublicKey: t2 }); +function jr(e2) { + return me$1(e2), `urn:recap:${Jf(e2).replace(/=/g, "")}`; } -function Fn(e) { - const n3 = new chacha20poly1305.ChaCha20Poly1305(fromString(e.symKey, p$1)), { sealed: t2, iv: r2 } = ee$1(e.encoded), o2 = n3.open(r2, t2); - if (o2 === null) - throw new Error("Failed to decrypt"); - return toString(o2, H$1); +function Oe(e2) { + const t2 = Gf(e2.replace("urn:recap:", "")); + return me$1(t2), t2; } -function Re(e) { - if (j$1(e.type) === _$1) { - if (typeof e.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - return toString(concat([e.type, e.senderPublicKey, e.iv, e.sealed]), F$2); - } - return toString(concat([e.type, e.iv, e.sealed]), F$2); +function cu(e2, t2, r3) { + const i2 = Yf(e2, t2, r3); + return jr(i2); } -function ee$1(e) { - const n3 = fromString(e, F$2), t2 = n3.slice(Dn, Te), r2 = Te; - if (j$1(t2) === _$1) { - const d3 = r2 + X$1, l2 = d3 + Z$1, c2 = n3.slice(r2, d3), u3 = n3.slice(d3, l2), a3 = n3.slice(l2); - return { type: t2, sealed: a3, iv: u3, senderPublicKey: c2 }; - } - const o2 = r2 + Z$1, s2 = n3.slice(r2, o2), i2 = n3.slice(o2); - return { type: t2, sealed: i2, iv: s2 }; +function Qi$1(e2) { + return e2 && e2.includes("urn:recap:"); } -function Hn(e, n3) { - const t2 = ee$1(e); - return Ae({ type: j$1(t2.type), senderPublicKey: typeof t2.senderPublicKey < "u" ? toString(t2.senderPublicKey, p$1) : void 0, receiverPublicKey: n3 == null ? void 0 : n3.receiverPublicKey }); +function lu(e2, t2) { + const r3 = Oe(e2), i2 = Oe(t2), n4 = Wf(r3, i2); + return jr(n4); } -function Ae(e) { - const n3 = (e == null ? void 0 : e.type) || Q$2; - if (n3 === _$1) { - if (typeof (e == null ? void 0 : e.senderPublicKey) > "u") - throw new Error("missing sender public key"); - if (typeof (e == null ? void 0 : e.receiverPublicKey) > "u") - throw new Error("missing receiver public key"); - } - return { type: n3, senderPublicKey: e == null ? void 0 : e.senderPublicKey, receiverPublicKey: e == null ? void 0 : e.receiverPublicKey }; +function Wf(e2, t2) { + me$1(e2), me$1(t2); + const r3 = Object.keys(e2.att).concat(Object.keys(t2.att)).sort((n4, o2) => n4.localeCompare(o2)), i2 = { att: {} }; + return r3.forEach((n4) => { + var o2, h4; + Object.keys(((o2 = e2.att) == null ? void 0 : o2[n4]) || {}).concat(Object.keys(((h4 = t2.att) == null ? void 0 : h4[n4]) || {})).sort((p2, b3) => p2.localeCompare(b3)).forEach((p2) => { + var b3, m3; + i2.att[n4] = Hf(Hi$1({}, i2.att[n4]), { [p2]: ((b3 = e2.att[n4]) == null ? void 0 : b3[p2]) || ((m3 = t2.att[n4]) == null ? void 0 : m3[p2]) }); + }); + }), i2; +} +function Ji$1(e2 = "", t2) { + me$1(t2); + const r3 = "I further authorize the stated URI to perform the following actions on my behalf: "; + if (e2.includes(r3)) + return e2; + const i2 = []; + let n4 = 0; + Object.keys(t2.att).forEach((p2) => { + const b3 = Object.keys(t2.att[p2]).map((y3) => ({ ability: y3.split("/")[0], action: y3.split("/")[1] })); + b3.sort((y3, S2) => y3.action.localeCompare(S2.action)); + const m3 = {}; + b3.forEach((y3) => { + m3[y3.ability] || (m3[y3.ability] = []), m3[y3.ability].push(y3.action); + }); + const w3 = Object.keys(m3).map((y3) => (n4++, `(${n4}) '${y3}': '${m3[y3].join("', '")}' for '${p2}'.`)); + i2.push(w3.join(", ").replace(".,", ".")); + }); + const o2 = i2.join(" "), h4 = `${r3}${o2}`; + return `${e2 ? e2 + " " : ""}${h4}`; } -function qn(e) { - return e.type === _$1 && typeof e.senderPublicKey == "string" && typeof e.receiverPublicKey == "string"; +function du(e2) { + var t2; + const r3 = Oe(e2); + me$1(r3); + const i2 = (t2 = r3.att) == null ? void 0 : t2.eip155; + return i2 ? Object.keys(i2).map((n4) => n4.split("/")[1]) : []; +} +function pu(e2) { + const t2 = Oe(e2); + me$1(t2); + const r3 = []; + return Object.values(t2.att).forEach((i2) => { + Object.values(i2).forEach((n4) => { + var o2; + (o2 = n4 == null ? void 0 : n4[0]) != null && o2.chains && r3.push(n4[0].chains); + }); + }), [...new Set(r3.flat())]; } -var Bn = Object.defineProperty, Ue$1 = Object.getOwnPropertySymbols, Gn = Object.prototype.hasOwnProperty, Wn = Object.prototype.propertyIsEnumerable, _e = (e, n3, t2) => n3 in e ? Bn(e, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[n3] = t2, $e$1 = (e, n3) => { - for (var t2 in n3 || (n3 = {})) - Gn.call(n3, t2) && _e(e, t2, n3[t2]); - if (Ue$1) - for (var t2 of Ue$1(n3)) - Wn.call(n3, t2) && _e(e, t2, n3[t2]); - return e; -}; -const Ce = "ReactNative", m$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, De$1 = "js"; -function te$1() { - return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; +function Qr(e2) { + if (!e2) + return; + const t2 = e2 == null ? void 0 : e2[e2.length - 1]; + return Qi$1(t2) ? t2 : void 0; } -function $$1() { - return !getDocument_1() && !!getNavigator_1() && navigator.product === Ce; +const Gi = "base10", zt$1 = "base16", Jr = "base64pad", Gr = "utf8", Yi$1 = 0, lr$1 = 1, vu = 0, Zf = 1, Vi = 12, Wi$1 = 32; +function mu() { + const e2 = x25519.generateKeyPair(); + return { privateKey: toString(e2.secretKey, zt$1), publicKey: toString(e2.publicKey, zt$1) }; } -function D$2() { - return !te$1() && !!getNavigator_1() && !!getDocument_1(); +function gu() { + const e2 = random.randomBytes(Wi$1); + return toString(e2, zt$1); } -function R$2() { - return $$1() ? m$1.reactNative : te$1() ? m$1.node : D$2() ? m$1.browser : m$1.unknown; +function Au(e2, t2) { + const r3 = x25519.sharedKey(fromString(e2, zt$1), fromString(t2, zt$1), true), i2 = new HKDF_1(sha256.SHA256, r3).expand(Wi$1); + return toString(i2, zt$1); } -function Jn() { - var e; - try { - return $$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e = global.Application) == null ? void 0 : e.applicationId : void 0; - } catch { - return; - } +function bu(e2) { + const t2 = sha256.hash(fromString(e2, zt$1)); + return toString(t2, zt$1); } -function ke$1(e, n3) { - let t2 = queryString.parse(e); - return t2 = $e$1($e$1({}, t2), n3), e = queryString.stringify(t2), e; +function yu(e2) { + const t2 = sha256.hash(fromString(e2, Gr)); + return toString(t2, zt$1); } -function Qn() { - return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; +function $f(e2) { + return fromString(`${e2}`, Gi); } -function Ve$1() { - if (R$2() === m$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { - const { OS: t2, Version: r2 } = global.Platform; - return [t2, r2].join("-"); - } - const e = detect(); - if (e === null) - return "unknown"; - const n3 = e.os ? e.os.replace(" ", "").toLowerCase() : "unknown"; - return e.type === "browser" ? [n3, e.name, e.version].join("-") : [n3, e.version].join("-"); -} -function Me$1() { - var e; - const n3 = R$2(); - return n3 === m$1.browser ? [n3, ((e = getLocation_1()) == null ? void 0 : e.host) || "unknown"].join(":") : n3; -} -function Ke$1(e, n3, t2) { - const r2 = Ve$1(), o2 = Me$1(); - return [[e, n3].join("-"), [De$1, t2].join("-"), r2, o2].join("/"); -} -function Xn({ protocol: e, version: n3, relayUrl: t2, sdkVersion: r2, auth: o2, projectId: s2, useOnCloseEvent: i2, bundleId: d3 }) { - const l2 = t2.split("?"), c2 = Ke$1(e, n3, r2), u3 = { auth: o2, ua: c2, projectId: s2, useOnCloseEvent: i2 || void 0, origin: d3 || void 0 }, a3 = ke$1(l2[1] || "", u3); - return l2[0] + "?" + a3; -} -function O$1(e, n3) { - return e.filter((t2) => n3.includes(t2)).length === e.length; -} -function rt$1(e) { - return Object.fromEntries(e.entries()); -} -function ot$1(e) { - return new Map(Object.entries(e)); -} -function at$1(e = cjs$4.FIVE_MINUTES, n3) { - const t2 = cjs$4.toMiliseconds(e || cjs$4.FIVE_MINUTES); - let r2, o2, s2; - return { resolve: (i2) => { - s2 && r2 && (clearTimeout(s2), r2(i2)); - }, reject: (i2) => { - s2 && o2 && (clearTimeout(s2), o2(i2)); - }, done: () => new Promise((i2, d3) => { - s2 = setTimeout(() => { - d3(new Error(n3)); - }, t2), r2 = i2, o2 = d3; - }) }; +function Mr(e2) { + return Number(toString(e2, Gi)); } -function ut$1(e, n3, t2) { - return new Promise(async (r2, o2) => { - const s2 = setTimeout(() => o2(new Error(t2)), n3); - try { - const i2 = await e; - r2(i2); - } catch (i2) { - o2(i2); - } - clearTimeout(s2); - }); +function wu(e2) { + const t2 = $f(typeof e2.type < "u" ? e2.type : Yi$1); + if (Mr(t2) === lr$1 && typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + const r3 = typeof e2.senderPublicKey < "u" ? fromString(e2.senderPublicKey, zt$1) : void 0, i2 = typeof e2.iv < "u" ? fromString(e2.iv, zt$1) : random.randomBytes(Vi), n4 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)).seal(i2, fromString(e2.message, Gr)); + return to({ type: t2, sealed: n4, iv: i2, senderPublicKey: r3 }); } -function re(e, n3) { - if (typeof n3 == "string" && n3.startsWith(`${e}:`)) - return n3; - if (e.toLowerCase() === "topic") { - if (typeof n3 != "string") - throw new Error('Value must be "string" for expirer target type: topic'); - return `topic:${n3}`; - } else if (e.toLowerCase() === "id") { - if (typeof n3 != "number") - throw new Error('Value must be "number" for expirer target type: id'); - return `id:${n3}`; - } - throw new Error(`Unknown expirer target type: ${e}`); +function xu(e2) { + const t2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)), { sealed: r3, iv: i2 } = Xi$1(e2.encoded), n4 = t2.open(i2, r3); + if (n4 === null) + throw new Error("Failed to decrypt"); + return toString(n4, Gr); } -function lt$1(e) { - return re("topic", e); +function to(e2) { + if (Mr(e2.type) === lr$1) { + if (typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + return toString(concat([e2.type, e2.senderPublicKey, e2.iv, e2.sealed]), Jr); + } + return toString(concat([e2.type, e2.iv, e2.sealed]), Jr); } -function dt$1(e) { - return re("id", e); +function Xi$1(e2) { + const t2 = fromString(e2, Jr), r3 = t2.slice(vu, Zf), i2 = Zf; + if (Mr(r3) === lr$1) { + const p2 = i2 + Wi$1, b3 = p2 + Vi, m3 = t2.slice(i2, p2), w3 = t2.slice(p2, b3), y3 = t2.slice(b3); + return { type: r3, sealed: y3, iv: w3, senderPublicKey: m3 }; + } + const n4 = i2 + Vi, o2 = t2.slice(i2, n4), h4 = t2.slice(n4); + return { type: r3, sealed: h4, iv: o2 }; } -function ft$1(e) { - const [n3, t2] = e.split(":"), r2 = { id: void 0, topic: void 0 }; - if (n3 === "topic" && typeof t2 == "string") - r2.topic = t2; - else if (n3 === "id" && Number.isInteger(Number(t2))) - r2.id = Number(t2); - else - throw new Error(`Invalid target, expected id:number or topic:string, got ${n3}:${t2}`); - return r2; +function Mu(e2, t2) { + const r3 = Xi$1(e2); + return eo({ type: Mr(r3.type), senderPublicKey: typeof r3.senderPublicKey < "u" ? toString(r3.senderPublicKey, zt$1) : void 0, receiverPublicKey: t2 == null ? void 0 : t2.receiverPublicKey }); } -function pt$1(e, n3) { - return cjs$4.fromMiliseconds((n3 || Date.now()) + cjs$4.toMiliseconds(e)); +function eo(e2) { + const t2 = (e2 == null ? void 0 : e2.type) || Yi$1; + if (t2 === lr$1) { + if (typeof (e2 == null ? void 0 : e2.senderPublicKey) > "u") + throw new Error("missing sender public key"); + if (typeof (e2 == null ? void 0 : e2.receiverPublicKey) > "u") + throw new Error("missing receiver public key"); + } + return { type: t2, senderPublicKey: e2 == null ? void 0 : e2.senderPublicKey, receiverPublicKey: e2 == null ? void 0 : e2.receiverPublicKey }; } -function mt$1(e) { - return Date.now() >= cjs$4.toMiliseconds(e); +function Eu(e2) { + return e2.type === lr$1 && typeof e2.senderPublicKey == "string" && typeof e2.receiverPublicKey == "string"; } -function yt$1(e, n3) { - return `${e}${n3 ? `:${n3}` : ""}`; +const ro = "irn"; +function Su(e2) { + return (e2 == null ? void 0 : e2.relay) || { protocol: ro }; } -async function gt$1({ id: e, topic: n3, wcDeepLink: t2 }) { - try { - if (!t2) - return; - const r2 = typeof t2 == "string" ? JSON.parse(t2) : t2; - let o2 = r2 == null ? void 0 : r2.href; - if (typeof o2 != "string") - return; - o2.endsWith("/") && (o2 = o2.slice(0, -1)); - const s2 = `${o2}/wc?requestId=${e}&sessionTopic=${n3}`, i2 = R$2(); - i2 === m$1.browser ? s2.startsWith("https://") ? window.open(s2, "_blank", "noreferrer noopener") : window.open(s2, "_self", "noreferrer noopener") : i2 === m$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(s2); - } catch (r2) { - console.error(r2); - } +function Nu(e2) { + const t2 = C$1[e2]; + if (typeof t2 > "u") + throw new Error(`Relay Protocol not supported: ${e2}`); + return t2; } -async function ht$1(e, n3) { - try { - return await e.getItem(n3) || (D$2() ? localStorage.getItem(n3) : void 0); - } catch (t2) { - console.error(t2); - } -} -const He$1 = "irn"; -function vt$1(e) { - return (e == null ? void 0 : e.relay) || { protocol: He$1 }; -} -function Et$1(e) { - const n3 = RELAY_JSONRPC[e]; - if (typeof n3 > "u") - throw new Error(`Relay Protocol not supported: ${e}`); - return n3; -} -var bt$1 = Object.defineProperty, Nt$1 = Object.defineProperties, Ot$1 = Object.getOwnPropertyDescriptors, qe$1 = Object.getOwnPropertySymbols, St$1 = Object.prototype.hasOwnProperty, wt$1 = Object.prototype.propertyIsEnumerable, Be$1 = (e, n3, t2) => n3 in e ? bt$1(e, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[n3] = t2, It$1 = (e, n3) => { - for (var t2 in n3 || (n3 = {})) - St$1.call(n3, t2) && Be$1(e, t2, n3[t2]); - if (qe$1) - for (var t2 of qe$1(n3)) - wt$1.call(n3, t2) && Be$1(e, t2, n3[t2]); - return e; -}, Tt$1 = (e, n3) => Nt$1(e, Ot$1(n3)); -function Ge$1(e, n3 = "-") { - const t2 = {}, r2 = "relay" + n3; - return Object.keys(e).forEach((o2) => { - if (o2.startsWith(r2)) { - const s2 = o2.replace(r2, ""), i2 = e[o2]; - t2[s2] = i2; - } +var Iu = Object.defineProperty, _u = Object.defineProperties, Bu = Object.getOwnPropertyDescriptors, io = Object.getOwnPropertySymbols, Cu = Object.prototype.hasOwnProperty, Ru = Object.prototype.propertyIsEnumerable, no = (e2, t2, r3) => t2 in e2 ? Iu(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, fo = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Cu.call(t2, r3) && no(e2, r3, t2[r3]); + if (io) + for (var r3 of io(t2)) + Ru.call(t2, r3) && no(e2, r3, t2[r3]); + return e2; +}, Ou = (e2, t2) => _u(e2, Bu(t2)); +function oo(e2, t2 = "-") { + const r3 = {}, i2 = "relay" + t2; + return Object.keys(e2).forEach((n4) => { + if (n4.startsWith(i2)) { + const o2 = n4.replace(i2, ""), h4 = e2[n4]; + r3[o2] = h4; + } + }), r3; +} +function Pu(e2) { + e2 = e2.includes("wc://") ? e2.replace("wc://", "") : e2, e2 = e2.includes("wc:") ? e2.replace("wc:", "") : e2; + const t2 = e2.indexOf(":"), r3 = e2.indexOf("?") !== -1 ? e2.indexOf("?") : void 0, i2 = e2.substring(0, t2), n4 = e2.substring(t2 + 1, r3).split("@"), o2 = typeof r3 < "u" ? e2.substring(r3) : "", h4 = queryString.parse(o2), p2 = typeof h4.methods == "string" ? h4.methods.split(",") : void 0; + return { protocol: i2, topic: so(n4[0]), version: parseInt(n4[1], 10), symKey: h4.symKey, relay: oo(h4), methods: p2, expiryTimestamp: h4.expiryTimestamp ? parseInt(h4.expiryTimestamp, 10) : void 0 }; +} +function so(e2) { + return e2.startsWith("//") ? e2.substring(2) : e2; +} +function ao(e2, t2 = "-") { + const r3 = "relay", i2 = {}; + return Object.keys(e2).forEach((n4) => { + const o2 = r3 + t2 + n4; + e2[n4] && (i2[o2] = e2[n4]); + }), i2; +} +function Du(e2) { + return `${e2.protocol}:${e2.topic}@${e2.version}?` + queryString.stringify(fo(Ou(fo({ symKey: e2.symKey }, ao(e2.relay)), { expiryTimestamp: e2.expiryTimestamp }), e2.methods ? { methods: e2.methods.join(",") } : {})); +} +function $e$1(e2) { + const t2 = []; + return e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2.push(`${i2}:${n4}`); }), t2; } -function Pt$1(e) { - e = e.includes("wc://") ? e.replace("wc://", "") : e, e = e.includes("wc:") ? e.replace("wc:", "") : e; - const n3 = e.indexOf(":"), t2 = e.indexOf("?") !== -1 ? e.indexOf("?") : void 0, r2 = e.substring(0, n3), o2 = e.substring(n3 + 1, t2).split("@"), s2 = typeof t2 < "u" ? e.substring(t2) : "", i2 = queryString.parse(s2); - return { protocol: r2, topic: We$1(o2[0]), version: parseInt(o2[1], 10), symKey: i2.symKey, relay: Ge$1(i2), expiryTimestamp: i2.expiryTimestamp ? parseInt(i2.expiryTimestamp, 10) : void 0 }; -} -function We$1(e) { - return e.startsWith("//") ? e.substring(2) : e; -} -function ze(e, n3 = "-") { - const t2 = "relay", r2 = {}; - return Object.keys(e).forEach((o2) => { - const s2 = t2 + n3 + o2; - e[o2] && (r2[s2] = e[o2]); - }), r2; -} -function Rt$1(e) { - return `${e.protocol}:${e.topic}@${e.version}?` + queryString.stringify(Tt$1(It$1({ symKey: e.symKey }, ze(e.relay)), { expiryTimestamp: e.expiryTimestamp })); -} -function A$1(e) { - const n3 = []; - return e.forEach((t2) => { - const [r2, o2] = t2.split(":"); - n3.push(`${r2}:${o2}`); - }), n3; -} -function Qe$1(e) { - const n3 = []; - return Object.values(e).forEach((t2) => { - n3.push(...A$1(t2.accounts)); - }), n3; -} -function Ze$1(e, n3) { +function co(e2) { const t2 = []; - return Object.values(e).forEach((r2) => { - A$1(r2.accounts).includes(n3) && t2.push(...r2.methods); + return Object.values(e2).forEach((r3) => { + t2.push(...$e$1(r3.accounts)); }), t2; } -function Xe$1(e, n3) { - const t2 = []; - return Object.values(e).forEach((r2) => { - A$1(r2.accounts).includes(n3) && t2.push(...r2.events); +function lo(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.methods); + }), r3; +} +function po(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.events); + }), r3; +} +function mo(e2) { + const t2 = {}; + return e2 == null ? void 0 : e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2[i2] || (t2[i2] = { accounts: [], chains: [], events: [] }), t2[i2].accounts.push(r3), t2[i2].chains.push(`${i2}:${n4}`); }), t2; } -const nn = { 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 } }, tn = { 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 N$1(e, n3) { - const { message: t2, code: r2 } = tn[e]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; +function ju(e2, t2) { + t2 = t2.map((i2) => i2.replace("did:pkh:", "")); + const r3 = mo(t2); + for (const [i2, n4] of Object.entries(r3)) + n4.methods ? n4.methods = ge$1(n4.methods, e2) : n4.methods = e2, n4.events = ["chainChanged", "accountsChanged"]; + return r3; +} +const go$1 = { 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 } }, Ao = { 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 xe(e2, t2) { + const { message: r3, code: i2 } = Ao[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; } -function U$2(e, n3) { - const { message: t2, code: r2 } = nn[e]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; +function tr$2(e2, t2) { + const { message: r3, code: i2 } = go$1[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; } -function k(e, n3) { - return Array.isArray(e) ? typeof n3 < "u" && e.length ? e.every(n3) : true : false; +function Er(e2, t2) { + return Array.isArray(e2) ? true : false; } -function B$1(e) { - return Object.getPrototypeOf(e) === Object.prototype && Object.keys(e).length; +function Yr(e2) { + return Object.getPrototypeOf(e2) === Object.prototype && Object.keys(e2).length; } -function w$3(e) { - return typeof e > "u"; +function Pe(e2) { + return typeof e2 > "u"; } -function g$3(e, n3) { - return n3 && w$3(e) ? true : typeof e == "string" && !!e.trim().length; +function Gt$1(e2, t2) { + return t2 && Pe(e2) ? true : typeof e2 == "string" && !!e2.trim().length; } -function G$1(e, n3) { - return n3 && w$3(e) ? true : typeof e == "number" && !isNaN(e); +function Vr(e2, t2) { + return typeof e2 == "number" && !isNaN(e2); } -function Mt$1(e, n3) { - const { requiredNamespaces: t2 } = n3, r2 = Object.keys(e.namespaces), o2 = Object.keys(t2); - let s2 = true; - return O$1(o2, r2) ? (r2.forEach((i2) => { - const { accounts: d3, methods: l2, events: c2 } = e.namespaces[i2], u3 = A$1(d3), a3 = t2[i2]; - (!O$1(L$1(i2, a3), u3) || !O$1(a3.methods, l2) || !O$1(a3.events, c2)) && (s2 = false); - }), s2) : false; +function Qu(e2, t2) { + const { requiredNamespaces: r3 } = t2, i2 = Object.keys(e2.namespaces), n4 = Object.keys(r3); + let o2 = true; + return _e$1(n4, i2) ? (i2.forEach((h4) => { + const { accounts: p2, methods: b3, events: m3 } = e2.namespaces[h4], w3 = $e$1(p2), y3 = r3[h4]; + (!_e$1(_r$1(h4, y3), w3) || !_e$1(y3.methods, b3) || !_e$1(y3.events, m3)) && (o2 = false); + }), o2) : false; } -function V$1(e) { - return g$3(e, false) && e.includes(":") ? e.split(":").length === 2 : false; +function Sr$1(e2) { + return Gt$1(e2, false) && e2.includes(":") ? e2.split(":").length === 2 : false; } -function rn(e) { - if (g$3(e, false) && e.includes(":")) { - const n3 = e.split(":"); - if (n3.length === 3) { - const t2 = n3[0] + ":" + n3[1]; - return !!n3[2] && V$1(t2); +function bo(e2) { + if (Gt$1(e2, false) && e2.includes(":")) { + const t2 = e2.split(":"); + if (t2.length === 3) { + const r3 = t2[0] + ":" + t2[1]; + return !!t2[2] && Sr$1(r3); } } return false; } -function Kt$1(e) { - if (g$3(e, false)) +function Ju(e2) { + if (Gt$1(e2, false)) try { - return typeof new URL(e) < "u"; + return typeof new URL(e2) < "u"; } catch { return false; } return false; } -function Lt$1(e) { - var n3; - return (n3 = e == null ? void 0 : e.proposer) == null ? void 0 : n3.publicKey; -} -function xt$1(e) { - return e == null ? void 0 : e.topic; +function Gu(e2) { + var t2; + return (t2 = e2 == null ? void 0 : e2.proposer) == null ? void 0 : t2.publicKey; } -function Ft$1(e, n3) { - let t2 = null; - return g$3(e == null ? void 0 : e.publicKey, false) || (t2 = N$1("MISSING_OR_INVALID", `${n3} controller public key should be a string`)), t2; -} -function ie(e) { - let n3 = true; - return k(e) ? e.length && (n3 = e.every((t2) => g$3(t2, false))) : n3 = false, n3; -} -function on(e, n3, t2) { - let r2 = null; - return k(n3) && n3.length ? n3.forEach((o2) => { - r2 || V$1(o2) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, chain ${o2} should be a string and conform to "namespace:chainId" format`)); - }) : V$1(e) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, 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"] }`)), r2; -} -function sn(e, n3, t2) { - let r2 = null; - return Object.entries(e).forEach(([o2, s2]) => { - if (r2) - return; - const i2 = on(o2, L$1(o2, s2), `${n3} ${t2}`); - i2 && (r2 = i2); - }), r2; +function Yu(e2) { + return e2 == null ? void 0 : e2.topic; } -function cn(e, n3) { - let t2 = null; - return k(e) ? e.forEach((r2) => { - t2 || rn(r2) || (t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, account ${r2} should be a string and conform to "namespace:chainId:address" format`)); - }) : t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), t2; +function Vu(e2, t2) { + let r3 = null; + return Gt$1(e2 == null ? void 0 : e2.publicKey, false) || (r3 = xe("MISSING_OR_INVALID", `${t2} controller public key should be a string`)), r3; } -function an(e, n3) { - let t2 = null; - return Object.values(e).forEach((r2) => { - if (t2) - return; - const o2 = cn(r2 == null ? void 0 : r2.accounts, `${n3} namespace`); - o2 && (t2 = o2); - }), t2; +function tn(e2) { + let t2 = true; + return Er(e2) ? e2.length && (t2 = e2.every((r3) => Gt$1(r3, false))) : t2 = false, t2; } -function un(e, n3) { - let t2 = null; - return ie(e == null ? void 0 : e.methods) ? ie(e == null ? void 0 : e.events) || (t2 = U$2("UNSUPPORTED_EVENTS", `${n3}, events should be an array of strings or empty array for no events`)) : t2 = U$2("UNSUPPORTED_METHODS", `${n3}, methods should be an array of strings or empty array for no methods`), t2; +function yo(e2, t2, r3) { + let i2 = null; + return Er(t2) && t2.length ? t2.forEach((n4) => { + i2 || Sr$1(n4) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, chain ${n4} should be a string and conform to "namespace:chainId" format`)); + }) : Sr$1(e2) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, 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"] }`)), i2; } -function ce$2(e, n3) { - let t2 = null; - return Object.values(e).forEach((r2) => { - if (t2) +function wo(e2, t2, r3) { + let i2 = null; + return Object.entries(e2).forEach(([n4, o2]) => { + if (i2) return; - const o2 = un(r2, `${n3}, namespace`); - o2 && (t2 = o2); - }), t2; -} -function Ht$1(e, n3, t2) { - let r2 = null; - if (e && B$1(e)) { - const o2 = ce$2(e, n3); - o2 && (r2 = o2); - const s2 = sn(e, n3, t2); - s2 && (r2 = s2); + const h4 = yo(n4, _r$1(n4, o2), `${t2} ${r3}`); + h4 && (i2 = h4); + }), i2; +} +function xo(e2, t2) { + let r3 = null; + return Er(e2) ? e2.forEach((i2) => { + r3 || bo(i2) || (r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, account ${i2} should be a string and conform to "namespace:chainId:address" format`)); + }) : r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), r3; +} +function Mo(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = xo(i2 == null ? void 0 : i2.accounts, `${t2} namespace`); + n4 && (r3 = n4); + }), r3; +} +function Eo(e2, t2) { + let r3 = null; + return tn(e2 == null ? void 0 : e2.methods) ? tn(e2 == null ? void 0 : e2.events) || (r3 = tr$2("UNSUPPORTED_EVENTS", `${t2}, events should be an array of strings or empty array for no events`)) : r3 = tr$2("UNSUPPORTED_METHODS", `${t2}, methods should be an array of strings or empty array for no methods`), r3; +} +function en(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = Eo(i2, `${t2}, namespace`); + n4 && (r3 = n4); + }), r3; +} +function Wu(e2, t2, r3) { + let i2 = null; + if (e2 && Yr(e2)) { + const n4 = en(e2, t2); + n4 && (i2 = n4); + const o2 = wo(e2, t2, r3); + o2 && (i2 = o2); } else - r2 = N$1("MISSING_OR_INVALID", `${n3}, ${t2} should be an object with data`); - return r2; -} -function ln(e, n3) { - let t2 = null; - if (e && B$1(e)) { - const r2 = ce$2(e, n3); - r2 && (t2 = r2); - const o2 = an(e, n3); - o2 && (t2 = o2); + i2 = xe("MISSING_OR_INVALID", `${t2}, ${r3} should be an object with data`); + return i2; +} +function So(e2, t2) { + let r3 = null; + if (e2 && Yr(e2)) { + const i2 = en(e2, t2); + i2 && (r3 = i2); + const n4 = Mo(e2, t2); + n4 && (r3 = n4); } else - t2 = N$1("MISSING_OR_INVALID", `${n3}, namespaces should be an object with data`); - return t2; + r3 = xe("MISSING_OR_INVALID", `${t2}, namespaces should be an object with data`); + return r3; } -function dn(e) { - return g$3(e.protocol, true); +function No(e2) { + return Gt$1(e2.protocol, true); } -function qt$1(e, n3) { - let t2 = false; - return n3 && !e ? t2 = true : e && k(e) && e.length && e.forEach((r2) => { - t2 = dn(r2); - }), t2; +function Xu(e2, t2) { + let r3 = false; + return !e2 ? r3 = true : e2 && Er(e2) && e2.length && e2.forEach((i2) => { + r3 = No(i2); + }), r3; } -function Bt$1(e) { - return typeof e == "number"; +function Zu(e2) { + return typeof e2 == "number"; } -function Gt$1(e) { - return typeof e < "u" && typeof e !== null; +function $u(e2) { + return typeof e2 < "u" && typeof e2 !== null; } -function Wt(e) { - return !(!e || typeof e != "object" || !e.code || !G$1(e.code, false) || !e.message || !g$3(e.message, false)); +function th(e2) { + return !(!e2 || typeof e2 != "object" || !e2.code || !Vr(e2.code) || !e2.message || !Gt$1(e2.message, false)); } -function zt$1(e) { - return !(w$3(e) || !g$3(e.method, false)); +function eh(e2) { + return !(Pe(e2) || !Gt$1(e2.method, false)); } -function Yt$1(e) { - return !(w$3(e) || w$3(e.result) && w$3(e.error) || !G$1(e.id, false) || !g$3(e.jsonrpc, false)); +function rh(e2) { + return !(Pe(e2) || Pe(e2.result) && Pe(e2.error) || !Vr(e2.id) || !Gt$1(e2.jsonrpc, false)); } -function Jt$1(e) { - return !(w$3(e) || !g$3(e.name, false)); +function ih(e2) { + return !(Pe(e2) || !Gt$1(e2.name, false)); } -function Qt(e, n3) { - return !(!V$1(n3) || !Qe$1(e).includes(n3)); +function nh(e2, t2) { + return !(!Sr$1(t2) || !co(e2).includes(t2)); } -function Zt(e, n3, t2) { - return g$3(t2, false) ? Ze$1(e, n3).includes(t2) : false; +function fh(e2, t2, r3) { + return Gt$1(r3, false) ? lo(e2, t2).includes(r3) : false; } -function Xt(e, n3, t2) { - return g$3(t2, false) ? Xe$1(e, n3).includes(t2) : false; +function oh(e2, t2, r3) { + return Gt$1(r3, false) ? po(e2, t2).includes(r3) : false; } -function fn(e, n3, t2) { - let r2 = null; - const o2 = er$1(e), s2 = nr$1(n3), i2 = Object.keys(o2), d3 = Object.keys(s2), l2 = pn(Object.keys(e)), c2 = pn(Object.keys(n3)), u3 = l2.filter((a3) => !c2.includes(a3)); - return u3.length && (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces keys don't satisfy requiredNamespaces. - Required: ${u3.toString()} - Received: ${Object.keys(n3).toString()}`)), O$1(i2, d3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces chains don't satisfy required namespaces. - Required: ${i2.toString()} - Approved: ${d3.toString()}`)), Object.keys(n3).forEach((a3) => { - if (!a3.includes(":") || r2) +function Io(e2, t2, r3) { + let i2 = null; + const n4 = sh(e2), o2 = ah(t2), h4 = Object.keys(n4), p2 = Object.keys(o2), b3 = _o(Object.keys(e2)), m3 = _o(Object.keys(t2)), w3 = b3.filter((y3) => !m3.includes(y3)); + return w3.length && (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces keys don't satisfy requiredNamespaces. + Required: ${w3.toString()} + Received: ${Object.keys(t2).toString()}`)), _e$1(h4, p2) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces chains don't satisfy required namespaces. + Required: ${h4.toString()} + Approved: ${p2.toString()}`)), Object.keys(t2).forEach((y3) => { + if (!y3.includes(":") || i2) return; - const b3 = A$1(n3[a3].accounts); - b3.includes(a3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces accounts don't satisfy namespace accounts for ${a3} - Required: ${a3} - Approved: ${b3.toString()}`)); - }), i2.forEach((a3) => { - r2 || (O$1(o2[a3].methods, s2[a3].methods) ? O$1(o2[a3].events, s2[a3].events) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces events don't satisfy namespace events for ${a3}`)) : r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces methods don't satisfy namespace methods for ${a3}`)); - }), r2; -} -function er$1(e) { - const n3 = {}; - return Object.keys(e).forEach((t2) => { - var r2; - t2.includes(":") ? n3[t2] = e[t2] : (r2 = e[t2].chains) == null || r2.forEach((o2) => { - n3[o2] = { methods: e[t2].methods, events: e[t2].events }; + const S2 = $e$1(t2[y3].accounts); + S2.includes(y3) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces accounts don't satisfy namespace accounts for ${y3} + Required: ${y3} + Approved: ${S2.toString()}`)); + }), h4.forEach((y3) => { + i2 || (_e$1(n4[y3].methods, o2[y3].methods) ? _e$1(n4[y3].events, o2[y3].events) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces events don't satisfy namespace events for ${y3}`)) : i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces methods don't satisfy namespace methods for ${y3}`)); + }), i2; +} +function sh(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + var i2; + r3.includes(":") ? t2[r3] = e2[r3] : (i2 = e2[r3].chains) == null || i2.forEach((n4) => { + t2[n4] = { methods: e2[r3].methods, events: e2[r3].events }; }); - }), n3; + }), t2; } -function pn(e) { - return [...new Set(e.map((n3) => n3.includes(":") ? n3.split(":")[0] : n3))]; +function _o(e2) { + return [...new Set(e2.map((t2) => t2.includes(":") ? t2.split(":")[0] : t2))]; } -function nr$1(e) { - const n3 = {}; - return Object.keys(e).forEach((t2) => { - if (t2.includes(":")) - n3[t2] = e[t2]; +function ah(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + if (r3.includes(":")) + t2[r3] = e2[r3]; else { - const r2 = A$1(e[t2].accounts); - r2 == null ? void 0 : r2.forEach((o2) => { - n3[o2] = { accounts: e[t2].accounts.filter((s2) => s2.includes(`${o2}:`)), methods: e[t2].methods, events: e[t2].events }; + const i2 = $e$1(e2[r3].accounts); + i2 == null ? void 0 : i2.forEach((n4) => { + t2[n4] = { accounts: e2[r3].accounts.filter((o2) => o2.includes(`${n4}:`)), methods: e2[r3].methods, events: e2[r3].events }; }); } - }), n3; + }), t2; } -function tr$1(e, n3) { - return G$1(e, false) && e <= n3.max && e >= n3.min; +function uh(e2, t2) { + return Vr(e2) && e2 <= t2.max && e2 >= t2.min; } -function rr$1() { - const e = R$2(); - return new Promise((n3) => { - switch (e) { - case m$1.browser: - n3(mn()); +function hh() { + const e2 = We$2(); + return new Promise((t2) => { + switch (e2) { + case qt$1.browser: + t2(Bo()); break; - case m$1.reactNative: - n3(yn()); + case qt$1.reactNative: + t2(Co()); break; - case m$1.node: - n3(gn()); + case qt$1.node: + t2(Ro()); break; default: - n3(true); + t2(true); } }); } -function mn() { - return D$2() && (navigator == null ? void 0 : navigator.onLine); +function Bo() { + return pr$1() && (navigator == null ? void 0 : navigator.onLine); } -async function yn() { - if ($$1() && typeof global < "u" && global != null && global.NetInfo) { - const e = await (global == null ? void 0 : global.NetInfo.fetch()); - return e == null ? void 0 : e.isConnected; +async function Co() { + if (er$1() && typeof global < "u" && global != null && global.NetInfo) { + const e2 = await (global == null ? void 0 : global.NetInfo.fetch()); + return e2 == null ? void 0 : e2.isConnected; } return true; } -function gn() { +function Ro() { return true; } -function or$1(e) { - switch (R$2()) { - case m$1.browser: - hn(e); +function ch(e2) { + switch (We$2()) { + case qt$1.browser: + Oo(e2); break; - case m$1.reactNative: - vn(e); + case qt$1.reactNative: + Po(e2); break; } } -function hn(e) { - !$$1() && D$2() && (window.addEventListener("online", () => e(true)), window.addEventListener("offline", () => e(false))); +function Oo(e2) { + !er$1() && pr$1() && (window.addEventListener("online", () => e2(true)), window.addEventListener("offline", () => e2(false))); } -function vn(e) { - $$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((n3) => e(n3 == null ? void 0 : n3.isConnected))); +function Po(e2) { + er$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((t2) => e2(t2 == null ? void 0 : t2.isConnected))); } -const ae$1 = {}; -let sr$1 = class sr { - static get(n3) { - return ae$1[n3]; +const rn = {}; +class lh { + static get(t2) { + return rn[t2]; } - static set(n3, t2) { - ae$1[n3] = t2; + static set(t2, r3) { + rn[t2] = r3; } - static delete(n3) { - delete ae$1[n3]; + static delete(t2) { + delete rn[t2]; } -}; +} const PARSE_ERROR = "PARSE_ERROR"; const INVALID_REQUEST = "INVALID_REQUEST"; const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; @@ -9087,14 +12598,14 @@ function getError(type2) { return STANDARD_ERROR_MAP[type2]; } function getErrorByCode(code) { - const match = Object.values(STANDARD_ERROR_MAP).find((e) => e.code === code); + const match = Object.values(STANDARD_ERROR_MAP).find((e2) => e2.code === code); if (!match) { return STANDARD_ERROR_MAP[DEFAULT_ERROR]; } return match; } -function parseConnectionError(e, url, type2) { - return e.message.includes("getaddrinfo ENOTFOUND") || e.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${type2} RPC url at ${url}`) : e; +function parseConnectionError(e2, url, type2) { + return e2.message.includes("getaddrinfo ENOTFOUND") || e2.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${type2} RPC url at ${url}`) : e2; } var cjs = {}; var crypto$1 = {}; @@ -9175,7 +12686,7 @@ function formatJsonRpcError(id, error, data) { return { id, jsonrpc: "2.0", - error: formatErrorMessage(error, data) + error: formatErrorMessage(error) }; } function formatErrorMessage(error, data) { @@ -9185,26 +12696,23 @@ function formatErrorMessage(error, data) { if (typeof error === "string") { error = Object.assign(Object.assign({}, getError(SERVER_ERROR)), { message: error }); } - if (typeof data !== "undefined") { - error.data = data; - } if (isReservedErrorCode(error.code)) { error = getErrorByCode(error.code); } return error; } -class IEvents2 { +class e { } -class IBaseJsonRpcProvider extends IEvents2 { +let n$1 = class n2 extends e { constructor() { super(); } -} -class IJsonRpcProvider extends IBaseJsonRpcProvider { - constructor(connection2) { +}; +let r$1 = class r extends n$1 { + constructor(c2) { super(); } -} +}; const WS_REGEX = "^wss?:"; function getUrlProtocol(url) { const matches = url.match(new RegExp(/^\w+:/, "gi")); @@ -9239,7 +12747,7 @@ function isJsonRpcResult(payload) { function isJsonRpcError(payload) { return "error" in payload; } -class JsonRpcProvider extends IJsonRpcProvider { +class JsonRpcProvider extends r$1 { constructor(connection2) { super(connection2); this.events = new eventsExports.EventEmitter(); @@ -9275,8 +12783,8 @@ class JsonRpcProvider extends IJsonRpcProvider { if (!this.connection.connected) { try { await this.open(); - } catch (e) { - reject(e); + } catch (e2) { + reject(e2); } } this.events.on(`${request.id}`, (response) => { @@ -9288,8 +12796,8 @@ class JsonRpcProvider extends IJsonRpcProvider { }); try { await this.connection.send(request, context); - } catch (e) { - reject(e); + } catch (e2) { + reject(e2); } }); } @@ -9340,17 +12848,17 @@ class JsonRpcProvider extends IJsonRpcProvider { this.hasRegisteredEventListeners = true; } } -const w$2 = () => 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 : (() => { +const w$1 = () => 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 : (() => { try { return (() => {try { return require("ws") } catch (e) { } })(); - } catch (e) { + } catch (e2) { } -})(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a$1 = (c2) => c2.split("?")[0], h$1 = 10, S$1 = w$2(); -class f { - constructor(e) { - if (this.url = e, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(e)) - throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`); - this.url = e; +})(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a2 = (c2) => c2.split("?")[0], h3 = 10, S$2 = w$1(); +let f$2 = class f { + constructor(e2) { + if (this.url = e2, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(e2)) + throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); + this.url = e2; } get connected() { return typeof this.socket < "u"; @@ -9358,94 +12866,94 @@ class f { get connecting() { return this.registering; } - on(e, t2) { - this.events.on(e, t2); + on(e2, t2) { + this.events.on(e2, t2); } - once(e, t2) { - this.events.once(e, t2); + once(e2, t2) { + this.events.once(e2, t2); } - off(e, t2) { - this.events.off(e, t2); + off(e2, t2) { + this.events.off(e2, t2); } - removeListener(e, t2) { - this.events.removeListener(e, t2); + removeListener(e2, t2) { + this.events.removeListener(e2, t2); } - async open(e = this.url) { - await this.register(e); + async open(e2 = this.url) { + await this.register(e2); } async close() { - return new Promise((e, t2) => { + return new Promise((e2, t2) => { if (typeof this.socket > "u") { t2(new Error("Connection already closed")); return; } - this.socket.onclose = (n3) => { - this.onClose(n3), e(); + this.socket.onclose = (n4) => { + this.onClose(n4), e2(); }, this.socket.close(); }); } - async send(e) { + async send(e2) { typeof this.socket > "u" && (this.socket = await this.register()); try { - this.socket.send(safeJsonStringify(e)); + this.socket.send(safeJsonStringify(e2)); } catch (t2) { - this.onError(e.id, t2); + this.onError(e2.id, t2); } } - register(e = this.url) { - if (!isWsUrl(e)) - throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`); + register(e2 = this.url) { + if (!isWsUrl(e2)) + throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); if (this.registering) { const t2 = this.events.getMaxListeners(); - return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n3, o2) => { + return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n4, o2) => { this.events.once("register_error", (s2) => { this.resetMaxListeners(), o2(s2); }), this.events.once("open", () => { if (this.resetMaxListeners(), typeof this.socket > "u") return o2(new Error("WebSocket connection is missing or invalid")); - n3(this.socket); + n4(this.socket); }); }); } - return this.url = e, this.registering = true, new Promise((t2, n3) => { - const o2 = new URLSearchParams(e).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e) }, i2 = new S$1(e, [], s2); - b2() ? i2.onerror = (r2) => { - const l2 = r2; - n3(this.emitError(l2.error)); - } : i2.on("error", (r2) => { - n3(this.emitError(r2)); + return this.url = e2, this.registering = true, new Promise((t2, n4) => { + const o2 = new URLSearchParams(e2).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e2) }, i2 = new S$2(e2, [], s2); + b2() ? i2.onerror = (r3) => { + const l2 = r3; + n4(this.emitError(l2.error)); + } : i2.on("error", (r3) => { + n4(this.emitError(r3)); }), i2.onopen = () => { this.onOpen(i2), t2(i2); }; }); } - onOpen(e) { - e.onmessage = (t2) => this.onPayload(t2), e.onclose = (t2) => this.onClose(t2), this.socket = e, this.registering = false, this.events.emit("open"); + onOpen(e2) { + e2.onmessage = (t2) => this.onPayload(t2), e2.onclose = (t2) => this.onClose(t2), this.socket = e2, this.registering = false, this.events.emit("open"); } - onClose(e) { - this.socket = void 0, this.registering = false, this.events.emit("close", e); + onClose(e2) { + this.socket = void 0, this.registering = false, this.events.emit("close", e2); } - onPayload(e) { - if (typeof e.data > "u") + onPayload(e2) { + if (typeof e2.data > "u") return; - const t2 = typeof e.data == "string" ? safeJsonParse(e.data) : e.data; + const t2 = typeof e2.data == "string" ? safeJsonParse(e2.data) : e2.data; this.events.emit("payload", t2); } - onError(e, t2) { - const n3 = this.parseError(t2), o2 = n3.message || n3.toString(), s2 = formatJsonRpcError(e, o2); + onError(e2, t2) { + const n4 = this.parseError(t2), o2 = n4.message || n4.toString(), s2 = formatJsonRpcError(e2, o2); this.events.emit("payload", s2); } - parseError(e, t2 = this.url) { - return parseConnectionError(e, a$1(t2), "WS"); + parseError(e2, t2 = this.url) { + return parseConnectionError(e2, a2(t2), "WS"); } resetMaxListeners() { - this.events.getMaxListeners() > h$1 && this.events.setMaxListeners(h$1); + this.events.getMaxListeners() > h3 && this.events.setMaxListeners(h3); } - emitError(e) { - const t2 = this.parseError(new Error((e == null ? void 0 : e.message) || `WebSocket connection failed for host: ${a$1(this.url)}`)); + emitError(e2) { + const t2 = this.parseError(new Error((e2 == null ? void 0 : e2.message) || `WebSocket connection failed for host: ${a2(this.url)}`)); return this.events.emit("register_error", t2), t2; } -} +}; var lodash_isequal = { exports: {} }; lodash_isequal.exports; (function(module2, exports2) { @@ -9471,7 +12979,7 @@ lodash_isequal.exports; var nodeUtil = function() { try { return freeProcess && freeProcess.binding && freeProcess.binding("util"); - } catch (e) { + } catch (e2) { } }(); var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; @@ -9501,9 +13009,9 @@ lodash_isequal.exports; } return false; } - function baseTimes(n3, iteratee) { - var index = -1, result = Array(n3); - while (++index < n3) { + function baseTimes(n4, iteratee) { + var index = -1, result = Array(n4); + while (++index < n4) { result[index] = iteratee(index); } return result; @@ -9739,7 +13247,7 @@ lodash_isequal.exports; function arrayLikeKeys(value, inherited) { var isArr = isArray2(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray2(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. + if (hasOwnProperty.call(value, key) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. @@ -9978,7 +13486,7 @@ lodash_isequal.exports; try { value[symToStringTag] = void 0; var unmasked = true; - } catch (e) { + } catch (e2) { } var result = nativeObjectToString.call(value); if (unmasked) { @@ -10042,11 +13550,11 @@ lodash_isequal.exports; if (func != null) { try { return funcToString.call(func); - } catch (e) { + } catch (e2) { } try { return func + ""; - } catch (e) { + } catch (e2) { } } return ""; @@ -10097,9 +13605,9 @@ lodash_isequal.exports; module2.exports = isEqual; })(lodash_isequal, lodash_isequal.exports); var lodash_isequalExports = lodash_isequal.exports; -const Gi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); -function unfetch_module(e, n3) { - return n3 = n3 || {}, new Promise(function(t2, r2) { +const Yi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); +function unfetch_module(e2, n4) { + return n4 = n4 || {}, new Promise(function(t2, r3) { var s2 = new XMLHttpRequest(), o2 = [], u3 = [], i2 = {}, a3 = function() { return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() { return Promise.resolve(s2.responseText); @@ -10111,19 +13619,19 @@ function unfetch_module(e, n3) { return o2; }, entries: function() { return u3; - }, get: function(e2) { - return i2[e2.toLowerCase()]; - }, has: function(e2) { - return e2.toLowerCase() in i2; + }, get: function(e3) { + return i2[e3.toLowerCase()]; + }, has: function(e3) { + return e3.toLowerCase() in i2; } } }; }; - for (var l2 in s2.open(n3.method || "get", e, true), s2.onload = function() { - s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e2, n4, t3) { - o2.push(n4 = n4.toLowerCase()), u3.push([n4, t3]), i2[n4] = i2[n4] ? i2[n4] + "," + t3 : t3; + for (var l2 in s2.open(n4.method || "get", e2, true), s2.onload = function() { + s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e3, n5, t3) { + o2.push(n5 = n5.toLowerCase()), u3.push([n5, t3]), i2[n5] = i2[n5] ? i2[n5] + "," + t3 : t3; }), t2(a3()); - }, s2.onerror = r2, s2.withCredentials = "include" == n3.credentials, n3.headers) - s2.setRequestHeader(l2, n3.headers[l2]); - s2.send(n3.body || null); + }, s2.onerror = r3, s2.withCredentials = "include" == n4.credentials, n4.headers) + s2.setRequestHeader(l2, n4.headers[l2]); + s2.send(n4.body || null); }); } const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ @@ -10132,289 +13640,289 @@ const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de }, Symbol.toStringTag, { value: "Module" })); const require$$0 = /* @__PURE__ */ getAugmentedNamespace(unfetch_module$1); var browser$2 = fetch || (self.fetch = require$$0.default || require$$0); -const Yi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); -function Hi(n3, e) { - if (n3.length >= 255) +const Hi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); +function Ji(n4, e2) { + if (n4.length >= 255) throw new TypeError("Alphabet too long"); for (var t2 = new Uint8Array(256), i2 = 0; i2 < t2.length; i2++) t2[i2] = 255; - for (var s2 = 0; s2 < n3.length; s2++) { - var r2 = n3.charAt(s2), o2 = r2.charCodeAt(0); + for (var s2 = 0; s2 < n4.length; s2++) { + var r3 = n4.charAt(s2), o2 = r3.charCodeAt(0); if (t2[o2] !== 255) - throw new TypeError(r2 + " is ambiguous"); + throw new TypeError(r3 + " is ambiguous"); t2[o2] = s2; } - var a3 = n3.length, h4 = n3.charAt(0), l2 = Math.log(a3) / Math.log(256), d3 = Math.log(256) / Math.log(a3); - function p3(u3) { + var a3 = n4.length, h4 = n4.charAt(0), l2 = Math.log(a3) / Math.log(256), d5 = Math.log(256) / Math.log(a3); + function g3(u3) { if (u3 instanceof Uint8Array || (ArrayBuffer.isView(u3) ? u3 = new Uint8Array(u3.buffer, u3.byteOffset, u3.byteLength) : Array.isArray(u3) && (u3 = Uint8Array.from(u3))), !(u3 instanceof Uint8Array)) throw new TypeError("Expected Uint8Array"); if (u3.length === 0) return ""; - for (var m2 = 0, z32 = 0, I2 = 0, _3 = u3.length; I2 !== _3 && u3[I2] === 0; ) - I2++, m2++; - for (var T2 = (_3 - I2) * d3 + 1 >>> 0, f2 = new Uint8Array(T2); I2 !== _3; ) { - for (var S2 = u3[I2], A2 = 0, C2 = T2 - 1; (S2 !== 0 || A2 < z32) && C2 !== -1; C2--, A2++) - S2 += 256 * f2[C2] >>> 0, f2[C2] = S2 % a3 >>> 0, S2 = S2 / a3 >>> 0; - if (S2 !== 0) + for (var p2 = 0, _3 = 0, D2 = 0, P2 = u3.length; D2 !== P2 && u3[D2] === 0; ) + D2++, p2++; + for (var x2 = (P2 - D2) * d5 + 1 >>> 0, E2 = new Uint8Array(x2); D2 !== P2; ) { + for (var O3 = u3[D2], N2 = 0, R2 = x2 - 1; (O3 !== 0 || N2 < _3) && R2 !== -1; R2--, N2++) + O3 += 256 * E2[R2] >>> 0, E2[R2] = O3 % a3 >>> 0, O3 = O3 / a3 >>> 0; + if (O3 !== 0) throw new Error("Non-zero carry"); - z32 = A2, I2++; + _3 = N2, D2++; } - for (var x2 = T2 - z32; x2 !== T2 && f2[x2] === 0; ) - x2++; - for (var j2 = h4.repeat(m2); x2 < T2; ++x2) - j2 += n3.charAt(f2[x2]); + for (var A2 = x2 - _3; A2 !== x2 && E2[A2] === 0; ) + A2++; + for (var j2 = h4.repeat(p2); A2 < x2; ++A2) + j2 += n4.charAt(E2[A2]); return j2; } - function y3(u3) { + function m3(u3) { if (typeof u3 != "string") throw new TypeError("Expected String"); if (u3.length === 0) return new Uint8Array(); - var m2 = 0; - if (u3[m2] !== " ") { - for (var z32 = 0, I2 = 0; u3[m2] === h4; ) - z32++, m2++; - for (var _3 = (u3.length - m2) * l2 + 1 >>> 0, T2 = new Uint8Array(_3); u3[m2]; ) { - var f2 = t2[u3.charCodeAt(m2)]; - if (f2 === 255) + var p2 = 0; + if (u3[p2] !== " ") { + for (var _3 = 0, D2 = 0; u3[p2] === h4; ) + _3++, p2++; + for (var P2 = (u3.length - p2) * l2 + 1 >>> 0, x2 = new Uint8Array(P2); u3[p2]; ) { + var E2 = t2[u3.charCodeAt(p2)]; + if (E2 === 255) return; - for (var S2 = 0, A2 = _3 - 1; (f2 !== 0 || S2 < I2) && A2 !== -1; A2--, S2++) - f2 += a3 * T2[A2] >>> 0, T2[A2] = f2 % 256 >>> 0, f2 = f2 / 256 >>> 0; - if (f2 !== 0) + for (var O3 = 0, N2 = P2 - 1; (E2 !== 0 || O3 < D2) && N2 !== -1; N2--, O3++) + E2 += a3 * x2[N2] >>> 0, x2[N2] = E2 % 256 >>> 0, E2 = E2 / 256 >>> 0; + if (E2 !== 0) throw new Error("Non-zero carry"); - I2 = S2, m2++; + D2 = O3, p2++; } - if (u3[m2] !== " ") { - for (var C2 = _3 - I2; C2 !== _3 && T2[C2] === 0; ) - C2++; - for (var x2 = new Uint8Array(z32 + (_3 - C2)), j2 = z32; C2 !== _3; ) - x2[j2++] = T2[C2++]; - return x2; + if (u3[p2] !== " ") { + for (var R2 = P2 - D2; R2 !== P2 && x2[R2] === 0; ) + R2++; + for (var A2 = new Uint8Array(_3 + (P2 - R2)), j2 = _3; R2 !== P2; ) + A2[j2++] = x2[R2++]; + return A2; } } } - function M2(u3) { - var m2 = y3(u3); - if (m2) - return m2; - throw new Error(`Non-${e} character`); + function L4(u3) { + var p2 = m3(u3); + if (p2) + return p2; + throw new Error(`Non-${e2} character`); } - return { encode: p3, decodeUnsafe: y3, decode: M2 }; + return { encode: g3, decodeUnsafe: m3, decode: L4 }; } -var Ji = Hi, Xi = Ji; -const Ne = (n3) => { - if (n3 instanceof Uint8Array && n3.constructor.name === "Uint8Array") - return n3; - if (n3 instanceof ArrayBuffer) - return new Uint8Array(n3); - if (ArrayBuffer.isView(n3)) - return new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength); +var Xi = Ji, Wi = Xi; +const Ue$1 = (n4) => { + if (n4 instanceof Uint8Array && n4.constructor.name === "Uint8Array") + return n4; + if (n4 instanceof ArrayBuffer) + return new Uint8Array(n4); + if (ArrayBuffer.isView(n4)) + return new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength); throw new Error("Unknown type, must be binary type"); -}, Wi = (n3) => new TextEncoder().encode(n3), Qi = (n3) => new TextDecoder().decode(n3); -class Zi { - constructor(e, t2, i2) { - this.name = e, this.prefix = t2, this.baseEncode = i2; - } - encode(e) { - if (e instanceof Uint8Array) - return `${this.prefix}${this.baseEncode(e)}`; +}, Qi = (n4) => new TextEncoder().encode(n4), Zi = (n4) => new TextDecoder().decode(n4); +let es$1 = class es { + constructor(e2, t2, i2) { + this.name = e2, this.prefix = t2, this.baseEncode = i2; + } + encode(e2) { + if (e2 instanceof Uint8Array) + return `${this.prefix}${this.baseEncode(e2)}`; throw Error("Unknown type, must be binary type"); } -} -class es { - constructor(e, t2, i2) { - if (this.name = e, this.prefix = t2, t2.codePointAt(0) === void 0) +}; +let ts$1 = class ts { + constructor(e2, t2, i2) { + if (this.name = e2, this.prefix = t2, t2.codePointAt(0) === void 0) throw new Error("Invalid prefix character"); this.prefixCodePoint = t2.codePointAt(0), this.baseDecode = i2; } - 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)); + decode(e2) { + if (typeof e2 == "string") { + if (e2.codePointAt(0) !== this.prefixCodePoint) + throw Error(`Unable to decode multibase string ${JSON.stringify(e2)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); + return this.baseDecode(e2.slice(this.prefix.length)); } else throw Error("Can only multibase decode strings"); } - or(e) { - return Ue(this, e); + or(e2) { + return $e(this, e2); } -} -class ts { - constructor(e) { - this.decoders = e; +}; +let is$1 = class is { + constructor(e2) { + this.decoders = e2; } - or(e) { - return Ue(this, e); + or(e2) { + return $e(this, e2); } - decode(e) { - const t2 = e[0], i2 = this.decoders[t2]; + decode(e2) { + const t2 = e2[0], i2 = this.decoders[t2]; if (i2) - return i2.decode(e); - throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + return i2.decode(e2); + throw RangeError(`Unable to decode multibase string ${JSON.stringify(e2)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); } -} -const Ue = (n3, e) => new ts({ ...n3.decoders || { [n3.prefix]: n3 }, ...e.decoders || { [e.prefix]: e } }); -class is { - constructor(e, t2, i2, s2) { - this.name = e, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new Zi(e, t2, i2), this.decoder = new es(e, t2, s2); +}; +const $e = (n4, e2) => new is$1({ ...n4.decoders || { [n4.prefix]: n4 }, ...e2.decoders || { [e2.prefix]: e2 } }); +let ss$2 = class ss { + constructor(e2, t2, i2, s2) { + this.name = e2, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new es$1(e2, t2, i2), this.decoder = new ts$1(e2, t2, s2); } - encode(e) { - return this.encoder.encode(e); + encode(e2) { + return this.encoder.encode(e2); } - decode(e) { - return this.decoder.decode(e); + decode(e2) { + return this.decoder.decode(e2); } -} -const W$1 = ({ name: n3, prefix: e, encode: t2, decode: i2 }) => new is(n3, e, t2, i2), B = ({ prefix: n3, name: e, alphabet: t2 }) => { - const { encode: i2, decode: s2 } = Xi(t2, e); - return W$1({ prefix: n3, name: e, encode: i2, decode: (r2) => Ne(s2(r2)) }); -}, ss = (n3, e, t2, i2) => { +}; +const Q$1 = ({ name: n4, prefix: e2, encode: t2, decode: i2 }) => new ss$2(n4, e2, t2, i2), K$1 = ({ prefix: n4, name: e2, alphabet: t2 }) => { + const { encode: i2, decode: s2 } = Wi(t2, e2); + return Q$1({ prefix: n4, name: e2, encode: i2, decode: (r3) => Ue$1(s2(r3)) }); +}, rs$1 = (n4, e2, t2, i2) => { const s2 = {}; - for (let d3 = 0; d3 < e.length; ++d3) - s2[e[d3]] = d3; - let r2 = n3.length; - for (; n3[r2 - 1] === "="; ) - --r2; - const o2 = new Uint8Array(r2 * t2 / 8 | 0); + for (let d5 = 0; d5 < e2.length; ++d5) + s2[e2[d5]] = d5; + let r3 = n4.length; + for (; n4[r3 - 1] === "="; ) + --r3; + const o2 = new Uint8Array(r3 * t2 / 8 | 0); let a3 = 0, h4 = 0, l2 = 0; - for (let d3 = 0; d3 < r2; ++d3) { - const p3 = s2[n3[d3]]; - if (p3 === void 0) + for (let d5 = 0; d5 < r3; ++d5) { + const g3 = s2[n4[d5]]; + if (g3 === void 0) throw new SyntaxError(`Non-${i2} character`); - h4 = h4 << t2 | p3, a3 += t2, a3 >= 8 && (a3 -= 8, o2[l2++] = 255 & h4 >> a3); + h4 = h4 << t2 | g3, a3 += t2, a3 >= 8 && (a3 -= 8, o2[l2++] = 255 & h4 >> a3); } if (a3 >= t2 || 255 & h4 << 8 - a3) throw new SyntaxError("Unexpected end of data"); return o2; -}, rs = (n3, e, t2) => { - const i2 = e[e.length - 1] === "=", s2 = (1 << t2) - 1; - let r2 = "", o2 = 0, a3 = 0; - for (let h4 = 0; h4 < n3.length; ++h4) - for (a3 = a3 << 8 | n3[h4], o2 += 8; o2 > t2; ) - o2 -= t2, r2 += e[s2 & a3 >> o2]; - if (o2 && (r2 += e[s2 & a3 << t2 - o2]), i2) - for (; r2.length * t2 & 7; ) - r2 += "="; - return r2; -}, g$2 = ({ name: n3, prefix: e, bitsPerChar: t2, alphabet: i2 }) => W$1({ prefix: e, name: n3, encode(s2) { - return rs(s2, i2, t2); +}, ns = (n4, e2, t2) => { + const i2 = e2[e2.length - 1] === "=", s2 = (1 << t2) - 1; + let r3 = "", o2 = 0, a3 = 0; + for (let h4 = 0; h4 < n4.length; ++h4) + for (a3 = a3 << 8 | n4[h4], o2 += 8; o2 > t2; ) + o2 -= t2, r3 += e2[s2 & a3 >> o2]; + if (o2 && (r3 += e2[s2 & a3 << t2 - o2]), i2) + for (; r3.length * t2 & 7; ) + r3 += "="; + return r3; +}, y2 = ({ name: n4, prefix: e2, bitsPerChar: t2, alphabet: i2 }) => Q$1({ prefix: e2, name: n4, encode(s2) { + return ns(s2, i2, t2); }, decode(s2) { - return ss(s2, i2, t2, n3); -} }), ns = W$1({ prefix: "\0", name: "identity", encode: (n3) => Qi(n3), decode: (n3) => Wi(n3) }); -var os = Object.freeze({ __proto__: null, identity: ns }); -const as$1 = g$2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); -var hs$1 = Object.freeze({ __proto__: null, base2: as$1 }); -const cs$1 = g$2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); -var us$1 = Object.freeze({ __proto__: null, base8: cs$1 }); -const ls$1 = B({ prefix: "9", name: "base10", alphabet: "0123456789" }); -var ds$1 = Object.freeze({ __proto__: null, base10: ls$1 }); -const gs$1 = g$2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), ps$1 = g$2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); -var Ds = Object.freeze({ __proto__: null, base16: gs$1, base16upper: ps$1 }); -const ys = g$2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), ms$1 = g$2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), bs = g$2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), fs = g$2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), Es = g$2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), ws = g$2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), vs = g$2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Is = g$2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), Cs = g$2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); -var Rs = Object.freeze({ __proto__: null, base32: ys, base32upper: ms$1, base32pad: bs, base32padupper: fs, base32hex: Es, base32hexupper: ws, base32hexpad: vs, base32hexpadupper: Is, base32z: Cs }); -const _s = B({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ts = B({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); -var Ss = Object.freeze({ __proto__: null, base36: _s, base36upper: Ts }); -const Ps = B({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), xs = B({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); -var Os = Object.freeze({ __proto__: null, base58btc: Ps, base58flickr: xs }); -const As = g$2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), zs = g$2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ns = g$2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us = g$2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); -var Ls = Object.freeze({ __proto__: null, base64: As, base64pad: zs, base64url: Ns, base64urlpad: Us }); -const Le = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), $s = Le.reduce((n3, e, t2) => (n3[t2] = e, n3), []), Fs = Le.reduce((n3, e, t2) => (n3[e.codePointAt(0)] = t2, n3), []); -function Ms(n3) { - return n3.reduce((e, t2) => (e += $s[t2], e), ""); -} -function ks(n3) { - const e = []; - for (const t2 of n3) { - const i2 = Fs[t2.codePointAt(0)]; + return rs$1(s2, i2, t2, n4); +} }), os$1 = Q$1({ prefix: "\0", name: "identity", encode: (n4) => Zi(n4), decode: (n4) => Qi(n4) }); +var as$1 = Object.freeze({ __proto__: null, identity: os$1 }); +const hs$1 = y2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); +var cs$1 = Object.freeze({ __proto__: null, base2: hs$1 }); +const ls$1 = y2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); +var us$1 = Object.freeze({ __proto__: null, base8: ls$1 }); +const ds$1 = K$1({ prefix: "9", name: "base10", alphabet: "0123456789" }); +var gs$1 = Object.freeze({ __proto__: null, base10: ds$1 }); +const ps$1 = y2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), Ds$1 = y2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); +var ys$1 = Object.freeze({ __proto__: null, base16: ps$1, base16upper: Ds$1 }); +const ms$2 = y2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), bs$1 = y2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), fs = y2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), Es$1 = y2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), ws$1 = y2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), vs$1 = y2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), Is$1 = y2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Cs$1 = y2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), _s$1 = y2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); +var Rs$1 = Object.freeze({ __proto__: null, base32: ms$2, base32upper: bs$1, base32pad: fs, base32padupper: Es$1, base32hex: ws$1, base32hexupper: vs$1, base32hexpad: Is$1, base32hexpadupper: Cs$1, base32z: _s$1 }); +const Ts$1 = K$1({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ss$1 = K$1({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); +var Ps$1 = Object.freeze({ __proto__: null, base36: Ts$1, base36upper: Ss$1 }); +const xs$1 = K$1({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), Os$1 = K$1({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); +var As$1 = Object.freeze({ __proto__: null, base58btc: xs$1, base58flickr: Os$1 }); +const zs$1 = y2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), Ns$1 = y2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ls$1 = y2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us$1 = y2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); +var $s$1 = Object.freeze({ __proto__: null, base64: zs$1, base64pad: Ns$1, base64url: Ls$1, base64urlpad: Us$1 }); +const Fe$1 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), Fs$1 = Fe$1.reduce((n4, e2, t2) => (n4[t2] = e2, n4), []), ks$1 = Fe$1.reduce((n4, e2, t2) => (n4[e2.codePointAt(0)] = t2, n4), []); +function Bs$1(n4) { + return n4.reduce((e2, t2) => (e2 += Fs$1[t2], e2), ""); +} +function Ms$1(n4) { + const e2 = []; + for (const t2 of n4) { + const i2 = ks$1[t2.codePointAt(0)]; if (i2 === void 0) throw new Error(`Non-base256emoji character: ${t2}`); - e.push(i2); - } - return new Uint8Array(e); -} -const Ks = W$1({ prefix: "🚀", name: "base256emoji", encode: Ms, decode: ks }); -var Bs = Object.freeze({ __proto__: null, base256emoji: Ks }), Vs = Fe, $e = 128, qs = 127, js = ~qs, Gs = Math.pow(2, 31); -function Fe(n3, e, t2) { - e = e || [], t2 = t2 || 0; - for (var i2 = t2; n3 >= Gs; ) - e[t2++] = n3 & 255 | $e, n3 /= 128; - for (; n3 & js; ) - e[t2++] = n3 & 255 | $e, n3 >>>= 7; - return e[t2] = n3 | 0, Fe.bytes = t2 - i2 + 1, e; -} -var Ys = he$1, Hs = 128, Me = 127; -function he$1(n3, i2) { - var t2 = 0, i2 = i2 || 0, s2 = 0, r2 = i2, o2, a3 = n3.length; + e2.push(i2); + } + return new Uint8Array(e2); +} +const Ks$1 = Q$1({ prefix: "🚀", name: "base256emoji", encode: Bs$1, decode: Ms$1 }); +var Vs$1 = Object.freeze({ __proto__: null, base256emoji: Ks$1 }), qs$1 = Be$2, ke$1 = 128, js$1 = 127, Gs$1 = ~js$1, Ys$1 = Math.pow(2, 31); +function Be$2(n4, e2, t2) { + e2 = e2 || [], t2 = t2 || 0; + for (var i2 = t2; n4 >= Ys$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 /= 128; + for (; n4 & Gs$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 >>>= 7; + return e2[t2] = n4 | 0, Be$2.bytes = t2 - i2 + 1, e2; +} +var Hs$1 = de$1, Js$1 = 128, Me = 127; +function de$1(n4, i2) { + var t2 = 0, i2 = i2 || 0, s2 = 0, r3 = i2, o2, a3 = n4.length; do { - if (r2 >= a3) - throw he$1.bytes = 0, new RangeError("Could not decode varint"); - o2 = n3[r2++], t2 += s2 < 28 ? (o2 & Me) << s2 : (o2 & Me) * Math.pow(2, s2), s2 += 7; - } while (o2 >= Hs); - return he$1.bytes = r2 - i2, t2; -} -var Js = Math.pow(2, 7), Xs = Math.pow(2, 14), Ws = Math.pow(2, 21), Qs = Math.pow(2, 28), Zs = Math.pow(2, 35), er = Math.pow(2, 42), tr = Math.pow(2, 49), ir = Math.pow(2, 56), sr2 = Math.pow(2, 63), rr = function(n3) { - return n3 < Js ? 1 : n3 < Xs ? 2 : n3 < Ws ? 3 : n3 < Qs ? 4 : n3 < Zs ? 5 : n3 < er ? 6 : n3 < tr ? 7 : n3 < ir ? 8 : n3 < sr2 ? 9 : 10; -}, nr = { encode: Vs, decode: Ys, encodingLength: rr }, ke = nr; -const Ke = (n3, e, t2 = 0) => (ke.encode(n3, e, t2), e), Be = (n3) => ke.encodingLength(n3), ce$1 = (n3, e) => { - const t2 = e.byteLength, i2 = Be(n3), s2 = i2 + Be(t2), r2 = new Uint8Array(s2 + t2); - return Ke(n3, r2, 0), Ke(t2, r2, i2), r2.set(e, s2), new or(n3, t2, e, r2); -}; -class or { - constructor(e, t2, i2, s2) { - this.code = e, this.size = t2, this.digest = i2, this.bytes = s2; - } -} -const Ve = ({ name: n3, code: e, encode: t2 }) => new ar(n3, e, t2); -class ar { - constructor(e, t2, i2) { - this.name = e, this.code = t2, this.encode = i2; - } - digest(e) { - if (e instanceof Uint8Array) { - const t2 = this.encode(e); - return t2 instanceof Uint8Array ? ce$1(this.code, t2) : t2.then((i2) => ce$1(this.code, i2)); + if (r3 >= a3) + throw de$1.bytes = 0, new RangeError("Could not decode varint"); + o2 = n4[r3++], t2 += s2 < 28 ? (o2 & Me) << s2 : (o2 & Me) * Math.pow(2, s2), s2 += 7; + } while (o2 >= Js$1); + return de$1.bytes = r3 - i2, t2; +} +var Xs$1 = Math.pow(2, 7), Ws$1 = Math.pow(2, 14), Qs$1 = Math.pow(2, 21), Zs$1 = Math.pow(2, 28), er = Math.pow(2, 35), tr$1 = Math.pow(2, 42), ir$1 = Math.pow(2, 49), sr$1 = Math.pow(2, 56), rr$1 = Math.pow(2, 63), nr$1 = function(n4) { + return n4 < Xs$1 ? 1 : n4 < Ws$1 ? 2 : n4 < Qs$1 ? 3 : n4 < Zs$1 ? 4 : n4 < er ? 5 : n4 < tr$1 ? 6 : n4 < ir$1 ? 7 : n4 < sr$1 ? 8 : n4 < rr$1 ? 9 : 10; +}, or$1 = { encode: qs$1, decode: Hs$1, encodingLength: nr$1 }, Ke$1 = or$1; +const Ve = (n4, e2, t2 = 0) => (Ke$1.encode(n4, e2, t2), e2), qe = (n4) => Ke$1.encodingLength(n4), ge = (n4, e2) => { + const t2 = e2.byteLength, i2 = qe(n4), s2 = i2 + qe(t2), r3 = new Uint8Array(s2 + t2); + return Ve(n4, r3, 0), Ve(t2, r3, i2), r3.set(e2, s2), new ar$1(n4, t2, e2, r3); +}; +let ar$1 = class ar { + constructor(e2, t2, i2, s2) { + this.code = e2, this.size = t2, this.digest = i2, this.bytes = s2; + } +}; +const je$1 = ({ name: n4, code: e2, encode: t2 }) => new hr$1(n4, e2, t2); +let hr$1 = class hr { + constructor(e2, t2, i2) { + this.name = e2, this.code = t2, this.encode = i2; + } + digest(e2) { + if (e2 instanceof Uint8Array) { + const t2 = this.encode(e2); + return t2 instanceof Uint8Array ? ge(this.code, t2) : t2.then((i2) => ge(this.code, i2)); } else throw Error("Unknown type, must be binary type"); } -} -const qe = (n3) => async (e) => new Uint8Array(await crypto.subtle.digest(n3, e)), hr = Ve({ name: "sha2-256", code: 18, encode: qe("SHA-256") }), cr = Ve({ name: "sha2-512", code: 19, encode: qe("SHA-512") }); -var ur = Object.freeze({ __proto__: null, sha256: hr, sha512: cr }); -const je = 0, lr = "identity", Ge = Ne, dr = (n3) => ce$1(je, Ge(n3)), gr = { code: je, name: lr, encode: Ge, digest: dr }; -var pr = Object.freeze({ __proto__: null, identity: gr }); +}; +const Ge$1 = (n4) => async (e2) => new Uint8Array(await crypto.subtle.digest(n4, e2)), cr$1 = je$1({ name: "sha2-256", code: 18, encode: Ge$1("SHA-256") }), lr = je$1({ name: "sha2-512", code: 19, encode: Ge$1("SHA-512") }); +var ur$1 = Object.freeze({ __proto__: null, sha256: cr$1, sha512: lr }); +const Ye$1 = 0, dr$1 = "identity", He$1 = Ue$1, gr$1 = (n4) => ge(Ye$1, He$1(n4)), pr = { code: Ye$1, name: dr$1, encode: He$1, digest: gr$1 }; +var Dr$1 = Object.freeze({ __proto__: null, identity: pr }); new TextEncoder(), new TextDecoder(); -const Ye = { ...os, ...hs$1, ...us$1, ...ds$1, ...Ds, ...Rs, ...Ss, ...Os, ...Ls, ...Bs }; -({ ...ur, ...pr }); -function He(n3) { - return globalThis.Buffer != null ? new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength) : n3; -} -function Dr(n3 = 0) { - return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? He(globalThis.Buffer.allocUnsafe(n3)) : new Uint8Array(n3); -} -function Je(n3, e, t2, i2) { - return { name: n3, prefix: e, encoder: { name: n3, prefix: e, encode: t2 }, decoder: { decode: i2 } }; -} -const Xe = Je("utf8", "u", (n3) => "u" + new TextDecoder("utf8").decode(n3), (n3) => new TextEncoder().encode(n3.substring(1))), ue$1 = Je("ascii", "a", (n3) => { - let e = "a"; - for (let t2 = 0; t2 < n3.length; t2++) - e += String.fromCharCode(n3[t2]); - return e; -}, (n3) => { - n3 = n3.substring(1); - const e = Dr(n3.length); - for (let t2 = 0; t2 < n3.length; t2++) - e[t2] = n3.charCodeAt(t2); - return e; -}), yr = { utf8: Xe, "utf-8": Xe, hex: Ye.base16, latin1: ue$1, ascii: ue$1, binary: ue$1, ...Ye }; -function mr(n3, e = "utf8") { - const t2 = yr[e]; +const Je$1 = { ...as$1, ...cs$1, ...us$1, ...gs$1, ...ys$1, ...Rs$1, ...Ps$1, ...As$1, ...$s$1, ...Vs$1 }; +({ ...ur$1, ...Dr$1 }); +function Xe$2(n4) { + return globalThis.Buffer != null ? new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength) : n4; +} +function yr$1(n4 = 0) { + return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? Xe$2(globalThis.Buffer.allocUnsafe(n4)) : new Uint8Array(n4); +} +function We$1(n4, e2, t2, i2) { + return { name: n4, prefix: e2, encoder: { name: n4, prefix: e2, encode: t2 }, decoder: { decode: i2 } }; +} +const Qe$1 = We$1("utf8", "u", (n4) => "u" + new TextDecoder("utf8").decode(n4), (n4) => new TextEncoder().encode(n4.substring(1))), pe$1 = We$1("ascii", "a", (n4) => { + let e2 = "a"; + for (let t2 = 0; t2 < n4.length; t2++) + e2 += String.fromCharCode(n4[t2]); + return e2; +}, (n4) => { + n4 = n4.substring(1); + const e2 = yr$1(n4.length); + for (let t2 = 0; t2 < n4.length; t2++) + e2[t2] = n4.charCodeAt(t2); + return e2; +}), mr$1 = { utf8: Qe$1, "utf-8": Qe$1, hex: Je$1.base16, latin1: pe$1, ascii: pe$1, binary: pe$1, ...Je$1 }; +function br(n4, e2 = "utf8") { + const t2 = mr$1[e2]; if (!t2) - throw new Error(`Unsupported encoding "${e}"`); - return (e === "utf8" || e === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? He(globalThis.Buffer.from(n3, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n3}`); + throw new Error(`Unsupported encoding "${e2}"`); + return (e2 === "utf8" || e2 === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? Xe$2(globalThis.Buffer.from(n4, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n4}`); } -const le$1 = "wc", We = 2, Q$1 = "core", O = `${le$1}@2:${Q$1}:`, Qe = { name: Q$1, logger: "error" }, Ze = { database: ":memory:" }, et = "crypto", de$1 = "client_ed25519_seed", tt = cjs$4.ONE_DAY, it = "keychain", st = "0.3", rt = "messages", nt = "0.3", ot = cjs$4.SIX_HOURS, at = "publisher", ht = "irn", ct = "error", ge$1 = "wss://relay.walletconnect.com", pe$1 = "wss://relay.walletconnect.org", ut = "relayer", D$1 = { 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" }, lt = "_subscription", P$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, dt = cjs$4.ONE_SECOND, gt = "2.11.2", pt = 1e4, Dt = "0.3", yt = "WALLETCONNECT_CLIENT_ID", w$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, mt = "subscription", bt = "0.3", ft = cjs$4.FIVE_SECONDS * 1e3, Et = "pairing", wt = "0.3", $ = { wc_pairingDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 } } }, V = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, R$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, vt = "history", It = "0.3", Ct = "expirer", v2 = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Rt = "0.3", Z = "verify-api", F$1 = "https://verify.walletconnect.com", ee = "https://verify.walletconnect.org", _t = [F$1, ee], Tt = "echo", St = "https://echo.walletconnect.com"; -class Pt { - constructor(e, t2) { - this.core = e, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = it, this.version = st, this.initialized = false, this.storagePrefix = O, this.init = async () => { +const De = "wc", Ze$1 = 2, Z = "core", z$1 = `${De}@2:${Z}:`, et = { name: Z, logger: "error" }, tt = { database: ":memory:" }, it = "crypto", ye$1 = "client_ed25519_seed", st = cjs$3.ONE_DAY, rt = "keychain", nt = "0.3", ot = "messages", at = "0.3", ht = cjs$3.SIX_HOURS, ct = "publisher", lt = "irn", ut = "error", me = "wss://relay.walletconnect.com", be$1 = "wss://relay.walletconnect.org", dt = "relayer", v2 = { 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" }, gt = "_subscription", f$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, pt = cjs$3.ONE_SECOND, Dt$1 = "2.12.2", yt = 1e4, mt = "0.3", bt = "WALLETCONNECT_CLIENT_ID", S$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, ft = "subscription", Et = "0.3", wt = cjs$3.FIVE_SECONDS * 1e3, vt = "pairing", It = "0.3", F$1 = { wc_pairingDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 } } }, V$1 = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, I$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, Ct = "history", _t = "0.3", Rt = "expirer", C = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Tt$1 = "0.3", ee = "verify-api", k$1 = "https://verify.walletconnect.com", te = "https://verify.walletconnect.org", St = [k$1, te], Pt = "echo", xt = "https://echo.walletconnect.com"; +let Ot$1 = class Ot { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = rt, this.version = nt, this.initialized = false, this.storagePrefix = z$1, this.init = async () => { if (!this.initialized) { const i2 = await this.getKeyChain(); typeof i2 < "u" && (this.keychain = i2), this.initialized = true; @@ -10425,126 +13933,126 @@ class Pt { this.isInitialized(); const s2 = this.keychain.get(i2); if (typeof s2 > "u") { - const { message: r2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${i2}`); - throw new Error(r2); + const { message: r3 } = xe("NO_MATCHING_KEY", `${this.name}: ${i2}`); + throw new Error(r3); } return s2; }, this.del = async (i2) => { this.isInitialized(), this.keychain.delete(i2), await this.persist(); - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.core = e2, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } - async setKeyChain(e) { - await this.core.storage.setItem(this.storageKey, rt$1(e)); + async setKeyChain(e2) { + await this.core.storage.setItem(this.storageKey, i0(e2)); } async getKeyChain() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? ot$1(e) : void 0; + const e2 = await this.core.storage.getItem(this.storageKey); + return typeof e2 < "u" ? n0(e2) : void 0; } async persist() { await this.setKeyChain(this.keychain); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } -} -class xt { - constructor(e, t2, i2) { - this.core = e, this.logger = t2, this.name = et, this.initialized = false, this.init = async () => { +}; +class At { + constructor(e2, t2, i2) { + this.core = e2, this.logger = t2, this.name = it, this.initialized = false, this.init = async () => { this.initialized || (await this.keychain.init(), this.initialized = true); }, this.hasKeys = (s2) => (this.isInitialized(), this.keychain.has(s2)), this.getClientId = async () => { this.isInitialized(); - const s2 = await this.getClientSeed(), r2 = generateKeyPair(s2); - return encodeIss(r2.publicKey); + const s2 = await this.getClientSeed(), r3 = generateKeyPair(s2); + return encodeIss(r3.publicKey); }, this.generateKeyPair = () => { this.isInitialized(); - const s2 = kn(); + const s2 = mu(); return this.setPrivateKey(s2.publicKey, s2.privateKey); }, this.signJWT = async (s2) => { this.isInitialized(); - const r2 = await this.getClientSeed(), o2 = generateKeyPair(r2), a3 = Vn(), h4 = tt; + const r3 = await this.getClientSeed(), o2 = generateKeyPair(r3), a3 = gu(), h4 = st; return await signJWT(a3, s2, h4, o2); - }, this.generateSharedKey = (s2, r2, o2) => { + }, this.generateSharedKey = (s2, r3, o2) => { this.isInitialized(); - const a3 = this.getPrivateKey(s2), h4 = Mn(a3, r2); + const a3 = this.getPrivateKey(s2), h4 = Au(a3, r3); return this.setSymKey(h4, o2); - }, this.setSymKey = async (s2, r2) => { + }, this.setSymKey = async (s2, r3) => { this.isInitialized(); - const o2 = r2 || Kn(s2); + const o2 = r3 || bu(s2); return await this.keychain.set(o2, s2), o2; }, this.deleteKeyPair = async (s2) => { this.isInitialized(), await this.keychain.del(s2); }, this.deleteSymKey = async (s2) => { this.isInitialized(), await this.keychain.del(s2); - }, this.encode = async (s2, r2, o2) => { + }, this.encode = async (s2, r3, o2) => { this.isInitialized(); - const a3 = Ae(o2), h4 = safeJsonStringify(r2); - if (qn(a3)) { - const y3 = a3.senderPublicKey, M2 = a3.receiverPublicKey; - s2 = await this.generateSharedKey(y3, M2); - } - const l2 = this.getSymKey(s2), { type: d3, senderPublicKey: p3 } = a3; - return xn({ type: d3, symKey: l2, message: h4, senderPublicKey: p3 }); - }, this.decode = async (s2, r2, o2) => { + const a3 = eo(o2), h4 = safeJsonStringify(r3); + if (Eu(a3)) { + const m3 = a3.senderPublicKey, L4 = a3.receiverPublicKey; + s2 = await this.generateSharedKey(m3, L4); + } + const l2 = this.getSymKey(s2), { type: d5, senderPublicKey: g3 } = a3; + return wu({ type: d5, symKey: l2, message: h4, senderPublicKey: g3 }); + }, this.decode = async (s2, r3, o2) => { this.isInitialized(); - const a3 = Hn(r2, o2); - if (qn(a3)) { + const a3 = Mu(r3, o2); + if (Eu(a3)) { const h4 = a3.receiverPublicKey, l2 = a3.senderPublicKey; s2 = await this.generateSharedKey(h4, l2); } try { - const h4 = this.getSymKey(s2), l2 = Fn({ symKey: h4, encoded: r2 }); + const h4 = this.getSymKey(s2), l2 = xu({ symKey: h4, encoded: r3 }); return safeJsonParse(l2); } catch (h4) { this.logger.error(`Failed to decode message from topic: '${s2}', clientId: '${await this.getClientId()}'`), this.logger.error(h4); } }, this.getPayloadType = (s2) => { - const r2 = ee$1(s2); - return j$1(r2.type); + const r3 = Xi$1(s2); + return Mr(r3.type); }, this.getPayloadSenderPublicKey = (s2) => { - const r2 = ee$1(s2); - return r2.senderPublicKey ? toString(r2.senderPublicKey, p$1) : void 0; - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.keychain = i2 || new Pt(this.core, this.logger); + const r3 = Xi$1(s2); + return r3.senderPublicKey ? toString(r3.senderPublicKey, zt$1) : void 0; + }, this.core = e2, this.logger = E$1(t2, this.name), this.keychain = i2 || new Ot$1(this.core, this.logger); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } - async setPrivateKey(e, t2) { - return await this.keychain.set(e, t2), e; + async setPrivateKey(e2, t2) { + return await this.keychain.set(e2, t2), e2; } - getPrivateKey(e) { - return this.keychain.get(e); + getPrivateKey(e2) { + return this.keychain.get(e2); } async getClientSeed() { - let e = ""; + let e2 = ""; try { - e = this.keychain.get(de$1); + e2 = this.keychain.get(ye$1); } catch { - e = Vn(), await this.keychain.set(de$1, e); + e2 = gu(), await this.keychain.set(ye$1, e2); } - return mr(e, "base16"); + return br(e2, "base16"); } - getSymKey(e) { - return this.keychain.get(e); + getSymKey(e2) { + return this.keychain.get(e2); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } } -class Ot extends a$2 { - constructor(e, t2) { - super(e, t2), this.logger = e, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = rt, this.version = nt, this.initialized = false, this.storagePrefix = O, this.init = async () => { +class zt extends a$1 { + constructor(e2, t2) { + super(e2, t2), this.logger = e2, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = ot, this.version = at, this.initialized = false, this.storagePrefix = z$1, this.init = async () => { if (!this.initialized) { this.logger.trace("Initialized"); try { @@ -10558,63 +14066,62 @@ class Ot extends a$2 { } }, this.set = async (i2, s2) => { this.isInitialized(); - const r2 = Ln(s2); + const r3 = yu(s2); let o2 = this.messages.get(i2); - return typeof o2 > "u" && (o2 = {}), typeof o2[r2] < "u" || (o2[r2] = s2, this.messages.set(i2, o2), await this.persist()), r2; + return typeof o2 > "u" && (o2 = {}), typeof o2[r3] < "u" || (o2[r3] = s2, this.messages.set(i2, o2), await this.persist()), r3; }, this.get = (i2) => { this.isInitialized(); let s2 = this.messages.get(i2); return typeof s2 > "u" && (s2 = {}), s2; }, this.has = (i2, s2) => { this.isInitialized(); - const r2 = this.get(i2), o2 = Ln(s2); - return typeof r2[o2] < "u"; + const r3 = this.get(i2), o2 = yu(s2); + return typeof r3[o2] < "u"; }, this.del = async (i2) => { this.isInitialized(), this.messages.delete(i2), await this.persist(); - }, this.logger = cjs$3.generateChildLogger(e, this.name), this.core = t2; + }, this.logger = E$1(e2, this.name), this.core = t2; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } - async setRelayerMessages(e) { - await this.core.storage.setItem(this.storageKey, rt$1(e)); + async setRelayerMessages(e2) { + await this.core.storage.setItem(this.storageKey, i0(e2)); } async getRelayerMessages() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? ot$1(e) : void 0; + const e2 = await this.core.storage.getItem(this.storageKey); + return typeof e2 < "u" ? n0(e2) : void 0; } async persist() { await this.setRelayerMessages(this.messages); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } } -class vr extends u$1 { - constructor(e, t2) { - super(e, t2), this.relayer = e, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = at, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$4.toMiliseconds(cjs$4.TEN_SECONDS * 2), this.needsTransportRestart = false, this.publish = async (i2, s2, r2) => { +class Ir extends u$1 { + constructor(e2, t2) { + super(e2, t2), this.relayer = e2, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = ct, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.failedPublishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_SECOND), this.needsTransportRestart = false, this.publish = async (i2, s2, r3) => { var o2; - this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); + this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r3 } }); + const a3 = (r3 == null ? void 0 : r3.ttl) || ht, h4 = Su(r3), l2 = (r3 == null ? void 0 : r3.prompt) || false, d5 = (r3 == null ? void 0 : r3.tag) || 0, g3 = (r3 == null ? void 0 : r3.id) || getBigIntRpcId().toString(), m3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d5, id: g3 } }, L4 = `Failed to publish payload, please try again. id:${g3} tag:${d5}`, u3 = Date.now(); + let p2, _3 = 1; try { - const a3 = (r2 == null ? void 0 : r2.ttl) || ot, h4 = vt$1(r2), l2 = (r2 == null ? void 0 : r2.prompt) || false, d3 = (r2 == null ? void 0 : r2.tag) || 0, p3 = (r2 == null ? void 0 : r2.id) || getBigIntRpcId().toString(), y3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d3, id: p3 } }, M2 = setTimeout(() => this.queue.set(p3, y3), this.publishTimeout); - try { - await await ut$1(this.rpcPublish(i2, s2, a3, h4, l2, d3, p3), this.publishTimeout, `Failed to publish payload, please try again. id:${p3} tag:${d3}`), this.removeRequestFromQueue(p3), this.relayer.events.emit(D$1.publish, y3); - } catch (u3) { - if (this.logger.debug("Publishing Payload stalled"), this.needsTransportRestart = true, (o2 = r2 == null ? void 0 : r2.internal) != null && o2.throwOnFailedPublish) - throw this.removeRequestFromQueue(p3), u3; - return; - } finally { - clearTimeout(M2); + for (; p2 === void 0; ) { + if (Date.now() - u3 > this.publishTimeout) + throw new Error(L4); + this.logger.trace({ id: g3, attempts: _3 }, `publisher.publish - attempt ${_3}`), p2 = await await u0(this.rpcPublish(i2, s2, a3, h4, l2, d5, g3).catch((D2) => this.logger.warn(D2)), this.publishTimeout, L4), _3++, p2 || await new Promise((D2) => setTimeout(D2, this.failedPublishTimeout)); } - this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); - } catch (a3) { - throw this.logger.debug("Failed to Publish Payload"), this.logger.error(a3), a3; + this.relayer.events.emit(v2.publish, m3), this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { id: g3, topic: i2, message: s2, opts: r3 } }); + } catch (D2) { + if (this.logger.debug("Failed to Publish Payload"), this.logger.error(D2), (o2 = r3 == null ? void 0 : r3.internal) != null && o2.throwOnFailedPublish) + throw D2; + this.queue.set(g3, m3); } }, this.on = (i2, s2) => { this.events.on(i2, s2); @@ -10624,58 +14131,58 @@ class vr extends u$1 { this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); - }, this.relayer = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.registerEventListeners(); + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.registerEventListeners(); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } - rpcPublish(e, t2, i2, s2, r2, o2, a3) { - var h4, l2, d3, p3; - const y3 = { method: Et$1(s2.protocol).publish, params: { topic: e, message: t2, ttl: i2, prompt: r2, tag: o2 }, id: a3 }; - return w$3((h4 = y3.params) == null ? void 0 : h4.prompt) && ((l2 = y3.params) == null || delete l2.prompt), w$3((d3 = y3.params) == null ? void 0 : d3.tag) && ((p3 = y3.params) == null || delete p3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: y3 }), this.relayer.request(y3); + rpcPublish(e2, t2, i2, s2, r3, o2, a3) { + var h4, l2, d5, g3; + const m3 = { method: Nu(s2.protocol).publish, params: { topic: e2, message: t2, ttl: i2, prompt: r3, tag: o2 }, id: a3 }; + return Pe((h4 = m3.params) == null ? void 0 : h4.prompt) && ((l2 = m3.params) == null || delete l2.prompt), Pe((d5 = m3.params) == null ? void 0 : d5.tag) && ((g3 = m3.params) == null || delete g3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: m3 }), this.relayer.request(m3); } - removeRequestFromQueue(e) { - this.queue.delete(e); + removeRequestFromQueue(e2) { + this.queue.delete(e2); } checkQueue() { - this.queue.forEach(async (e) => { - const { topic: t2, message: i2, opts: s2 } = e; + this.queue.forEach(async (e2) => { + const { topic: t2, message: i2, opts: s2 } = e2; await this.publish(t2, i2, s2); }); } registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { if (this.needsTransportRestart) { - this.needsTransportRestart = false, this.relayer.events.emit(D$1.connection_stalled); + this.needsTransportRestart = false, this.relayer.events.emit(v2.connection_stalled); return; } this.checkQueue(); - }), this.relayer.on(D$1.message_ack, (e) => { - this.removeRequestFromQueue(e.id.toString()); + }), this.relayer.on(v2.message_ack, (e2) => { + this.removeRequestFromQueue(e2.id.toString()); }); } } -class Ir { +let Cr$1 = class Cr { constructor() { - this.map = /* @__PURE__ */ new Map(), this.set = (e, t2) => { - const i2 = this.get(e); - this.exists(e, t2) || this.map.set(e, [...i2, t2]); - }, this.get = (e) => this.map.get(e) || [], this.exists = (e, t2) => this.get(e).includes(t2), this.delete = (e, t2) => { + this.map = /* @__PURE__ */ new Map(), this.set = (e2, t2) => { + const i2 = this.get(e2); + this.exists(e2, t2) || this.map.set(e2, [...i2, t2]); + }, this.get = (e2) => this.map.get(e2) || [], this.exists = (e2, t2) => this.get(e2).includes(t2), this.delete = (e2, t2) => { if (typeof t2 > "u") { - this.map.delete(e); + this.map.delete(e2); return; } - if (!this.map.has(e)) + if (!this.map.has(e2)) return; - const i2 = this.get(e); - if (!this.exists(e, t2)) + const i2 = this.get(e2); + if (!this.exists(e2, t2)) return; - const s2 = i2.filter((r2) => r2 !== t2); + const s2 = i2.filter((r3) => r3 !== t2); if (!s2.length) { - this.map.delete(e); + this.map.delete(e2); return; } - this.map.set(e, s2); + this.map.set(e2, s2); }, this.clear = () => { this.map.clear(); }; @@ -10683,28 +14190,28 @@ class Ir { get topics() { return Array.from(this.map.keys()); } -} -var Cr = Object.defineProperty, Rr = Object.defineProperties, _r = Object.getOwnPropertyDescriptors, At = Object.getOwnPropertySymbols, Tr = Object.prototype.hasOwnProperty, Sr = Object.prototype.propertyIsEnumerable, zt = (n3, e, t2) => e in n3 ? Cr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, q$1 = (n3, e) => { - for (var t2 in e || (e = {})) - Tr.call(e, t2) && zt(n3, t2, e[t2]); - if (At) - for (var t2 of At(e)) - Sr.call(e, t2) && zt(n3, t2, e[t2]); - return n3; -}, De = (n3, e) => Rr(n3, _r(e)); -class Nt extends d2 { - constructor(e, t2) { - super(e, t2), this.relayer = e, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Ir(), this.events = new eventsExports.EventEmitter(), this.name = mt, this.version = bt, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = O, this.subscribeTimeout = 1e4, this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { +}; +var _r = Object.defineProperty, Rr$1 = Object.defineProperties, Tr$1 = Object.getOwnPropertyDescriptors, Nt = Object.getOwnPropertySymbols, Sr = Object.prototype.hasOwnProperty, Pr$1 = Object.prototype.propertyIsEnumerable, Lt$1 = (n4, e2, t2) => e2 in n4 ? _r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, q$2 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Sr.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + if (Nt) + for (var t2 of Nt(e2)) + Pr$1.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + return n4; +}, fe$1 = (n4, e2) => Rr$1(n4, Tr$1(e2)); +let Ut$1 = class Ut2 extends d$1 { + constructor(e2, t2) { + super(e2, t2), this.relayer = e2, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Cr$1(), this.events = new eventsExports.EventEmitter(), this.name = ft, this.version = Et, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = z$1, this.subscribeTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), this.clientId = await this.relayer.core.crypto.getClientId()); }, this.subscribe = async (i2, s2) => { await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }); try { - const r2 = vt$1(s2), o2 = { topic: i2, relay: r2 }; + const r3 = Su(s2), o2 = { topic: i2, relay: r3 }; this.pending.set(i2, o2); - const a3 = await this.rpcSubscribe(i2, r2); - return this.onSubscribe(a3, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }), a3; - } catch (r2) { - throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r2), r2; + const a3 = await this.rpcSubscribe(i2, r3); + return typeof a3 == "string" && (this.onSubscribe(a3, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } })), a3; + } catch (r3) { + throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r3), r3; } }, this.unsubscribe = async (i2, s2) => { await this.restartToComplete(), this.isInitialized(), typeof (s2 == null ? void 0 : s2.id) < "u" ? await this.unsubscribeById(i2, s2.id, s2) : await this.unsubscribeByTopic(i2, s2); @@ -10712,11 +14219,11 @@ class Nt extends d2 { if (this.topics.includes(i2)) return true; const s2 = `${this.pendingSubscriptionWatchLabel}_${i2}`; - return await new Promise((r2, o2) => { - const a3 = new cjs$4.Watch(); + return await new Promise((r3, o2) => { + const a3 = new cjs$3.Watch(); a3.start(s2); const h4 = setInterval(() => { - !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r2(true)), a3.elapsed(s2) >= ft && (clearInterval(h4), a3.stop(s2), o2(new Error("Subscription resolution timeout"))); + !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r3(true)), a3.elapsed(s2) >= wt && (clearInterval(h4), a3.stop(s2), o2(new Error("Subscription resolution timeout"))); }, this.pollingInterval); }).catch(() => false); }, this.on = (i2, s2) => { @@ -10727,12 +14234,16 @@ class Nt extends d2 { this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); + }, this.start = async () => { + await this.onConnect(); + }, this.stop = async () => { + await this.onDisconnect(); }, this.restart = async () => { this.restartInProgress = true, await this.restore(), await this.reset(), this.restartInProgress = false; - }, this.relayer = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.clientId = ""; + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.clientId = ""; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.relayer.core.customStoragePrefix + "//" + this.name; @@ -10749,10 +14260,10 @@ class Nt extends d2 { get topics() { return this.topicMap.topics; } - hasSubscription(e, t2) { + hasSubscription(e2, t2) { let i2 = false; try { - i2 = this.getSubscription(e).topic === t2; + i2 = this.getSubscription(e2).topic === t2; } catch { } return i2; @@ -10763,303 +14274,326 @@ class Nt extends d2 { onDisable() { this.cached = this.values, this.subscriptions.clear(), this.topicMap.clear(); } - async unsubscribeByTopic(e, t2) { - const i2 = this.topicMap.get(e); - await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e, s2, t2))); + async unsubscribeByTopic(e2, t2) { + const i2 = this.topicMap.get(e2); + await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e2, s2, t2))); } - async unsubscribeById(e, t2, i2) { - this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: t2, opts: i2 } }); + async unsubscribeById(e2, t2, i2) { + this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); try { - const s2 = vt$1(i2); - await this.rpcUnsubscribe(e, t2, s2); - const r2 = U$2("USER_DISCONNECTED", `${this.name}, ${e}`); - await this.onUnsubscribe(e, t2, r2), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: t2, opts: i2 } }); + const s2 = Su(i2); + await this.rpcUnsubscribe(e2, t2, s2); + const r3 = tr$2("USER_DISCONNECTED", `${this.name}, ${e2}`); + await this.onUnsubscribe(e2, t2, r3), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); } catch (s2) { throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s2), s2; } } - async rpcSubscribe(e, t2) { - const i2 = { method: Et$1(t2.protocol).subscribe, params: { topic: e } }; + async rpcSubscribe(e2, t2) { + const i2 = { method: Nu(t2.protocol).subscribe, params: { topic: e2 } }; this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); try { - await await ut$1(this.relayer.request(i2), this.subscribeTimeout); + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout) ? yu(e2 + this.clientId) : null; } catch { - this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(D$1.connection_stalled); + this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(v2.connection_stalled); } - return Ln(e + this.clientId); + return null; } - async rpcBatchSubscribe(e) { - if (!e.length) + async rpcBatchSubscribe(e2) { + if (!e2.length) return; - const t2 = e[0].relay, i2 = { method: Et$1(t2.protocol).batchSubscribe, params: { topics: e.map((s2) => s2.topic) } }; + const t2 = e2[0].relay, i2 = { method: Nu(t2.protocol).batchSubscribe, params: { topics: e2.map((s2) => s2.topic) } }; this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); try { - return await await ut$1(this.relayer.request(i2), this.subscribeTimeout); + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout); } catch { - this.logger.debug("Outgoing Relay Payload stalled"), this.relayer.events.emit(D$1.connection_stalled); + this.relayer.events.emit(v2.connection_stalled); } } - rpcUnsubscribe(e, t2, i2) { - const s2 = { method: Et$1(i2.protocol).unsubscribe, params: { topic: e, id: t2 } }; + rpcUnsubscribe(e2, t2, i2) { + const s2 = { method: Nu(i2.protocol).unsubscribe, params: { topic: e2, id: t2 } }; return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s2 }), this.relayer.request(s2); } - onSubscribe(e, t2) { - this.setSubscription(e, De(q$1({}, t2), { id: e })), this.pending.delete(t2.topic); + onSubscribe(e2, t2) { + this.setSubscription(e2, fe$1(q$2({}, t2), { id: e2 })), this.pending.delete(t2.topic); } - onBatchSubscribe(e) { - e.length && e.forEach((t2) => { - this.setSubscription(t2.id, q$1({}, t2)), this.pending.delete(t2.topic); + onBatchSubscribe(e2) { + e2.length && e2.forEach((t2) => { + this.setSubscription(t2.id, q$2({}, t2)), this.pending.delete(t2.topic); }); } - async onUnsubscribe(e, t2, i2) { - this.events.removeAllListeners(t2), this.hasSubscription(t2, e) && this.deleteSubscription(t2, i2), await this.relayer.messages.del(e); + async onUnsubscribe(e2, t2, i2) { + this.events.removeAllListeners(t2), this.hasSubscription(t2, e2) && this.deleteSubscription(t2, i2), await this.relayer.messages.del(e2); } - async setRelayerSubscriptions(e) { - await this.relayer.core.storage.setItem(this.storageKey, e); + async setRelayerSubscriptions(e2) { + await this.relayer.core.storage.setItem(this.storageKey, e2); } async getRelayerSubscriptions() { return await this.relayer.core.storage.getItem(this.storageKey); } - setSubscription(e, t2) { - this.subscriptions.has(e) || (this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e, subscription: t2 }), this.addSubscription(e, t2)); + setSubscription(e2, t2) { + this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e2, subscription: t2 }), this.addSubscription(e2, t2); } - addSubscription(e, t2) { - this.subscriptions.set(e, q$1({}, t2)), this.topicMap.set(t2.topic, e), this.events.emit(w$1.created, t2); + addSubscription(e2, t2) { + this.subscriptions.set(e2, q$2({}, t2)), this.topicMap.set(t2.topic, e2), this.events.emit(S$1.created, t2); } - getSubscription(e) { - this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e }); - const t2 = this.subscriptions.get(e); + getSubscription(e2) { + this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e2 }); + const t2 = this.subscriptions.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw new Error(i2); } return t2; } - deleteSubscription(e, t2) { - this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e, reason: t2 }); - const i2 = this.getSubscription(e); - this.subscriptions.delete(e), this.topicMap.delete(i2.topic, e), this.events.emit(w$1.deleted, De(q$1({}, i2), { reason: t2 })); + deleteSubscription(e2, t2) { + this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e2, reason: t2 }); + const i2 = this.getSubscription(e2); + this.subscriptions.delete(e2), this.topicMap.delete(i2.topic, e2), this.events.emit(S$1.deleted, fe$1(q$2({}, i2), { reason: t2 })); } async persist() { - await this.setRelayerSubscriptions(this.values), this.events.emit(w$1.sync); + await this.setRelayerSubscriptions(this.values), this.events.emit(S$1.sync); } async reset() { if (this.cached.length) { - const e = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); - for (let t2 = 0; t2 < e; t2++) { + const e2 = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); + for (let t2 = 0; t2 < e2; t2++) { const i2 = this.cached.splice(0, this.batchSubscribeTopicsLimit); await this.batchSubscribe(i2); } } - this.events.emit(w$1.resubscribed); + this.events.emit(S$1.resubscribed); } async restore() { try { - const e = await this.getRelayerSubscriptions(); - if (typeof e > "u" || !e.length) + const e2 = await this.getRelayerSubscriptions(); + if (typeof e2 > "u" || !e2.length) return; if (this.subscriptions.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); } - 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); + this.cached = e2, this.logger.debug(`Successfully Restored subscriptions for ${this.name}`), this.logger.trace({ type: "method", method: "restore", subscriptions: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore subscriptions for ${this.name}`), this.logger.error(e2); } } - async batchSubscribe(e) { - if (!e.length) + async batchSubscribe(e2) { + if (!e2.length) return; - const t2 = await this.rpcBatchSubscribe(e); - k(t2) && this.onBatchSubscribe(t2.map((i2, s2) => De(q$1({}, e[s2]), { id: i2 }))); + const t2 = await this.rpcBatchSubscribe(e2); + Er(t2) && this.onBatchSubscribe(t2.map((i2, s2) => fe$1(q$2({}, e2[s2]), { id: i2 }))); } async onConnect() { - this.restartInProgress || (await this.restart(), this.onEnable()); + await this.restart(), this.onEnable(); } onDisconnect() { this.onDisable(); } async checkPending() { - if (!this.initialized || this.relayer.transportExplicitlyClosed) + if (!this.initialized || !this.relayer.connected) return; - const e = []; + const e2 = []; this.pending.forEach((t2) => { - e.push(t2); - }), await this.batchSubscribe(e); + e2.push(t2); + }), await this.batchSubscribe(e2); } registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, async () => { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, async () => { await this.checkPending(); - }), this.relayer.on(D$1.connect, async () => { - await this.onConnect(); - }), this.relayer.on(D$1.disconnect, () => { - this.onDisconnect(); - }), this.events.on(w$1.created, async (e) => { - const t2 = w$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), await this.persist(); - }), this.events.on(w$1.deleted, async (e) => { - const t2 = w$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), await this.persist(); + }), this.events.on(S$1.created, async (e2) => { + const t2 = S$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); + }), this.events.on(S$1.deleted, async (e2) => { + const t2 = S$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); }); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } async restartToComplete() { - this.restartInProgress && await new Promise((e) => { + this.restartInProgress && await new Promise((e2) => { const t2 = setInterval(() => { - this.restartInProgress || (clearInterval(t2), e()); + this.restartInProgress || (clearInterval(t2), e2()); }, this.pollingInterval); }); } -} -var Pr = Object.defineProperty, Ut = Object.getOwnPropertySymbols, xr = Object.prototype.hasOwnProperty, Or = Object.prototype.propertyIsEnumerable, Lt = (n3, e, t2) => e in n3 ? Pr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, Ar = (n3, e) => { - for (var t2 in e || (e = {})) - xr.call(e, t2) && Lt(n3, t2, e[t2]); - if (Ut) - for (var t2 of Ut(e)) - Or.call(e, t2) && Lt(n3, t2, e[t2]); - return n3; }; -class $t extends g$4 { - constructor(e) { - super(e), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = ut, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.request = async (t2) => { +var xr$1 = Object.defineProperty, $t$1 = Object.getOwnPropertySymbols, Or$1 = Object.prototype.hasOwnProperty, Ar = Object.prototype.propertyIsEnumerable, Ft$1 = (n4, e2, t2) => e2 in n4 ? xr$1(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, zr$1 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Or$1.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + if ($t$1) + for (var t2 of $t$1(e2)) + Ar.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + return n4; +}; +let kt$1 = class kt extends g$1 { + constructor(e2) { + super(e2), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = dt, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled", "interrupted"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.heartBeatTimeout = cjs$3.toMiliseconds(cjs$3.THIRTY_SECONDS + cjs$3.ONE_SECOND), this.request = async (t2) => { + var i2, s2; this.logger.debug("Publishing Request Payload"); - const i2 = t2.id; + const r3 = t2.id || getBigIntRpcId().toString(); + await this.toEstablishConnection(); try { - await this.toEstablishConnection(); - const s2 = this.provider.request(t2); - return this.requestsInFlight.set(i2, { promise: s2, request: t2 }), await s2; - } catch (s2) { - throw this.logger.debug("Failed to Publish Request"), this.logger.error(s2), s2; + const o2 = this.provider.request(t2); + this.requestsInFlight.set(r3, { promise: o2, request: t2 }), this.logger.trace({ id: r3, method: t2.method, topic: (i2 = t2.params) == null ? void 0 : i2.topic }, "relayer.request - attempt to publish..."); + const a3 = await new Promise(async (h4, l2) => { + const d5 = () => { + l2(new Error(`relayer.request - publish interrupted, id: ${r3}`)); + }; + this.provider.on(f$1.disconnect, d5); + const g3 = await o2; + this.provider.off(f$1.disconnect, d5), h4(g3); + }); + return this.logger.trace({ id: r3, method: t2.method, topic: (s2 = t2.params) == null ? void 0 : s2.topic }, "relayer.request - published"), a3; + } catch (o2) { + throw this.logger.debug(`Failed to Publish Request: ${r3}`), o2; } finally { - this.requestsInFlight.delete(i2); + this.requestsInFlight.delete(r3); } + }, this.resetPingTimeout = () => { + if (pi()) + try { + clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => { + var t2, i2, s2; + (s2 = (i2 = (t2 = this.provider) == null ? void 0 : t2.connection) == null ? void 0 : i2.socket) == null || s2.terminate(); + }, this.heartBeatTimeout); + } catch (t2) { + this.logger.warn(t2); + } }, this.onPayloadHandler = (t2) => { - this.onProviderPayload(t2); + this.onProviderPayload(t2), this.resetPingTimeout(); }, this.onConnectHandler = () => { - this.events.emit(D$1.connect); + this.startPingTimeout(), this.events.emit(v2.connect); }, this.onDisconnectHandler = () => { this.onProviderDisconnect(); }, this.onProviderErrorHandler = (t2) => { - this.logger.error(t2), this.events.emit(D$1.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); + this.logger.error(t2), this.events.emit(v2.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); }, this.registerProviderListeners = () => { - this.provider.on(P$1.payload, this.onPayloadHandler), this.provider.on(P$1.connect, this.onConnectHandler), this.provider.on(P$1.disconnect, this.onDisconnectHandler), this.provider.on(P$1.error, this.onProviderErrorHandler); - }, this.core = e.core, this.logger = typeof e.logger < "u" && typeof e.logger != "string" ? cjs$3.generateChildLogger(e.logger, this.name) : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: e.logger || ct })), this.messages = new Ot(this.logger, e.core), this.subscriber = new Nt(this, this.logger), this.publisher = new vr(this, this.logger), this.relayUrl = (e == null ? void 0 : e.relayUrl) || ge$1, this.projectId = e.projectId, this.bundleId = Jn(), this.provider = {}; + this.provider.on(f$1.payload, this.onPayloadHandler), this.provider.on(f$1.connect, this.onConnectHandler), this.provider.on(f$1.disconnect, this.onDisconnectHandler), this.provider.on(f$1.error, this.onProviderErrorHandler); + }, this.core = e2.core, this.logger = typeof e2.logger < "u" && typeof e2.logger != "string" ? E$1(e2.logger, this.name) : nt$1(k$2({ level: e2.logger || ut })), this.messages = new zt(this.logger, e2.core), this.subscriber = new Ut$1(this, this.logger), this.publisher = new Ir(this, this.logger), this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me, this.projectId = e2.projectId, this.bundleId = Wo(), this.provider = {}; } async init() { this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); try { await this.transportOpen(); } catch { - this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$1}...`), await this.restartTransport(pe$1); + this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${be$1}...`), await this.restartTransport(be$1); } this.initialized = true, setTimeout(async () => { - this.subscriber.topics.length === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); - }, pt); + this.subscriber.topics.length === 0 && this.subscriber.pending.size === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); + }, yt); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get connected() { - return this.provider.connection.connected; + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 1; } get connecting() { - return this.provider.connection.connecting; + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 0; } - async publish(e, t2, i2) { - this.isInitialized(), await this.publisher.publish(e, t2, i2), await this.recordMessageEvent({ topic: e, message: t2, publishedAt: Date.now() }); + async publish(e2, t2, i2) { + this.isInitialized(), await this.publisher.publish(e2, t2, i2), await this.recordMessageEvent({ topic: e2, message: t2, publishedAt: Date.now() }); } - async subscribe(e, t2) { + async subscribe(e2, t2) { var i2; this.isInitialized(); - let s2 = ((i2 = this.subscriber.topicMap.get(e)) == null ? void 0 : i2[0]) || ""; - if (s2) - return s2; - let r2; + let s2 = ((i2 = this.subscriber.topicMap.get(e2)) == null ? void 0 : i2[0]) || "", r3; const o2 = (a3) => { - a3.topic === e && (this.subscriber.off(w$1.created, o2), r2()); + a3.topic === e2 && (this.subscriber.off(S$1.created, o2), r3()); }; return await Promise.all([new Promise((a3) => { - r2 = a3, this.subscriber.on(w$1.created, o2); + r3 = a3, this.subscriber.on(S$1.created, o2); }), new Promise(async (a3) => { - s2 = await this.subscriber.subscribe(e, t2), a3(); + s2 = await this.subscriber.subscribe(e2, t2) || s2, a3(); })]), s2; } - async unsubscribe(e, t2) { - this.isInitialized(), await this.subscriber.unsubscribe(e, t2); + async unsubscribe(e2, t2) { + this.isInitialized(), await this.subscriber.unsubscribe(e2, t2); } - on(e, t2) { - this.events.on(e, t2); + on(e2, t2) { + this.events.on(e2, t2); } - once(e, t2) { - this.events.once(e, t2); + once(e2, t2) { + this.events.once(e2, t2); } - off(e, t2) { - this.events.off(e, t2); + off(e2, t2) { + this.events.off(e2, t2); } - removeListener(e, t2) { - this.events.removeListener(e, t2); + removeListener(e2, t2) { + this.events.removeListener(e2, t2); } - async transportClose() { - this.requestsInFlight.size > 0 && (this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."), this.requestsInFlight.forEach(async (e) => { - await e.promise; - })), this.transportExplicitlyClosed = true, this.hasExperiencedNetworkDisruption && this.connected ? await ut$1(this.provider.disconnect(), 1e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.connected && await this.provider.disconnect(); - } - async transportOpen(e) { - if (this.transportExplicitlyClosed = false, await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress) { - e && e !== this.relayUrl && (this.relayUrl = e, await this.transportClose(), await this.createProvider()), this.connectionAttemptInProgress = true; + async transportDisconnect() { + if (!this.hasExperiencedNetworkDisruption && this.connected && this.requestsInFlight.size > 0) try { - await Promise.all([new Promise((t2) => { - if (!this.initialized) - return t2(); - this.subscriber.once(w$1.resubscribed, () => { - t2(); - }); - }), new Promise(async (t2, i2) => { - try { - await ut$1(this.provider.connect(), 1e4, `Socket stalled when trying to connect to ${this.relayUrl}`); - } catch (s2) { - i2(s2); - return; - } - t2(); - })]); - } catch (t2) { - this.logger.error(t2); - const i2 = t2; - if (!this.isConnectionStalled(i2.message)) - throw t2; - this.provider.events.emit(P$1.disconnect); - } finally { - this.connectionAttemptInProgress = false, this.hasExperiencedNetworkDisruption = false; + await Promise.all(Array.from(this.requestsInFlight.values()).map((e2) => e2.promise)); + } catch (e2) { + this.logger.warn(e2); } + this.hasExperiencedNetworkDisruption || this.connected ? await u0(this.provider.disconnect(), 2e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.onProviderDisconnect(); + } + async transportClose() { + this.transportExplicitlyClosed = true, await this.transportDisconnect(); + } + async transportOpen(e2) { + await this.confirmOnlineStateOrThrow(), e2 && e2 !== this.relayUrl && (this.relayUrl = e2, await this.transportDisconnect(), await this.createProvider()), this.connectionAttemptInProgress = true, this.transportExplicitlyClosed = false; + try { + await new Promise(async (t2, i2) => { + const s2 = () => { + this.provider.off(f$1.disconnect, s2), i2(new Error("Connection interrupted while trying to subscribe")); + }; + this.provider.on(f$1.disconnect, s2), await u0(this.provider.connect(), cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), `Socket stalled when trying to connect to ${this.relayUrl}`).catch((r3) => { + i2(r3); + }), await this.subscriber.start(), this.hasExperiencedNetworkDisruption = false, t2(); + }); + } catch (t2) { + this.logger.error(t2); + const i2 = t2; + if (!this.isConnectionStalled(i2.message)) + throw t2; + } finally { + this.connectionAttemptInProgress = false; } } - async restartTransport(e) { - await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress && (this.relayUrl = e || this.relayUrl, await this.transportClose(), await this.createProvider(), await this.transportOpen()); + async restartTransport(e2) { + this.connectionAttemptInProgress || (this.relayUrl = e2 || this.relayUrl, await this.confirmOnlineStateOrThrow(), await this.transportClose(), await this.createProvider(), await this.transportOpen()); } async confirmOnlineStateOrThrow() { - if (!await rr$1()) + if (!await hh()) throw new Error("No internet connection detected. Please restart your network and try again."); } - isConnectionStalled(e) { - return this.staleConnectionErrors.some((t2) => e.includes(t2)); + startPingTimeout() { + var e2, t2, i2, s2, r3; + if (pi()) + try { + (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) != null && t2.socket && ((r3 = (s2 = (i2 = this.provider) == null ? void 0 : i2.connection) == null ? void 0 : s2.socket) == null || r3.once("ping", () => { + this.resetPingTimeout(); + })), this.resetPingTimeout(); + } catch (o2) { + this.logger.warn(o2); + } + } + isConnectionStalled(e2) { + return this.staleConnectionErrors.some((t2) => e2.includes(t2)); } async createProvider() { this.provider.connection && this.unregisterProviderListeners(); - const e = await this.core.crypto.signJWT(this.relayUrl); - this.provider = new JsonRpcProvider(new f(Xn({ sdkVersion: gt, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); + const e2 = await this.core.crypto.signJWT(this.relayUrl); + this.provider = new JsonRpcProvider(new f$2($o({ sdkVersion: Dt$1, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e2, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); } - async recordMessageEvent(e) { - const { topic: t2, message: i2 } = e; + async recordMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; await this.messages.set(t2, i2); } - async shouldIgnoreMessageEvent(e) { - const { topic: t2, message: i2 } = e; + async shouldIgnoreMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; if (!i2 || i2.length === 0) return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; if (!await this.subscriber.isSubscribed(t2)) @@ -11067,86 +14601,76 @@ class $t extends g$4 { const s2 = this.messages.has(t2, i2); return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; } - async onProviderPayload(e) { - if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e }), isJsonRpcRequest(e)) { - if (!e.method.endsWith(lt)) + async onProviderPayload(e2) { + if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e2 }), isJsonRpcRequest(e2)) { + if (!e2.method.endsWith(gt)) return; - const t2 = e.params, { topic: i2, message: s2, publishedAt: r2 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r2 }; - this.logger.debug("Emitting Relayer Payload"), this.logger.trace(Ar({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e), await this.onMessageEvent(o2); + const t2 = e2.params, { topic: i2, message: s2, publishedAt: r3 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r3 }; + this.logger.debug("Emitting Relayer Payload"), this.logger.trace(zr$1({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e2), await this.onMessageEvent(o2); } else - isJsonRpcResponse(e) && this.events.emit(D$1.message_ack, e); + isJsonRpcResponse(e2) && this.events.emit(v2.message_ack, e2); } - async onMessageEvent(e) { - await this.shouldIgnoreMessageEvent(e) || (this.events.emit(D$1.message, e), await this.recordMessageEvent(e)); + async onMessageEvent(e2) { + await this.shouldIgnoreMessageEvent(e2) || (this.events.emit(v2.message, e2), await this.recordMessageEvent(e2)); } - async acknowledgePayload(e) { - const t2 = formatJsonRpcResult(e.id, true); + async acknowledgePayload(e2) { + const t2 = formatJsonRpcResult(e2.id, true); await this.provider.connection.send(t2); } unregisterProviderListeners() { - this.provider.off(P$1.payload, this.onPayloadHandler), this.provider.off(P$1.connect, this.onConnectHandler), this.provider.off(P$1.disconnect, this.onDisconnectHandler), this.provider.off(P$1.error, this.onProviderErrorHandler); + this.provider.off(f$1.payload, this.onPayloadHandler), this.provider.off(f$1.connect, this.onConnectHandler), this.provider.off(f$1.disconnect, this.onDisconnectHandler), this.provider.off(f$1.error, this.onProviderErrorHandler); } async registerEventListeners() { - this.events.on(D$1.connection_stalled, () => { - this.restartTransport().catch((t2) => this.logger.error(t2)); - }); - let e = await rr$1(); - or$1(async (t2) => { - this.initialized && e !== t2 && (e = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportClose().catch((i2) => this.logger.error(i2)))); + let e2 = await hh(); + ch(async (t2) => { + e2 !== t2 && (e2 = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportDisconnect(), this.transportExplicitlyClosed = false)); }); } - onProviderDisconnect() { - this.events.emit(D$1.disconnect), this.attemptToReconnect(); - } - attemptToReconnect() { - this.transportExplicitlyClosed || (this.logger.info("attemptToReconnect called. Connecting..."), setTimeout(async () => { - await this.restartTransport().catch((e) => this.logger.error(e)); - }, cjs$4.toMiliseconds(dt))); + async onProviderDisconnect() { + await this.subscriber.stop(), this.events.emit(v2.disconnect), this.connectionAttemptInProgress = false, !this.transportExplicitlyClosed && setTimeout(async () => { + await this.transportOpen().catch((e2) => this.logger.error(e2)); + }, cjs$3.toMiliseconds(pt)); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } async toEstablishConnection() { - if (await this.confirmOnlineStateOrThrow(), !this.connected) { - if (this.connectionAttemptInProgress) - return await new Promise((e) => { - const t2 = setInterval(() => { - this.connected && (clearInterval(t2), e()); - }, this.connectionStatusPollingInterval); - }); - await this.restartTransport(); - } - } -} -var zr = Object.defineProperty, Ft = Object.getOwnPropertySymbols, Nr = Object.prototype.hasOwnProperty, Ur = Object.prototype.propertyIsEnumerable, Mt = (n3, e, t2) => e in n3 ? zr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, kt = (n3, e) => { - for (var t2 in e || (e = {})) - Nr.call(e, t2) && Mt(n3, t2, e[t2]); - if (Ft) - for (var t2 of Ft(e)) - Ur.call(e, t2) && Mt(n3, t2, e[t2]); - return n3; -}; -class Kt extends p$2 { - constructor(e, t2, i2, s2 = O, r2 = void 0) { - super(e, t2, i2, s2), this.core = e, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = Dt, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { + await this.confirmOnlineStateOrThrow(), !this.connected && (this.connectionAttemptInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.connected && (clearInterval(t2), e2()); + }, this.connectionStatusPollingInterval); + }), await this.transportOpen()); + } +}; +var Nr = Object.defineProperty, Bt$1 = Object.getOwnPropertySymbols, Lr = Object.prototype.hasOwnProperty, Ur$1 = Object.prototype.propertyIsEnumerable, Mt = (n4, e2, t2) => e2 in n4 ? Nr(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Kt$1 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Lr.call(e2, t2) && Mt(n4, t2, e2[t2]); + if (Bt$1) + for (var t2 of Bt$1(e2)) + Ur$1.call(e2, t2) && Mt(n4, t2, e2[t2]); + return n4; +}; +class Vt extends p { + constructor(e2, t2, i2, s2 = z$1, r3 = void 0) { + super(e2, t2, i2, s2), this.core = e2, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = mt, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.recentlyDeleted = [], this.recentlyDeletedLimit = 200, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o2) => { - this.getKey && o2 !== null && !w$3(o2) ? this.map.set(this.getKey(o2), o2) : Lt$1(o2) ? this.map.set(o2.id, o2) : xt$1(o2) && this.map.set(o2.topic, o2); + this.getKey && o2 !== null && !Pe(o2) ? this.map.set(this.getKey(o2), o2) : Gu(o2) ? this.map.set(o2.id, o2) : Yu(o2) && this.map.set(o2.topic, o2); }), this.cached = [], this.initialized = true); }, this.set = async (o2, a3) => { this.isInitialized(), this.map.has(o2) ? await this.update(o2, a3) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o2, value: a3 }), this.map.set(o2, a3), await this.persist()); - }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a3) => Object.keys(o2).every((h4) => Gi(a3[h4], o2[h4]))) : this.values), this.update = async (o2, a3) => { + }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a3) => Object.keys(o2).every((h4) => Yi(a3[h4], o2[h4]))) : this.values), this.update = async (o2, a3) => { this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o2, update: a3 }); - const h4 = kt(kt({}, this.getData(o2)), a3); + const h4 = Kt$1(Kt$1({}, this.getData(o2)), a3); this.map.set(o2, h4), await this.persist(); }, this.delete = async (o2, a3) => { - this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a3 }), this.map.delete(o2), await this.persist()); - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.storagePrefix = s2, this.getKey = r2; + this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a3 }), this.map.delete(o2), this.addToRecentlyDeleted(o2), await this.persist()); + }, this.logger = E$1(t2, this.name), this.storagePrefix = s2, this.getKey = r3; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11160,16 +14684,23 @@ class Kt extends p$2 { get values() { return Array.from(this.map.values()); } - async setDataStore(e) { - await this.core.storage.setItem(this.storageKey, e); + addToRecentlyDeleted(e2) { + this.recentlyDeleted.push(e2), this.recentlyDeleted.length >= this.recentlyDeletedLimit && this.recentlyDeleted.splice(0, this.recentlyDeletedLimit / 2); + } + async setDataStore(e2) { + await this.core.storage.setItem(this.storageKey, e2); } async getDataStore() { return await this.core.storage.getItem(this.storageKey); } - getData(e) { - const t2 = this.map.get(e); + getData(e2) { + const t2 = this.map.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); + if (this.recentlyDeleted.includes(e2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e2}`); + throw this.logger.error(s2), new Error(s2); + } + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw this.logger.error(i2), new Error(i2); } return t2; @@ -11179,53 +14710,53 @@ class Kt extends p$2 { } async restore() { try { - const e = await this.getDataStore(); - if (typeof e > "u" || !e.length) + const e2 = await this.getDataStore(); + if (typeof e2 > "u" || !e2.length) return; if (this.map.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } - 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); + this.cached = e2, this.logger.debug(`Successfully Restored value for ${this.name}`), this.logger.trace({ type: "method", method: "restore", value: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore value for ${this.name}`), this.logger.error(e2); } } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } } -class Bt { - constructor(e, t2) { - this.core = e, this.logger = t2, this.name = Et, this.version = wt, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = O, this.ignoredPayloadTypes = [_$1], this.registeredMethods = [], this.init = async () => { +class qt { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.name = vt, this.version = It, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = z$1, this.ignoredPayloadTypes = [lr$1], this.registeredMethods = [], this.init = async () => { this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); }, this.register = ({ methods: i2 }) => { this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; - }, this.create = async () => { + }, this.create = async (i2) => { this.isInitialized(); - const i2 = Vn(), s2 = await this.core.crypto.setSymKey(i2), r2 = pt$1(cjs$4.FIVE_MINUTES), o2 = { protocol: ht }, a3 = { topic: s2, expiry: r2, relay: o2, active: false }, h4 = Rt$1({ protocol: this.core.protocol, version: this.core.version, topic: s2, symKey: i2, relay: o2, expiryTimestamp: r2 }); - return await this.pairings.set(s2, a3), await this.core.relayer.subscribe(s2), this.core.expirer.set(s2, r2), { topic: s2, uri: h4 }; + const s2 = gu(), r3 = await this.core.crypto.setSymKey(s2), o2 = d0(cjs$3.FIVE_MINUTES), a3 = { protocol: lt }, h4 = { topic: r3, expiry: o2, relay: a3, active: false }, l2 = Du({ protocol: this.core.protocol, version: this.core.version, topic: r3, symKey: s2, relay: a3, expiryTimestamp: o2, methods: i2 == null ? void 0 : i2.methods }); + return await this.pairings.set(r3, h4), await this.core.relayer.subscribe(r3), this.core.expirer.set(r3, o2), { topic: r3, uri: l2 }; }, this.pair = async (i2) => { this.isInitialized(), this.isValidPair(i2); - const { topic: s2, symKey: r2, relay: o2, expiryTimestamp: a3 } = Pt$1(i2.uri); - let h4; - if (this.pairings.keys.includes(s2) && (h4 = this.pairings.get(s2), h4.active)) + const { topic: s2, symKey: r3, relay: o2, expiryTimestamp: a3, methods: h4 } = Pu(i2.uri); + let l2; + if (this.pairings.keys.includes(s2) && (l2 = this.pairings.get(s2), l2.active)) throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); - const l2 = a3 || pt$1(cjs$4.FIVE_MINUTES), d3 = { topic: s2, relay: o2, expiry: l2, active: false }; - return await this.pairings.set(s2, d3), this.core.expirer.set(s2, l2), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V.create, d3), this.core.crypto.keychain.has(s2) || (await this.core.crypto.setSymKey(r2, s2), await this.core.relayer.subscribe(s2, { relay: o2 })), d3; + const d5 = a3 || d0(cjs$3.FIVE_MINUTES), g3 = { topic: s2, relay: o2, expiry: d5, active: false, methods: h4 }; + return await this.pairings.set(s2, g3), this.core.expirer.set(s2, d5), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V$1.create, g3), this.core.crypto.keychain.has(s2) || await this.core.crypto.setSymKey(r3, s2), await this.core.relayer.subscribe(s2, { relay: o2 }), g3; }, this.activate = async ({ topic: i2 }) => { this.isInitialized(); - const s2 = pt$1(cjs$4.THIRTY_DAYS); + const s2 = d0(cjs$3.THIRTY_DAYS); await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); }, this.ping = async (i2) => { this.isInitialized(), await this.isValidPing(i2); const { topic: s2 } = i2; if (this.pairings.keys.includes(s2)) { - const r2 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a3, reject: h4 } = at$1(); - this.events.once(yt$1("pairing_ping", r2), ({ error: l2 }) => { + const r3 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a3, reject: h4 } = a0(); + this.events.once(v0("pairing_ping", r3), ({ error: l2 }) => { l2 ? h4(l2) : a3(); }), await o2(); } @@ -11236,174 +14767,174 @@ class Bt { }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { this.isInitialized(), await this.isValidDisconnect(i2); const { topic: s2 } = i2; - this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", U$2("USER_DISCONNECTED")), await this.deletePairing(s2)); - }, this.sendRequest = async (i2, s2, r2) => { - const o2 = formatJsonRpcRequest(s2, r2), a3 = await this.core.crypto.encode(i2, o2), h4 = $[s2].req; + this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", tr$2("USER_DISCONNECTED")), await this.deletePairing(s2)); + }, this.sendRequest = async (i2, s2, r3) => { + const o2 = formatJsonRpcRequest(s2, r3), a3 = await this.core.crypto.encode(i2, o2), h4 = F$1[s2].req; return this.core.history.set(i2, o2), this.core.relayer.publish(i2, a3, h4), o2.id; - }, this.sendResult = async (i2, s2, r2) => { - const o2 = formatJsonRpcResult(i2, r2), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = $[h4.request.method].res; + }, this.sendResult = async (i2, s2, r3) => { + const o2 = formatJsonRpcResult(i2, r3), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = F$1[h4.request.method].res; await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); - }, this.sendError = async (i2, s2, r2) => { - const o2 = formatJsonRpcError(i2, r2), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = $[h4.request.method] ? $[h4.request.method].res : $.unregistered_method.res; + }, this.sendError = async (i2, s2, r3) => { + const o2 = formatJsonRpcError(i2, r3), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = F$1[h4.request.method] ? F$1[h4.request.method].res : F$1.unregistered_method.res; await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); }, this.deletePairing = async (i2, s2) => { - await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, U$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); + await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, tr$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); }, this.cleanup = async () => { - const i2 = this.pairings.getAll().filter((s2) => mt$1(s2.expiry)); + const i2 = this.pairings.getAll().filter((s2) => p0(s2.expiry)); await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); }, this.onRelayEventRequest = (i2) => { - const { topic: s2, payload: r2 } = i2; - switch (r2.method) { + const { topic: s2, payload: r3 } = i2; + switch (r3.method) { case "wc_pairingPing": - return this.onPairingPingRequest(s2, r2); + return this.onPairingPingRequest(s2, r3); case "wc_pairingDelete": - return this.onPairingDeleteRequest(s2, r2); + return this.onPairingDeleteRequest(s2, r3); default: - return this.onUnknownRpcMethodRequest(s2, r2); + return this.onUnknownRpcMethodRequest(s2, r3); } }, this.onRelayEventResponse = async (i2) => { - const { topic: s2, payload: r2 } = i2, o2 = (await this.core.history.get(s2, r2.id)).request.method; + const { topic: s2, payload: r3 } = i2, o2 = (await this.core.history.get(s2, r3.id)).request.method; switch (o2) { case "wc_pairingPing": - return this.onPairingPingResponse(s2, r2); + return this.onPairingPingResponse(s2, r3); default: return this.onUnknownRpcMethodResponse(o2); } }, this.onPairingPingRequest = async (i2, s2) => { - const { id: r2 } = s2; + const { id: r3 } = s2; try { - this.isValidPing({ topic: i2 }), await this.sendResult(r2, i2, true), this.events.emit(V.ping, { id: r2, topic: i2 }); + this.isValidPing({ topic: i2 }), await this.sendResult(r3, i2, true), this.events.emit(V$1.ping, { id: r3, topic: i2 }); } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); + await this.sendError(r3, i2, o2), this.logger.error(o2); } }, this.onPairingPingResponse = (i2, s2) => { - const { id: r2 } = s2; + const { id: r3 } = s2; setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("pairing_ping", r2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("pairing_ping", r2), { error: s2.error }); + isJsonRpcResult(s2) ? this.events.emit(v0("pairing_ping", r3), {}) : isJsonRpcError(s2) && this.events.emit(v0("pairing_ping", r3), { error: s2.error }); }, 500); }, this.onPairingDeleteRequest = async (i2, s2) => { - const { id: r2 } = s2; + const { id: r3 } = s2; try { - this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V.delete, { id: r2, topic: i2 }); + this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V$1.delete, { id: r3, topic: i2 }); } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); + await this.sendError(r3, i2, o2), this.logger.error(o2); } }, this.onUnknownRpcMethodRequest = async (i2, s2) => { - const { id: r2, method: o2 } = s2; + const { id: r3, method: o2 } = s2; try { if (this.registeredMethods.includes(o2)) return; - const a3 = U$2("WC_METHOD_UNSUPPORTED", o2); - await this.sendError(r2, i2, a3), this.logger.error(a3); + const a3 = tr$2("WC_METHOD_UNSUPPORTED", o2); + await this.sendError(r3, i2, a3), this.logger.error(a3); } catch (a3) { - await this.sendError(r2, i2, a3), this.logger.error(a3); + await this.sendError(r3, i2, a3), this.logger.error(a3); } }, this.onUnknownRpcMethodResponse = (i2) => { - this.registeredMethods.includes(i2) || this.logger.error(U$2("WC_METHOD_UNSUPPORTED", i2)); + this.registeredMethods.includes(i2) || this.logger.error(tr$2("WC_METHOD_UNSUPPORTED", i2)); }, this.isValidPair = (i2) => { var s2; - if (!Gt$1(i2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `pair() params: ${i2}`); + if (!$u(i2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `pair() params: ${i2}`); throw new Error(o2); } - if (!Kt$1(i2.uri)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); + if (!Ju(i2.uri)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); throw new Error(o2); } - const r2 = Pt$1(i2.uri); - if (!((s2 = r2 == null ? void 0 : r2.relay) != null && s2.protocol)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", "pair() uri#relay-protocol"); + const r3 = Pu(i2.uri); + if (!((s2 = r3 == null ? void 0 : r3.relay) != null && s2.protocol)) { + const { message: o2 } = xe("MISSING_OR_INVALID", "pair() uri#relay-protocol"); throw new Error(o2); } - if (!(r2 != null && r2.symKey)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", "pair() uri#symKey"); + if (!(r3 != null && r3.symKey)) { + const { message: o2 } = xe("MISSING_OR_INVALID", "pair() uri#symKey"); throw new Error(o2); } - if (r2 != null && r2.expiryTimestamp && cjs$4.toMiliseconds(r2 == null ? void 0 : r2.expiryTimestamp) < Date.now()) { - const { message: o2 } = N$1("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); + if (r3 != null && r3.expiryTimestamp && cjs$3.toMiliseconds(r3 == null ? void 0 : r3.expiryTimestamp) < Date.now()) { + const { message: o2 } = xe("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); throw new Error(o2); } }, this.isValidPing = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `ping() params: ${i2}`); - throw new Error(r2); + if (!$u(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `ping() params: ${i2}`); + throw new Error(r3); } const { topic: s2 } = i2; await this.isValidPairingTopic(s2); }, this.isValidDisconnect = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${i2}`); - throw new Error(r2); + if (!$u(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `disconnect() params: ${i2}`); + throw new Error(r3); } const { topic: s2 } = i2; await this.isValidPairingTopic(s2); }, this.isValidPairingTopic = async (i2) => { - if (!g$3(i2, false)) { - const { message: s2 } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); + if (!Gt$1(i2, false)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); throw new Error(s2); } if (!this.pairings.keys.includes(i2)) { - const { message: s2 } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); + const { message: s2 } = xe("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); throw new Error(s2); } - if (mt$1(this.pairings.get(i2).expiry)) { + if (p0(this.pairings.get(i2).expiry)) { await this.deletePairing(i2); - const { message: s2 } = N$1("EXPIRED", `pairing topic: ${i2}`); + const { message: s2 } = xe("EXPIRED", `pairing topic: ${i2}`); throw new Error(s2); } - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.pairings = new Kt(this.core, this.logger, this.name, this.storagePrefix); + }, this.core = e2, this.logger = E$1(t2, this.name), this.pairings = new Vt(this.core, this.logger, this.name, this.storagePrefix); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } registerRelayerEvents() { - this.core.relayer.on(D$1.message, async (e) => { - const { topic: t2, message: i2 } = e; + this.core.relayer.on(v2.message, async (e2) => { + const { topic: t2, message: i2 } = e2; if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) return; const s2 = await this.core.crypto.decode(t2, i2); try { isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); - } catch (r2) { - this.logger.error(r2); + } catch (r3) { + this.logger.error(r3); } }); } registerExpirerEvents() { - this.core.expirer.on(v2.expired, async (e) => { - const { topic: t2 } = ft$1(e.target); - t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V.expire, { topic: t2 })); + this.core.expirer.on(C.expired, async (e2) => { + const { topic: t2 } = l0(e2.target); + t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V$1.expire, { topic: t2 })); }); } } -class Vt extends h$2 { - constructor(e, t2) { - super(e, t2), this.core = e, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = vt, this.version = It, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { +let jt$1 = class jt extends h$1 { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = _t, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.set = (i2, s2, r2) => { - if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r2 }), this.records.has(s2.id)) + }, this.set = (i2, s2, r3) => { + if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r3 }), this.records.has(s2.id)) return; - const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r2, expiry: pt$1(cjs$4.THIRTY_DAYS) }; - this.records.set(o2.id, o2), this.events.emit(R$1.created, o2); + const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r3, expiry: d0(cjs$3.THIRTY_DAYS) }; + this.records.set(o2.id, o2), this.persist(), this.events.emit(I$1.created, o2); }, this.resolve = async (i2) => { if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) return; const s2 = await this.getRecord(i2.id); - typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.events.emit(R$1.updated, s2)); + typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.persist(), this.events.emit(I$1.updated, s2)); }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { - this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r2) => { - if (r2.topic === i2) { - if (typeof s2 < "u" && r2.id !== s2) + this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r3) => { + if (r3.topic === i2) { + if (typeof s2 < "u" && r3.id !== s2) return; - this.records.delete(r2.id), this.events.emit(R$1.deleted, r2); + this.records.delete(r3.id), this.events.emit(I$1.deleted, r3); } - }); + }), this.persist(); }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { this.events.on(i2, s2); }, this.once = (i2, s2) => { @@ -11412,10 +14943,10 @@ class Vt extends h$2 { this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11430,79 +14961,81 @@ class Vt extends h$2 { return Array.from(this.records.values()); } get pending() { - const e = []; + const e2 = []; return this.values.forEach((t2) => { if (typeof t2.response < "u") return; const i2 = { topic: t2.topic, request: formatJsonRpcRequest(t2.request.method, t2.request.params, t2.id), chainId: t2.chainId }; - return e.push(i2); - }), e; + return e2.push(i2); + }), e2; } - async setJsonRpcRecords(e) { - await this.core.storage.setItem(this.storageKey, e); + async setJsonRpcRecords(e2) { + await this.core.storage.setItem(this.storageKey, e2); } async getJsonRpcRecords() { return await this.core.storage.getItem(this.storageKey); } - getRecord(e) { + getRecord(e2) { this.isInitialized(); - const t2 = this.records.get(e); + const t2 = this.records.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw new Error(i2); } return t2; } async persist() { - await this.setJsonRpcRecords(this.values), this.events.emit(R$1.sync); + await this.setJsonRpcRecords(this.values), this.events.emit(I$1.sync); } async restore() { try { - const e = await this.getJsonRpcRecords(); - if (typeof e > "u" || !e.length) + const e2 = await this.getJsonRpcRecords(); + if (typeof e2 > "u" || !e2.length) return; if (this.records.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } - 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); + this.cached = e2, this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", records: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(e2); } } registerEventListeners() { - this.events.on(R$1.created, (e) => { - const t2 = R$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.events.on(R$1.updated, (e) => { - const t2 = R$1.updated; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.events.on(R$1.deleted, (e) => { - const t2 = R$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { + this.events.on(I$1.created, (e2) => { + const t2 = I$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.updated, (e2) => { + const t2 = I$1.updated; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.deleted, (e2) => { + const t2 = I$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { this.cleanup(); }); } cleanup() { try { - this.records.forEach((e) => { - cjs$4.toMiliseconds(e.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${e.id}`), this.delete(e.topic, e.id)); - }); - } catch (e) { - this.logger.warn(e); + this.isInitialized(); + let e2 = false; + this.records.forEach((t2) => { + cjs$3.toMiliseconds(t2.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${t2.id}`), this.records.delete(t2.id), this.events.emit(I$1.deleted, t2, false), e2 = true); + }), e2 && this.persist(); + } catch (e2) { + this.logger.warn(e2); } } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } -} -class qt extends E { - constructor(e, t2) { - super(e, t2), this.core = e, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = Rt, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { +}; +class Gt extends E { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Rt, this.version = Tt$1, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); }, this.has = (i2) => { try { @@ -11513,16 +15046,16 @@ class qt extends E { } }, this.set = (i2, s2) => { this.isInitialized(); - const r2 = this.formatTarget(i2), o2 = { target: r2, expiry: s2 }; - this.expirations.set(r2, o2), this.checkExpiry(r2, o2), this.events.emit(v2.created, { target: r2, expiration: o2 }); + const r3 = this.formatTarget(i2), o2 = { target: r3, expiry: s2 }; + this.expirations.set(r3, o2), this.checkExpiry(r3, o2), this.events.emit(C.created, { target: r3, expiration: o2 }); }, this.get = (i2) => { this.isInitialized(); const s2 = this.formatTarget(i2); return this.getExpiration(s2); }, this.del = (i2) => { if (this.isInitialized(), this.has(i2)) { - const s2 = this.formatTarget(i2), r2 = this.getExpiration(s2); - this.expirations.delete(s2), this.events.emit(v2.deleted, { target: s2, expiration: r2 }); + const s2 = this.formatTarget(i2), r3 = this.getExpiration(s2); + this.expirations.delete(s2), this.events.emit(C.deleted, { target: s2, expiration: r3 }); } }, this.on = (i2, s2) => { this.events.on(i2, s2); @@ -11532,10 +15065,10 @@ class qt extends E { this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11549,92 +15082,92 @@ class qt extends E { get values() { return Array.from(this.expirations.values()); } - formatTarget(e) { - if (typeof e == "string") - return lt$1(e); - if (typeof e == "number") - return dt$1(e); - const { message: t2 } = N$1("UNKNOWN_TYPE", `Target type: ${typeof e}`); + formatTarget(e2) { + if (typeof e2 == "string") + return h0(e2); + if (typeof e2 == "number") + return c0(e2); + const { message: t2 } = xe("UNKNOWN_TYPE", `Target type: ${typeof e2}`); throw new Error(t2); } - async setExpirations(e) { - await this.core.storage.setItem(this.storageKey, e); + async setExpirations(e2) { + await this.core.storage.setItem(this.storageKey, e2); } async getExpirations() { return await this.core.storage.getItem(this.storageKey); } async persist() { - await this.setExpirations(this.values), this.events.emit(v2.sync); + await this.setExpirations(this.values), this.events.emit(C.sync); } async restore() { try { - const e = await this.getExpirations(); - if (typeof e > "u" || !e.length) + const e2 = await this.getExpirations(); + if (typeof e2 > "u" || !e2.length) return; if (this.expirations.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } - 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); + this.cached = e2, this.logger.debug(`Successfully Restored expirations for ${this.name}`), this.logger.trace({ type: "method", method: "restore", expirations: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore expirations for ${this.name}`), this.logger.error(e2); } } - getExpiration(e) { - const t2 = this.expirations.get(e); + getExpiration(e2) { + const t2 = this.expirations.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw this.logger.error(i2), new Error(i2); + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.warn(i2), new Error(i2); } return t2; } - checkExpiry(e, t2) { + checkExpiry(e2, t2) { const { expiry: i2 } = t2; - cjs$4.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e, t2); + cjs$3.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e2, t2); } - expire(e, t2) { - this.expirations.delete(e), this.events.emit(v2.expired, { target: e, expiration: t2 }); + expire(e2, t2) { + this.expirations.delete(e2), this.events.emit(C.expired, { target: e2, expiration: t2 }); } checkExpirations() { - this.core.relayer.connected && this.expirations.forEach((e, t2) => this.checkExpiry(t2, e)); + this.core.relayer.connected && this.expirations.forEach((e2, t2) => this.checkExpiry(t2, e2)); } registerEventListeners() { - this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(v2.created, (e) => { - const t2 = v2.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }), this.events.on(v2.expired, (e) => { - const t2 = v2.expired; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }), this.events.on(v2.deleted, (e) => { - const t2 = v2.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); + this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(C.created, (e2) => { + const t2 = C.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C.expired, (e2) => { + const t2 = C.expired; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C.deleted, (e2) => { + const t2 = C.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); }); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } } -class jt extends y$1 { - constructor(e, t2) { - super(e, t2), this.projectId = e, this.logger = t2, this.name = Z, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { - if (this.verifyDisabled || $$1() || !D$2()) +let Yt$1 = class Yt extends y$1 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.name = ee, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { + if (this.verifyDisabled || er$1() || !pr$1()) return; const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; try { await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2); + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3); } if (!this.initialized) { - this.removeIframe(), this.verifyUrl = ee; + this.removeIframe(), this.verifyUrl = te; try { await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2), this.verifyDisabled = true; + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3), this.verifyDisabled = true; } } }, this.register = async (i2) => { @@ -11643,17 +15176,17 @@ class jt extends y$1 { if (this.isDevEnv) return ""; const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - let r2; + let r3; try { - r2 = await this.fetchAttestation(i2.attestationId, s2); + r3 = await this.fetchAttestation(i2.attestationId, s2); } catch (o2) { - this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r2 = await this.fetchAttestation(i2.attestationId, ee); + this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r3 = await this.fetchAttestation(i2.attestationId, te); } - return r2; + return r3; }, this.fetchAttestation = async (i2, s2) => { this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); - const r2 = this.startAbortTimer(cjs$4.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); - return clearTimeout(r2), o2.status === 200 ? await o2.json() : void 0; + const r3 = this.startAbortTimer(cjs$3.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); + return clearTimeout(r3), o2.status === 200 ? await o2.json() : void 0; }, this.addToQueue = (i2) => { this.queue.push(i2); }, this.processQueue = () => { @@ -11668,1197 +15201,1247 @@ class jt extends y$1 { } }, this.createIframe = async () => { let i2; - const s2 = (r2) => { - r2.data === "verify_ready" && (this.initialized = true, this.processQueue(), window.removeEventListener("message", s2), i2()); + const s2 = (r3) => { + r3.data === "verify_ready" && (this.onInit(), window.removeEventListener("message", s2), i2()); }; - await Promise.race([new Promise((r2) => { - if (document.getElementById(Z)) - return r2(); + await Promise.race([new Promise((r3) => { + const o2 = document.getElementById(ee); + if (o2) + return this.iframe = o2, this.onInit(), r3(); window.addEventListener("message", s2); - const o2 = document.createElement("iframe"); - o2.id = Z, o2.src = `${this.verifyUrl}/${this.projectId}`, o2.style.display = "none", document.body.append(o2), this.iframe = o2, i2 = r2; - }), new Promise((r2, o2) => setTimeout(() => { + const a3 = document.createElement("iframe"); + a3.id = ee, a3.src = `${this.verifyUrl}/${this.projectId}`, a3.style.display = "none", document.body.append(a3), this.iframe = a3, i2 = r3; + }), new Promise((r3, o2) => setTimeout(() => { window.removeEventListener("message", s2), o2("verify iframe load timeout"); - }, cjs$4.toMiliseconds(cjs$4.FIVE_SECONDS)))]); + }, cjs$3.toMiliseconds(cjs$3.FIVE_SECONDS)))]); + }, this.onInit = () => { + this.initialized = true, this.processQueue(); }, this.removeIframe = () => { this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); }, this.getVerifyUrl = (i2) => { - let s2 = i2 || F$1; - return _t.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${F$1}`), s2 = F$1), s2; - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.verifyUrl = F$1, this.abortController = new AbortController(), this.isDevEnv = te$1() && process.env.IS_VITEST; + let s2 = i2 || k$1; + return St.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${k$1}`), s2 = k$1), s2; + }, this.logger = E$1(t2, this.name), this.verifyUrl = k$1, this.abortController = new AbortController(), this.isDevEnv = pi() && process.env.IS_VITEST; } get context() { - return cjs$3.getLoggerContext(this.logger); - } - startAbortTimer(e) { - return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$4.toMiliseconds(e)); - } -} -class Gt extends v$1 { - constructor(e, t2) { - super(e, t2), this.projectId = e, this.logger = t2, this.context = Tt, this.registerDeviceToken = async (i2) => { - const { clientId: s2, token: r2, notificationType: o2, enableEncrypted: a3 = false } = i2, h4 = `${St}/${this.projectId}/clients`; - await Yi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r2, always_raw: a3 }) }); - }, this.logger = cjs$3.generateChildLogger(t2, this.context); - } -} -var Lr = Object.defineProperty, Yt = Object.getOwnPropertySymbols, $r = Object.prototype.hasOwnProperty, Fr = Object.prototype.propertyIsEnumerable, Ht = (n3, e, t2) => e in n3 ? Lr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, Jt = (n3, e) => { - for (var t2 in e || (e = {})) - $r.call(e, t2) && Ht(n3, t2, e[t2]); - if (Yt) - for (var t2 of Yt(e)) - Fr.call(e, t2) && Ht(n3, t2, e[t2]); - return n3; -}; -class te extends n$1 { - constructor(e) { - super(e), this.protocol = le$1, this.version = We, this.name = Q$1, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (i2, s2) => this.events.on(i2, s2), this.once = (i2, s2) => this.events.once(i2, s2), this.off = (i2, s2) => this.events.off(i2, s2), this.removeListener = (i2, s2) => this.events.removeListener(i2, s2), this.projectId = e == null ? void 0 : e.projectId, this.relayUrl = (e == null ? void 0 : e.relayUrl) || ge$1, this.customStoragePrefix = e != null && e.customStoragePrefix ? `:${e.customStoragePrefix}` : ""; - const t2 = typeof (e == null ? void 0 : e.logger) < "u" && typeof (e == null ? void 0 : e.logger) != "string" ? e.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (e == null ? void 0 : e.logger) || Qe.logger })); - this.logger = cjs$3.generateChildLogger(t2, this.name), this.heartbeat = new cjs$5.HeartBeat(), this.crypto = new xt(this, this.logger, e == null ? void 0 : e.keychain), this.history = new Vt(this, this.logger), this.expirer = new qt(this, this.logger), this.storage = e != null && e.storage ? e.storage : new h$3(Jt(Jt({}, Ze), e == null ? void 0 : e.storageOptions)), this.relayer = new $t({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new Bt(this, this.logger), this.verify = new jt(this.projectId || "", this.logger), this.echoClient = new Gt(this.projectId || "", this.logger); - } - static async init(e) { - const t2 = new te(e); + return y$2(this.logger); + } + startAbortTimer(e2) { + return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$3.toMiliseconds(e2)); + } +}; +let Ht$2 = class Ht extends v$1 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.context = Pt, this.registerDeviceToken = async (i2) => { + const { clientId: s2, token: r3, notificationType: o2, enableEncrypted: a3 = false } = i2, h4 = `${xt}/${this.projectId}/clients`; + await Hi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r3, always_raw: a3 }) }); + }, this.logger = E$1(t2, this.context); + } +}; +var $r = Object.defineProperty, Jt$2 = Object.getOwnPropertySymbols, Fr$1 = Object.prototype.hasOwnProperty, kr$1 = Object.prototype.propertyIsEnumerable, Xt$2 = (n4, e2, t2) => e2 in n4 ? $r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Wt$2 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Fr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + if (Jt$2) + for (var t2 of Jt$2(e2)) + kr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + return n4; +}; +let ie$2 = class ie extends n$2 { + constructor(e2) { + var t2; + super(e2), this.protocol = De, this.version = Ze$1, this.name = Z, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (o2, a3) => this.events.on(o2, a3), this.once = (o2, a3) => this.events.once(o2, a3), this.off = (o2, a3) => this.events.off(o2, a3), this.removeListener = (o2, a3) => this.events.removeListener(o2, a3), this.projectId = e2 == null ? void 0 : e2.projectId, this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me, this.customStoragePrefix = e2 != null && e2.customStoragePrefix ? `:${e2.customStoragePrefix}` : ""; + const i2 = k$2({ level: typeof (e2 == null ? void 0 : e2.logger) == "string" && e2.logger ? e2.logger : et.logger }), { logger: s2, chunkLoggerController: r3 } = A$2({ opts: i2, maxSizeInBytes: e2 == null ? void 0 : e2.maxLogBlobSizeInBytes, loggerOverride: e2 == null ? void 0 : e2.logger }); + this.logChunkController = r3, (t2 = this.logChunkController) != null && t2.downloadLogsBlobInBrowser && (window.downloadLogsBlobInBrowser = async () => { + var o2, a3; + (o2 = this.logChunkController) != null && o2.downloadLogsBlobInBrowser && ((a3 = this.logChunkController) == null || a3.downloadLogsBlobInBrowser({ clientId: await this.crypto.getClientId() })); + }), this.logger = E$1(s2, this.name), this.heartbeat = new cjs$4.HeartBeat(), this.crypto = new At(this, this.logger, e2 == null ? void 0 : e2.keychain), this.history = new jt$1(this, this.logger), this.expirer = new Gt(this, this.logger), this.storage = e2 != null && e2.storage ? e2.storage : new h$2(Wt$2(Wt$2({}, tt), e2 == null ? void 0 : e2.storageOptions)), this.relayer = new kt$1({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new qt(this, this.logger), this.verify = new Yt$1(this.projectId || "", this.logger), this.echoClient = new Ht$2(this.projectId || "", this.logger); + } + static async init(e2) { + const t2 = new ie(e2); await t2.initialize(); const i2 = await t2.crypto.getClientId(); - return await t2.storage.setItem(yt, i2), t2; + return await t2.storage.setItem(bt, i2), t2; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } async start() { this.initialized || await this.initialize(); } + async getLogsBlob() { + var e2; + return (e2 = this.logChunkController) == null ? void 0 : e2.logsToBlob({ clientId: await this.crypto.getClientId() }); + } 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.initialized = true, 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; - } - } -} -const Mr = te; -const J = "wc", F = 2, X = "client", G = `${J}@${F}:${X}:`, M = { name: X, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, H = "WALLETCONNECT_DEEPLINK_CHOICE", oe = "proposal", ae = "Proposal expired", ce = "session", L = cjs$4.SEVEN_DAYS, le = "engine", R = { wc_sessionPropose: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1114 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1115 } } }, U$1 = { min: cjs$4.FIVE_MINUTES, max: cjs$4.SEVEN_DAYS }, I = { idle: "IDLE", active: "ACTIVE" }, pe = "request", he = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"]; -var as = Object.defineProperty, cs = Object.defineProperties, ls = Object.getOwnPropertyDescriptors, de = Object.getOwnPropertySymbols, ps = Object.prototype.hasOwnProperty, hs = Object.prototype.propertyIsEnumerable, ue = (w3, r2, e) => r2 in w3 ? as(w3, r2, { enumerable: true, configurable: true, writable: true, value: e }) : w3[r2] = e, g$1 = (w3, r2) => { - for (var e in r2 || (r2 = {})) - ps.call(r2, e) && ue(w3, e, r2[e]); - if (de) - for (var e of de(r2)) - hs.call(r2, e) && ue(w3, e, r2[e]); - return w3; -}, D = (w3, r2) => cs(w3, ls(r2)); -class ds extends w$4 { - constructor(r2) { - super(r2), this.name = le, this.events = new EventEmitter$1(), this.initialized = false, this.ignoredPayloadTypes = [_$1], this.requestQueue = { state: I.idle, queue: [] }, this.sessionRequestQueue = { state: I.idle, queue: [] }, this.requestQueueDelay = cjs$4.ONE_SECOND, this.init = async () => { - this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(R) }), this.initialized = true, setTimeout(() => { + } catch (e2) { + throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`, e2), this.logger.error(e2.message), e2; + } + } +}; +const Br = ie$2; +const Se = "wc", Ee = 2, _e = "client", se$1 = `${Se}@${Ee}:${_e}:`, ie$1 = { name: _e, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, Re$1 = "WALLETCONNECT_DEEPLINK_CHOICE", Ke = "proposal", Ue = "Proposal expired", Ge = "session", L$2 = cjs$3.SEVEN_DAYS, ke = "engine", q$1 = { wc_sessionPropose: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1114 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1115 } }, wc_sessionAuthenticate: { req: { ttl: cjs$3.ONE_HOUR, prompt: true, tag: 1116 }, res: { ttl: cjs$3.ONE_HOUR, prompt: false, tag: 1117 } } }, re$1 = { min: cjs$3.FIVE_MINUTES, max: cjs$3.SEVEN_DAYS }, A$1 = { idle: "IDLE", active: "ACTIVE" }, Fe = "request", je = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"], Qe = "wc", ze = "auth", He = "authKeys", Ye = "pairingTopics", Xe$1 = "requests", X = `${Qe}@${1.5}:${ze}:`, J = `${X}:PUB_KEY`; +var Ht$1 = Object.defineProperty, Yt2 = Object.defineProperties, Xt$1 = Object.getOwnPropertyDescriptors, Je = Object.getOwnPropertySymbols, Jt$1 = Object.prototype.hasOwnProperty, Bt = Object.prototype.propertyIsEnumerable, Be$1 = (S2, n4, t2) => n4 in S2 ? Ht$1(S2, n4, { enumerable: true, configurable: true, writable: true, value: t2 }) : S2[n4] = t2, m2 = (S2, n4) => { + for (var t2 in n4 || (n4 = {})) + Jt$1.call(n4, t2) && Be$1(S2, t2, n4[t2]); + if (Je) + for (var t2 of Je(n4)) + Bt.call(n4, t2) && Be$1(S2, t2, n4[t2]); + return S2; +}, F = (S2, n4) => Yt2(S2, Xt$1(n4)); +let Wt$1 = class Wt extends w$2 { + constructor(n4) { + super(n4), this.name = ke, this.events = new EventEmitter$1(), this.initialized = false, this.requestQueue = { state: A$1.idle, queue: [] }, this.sessionRequestQueue = { state: A$1.idle, queue: [] }, this.requestQueueDelay = cjs$3.ONE_SECOND, this.expectedPairingMethodMap = /* @__PURE__ */ new Map(), this.recentlyDeletedMap = /* @__PURE__ */ new Map(), this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(q$1) }), this.initialized = true, setTimeout(() => { this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay))); - }, this.connect = async (e) => { + }, cjs$3.toMiliseconds(this.requestQueueDelay))); + }, this.connect = async (t2) => { + await this.isInitialized(); + const e2 = F(m2({}, t2), { requiredNamespaces: t2.requiredNamespaces || {}, optionalNamespaces: t2.optionalNamespaces || {} }); + await this.isValidConnect(e2); + const { pairingTopic: s2, requiredNamespaces: i2, optionalNamespaces: r3, sessionProperties: o2, relays: a3 } = e2; + let c2 = s2, d5, p2 = false; + try { + c2 && (p2 = this.client.core.pairing.pairings.get(c2).active); + } catch (f3) { + throw this.client.logger.error(`connect() -> pairing.get(${c2}) failed`), f3; + } + if (!c2 || !p2) { + const { topic: f3, uri: v3 } = await this.client.core.pairing.create(); + c2 = f3, d5 = v3; + } + if (!c2) { + const { message: f3 } = xe("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); + throw new Error(f3); + } + const g3 = await this.client.core.crypto.generateKeyPair(), h4 = q$1.wc_sessionPropose.req.ttl || cjs$3.FIVE_MINUTES, y3 = d0(h4), w3 = m2({ requiredNamespaces: i2, optionalNamespaces: r3, relays: a3 ?? [{ protocol: lt }], proposer: { publicKey: g3, metadata: this.client.metadata }, expiryTimestamp: y3 }, o2 && { sessionProperties: o2 }), { reject: I2, resolve: D2, done: E2 } = a0(h4, Ue); + this.events.once(v0("session_connect"), async ({ error: f3, session: v3 }) => { + if (f3) + I2(f3); + else if (v3) { + v3.self.publicKey = g3; + const j2 = F(m2({}, v3), { requiredNamespaces: w3.requiredNamespaces, optionalNamespaces: w3.optionalNamespaces }); + await this.client.session.set(v3.topic, j2), await this.setExpiry(v3.topic, v3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: v3.peer.metadata }), D2(j2); + } + }); + const P2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: w3, throwOnFailedPublish: true }); + return await this.setProposal(P2, m2({ id: P2 }, w3)), { uri: d5, approval: E2 }; + }, this.pair = async (t2) => { + await this.isInitialized(); + try { + return await this.client.core.pairing.pair(t2); + } catch (e2) { + throw this.client.logger.error("pair() failed"), e2; + } + }, this.approve = async (t2) => { + await this.isInitialized(); + try { + await this.isValidApprove(t2); + } catch (E2) { + throw this.client.logger.error("approve() -> isValidApprove() failed"), E2; + } + const { id: e2, relayProtocol: s2, namespaces: i2, sessionProperties: r3, sessionConfig: o2 } = t2; + let a3; + try { + a3 = this.client.proposal.get(e2); + } catch (E2) { + throw this.client.logger.error(`approve() -> proposal.get(${e2}) failed`), E2; + } + let { pairingTopic: c2, proposer: d5, requiredNamespaces: p2, optionalNamespaces: g3 } = a3; + c2 = c2 || ""; + const h4 = await this.client.core.crypto.generateKeyPair(), y3 = d5.publicKey, w3 = await this.client.core.crypto.generateSharedKey(h4, y3), I2 = m2(m2({ relay: { protocol: s2 ?? "irn" }, namespaces: i2, pairingTopic: c2, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: d0(L$2) }, r3 && { sessionProperties: r3 }), o2 && { sessionConfig: o2 }); + await this.client.core.relayer.subscribe(w3); + const D2 = F(m2({}, I2), { topic: w3, requiredNamespaces: p2, optionalNamespaces: g3, pairingTopic: c2, acknowledged: false, self: I2.controller, peer: { publicKey: d5.publicKey, metadata: d5.metadata }, controller: h4 }); + await this.client.session.set(w3, D2); + try { + await this.sendResult({ id: e2, topic: c2, result: { relay: { protocol: s2 ?? "irn" }, responderPublicKey: h4 }, throwOnFailedPublish: true }), await this.sendRequest({ topic: w3, method: "wc_sessionSettle", params: I2, throwOnFailedPublish: true }); + } catch (E2) { + throw this.client.logger.error(E2), this.client.session.delete(w3, tr$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(w3), E2; + } + return await this.client.core.pairing.updateMetadata({ topic: c2, metadata: d5.metadata }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: c2 }), await this.setExpiry(w3, d0(L$2)), { topic: w3, acknowledged: () => new Promise((E2) => setTimeout(() => E2(this.client.session.get(w3)), 500)) }; + }, this.reject = async (t2) => { + await this.isInitialized(); + try { + await this.isValidReject(t2); + } catch (r3) { + throw this.client.logger.error("reject() -> isValidReject() failed"), r3; + } + const { id: e2, reason: s2 } = t2; + let i2; + try { + i2 = this.client.proposal.get(e2).pairingTopic; + } catch (r3) { + throw this.client.logger.error(`reject() -> proposal.get(${e2}) failed`), r3; + } + i2 && (await this.sendError({ id: e2, topic: i2, error: s2 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED"))); + }, this.update = async (t2) => { + await this.isInitialized(); + try { + await this.isValidUpdate(t2); + } catch (p2) { + throw this.client.logger.error("update() -> isValidUpdate() failed"), p2; + } + const { topic: e2, namespaces: s2 } = t2, { done: i2, resolve: r3, reject: o2 } = a0(), a3 = payloadId(), c2 = getBigIntRpcId().toString(), d5 = this.client.session.get(e2).namespaces; + return this.events.once(v0("session_update", a3), ({ error: p2 }) => { + p2 ? o2(p2) : r3(); + }), await this.client.session.update(e2, { namespaces: s2 }), this.sendRequest({ topic: e2, method: "wc_sessionUpdate", params: { namespaces: s2 }, throwOnFailedPublish: true, clientRpcId: a3, relayRpcId: c2 }).catch((p2) => { + this.client.logger.error(p2), this.client.session.update(e2, { namespaces: d5 }), o2(p2); + }), { acknowledged: i2 }; + }, this.extend = async (t2) => { + await this.isInitialized(); + try { + await this.isValidExtend(t2); + } catch (a3) { + throw this.client.logger.error("extend() -> isValidExtend() failed"), a3; + } + const { topic: e2 } = t2, s2 = payloadId(), { done: i2, resolve: r3, reject: o2 } = a0(); + return this.events.once(v0("session_extend", s2), ({ error: a3 }) => { + a3 ? o2(a3) : r3(); + }), await this.setExpiry(e2, d0(L$2)), this.sendRequest({ topic: e2, method: "wc_sessionExtend", params: {}, clientRpcId: s2, throwOnFailedPublish: true }).catch((a3) => { + o2(a3); + }), { acknowledged: i2 }; + }, this.request = async (t2) => { + await this.isInitialized(); + try { + await this.isValidRequest(t2); + } catch (h4) { + throw this.client.logger.error("request() -> isValidRequest() failed"), h4; + } + const { chainId: e2, request: s2, topic: i2, expiry: r3 = q$1.wc_sessionRequest.req.ttl } = t2, o2 = this.client.session.get(i2), a3 = payloadId(), c2 = getBigIntRpcId().toString(), { done: d5, resolve: p2, reject: g3 } = a0(r3, "Request expired. Please try again."); + return this.events.once(v0("session_request", a3), ({ error: h4, result: y3 }) => { + h4 ? g3(h4) : p2(y3); + }), await Promise.all([new Promise(async (h4) => { + await this.sendRequest({ clientRpcId: a3, relayRpcId: c2, topic: i2, method: "wc_sessionRequest", params: { request: F(m2({}, s2), { expiryTimestamp: d0(r3) }), chainId: e2 }, expiry: r3, throwOnFailedPublish: true }).catch((y3) => g3(y3)), this.client.events.emit("session_request_sent", { topic: i2, request: s2, chainId: e2, id: a3 }), h4(); + }), new Promise(async (h4) => { + var y3; + if (!((y3 = o2.sessionConfig) != null && y3.disableDeepLink)) { + const w3 = await g0(this.client.core.storage, Re$1); + m0({ id: a3, topic: i2, wcDeepLink: w3 }); + } + h4(); + }), d5()]).then((h4) => h4[2]); + }, this.respond = async (t2) => { + await this.isInitialized(), await this.isValidRespond(t2); + const { topic: e2, response: s2 } = t2, { id: i2 } = s2; + isJsonRpcResult(s2) ? await this.sendResult({ id: i2, topic: e2, result: s2.result, throwOnFailedPublish: true }) : isJsonRpcError(s2) && await this.sendError({ id: i2, topic: e2, error: s2.error }), this.cleanupAfterResponse(t2); + }, this.ping = async (t2) => { await this.isInitialized(); - const s2 = D(g$1({}, e), { requiredNamespaces: e.requiredNamespaces || {}, optionalNamespaces: e.optionalNamespaces || {} }); - await this.isValidConnect(s2); - const { pairingTopic: t2, requiredNamespaces: i2, optionalNamespaces: n3, sessionProperties: o2, relays: a3 } = s2; - let c2 = t2, p3, d3 = false; - if (c2 && (d3 = this.client.core.pairing.pairings.get(c2).active), !c2 || !d3) { - const { topic: T2, uri: _3 } = await this.client.core.pairing.create(); - c2 = T2, p3 = _3; - } - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = R.wc_sessionPropose.req.ttl || cjs$4.FIVE_MINUTES, m2 = pt$1(N2), f2 = g$1({ requiredNamespaces: i2, optionalNamespaces: n3, relays: a3 ?? [{ protocol: ht }], proposer: { publicKey: h4, metadata: this.client.metadata }, expiryTimestamp: m2 }, o2 && { sessionProperties: o2 }), { reject: k2, resolve: O2, done: we } = at$1(N2, ae); - if (this.events.once(yt$1("session_connect"), async ({ error: T2, session: _3 }) => { - if (T2) - k2(T2); - else if (_3) { - _3.self.publicKey = h4; - const B2 = D(g$1({}, _3), { requiredNamespaces: f2.requiredNamespaces, optionalNamespaces: f2.optionalNamespaces }); - await this.client.session.set(_3.topic, B2), await this.setExpiry(_3.topic, _3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: _3.peer.metadata }), O2(B2); - } - }), !c2) { - const { message: T2 } = N$1("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); - throw new Error(T2); - } - const W2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: f2, throwOnFailedPublish: true }); - return await this.setProposal(W2, g$1({ id: W2 }, f2)), { uri: p3, approval: we }; - }, this.pair = async (e) => (await this.isInitialized(), await this.client.core.pairing.pair(e)), this.approve = async (e) => { - await this.isInitialized(), await this.isValidApprove(e); - const { id: s2, relayProtocol: t2, namespaces: i2, sessionProperties: n3 } = e, o2 = this.client.proposal.get(s2); - let { pairingTopic: a3, proposer: c2, requiredNamespaces: p3, optionalNamespaces: d3 } = o2; - a3 = a3 || ""; - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = c2.publicKey, m2 = await this.client.core.crypto.generateSharedKey(h4, N2); - a3 && s2 && (await this.client.core.pairing.updateMetadata({ topic: a3, metadata: c2.metadata }), await this.sendResult({ id: s2, topic: a3, result: { relay: { protocol: t2 ?? "irn" }, responderPublicKey: h4 } }), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: a3 })); - const f2 = g$1({ relay: { protocol: t2 ?? "irn" }, namespaces: i2, pairingTopic: a3, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: pt$1(L) }, n3 && { sessionProperties: n3 }); - await this.client.core.relayer.subscribe(m2); - const k2 = D(g$1({}, f2), { topic: m2, requiredNamespaces: p3, optionalNamespaces: d3, pairingTopic: a3, acknowledged: false, self: f2.controller, peer: { publicKey: c2.publicKey, metadata: c2.metadata }, controller: h4 }); - await this.client.session.set(m2, k2); try { - await this.sendRequest({ topic: m2, method: "wc_sessionSettle", params: f2, throwOnFailedPublish: true }); - } catch (O2) { - throw this.client.logger.error(O2), this.client.session.delete(m2, U$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(m2), O2; - } - return await this.setExpiry(m2, pt$1(L)), { topic: m2, acknowledged: () => new Promise((O2) => setTimeout(() => O2(this.client.session.get(m2)), 500)) }; - }, this.reject = async (e) => { - await this.isInitialized(), await this.isValidReject(e); - const { id: s2, reason: t2 } = e, { pairingTopic: i2 } = this.client.proposal.get(s2); - i2 && (await this.sendError(s2, i2, t2), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED"))); - }, this.update = async (e) => { - await this.isInitialized(), await this.isValidUpdate(e); - const { topic: s2, namespaces: t2 } = e, i2 = await this.sendRequest({ topic: s2, method: "wc_sessionUpdate", params: { namespaces: t2 } }), { done: n3, resolve: o2, reject: a3 } = at$1(); - return this.events.once(yt$1("session_update", i2), ({ error: c2 }) => { - c2 ? a3(c2) : o2(); - }), await this.client.session.update(s2, { namespaces: t2 }), { acknowledged: n3 }; - }, this.extend = async (e) => { - await this.isInitialized(), await this.isValidExtend(e); - const { topic: s2 } = e, t2 = await this.sendRequest({ topic: s2, method: "wc_sessionExtend", params: {} }), { done: i2, resolve: n3, reject: o2 } = at$1(); - return this.events.once(yt$1("session_extend", t2), ({ error: a3 }) => { - a3 ? o2(a3) : n3(); - }), await this.setExpiry(s2, pt$1(L)), { acknowledged: i2 }; - }, this.request = async (e) => { - await this.isInitialized(), await this.isValidRequest(e); - const { chainId: s2, request: t2, topic: i2, expiry: n3 = R.wc_sessionRequest.req.ttl } = e, o2 = payloadId(), { done: a3, resolve: c2, reject: p3 } = at$1(n3, "Request expired. Please try again."); - return this.events.once(yt$1("session_request", o2), ({ error: d3, result: h4 }) => { - d3 ? p3(d3) : c2(h4); - }), await Promise.all([new Promise(async (d3) => { - await this.sendRequest({ clientRpcId: o2, topic: i2, method: "wc_sessionRequest", params: { request: D(g$1({}, t2), { expiryTimestamp: pt$1(n3) }), chainId: s2 }, expiry: n3, throwOnFailedPublish: true }).catch((h4) => p3(h4)), this.client.events.emit("session_request_sent", { topic: i2, request: t2, chainId: s2, id: o2 }), d3(); - }), new Promise(async (d3) => { - const h4 = await ht$1(this.client.core.storage, H); - gt$1({ id: o2, topic: i2, wcDeepLink: h4 }), d3(); - }), a3()]).then((d3) => d3[2]); - }, this.respond = async (e) => { - await this.isInitialized(), await this.isValidRespond(e); - const { topic: s2, response: t2 } = e, { id: i2 } = t2; - isJsonRpcResult(t2) ? await this.sendResult({ id: i2, topic: s2, result: t2.result, throwOnFailedPublish: true }) : isJsonRpcError(t2) && await this.sendError(i2, s2, t2.error), this.cleanupAfterResponse(e); - }, this.ping = async (e) => { - await this.isInitialized(), await this.isValidPing(e); - const { topic: s2 } = e; - if (this.client.session.keys.includes(s2)) { - const t2 = await this.sendRequest({ topic: s2, method: "wc_sessionPing", params: {} }), { done: i2, resolve: n3, reject: o2 } = at$1(); - this.events.once(yt$1("session_ping", t2), ({ error: a3 }) => { - a3 ? o2(a3) : n3(); - }), await i2(); + await this.isValidPing(t2); + } catch (s2) { + throw this.client.logger.error("ping() -> isValidPing() failed"), s2; + } + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) { + const s2 = payloadId(), i2 = getBigIntRpcId().toString(), { done: r3, resolve: o2, reject: a3 } = a0(); + this.events.once(v0("session_ping", s2), ({ error: c2 }) => { + c2 ? a3(c2) : o2(); + }), await Promise.all([this.sendRequest({ topic: e2, method: "wc_sessionPing", params: {}, throwOnFailedPublish: true, clientRpcId: s2, relayRpcId: i2 }), r3()]); } else - this.client.core.pairing.pairings.keys.includes(s2) && await this.client.core.pairing.ping({ topic: s2 }); - }, this.emit = async (e) => { - await this.isInitialized(), await this.isValidEmit(e); - const { topic: s2, event: t2, chainId: i2 } = e; - await this.sendRequest({ topic: s2, method: "wc_sessionEvent", params: { event: t2, chainId: i2 } }); - }, this.disconnect = async (e) => { - await this.isInitialized(), await this.isValidDisconnect(e); - const { topic: s2 } = e; - if (this.client.session.keys.includes(s2)) - await this.sendRequest({ topic: s2, method: "wc_sessionDelete", params: U$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: s2, emitEvent: false }); - else if (this.client.core.pairing.pairings.keys.includes(s2)) - await this.client.core.pairing.disconnect({ topic: s2 }); + this.client.core.pairing.pairings.keys.includes(e2) && await this.client.core.pairing.ping({ topic: e2 }); + }, this.emit = async (t2) => { + await this.isInitialized(), await this.isValidEmit(t2); + const { topic: e2, event: s2, chainId: i2 } = t2, r3 = getBigIntRpcId().toString(); + await this.sendRequest({ topic: e2, method: "wc_sessionEvent", params: { event: s2, chainId: i2 }, throwOnFailedPublish: true, relayRpcId: r3 }); + }, this.disconnect = async (t2) => { + await this.isInitialized(), await this.isValidDisconnect(t2); + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) + await this.sendRequest({ topic: e2, method: "wc_sessionDelete", params: tr$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: e2, emitEvent: false }); + else if (this.client.core.pairing.pairings.keys.includes(e2)) + await this.client.core.pairing.disconnect({ topic: e2 }); else { - const { message: t2 } = N$1("MISMATCHED_TOPIC", `Session or pairing topic not found: ${s2}`); - throw new Error(t2); + const { message: s2 } = xe("MISMATCHED_TOPIC", `Session or pairing topic not found: ${e2}`); + throw new Error(s2); + } + }, this.find = (t2) => (this.isInitialized(), this.client.session.getAll().filter((e2) => Qu(e2, t2))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (t2) => { + this.isInitialized(), this.isValidAuthenticate(t2); + const { chains: e2, statement: s2 = "", uri: i2, domain: r3, nonce: o2, type: a3, exp: c2, nbf: d5, methods: p2 = [] } = t2, g3 = [...t2.resources || []], { topic: h4, uri: y3 } = await this.client.core.pairing.create({ methods: ["wc_sessionAuthenticate"] }); + this.client.logger.info({ message: "Generated new pairing", pairing: { topic: h4, uri: y3 } }); + const w3 = await this.client.core.crypto.generateKeyPair(), I2 = bu(w3); + if (await Promise.all([this.client.auth.authKeys.set(J, { responseTopic: I2, publicKey: w3 }), this.client.auth.pairingTopics.set(I2, { topic: I2, pairingTopic: h4 })]), await this.client.core.relayer.subscribe(I2), this.client.logger.info(`sending request to new pairing topic: ${h4}`), p2.length > 0) { + const { namespace: O3 } = dn(e2[0]); + let _3 = cu(O3, "request", p2); + Qr(g3) && (_3 = lu(_3, g3.pop())), g3.push(_3); + } + const D2 = d0(q$1.wc_sessionPropose.req.ttl), E2 = { authPayload: { type: a3 ?? "caip122", chains: e2, statement: s2, aud: i2, domain: r3, version: "1", nonce: o2, iat: (/* @__PURE__ */ new Date()).toISOString(), exp: c2, nbf: d5, resources: g3 }, requester: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, P2 = { eip155: { chains: e2, methods: [.../* @__PURE__ */ new Set(["personal_sign", ...p2])], events: ["chainChanged", "accountsChanged"] } }, f3 = { requiredNamespaces: {}, optionalNamespaces: P2, relays: [{ protocol: "irn" }], proposer: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, { done: v3, resolve: j2, reject: oe2 } = a0(q$1.wc_sessionAuthenticate.req.ttl, "Request expired"), B2 = async ({ error: O3, session: _3 }) => { + if (this.events.off(v0("session_request", M2), ae2), O3) + oe2(O3); + else if (_3) { + _3.self.publicKey = w3, await this.client.session.set(_3.topic, _3), await this.setExpiry(_3.topic, _3.expiry), h4 && await this.client.core.pairing.updateMetadata({ topic: h4, metadata: _3.peer.metadata }); + const Q2 = this.client.session.get(_3.topic); + j2({ session: Q2 }); + } + }, ae2 = async (O3) => { + if (O3.error) { + const z2 = tr$2("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate"); + return O3.error.code === z2.code ? void 0 : (this.events.off(v0("session_connect"), B2), oe2(O3.error.message)); + } + this.events.off(v0("session_connect"), B2); + const { cacaos: _3, responder: Q2 } = O3.result, le2 = [], Ie = []; + for (const z2 of _3) { + await ou({ cacao: z2, projectId: this.client.core.projectId }) || (this.client.logger.error(z2, "Signature verification failed"), oe2(tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"))); + const { p: he2 } = z2, pe2 = Qr(he2.resources), fe2 = [fu(he2.iss)], Ze2 = Li(he2.iss); + if (pe2) { + const de2 = du(pe2), et2 = pu(pe2); + le2.push(...de2), fe2.push(...et2); + } + for (const de2 of fe2) + Ie.push(`${de2}:${Ze2}`); + } + const W2 = await this.client.core.crypto.generateSharedKey(w3, Q2.publicKey); + let Z2; + le2.length > 0 && (Z2 = { topic: W2, acknowledged: true, self: { publicKey: w3, metadata: this.client.metadata }, peer: Q2, controller: Q2.publicKey, expiry: d0(L$2), requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: h4, namespaces: ju([...new Set(le2)], [...new Set(Ie)]) }, await this.client.core.relayer.subscribe(W2), await this.client.session.set(W2, Z2), Z2 = this.client.session.get(W2)), j2({ auths: _3, session: Z2 }); + }, M2 = payloadId(), ce2 = payloadId(); + this.events.once(v0("session_connect"), B2), this.events.once(v0("session_request", M2), ae2); + try { + await Promise.all([this.sendRequest({ topic: h4, method: "wc_sessionAuthenticate", params: E2, expiry: t2.expiry, throwOnFailedPublish: true, clientRpcId: M2 }), this.sendRequest({ topic: h4, method: "wc_sessionPropose", params: f3, expiry: q$1.wc_sessionPropose.req.ttl, throwOnFailedPublish: true, clientRpcId: ce2 })]); + } catch (O3) { + throw this.events.off(v0("session_connect"), B2), this.events.off(v0("session_request", M2), ae2), O3; } - }, this.find = (e) => (this.isInitialized(), this.client.session.getAll().filter((s2) => Mt$1(s2, e))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.cleanupDuplicatePairings = async (e) => { - if (e.pairingTopic) + return await this.setProposal(ce2, m2({ id: ce2 }, f3)), await this.client.auth.requests.set(M2, { authPayload: E2.authPayload, requester: E2.requester, expiryTimestamp: D2, id: M2, pairingTopic: h4, verifyContext: {} }), { uri: y3, response: v3 }; + }, this.approveSessionAuthenticate = async (t2) => { + this.isInitialized(); + const { id: e2, auths: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o2 }, d5 = [], p2 = []; + for (const y3 of s2) { + if (!await ou({ cacao: y3, projectId: this.client.core.projectId })) { + const P2 = tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"); + throw await this.sendError({ id: e2, topic: a3, error: P2, encodeOpts: c2 }), new Error(P2.message); + } + const { p: w3 } = y3, I2 = Qr(w3.resources), D2 = [fu(w3.iss)], E2 = Li(w3.iss); + if (I2) { + const P2 = du(I2), f3 = pu(I2); + d5.push(...P2), D2.push(...f3); + } + for (const P2 of D2) + p2.push(`${P2}:${E2}`); + } + const g3 = await this.client.core.crypto.generateSharedKey(o2, r3); + let h4; + return (d5 == null ? void 0 : d5.length) > 0 && (h4 = { topic: g3, acknowledged: true, self: { publicKey: o2, metadata: this.client.metadata }, peer: { publicKey: r3, metadata: i2.requester.metadata }, controller: r3, expiry: d0(L$2), authentication: s2, requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: "", namespaces: ju([...new Set(d5)], [...new Set(p2)]) }, await this.client.core.relayer.subscribe(g3), await this.client.session.set(g3, h4)), await this.sendResult({ topic: a3, id: e2, result: { cacaos: s2, responder: { publicKey: o2, metadata: this.client.metadata } }, encodeOpts: c2, throwOnFailedPublish: true }), await this.client.auth.requests.delete(e2, { message: "fullfilled", code: 0 }), await this.client.core.pairing.activate({ topic: i2.pairingTopic }), { session: h4 }; + }, this.rejectSessionAuthenticate = async (t2) => { + await this.isInitialized(); + const { id: e2, reason: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o2 }; + await this.sendError({ id: e2, topic: a3, error: s2, encodeOpts: c2 }), await this.client.auth.requests.delete(e2, { message: "rejected", code: 0 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")); + }, this.formatAuthMessage = (t2) => { + this.isInitialized(); + const { request: e2, iss: s2 } = t2; + return zf(e2, s2); + }, this.cleanupDuplicatePairings = async (t2) => { + if (t2.pairingTopic) try { - const s2 = this.client.core.pairing.pairings.get(e.pairingTopic), t2 = this.client.core.pairing.pairings.getAll().filter((i2) => { - var n3, o2; - return ((n3 = i2.peerMetadata) == null ? void 0 : n3.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === e.peer.metadata.url && i2.topic && i2.topic !== s2.topic; + const e2 = this.client.core.pairing.pairings.get(t2.pairingTopic), s2 = this.client.core.pairing.pairings.getAll().filter((i2) => { + var r3, o2; + return ((r3 = i2.peerMetadata) == null ? void 0 : r3.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === t2.peer.metadata.url && i2.topic && i2.topic !== e2.topic; }); - if (t2.length === 0) + if (s2.length === 0) return; - this.client.logger.info(`Cleaning up ${t2.length} duplicate pairing(s)`), await Promise.all(t2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.deleteSession = async (e) => { - const { topic: s2, expirerHasDeleted: t2 = false, emitEvent: i2 = true, id: n3 = 0 } = e, { self: o2 } = this.client.session.get(s2); - await this.client.core.relayer.unsubscribe(s2), await this.client.session.delete(s2, U$2("USER_DISCONNECTED")), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(s2) && await this.client.core.crypto.deleteSymKey(s2), t2 || this.client.core.expirer.del(s2), this.client.core.storage.removeItem(H).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { - a3.topic === s2 && this.deletePendingSessionRequest(a3.id, U$2("USER_DISCONNECTED")); - }), i2 && this.client.events.emit("session_delete", { id: n3, topic: s2 }); - }, this.deleteProposal = async (e, s2) => { - await Promise.all([this.client.proposal.delete(e, U$2("USER_DISCONNECTED")), s2 ? Promise.resolve() : this.client.core.expirer.del(e)]); - }, this.deletePendingSessionRequest = async (e, s2, t2 = false) => { - await Promise.all([this.client.pendingRequest.delete(e, s2), t2 ? Promise.resolve() : this.client.core.expirer.del(e)]), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== e), t2 && (this.sessionRequestQueue.state = I.idle, this.client.events.emit("session_request_expire", { id: e })); - }, this.setExpiry = async (e, s2) => { - this.client.session.keys.includes(e) && await this.client.session.update(e, { expiry: s2 }), this.client.core.expirer.set(e, s2); - }, this.setProposal = async (e, s2) => { - await this.client.proposal.set(e, s2), this.client.core.expirer.set(e, pt$1(R.wc_sessionPropose.req.ttl)); - }, this.setPendingSessionRequest = async (e) => { - const { id: s2, topic: t2, params: i2, verifyContext: n3 } = e, o2 = i2.request.expiryTimestamp || pt$1(R.wc_sessionRequest.req.ttl); - await this.client.pendingRequest.set(s2, { id: s2, topic: t2, params: i2, verifyContext: n3 }), o2 && this.client.core.expirer.set(s2, o2); - }, this.sendRequest = async (e) => { - const { topic: s2, method: t2, params: i2, expiry: n3, relayRpcId: o2, clientRpcId: a3, throwOnFailedPublish: c2 } = e, p3 = formatJsonRpcRequest(t2, i2, a3); - if (D$2() && he.includes(t2)) { - const N2 = Ln(JSON.stringify(p3)); - this.client.core.verify.register({ attestationId: N2 }); - } - const d3 = await this.client.core.crypto.encode(s2, p3), h4 = R[t2].req; - return n3 && (h4.ttl = n3), o2 && (h4.id = o2), this.client.core.history.set(s2, p3), c2 ? (h4.internal = D(g$1({}, h4.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, d3, h4)) : this.client.core.relayer.publish(s2, d3, h4).catch((N2) => this.client.logger.error(N2)), p3.id; - }, this.sendResult = async (e) => { - const { id: s2, topic: t2, result: i2, throwOnFailedPublish: n3 } = e, o2 = formatJsonRpcResult(s2, i2), a3 = await this.client.core.crypto.encode(t2, o2), c2 = await this.client.core.history.get(t2, s2), p3 = R[c2.request.method].res; - n3 ? (p3.internal = D(g$1({}, p3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(t2, a3, p3)) : this.client.core.relayer.publish(t2, a3, p3).catch((d3) => this.client.logger.error(d3)), await this.client.core.history.resolve(o2); - }, this.sendError = async (e, s2, t2) => { - const i2 = formatJsonRpcError(e, t2), n3 = await this.client.core.crypto.encode(s2, i2), o2 = await this.client.core.history.get(s2, e), a3 = R[o2.request.method].res; - this.client.core.relayer.publish(s2, n3, a3), await this.client.core.history.resolve(i2); + this.client.logger.info(`Cleaning up ${s2.length} duplicate pairing(s)`), await Promise.all(s2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.deleteSession = async (t2) => { + const { topic: e2, expirerHasDeleted: s2 = false, emitEvent: i2 = true, id: r3 = 0 } = t2, { self: o2 } = this.client.session.get(e2); + await this.client.core.relayer.unsubscribe(e2), await this.client.session.delete(e2, tr$2("USER_DISCONNECTED")), this.addToRecentlyDeleted(e2, "session"), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(e2) && await this.client.core.crypto.deleteSymKey(e2), s2 || this.client.core.expirer.del(e2), this.client.core.storage.removeItem(Re$1).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { + a3.topic === e2 && this.deletePendingSessionRequest(a3.id, tr$2("USER_DISCONNECTED")); + }), i2 && this.client.events.emit("session_delete", { id: r3, topic: e2 }); + }, this.deleteProposal = async (t2, e2) => { + await Promise.all([this.client.proposal.delete(t2, tr$2("USER_DISCONNECTED")), e2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "proposal"); + }, this.deletePendingSessionRequest = async (t2, e2, s2 = false) => { + await Promise.all([this.client.pendingRequest.delete(t2, e2), s2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== t2), s2 && (this.sessionRequestQueue.state = A$1.idle, this.client.events.emit("session_request_expire", { id: t2 })); + }, this.setExpiry = async (t2, e2) => { + this.client.session.keys.includes(t2) && await this.client.session.update(t2, { expiry: e2 }), this.client.core.expirer.set(t2, e2); + }, this.setProposal = async (t2, e2) => { + await this.client.proposal.set(t2, e2), this.client.core.expirer.set(t2, d0(q$1.wc_sessionPropose.req.ttl)); + }, this.setPendingSessionRequest = async (t2) => { + const { id: e2, topic: s2, params: i2, verifyContext: r3 } = t2, o2 = i2.request.expiryTimestamp || d0(q$1.wc_sessionRequest.req.ttl); + await this.client.pendingRequest.set(e2, { id: e2, topic: s2, params: i2, verifyContext: r3 }), o2 && this.client.core.expirer.set(e2, o2); + }, this.sendRequest = async (t2) => { + const { topic: e2, method: s2, params: i2, expiry: r3, relayRpcId: o2, clientRpcId: a3, throwOnFailedPublish: c2 } = t2, d5 = formatJsonRpcRequest(s2, i2, a3); + if (pr$1() && je.includes(s2)) { + const h4 = yu(JSON.stringify(d5)); + this.client.core.verify.register({ attestationId: h4 }); + } + let p2; + try { + p2 = await this.client.core.crypto.encode(e2, d5); + } catch (h4) { + throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e2} failed`), h4; + } + const g3 = q$1[s2].req; + return r3 && (g3.ttl = r3), o2 && (g3.id = o2), this.client.core.history.set(e2, d5), c2 ? (g3.internal = F(m2({}, g3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(e2, p2, g3)) : this.client.core.relayer.publish(e2, p2, g3).catch((h4) => this.client.logger.error(h4)), d5.id; + }, this.sendResult = async (t2) => { + const { id: e2, topic: s2, result: i2, throwOnFailedPublish: r3, encodeOpts: o2 } = t2, a3 = formatJsonRpcResult(e2, i2); + let c2; + try { + c2 = await this.client.core.crypto.encode(s2, a3, o2); + } catch (g3) { + throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s2} failed`), g3; + } + let d5; + try { + d5 = await this.client.core.history.get(s2, e2); + } catch (g3) { + throw this.client.logger.error(`sendResult() -> history.get(${s2}, ${e2}) failed`), g3; + } + const p2 = q$1[d5.request.method].res; + r3 ? (p2.internal = F(m2({}, p2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, c2, p2)) : this.client.core.relayer.publish(s2, c2, p2).catch((g3) => this.client.logger.error(g3)), await this.client.core.history.resolve(a3); + }, this.sendError = async (t2) => { + const { id: e2, topic: s2, error: i2, encodeOpts: r3 } = t2, o2 = formatJsonRpcError(e2, i2); + let a3; + try { + a3 = await this.client.core.crypto.encode(s2, o2, r3); + } catch (p2) { + throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s2} failed`), p2; + } + let c2; + try { + c2 = await this.client.core.history.get(s2, e2); + } catch (p2) { + throw this.client.logger.error(`sendError() -> history.get(${s2}, ${e2}) failed`), p2; + } + const d5 = q$1[c2.request.method].res; + this.client.core.relayer.publish(s2, a3, d5), await this.client.core.history.resolve(o2); }, this.cleanup = async () => { - const e = [], s2 = []; - this.client.session.getAll().forEach((t2) => { + const t2 = [], e2 = []; + this.client.session.getAll().forEach((s2) => { let i2 = false; - mt$1(t2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(t2.topic) || (i2 = true), i2 && e.push(t2.topic); - }), this.client.proposal.getAll().forEach((t2) => { - mt$1(t2.expiryTimestamp) && s2.push(t2.id); - }), await Promise.all([...e.map((t2) => this.deleteSession({ topic: t2 })), ...s2.map((t2) => this.deleteProposal(t2))]); - }, this.onRelayEventRequest = async (e) => { - this.requestQueue.queue.push(e), await this.processRequestsQueue(); + p0(s2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(s2.topic) || (i2 = true), i2 && t2.push(s2.topic); + }), this.client.proposal.getAll().forEach((s2) => { + p0(s2.expiryTimestamp) && e2.push(s2.id); + }), await Promise.all([...t2.map((s2) => this.deleteSession({ topic: s2 })), ...e2.map((s2) => this.deleteProposal(s2))]); + }, this.onRelayEventRequest = async (t2) => { + this.requestQueue.queue.push(t2), await this.processRequestsQueue(); }, this.processRequestsQueue = async () => { - if (this.requestQueue.state === I.active) { + if (this.requestQueue.state === A$1.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 = I.active; - const e = this.requestQueue.queue.shift(); - if (e) + this.requestQueue.state = A$1.active; + const t2 = this.requestQueue.queue.shift(); + if (t2) try { - this.processRequest(e), await new Promise((s2) => setTimeout(s2, 300)); - } catch (s2) { - this.client.logger.warn(s2); + this.processRequest(t2), await new Promise((e2) => setTimeout(e2, 300)); + } catch (e2) { + this.client.logger.warn(e2); } } - this.requestQueue.state = I.idle; - }, this.processRequest = (e) => { - const { topic: s2, payload: t2 } = e, i2 = t2.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeRequest(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleRequest(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateRequest(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendRequest(s2, t2); - case "wc_sessionPing": - return this.onSessionPingRequest(s2, t2); - case "wc_sessionDelete": - return this.onSessionDeleteRequest(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequest(s2, t2); - case "wc_sessionEvent": - return this.onSessionEventRequest(s2, t2); - default: - return this.client.logger.info(`Unsupported request method ${i2}`); - } - }, this.onRelayEventResponse = async (e) => { - const { topic: s2, payload: t2 } = e, i2 = (await this.client.core.history.get(s2, t2.id)).request.method; + this.requestQueue.state = A$1.idle; + }, this.processRequest = (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = s2.method; + if (!this.shouldIgnorePairingRequest({ topic: e2, requestMethod: i2 })) + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeRequest(e2, s2); + case "wc_sessionSettle": + return this.onSessionSettleRequest(e2, s2); + case "wc_sessionUpdate": + return this.onSessionUpdateRequest(e2, s2); + case "wc_sessionExtend": + return this.onSessionExtendRequest(e2, s2); + case "wc_sessionPing": + return this.onSessionPingRequest(e2, s2); + case "wc_sessionDelete": + return this.onSessionDeleteRequest(e2, s2); + case "wc_sessionRequest": + return this.onSessionRequest(e2, s2); + case "wc_sessionEvent": + return this.onSessionEventRequest(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateRequest(e2, s2); + default: + return this.client.logger.info(`Unsupported request method ${i2}`); + } + }, this.onRelayEventResponse = async (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = (await this.client.core.history.get(e2, s2.id)).request.method; switch (i2) { case "wc_sessionPropose": - return this.onSessionProposeResponse(s2, t2); + return this.onSessionProposeResponse(e2, s2); case "wc_sessionSettle": - return this.onSessionSettleResponse(s2, t2); + return this.onSessionSettleResponse(e2, s2); case "wc_sessionUpdate": - return this.onSessionUpdateResponse(s2, t2); + return this.onSessionUpdateResponse(e2, s2); case "wc_sessionExtend": - return this.onSessionExtendResponse(s2, t2); + return this.onSessionExtendResponse(e2, s2); case "wc_sessionPing": - return this.onSessionPingResponse(s2, t2); + return this.onSessionPingResponse(e2, s2); case "wc_sessionRequest": - return this.onSessionRequestResponse(s2, t2); + return this.onSessionRequestResponse(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateResponse(e2, s2); default: return this.client.logger.info(`Unsupported response method ${i2}`); } - }, this.onRelayEventUnknownPayload = (e) => { - const { topic: s2 } = e, { message: t2 } = N$1("MISSING_OR_INVALID", `Decoded payload on topic ${s2} is not identifiable as a JSON-RPC request or a response.`); - throw new Error(t2); - }, this.onSessionProposeRequest = async (e, s2) => { - const { params: t2, id: i2 } = s2; + }, this.onRelayEventUnknownPayload = (t2) => { + const { topic: e2 } = t2, { message: s2 } = xe("MISSING_OR_INVALID", `Decoded payload on topic ${e2} is not identifiable as a JSON-RPC request or a response.`); + throw new Error(s2); + }, this.shouldIgnorePairingRequest = (t2) => { + const { topic: e2, requestMethod: s2 } = t2, i2 = this.expectedPairingMethodMap.get(e2); + return !i2 || i2.includes(s2) ? false : !!(i2.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0); + }, this.onSessionProposeRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; try { - this.isValidConnect(g$1({}, s2.params)); - const n3 = t2.expiryTimestamp || pt$1(R.wc_sessionPropose.req.ttl), o2 = g$1({ id: i2, pairingTopic: e, expiryTimestamp: n3 }, t2); + this.isValidConnect(m2({}, e2.params)); + const r3 = s2.expiryTimestamp || d0(q$1.wc_sessionPropose.req.ttl), o2 = m2({ id: i2, pairingTopic: t2, expiryTimestamp: r3 }, s2); await this.setProposal(i2, o2); - const a3 = Ln(JSON.stringify(s2)), c2 = await this.getVerifyContext(a3, o2.proposer.metadata); + const a3 = yu(JSON.stringify(e2)), c2 = await this.getVerifyContext(a3, o2.proposer.metadata); this.client.events.emit("session_proposal", { id: i2, params: o2, verifyContext: c2 }); - } catch (n3) { - await this.sendError(i2, e, n3), this.client.logger.error(n3); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); } - }, this.onSessionProposeResponse = async (e, s2) => { - const { id: t2 } = s2; - if (isJsonRpcResult(s2)) { - const { result: i2 } = s2; + }, this.onSessionProposeResponse = async (t2, e2) => { + const { id: s2 } = e2; + if (isJsonRpcResult(e2)) { + const { result: i2 } = e2; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); - const n3 = this.client.proposal.get(t2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: n3 }); - const o2 = n3.proposer.publicKey; + const r3 = this.client.proposal.get(s2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: r3 }); + const o2 = r3.proposer.publicKey; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o2 }); const a3 = i2.responderPublicKey; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a3 }); const c2 = await this.client.core.crypto.generateSharedKey(o2, a3); this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); - const p3 = await this.client.core.relayer.subscribe(c2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: p3 }), await this.client.core.pairing.activate({ topic: e }); - } else - isJsonRpcError(s2) && (await this.client.proposal.delete(t2, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_connect"), { error: s2.error })); - }, this.onSessionSettleRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; + const d5 = await this.client.core.relayer.subscribe(c2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: d5 }), await this.client.core.pairing.activate({ topic: t2 }); + } else if (isJsonRpcError(e2)) { + await this.client.proposal.delete(s2, tr$2("USER_DISCONNECTED")); + const i2 = v0("session_connect"); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners, 954`); + this.events.emit(v0("session_connect"), { error: e2.error }); + } + }, this.onSessionSettleRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; try { this.isValidSessionSettleRequest(i2); - const { relay: n3, controller: o2, expiry: a3, namespaces: c2, sessionProperties: p3, pairingTopic: d3 } = s2.params, h4 = g$1({ topic: e, relay: n3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: d3, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, p3 && { sessionProperties: p3 }); - await this.sendResult({ id: s2.id, topic: e, result: true }), this.events.emit(yt$1("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionSettleResponse = async (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? (await this.client.session.update(e, { acknowledged: true }), this.events.emit(yt$1("session_approve", t2), {})) : isJsonRpcError(s2) && (await this.client.session.delete(e, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_approve", t2), { error: s2.error })); - }, this.onSessionUpdateRequest = async (e, s2) => { - const { params: t2, id: i2 } = s2; + const { relay: r3, controller: o2, expiry: a3, namespaces: c2, sessionProperties: d5, pairingTopic: p2, sessionConfig: g3 } = e2.params, h4 = m2(m2({ topic: t2, relay: r3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: p2, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, d5 && { sessionProperties: d5 }), g3 && { sessionConfig: g3 }); + await this.sendResult({ id: e2.id, topic: t2, result: true, throwOnFailedPublish: true }); + const y3 = v0("session_connect"); + if (this.events.listenerCount(y3) === 0) + throw new Error(`emitting ${y3} without any listeners 997`); + this.events.emit(v0("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionSettleResponse = async (t2, e2) => { + const { id: s2 } = e2; + isJsonRpcResult(e2) ? (await this.client.session.update(t2, { acknowledged: true }), this.events.emit(v0("session_approve", s2), {})) : isJsonRpcError(e2) && (await this.client.session.delete(t2, tr$2("USER_DISCONNECTED")), this.events.emit(v0("session_approve", s2), { error: e2.error })); + }, this.onSessionUpdateRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; try { - const n3 = `${e}_session_update`, o2 = sr$1.get(n3); + const r3 = `${t2}_session_update`, o2 = lh.get(r3); if (o2 && this.isRequestOutOfSync(o2, i2)) { - this.client.logger.info(`Discarding out of sync request - ${i2}`); + this.client.logger.info(`Discarding out of sync request - ${i2}`), this.sendError({ id: i2, topic: t2, error: tr$2("INVALID_UPDATE_REQUEST") }); return; } - this.isValidUpdate(g$1({ topic: e }, t2)), await this.client.session.update(e, { namespaces: t2.namespaces }), await this.sendResult({ id: i2, topic: e, result: true }), this.client.events.emit("session_update", { id: i2, topic: e, params: t2 }), sr$1.set(n3, i2); - } catch (n3) { - await this.sendError(i2, e, n3), this.client.logger.error(n3); - } - }, this.isRequestOutOfSync = (e, s2) => parseInt(s2.toString().slice(0, -3)) <= parseInt(e.toString().slice(0, -3)), this.onSessionUpdateResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_update", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_update", t2), { error: s2.error }); - }, this.onSessionExtendRequest = async (e, s2) => { - const { id: t2 } = s2; + this.isValidUpdate(m2({ topic: t2 }, s2)); + try { + lh.set(r3, i2), await this.client.session.update(t2, { namespaces: s2.namespaces }), await this.sendResult({ id: i2, topic: t2, result: true, throwOnFailedPublish: true }); + } catch (a3) { + throw lh.delete(r3), a3; + } + this.client.events.emit("session_update", { id: i2, topic: t2, params: s2 }); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.isRequestOutOfSync = (t2, e2) => parseInt(e2.toString().slice(0, -3)) <= parseInt(t2.toString().slice(0, -3)), this.onSessionUpdateResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_update", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_update", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_update", s2), { error: e2.error }); + }, this.onSessionExtendRequest = async (t2, e2) => { + const { id: s2 } = e2; try { - this.isValidExtend({ topic: e }), await this.setExpiry(e, pt$1(L)), await this.sendResult({ id: t2, topic: e, result: true }), this.client.events.emit("session_extend", { id: t2, topic: e }); + this.isValidExtend({ topic: t2 }), await this.setExpiry(t2, d0(L$2)), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_extend", { id: s2, topic: t2 }); } catch (i2) { - await this.sendError(t2, e, i2), this.client.logger.error(i2); - } - }, this.onSessionExtendResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_extend", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_extend", t2), { error: s2.error }); - }, this.onSessionPingRequest = async (e, s2) => { - const { id: t2 } = s2; + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionExtendResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_extend", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_extend", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_extend", s2), { error: e2.error }); + }, this.onSessionPingRequest = async (t2, e2) => { + const { id: s2 } = e2; try { - this.isValidPing({ topic: e }), await this.sendResult({ id: t2, topic: e, result: true }), this.client.events.emit("session_ping", { id: t2, topic: e }); + this.isValidPing({ topic: t2 }), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_ping", { id: s2, topic: t2 }); } catch (i2) { - await this.sendError(t2, e, i2), this.client.logger.error(i2); + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); } - }, this.onSessionPingResponse = (e, s2) => { - const { id: t2 } = s2; + }, this.onSessionPingResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_ping", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_ping", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_ping", t2), { error: s2.error }); + isJsonRpcResult(e2) ? this.events.emit(v0("session_ping", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_ping", s2), { error: e2.error }); }, 500); - }, this.onSessionDeleteRequest = async (e, s2) => { - const { id: t2 } = s2; + }, this.onSessionDeleteRequest = async (t2, e2) => { + const { id: s2 } = e2; try { - this.isValidDisconnect({ topic: e, reason: s2.params }), await Promise.all([new Promise((i2) => { - this.client.core.relayer.once(D$1.publish, async () => { - i2(await this.deleteSession({ topic: e, id: t2 })); + this.isValidDisconnect({ topic: t2, reason: e2.params }), await Promise.all([new Promise((i2) => { + this.client.core.relayer.once(v2.publish, async () => { + i2(await this.deleteSession({ topic: t2, id: s2 })); }); - }), this.sendResult({ id: t2, topic: e, result: true }), this.cleanupPendingSentRequestsForTopic({ topic: e, error: U$2("USER_DISCONNECTED") })]); + }), this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.cleanupPendingSentRequestsForTopic({ topic: t2, error: tr$2("USER_DISCONNECTED") })]); } catch (i2) { this.client.logger.error(i2); } - }, this.onSessionRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; + }, this.onSessionRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; try { - this.isValidRequest(g$1({ topic: e }, i2)); - const n3 = Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, t2))), o2 = this.client.session.get(e), a3 = await this.getVerifyContext(n3, o2.peer.metadata), c2 = { id: t2, topic: e, params: i2, verifyContext: a3 }; + await this.isValidRequest(m2({ topic: t2 }, i2)); + const r3 = yu(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, s2))), o2 = this.client.session.get(t2), a3 = await this.getVerifyContext(r3, o2.peer.metadata), c2 = { id: s2, topic: t2, params: i2, verifyContext: a3 }; await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionRequestResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_request", t2), { result: s2.result }) : isJsonRpcError(s2) && this.events.emit(yt$1("session_request", t2), { error: s2.error }); - }, this.onSessionEventRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionRequestResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_request", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionEventRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; try { - const n3 = `${e}_session_event_${i2.event.name}`, o2 = sr$1.get(n3); - if (o2 && this.isRequestOutOfSync(o2, t2)) { - this.client.logger.info(`Discarding out of sync request - ${t2}`); + const r3 = `${t2}_session_event_${i2.event.name}`, o2 = lh.get(r3); + if (o2 && this.isRequestOutOfSync(o2, s2)) { + this.client.logger.info(`Discarding out of sync request - ${s2}`); return; } - this.isValidEmit(g$1({ topic: e }, i2)), this.client.events.emit("session_event", { id: t2, topic: e, params: i2 }), sr$1.set(n3, t2); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.addSessionRequestToSessionRequestQueue = (e) => { - this.sessionRequestQueue.queue.push(e); - }, this.cleanupAfterResponse = (e) => { - this.deletePendingSessionRequest(e.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { - this.sessionRequestQueue.state = I.idle, this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay)); - }, this.cleanupPendingSentRequestsForTopic = ({ topic: e, error: s2 }) => { - const t2 = this.client.core.history.pending; - t2.length > 0 && t2.filter((i2) => i2.topic === e && i2.request.method === "wc_sessionRequest").forEach((i2) => { - this.events.emit(yt$1("session_request", i2.request.id), { error: s2 }); + this.isValidEmit(m2({ topic: t2 }, i2)), this.client.events.emit("session_event", { id: s2, topic: t2, params: i2 }), lh.set(r3, s2); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionAuthenticateResponse = (t2, e2) => { + const { id: s2 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionAuthenticateResponse", topic: t2, payload: e2 }), isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionAuthenticateRequest = async (t2, e2) => { + const { requester: s2, authPayload: i2, expiryTimestamp: r3 } = e2.params, o2 = yu(JSON.stringify(e2)), a3 = await this.getVerifyContext(o2, this.client.metadata), c2 = { requester: s2, pairingTopic: t2, id: e2.id, authPayload: i2, verifyContext: a3, expiryTimestamp: r3 }; + await this.client.auth.requests.set(e2.id, c2), this.client.events.emit("session_authenticate", { topic: t2, params: e2.params, id: e2.id }); + }, this.addSessionRequestToSessionRequestQueue = (t2) => { + this.sessionRequestQueue.queue.push(t2); + }, this.cleanupAfterResponse = (t2) => { + this.deletePendingSessionRequest(t2.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { + this.sessionRequestQueue.state = A$1.idle, this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay)); + }, this.cleanupPendingSentRequestsForTopic = ({ topic: t2, error: e2 }) => { + const s2 = this.client.core.history.pending; + s2.length > 0 && s2.filter((i2) => i2.topic === t2 && i2.request.method === "wc_sessionRequest").forEach((i2) => { + const r3 = i2.request.id, o2 = v0("session_request", r3); + if (this.events.listenerCount(o2) === 0) + throw new Error(`emitting ${o2} without any listeners`); + this.events.emit(v0("session_request", i2.request.id), { error: e2 }); }); }, this.processSessionRequestQueue = () => { - if (this.sessionRequestQueue.state === I.active) { + if (this.sessionRequestQueue.state === A$1.active) { this.client.logger.info("session request queue is already active."); return; } - const e = this.sessionRequestQueue.queue[0]; - if (!e) { + const t2 = this.sessionRequestQueue.queue[0]; + if (!t2) { this.client.logger.info("session request queue is empty."); return; } try { - this.sessionRequestQueue.state = I.active, this.client.events.emit("session_request", e); - } catch (s2) { - this.client.logger.error(s2); + this.sessionRequestQueue.state = A$1.active, this.client.events.emit("session_request", t2); + } catch (e2) { + this.client.logger.error(e2); } - }, this.onPairingCreated = (e) => { - if (e.active) + }, this.onPairingCreated = (t2) => { + if (t2.methods && this.expectedPairingMethodMap.set(t2.topic, t2.methods), t2.active) return; - const s2 = this.client.proposal.getAll().find((t2) => t2.pairingTopic === e.topic); - s2 && this.onSessionProposeRequest(e.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: s2.requiredNamespaces, optionalNamespaces: s2.optionalNamespaces, relays: s2.relays, proposer: s2.proposer, sessionProperties: s2.sessionProperties }, s2.id)); - }, this.isValidConnect = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(e)}`); + const e2 = this.client.proposal.getAll().find((s2) => s2.pairingTopic === t2.topic); + e2 && this.onSessionProposeRequest(t2.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: e2.requiredNamespaces, optionalNamespaces: e2.optionalNamespaces, relays: e2.relays, proposer: e2.proposer, sessionProperties: e2.sessionProperties }, e2.id)); + }, this.isValidConnect = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(t2)}`); throw new Error(a3); } - const { pairingTopic: s2, requiredNamespaces: t2, optionalNamespaces: i2, sessionProperties: n3, relays: o2 } = e; - if (w$3(s2) || await this.isValidPairingTopic(s2), !qt$1(o2, true)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() relays: ${o2}`); + const { pairingTopic: e2, requiredNamespaces: s2, optionalNamespaces: i2, sessionProperties: r3, relays: o2 } = t2; + if (Pe(e2) || await this.isValidPairingTopic(e2), !Xu(o2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `connect() relays: ${o2}`); throw new Error(a3); } - !w$3(t2) && B$1(t2) !== 0 && this.validateNamespaces(t2, "requiredNamespaces"), !w$3(i2) && B$1(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.validateNamespaces = (e, s2) => { - const t2 = Ht$1(e, "connect()", s2); - if (t2) - throw new Error(t2.message); - }, this.isValidApprove = async (e) => { - if (!Gt$1(e)) - throw new Error(N$1("MISSING_OR_INVALID", `approve() params: ${e}`).message); - const { id: s2, namespaces: t2, relayProtocol: i2, sessionProperties: n3 } = e; - await this.isValidProposalId(s2); - const o2 = this.client.proposal.get(s2), a3 = ln(t2, "approve()"); + !Pe(s2) && Yr(s2) !== 0 && this.validateNamespaces(s2, "requiredNamespaces"), !Pe(i2) && Yr(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), Pe(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.validateNamespaces = (t2, e2) => { + const s2 = Wu(t2, "connect()", e2); + if (s2) + throw new Error(s2.message); + }, this.isValidApprove = async (t2) => { + if (!$u(t2)) + throw new Error(xe("MISSING_OR_INVALID", `approve() params: ${t2}`).message); + const { id: e2, namespaces: s2, relayProtocol: i2, sessionProperties: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2); + const o2 = this.client.proposal.get(e2), a3 = So(s2, "approve()"); if (a3) throw new Error(a3.message); - const c2 = fn(o2.requiredNamespaces, t2, "approve()"); + const c2 = Io(o2.requiredNamespaces, s2, "approve()"); if (c2) throw new Error(c2.message); - if (!g$3(i2, true)) { - const { message: p3 } = N$1("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); - throw new Error(p3); - } - w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.isValidReject = async (e) => { - if (!Gt$1(e)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() params: ${e}`); + if (!Gt$1(i2, true)) { + const { message: d5 } = xe("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); + throw new Error(d5); + } + Pe(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.isValidReject = async (t2) => { + if (!$u(t2)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `reject() params: ${t2}`); throw new Error(i2); } - const { id: s2, reason: t2 } = e; - if (await this.isValidProposalId(s2), !Wt(t2)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(t2)}`); + const { id: e2, reason: s2 } = t2; + if (this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2), !th(s2)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(s2)}`); throw new Error(i2); } - }, this.isValidSessionSettleRequest = (e) => { - if (!Gt$1(e)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${e}`); + }, this.isValidSessionSettleRequest = (t2) => { + if (!$u(t2)) { + const { message: c2 } = xe("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${t2}`); throw new Error(c2); } - const { relay: s2, controller: t2, namespaces: i2, expiry: n3 } = e; - if (!dn(s2)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); + const { relay: e2, controller: s2, namespaces: i2, expiry: r3 } = t2; + if (!No(e2)) { + const { message: c2 } = xe("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); throw new Error(c2); } - const o2 = Ft$1(t2, "onSessionSettleRequest()"); + const o2 = Vu(s2, "onSessionSettleRequest()"); if (o2) throw new Error(o2.message); - const a3 = ln(i2, "onSessionSettleRequest()"); + const a3 = So(i2, "onSessionSettleRequest()"); if (a3) throw new Error(a3.message); - if (mt$1(n3)) { - const { message: c2 } = N$1("EXPIRED", "onSessionSettleRequest()"); + if (p0(r3)) { + const { message: c2 } = xe("EXPIRED", "onSessionSettleRequest()"); throw new Error(c2); } - }, this.isValidUpdate = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `update() params: ${e}`); + }, this.isValidUpdate = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `update() params: ${t2}`); throw new Error(a3); } - const { topic: s2, namespaces: t2 } = e; - await this.isValidSessionTopic(s2); - const i2 = this.client.session.get(s2), n3 = ln(t2, "update()"); - if (n3) - throw new Error(n3.message); - const o2 = fn(i2.requiredNamespaces, t2, "update()"); + const { topic: e2, namespaces: s2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const i2 = this.client.session.get(e2), r3 = So(s2, "update()"); + if (r3) + throw new Error(r3.message); + const o2 = Io(i2.requiredNamespaces, s2, "update()"); if (o2) throw new Error(o2.message); - }, this.isValidExtend = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `extend() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionTopic(s2); - }, this.isValidRequest = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() params: ${e}`); + }, this.isValidExtend = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `extend() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + }, this.isValidRequest = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() params: ${t2}`); throw new Error(a3); } - const { topic: s2, request: t2, chainId: i2, expiry: n3 } = e; - await this.isValidSessionTopic(s2); - const { namespaces: o2 } = this.client.session.get(s2); - if (!Qt(o2, i2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() chainId: ${i2}`); + const { topic: e2, request: s2, chainId: i2, expiry: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const { namespaces: o2 } = this.client.session.get(e2); + if (!nh(o2, i2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() chainId: ${i2}`); throw new Error(a3); } - if (!zt$1(t2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() ${JSON.stringify(t2)}`); + if (!eh(s2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() ${JSON.stringify(s2)}`); throw new Error(a3); } - if (!Zt(o2, i2, t2.method)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() method: ${t2.method}`); + if (!fh(o2, i2, s2.method)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() method: ${s2.method}`); throw new Error(a3); } - if (n3 && !tr$1(n3, U$1)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() expiry: ${n3}. Expiry must be a number (in seconds) between ${U$1.min} and ${U$1.max}`); + if (r3 && !uh(r3, re$1)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() expiry: ${r3}. Expiry must be a number (in seconds) between ${re$1.min} and ${re$1.max}`); throw new Error(a3); } - }, this.isValidRespond = async (e) => { - var s2; - if (!Gt$1(e)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() params: ${e}`); - throw new Error(n3); + }, this.isValidRespond = async (t2) => { + var e2; + if (!$u(t2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `respond() params: ${t2}`); + throw new Error(r3); } - const { topic: t2, response: i2 } = e; + const { topic: s2, response: i2 } = t2; try { - await this.isValidSessionTopic(t2); - } catch (n3) { - throw (s2 = e == null ? void 0 : e.response) != null && s2.id && this.cleanupAfterResponse(e), n3; - } - if (!Yt$1(i2)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); - throw new Error(n3); - } - }, this.isValidPing = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `ping() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionOrPairingTopic(s2); - }, this.isValidEmit = async (e) => { - if (!Gt$1(e)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() params: ${e}`); + await this.isValidSessionTopic(s2); + } catch (r3) { + throw (e2 = t2 == null ? void 0 : t2.response) != null && e2.id && this.cleanupAfterResponse(t2), r3; + } + if (!rh(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); + throw new Error(r3); + } + }, this.isValidPing = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `ping() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidEmit = async (t2) => { + if (!$u(t2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() params: ${t2}`); throw new Error(o2); } - const { topic: s2, event: t2, chainId: i2 } = e; - await this.isValidSessionTopic(s2); - const { namespaces: n3 } = this.client.session.get(s2); - if (!Qt(n3, i2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() chainId: ${i2}`); + const { topic: e2, event: s2, chainId: i2 } = t2; + await this.isValidSessionTopic(e2); + const { namespaces: r3 } = this.client.session.get(e2); + if (!nh(r3, i2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() chainId: ${i2}`); throw new Error(o2); } - if (!Jt$1(t2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); + if (!ih(s2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); throw new Error(o2); } - if (!Xt(n3, i2, t2.name)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); + if (!oh(r3, i2, s2.name)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); throw new Error(o2); } - }, this.isValidDisconnect = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${e}`); - throw new Error(t2); + }, this.isValidDisconnect = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `disconnect() params: ${t2}`); + throw new Error(s2); } - const { topic: s2 } = e; - await this.isValidSessionOrPairingTopic(s2); - }, this.getVerifyContext = async (e, s2) => { - const t2 = { verified: { verifyUrl: s2.verifyUrl || F$1, validation: "UNKNOWN", origin: s2.url || "" } }; + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidAuthenticate = (t2) => { + const { chains: e2, uri: s2, domain: i2, nonce: r3 } = t2; + if (!Array.isArray(e2) || e2.length === 0) + throw new Error("chains is required and must be a non-empty array"); + if (!Gt$1(s2, false)) + throw new Error("uri is required parameter"); + if (!Gt$1(i2, false)) + throw new Error("domain is required parameter"); + if (!Gt$1(r3, false)) + throw new Error("nonce is required parameter"); + if ([...new Set(e2.map((a3) => dn(a3).namespace))].length > 1) + throw new Error("Multi-namespace requests are not supported. Please request single namespace only."); + const { namespace: o2 } = dn(e2[0]); + if (o2 !== "eip155") + throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains."); + }, this.getVerifyContext = async (t2, e2) => { + const s2 = { verified: { verifyUrl: e2.verifyUrl || k$1, validation: "UNKNOWN", origin: e2.url || "" } }; try { - const i2 = await this.client.core.verify.resolve({ attestationId: e, verifyUrl: s2.verifyUrl }); - i2 && (t2.verified.origin = i2.origin, t2.verified.isScam = i2.isScam, t2.verified.validation = i2.origin === new URL(s2.url).origin ? "VALID" : "INVALID"); + const i2 = await this.client.core.verify.resolve({ attestationId: t2, verifyUrl: e2.verifyUrl }); + i2 && (s2.verified.origin = i2.origin, s2.verified.isScam = i2.isScam, s2.verified.validation = i2.origin === new URL(e2.url).origin ? "VALID" : "INVALID"); } catch (i2) { this.client.logger.info(i2); } - return this.client.logger.info(`Verify context: ${JSON.stringify(t2)}`), t2; - }, this.validateSessionProps = (e, s2) => { - Object.values(e).forEach((t2) => { - if (!g$3(t2, false)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `${s2} must be in Record format. Received: ${JSON.stringify(t2)}`); + return this.client.logger.info(`Verify context: ${JSON.stringify(s2)}`), s2; + }, this.validateSessionProps = (t2, e2) => { + Object.values(t2).forEach((s2) => { + if (!Gt$1(s2, false)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `${e2} must be in Record format. Received: ${JSON.stringify(s2)}`); throw new Error(i2); } }); + }, this.getPendingAuthRequest = (t2) => { + const e2 = this.client.auth.requests.get(t2); + return typeof e2 == "object" ? e2 : void 0; + }, this.addToRecentlyDeleted = (t2, e2) => { + if (this.recentlyDeletedMap.set(t2, e2), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) { + let s2 = 0; + const i2 = this.recentlyDeletedLimit / 2; + for (const r3 of this.recentlyDeletedMap.keys()) { + if (s2++ >= i2) + break; + this.recentlyDeletedMap.delete(r3); + } + } + }, this.checkRecentlyDeleted = (t2) => { + const e2 = this.recentlyDeletedMap.get(t2); + if (e2) { + const { message: s2 } = xe("MISSING_OR_INVALID", `Record was recently deleted - ${e2}: ${t2}`); + throw new Error(s2); + } }; } async isInitialized() { if (!this.initialized) { - const { message: r2 } = N$1("NOT_INITIALIZED", this.name); - throw new Error(r2); + const { message: n4 } = xe("NOT_INITIALIZED", this.name); + throw new Error(n4); } await this.client.core.relayer.confirmOnlineStateOrThrow(); } registerRelayerEvents() { - this.client.core.relayer.on(D$1.message, async (r2) => { - const { topic: e, message: s2 } = r2; - if (this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s2))) - return; - const t2 = await this.client.core.crypto.decode(e, s2); + this.client.core.relayer.on(v2.message, async (n4) => { + const { topic: t2, message: e2 } = n4, { publicKey: s2 } = this.client.auth.authKeys.keys.includes(J) ? this.client.auth.authKeys.get(J) : { responseTopic: void 0, publicKey: void 0 }, i2 = await this.client.core.crypto.decode(t2, e2, { receiverPublicKey: s2 }); try { - isJsonRpcRequest(t2) ? (this.client.core.history.set(e, t2), this.onRelayEventRequest({ topic: e, payload: t2 })) : isJsonRpcResponse(t2) ? (await this.client.core.history.resolve(t2), await this.onRelayEventResponse({ topic: e, payload: t2 }), this.client.core.history.delete(e, t2.id)) : this.onRelayEventUnknownPayload({ topic: e, payload: t2 }); - } catch (i2) { - this.client.logger.error(i2); + isJsonRpcRequest(i2) ? (this.client.core.history.set(t2, i2), this.onRelayEventRequest({ topic: t2, payload: i2 })) : isJsonRpcResponse(i2) ? (await this.client.core.history.resolve(i2), await this.onRelayEventResponse({ topic: t2, payload: i2 }), this.client.core.history.delete(t2, i2.id)) : this.onRelayEventUnknownPayload({ topic: t2, payload: i2 }); + } catch (r3) { + this.client.logger.error(r3); } }); } registerExpirerEvents() { - this.client.core.expirer.on(v2.expired, async (r2) => { - const { topic: e, id: s2 } = ft$1(r2.target); - if (s2 && this.client.pendingRequest.keys.includes(s2)) - return await this.deletePendingSessionRequest(s2, N$1("EXPIRED"), true); - e ? this.client.session.keys.includes(e) && (await this.deleteSession({ topic: e, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: e })) : s2 && (await this.deleteProposal(s2, true), this.client.events.emit("proposal_expire", { id: s2 })); + this.client.core.expirer.on(C.expired, async (n4) => { + const { topic: t2, id: e2 } = l0(n4.target); + if (e2 && this.client.pendingRequest.keys.includes(e2)) + return await this.deletePendingSessionRequest(e2, xe("EXPIRED"), true); + t2 ? this.client.session.keys.includes(t2) && (await this.deleteSession({ topic: t2, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: t2 })) : e2 && (await this.deleteProposal(e2, true), this.client.events.emit("proposal_expire", { id: e2 })); }); } registerPairingEvents() { - this.client.core.pairing.events.on(V.create, (r2) => this.onPairingCreated(r2)); + this.client.core.pairing.events.on(V$1.create, (n4) => this.onPairingCreated(n4)), this.client.core.pairing.events.on(V$1.delete, (n4) => { + this.addToRecentlyDeleted(n4.topic, "pairing"); + }); } - isValidPairingTopic(r2) { - if (!g$3(r2, false)) { - const { message: e } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${r2}`); - throw new Error(e); + isValidPairingTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `pairing topic should be a string: ${n4}`); + throw new Error(t2); } - if (!this.client.core.pairing.pairings.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${r2}`); - throw new Error(e); + if (!this.client.core.pairing.pairings.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `pairing topic doesn't exist: ${n4}`); + throw new Error(t2); } - if (mt$1(this.client.core.pairing.pairings.get(r2).expiry)) { - const { message: e } = N$1("EXPIRED", `pairing topic: ${r2}`); - throw new Error(e); + if (p0(this.client.core.pairing.pairings.get(n4).expiry)) { + const { message: t2 } = xe("EXPIRED", `pairing topic: ${n4}`); + throw new Error(t2); } } - async isValidSessionTopic(r2) { - if (!g$3(r2, false)) { - const { message: e } = N$1("MISSING_OR_INVALID", `session topic should be a string: ${r2}`); - throw new Error(e); + async isValidSessionTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `session topic should be a string: ${n4}`); + throw new Error(t2); } - if (!this.client.session.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `session topic doesn't exist: ${r2}`); - throw new Error(e); + if (this.checkRecentlyDeleted(n4), !this.client.session.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `session topic doesn't exist: ${n4}`); + throw new Error(t2); } - if (mt$1(this.client.session.get(r2).expiry)) { - await this.deleteSession({ topic: r2 }); - const { message: e } = N$1("EXPIRED", `session topic: ${r2}`); - throw new Error(e); + if (p0(this.client.session.get(n4).expiry)) { + await this.deleteSession({ topic: n4 }); + const { message: t2 } = xe("EXPIRED", `session topic: ${n4}`); + throw new Error(t2); } - if (!this.client.core.crypto.keychain.has(r2)) { - const { message: e } = N$1("MISSING_OR_INVALID", `session topic does not exist in keychain: ${r2}`); - throw await this.deleteSession({ topic: r2 }), new Error(e); + if (!this.client.core.crypto.keychain.has(n4)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `session topic does not exist in keychain: ${n4}`); + throw await this.deleteSession({ topic: n4 }), new Error(t2); } } - async isValidSessionOrPairingTopic(r2) { - if (this.client.session.keys.includes(r2)) - await this.isValidSessionTopic(r2); - else if (this.client.core.pairing.pairings.keys.includes(r2)) - this.isValidPairingTopic(r2); - else if (g$3(r2, false)) { - const { message: e } = N$1("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${r2}`); - throw new Error(e); + async isValidSessionOrPairingTopic(n4) { + if (this.checkRecentlyDeleted(n4), this.client.session.keys.includes(n4)) + await this.isValidSessionTopic(n4); + else if (this.client.core.pairing.pairings.keys.includes(n4)) + this.isValidPairingTopic(n4); + else if (Gt$1(n4, false)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${n4}`); + throw new Error(t2); } else { - const { message: e } = N$1("MISSING_OR_INVALID", `session or pairing topic should be a string: ${r2}`); - throw new Error(e); - } - } - async isValidProposalId(r2) { - if (!Bt$1(r2)) { - const { message: e } = N$1("MISSING_OR_INVALID", `proposal id should be a number: ${r2}`); - throw new Error(e); - } - if (!this.client.proposal.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `proposal id doesn't exist: ${r2}`); - throw new Error(e); - } - if (mt$1(this.client.proposal.get(r2).expiryTimestamp)) { - await this.deleteProposal(r2); - const { message: e } = N$1("EXPIRED", `proposal id: ${r2}`); - throw new Error(e); - } - } -} -class us extends Kt { - constructor(r2, e) { - super(r2, e, oe, G), this.core = r2, this.logger = e; - } -} -class ge extends Kt { - constructor(r2, e) { - super(r2, e, ce, G), this.core = r2, this.logger = e; - } -} -class gs extends Kt { - constructor(r2, e) { - super(r2, e, pe, G, (s2) => s2.id), this.core = r2, this.logger = e; - } -} -class Q extends b$1 { - constructor(r2) { - super(r2), this.protocol = J, this.version = F, this.name = M.name, this.events = new eventsExports.EventEmitter(), this.on = (s2, t2) => this.events.on(s2, t2), this.once = (s2, t2) => this.events.once(s2, t2), this.off = (s2, t2) => this.events.off(s2, t2), this.removeListener = (s2, t2) => this.events.removeListener(s2, t2), this.removeAllListeners = (s2) => this.events.removeAllListeners(s2), this.connect = async (s2) => { - try { - return await this.engine.connect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.pair = async (s2) => { - try { - return await this.engine.pair(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.approve = async (s2) => { - try { - return await this.engine.approve(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.reject = async (s2) => { - try { - return await this.engine.reject(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.update = async (s2) => { - try { - return await this.engine.update(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.extend = async (s2) => { - try { - return await this.engine.extend(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.request = async (s2) => { - try { - return await this.engine.request(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.respond = async (s2) => { - try { - return await this.engine.respond(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.ping = async (s2) => { - try { - return await this.engine.ping(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.emit = async (s2) => { - try { - return await this.engine.emit(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.disconnect = async (s2) => { - try { - return await this.engine.disconnect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.find = (s2) => { - try { - return this.engine.find(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.getPendingSessionRequests = () => { - try { - return this.engine.getPendingSessionRequests(); - } catch (s2) { - throw this.logger.error(s2.message), s2; - } - }, this.name = (r2 == null ? void 0 : r2.name) || M.name, this.metadata = (r2 == null ? void 0 : r2.metadata) || Qn(); - const e = typeof (r2 == null ? void 0 : r2.logger) < "u" && typeof (r2 == null ? void 0 : r2.logger) != "string" ? r2.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (r2 == null ? void 0 : r2.logger) || M.logger })); - this.core = (r2 == null ? void 0 : r2.core) || new Mr(r2), this.logger = cjs$3.generateChildLogger(e, this.name), this.session = new ge(this.core, this.logger), this.proposal = new us(this.core, this.logger), this.pendingRequest = new gs(this.core, this.logger), this.engine = new ds(this); - } - static async init(r2) { - const e = new Q(r2); - return await e.initialize(), e; - } - get context() { - return cjs$3.getLoggerContext(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.engine.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); - } catch (r2) { - throw this.logger.info("SignClient Initialization Failure"), this.logger.error(r2.message), r2; - } - } -} -var P = Object.defineProperty, x = Object.defineProperties, N = Object.getOwnPropertyDescriptors, j = Object.getOwnPropertySymbols, U = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable, W = (e, t2, s2) => t2 in e ? P(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, q = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - U.call(t2, s2) && W(e, s2, t2[s2]); - if (j) - for (var s2 of j(t2)) - T.call(t2, s2) && W(e, s2, t2[s2]); - return e; -}, A = (e, t2) => x(e, N(t2)), S = (e, t2, s2) => { - if (!t2.has(e)) - throw TypeError("Cannot " + s2); -}, a2 = (e, t2, s2) => (S(e, t2, "read from private field"), s2 ? s2.call(e) : t2.get(e)), l = (e, t2, s2) => { - if (t2.has(e)) - throw TypeError("Cannot add the same private member more than once"); - t2 instanceof WeakSet ? t2.add(e) : t2.set(e, s2); -}, y2 = (e, t2, s2, d3) => (S(e, t2, "write to private field"), d3 ? d3.call(e, s2) : t2.set(e, s2), s2), o = (e, t2, s2) => (S(e, t2, "access private method"), s2), h3, p2, w2, i, u2, _2, n2, r, m, g2; -let z$1 = class z { - constructor(t2) { - l(this, u2), l(this, n2), l(this, m), l(this, h3, void 0), l(this, p2, void 0), l(this, w2, void 0), l(this, i, void 0), y2(this, h3, t2), y2(this, p2, o(this, u2, _2).call(this)), o(this, n2, r).call(this); - } - async connect(t2) { - const { requiredNamespaces: s2, optionalNamespaces: d3 } = t2; - return new Promise(async (C2, b3) => { - await o(this, n2, r).call(this); - const E2 = a2(this, p2).subscribeModal((c2) => { - c2.open || (E2(), b3(new Error("Modal closed"))); - }), { uri: O2, approval: I2 } = await a2(this, i).connect(t2); - if (O2) { - const c2 = /* @__PURE__ */ new Set(); - s2 && Object.values(s2).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), d3 && Object.values(d3).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), await a2(this, p2).openModal({ uri: O2, chains: Array.from(c2) }); - } - try { - const c2 = await I2(); - C2(c2); - } catch (c2) { - b3(c2); - } finally { - E2(), a2(this, p2).closeModal(); - } - }); - } - async disconnect(t2) { - await o(this, n2, r).call(this), await a2(this, i).disconnect(t2); - } - async request(t2) { - return await o(this, n2, r).call(this), await a2(this, i).request(t2); - } - async getSessions() { - return await o(this, n2, r).call(this), a2(this, i).session.getAll(); - } - async getSession() { - return await o(this, n2, r).call(this), a2(this, i).session.getAll().at(-1); - } - async onSessionEvent(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_event", t2); - } - async offSessionEvent(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_event", t2); - } - async onSessionUpdate(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_update", t2); - } - async offSessionUpdate(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_update", t2); - } - async onSessionDelete(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_delete", t2); - } - async offSessionDelete(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_delete", t2); - } - async onSessionExpire(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_expire", t2); - } - async offSessionExpire(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_expire", t2); - } -}; -h3 = /* @__PURE__ */ new WeakMap(), p2 = /* @__PURE__ */ new WeakMap(), w2 = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), u2 = /* @__PURE__ */ new WeakSet(), _2 = function() { - const { modalOptions: e, projectId: t2 } = a2(this, h3); - return new d$1(A(q({}, e), { projectId: t2 })); -}, n2 = /* @__PURE__ */ new WeakSet(), r = async function() { - return a2(this, i) ? true : (!a2(this, w2) && typeof window < "u" && y2(this, w2, o(this, m, g2).call(this)), a2(this, w2)); -}, m = /* @__PURE__ */ new WeakSet(), g2 = async function() { - y2(this, i, await Q.init({ metadata: a2(this, h3).metadata, projectId: a2(this, h3).projectId, relayUrl: a2(this, h3).relayUrl })); - const e = await a2(this, i).core.crypto.getClientId(); - try { - localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e); - } catch { - console.info("Unable to set client id"); - } -}; -const wc_aleo_methods$1 = [ - "decrypt", - "disconnect", - "getSelectedAccount", - "getBalance", - "getRecords", - "requestCreateEvent", - "getEvent", - "getEvents", - "createSharedState", - "importSharedState", - "requestSignature" -]; -const wc_aleo_chains$1 = ["aleo:1"]; -const wc_events$1 = [ - "chainChanged", - "accountSelected", - "selectedAccountSynced", - "sharedAccountSynced" -]; -const projectId$1 = "f0aaeffe71b636da453fce042d79d723"; -function isAndroid$1() { - if (!navigator) { - return false; - } - return /Android/i.test(navigator.userAgent); -} -const web3modal_puzzle_props_android$1 = { - projectId: projectId$1, - chains: ["aleo:3"], - enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png" - } -}; -const web3modal_puzzle_props_default$1 = { - projectId: projectId$1, - chains: wc_aleo_chains$1, - enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } - } - ], - desktopWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "", - universal: "https://walletconnect.puzzle.online/" - } - }, - { - id: "avail", - name: "Avail Wallet", - links: { - native: "avail://", - universal: "https://avail.global" - } + const { message: t2 } = xe("MISSING_OR_INVALID", `session or pairing topic should be a string: ${n4}`); + throw new Error(t2); } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png", - avail: "https://i.imgur.com/GxNn8BO.png" } -}; -const web3modal_puzzle_props$1 = isAndroid$1() ? web3modal_puzzle_props_android$1 : web3modal_puzzle_props_default$1; -const name$1 = "@puzzlehq/sdk-core"; -const displayName$1 = "Puzzle SDK"; -const version$1 = "0.3.1"; -const description$1 = "Your portal to privacy"; -const main$1 = "./dist/puzzle.cjs.js"; -const module$2 = "./dist/puzzle.es.js"; -const browser$1 = "./dist/puzzle.umd.js"; -const types$3 = "./dist/types/src/index.d.ts"; -const exports$2 = { - ".": { - "import": "./dist/puzzle.es.js", - require: "./dist/puzzle.cjs.js", - browser: "./dist/puzzle.umd.js", - types: "./dist/types/src/index.d.ts" + async isValidProposalId(n4) { + if (!Zu(n4)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `proposal id should be a number: ${n4}`); + throw new Error(t2); + } + if (!this.client.proposal.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `proposal id doesn't exist: ${n4}`); + throw new Error(t2); + } + if (p0(this.client.proposal.get(n4).expiryTimestamp)) { + await this.deleteProposal(n4); + const { message: t2 } = xe("EXPIRED", `proposal id: ${n4}`); + throw new Error(t2); + } } }; -const type$1 = "module"; -const scripts$1 = { - "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", - "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, - build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", - "type-check": "tsc --noEmit" -}; -const repository$1 = { - type: "git", - url: "git+https://github.com/puzzlehq/puzzle-sdk.git" -}; -const dependencies$1 = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", - "@walletconnect/types": "^2.11.2", - "@walletconnect/utils": "^2.11.2", - debug: "^4.3.4", - events: "^3.3.0", - ws: "^8.16.0" -}; -const peerDependencies$1 = { - buffer: "^6.0.3" -}; -const keywords$1 = [ - "puzzle", - "cryptocurrency wallet", - "privacy", - "aleo", - "web3", - "crypto", - "typescript" -]; -const author$1 = "Puzzle"; -const license$1 = "ISC"; -const bugs$1 = { - url: "https://github.com/puzzlehq/puzzle-sdk/issues" -}; -const homepage$1 = "https://github.com/puzzlehq/puzzle-sdk#readme"; -const pkg$1 = { - name: name$1, - displayName: displayName$1, - version: version$1, - description: description$1, - main: main$1, - module: module$2, - browser: browser$1, - types: types$3, - "private": false, - exports: exports$2, - type: type$1, - scripts: scripts$1, - repository: repository$1, - dependencies: dependencies$1, - peerDependencies: peerDependencies$1, - keywords: keywords$1, - author: author$1, - license: license$1, - bugs: bugs$1, - homepage: homepage$1 +let Zt$1 = class Zt extends Vt { + constructor(n4, t2) { + super(n4, t2, Ke, se$1), this.core = n4, this.logger = t2; + } }; -const emitter$1 = new EventEmitter$1(); -let connection = void 0; -async function configureConnection$1(options) { - let disconnectSessions = false; - const thisVersion = pkg$1.version; - const prevVersion = localStorage.getItem("puzzle_sdk_version"); - if (thisVersion !== prevVersion) { - console.log( - `${pkg$1.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" - ); - localStorage.setItem("puzzle_sdk_version", thisVersion); - disconnectSessions = true; +class We extends Vt { + constructor(n4, t2) { + super(n4, t2, Ge, se$1), this.core = n4, this.logger = t2; } - connection = new z$1({ - projectId: options.projectId ?? projectId$1, - metadata: { - name: options.dAppName, - description: options.dAppDescription, - url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", - icons: [options.dAppIconURL] - }, - modalOptions: { ...web3modal_puzzle_props$1 } - }); - if (disconnectSessions) { - localStorage.removeItem("puzzle-hasInjectedConnection"); - try { - disconnectOnVersionChange$1(connection, options.onDisconnect); - } catch (e) { - console.error(e); - } +} +class es2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Fe, se$1, (e2) => e2.id), this.core = n4, this.logger = t2; } - connection.onSessionDelete(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - connection.onSessionExpire(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); +} +class ts2 extends Vt { + constructor(n4, t2) { + super(n4, t2, He, X, () => J), this.core = n4, this.logger = t2; } - if (typeof window !== "undefined") { - window.puzzleSdkConnection = connection; +} +let ss$1 = class ss2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Ye, X), this.core = n4, this.logger = t2; + } +}; +class is2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Xe$1, X, (e2) => e2.id), this.core = n4, this.logger = t2; } - return connection; } -async function disconnectOnVersionChange$1(connection2, onDisconnect) { - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (session) { - console.log("Disconnecting session", session); - onDisconnect && onDisconnect(); - connection2.disconnect({ - topic: session.topic, - reason: U$2("USER_DISCONNECTED") - }); +class rs { + constructor(n4, t2) { + this.core = n4, this.logger = t2, this.authKeys = new ts2(this.core, this.logger), this.pairingTopics = new ss$1(this.core, this.logger), this.requests = new is2(this.core, this.logger); + } + async init() { + await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init(); } } -async function getWalletConnectModalSignClient$1() { - return new Promise((resolve) => { - if (connection) { - resolve(connection); - } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { - resolve(window.puzzleSdkConnection); - } else { - const interval = setInterval(() => { - if (connection) { - clearInterval(interval); - resolve(connection); +let ne$1 = class ne extends b$1 { + constructor(n4) { + super(n4), this.protocol = Se, this.version = Ee, this.name = ie$1.name, this.events = new eventsExports.EventEmitter(), this.on = (e2, s2) => this.events.on(e2, s2), this.once = (e2, s2) => this.events.once(e2, s2), this.off = (e2, s2) => this.events.off(e2, s2), this.removeListener = (e2, s2) => this.events.removeListener(e2, s2), this.removeAllListeners = (e2) => this.events.removeAllListeners(e2), this.connect = async (e2) => { + try { + return await this.engine.connect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.pair = async (e2) => { + try { + return await this.engine.pair(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approve = async (e2) => { + try { + return await this.engine.approve(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.reject = async (e2) => { + try { + return await this.engine.reject(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.update = async (e2) => { + try { + return await this.engine.update(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.extend = async (e2) => { + try { + return await this.engine.extend(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.request = async (e2) => { + try { + return await this.engine.request(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.respond = async (e2) => { + try { + return await this.engine.respond(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.ping = async (e2) => { + try { + return await this.engine.ping(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.emit = async (e2) => { + try { + return await this.engine.emit(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.disconnect = async (e2) => { + try { + return await this.engine.disconnect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.find = (e2) => { + try { + return this.engine.find(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.getPendingSessionRequests = () => { + try { + return this.engine.getPendingSessionRequests(); + } catch (e2) { + throw this.logger.error(e2.message), e2; + } + }, this.authenticate = async (e2) => { + try { + return await this.engine.authenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.formatAuthMessage = (e2) => { + try { + return this.engine.formatAuthMessage(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approveSessionAuthenticate = async (e2) => { + try { + return await this.engine.approveSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.rejectSessionAuthenticate = async (e2) => { + try { + return await this.engine.rejectSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.name = (n4 == null ? void 0 : n4.name) || ie$1.name, this.metadata = (n4 == null ? void 0 : n4.metadata) || Xo(); + const t2 = typeof (n4 == null ? void 0 : n4.logger) < "u" && typeof (n4 == null ? void 0 : n4.logger) != "string" ? n4.logger : nt$1(k$2({ level: (n4 == null ? void 0 : n4.logger) || ie$1.logger })); + this.core = (n4 == null ? void 0 : n4.core) || new Br(n4), this.logger = E$1(t2, this.name), this.session = new We(this.core, this.logger), this.proposal = new Zt$1(this.core, this.logger), this.pendingRequest = new es2(this.core, this.logger), this.engine = new Wt$1(this), this.auth = new rs(this.core, this.logger); + } + static async init(n4) { + const t2 = new ne(n4); + return await t2.initialize(), t2; + } + get context() { + return y$2(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.engine.init(), await this.auth.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); + } catch (n4) { + throw this.logger.info("SignClient Initialization Failure"), this.logger.error(n4.message), n4; + } + } +}; +var N = Object.defineProperty, T = Object.defineProperties, U = Object.getOwnPropertyDescriptors, I = Object.getOwnPropertySymbols, A = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable, M = (e2, t2, a3) => t2 in e2 ? N(e2, t2, { enumerable: true, configurable: true, writable: true, value: a3 }) : e2[t2] = a3, q = (e2, t2) => { + for (var a3 in t2 || (t2 = {})) + A.call(t2, a3) && M(e2, a3, t2[a3]); + if (I) + for (var a3 of I(t2)) + D.call(t2, a3) && M(e2, a3, t2[a3]); + return e2; +}, L$1 = (e2, t2) => T(e2, U(t2)), g2 = (e2, t2, a3) => { + if (!t2.has(e2)) + throw TypeError("Cannot " + a3); +}, s = (e2, t2, a3) => (g2(e2, t2, "read from private field"), a3 ? a3.call(e2) : t2.get(e2)), d4 = (e2, t2, a3) => { + if (t2.has(e2)) + throw TypeError("Cannot add the same private member more than once"); + t2 instanceof WeakSet ? t2.add(e2) : t2.set(e2, a3); +}, S = (e2, t2, a3, h4) => (g2(e2, t2, "write to private field"), t2.set(e2, a3), a3), n3 = (e2, t2, a3) => (g2(e2, t2, "access private method"), a3), w2, f2, u2, o, O2, k, r2, c, j$1, P; +class G { + constructor(t2) { + d4(this, O2), d4(this, r2), d4(this, j$1), d4(this, w2, void 0), d4(this, f2, void 0), d4(this, u2, void 0), d4(this, o, void 0), S(this, w2, t2), S(this, f2, n3(this, O2, k).call(this)), n3(this, r2, c).call(this); + } + async connect(t2, a3 = true) { + const { requiredNamespaces: h4, optionalNamespaces: y3 } = t2; + return new Promise(async (W2, E2) => { + var _3, C2; + if (await n3(this, r2, c).call(this), a3) { + const p2 = s(this, f2).subscribeModal((i2) => { + i2.open || (p2(), E2(new Error("Modal closed"))); + }), { uri: v3, approval: m3 } = await s(this, o).connect(t2); + if (v3) { + const i2 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), y3 && Object.values(y3).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), await s(this, f2).openModal({ uri: v3, chains: Array.from(i2) }); } - }, 200); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - }); -} -const checkForDesktopConnection$1 = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; + try { + const i2 = await m3(); + W2(i2); + } catch (i2) { + E2(i2); + } finally { + p2(), s(this, f2).closeModal(); + } + } else { + const { uri: p2, approval: v3 } = await s(this, o).connect(t2); + if (p2) { + const m3 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }), y3 && Object.values(y3).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }); + try { + if ((_3 = window == null ? void 0 : window.aleo) != null && _3.connectPuzzle) { + (C2 = window == null ? void 0 : window.aleo) == null || C2.connectPuzzle({ wc: { uri: p2 } }); + const i2 = await v3(); + W2(i2); + } else + throw new Error("window.aleo.connectPuzzle is undefined! Set showModal to true."); + } catch (i2) { + console.error(i2), E2(i2); + } + } + } + }); + } + async disconnect(t2) { + await n3(this, r2, c).call(this), await s(this, o).disconnect(t2); + } + async request(t2) { + return await n3(this, r2, c).call(this), await s(this, o).request(t2); } - try { - const res = await window.aleo.puzzleWalletClient.isConnected.query( - { sessionTopic } - ); - if (res) { - localStorage.setItem("puzzle-hasInjectedConnection", "true"); - return true; - } else { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - } catch (e) { - console.warn(e); - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; + async getSessions() { + return await n3(this, r2, c).call(this), s(this, o).session.getAll(); } -}; -const hasInjectedConnection$1 = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - return false; + async getSession() { + return await n3(this, r2, c).call(this), s(this, o).session.getAll().at(-1); + } + async onSessionEvent(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_event", t2); + } + async offSessionEvent(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_event", t2); + } + async onSessionUpdate(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_update", t2); + } + async offSessionUpdate(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_update", t2); + } + async onSessionDelete(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_delete", t2); + } + async offSessionDelete(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_delete", t2); + } + async onSessionExpire(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_expire", t2); + } + async offSessionExpire(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_expire", t2); + } +} +w2 = /* @__PURE__ */ new WeakMap(), f2 = /* @__PURE__ */ new WeakMap(), u2 = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), O2 = /* @__PURE__ */ new WeakSet(), k = function() { + const { modalOptions: e2, projectId: t2 } = s(this, w2); + return new d$3(L$1(q({}, e2), { projectId: t2 })); +}, r2 = /* @__PURE__ */ new WeakSet(), c = async function() { + return s(this, o) ? true : (!s(this, u2) && typeof window < "u" && S(this, u2, n3(this, j$1, P).call(this)), s(this, u2)); +}, j$1 = /* @__PURE__ */ new WeakSet(), P = async function() { + S(this, o, await ne$1.init({ metadata: s(this, w2).metadata, projectId: s(this, w2).projectId, relayUrl: s(this, w2).relayUrl })); + const e2 = await s(this, o).core.crypto.getClientId(); + try { + localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e2); + } catch { + console.info("Unable to set client id"); } - const puzzleHasDesktopConnection = localStorage.getItem( - "puzzle-hasInjectedConnection" - ); - return puzzleHasDesktopConnection === "true"; }; var util$1; (function(util2) { @@ -12886,8 +16469,8 @@ var util$1; return util2.objectValues(filtered); }; util2.objectValues = (obj) => { - return util2.objectKeys(obj).map(function(e) { - return obj[e]; + return util2.objectKeys(obj).map(function(e2) { + return obj[e2]; }); }; util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { @@ -13214,7 +16797,7 @@ const makeIssue$1 = (params) => { path: fullPath }; let errorMessage = ""; - const maps = errorMaps.filter((m2) => !!m2).slice().reverse(); + const maps = errorMaps.filter((m3) => !!m3).slice().reverse(); for (const map of maps) { errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; } @@ -13438,11 +17021,11 @@ let ZodType$1 = class ZodType { throw result.error; } safeParse(data, params) { - var _a; + var _a2; const ctx = { common: { issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap }, path: (params === null || params === void 0 ? void 0 : params.path) || [], @@ -13798,7 +17381,7 @@ let ZodString$1 = class ZodString extends ZodType$1 { } else if (check.kind === "url") { try { new URL(input.data); - } catch (_a) { + } catch (_a2) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { validation: "url", @@ -13913,7 +17496,7 @@ let ZodString$1 = class ZodString extends ZodType$1 { return this._addCheck({ kind: "ip", ...errorUtil$1.errToObj(options) }); } datetime(options) { - var _a; + var _a2; if (typeof options === "string") { return this._addCheck({ kind: "datetime", @@ -13925,7 +17508,7 @@ let ZodString$1 = class ZodString extends ZodType$1 { return this._addCheck({ kind: "datetime", precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, ...errorUtil$1.errToObj(options === null || options === void 0 ? void 0 : options.message) }); } @@ -13951,116 +17534,346 @@ let ZodString$1 = class ZodString extends ZodType$1 { ...errorUtil$1.errToObj(message) }); } - endsWith(value, message) { + endsWith(value, message) { + return this._addCheck({ + kind: "endsWith", + value, + ...errorUtil$1.errToObj(message) + }); + } + min(minLength, message) { + return this._addCheck({ + kind: "min", + value: minLength, + ...errorUtil$1.errToObj(message) + }); + } + max(maxLength, message) { + return this._addCheck({ + kind: "max", + value: maxLength, + ...errorUtil$1.errToObj(message) + }); + } + length(len, message) { + return this._addCheck({ + kind: "length", + value: len, + ...errorUtil$1.errToObj(message) + }); + } + get isDatetime() { + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); + } + get isEmail() { + return !!this._def.checks.find((ch2) => ch2.kind === "email"); + } + get isURL() { + return !!this._def.checks.find((ch2) => ch2.kind === "url"); + } + get isEmoji() { + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); + } + get isUUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); + } + get isCUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); + } + get isCUID2() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); + } + get isULID() { + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); + } + get isIP() { + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); + } + get minLength() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxLength() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } +}; +ZodString$1.create = (params) => { + var _a2; + return new ZodString$1({ + checks: [], + typeName: ZodFirstPartyTypeKind$1.ZodString, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams$1(params) + }); +}; +function floatSafeRemainder$1(val, step) { + const valDecCount = (val.toString().split(".")[1] || "").length; + const stepDecCount = (step.toString().split(".")[1] || "").length; + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; + const valInt = parseInt(val.toFixed(decCount).replace(".", "")); + const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); + return valInt % stepInt / Math.pow(10, decCount); +} +let ZodNumber$1 = class ZodNumber extends ZodType$1 { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + this.step = this.multipleOf; + } + _parse(input) { + if (this._def.coerce) { + input.data = Number(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.number) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext$1(ctx2, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.number, + received: ctx2.parsedType + }); + return INVALID$1; + } + let ctx = void 0; + const status = new ParseStatus$1(); + for (const check of this._def.checks) { + if (check.kind === "int") { + if (!util$1.isInteger(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: "integer", + received: "float", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_small, + minimum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + maximum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (floatSafeRemainder$1(input.data, check.value) !== 0) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "finite") { + if (!Number.isFinite(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.not_finite, + message: check.message + }); + status.dirty(); + } + } else { + util$1.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil$1.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil$1.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil$1.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil$1.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodNumber({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil$1.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodNumber({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + int(message) { + return this._addCheck({ + kind: "int", + message: errorUtil$1.toString(message) + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: false, + message: errorUtil$1.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: false, + message: errorUtil$1.toString(message) + }); + } + nonpositive(message) { return this._addCheck({ - kind: "endsWith", - value, - ...errorUtil$1.errToObj(message) + kind: "max", + value: 0, + inclusive: true, + message: errorUtil$1.toString(message) }); } - min(minLength, message) { + nonnegative(message) { return this._addCheck({ kind: "min", - value: minLength, - ...errorUtil$1.errToObj(message) + value: 0, + inclusive: true, + message: errorUtil$1.toString(message) }); } - max(maxLength, message) { + multipleOf(value, message) { return this._addCheck({ - kind: "max", - value: maxLength, - ...errorUtil$1.errToObj(message) + kind: "multipleOf", + value, + message: errorUtil$1.toString(message) }); } - length(len, message) { + finite(message) { return this._addCheck({ - kind: "length", - value: len, - ...errorUtil$1.errToObj(message) + kind: "finite", + message: errorUtil$1.toString(message) }); } - get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); - } - get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); - } - get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); - } - get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); - } - get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); - } - get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); - } - get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); - } - get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); - } - get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); + safe(message) { + return this._addCheck({ + kind: "min", + inclusive: true, + value: Number.MIN_SAFE_INTEGER, + message: errorUtil$1.toString(message) + })._addCheck({ + kind: "max", + inclusive: true, + value: Number.MAX_SAFE_INTEGER, + message: errorUtil$1.toString(message) + }); } - get minLength() { + get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } - get maxLength() { + get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } + get isInt() { + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util$1.isInteger(ch2.value)); + } + get isFinite() { + let max = null, min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { + return true; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return Number.isFinite(min) && Number.isFinite(max); + } }; -ZodString$1.create = (params) => { - var _a; - return new ZodString$1({ +ZodNumber$1.create = (params) => { + return new ZodNumber$1({ checks: [], - typeName: ZodFirstPartyTypeKind$1.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + typeName: ZodFirstPartyTypeKind$1.ZodNumber, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, ...processCreateParams$1(params) }); }; -function floatSafeRemainder$1(val, step) { - const valDecCount = (val.toString().split(".")[1] || "").length; - const stepDecCount = (step.toString().split(".")[1] || "").length; - const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; - const valInt = parseInt(val.toFixed(decCount).replace(".", "")); - const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); - return valInt % stepInt / Math.pow(10, decCount); -} -let ZodNumber$1 = class ZodNumber extends ZodType$1 { +let ZodBigInt$1 = class ZodBigInt extends ZodType$1 { constructor() { super(...arguments); this.min = this.gte; this.max = this.lte; - this.step = this.multipleOf; } _parse(input) { if (this._def.coerce) { - input.data = Number(input.data); + input.data = BigInt(input.data); } const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.number) { + if (parsedType !== ZodParsedType$1.bigint) { const ctx2 = this._getOrReturnCtx(input); addIssueToContext$1(ctx2, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.number, + expected: ZodParsedType$1.bigint, received: ctx2.parsedType }); return INVALID$1; @@ -14068,27 +17881,15 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { let ctx = void 0; const status = new ParseStatus$1(); for (const check of this._def.checks) { - if (check.kind === "int") { - if (!util$1.isInteger(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: "integer", - received: "float", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "min") { + if (check.kind === "min") { const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; if (tooSmall) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { code: ZodIssueCode$1.too_small, + type: "bigint", minimum: check.value, - type: "number", inclusive: check.inclusive, - exact: false, message: check.message }); status.dirty(); @@ -14099,16 +17900,15 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { code: ZodIssueCode$1.too_big, + type: "bigint", maximum: check.value, - type: "number", inclusive: check.inclusive, - exact: false, message: check.message }); status.dirty(); } } else if (check.kind === "multipleOf") { - if (floatSafeRemainder$1(input.data, check.value) !== 0) { + if (input.data % check.value !== BigInt(0)) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { code: ZodIssueCode$1.not_multiple_of, @@ -14117,15 +17917,6 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { }); status.dirty(); } - } else if (check.kind === "finite") { - if (!Number.isFinite(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.not_finite, - message: check.message - }); - status.dirty(); - } } else { util$1.assertNever(check); } @@ -14145,7 +17936,7 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { return this.setLimit("max", value, false, errorUtil$1.toString(message)); } setLimit(kind, value, inclusive, message) { - return new ZodNumber({ + return new ZodBigInt({ ...this._def, checks: [ ...this._def.checks, @@ -14155,2449 +17946,5763 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { inclusive, message: errorUtil$1.toString(message) } - ] - }); + ] + }); + } + _addCheck(check) { + return new ZodBigInt({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: false, + message: errorUtil$1.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: false, + message: errorUtil$1.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: true, + message: errorUtil$1.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: true, + message: errorUtil$1.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil$1.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } +}; +ZodBigInt$1.create = (params) => { + var _a2; + return new ZodBigInt$1({ + checks: [], + typeName: ZodFirstPartyTypeKind$1.ZodBigInt, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams$1(params) + }); +}; +let ZodBoolean$1 = class ZodBoolean extends ZodType$1 { + _parse(input) { + if (this._def.coerce) { + input.data = Boolean(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.boolean) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.boolean, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodBoolean$1.create = (params) => { + return new ZodBoolean$1({ + typeName: ZodFirstPartyTypeKind$1.ZodBoolean, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams$1(params) + }); +}; +let ZodDate$1 = class ZodDate extends ZodType$1 { + _parse(input) { + if (this._def.coerce) { + input.data = new Date(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.date) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext$1(ctx2, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.date, + received: ctx2.parsedType + }); + return INVALID$1; + } + if (isNaN(input.data.getTime())) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext$1(ctx2, { + code: ZodIssueCode$1.invalid_date + }); + return INVALID$1; + } + const status = new ParseStatus$1(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.getTime() < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_small, + message: check.message, + inclusive: true, + exact: false, + minimum: check.value, + type: "date" + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.getTime() > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + message: check.message, + inclusive: true, + exact: false, + maximum: check.value, + type: "date" + }); + status.dirty(); + } + } else { + util$1.assertNever(check); + } + } + return { + status: status.value, + value: new Date(input.data.getTime()) + }; } _addCheck(check) { - return new ZodNumber({ + return new ZodDate({ ...this._def, checks: [...this._def.checks, check] }); } - int(message) { - return this._addCheck({ - kind: "int", - message: errorUtil$1.toString(message) - }); - } - positive(message) { + min(minDate, message) { return this._addCheck({ kind: "min", - value: 0, - inclusive: false, + value: minDate.getTime(), message: errorUtil$1.toString(message) }); } - negative(message) { + max(maxDate, message) { return this._addCheck({ kind: "max", - value: 0, - inclusive: false, + value: maxDate.getTime(), message: errorUtil$1.toString(message) }); } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: 0, - inclusive: true, - message: errorUtil$1.toString(message) + get minDate() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min != null ? new Date(min) : null; + } + get maxDate() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max != null ? new Date(max) : null; + } +}; +ZodDate$1.create = (params) => { + return new ZodDate$1({ + checks: [], + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + typeName: ZodFirstPartyTypeKind$1.ZodDate, + ...processCreateParams$1(params) + }); +}; +let ZodSymbol$1 = class ZodSymbol extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.symbol) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.symbol, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodSymbol$1.create = (params) => { + return new ZodSymbol$1({ + typeName: ZodFirstPartyTypeKind$1.ZodSymbol, + ...processCreateParams$1(params) + }); +}; +let ZodUndefined$1 = class ZodUndefined extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.undefined, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodUndefined$1.create = (params) => { + return new ZodUndefined$1({ + typeName: ZodFirstPartyTypeKind$1.ZodUndefined, + ...processCreateParams$1(params) + }); +}; +let ZodNull$1 = class ZodNull extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.null) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.null, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodNull$1.create = (params) => { + return new ZodNull$1({ + typeName: ZodFirstPartyTypeKind$1.ZodNull, + ...processCreateParams$1(params) + }); +}; +let ZodAny$1 = class ZodAny extends ZodType$1 { + constructor() { + super(...arguments); + this._any = true; + } + _parse(input) { + return OK$1(input.data); + } +}; +ZodAny$1.create = (params) => { + return new ZodAny$1({ + typeName: ZodFirstPartyTypeKind$1.ZodAny, + ...processCreateParams$1(params) + }); +}; +let ZodUnknown$1 = class ZodUnknown extends ZodType$1 { + constructor() { + super(...arguments); + this._unknown = true; + } + _parse(input) { + return OK$1(input.data); + } +}; +ZodUnknown$1.create = (params) => { + return new ZodUnknown$1({ + typeName: ZodFirstPartyTypeKind$1.ZodUnknown, + ...processCreateParams$1(params) + }); +}; +let ZodNever$1 = class ZodNever extends ZodType$1 { + _parse(input) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.never, + received: ctx.parsedType + }); + return INVALID$1; + } +}; +ZodNever$1.create = (params) => { + return new ZodNever$1({ + typeName: ZodFirstPartyTypeKind$1.ZodNever, + ...processCreateParams$1(params) + }); +}; +let ZodVoid$1 = class ZodVoid extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.void, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodVoid$1.create = (params) => { + return new ZodVoid$1({ + typeName: ZodFirstPartyTypeKind$1.ZodVoid, + ...processCreateParams$1(params) + }); +}; +let ZodArray$1 = class ZodArray extends ZodType$1 { + _parse(input) { + const { ctx, status } = this._processInputParams(input); + const def = this._def; + if (ctx.parsedType !== ZodParsedType$1.array) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.array, + received: ctx.parsedType + }); + return INVALID$1; + } + if (def.exactLength !== null) { + const tooBig = ctx.data.length > def.exactLength.value; + const tooSmall = ctx.data.length < def.exactLength.value; + if (tooBig || tooSmall) { + addIssueToContext$1(ctx, { + code: tooBig ? ZodIssueCode$1.too_big : ZodIssueCode$1.too_small, + minimum: tooSmall ? def.exactLength.value : void 0, + maximum: tooBig ? def.exactLength.value : void 0, + type: "array", + inclusive: true, + exact: true, + message: def.exactLength.message + }); + status.dirty(); + } + } + if (def.minLength !== null) { + if (ctx.data.length < def.minLength.value) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_small, + minimum: def.minLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.minLength.message + }); + status.dirty(); + } + } + if (def.maxLength !== null) { + if (ctx.data.length > def.maxLength.value) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + maximum: def.maxLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.maxLength.message + }); + status.dirty(); + } + } + if (ctx.common.async) { + return Promise.all([...ctx.data].map((item, i2) => { + return def.type._parseAsync(new ParseInputLazyPath$1(ctx, item, ctx.path, i2)); + })).then((result2) => { + return ParseStatus$1.mergeArray(status, result2); + }); + } + const result = [...ctx.data].map((item, i2) => { + return def.type._parseSync(new ParseInputLazyPath$1(ctx, item, ctx.path, i2)); }); + return ParseStatus$1.mergeArray(status, result); } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: 0, - inclusive: true, - message: errorUtil$1.toString(message) - }); + get element() { + return this._def.type; } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil$1.toString(message) + min(minLength, message) { + return new ZodArray({ + ...this._def, + minLength: { value: minLength, message: errorUtil$1.toString(message) } }); } - finite(message) { - return this._addCheck({ - kind: "finite", - message: errorUtil$1.toString(message) + max(maxLength, message) { + return new ZodArray({ + ...this._def, + maxLength: { value: maxLength, message: errorUtil$1.toString(message) } }); } - safe(message) { - return this._addCheck({ - kind: "min", - inclusive: true, - value: Number.MIN_SAFE_INTEGER, - message: errorUtil$1.toString(message) - })._addCheck({ - kind: "max", - inclusive: true, - value: Number.MAX_SAFE_INTEGER, - message: errorUtil$1.toString(message) + length(len, message) { + return new ZodArray({ + ...this._def, + exactLength: { value: len, message: errorUtil$1.toString(message) } }); } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } - get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util$1.isInteger(ch.value)); - } - get isFinite() { - let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { - return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return Number.isFinite(min) && Number.isFinite(max); + nonempty(message) { + return this.min(1, message); } }; -ZodNumber$1.create = (params) => { - return new ZodNumber$1({ - checks: [], - typeName: ZodFirstPartyTypeKind$1.ZodNumber, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, +ZodArray$1.create = (schema, params) => { + return new ZodArray$1({ + type: schema, + minLength: null, + maxLength: null, + exactLength: null, + typeName: ZodFirstPartyTypeKind$1.ZodArray, ...processCreateParams$1(params) }); }; -let ZodBigInt$1 = class ZodBigInt extends ZodType$1 { +function deepPartialify$1(schema) { + if (schema instanceof ZodObject$1) { + const newShape = {}; + for (const key in schema.shape) { + const fieldSchema = schema.shape[key]; + newShape[key] = ZodOptional$1.create(deepPartialify$1(fieldSchema)); + } + return new ZodObject$1({ + ...schema._def, + shape: () => newShape + }); + } else if (schema instanceof ZodArray$1) { + return new ZodArray$1({ + ...schema._def, + type: deepPartialify$1(schema.element) + }); + } else if (schema instanceof ZodOptional$1) { + return ZodOptional$1.create(deepPartialify$1(schema.unwrap())); + } else if (schema instanceof ZodNullable$1) { + return ZodNullable$1.create(deepPartialify$1(schema.unwrap())); + } else if (schema instanceof ZodTuple$1) { + return ZodTuple$1.create(schema.items.map((item) => deepPartialify$1(item))); + } else { + return schema; + } +} +let ZodObject$1 = class ZodObject extends ZodType$1 { constructor() { super(...arguments); - this.min = this.gte; - this.max = this.lte; + this._cached = null; + this.nonstrict = this.passthrough; + this.augment = this.extend; + } + _getCached() { + if (this._cached !== null) + return this._cached; + const shape = this._def.shape(); + const keys2 = util$1.objectKeys(shape); + return this._cached = { shape, keys: keys2 }; } _parse(input) { - if (this._def.coerce) { - input.data = BigInt(input.data); - } const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.bigint) { + if (parsedType !== ZodParsedType$1.object) { const ctx2 = this._getOrReturnCtx(input); addIssueToContext$1(ctx2, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.bigint, + expected: ZodParsedType$1.object, received: ctx2.parsedType }); return INVALID$1; } - let ctx = void 0; - const status = new ParseStatus$1(); - for (const check of this._def.checks) { - if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - type: "bigint", - minimum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); + const { status, ctx } = this._processInputParams(input); + const { shape, keys: shapeKeys } = this._getCached(); + const extraKeys = []; + if (!(this._def.catchall instanceof ZodNever$1 && this._def.unknownKeys === "strip")) { + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - type: "bigint", - maximum: check.value, - inclusive: check.inclusive, - message: check.message + } + } + const pairs = []; + for (const key of shapeKeys) { + const keyValidator = shape[key]; + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: keyValidator._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, key)), + alwaysSet: key in ctx.data + }); + } + if (this._def.catchall instanceof ZodNever$1) { + const unknownKeys = this._def.unknownKeys; + if (unknownKeys === "passthrough") { + for (const key of extraKeys) { + pairs.push({ + key: { status: "valid", value: key }, + value: { status: "valid", value: ctx.data[key] } }); - status.dirty(); } - } else if (check.kind === "multipleOf") { - if (input.data % check.value !== BigInt(0)) { - ctx = this._getOrReturnCtx(input, ctx); + } else if (unknownKeys === "strict") { + if (extraKeys.length > 0) { addIssueToContext$1(ctx, { - code: ZodIssueCode$1.not_multiple_of, - multipleOf: check.value, - message: check.message + code: ZodIssueCode$1.unrecognized_keys, + keys: extraKeys }); status.dirty(); } - } else { - util$1.assertNever(check); + } else if (unknownKeys === "strip") + ; + else { + throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); + } + } else { + const catchall = this._def.catchall; + for (const key of extraKeys) { + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: catchall._parse( + new ParseInputLazyPath$1(ctx, value, ctx.path, key) + //, ctx.child(key), value, getParsedType(value) + ), + alwaysSet: key in ctx.data + }); } } - return { status: status.value, value: input.data }; - } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil$1.toString(message)); - } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil$1.toString(message)); + if (ctx.common.async) { + return Promise.resolve().then(async () => { + const syncPairs = []; + for (const pair of pairs) { + const key = await pair.key; + syncPairs.push({ + key, + value: await pair.value, + alwaysSet: pair.alwaysSet + }); + } + return syncPairs; + }).then((syncPairs) => { + return ParseStatus$1.mergeObjectSync(status, syncPairs); + }); + } else { + return ParseStatus$1.mergeObjectSync(status, pairs); + } } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil$1.toString(message)); + get shape() { + return this._def.shape(); } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil$1.toString(message)); + strict(message) { + errorUtil$1.errToObj; + return new ZodObject({ + ...this._def, + unknownKeys: "strict", + ...message !== void 0 ? { + errorMap: (issue, ctx) => { + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + if (issue.code === "unrecognized_keys") + return { + message: (_d = errorUtil$1.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError + }; + return { + message: defaultError + }; + } + } : {} + }); } - setLimit(kind, value, inclusive, message) { - return new ZodBigInt({ + strip() { + return new ZodObject({ ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil$1.toString(message) - } - ] + unknownKeys: "strip" }); } - _addCheck(check) { - return new ZodBigInt({ + passthrough() { + return new ZodObject({ ...this._def, - checks: [...this._def.checks, check] + unknownKeys: "passthrough" }); } - positive(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: false, - message: errorUtil$1.toString(message) + // const AugmentFactory = + // (def: Def) => + // ( + // augmentation: Augmentation + // ): ZodObject< + // extendShape, Augmentation>, + // Def["unknownKeys"], + // Def["catchall"] + // > => { + // return new ZodObject({ + // ...def, + // shape: () => ({ + // ...def.shape(), + // ...augmentation, + // }), + // }) as any; + // }; + extend(augmentation) { + return new ZodObject({ + ...this._def, + shape: () => ({ + ...this._def.shape(), + ...augmentation + }) }); } - negative(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: false, - message: errorUtil$1.toString(message) + /** + * Prior to zod@1.0.12 there was a bug in the + * inferred type of merged objects. Please + * upgrade if you are experiencing issues. + */ + merge(merging) { + const merged = new ZodObject({ + unknownKeys: merging._def.unknownKeys, + catchall: merging._def.catchall, + shape: () => ({ + ...this._def.shape(), + ...merging._def.shape() + }), + typeName: ZodFirstPartyTypeKind$1.ZodObject }); + return merged; } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: true, - message: errorUtil$1.toString(message) + // merge< + // Incoming extends AnyZodObject, + // Augmentation extends Incoming["shape"], + // NewOutput extends { + // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation + // ? Augmentation[k]["_output"] + // : k extends keyof Output + // ? Output[k] + // : never; + // }, + // NewInput extends { + // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation + // ? Augmentation[k]["_input"] + // : k extends keyof Input + // ? Input[k] + // : never; + // } + // >( + // merging: Incoming + // ): ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"], + // NewOutput, + // NewInput + // > { + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + setKey(key, schema) { + return this.augment({ [key]: schema }); + } + // merge( + // merging: Incoming + // ): //ZodObject = (merging) => { + // ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"] + // > { + // // const mergedShape = objectUtil.mergeShapes( + // // this._def.shape(), + // // merging._def.shape() + // // ); + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + catchall(index) { + return new ZodObject({ + ...this._def, + catchall: index }); } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: true, - message: errorUtil$1.toString(message) + pick(mask) { + const shape = {}; + util$1.objectKeys(mask).forEach((key) => { + if (mask[key] && this.shape[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ + ...this._def, + shape: () => shape }); } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil$1.toString(message) + omit(mask) { + const shape = {}; + util$1.objectKeys(this.shape).forEach((key) => { + if (!mask[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ + ...this._def, + shape: () => shape }); } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + /** + * @deprecated + */ + deepPartial() { + return deepPartialify$1(this); + } + partial(mask) { + const newShape = {}; + util$1.objectKeys(this.shape).forEach((key) => { + const fieldSchema = this.shape[key]; + if (mask && !mask[key]) { + newShape[key] = fieldSchema; + } else { + newShape[key] = fieldSchema.optional(); } - } - return min; + }); + return new ZodObject({ + ...this._def, + shape: () => newShape + }); } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + required(mask) { + const newShape = {}; + util$1.objectKeys(this.shape).forEach((key) => { + if (mask && !mask[key]) { + newShape[key] = this.shape[key]; + } else { + const fieldSchema = this.shape[key]; + let newField = fieldSchema; + while (newField instanceof ZodOptional$1) { + newField = newField._def.innerType; + } + newShape[key] = newField; } - } - return max; + }); + return new ZodObject({ + ...this._def, + shape: () => newShape + }); + } + keyof() { + return createZodEnum$1(util$1.objectKeys(this.shape)); } }; -ZodBigInt$1.create = (params) => { - var _a; - return new ZodBigInt$1({ - checks: [], - typeName: ZodFirstPartyTypeKind$1.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, +ZodObject$1.create = (shape, params) => { + return new ZodObject$1({ + shape: () => shape, + unknownKeys: "strip", + catchall: ZodNever$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodObject, ...processCreateParams$1(params) }); }; -let ZodBoolean$1 = class ZodBoolean extends ZodType$1 { +ZodObject$1.strictCreate = (shape, params) => { + return new ZodObject$1({ + shape: () => shape, + unknownKeys: "strict", + catchall: ZodNever$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodObject, + ...processCreateParams$1(params) + }); +}; +ZodObject$1.lazycreate = (shape, params) => { + return new ZodObject$1({ + shape, + unknownKeys: "strip", + catchall: ZodNever$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodObject, + ...processCreateParams$1(params) + }); +}; +let ZodUnion$1 = class ZodUnion extends ZodType$1 { _parse(input) { - if (this._def.coerce) { - input.data = Boolean(input.data); + const { ctx } = this._processInputParams(input); + const options = this._def.options; + function handleResults(results) { + for (const result of results) { + if (result.result.status === "valid") { + return result.result; + } + } + for (const result of results) { + if (result.result.status === "dirty") { + ctx.common.issues.push(...result.ctx.common.issues); + return result.result; + } + } + const unionErrors = results.map((result) => new ZodError$1(result.ctx.common.issues)); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_union, + unionErrors + }); + return INVALID$1; } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.boolean) { - const ctx = this._getOrReturnCtx(input); + if (ctx.common.async) { + return Promise.all(options.map(async (option) => { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + return { + result: await option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }), + ctx: childCtx + }; + })).then(handleResults); + } else { + let dirty = void 0; + const issues = []; + for (const option of options) { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + const result = option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }); + if (result.status === "valid") { + return result; + } else if (result.status === "dirty" && !dirty) { + dirty = { result, ctx: childCtx }; + } + if (childCtx.common.issues.length) { + issues.push(childCtx.common.issues); + } + } + if (dirty) { + ctx.common.issues.push(...dirty.ctx.common.issues); + return dirty.result; + } + const unionErrors = issues.map((issues2) => new ZodError$1(issues2)); addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.boolean, - received: ctx.parsedType + code: ZodIssueCode$1.invalid_union, + unionErrors }); return INVALID$1; } - return OK$1(input.data); + } + get options() { + return this._def.options; } }; -ZodBoolean$1.create = (params) => { - return new ZodBoolean$1({ - typeName: ZodFirstPartyTypeKind$1.ZodBoolean, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, +ZodUnion$1.create = (types2, params) => { + return new ZodUnion$1({ + options: types2, + typeName: ZodFirstPartyTypeKind$1.ZodUnion, ...processCreateParams$1(params) }); }; -let ZodDate$1 = class ZodDate extends ZodType$1 { +const getDiscriminator$1 = (type2) => { + if (type2 instanceof ZodLazy$1) { + return getDiscriminator$1(type2.schema); + } else if (type2 instanceof ZodEffects$1) { + return getDiscriminator$1(type2.innerType()); + } else if (type2 instanceof ZodLiteral$1) { + return [type2.value]; + } else if (type2 instanceof ZodEnum$1) { + return type2.options; + } else if (type2 instanceof ZodNativeEnum$1) { + return Object.keys(type2.enum); + } else if (type2 instanceof ZodDefault$1) { + return getDiscriminator$1(type2._def.innerType); + } else if (type2 instanceof ZodUndefined$1) { + return [void 0]; + } else if (type2 instanceof ZodNull$1) { + return [null]; + } else { + return null; + } +}; +let ZodDiscriminatedUnion$1 = class ZodDiscriminatedUnion extends ZodType$1 { _parse(input) { - if (this._def.coerce) { - input.data = new Date(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.date) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext$1(ctx2, { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.object) { + addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.date, - received: ctx2.parsedType + expected: ZodParsedType$1.object, + received: ctx.parsedType }); return INVALID$1; } - if (isNaN(input.data.getTime())) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext$1(ctx2, { - code: ZodIssueCode$1.invalid_date + const discriminator = this.discriminator; + const discriminatorValue = ctx.data[discriminator]; + const option = this.optionsMap.get(discriminatorValue); + if (!option) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_union_discriminator, + options: Array.from(this.optionsMap.keys()), + path: [discriminator] }); return INVALID$1; } - const status = new ParseStatus$1(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.getTime() < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - message: check.message, - inclusive: true, - exact: false, - minimum: check.value, - type: "date" - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.getTime() > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - message: check.message, - inclusive: true, - exact: false, - maximum: check.value, - type: "date" - }); - status.dirty(); - } - } else { - util$1.assertNever(check); - } + if (ctx.common.async) { + return option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } else { + return option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); } - return { - status: status.value, - value: new Date(input.data.getTime()) - }; } - _addCheck(check) { - return new ZodDate({ - ...this._def, - checks: [...this._def.checks, check] - }); + get discriminator() { + return this._def.discriminator; } - min(minDate, message) { - return this._addCheck({ - kind: "min", - value: minDate.getTime(), - message: errorUtil$1.toString(message) - }); + get options() { + return this._def.options; } - max(maxDate, message) { - return this._addCheck({ - kind: "max", - value: maxDate.getTime(), - message: errorUtil$1.toString(message) + get optionsMap() { + return this._def.optionsMap; + } + /** + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must + * have a different value for each object in the union. + * @param discriminator the name of the discriminator property + * @param types an array of object schemas + * @param params + */ + static create(discriminator, options, params) { + const optionsMap = /* @__PURE__ */ new Map(); + for (const type2 of options) { + const discriminatorValues = getDiscriminator$1(type2.shape[discriminator]); + if (!discriminatorValues) { + throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); + } + for (const value of discriminatorValues) { + if (optionsMap.has(value)) { + throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); + } + optionsMap.set(value, type2); + } + } + return new ZodDiscriminatedUnion({ + typeName: ZodFirstPartyTypeKind$1.ZodDiscriminatedUnion, + discriminator, + options, + optionsMap, + ...processCreateParams$1(params) }); } - get minDate() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; +}; +function mergeValues$1(a3, b3) { + const aType = getParsedType$1(a3); + const bType = getParsedType$1(b3); + if (a3 === b3) { + return { valid: true, data: a3 }; + } else if (aType === ZodParsedType$1.object && bType === ZodParsedType$1.object) { + const bKeys = util$1.objectKeys(b3); + const sharedKeys = util$1.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1); + const newObj = { ...a3, ...b3 }; + for (const key of sharedKeys) { + const sharedValue = mergeValues$1(a3[key], b3[key]); + if (!sharedValue.valid) { + return { valid: false }; } + newObj[key] = sharedValue.data; } - return min != null ? new Date(min) : null; + return { valid: true, data: newObj }; + } else if (aType === ZodParsedType$1.array && bType === ZodParsedType$1.array) { + if (a3.length !== b3.length) { + return { valid: false }; + } + const newArray = []; + for (let index = 0; index < a3.length; index++) { + const itemA = a3[index]; + const itemB = b3[index]; + const sharedValue = mergeValues$1(itemA, itemB); + if (!sharedValue.valid) { + return { valid: false }; + } + newArray.push(sharedValue.data); + } + return { valid: true, data: newArray }; + } else if (aType === ZodParsedType$1.date && bType === ZodParsedType$1.date && +a3 === +b3) { + return { valid: true, data: a3 }; + } else { + return { valid: false }; } - get maxDate() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; +} +let ZodIntersection$1 = class ZodIntersection extends ZodType$1 { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const handleParsed = (parsedLeft, parsedRight) => { + if (isAborted$1(parsedLeft) || isAborted$1(parsedRight)) { + return INVALID$1; } + const merged = mergeValues$1(parsedLeft.value, parsedRight.value); + if (!merged.valid) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_intersection_types + }); + return INVALID$1; + } + if (isDirty$1(parsedLeft) || isDirty$1(parsedRight)) { + status.dirty(); + } + return { status: status.value, value: merged.data }; + }; + if (ctx.common.async) { + return Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)); + } else { + return handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); } - return max != null ? new Date(max) : null; } }; -ZodDate$1.create = (params) => { - return new ZodDate$1({ - checks: [], - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - typeName: ZodFirstPartyTypeKind$1.ZodDate, +ZodIntersection$1.create = (left, right, params) => { + return new ZodIntersection$1({ + left, + right, + typeName: ZodFirstPartyTypeKind$1.ZodIntersection, ...processCreateParams$1(params) }); }; -let ZodSymbol$1 = class ZodSymbol extends ZodType$1 { +let ZodTuple$1 = class ZodTuple extends ZodType$1 { _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.symbol) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.array) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.symbol, + expected: ZodParsedType$1.array, received: ctx.parsedType }); return INVALID$1; } - return OK$1(input.data); - } -}; -ZodSymbol$1.create = (params) => { - return new ZodSymbol$1({ - typeName: ZodFirstPartyTypeKind$1.ZodSymbol, - ...processCreateParams$1(params) - }); -}; -let ZodUndefined$1 = class ZodUndefined extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.undefined) { - const ctx = this._getOrReturnCtx(input); + if (ctx.data.length < this._def.items.length) { addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.undefined, - received: ctx.parsedType + code: ZodIssueCode$1.too_small, + minimum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" }); return INVALID$1; } - return OK$1(input.data); + const rest = this._def.rest; + if (!rest && ctx.data.length > this._def.items.length) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + maximum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + status.dirty(); + } + const items = [...ctx.data].map((item, itemIndex) => { + const schema = this._def.items[itemIndex] || this._def.rest; + if (!schema) + return null; + return schema._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, itemIndex)); + }).filter((x2) => !!x2); + if (ctx.common.async) { + return Promise.all(items).then((results) => { + return ParseStatus$1.mergeArray(status, results); + }); + } else { + return ParseStatus$1.mergeArray(status, items); + } + } + get items() { + return this._def.items; + } + rest(rest) { + return new ZodTuple({ + ...this._def, + rest + }); } }; -ZodUndefined$1.create = (params) => { - return new ZodUndefined$1({ - typeName: ZodFirstPartyTypeKind$1.ZodUndefined, +ZodTuple$1.create = (schemas, params) => { + if (!Array.isArray(schemas)) { + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + } + return new ZodTuple$1({ + items: schemas, + typeName: ZodFirstPartyTypeKind$1.ZodTuple, + rest: null, ...processCreateParams$1(params) }); }; -let ZodNull$1 = class ZodNull extends ZodType$1 { +let ZodRecord$1 = class ZodRecord extends ZodType$1 { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.null) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.object) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.null, + expected: ZodParsedType$1.object, received: ctx.parsedType }); return INVALID$1; } - return OK$1(input.data); - } -}; -ZodNull$1.create = (params) => { - return new ZodNull$1({ - typeName: ZodFirstPartyTypeKind$1.ZodNull, - ...processCreateParams$1(params) - }); -}; -let ZodAny$1 = class ZodAny extends ZodType$1 { - constructor() { - super(...arguments); - this._any = true; - } - _parse(input) { - return OK$1(input.data); - } -}; -ZodAny$1.create = (params) => { - return new ZodAny$1({ - typeName: ZodFirstPartyTypeKind$1.ZodAny, - ...processCreateParams$1(params) - }); -}; -let ZodUnknown$1 = class ZodUnknown extends ZodType$1 { - constructor() { - super(...arguments); - this._unknown = true; + const pairs = []; + const keyType = this._def.keyType; + const valueType = this._def.valueType; + for (const key in ctx.data) { + pairs.push({ + key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath$1(ctx, ctx.data[key], ctx.path, key)) + }); + } + if (ctx.common.async) { + return ParseStatus$1.mergeObjectAsync(status, pairs); + } else { + return ParseStatus$1.mergeObjectSync(status, pairs); + } } - _parse(input) { - return OK$1(input.data); + get element() { + return this._def.valueType; } -}; -ZodUnknown$1.create = (params) => { - return new ZodUnknown$1({ - typeName: ZodFirstPartyTypeKind$1.ZodUnknown, - ...processCreateParams$1(params) - }); -}; -let ZodNever$1 = class ZodNever extends ZodType$1 { - _parse(input) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.never, - received: ctx.parsedType + static create(first, second, third) { + if (second instanceof ZodType$1) { + return new ZodRecord({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind$1.ZodRecord, + ...processCreateParams$1(third) + }); + } + return new ZodRecord({ + keyType: ZodString$1.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind$1.ZodRecord, + ...processCreateParams$1(second) }); - return INVALID$1; } }; -ZodNever$1.create = (params) => { - return new ZodNever$1({ - typeName: ZodFirstPartyTypeKind$1.ZodNever, - ...processCreateParams$1(params) - }); -}; -let ZodVoid$1 = class ZodVoid extends ZodType$1 { +let ZodMap$1 = class ZodMap extends ZodType$1 { _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.undefined) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.map) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.void, + expected: ZodParsedType$1.map, received: ctx.parsedType }); return INVALID$1; } - return OK$1(input.data); + const keyType = this._def.keyType; + const valueType = this._def.valueType; + const pairs = [...ctx.data.entries()].map(([key, value], index) => { + return { + key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, [index, "key"])), + value: valueType._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, [index, "value"])) + }; + }); + if (ctx.common.async) { + const finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (const pair of pairs) { + const key = await pair.key; + const value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID$1; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + const finalMap = /* @__PURE__ */ new Map(); + for (const pair of pairs) { + const key = pair.key; + const value = pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID$1; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } } }; -ZodVoid$1.create = (params) => { - return new ZodVoid$1({ - typeName: ZodFirstPartyTypeKind$1.ZodVoid, +ZodMap$1.create = (keyType, valueType, params) => { + return new ZodMap$1({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind$1.ZodMap, ...processCreateParams$1(params) }); }; -let ZodArray$1 = class ZodArray extends ZodType$1 { +let ZodSet$1 = class ZodSet extends ZodType$1 { _parse(input) { - const { ctx, status } = this._processInputParams(input); - const def = this._def; - if (ctx.parsedType !== ZodParsedType$1.array) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.set) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.array, + expected: ZodParsedType$1.set, received: ctx.parsedType }); return INVALID$1; } - if (def.exactLength !== null) { - const tooBig = ctx.data.length > def.exactLength.value; - const tooSmall = ctx.data.length < def.exactLength.value; - if (tooBig || tooSmall) { - addIssueToContext$1(ctx, { - code: tooBig ? ZodIssueCode$1.too_big : ZodIssueCode$1.too_small, - minimum: tooSmall ? def.exactLength.value : void 0, - maximum: tooBig ? def.exactLength.value : void 0, - type: "array", - inclusive: true, - exact: true, - message: def.exactLength.message - }); - status.dirty(); - } - } - if (def.minLength !== null) { - if (ctx.data.length < def.minLength.value) { + const def = this._def; + if (def.minSize !== null) { + if (ctx.data.size < def.minSize.value) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.too_small, - minimum: def.minLength.value, - type: "array", + minimum: def.minSize.value, + type: "set", inclusive: true, exact: false, - message: def.minLength.message + message: def.minSize.message }); status.dirty(); } } - if (def.maxLength !== null) { - if (ctx.data.length > def.maxLength.value) { + if (def.maxSize !== null) { + if (ctx.data.size > def.maxSize.value) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.too_big, - maximum: def.maxLength.value, - type: "array", + maximum: def.maxSize.value, + type: "set", inclusive: true, exact: false, - message: def.maxLength.message + message: def.maxSize.message }); status.dirty(); } } - if (ctx.common.async) { - return Promise.all([...ctx.data].map((item, i2) => { - return def.type._parseAsync(new ParseInputLazyPath$1(ctx, item, ctx.path, i2)); - })).then((result2) => { - return ParseStatus$1.mergeArray(status, result2); - }); - } - const result = [...ctx.data].map((item, i2) => { - return def.type._parseSync(new ParseInputLazyPath$1(ctx, item, ctx.path, i2)); - }); - return ParseStatus$1.mergeArray(status, result); - } - get element() { - return this._def.type; - } - min(minLength, message) { - return new ZodArray({ - ...this._def, - minLength: { value: minLength, message: errorUtil$1.toString(message) } - }); - } - max(maxLength, message) { - return new ZodArray({ - ...this._def, - maxLength: { value: maxLength, message: errorUtil$1.toString(message) } - }); - } - length(len, message) { - return new ZodArray({ - ...this._def, - exactLength: { value: len, message: errorUtil$1.toString(message) } - }); - } - nonempty(message) { - return this.min(1, message); - } -}; -ZodArray$1.create = (schema, params) => { - return new ZodArray$1({ - type: schema, - minLength: null, - maxLength: null, - exactLength: null, - typeName: ZodFirstPartyTypeKind$1.ZodArray, - ...processCreateParams$1(params) - }); -}; -function deepPartialify$1(schema) { - if (schema instanceof ZodObject$1) { - const newShape = {}; - for (const key in schema.shape) { - const fieldSchema = schema.shape[key]; - newShape[key] = ZodOptional$1.create(deepPartialify$1(fieldSchema)); - } - return new ZodObject$1({ - ...schema._def, - shape: () => newShape - }); - } else if (schema instanceof ZodArray$1) { - return new ZodArray$1({ - ...schema._def, - type: deepPartialify$1(schema.element) - }); - } else if (schema instanceof ZodOptional$1) { - return ZodOptional$1.create(deepPartialify$1(schema.unwrap())); - } else if (schema instanceof ZodNullable$1) { - return ZodNullable$1.create(deepPartialify$1(schema.unwrap())); - } else if (schema instanceof ZodTuple$1) { - return ZodTuple$1.create(schema.items.map((item) => deepPartialify$1(item))); - } else { - return schema; - } -} -let ZodObject$1 = class ZodObject extends ZodType$1 { - constructor() { - super(...arguments); - this._cached = null; - this.nonstrict = this.passthrough; - this.augment = this.extend; - } - _getCached() { - if (this._cached !== null) - return this._cached; - const shape = this._def.shape(); - const keys2 = util$1.objectKeys(shape); - return this._cached = { shape, keys: keys2 }; - } - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.object) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext$1(ctx2, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.object, - received: ctx2.parsedType - }); - return INVALID$1; - } - const { status, ctx } = this._processInputParams(input); - const { shape, keys: shapeKeys } = this._getCached(); - const extraKeys = []; - if (!(this._def.catchall instanceof ZodNever$1 && this._def.unknownKeys === "strip")) { - for (const key in ctx.data) { - if (!shapeKeys.includes(key)) { - extraKeys.push(key); - } - } - } - const pairs = []; - for (const key of shapeKeys) { - const keyValidator = shape[key]; - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: keyValidator._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, key)), - alwaysSet: key in ctx.data - }); - } - if (this._def.catchall instanceof ZodNever$1) { - const unknownKeys = this._def.unknownKeys; - if (unknownKeys === "passthrough") { - for (const key of extraKeys) { - pairs.push({ - key: { status: "valid", value: key }, - value: { status: "valid", value: ctx.data[key] } - }); - } - } else if (unknownKeys === "strict") { - if (extraKeys.length > 0) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.unrecognized_keys, - keys: extraKeys - }); - status.dirty(); - } - } else if (unknownKeys === "strip") - ; - else { - throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); - } - } else { - const catchall = this._def.catchall; - for (const key of extraKeys) { - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: catchall._parse( - new ParseInputLazyPath$1(ctx, value, ctx.path, key) - //, ctx.child(key), value, getParsedType(value) - ), - alwaysSet: key in ctx.data - }); + const valueType = this._def.valueType; + function finalizeSet(elements2) { + const parsedSet = /* @__PURE__ */ new Set(); + for (const element of elements2) { + if (element.status === "aborted") + return INVALID$1; + if (element.status === "dirty") + status.dirty(); + parsedSet.add(element.value); } + return { status: status.value, value: parsedSet }; } + const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, i2))); if (ctx.common.async) { - return Promise.resolve().then(async () => { - const syncPairs = []; - for (const pair of pairs) { - const key = await pair.key; - syncPairs.push({ - key, - value: await pair.value, - alwaysSet: pair.alwaysSet - }); - } - return syncPairs; - }).then((syncPairs) => { - return ParseStatus$1.mergeObjectSync(status, syncPairs); - }); + return Promise.all(elements).then((elements2) => finalizeSet(elements2)); } else { - return ParseStatus$1.mergeObjectSync(status, pairs); + return finalizeSet(elements); } } - get shape() { - return this._def.shape(); - } - strict(message) { - errorUtil$1.errToObj; - return new ZodObject({ + min(minSize, message) { + return new ZodSet({ ...this._def, - unknownKeys: "strict", - ...message !== void 0 ? { - errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; - if (issue.code === "unrecognized_keys") - return { - message: (_d = errorUtil$1.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError - }; - return { - message: defaultError - }; - } - } : {} + minSize: { value: minSize, message: errorUtil$1.toString(message) } }); } - strip() { - return new ZodObject({ + max(maxSize, message) { + return new ZodSet({ ...this._def, - unknownKeys: "strip" + maxSize: { value: maxSize, message: errorUtil$1.toString(message) } }); } - passthrough() { - return new ZodObject({ - ...this._def, - unknownKeys: "passthrough" - }); + size(size, message) { + return this.min(size, message).max(size, message); } - // const AugmentFactory = - // (def: Def) => - // ( - // augmentation: Augmentation - // ): ZodObject< - // extendShape, Augmentation>, - // Def["unknownKeys"], - // Def["catchall"] - // > => { - // return new ZodObject({ - // ...def, - // shape: () => ({ - // ...def.shape(), - // ...augmentation, - // }), - // }) as any; - // }; - extend(augmentation) { - return new ZodObject({ - ...this._def, - shape: () => ({ - ...this._def.shape(), - ...augmentation - }) - }); + nonempty(message) { + return this.min(1, message); } - /** - * Prior to zod@1.0.12 there was a bug in the - * inferred type of merged objects. Please - * upgrade if you are experiencing issues. - */ - merge(merging) { - const merged = new ZodObject({ - unknownKeys: merging._def.unknownKeys, - catchall: merging._def.catchall, - shape: () => ({ - ...this._def.shape(), - ...merging._def.shape() - }), - typeName: ZodFirstPartyTypeKind$1.ZodObject - }); - return merged; +}; +ZodSet$1.create = (valueType, params) => { + return new ZodSet$1({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind$1.ZodSet, + ...processCreateParams$1(params) + }); +}; +let ZodFunction$1 = class ZodFunction extends ZodType$1 { + constructor() { + super(...arguments); + this.validate = this.implement; } - // merge< - // Incoming extends AnyZodObject, - // Augmentation extends Incoming["shape"], - // NewOutput extends { - // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation - // ? Augmentation[k]["_output"] - // : k extends keyof Output - // ? Output[k] - // : never; - // }, - // NewInput extends { - // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation - // ? Augmentation[k]["_input"] - // : k extends keyof Input - // ? Input[k] - // : never; - // } - // >( - // merging: Incoming - // ): ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"], - // NewOutput, - // NewInput - // > { - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - setKey(key, schema) { - return this.augment({ [key]: schema }); + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.function) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.function, + received: ctx.parsedType + }); + return INVALID$1; + } + function makeArgsIssue(args, error) { + return makeIssue$1({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap$1(), + errorMap$1 + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode$1.invalid_arguments, + argumentsError: error + } + }); + } + function makeReturnsIssue(returns, error) { + return makeIssue$1({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap$1(), + errorMap$1 + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode$1.invalid_return_type, + returnTypeError: error + } + }); + } + const params = { errorMap: ctx.common.contextualErrorMap }; + const fn = ctx.data; + if (this._def.returns instanceof ZodPromise$1) { + return OK$1(async (...args) => { + const error = new ZodError$1([]); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { + error.addIssue(makeArgsIssue(args, e2)); + throw error; + }); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { + error.addIssue(makeReturnsIssue(result, e2)); + throw error; + }); + return parsedReturns; + }); + } else { + return OK$1((...args) => { + const parsedArgs = this._def.args.safeParse(args, params); + if (!parsedArgs.success) { + throw new ZodError$1([makeArgsIssue(args, parsedArgs.error)]); + } + const result = fn(...parsedArgs.data); + const parsedReturns = this._def.returns.safeParse(result, params); + if (!parsedReturns.success) { + throw new ZodError$1([makeReturnsIssue(result, parsedReturns.error)]); + } + return parsedReturns.data; + }); + } } - // merge( - // merging: Incoming - // ): //ZodObject = (merging) => { - // ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"] - // > { - // // const mergedShape = objectUtil.mergeShapes( - // // this._def.shape(), - // // merging._def.shape() - // // ); - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - catchall(index) { - return new ZodObject({ - ...this._def, - catchall: index - }); + parameters() { + return this._def.args; } - pick(mask) { - const shape = {}; - util$1.objectKeys(mask).forEach((key) => { - if (mask[key] && this.shape[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ + returnType() { + return this._def.returns; + } + args(...items) { + return new ZodFunction({ ...this._def, - shape: () => shape + args: ZodTuple$1.create(items).rest(ZodUnknown$1.create()) }); } - omit(mask) { - const shape = {}; - util$1.objectKeys(this.shape).forEach((key) => { - if (!mask[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ + returns(returnType) { + return new ZodFunction({ ...this._def, - shape: () => shape + returns: returnType }); } - /** - * @deprecated - */ - deepPartial() { - return deepPartialify$1(this); + implement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; } - partial(mask) { - const newShape = {}; - util$1.objectKeys(this.shape).forEach((key) => { - const fieldSchema = this.shape[key]; - if (mask && !mask[key]) { - newShape[key] = fieldSchema; - } else { - newShape[key] = fieldSchema.optional(); - } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape - }); + strictImplement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; } - required(mask) { - const newShape = {}; - util$1.objectKeys(this.shape).forEach((key) => { - if (mask && !mask[key]) { - newShape[key] = this.shape[key]; - } else { - const fieldSchema = this.shape[key]; - let newField = fieldSchema; - while (newField instanceof ZodOptional$1) { - newField = newField._def.innerType; - } - newShape[key] = newField; - } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape + static create(args, returns, params) { + return new ZodFunction({ + args: args ? args : ZodTuple$1.create([]).rest(ZodUnknown$1.create()), + returns: returns || ZodUnknown$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodFunction, + ...processCreateParams$1(params) }); } - keyof() { - return createZodEnum$1(util$1.objectKeys(this.shape)); +}; +let ZodLazy$1 = class ZodLazy extends ZodType$1 { + get schema() { + return this._def.getter(); + } + _parse(input) { + const { ctx } = this._processInputParams(input); + const lazySchema = this._def.getter(); + return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); } }; -ZodObject$1.create = (shape, params) => { - return new ZodObject$1({ - shape: () => shape, - unknownKeys: "strip", - catchall: ZodNever$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodObject, +ZodLazy$1.create = (getter, params) => { + return new ZodLazy$1({ + getter, + typeName: ZodFirstPartyTypeKind$1.ZodLazy, ...processCreateParams$1(params) }); }; -ZodObject$1.strictCreate = (shape, params) => { - return new ZodObject$1({ - shape: () => shape, - unknownKeys: "strict", - catchall: ZodNever$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodObject, +let ZodLiteral$1 = class ZodLiteral extends ZodType$1 { + _parse(input) { + if (input.data !== this._def.value) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + received: ctx.data, + code: ZodIssueCode$1.invalid_literal, + expected: this._def.value + }); + return INVALID$1; + } + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } +}; +ZodLiteral$1.create = (value, params) => { + return new ZodLiteral$1({ + value, + typeName: ZodFirstPartyTypeKind$1.ZodLiteral, ...processCreateParams$1(params) }); }; -ZodObject$1.lazycreate = (shape, params) => { - return new ZodObject$1({ - shape, - unknownKeys: "strip", - catchall: ZodNever$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodObject, +function createZodEnum$1(values, params) { + return new ZodEnum$1({ + values, + typeName: ZodFirstPartyTypeKind$1.ZodEnum, ...processCreateParams$1(params) }); +} +let ZodEnum$1 = class ZodEnum extends ZodType$1 { + _parse(input) { + if (typeof input.data !== "string") { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext$1(ctx, { + expected: util$1.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode$1.invalid_type + }); + return INVALID$1; + } + if (this._def.values.indexOf(input.data) === -1) { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext$1(ctx, { + received: ctx.data, + code: ZodIssueCode$1.invalid_enum_value, + options: expectedValues + }); + return INVALID$1; + } + return OK$1(input.data); + } + get options() { + return this._def.values; + } + get enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Values() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + extract(values) { + return ZodEnum.create(values); + } + exclude(values) { + return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + } }; -let ZodUnion$1 = class ZodUnion extends ZodType$1 { +ZodEnum$1.create = createZodEnum$1; +let ZodNativeEnum$1 = class ZodNativeEnum extends ZodType$1 { _parse(input) { - const { ctx } = this._processInputParams(input); - const options = this._def.options; - function handleResults(results) { - for (const result of results) { - if (result.result.status === "valid") { - return result.result; - } - } - for (const result of results) { - if (result.result.status === "dirty") { - ctx.common.issues.push(...result.ctx.common.issues); - return result.result; - } - } - const unionErrors = results.map((result) => new ZodError$1(result.ctx.common.issues)); + const nativeEnumValues = util$1.getValidEnumValues(this._def.values); + const ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType$1.string && ctx.parsedType !== ZodParsedType$1.number) { + const expectedValues = util$1.objectValues(nativeEnumValues); addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_union, - unionErrors + expected: util$1.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode$1.invalid_type }); return INVALID$1; } - if (ctx.common.async) { - return Promise.all(options.map(async (option) => { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - return { - result: await option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }), - ctx: childCtx - }; - })).then(handleResults); - } else { - let dirty = void 0; - const issues = []; - for (const option of options) { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - const result = option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }); - if (result.status === "valid") { - return result; - } else if (result.status === "dirty" && !dirty) { - dirty = { result, ctx: childCtx }; - } - if (childCtx.common.issues.length) { - issues.push(childCtx.common.issues); - } - } - if (dirty) { - ctx.common.issues.push(...dirty.ctx.common.issues); - return dirty.result; - } - const unionErrors = issues.map((issues2) => new ZodError$1(issues2)); + if (nativeEnumValues.indexOf(input.data) === -1) { + const expectedValues = util$1.objectValues(nativeEnumValues); addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_union, - unionErrors + received: ctx.data, + code: ZodIssueCode$1.invalid_enum_value, + options: expectedValues }); return INVALID$1; } + return OK$1(input.data); } - get options() { - return this._def.options; + get enum() { + return this._def.values; } }; -ZodUnion$1.create = (types2, params) => { - return new ZodUnion$1({ - options: types2, - typeName: ZodFirstPartyTypeKind$1.ZodUnion, +ZodNativeEnum$1.create = (values, params) => { + return new ZodNativeEnum$1({ + values, + typeName: ZodFirstPartyTypeKind$1.ZodNativeEnum, ...processCreateParams$1(params) }); }; -const getDiscriminator$1 = (type2) => { - if (type2 instanceof ZodLazy$1) { - return getDiscriminator$1(type2.schema); - } else if (type2 instanceof ZodEffects$1) { - return getDiscriminator$1(type2.innerType()); - } else if (type2 instanceof ZodLiteral$1) { - return [type2.value]; - } else if (type2 instanceof ZodEnum$1) { - return type2.options; - } else if (type2 instanceof ZodNativeEnum$1) { - return Object.keys(type2.enum); - } else if (type2 instanceof ZodDefault$1) { - return getDiscriminator$1(type2._def.innerType); - } else if (type2 instanceof ZodUndefined$1) { - return [void 0]; - } else if (type2 instanceof ZodNull$1) { - return [null]; - } else { - return null; +let ZodPromise$1 = class ZodPromise extends ZodType$1 { + unwrap() { + return this._def.type; } -}; -let ZodDiscriminatedUnion$1 = class ZodDiscriminatedUnion extends ZodType$1 { _parse(input) { const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.object) { + if (ctx.parsedType !== ZodParsedType$1.promise && ctx.common.async === false) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.object, + expected: ZodParsedType$1.promise, received: ctx.parsedType }); return INVALID$1; } - const discriminator = this.discriminator; - const discriminatorValue = ctx.data[discriminator]; - const option = this.optionsMap.get(discriminatorValue); - if (!option) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_union_discriminator, - options: Array.from(this.optionsMap.keys()), - path: [discriminator] - }); - return INVALID$1; - } - if (ctx.common.async) { - return option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } else { - return option._parseSync({ - data: ctx.data, + const promisified = ctx.parsedType === ZodParsedType$1.promise ? ctx.data : Promise.resolve(ctx.data); + return OK$1(promisified.then((data) => { + return this._def.type.parseAsync(data, { path: ctx.path, - parent: ctx + errorMap: ctx.common.contextualErrorMap }); - } - } - get discriminator() { - return this._def.discriminator; - } - get options() { - return this._def.options; - } - get optionsMap() { - return this._def.optionsMap; - } - /** - * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. - * However, it only allows a union of objects, all of which need to share a discriminator property. This property must - * have a different value for each object in the union. - * @param discriminator the name of the discriminator property - * @param types an array of object schemas - * @param params - */ - static create(discriminator, options, params) { - const optionsMap = /* @__PURE__ */ new Map(); - for (const type2 of options) { - const discriminatorValues = getDiscriminator$1(type2.shape[discriminator]); - if (!discriminatorValues) { - throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); - } - for (const value of discriminatorValues) { - if (optionsMap.has(value)) { - throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); - } - optionsMap.set(value, type2); - } - } - return new ZodDiscriminatedUnion({ - typeName: ZodFirstPartyTypeKind$1.ZodDiscriminatedUnion, - discriminator, - options, - optionsMap, - ...processCreateParams$1(params) - }); + })); } }; -function mergeValues$1(a3, b3) { - const aType = getParsedType$1(a3); - const bType = getParsedType$1(b3); - if (a3 === b3) { - return { valid: true, data: a3 }; - } else if (aType === ZodParsedType$1.object && bType === ZodParsedType$1.object) { - const bKeys = util$1.objectKeys(b3); - const sharedKeys = util$1.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1); - const newObj = { ...a3, ...b3 }; - for (const key of sharedKeys) { - const sharedValue = mergeValues$1(a3[key], b3[key]); - if (!sharedValue.valid) { - return { valid: false }; - } - newObj[key] = sharedValue.data; - } - return { valid: true, data: newObj }; - } else if (aType === ZodParsedType$1.array && bType === ZodParsedType$1.array) { - if (a3.length !== b3.length) { - return { valid: false }; - } - const newArray = []; - for (let index = 0; index < a3.length; index++) { - const itemA = a3[index]; - const itemB = b3[index]; - const sharedValue = mergeValues$1(itemA, itemB); - if (!sharedValue.valid) { - return { valid: false }; - } - newArray.push(sharedValue.data); - } - return { valid: true, data: newArray }; - } else if (aType === ZodParsedType$1.date && bType === ZodParsedType$1.date && +a3 === +b3) { - return { valid: true, data: a3 }; - } else { - return { valid: false }; +ZodPromise$1.create = (schema, params) => { + return new ZodPromise$1({ + type: schema, + typeName: ZodFirstPartyTypeKind$1.ZodPromise, + ...processCreateParams$1(params) + }); +}; +let ZodEffects$1 = class ZodEffects extends ZodType$1 { + innerType() { + return this._def.schema; + } + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind$1.ZodEffects ? this._def.schema.sourceType() : this._def.schema; } -} -let ZodIntersection$1 = class ZodIntersection extends ZodType$1 { _parse(input) { const { status, ctx } = this._processInputParams(input); - const handleParsed = (parsedLeft, parsedRight) => { - if (isAborted$1(parsedLeft) || isAborted$1(parsedRight)) { - return INVALID$1; - } - const merged = mergeValues$1(parsedLeft.value, parsedRight.value); - if (!merged.valid) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_intersection_types + const effect = this._def.effect || null; + if (effect.type === "preprocess") { + const processed = effect.transform(ctx.data); + if (ctx.common.async) { + return Promise.resolve(processed).then((processed2) => { + return this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + }); + }); + } else { + return this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx }); - return INVALID$1; } - if (isDirty$1(parsedLeft) || isDirty$1(parsedRight)) { - status.dirty(); + } + const checkCtx = { + addIssue: (arg) => { + addIssueToContext$1(ctx, arg); + if (arg.fatal) { + status.abort(); + } else { + status.dirty(); + } + }, + get path() { + return ctx.path; } - return { status: status.value, value: merged.data }; }; - if (ctx.common.async) { - return Promise.all([ - this._def.left._parseAsync({ + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); + if (effect.type === "refinement") { + const executeRefinement = (acc) => { + const result = effect.refinement(acc, checkCtx); + if (ctx.common.async) { + return Promise.resolve(result); + } + if (result instanceof Promise) { + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + } + return acc; + }; + if (ctx.common.async === false) { + const inner = this._def.schema._parseSync({ data: ctx.data, path: ctx.path, parent: ctx - }), - this._def.right._parseAsync({ + }); + if (inner.status === "aborted") + return INVALID$1; + if (inner.status === "dirty") + status.dirty(); + executeRefinement(inner.value); + return { status: status.value, value: inner.value }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { + if (inner.status === "aborted") + return INVALID$1; + if (inner.status === "dirty") + status.dirty(); + return executeRefinement(inner.value).then(() => { + return { status: status.value, value: inner.value }; + }); + }); + } + } + if (effect.type === "transform") { + if (ctx.common.async === false) { + const base3 = this._def.schema._parseSync({ data: ctx.data, - path: ctx.path, - parent: ctx - }) - ]).then(([left, right]) => handleParsed(left, right)); - } else { - return handleParsed(this._def.left._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), this._def.right._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - })); + path: ctx.path, + parent: ctx + }); + if (!isValid$1(base3)) + return base3; + const result = effect.transform(base3.value, checkCtx); + if (result instanceof Promise) { + throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + } + return { status: status.value, value: result }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { + if (!isValid$1(base3)) + return base3; + return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); + }); + } } + util$1.assertNever(effect); } }; -ZodIntersection$1.create = (left, right, params) => { - return new ZodIntersection$1({ - left, - right, - typeName: ZodFirstPartyTypeKind$1.ZodIntersection, +ZodEffects$1.create = (schema, effect, params) => { + return new ZodEffects$1({ + schema, + typeName: ZodFirstPartyTypeKind$1.ZodEffects, + effect, ...processCreateParams$1(params) }); }; -let ZodTuple$1 = class ZodTuple extends ZodType$1 { +ZodEffects$1.createWithPreprocess = (preprocess, schema, params) => { + return new ZodEffects$1({ + schema, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind$1.ZodEffects, + ...processCreateParams$1(params) + }); +}; +let ZodOptional$1 = class ZodOptional extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.array) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.array, - received: ctx.parsedType - }); - return INVALID$1; - } - if (ctx.data.length < this._def.items.length) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - minimum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - return INVALID$1; - } - const rest = this._def.rest; - if (!rest && ctx.data.length > this._def.items.length) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - maximum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - status.dirty(); - } - const items = [...ctx.data].map((item, itemIndex) => { - const schema = this._def.items[itemIndex] || this._def.rest; - if (!schema) - return null; - return schema._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, itemIndex)); - }).filter((x2) => !!x2); - if (ctx.common.async) { - return Promise.all(items).then((results) => { - return ParseStatus$1.mergeArray(status, results); - }); - } else { - return ParseStatus$1.mergeArray(status, items); + const parsedType = this._getType(input); + if (parsedType === ZodParsedType$1.undefined) { + return OK$1(void 0); } + return this._def.innerType._parse(input); } - get items() { - return this._def.items; - } - rest(rest) { - return new ZodTuple({ - ...this._def, - rest - }); + unwrap() { + return this._def.innerType; } }; -ZodTuple$1.create = (schemas, params) => { - if (!Array.isArray(schemas)) { - throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); - } - return new ZodTuple$1({ - items: schemas, - typeName: ZodFirstPartyTypeKind$1.ZodTuple, - rest: null, +ZodOptional$1.create = (type2, params) => { + return new ZodOptional$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodOptional, ...processCreateParams$1(params) }); }; -let ZodRecord$1 = class ZodRecord extends ZodType$1 { - get keySchema() { - return this._def.keyType; - } - get valueSchema() { - return this._def.valueType; - } +let ZodNullable$1 = class ZodNullable extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.object) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.object, - received: ctx.parsedType - }); - return INVALID$1; - } - const pairs = []; - const keyType = this._def.keyType; - const valueType = this._def.valueType; - for (const key in ctx.data) { - pairs.push({ - key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, key)), - value: valueType._parse(new ParseInputLazyPath$1(ctx, ctx.data[key], ctx.path, key)) - }); - } - if (ctx.common.async) { - return ParseStatus$1.mergeObjectAsync(status, pairs); - } else { - return ParseStatus$1.mergeObjectSync(status, pairs); + const parsedType = this._getType(input); + if (parsedType === ZodParsedType$1.null) { + return OK$1(null); } + return this._def.innerType._parse(input); } - get element() { - return this._def.valueType; + unwrap() { + return this._def.innerType; } - static create(first, second, third) { - if (second instanceof ZodType$1) { - return new ZodRecord({ - keyType: first, - valueType: second, - typeName: ZodFirstPartyTypeKind$1.ZodRecord, - ...processCreateParams$1(third) - }); +}; +ZodNullable$1.create = (type2, params) => { + return new ZodNullable$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodNullable, + ...processCreateParams$1(params) + }); +}; +let ZodDefault$1 = class ZodDefault extends ZodType$1 { + _parse(input) { + const { ctx } = this._processInputParams(input); + let data = ctx.data; + if (ctx.parsedType === ZodParsedType$1.undefined) { + data = this._def.defaultValue(); } - return new ZodRecord({ - keyType: ZodString$1.create(), - valueType: first, - typeName: ZodFirstPartyTypeKind$1.ZodRecord, - ...processCreateParams$1(second) + return this._def.innerType._parse({ + data, + path: ctx.path, + parent: ctx }); } + removeDefault() { + return this._def.innerType; + } }; -let ZodMap$1 = class ZodMap extends ZodType$1 { +ZodDefault$1.create = (type2, params) => { + return new ZodDefault$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodDefault, + defaultValue: typeof params.default === "function" ? params.default : () => params.default, + ...processCreateParams$1(params) + }); +}; +let ZodCatch$1 = class ZodCatch extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.map) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.map, - received: ctx.parsedType - }); - return INVALID$1; - } - const keyType = this._def.keyType; - const valueType = this._def.valueType; - const pairs = [...ctx.data.entries()].map(([key, value], index) => { - return { - key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, [index, "key"])), - value: valueType._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, [index, "value"])) - }; - }); - if (ctx.common.async) { - const finalMap = /* @__PURE__ */ new Map(); - return Promise.resolve().then(async () => { - for (const pair of pairs) { - const key = await pair.key; - const value = await pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID$1; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - }); - } else { - const finalMap = /* @__PURE__ */ new Map(); - for (const pair of pairs) { - const key = pair.key; - const value = pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID$1; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); + const { ctx } = this._processInputParams(input); + const newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] } - return { status: status.value, value: finalMap }; + }; + const result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx + } + }); + if (isAsync$1(result)) { + return result.then((result2) => { + return { + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError$1(newCtx.common.issues); + } + }) + }; + }); + } else { + return { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError$1(newCtx.common.issues); + } + }) + }; } } + removeCatch() { + return this._def.innerType; + } }; -ZodMap$1.create = (keyType, valueType, params) => { - return new ZodMap$1({ - valueType, - keyType, - typeName: ZodFirstPartyTypeKind$1.ZodMap, +ZodCatch$1.create = (type2, params) => { + return new ZodCatch$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodCatch, + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, ...processCreateParams$1(params) }); }; -let ZodSet$1 = class ZodSet extends ZodType$1 { +let ZodNaN$1 = class ZodNaN extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.set) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.nan) { + const ctx = this._getOrReturnCtx(input); addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.set, + expected: ZodParsedType$1.nan, received: ctx.parsedType }); return INVALID$1; } - const def = this._def; - if (def.minSize !== null) { - if (ctx.data.size < def.minSize.value) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - minimum: def.minSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.minSize.message - }); - status.dirty(); - } - } - if (def.maxSize !== null) { - if (ctx.data.size > def.maxSize.value) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - maximum: def.maxSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.maxSize.message + return { status: "valid", value: input.data }; + } +}; +ZodNaN$1.create = (params) => { + return new ZodNaN$1({ + typeName: ZodFirstPartyTypeKind$1.ZodNaN, + ...processCreateParams$1(params) + }); +}; +const BRAND$1 = Symbol("zod_brand"); +let ZodBranded$1 = class ZodBranded extends ZodType$1 { + _parse(input) { + const { ctx } = this._processInputParams(input); + const data = ctx.data; + return this._def.type._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + unwrap() { + return this._def.type; + } +}; +let ZodPipeline$1 = class ZodPipeline extends ZodType$1 { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.common.async) { + const handleAsync = async () => { + const inResult = await this._def.in._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx }); - status.dirty(); - } - } - const valueType = this._def.valueType; - function finalizeSet(elements2) { - const parsedSet = /* @__PURE__ */ new Set(); - for (const element of elements2) { - if (element.status === "aborted") + if (inResult.status === "aborted") return INVALID$1; - if (element.status === "dirty") + if (inResult.status === "dirty") { status.dirty(); - parsedSet.add(element.value); - } - return { status: status.value, value: parsedSet }; - } - const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, i2))); - if (ctx.common.async) { - return Promise.all(elements).then((elements2) => finalizeSet(elements2)); + return DIRTY$1(inResult.value); + } else { + return this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + }; + return handleAsync(); } else { - return finalizeSet(elements); + const inResult = this._def.in._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID$1; + if (inResult.status === "dirty") { + status.dirty(); + return { + status: "dirty", + value: inResult.value + }; + } else { + return this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } } } - min(minSize, message) { - return new ZodSet({ - ...this._def, - minSize: { value: minSize, message: errorUtil$1.toString(message) } + static create(a3, b3) { + return new ZodPipeline({ + in: a3, + out: b3, + typeName: ZodFirstPartyTypeKind$1.ZodPipeline }); } - max(maxSize, message) { - return new ZodSet({ - ...this._def, - maxSize: { value: maxSize, message: errorUtil$1.toString(message) } +}; +const custom$1 = (check, params = {}, fatal) => { + if (check) + return ZodAny$1.create().superRefine((data, ctx) => { + var _a2, _b; + if (!check(data)) { + const p2 = typeof params === "function" ? params(data) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; + ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); + } }); - } - size(size, message) { - return this.min(size, message).max(size, message); - } - nonempty(message) { - return this.min(1, message); - } + return ZodAny$1.create(); }; -ZodSet$1.create = (valueType, params) => { - return new ZodSet$1({ - valueType, - minSize: null, - maxSize: null, - typeName: ZodFirstPartyTypeKind$1.ZodSet, - ...processCreateParams$1(params) - }); +const late$1 = { + object: ZodObject$1.lazycreate +}; +var ZodFirstPartyTypeKind$1; +(function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; + ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; + ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; + ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; + ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; + ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; + ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; + ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; + ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; + ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; + ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; + ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; + ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; + ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; + ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; + ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; + ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; + ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; + ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; + ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; + ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; + ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; + ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; + ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; + ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; + ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; + ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; + ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; + ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; + ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; + ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; + ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; + ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; + ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; + ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; +})(ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {})); +const instanceOfType$1 = (cls, params = { + message: `Input not instance of ${cls.name}` +}) => custom$1((data) => data instanceof cls, params); +const stringType$1 = ZodString$1.create; +const numberType$1 = ZodNumber$1.create; +const nanType$1 = ZodNaN$1.create; +const bigIntType$1 = ZodBigInt$1.create; +const booleanType$1 = ZodBoolean$1.create; +const dateType$1 = ZodDate$1.create; +const symbolType$1 = ZodSymbol$1.create; +const undefinedType$1 = ZodUndefined$1.create; +const nullType$1 = ZodNull$1.create; +const anyType$1 = ZodAny$1.create; +const unknownType$1 = ZodUnknown$1.create; +const neverType$1 = ZodNever$1.create; +const voidType$1 = ZodVoid$1.create; +const arrayType$1 = ZodArray$1.create; +const objectType$1 = ZodObject$1.create; +const strictObjectType$1 = ZodObject$1.strictCreate; +const unionType$1 = ZodUnion$1.create; +const discriminatedUnionType$1 = ZodDiscriminatedUnion$1.create; +const intersectionType$1 = ZodIntersection$1.create; +const tupleType$1 = ZodTuple$1.create; +const recordType$1 = ZodRecord$1.create; +const mapType$1 = ZodMap$1.create; +const setType$1 = ZodSet$1.create; +const functionType$1 = ZodFunction$1.create; +const lazyType$1 = ZodLazy$1.create; +const literalType$1 = ZodLiteral$1.create; +const enumType$1 = ZodEnum$1.create; +const nativeEnumType$1 = ZodNativeEnum$1.create; +const promiseType$1 = ZodPromise$1.create; +const effectsType$1 = ZodEffects$1.create; +const optionalType$1 = ZodOptional$1.create; +const nullableType$1 = ZodNullable$1.create; +const preprocessType$1 = ZodEffects$1.createWithPreprocess; +const pipelineType$1 = ZodPipeline$1.create; +const ostring$1 = () => stringType$1().optional(); +const onumber$1 = () => numberType$1().optional(); +const oboolean$1 = () => booleanType$1().optional(); +const coerce$2 = { + string: (arg) => ZodString$1.create({ ...arg, coerce: true }), + number: (arg) => ZodNumber$1.create({ ...arg, coerce: true }), + boolean: (arg) => ZodBoolean$1.create({ + ...arg, + coerce: true + }), + bigint: (arg) => ZodBigInt$1.create({ ...arg, coerce: true }), + date: (arg) => ZodDate$1.create({ ...arg, coerce: true }) }; -let ZodFunction$1 = class ZodFunction extends ZodType$1 { - constructor() { - super(...arguments); - this.validate = this.implement; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.function) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.function, - received: ctx.parsedType - }); - return INVALID$1; - } - function makeArgsIssue(args, error) { - return makeIssue$1({ - data: args, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap$1(), - errorMap$1 - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode$1.invalid_arguments, - argumentsError: error - } - }); - } - function makeReturnsIssue(returns, error) { - return makeIssue$1({ - data: returns, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap$1(), - errorMap$1 - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode$1.invalid_return_type, - returnTypeError: error - } - }); - } - const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; - if (this._def.returns instanceof ZodPromise$1) { - return OK$1(async (...args) => { - const error = new ZodError$1([]); - const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => { - error.addIssue(makeArgsIssue(args, e)); - throw error; - }); - const result = await fn2(...parsedArgs); - const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => { - error.addIssue(makeReturnsIssue(result, e)); - throw error; - }); - return parsedReturns; - }); - } else { - return OK$1((...args) => { - const parsedArgs = this._def.args.safeParse(args, params); - if (!parsedArgs.success) { - throw new ZodError$1([makeArgsIssue(args, parsedArgs.error)]); - } - const result = fn2(...parsedArgs.data); - const parsedReturns = this._def.returns.safeParse(result, params); - if (!parsedReturns.success) { - throw new ZodError$1([makeReturnsIssue(result, parsedReturns.error)]); - } - return parsedReturns.data; - }); - } +const NEVER$1 = INVALID$1; +var z$5 = /* @__PURE__ */ Object.freeze({ + __proto__: null, + defaultErrorMap: errorMap$1, + setErrorMap: setErrorMap$1, + getErrorMap: getErrorMap$1, + makeIssue: makeIssue$1, + EMPTY_PATH: EMPTY_PATH$1, + addIssueToContext: addIssueToContext$1, + ParseStatus: ParseStatus$1, + INVALID: INVALID$1, + DIRTY: DIRTY$1, + OK: OK$1, + isAborted: isAborted$1, + isDirty: isDirty$1, + isValid: isValid$1, + isAsync: isAsync$1, + get util() { + return util$1; + }, + get objectUtil() { + return objectUtil$1; + }, + ZodParsedType: ZodParsedType$1, + getParsedType: getParsedType$1, + ZodType: ZodType$1, + ZodString: ZodString$1, + ZodNumber: ZodNumber$1, + ZodBigInt: ZodBigInt$1, + ZodBoolean: ZodBoolean$1, + ZodDate: ZodDate$1, + ZodSymbol: ZodSymbol$1, + ZodUndefined: ZodUndefined$1, + ZodNull: ZodNull$1, + ZodAny: ZodAny$1, + ZodUnknown: ZodUnknown$1, + ZodNever: ZodNever$1, + ZodVoid: ZodVoid$1, + ZodArray: ZodArray$1, + ZodObject: ZodObject$1, + ZodUnion: ZodUnion$1, + ZodDiscriminatedUnion: ZodDiscriminatedUnion$1, + ZodIntersection: ZodIntersection$1, + ZodTuple: ZodTuple$1, + ZodRecord: ZodRecord$1, + ZodMap: ZodMap$1, + ZodSet: ZodSet$1, + ZodFunction: ZodFunction$1, + ZodLazy: ZodLazy$1, + ZodLiteral: ZodLiteral$1, + ZodEnum: ZodEnum$1, + ZodNativeEnum: ZodNativeEnum$1, + ZodPromise: ZodPromise$1, + ZodEffects: ZodEffects$1, + ZodTransformer: ZodEffects$1, + ZodOptional: ZodOptional$1, + ZodNullable: ZodNullable$1, + ZodDefault: ZodDefault$1, + ZodCatch: ZodCatch$1, + ZodNaN: ZodNaN$1, + BRAND: BRAND$1, + ZodBranded: ZodBranded$1, + ZodPipeline: ZodPipeline$1, + custom: custom$1, + Schema: ZodType$1, + ZodSchema: ZodType$1, + late: late$1, + get ZodFirstPartyTypeKind() { + return ZodFirstPartyTypeKind$1; + }, + coerce: coerce$2, + any: anyType$1, + array: arrayType$1, + bigint: bigIntType$1, + boolean: booleanType$1, + date: dateType$1, + discriminatedUnion: discriminatedUnionType$1, + effect: effectsType$1, + "enum": enumType$1, + "function": functionType$1, + "instanceof": instanceOfType$1, + intersection: intersectionType$1, + lazy: lazyType$1, + literal: literalType$1, + map: mapType$1, + nan: nanType$1, + nativeEnum: nativeEnumType$1, + never: neverType$1, + "null": nullType$1, + nullable: nullableType$1, + number: numberType$1, + object: objectType$1, + oboolean: oboolean$1, + onumber: onumber$1, + optional: optionalType$1, + ostring: ostring$1, + pipeline: pipelineType$1, + preprocess: preprocessType$1, + promise: promiseType$1, + record: recordType$1, + set: setType$1, + strictObject: strictObjectType$1, + string: stringType$1, + symbol: symbolType$1, + transformer: effectsType$1, + tuple: tupleType$1, + "undefined": undefinedType$1, + union: unionType$1, + unknown: unknownType$1, + "void": voidType$1, + NEVER: NEVER$1, + ZodIssueCode: ZodIssueCode$1, + quotelessJson: quotelessJson$1, + ZodError: ZodError$1 +}); +const aleoAddressRegex$1 = /^aleo1[a-z0-9]{58}$/i; +const aleoViewKeyRegex$1 = /^AViewKey1[a-z0-9]{44}$/i; +const aleoPrivateKeyRegex$1 = /^APrivateKey1[a-z0-9]{47}$/i; +const aleoTransitionIdRegex$1 = /^au1[a-z0-9]{58}$/i; +const aleoTransactionIdRegex$1 = /^at1[a-z0-9]{58}$/i; +const aleoFieldRegex$1 = /^\d+field$/; +const aleoU32$1 = /^\d+u32$/; +const aleoU64$1 = /^\d+u64$/; +z$5.string().regex(aleoAddressRegex$1); +z$5.string().regex(aleoViewKeyRegex$1); +z$5.string().regex(aleoPrivateKeyRegex$1); +z$5.string().regex(aleoTransitionIdRegex$1); +z$5.string().regex(aleoTransactionIdRegex$1); +z$5.string().regex(aleoFieldRegex$1); +z$5.string().regex(aleoU32$1); +z$5.string().regex(aleoU64$1); +var InputOutputType$1; +(function(InputOutputType2) { + InputOutputType2["Record"] = "record"; + InputOutputType2["OutputRecord"] = "outputRecord"; + InputOutputType2["Public"] = "public"; + InputOutputType2["Private"] = "private"; + InputOutputType2["Constant"] = "constant"; + InputOutputType2["Future"] = "future"; + InputOutputType2["ExternalRecord"] = "external_record"; +})(InputOutputType$1 || (InputOutputType$1 = {})); +var EventType; +(function(EventType2) { + EventType2["Deploy"] = "Deploy"; + EventType2["Execute"] = "Execute"; + EventType2["Send"] = "Send"; + EventType2["Receive"] = "Receive"; + EventType2["Join"] = "Join"; + EventType2["Split"] = "Split"; + EventType2["Shield"] = "Shield"; + EventType2["Unshield"] = "Unshield"; + EventType2["Referral"] = "Referral"; + EventType2["Points"] = "Points"; + EventType2["Raffle"] = "Raffle"; +})(EventType || (EventType = {})); +var EventStatus; +(function(EventStatus2) { + EventStatus2["Creating"] = "Creating"; + EventStatus2["Pending"] = "Pending"; + EventStatus2["Settled"] = "Settled"; + EventStatus2["Failed"] = "Failed"; +})(EventStatus || (EventStatus = {})); +var Visibility; +(function(Visibility2) { + Visibility2["Private"] = "Private"; + Visibility2["Public"] = "Public"; +})(Visibility || (Visibility = {})); +var Network; +(function(Network2) { + Network2["AleoTestnet"] = "AleoTestnet"; + Network2["AleoCanarynet"] = "AleoCanarynet"; + Network2["AleoMainnet"] = "AleoMainnet"; +})(Network || (Network = {})); +z$5.nativeEnum(EventType); +z$5.nativeEnum(EventStatus); +z$5.nativeEnum(Network); +z$5.nativeEnum(Visibility); +const wc_aleo_methods$1 = [ + "decrypt", + "disconnect", + "getSelectedAccount", + "getBalance", + "getRecords", + "requestCreateEvent", + "getEvent", + "getEvents", + "createSharedState", + "importSharedState", + "requestSignature" +]; +const wc_required_aleo_chains$1 = ["aleo:1"]; +const wc_optional_aleo_chains$1 = [ + "aleo:0" + // for eventual mainnet +]; +const wc_aleo_chains$1 = [ + ...wc_required_aleo_chains$1, + ...wc_optional_aleo_chains$1 +]; +const wc_events$1 = [ + "chainChanged", + "accountSelected", + "selectedAccountSynced", + "sharedAccountSynced" +]; +const projectId$1 = "f0aaeffe71b636da453fce042d79d723"; +function isAndroid$1() { + if (typeof navigator === "undefined") { + return false; } - parameters() { - return this._def.args; + return /Android/i.test(navigator.userAgent); +} +const web3modal_puzzle_props_android$1 = { + projectId: projectId$1, + chains: wc_aleo_chains$1, + enableExplorer: true, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png" } - returnType() { - return this._def.returns; +}; +const web3modal_puzzle_props_default$1 = { + projectId: projectId$1, + chains: wc_aleo_chains$1, + enableExplorer: false, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + desktopWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "", + universal: "https://walletconnect.puzzle.online/" + } + }, + { + id: "avail", + name: "Avail Wallet", + links: { + native: "avail://", + universal: "https://avail.global" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png", + avail: "https://i.imgur.com/GxNn8BO.png" } - args(...items) { - return new ZodFunction({ - ...this._def, - args: ZodTuple$1.create(items).rest(ZodUnknown$1.create()) - }); +}; +const web3modal_puzzle_props$1 = isAndroid$1() ? web3modal_puzzle_props_android$1 : web3modal_puzzle_props_default$1; +const name$1 = "@puzzlehq/sdk-core"; +const displayName$1 = "Puzzle SDK"; +const version$1 = "0.4.0"; +const description$1 = "Your portal to privacy"; +const main$1 = "./dist/puzzle.cjs.js"; +const module$2 = "./dist/puzzle.es.js"; +const browser$1 = "./dist/puzzle.umd.js"; +const types$3 = "./dist/types/src/index.d.ts"; +const exports$2 = { + ".": { + "import": "./dist/puzzle.es.js", + require: "./dist/puzzle.cjs.js", + browser: "./dist/puzzle.umd.js", + types: "./dist/types/src/index.d.ts" } - returns(returnType) { - return new ZodFunction({ - ...this._def, - returns: returnType +}; +const type$1 = "module"; +const scripts$1 = { + "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", + "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, + build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", + "type-check": "tsc --noEmit" +}; +const repository$1 = { + type: "git", + url: "git+https://github.com/puzzlehq/puzzle-sdk.git" +}; +const dependencies$1 = { + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", + "@walletconnect/types": "^2.11.2", + "@walletconnect/utils": "^2.11.2", + debug: "^4.3.4", + events: "^3.3.0", + ws: "^8.16.0" +}; +const peerDependencies$1 = { + buffer: "^6.0.3" +}; +const keywords$1 = [ + "puzzle", + "cryptocurrency wallet", + "privacy", + "aleo", + "web3", + "crypto", + "typescript" +]; +const author$1 = "Puzzle"; +const license$1 = "ISC"; +const bugs$1 = { + url: "https://github.com/puzzlehq/puzzle-sdk/issues" +}; +const homepage$1 = "https://github.com/puzzlehq/puzzle-sdk#readme"; +const pkg$1 = { + name: name$1, + displayName: displayName$1, + version: version$1, + description: description$1, + main: main$1, + module: module$2, + browser: browser$1, + types: types$3, + "private": false, + exports: exports$2, + type: type$1, + scripts: scripts$1, + repository: repository$1, + dependencies: dependencies$1, + peerDependencies: peerDependencies$1, + keywords: keywords$1, + author: author$1, + license: license$1, + bugs: bugs$1, + homepage: homepage$1 +}; +var On = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function A0(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; +} +var Pn = { exports: {} }; +/** +* [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 +*/ +(function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On : o2 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s2(u3, E2, u3).update(B2)[_3](); + }; + }, H2 = function(u3, E2, _3) { + return function(B2, R2) { + return new s2(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s2(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H2(u3, E2, "hex"); + return _3.create = function(B2) { + return new s2(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H2, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s2(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s2(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N2[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; + } + return this; + }, s2.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s2.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s2.call(this, u3, E2, _3); + } + v3.prototype = new s2(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne, Ie; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z2 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z2 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _3 = D2 ^ (Z2 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne = u3[42] << 2 | u3[43] >>> 30, Ie = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne, u3[45] = Me2 ^ ~Se2 & Ie, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne & St2, u3[47] = Se2 ^ ~Ie & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne ^ ~St2 & Ve2, u3[49] = Ie ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); +})(Pn); +const y0 = "logger/5.7.0"; +let Dn = false, Fn = false; +const Cr2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let Tn = Cr2.default, gi = null; +function w0() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; } - implement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - strictImplement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - static create(args, returns, params) { - return new ZodFunction({ - args: args ? args : ZodTuple$1.create([]).rest(ZodUnknown$1.create()), - returns: returns || ZodUnknown$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodFunction, - ...processCreateParams$1(params) - }); + return null; +} +const Un = w0(); +var Ai; +(function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; +})(Ai || (Ai = {})); +var re; +(function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; +})(re || (re = {})); +const kn = "0123456789abcdef"; +class L3 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); } -}; -let ZodLazy$1 = class ZodLazy extends ZodType$1 { - get schema() { - return this._def.getter(); + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn > Cr2[i2]) && console.log.apply(console, r3); } - _parse(input) { - const { ctx } = this._processInputParams(input); - const lazySchema = this._def.getter(); - return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + debug(...t2) { + this._log(L3.levels.DEBUG, t2); } -}; -ZodLazy$1.create = (getter, params) => { - return new ZodLazy$1({ - getter, - typeName: ZodFirstPartyTypeKind$1.ZodLazy, - ...processCreateParams$1(params) - }); -}; -let ZodLiteral$1 = class ZodLiteral extends ZodType$1 { - _parse(input) { - if (input.data !== this._def.value) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_literal, - expected: this._def.value - }); - return INVALID$1; - } - return { status: "valid", value: input.data }; + info(...t2) { + this._log(L3.levels.INFO, t2); } - get value() { - return this._def.value; + warn(...t2) { + this._log(L3.levels.WARNING, t2); } -}; -ZodLiteral$1.create = (value, params) => { - return new ZodLiteral$1({ - value, - typeName: ZodFirstPartyTypeKind$1.ZodLiteral, - ...processCreateParams$1(params) - }); -}; -function createZodEnum$1(values, params) { - return new ZodEnum$1({ - values, - typeName: ZodFirstPartyTypeKind$1.ZodEnum, - ...processCreateParams$1(params) - }); -} -let ZodEnum$1 = class ZodEnum extends ZodType$1 { - _parse(input) { - if (typeof input.data !== "string") { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext$1(ctx, { - expected: util$1.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode$1.invalid_type - }); - return INVALID$1; - } - if (this._def.values.indexOf(input.data) === -1) { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_enum_value, - options: expectedValues - }); - return INVALID$1; + makeError(t2, r3, i2) { + if (Fn) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L3.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn[m3[y3] >> 4], w3 += kn[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o2 = t2; + let h4 = ""; + switch (r3) { + case re.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; + } + case re.CALL_EXCEPTION: + case re.INSUFFICIENT_FUNDS: + case re.MISSING_NEW: + case re.NONCE_EXPIRED: + case re.REPLACEMENT_UNDERPRICED: + case re.TRANSACTION_REPLACED: + case re.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; } - return OK$1(input.data); + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; } - get options() { - return this._def.values; + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); } - get enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L3.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); } - get Values() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); } - get Enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); } - extract(values) { - return ZodEnum.create(values); + checkNormalize(t2) { + Un && this.throwError("platform missing String.prototype.normalize", L3.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un }); } - exclude(values) { - return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); } -}; -ZodEnum$1.create = createZodEnum$1; -let ZodNativeEnum$1 = class ZodNativeEnum extends ZodType$1 { - _parse(input) { - const nativeEnumValues = util$1.getValidEnumValues(this._def.values); - const ctx = this._getOrReturnCtx(input); - if (ctx.parsedType !== ZodParsedType$1.string && ctx.parsedType !== ZodParsedType$1.number) { - const expectedValues = util$1.objectValues(nativeEnumValues); - addIssueToContext$1(ctx, { - expected: util$1.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode$1.invalid_type - }); - return INVALID$1; - } - if (nativeEnumValues.indexOf(input.data) === -1) { - const expectedValues = util$1.objectValues(nativeEnumValues); - addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_enum_value, - options: expectedValues - }); - return INVALID$1; - } - return OK$1(input.data); + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L3.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L3.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); } - get enum() { - return this._def.values; + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); } -}; -ZodNativeEnum$1.create = (values, params) => { - return new ZodNativeEnum$1({ - values, - typeName: ZodFirstPartyTypeKind$1.ZodNativeEnum, - ...processCreateParams$1(params) - }); -}; -let ZodPromise$1 = class ZodPromise extends ZodType$1 { - unwrap() { - return this._def.type; + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L3.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.promise && ctx.common.async === false) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.promise, - received: ctx.parsedType - }); - return INVALID$1; + static globalLogger() { + return gi || (gi = new L3(y0)), gi; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } - const promisified = ctx.parsedType === ZodParsedType$1.promise ? ctx.data : Promise.resolve(ctx.data); - return OK$1(promisified.then((data) => { - return this._def.type.parseAsync(data, { - path: ctx.path, - errorMap: ctx.common.contextualErrorMap - }); - })); + Fn = !!t2, Dn = !!r3; } -}; -ZodPromise$1.create = (schema, params) => { - return new ZodPromise$1({ - type: schema, - typeName: ZodFirstPartyTypeKind$1.ZodPromise, - ...processCreateParams$1(params) - }); -}; -let ZodEffects$1 = class ZodEffects extends ZodType$1 { - innerType() { - return this._def.schema; + static setLogLevel(t2) { + const r3 = Cr2[t2.toLowerCase()]; + if (r3 == null) { + L3.globalLogger().warn("invalid log level - " + t2); + return; + } + Tn = r3; } - sourceType() { - return this._def.schema._def.typeName === ZodFirstPartyTypeKind$1.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + static from(t2) { + return new L3(t2); } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const effect = this._def.effect || null; - if (effect.type === "preprocess") { - const processed = effect.transform(ctx.data); - if (ctx.common.async) { - return Promise.resolve(processed).then((processed2) => { - return this._def.schema._parseAsync({ - data: processed2, - path: ctx.path, - parent: ctx - }); - }); - } else { - return this._def.schema._parseSync({ - data: processed, - path: ctx.path, - parent: ctx - }); - } +} +L3.errors = re, L3.levels = Ai; +const x0 = "bytes/5.7.0", Dt = new L3(x0); +function qn(e2) { + return !!e2.toHexString; +} +function rr(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; +} +function Kn(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; +} +function ir(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; +} +function Ot2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2) && (e2 = e2.toHexString()), Qt(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr(new Uint8Array(i2)); + } + return ir(e2) ? rr(new Uint8Array(e2)) : Dt.throwArgumentError("invalid arrayify value", "value", e2); +} +function Qt(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2); +} +const bi = "0123456789abcdef"; +function Kt(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2)) + return e2.toHexString(); + if (Qt(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi[(n4 & 240) >> 4] + bi[n4 & 15]; + } + return r3; + } + return Dt.throwArgumentError("invalid hexlify value", "value", e2); +} +function oe(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt(e2) : Qt(e2) || Dt.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; +} +var Ln = { exports: {} }, I0 = {}, _0 = Object.freeze({ __proto__: null, default: I0 }), B0 = A0(_0); +(function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; } - const checkCtx = { - addIssue: (arg) => { - addIssueToContext$1(ctx, arg); - if (arg.fatal) { - status.abort(); - } else { - status.dirty(); - } - }, - get path() { - return ctx.path; + function o2(A2, f3, a3) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r3.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0.Buffer; + } catch { + } + o2.isBN = function(f3) { + return f3 instanceof o2 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o2.wordSize && Array.isArray(f3.words); + }, o2.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o2.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o2.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o2.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o2.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; } + this._strip(); }; - checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); - if (effect.type === "refinement") { - const executeRefinement = (acc) => { - const result = effect.refinement(acc, checkCtx); - if (ctx.common.async) { - return Promise.resolve(result); - } - if (result instanceof Promise) { - throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); - } - return acc; - }; - if (ctx.common.async === false) { - const inner = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inner.status === "aborted") - return INVALID$1; - if (inner.status === "dirty") - status.dirty(); - executeRefinement(inner.value); - return { status: status.value, value: inner.value }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { - if (inner.status === "aborted") - return INVALID$1; - if (inner.status === "dirty") - status.dirty(); - return executeRefinement(inner.value).then(() => { - return { status: status.value, value: inner.value }; - }); - }); + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o2.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v3 = c2; v3 < l2; v3 += d5) + s2 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o2.prototype._move = function(f3) { + w3(f3, this); + }, o2.prototype.clone = function() { + var f3 = new o2(null); + return this.copy(f3), f3; + }, o2.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o2.prototype.inspect = y3; + } + else + o2.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s2 = I2[f3], v3 = N2[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s2 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o2.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o2.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o2.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o2.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o2.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o2.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; } - } - if (effect.type === "transform") { - if (ctx.common.async === false) { - const base3 = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (!isValid$1(base3)) - return base3; - const result = effect.transform(base3.value, checkCtx); - if (result instanceof Promise) { - throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + return f3; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o2.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o2.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o2.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o2.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o2.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o2.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o2.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o2.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o2.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o2.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o2.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o2.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o2.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o2.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o2.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s2, f3.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s2 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s2] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s2] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s2, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te = d5[6] | 0, et2 = Te & 8191, rt2 = Te >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le = g3[3] | 0, vt2 = Le & 8191, mt2 = Le >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s2 = Math.imul(u3, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s2 = s2 + Math.imul(u3, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s2 = s2 + Math.imul(u3, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s2 = s2 + Math.imul(u3, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ne >>> 26) | 0, Ne &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v3 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s2 = s2 + Math.imul(u3, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v3 = v3 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s2 = s2 + Math.imul(u3, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v3 = v3 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s2 = s2 + Math.imul(u3, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v3 = v3 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s2 = s2 + Math.imul(u3, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v3 = v3 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s2 = s2 + Math.imul(u3, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v3 = v3 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s2 = s2 + Math.imul(u3, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v3 = v3 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v3 = v3 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v3 = v3 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v3 = v3 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v3 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne, x2[4] = Ie, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s2 = Math.max(0, g3 - A2.length + 1); s2 <= l2; s2++) { + var v3 = g3 - s2, k2 = A2.words[v3] | 0, u3 = f3.words[s2] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o2.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o2.prototype.mul = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o2.prototype.mulf = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o2.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o2.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o2.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o2(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o2.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o2.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v3 !== 0 || s2 >= d5); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o2.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o2.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o2.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o2.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o2.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o2.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o2.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o2.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o2.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o2.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o2.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s2; + if (a3 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v3 = 0; v3 < s2.length; v3++) + s2.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s2 && (s2.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s2 && (s2.words[u3] = E2); + } + return s2 && s2._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s2 || null, mod: d5 }; + }, o2.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o2(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o2(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o2(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o2.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o2.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o2.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o2.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o2.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o2.prototype.modn = function(f3) { + return this.modrn(f3); + }, o2.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o2.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o2.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s2), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s2 = 0, v3 = 1; !(c2.words[0] & v3) && s2 < 26; ++s2, v3 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o2.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o2.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o2.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o2.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; } - return { status: status.value, value: result }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { - if (!isValid$1(base3)) - return base3; - return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); - }); } - } - util$1.assertNever(effect); + return a3; + }, o2.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o2.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o2.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o2.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o2.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o2.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o2.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o2.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o2.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o2.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o2.red = function(f3) { + return new Y2(f3); + }, o2.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o2.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o2.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o2.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o2.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o2.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o2.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o2.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o2.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o2(f3, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o2(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o2._prime = function(f3) { + if (H2[f3]) + return H2[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H2[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o2._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v3 = this.pow(s2, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o2(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o2(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s2 = a3.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s2 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o2.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o2(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On); +})(Ln); +var K2 = Ln.exports; +const jn = "bignumber/5.7.0"; +var Rr = K2.BN; +const Ae = new L3(jn), wi = {}, Qn = 9007199254740991; +function C0(e2) { + return e2 != null && (V2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt(e2) || typeof e2 == "bigint" || ir(e2)); +} +let Jn = false; +class V2 { + constructor(t2, r3) { + t2 !== wi && Ae.throwError("cannot call constructor directly; use BigNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); + } + fromTwos(t2) { + return Lt(j(this).fromTwos(t2)); + } + toTwos(t2) { + return Lt(j(this).toTwos(t2)); + } + abs() { + return this._hex[0] === "-" ? V2.from(this._hex.substring(1)) : this; + } + add(t2) { + return Lt(j(this).add(j(t2))); + } + sub(t2) { + return Lt(j(this).sub(j(t2))); + } + div(t2) { + return V2.from(t2).isZero() && Wt2("division-by-zero", "div"), Lt(j(this).div(j(t2))); + } + mul(t2) { + return Lt(j(this).mul(j(t2))); + } + mod(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("division-by-zero", "mod"), Lt(j(this).umod(r3)); + } + pow(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("negative-power", "pow"), Lt(j(this).pow(r3)); + } + and(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "and"), Lt(j(this).and(r3)); + } + or(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "or"), Lt(j(this).or(r3)); + } + xor(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "xor"), Lt(j(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "mask"), Lt(j(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shl"), Lt(j(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shr"), Lt(j(this).shrn(t2)); } -}; -ZodEffects$1.create = (schema, effect, params) => { - return new ZodEffects$1({ - schema, - typeName: ZodFirstPartyTypeKind$1.ZodEffects, - effect, - ...processCreateParams$1(params) - }); -}; -ZodEffects$1.createWithPreprocess = (preprocess, schema, params) => { - return new ZodEffects$1({ - schema, - effect: { type: "preprocess", transform: preprocess }, - typeName: ZodFirstPartyTypeKind$1.ZodEffects, - ...processCreateParams$1(params) - }); -}; -let ZodOptional$1 = class ZodOptional extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType$1.undefined) { - return OK$1(void 0); - } - return this._def.innerType._parse(input); + eq(t2) { + return j(this).eq(j(t2)); } - unwrap() { - return this._def.innerType; + lt(t2) { + return j(this).lt(j(t2)); } -}; -ZodOptional$1.create = (type2, params) => { - return new ZodOptional$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodOptional, - ...processCreateParams$1(params) - }); -}; -let ZodNullable$1 = class ZodNullable extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType$1.null) { - return OK$1(null); + lte(t2) { + return j(this).lte(j(t2)); + } + gt(t2) { + return j(this).gt(j(t2)); + } + gte(t2) { + return j(this).gte(j(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j(this).isZero(); + } + toNumber() { + try { + return j(this).toNumber(); + } catch { + Wt2("overflow", "toNumber", this.toString()); } - return this._def.innerType._parse(input); + return null; } - unwrap() { - return this._def.innerType; + toBigInt() { + try { + return BigInt(this.toString()); + } catch { + } + return Ae.throwError("this platform does not support BigInt", L3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); } -}; -ZodNullable$1.create = (type2, params) => { - return new ZodNullable$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodNullable, - ...processCreateParams$1(params) - }); -}; -let ZodDefault$1 = class ZodDefault extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - let data = ctx.data; - if (ctx.parsedType === ZodParsedType$1.undefined) { - data = this._def.defaultValue(); + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn || (Jn = true, Ae.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L3.errors.UNEXPECTED_ARGUMENT, {}) : Ae.throwError("BigNumber.toString does not accept parameters", L3.errors.UNEXPECTED_ARGUMENT, {})), j(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V2) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V2(wi, vr(t2)) : t2.match(/^-?[0-9]+$/) ? new V2(wi, vr(new Rr(t2))) : Ae.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt2("underflow", "BigNumber.from", t2), (t2 >= Qn || t2 <= -Qn) && Wt2("overflow", "BigNumber.from", t2), V2.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V2.from(r3.toString()); + if (ir(r3)) + return V2.from(Kt(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V2.from(i2); + } else { + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt(i2) || i2[0] === "-" && Qt(i2.substring(1)))) + return V2.from(i2); + } + return Ae.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } +} +function vr(e2) { + if (typeof e2 != "string") + return vr(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae.throwArgumentError("invalid hex", "value", e2), e2 = vr(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; +} +function Lt(e2) { + return V2.from(vr(e2)); +} +function j(e2) { + const t2 = V2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr("-" + t2.substring(3), 16) : new Rr(t2.substring(2), 16); +} +function Wt2(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae.throwError(e2, L3.errors.NUMERIC_FAULT, i2); +} +const Ht2 = new L3(jn), mr = {}, Gn = V2.from(0), Yn = V2.from(-1); +function Vn(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht2.throwError(e2, L3.errors.NUMERIC_FAULT, n4); +} +let gr = "0"; +for (; gr.length < 256; ) + gr += gr; +function xi(e2) { + if (typeof e2 != "number") + try { + e2 = V2.from(e2).toNumber(); + } catch { } - return this._def.innerType._parse({ - data, - path: ctx.path, - parent: ctx - }); + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr.substring(0, e2) : Ht2.throwArgumentError("invalid decimal size", "decimals", e2); +} +function Mi(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + e2 = V2.from(e2); + const i2 = e2.lt(Gn); + i2 && (e2 = e2.mul(Yn)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o2 : e2 = o2 + "." + n4, i2 && (e2 = "-" + e2), e2; +} +function be(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht2.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht2.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht2.throwArgumentError("too many decimal points", "value", e2); + let o2 = n4[0], h4 = n4[1]; + for (o2 || (o2 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V2.from(o2), b3 = V2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn)), m3; +} +class dr2 { + constructor(t2, r3, i2, n4) { + t2 !== mr && Ht2.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr2) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht2.throwArgumentError("invalid fixed format", "format", t2), r3 = o2[1] !== "u", i2 = parseInt(o2[2]), n4 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht2.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o2("signed", "boolean", r3), i2 = o2("width", "number", i2), n4 = o2("decimals", "number", n4); + } + return i2 % 8 && Ht2.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht2.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr2(mr, r3, i2, n4); + } +} +class Ut3 { + constructor(t2, r3, i2, n4) { + t2 !== mr && Ht2.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht2.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht2.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut3.from("1" + gr.substring(0, t2), this.format), n4 = O0.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); } - removeDefault() { - return this._def.innerType; + isZero() { + return this._value === "0.0" || this._value === "0"; } -}; -ZodDefault$1.create = (type2, params) => { - return new ZodDefault$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodDefault, - defaultValue: typeof params.default === "function" ? params.default : () => params.default, - ...processCreateParams$1(params) + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht2.throwArgumentError("invalid byte width", "width", t2); + const r3 = V2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut3.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut3.fromString(Mi(t2, r3), dr2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3), n4 = be(t2, i2.decimals); + !i2.signed && n4.lt(Gn) && Vn("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n4.toTwos(i2.width).toHexString() : (o2 = n4.toHexString(), o2 = oe(o2, i2.width / 8)); + const h4 = Mi(n4, i2.decimals); + return new Ut3(mr, o2, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3); + if (Ot2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o2 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi(n4, i2.decimals); + return new Ut3(mr, o2, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut3.fromString(t2, r3); + if (ir(t2)) + return Ut3.fromBytes(t2, r3); + try { + return Ut3.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht2.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } +} +const Wn = Ut3.from(1), O0 = Ut3.from("0.5"); +var Or; +(function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; +})(Or || (Or = {})); +var nr; +(function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; +})(nr || (nr = {})); +function T0(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; +} +function Si(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; }); -}; -let ZodCatch$1 = class ZodCatch extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const newCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - } - }; - const result = this._def.innerType._parse({ - data: newCtx.data, - path: newCtx.path, - parent: { - ...newCtx - } + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o2 = n4.split(":"); + r3 += parseInt(o2[0], 16), i2[r3] = t2(o2[1]); + }), i2; +} +function $n(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); +} +$n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0), $n("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function U0(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot2(t2); +} +function ef(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o2, h4) { + i2.call(o2, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); }); - if (isAsync$1(result)) { - return result.then((result2) => { - return { - status: "valid", - value: result2.status === "valid" ? result2.value : this._def.catchValue({ - get error() { - return new ZodError$1(newCtx.common.issues); - } - }) - }; - }); - } else { - return { - status: "valid", - value: result.status === "valid" ? result.value : this._def.catchValue({ - get error() { - return new ZodError$1(newCtx.common.issues); - } - }) - }; + }; + return n4(e2, t2), r3; +} +function k0(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; +} +function q0(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y3; H2++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H2 < o2[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; } + }); +} +function K0(e2) { + let t2 = 0; + return () => e2[t2++]; +} +function H0(e2) { + return K0(q0(e2)); +} +function z0(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; +} +function L0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; +} +function rf(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; +} +function j0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0(t2()); + return r3; +} +function Pr(e2, t2) { + let r3 = rf(e2(), e2), i2 = e2(), n4 = rf(i2, e2), o2 = L0(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o2[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; +} +function Q0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0(r3, e2)); } - removeCatch() { - return this._def.innerType; + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0(r3, e2)); } -}; -ZodCatch$1.create = (type2, params) => { - return new ZodCatch$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodCatch, - catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, - ...processCreateParams$1(params) - }); -}; -let ZodNaN$1 = class ZodNaN extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.nan) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.nan, - received: ctx.parsedType - }); - return INVALID$1; - } - return { status: "valid", value: input.data }; + return k0(ef(t2)); +} +function J0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); } -}; -ZodNaN$1.create = (params) => { - return new ZodNaN$1({ - typeName: ZodFirstPartyTypeKind$1.ZodNaN, - ...processCreateParams$1(params) - }); -}; -const BRAND$1 = Symbol("zod_brand"); -let ZodBranded$1 = class ZodBranded extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const data = ctx.data; - return this._def.type._parse({ - data, - path: ctx.path, - parent: ctx + return t2; +} +function nf(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0(e2, r3).forEach((o2, h4) => i2[h4].push(o2)); + return i2; +} +function G0(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0(t2), o2 = nf(n4.length, 1 + e2, t2); + return ef(o2.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; }); - } - unwrap() { - return this._def.type; + })); +} +function Y0(e2, t2) { + let r3 = 1 + t2(); + return nf(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); +} +function V0(e2) { + let t2 = Pr(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o2 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o2, fe0f: h4, save: p2, check: b3 }; + } +} +function W0() { + return H0(U0("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); +} +const Dr = W0(); +new Set(Pr(Dr)), new Set(Pr(Dr)), Q0(Dr), V0(Dr); +const X0 = new Uint8Array(32); +X0.fill(0); +const os = new Uint8Array(32); +os.fill(0), V2.from(-1); +const ss3 = V2.from(0), as = V2.from(1); +V2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe(as.toHexString(), 32), oe(ss3.toHexString(), 32); +var se = {}, Q = {}, yr = af; +function af(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +af.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var Ii = { exports: {} }; +typeof Object.create == "function" ? Ii.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); +} : Ii.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; } }; -let ZodPipeline$1 = class ZodPipeline extends ZodType$1 { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.common.async) { - const handleAsync = async () => { - const inResult = await this._def.in._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID$1; - if (inResult.status === "dirty") { - status.dirty(); - return DIRTY$1(inResult.value); - } else { - return this._def.out._parseAsync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - }; - return handleAsync(); - } else { - const inResult = this._def.in._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID$1; - if (inResult.status === "dirty") { - status.dirty(); - return { - status: "dirty", - value: inResult.value - }; - } else { - return this._def.out._parseSync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); +var us = yr, hs = Ii.exports; +Q.inherits = hs; +function cs(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; +} +function ls(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o2 = e2.charCodeAt(n4); + o2 < 128 ? r3[i2++] = o2 : o2 < 2048 ? (r3[i2++] = o2 >> 6 | 192, r3[i2++] = o2 & 63 | 128) : cs(e2, n4) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o2 >> 18 | 240, r3[i2++] = o2 >> 12 & 63 | 128, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128) : (r3[i2++] = o2 >> 12 | 224, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128); + } + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; +} +Q.toArray = ls; +function ds(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf(e2[r3].toString(16)); + return t2; +} +Q.toHex = ds; +function uf(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; +} +Q.htonl = uf; +function ps(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf(n4)), r3 += cf(n4.toString(16)); + } + return r3; +} +Q.toHex32 = ps; +function hf(e2) { + return e2.length === 1 ? "0" + e2 : e2; +} +Q.zero2 = hf; +function cf(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; +} +Q.zero8 = cf; +function vs(e2, t2, r3, i2) { + var n4 = r3 - t2; + us(n4 % 4 === 0); + for (var o2 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o2.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h4] = b3 >>> 0; + } + return o2; +} +Q.join32 = vs; +function ms$1(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r3[n4] = o2 >>> 24, r3[n4 + 1] = o2 >>> 16 & 255, r3[n4 + 2] = o2 >>> 8 & 255, r3[n4 + 3] = o2 & 255) : (r3[n4 + 3] = o2 >>> 24, r3[n4 + 2] = o2 >>> 16 & 255, r3[n4 + 1] = o2 >>> 8 & 255, r3[n4] = o2 & 255); + } + return r3; +} +Q.split32 = ms$1; +function gs(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; +} +Q.rotr32 = gs; +function As(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; +} +Q.rotl32 = As; +function bs(e2, t2) { + return e2 + t2 >>> 0; +} +Q.sum32 = bs; +function ys(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; +} +Q.sum32_3 = ys; +function ws(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; +} +Q.sum32_4 = ws; +function xs(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; +} +Q.sum32_5 = xs; +function Ms(e2, t2, r3, i2) { + var n4 = e2[t2], o2 = e2[t2 + 1], h4 = i2 + o2 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; +} +Q.sum64 = Ms; +function Es(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o2 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o2 >>> 0; +} +Q.sum64_hi = Es; +function Ss(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; +} +Q.sum64_lo = Ss; +function Ns(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o2 >>> 0, b3 += m3 < o2 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; +} +Q.sum64_4_hi = Ns; +function Is(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = t2 + i2 + o2 + p2; + return b3 >>> 0; +} +Q.sum64_4_lo = Is; +function _s(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o2 >>> 0, w3 += y3 < o2 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; +} +Q.sum64_5_hi = _s; +function Bs(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = t2 + i2 + o2 + p2 + m3; + return w3 >>> 0; +} +Q.sum64_5_lo = Bs; +function Cs(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; +} +Q.rotr64_hi = Cs; +function Rs(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q.rotr64_lo = Rs; +function Os(e2, t2, r3) { + return e2 >>> r3; +} +Q.shr64_hi = Os; +function Ps(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q.shr64_lo = Ps; +var fr = {}, lf = Q, Ds = yr; +function Fr() { + 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; +} +fr.BlockHash = Fr, Fr.prototype.update = function(t2, r3) { + if (t2 = lf.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; +}, Fr.prototype.digest = function(t2) { + return this.update(this._pad()), Ds(this.pending === null), this._digest(t2); +}, Fr.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n4[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 & 255; + } else + for (n4[o2++] = t2 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + return n4; +}; +var or = {}, ae = {}, Fs = Q, ue = Fs.rotr32; +function Ts(e2, t2, r3, i2) { + if (e2 === 0) + return df(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf(t2, r3, i2); + if (e2 === 2) + return pf(t2, r3, i2); +} +ae.ft_1 = Ts; +function df(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; +} +ae.ch32 = df; +function pf(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; +} +ae.maj32 = pf; +function vf(e2, t2, r3) { + return e2 ^ t2 ^ r3; +} +ae.p32 = vf; +function Us(e2) { + return ue(e2, 2) ^ ue(e2, 13) ^ ue(e2, 22); +} +ae.s0_256 = Us; +function ks(e2) { + return ue(e2, 6) ^ ue(e2, 11) ^ ue(e2, 25); +} +ae.s1_256 = ks; +function qs(e2) { + return ue(e2, 7) ^ ue(e2, 18) ^ e2 >>> 3; +} +ae.g0_256 = qs; +function Ks(e2) { + return ue(e2, 17) ^ ue(e2, 19) ^ e2 >>> 10; +} +ae.g1_256 = Ks; +var sr = Q, Hs = fr, zs = ae, _i = sr.rotl32, wr = sr.sum32, Ls = sr.sum32_5, js = zs.ft_1, mf = Hs.BlockHash, Qs = [1518500249, 1859775393, 2400959708, 3395469782]; +function he() { + if (!(this instanceof he)) + return new he(); + mf.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); +} +sr.inherits(he, mf); +var Js = he; +he.blockSize = 512, he.outSize = 160, he.hmacStrength = 80, he.padLength = 64, he.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls(_i(o2, 5), js(w3, h4, p2, b3), m3, i2[n4], Qs[w3]); + m3 = b3, b3 = p2, p2 = _i(h4, 30), h4 = o2, o2 = y3; + } + this.h[0] = wr(this.h[0], o2), this.h[1] = wr(this.h[1], h4), this.h[2] = wr(this.h[2], p2), this.h[3] = wr(this.h[3], b3), this.h[4] = wr(this.h[4], m3); +}, he.prototype._digest = function(t2) { + return t2 === "hex" ? sr.toHex32(this.h, "big") : sr.split32(this.h, "big"); +}; +var ar2 = Q, Gs = fr, ur = ae, Ys = yr, ie2 = ar2.sum32, Vs = ar2.sum32_4, Ws = ar2.sum32_5, Xs = ur.ch32, Zs = ur.maj32, $s = ur.s0_256, ta = ur.s1_256, ea = ur.g0_256, ra = ur.g1_256, gf = Gs.BlockHash, ia = [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 ce() { + if (!(this instanceof ce)) + return new ce(); + gf.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia, this.W = new Array(64); +} +ar2.inherits(ce, gf); +var Af = ce; +ce.blockSize = 512, ce.outSize = 256, ce.hmacStrength = 192, ce.padLength = 64, ce.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs(ra(i2[n4 - 2]), i2[n4 - 7], ea(i2[n4 - 15]), i2[n4 - 16]); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws(S2, ta(m3), Xs(m3, w3, y3), this.k[n4], i2[n4]), N2 = ie2($s(o2), Zs(o2, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie2(b3, I2), b3 = p2, p2 = h4, h4 = o2, o2 = ie2(I2, N2); + } + this.h[0] = ie2(this.h[0], o2), this.h[1] = ie2(this.h[1], h4), this.h[2] = ie2(this.h[2], p2), this.h[3] = ie2(this.h[3], b3), this.h[4] = ie2(this.h[4], m3), this.h[5] = ie2(this.h[5], w3), this.h[6] = ie2(this.h[6], y3), this.h[7] = ie2(this.h[7], S2); +}, ce.prototype._digest = function(t2) { + return t2 === "hex" ? ar2.toHex32(this.h, "big") : ar2.split32(this.h, "big"); +}; +var Bi = Q, bf = Af; +function ye() { + if (!(this instanceof ye)) + return new ye(); + bf.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; +} +Bi.inherits(ye, bf); +var na = ye; +ye.blockSize = 512, ye.outSize = 224, ye.hmacStrength = 192, ye.padLength = 64, ye.prototype._digest = function(t2) { + return t2 === "hex" ? Bi.toHex32(this.h.slice(0, 7), "big") : Bi.split32(this.h.slice(0, 7), "big"); +}; +var jt2 = Q, fa = fr, oa = yr, le = jt2.rotr64_hi, de = jt2.rotr64_lo, yf = jt2.shr64_hi, wf = jt2.shr64_lo, Be = jt2.sum64, Ci = jt2.sum64_hi, Ri = jt2.sum64_lo, sa = jt2.sum64_4_hi, aa = jt2.sum64_4_lo, ua = jt2.sum64_5_hi, ha = jt2.sum64_5_lo, xf = fa.BlockHash, ca = [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 ne2() { + if (!(this instanceof ne2)) + return new ne2(); + xf.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca, this.W = new Array(160); +} +jt2.inherits(ne2, xf); +var Mf = ne2; +ne2.blockSize = 1024, ne2.outSize = 512, ne2.hmacStrength = 192, ne2.padLength = 128, ne2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o2 = xa(i2[n4 - 4], i2[n4 - 3]), h4 = Ma(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya(i2[n4 - 30], i2[n4 - 29]), w3 = wa(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa(o2, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa(o2, h4, p2, b3, m3, w3, y3, S2); + } +}, ne2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o2 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa(S2, I2), W2 = ba(S2, I2), Rt2 = la(S2, I2, N2, C2, F2), Yt3 = da(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H2 = ma(n4, o2), z2 = ga(n4, o2), Pt2 = pa(n4, o2, h4, p2, b3), W2 = va(n4, o2, h4, p2, b3, m3); + var d5 = Ci(H2, z2, Pt2, W2), g3 = Ri(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci(w3, y3, a3, c2), I2 = Ri(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o2, n4 = Ci(a3, c2, d5, g3), o2 = Ri(a3, c2, d5, g3); + } + Be(this.h, 0, n4, o2), Be(this.h, 2, h4, p2), Be(this.h, 4, b3, m3), Be(this.h, 6, w3, y3), Be(this.h, 8, S2, I2), Be(this.h, 10, N2, C2), Be(this.h, 12, F2, U2), Be(this.h, 14, J2, Bt2); +}, ne2.prototype._digest = function(t2) { + return t2 === "hex" ? jt2.toHex32(this.h, "big") : jt2.split32(this.h, "big"); +}; +function la(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ ~e2 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function da(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ ~t2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function pa(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function va(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function ma(e2, t2) { + var r3 = le(e2, t2, 28), i2 = le(t2, e2, 2), n4 = le(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ga(e2, t2) { + var r3 = de(e2, t2, 28), i2 = de(t2, e2, 2), n4 = de(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Aa(e2, t2) { + var r3 = le(e2, t2, 14), i2 = le(e2, t2, 18), n4 = le(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ba(e2, t2) { + var r3 = de(e2, t2, 14), i2 = de(e2, t2, 18), n4 = de(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ya(e2, t2) { + var r3 = le(e2, t2, 1), i2 = le(e2, t2, 8), n4 = yf(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function wa(e2, t2) { + var r3 = de(e2, t2, 1), i2 = de(e2, t2, 8), n4 = wf(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function xa(e2, t2) { + var r3 = le(e2, t2, 19), i2 = le(t2, e2, 29), n4 = yf(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Ma(e2, t2) { + var r3 = de(e2, t2, 19), i2 = de(t2, e2, 29), n4 = wf(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +var Oi = Q, Ef = Mf; +function we() { + if (!(this instanceof we)) + return new we(); + Ef.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; +} +Oi.inherits(we, Ef); +var Ea = we; +we.blockSize = 1024, we.outSize = 384, we.hmacStrength = 192, we.padLength = 128, we.prototype._digest = function(t2) { + return t2 === "hex" ? Oi.toHex32(this.h.slice(0, 12), "big") : Oi.split32(this.h.slice(0, 12), "big"); +}, or.sha1 = Js, or.sha224 = na, or.sha256 = Af, or.sha384 = Ea, or.sha512 = Mf; +var Sf = {}, Xe = Q, Sa = fr, Tr = Xe.rotl32, Nf = Xe.sum32, xr = Xe.sum32_3, If = Xe.sum32_4, _f = Sa.BlockHash; +function pe() { + if (!(this instanceof pe)) + return new pe(); + _f.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; +} +Xe.inherits(pe, _f), Sf.ripemd160 = pe, pe.blockSize = 512, pe.outSize = 160, pe.hmacStrength = 192, pe.padLength = 64, pe.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o2 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o2, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf(Tr(If(i2, Bf(I2, n4, o2, h4), t2[_a[I2] + r3], Na(I2)), Ca[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr(o2, 10), o2 = n4, n4 = N2, N2 = Nf(Tr(If(b3, Bf(79 - I2, m3, w3, y3), t2[Ba[I2] + r3], Ia(I2)), Ra[I2]), S2), b3 = S2, S2 = y3, y3 = Tr(w3, 10), w3 = m3, m3 = N2; + } + N2 = xr(this.h[1], o2, y3), this.h[1] = xr(this.h[2], h4, S2), this.h[2] = xr(this.h[3], p2, b3), this.h[3] = xr(this.h[4], i2, m3), this.h[4] = xr(this.h[0], n4, w3), this.h[0] = N2; +}, pe.prototype._digest = function(t2) { + return t2 === "hex" ? Xe.toHex32(this.h, "little") : Xe.split32(this.h, "little"); +}; +function Bf(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); +} +function Na(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; +} +function Ia(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; +} +var _a = [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], Ba = [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], Ca = [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], Ra = [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], Oa = Q, Pa = yr; +function hr2(e2, t2, r3) { + if (!(this instanceof hr2)) + return new hr2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa.toArray(t2, r3)); +} +var Da = hr2; +hr2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); +}, hr2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; +}, hr2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); +}, function(e2) { + var t2 = e2; + t2.utils = Q, t2.common = fr, t2.sha = or, t2.ripemd = Sf, t2.hmac = Da, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; +}(se); +function cr(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; +} +function Fa() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var Pi = Cf; +function Cf(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +Cf.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var fe = cr(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); } - } + return b3; } - static create(a3, b3) { - return new ZodPipeline({ - in: a3, - out: b3, - typeName: ZodFirstPartyTypeKind$1.ZodPipeline - }); + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; } + r3.zero2 = n4; + function o2(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o2, r3.encode = function(p2, b3) { + return b3 === "hex" ? o2(p2) : p2; + }; +}), Jt = cr(function(e2, t2) { + var r3 = t2; + r3.assert = Pi, r3.toArray = fe.toArray, r3.zero2 = fe.zero2, r3.toHex = fe.toHex, r3.encode = fe.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N2 = 0; N2 < y3.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N2] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N2 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o2(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o2; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K2(b3, "hex", "le"); + } + r3.intFromLE = p2; +}), Ur = Jt.getNAF, Ta = Jt.getJSF, kr = Jt.assert; +function Ce(e2, t2) { + this.type = e2, this.p = new K2(t2.p, 16), this.red = t2.prime ? K2.red(t2.prime) : K2.mont(this.p), this.zero = new K2(0).toRed(this.red), this.one = new K2(1).toRed(this.red), this.two = new K2(2).toRed(this.red), this.n = t2.n && new K2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); +} +var Ze = Ce; +Ce.prototype.point = function() { + throw new Error("Not implemented"); +}, Ce.prototype.validate = function() { + throw new Error("Not implemented"); +}, Ce.prototype._fixedNafMul = function(t2, r3) { + kr(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur(r3, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); +}, Ce.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o2 = n4.points, h4 = Ur(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o2[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o2[w3 - 1 >> 1]) : p2 = p2.add(o2[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; +}, Ce.prototype._wnafMulAdd = function(t2, r3, i2, n4, o2) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N2 = w3 - 1, C2 = w3; + if (h4[N2] !== 1 || h4[C2] !== 1) { + b3[N2] = Ur(i2[N2], h4[N2], this._bitLength), b3[C2] = Ur(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N2].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; + } + var F2 = [r3[N2], null, null, r3[C2]]; + r3[N2].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N2].add(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())) : r3[N2].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].add(r3[C2].neg())) : (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta(i2[N2], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N2] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N2][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; + } + if (w3 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o2 ? H2 : H2.toP(); +}; +function Xt(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; +} +Ce.BasePoint = Xt, Xt.prototype.eq = function() { + throw new Error("Not implemented"); +}, Xt.prototype.validate = function() { + return this.curve.validate(this); +}, Ce.prototype.decodePoint = function(t2, r3) { + t2 = Jt.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); +}, Xt.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); +}, Xt.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); +}, Xt.prototype.encode = function(t2, r3) { + return Jt.encode(this._encode(r3), t2); +}, Xt.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; +}, Xt.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; +}, Xt.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o2 = 0; o2 < r3; o2 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; +}, Xt.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r3[o2] = r3[o2 - 1].add(n4); + return { wnd: t2, points: r3 }; +}, Xt.prototype._getBeta = function() { + return null; +}, Xt.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; +}; +var Di = cr(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; +}), Ua = Jt.assert; +function Zt2(e2) { + Ze.call(this, "short", e2), this.a = new K2(e2.a, 16).toRed(this.red), this.b = new K2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +Di(Zt2, Ze); +var ka = Zt2; +Zt2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K2(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K2(p2.a, 16), b: new K2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } +}, Zt2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K2.mont(t2), i2 = new K2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o2 = new K2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o2).fromRed(), p2 = n4.redSub(o2).fromRed(); + return [h4, p2]; +}, Zt2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o2 = new K2(1), h4 = new K2(0), p2 = new K2(0), b3 = new K2(1), m3, w3, y3, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o2, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o2, o2 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m3, N2 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y3, b: S2 }, { a: I2, b: N2 }]; +}, Zt2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o2 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b3 = h4.mul(n4.a), m3 = o2.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; +}, Zt2.prototype.pointFromX = function(t2, r3) { + t2 = new K2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n4.fromRed().isOdd(); + return (r3 && !o2 || !r3 && o2) && (n4 = n4.redNeg()), this.point(t2, n4); +}, Zt2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o2 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; +}, Zt2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o2 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o2[h4 * 2] = p2.k1, o2[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o2, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o2[y3] = null; + return w3; }; -const custom$1 = (check, params = {}, fatal) => { - if (check) - return ZodAny$1.create().superRefine((data, ctx) => { - var _a, _b; - if (!check(data)) { - const p3 = typeof params === "function" ? params(data) : params; - const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p3 === "string" ? { message: p3 } : p3; - ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); - } - }); - return ZodAny$1.create(); -}; -const late$1 = { - object: ZodObject$1.lazycreate -}; -var ZodFirstPartyTypeKind$1; -(function(ZodFirstPartyTypeKind2) { - ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; - ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; - ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; - ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; - ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; - ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; - ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; - ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; - ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; - ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; - ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; - ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; - ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; - ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; - ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; - ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; - ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; - ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; - ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; - ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; - ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; - ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; - ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; - ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; - ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; - ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; - ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; - ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; - ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; - ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; - ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; - ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; - ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; - ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; - ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; -})(ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {})); -const instanceOfType$1 = (cls, params = { - message: `Input not instance of ${cls.name}` -}) => custom$1((data) => data instanceof cls, params); -const stringType$1 = ZodString$1.create; -const numberType$1 = ZodNumber$1.create; -const nanType$1 = ZodNaN$1.create; -const bigIntType$1 = ZodBigInt$1.create; -const booleanType$1 = ZodBoolean$1.create; -const dateType$1 = ZodDate$1.create; -const symbolType$1 = ZodSymbol$1.create; -const undefinedType$1 = ZodUndefined$1.create; -const nullType$1 = ZodNull$1.create; -const anyType$1 = ZodAny$1.create; -const unknownType$1 = ZodUnknown$1.create; -const neverType$1 = ZodNever$1.create; -const voidType$1 = ZodVoid$1.create; -const arrayType$1 = ZodArray$1.create; -const objectType$1 = ZodObject$1.create; -const strictObjectType$1 = ZodObject$1.strictCreate; -const unionType$1 = ZodUnion$1.create; -const discriminatedUnionType$1 = ZodDiscriminatedUnion$1.create; -const intersectionType$1 = ZodIntersection$1.create; -const tupleType$1 = ZodTuple$1.create; -const recordType$1 = ZodRecord$1.create; -const mapType$1 = ZodMap$1.create; -const setType$1 = ZodSet$1.create; -const functionType$1 = ZodFunction$1.create; -const lazyType$1 = ZodLazy$1.create; -const literalType$1 = ZodLiteral$1.create; -const enumType$1 = ZodEnum$1.create; -const nativeEnumType$1 = ZodNativeEnum$1.create; -const promiseType$1 = ZodPromise$1.create; -const effectsType$1 = ZodEffects$1.create; -const optionalType$1 = ZodOptional$1.create; -const nullableType$1 = ZodNullable$1.create; -const preprocessType$1 = ZodEffects$1.createWithPreprocess; -const pipelineType$1 = ZodPipeline$1.create; -const ostring$1 = () => stringType$1().optional(); -const onumber$1 = () => numberType$1().optional(); -const oboolean$1 = () => booleanType$1().optional(); -const coerce$2 = { - string: (arg) => ZodString$1.create({ ...arg, coerce: true }), - number: (arg) => ZodNumber$1.create({ ...arg, coerce: true }), - boolean: (arg) => ZodBoolean$1.create({ - ...arg, - coerce: true - }), - bigint: (arg) => ZodBigInt$1.create({ ...arg, coerce: true }), - date: (arg) => ZodDate$1.create({ ...arg, coerce: true }) +function Ft(e2, t2, r3, i2) { + Ze.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); +} +Di(Ft, Ze.BasePoint), Zt2.prototype.point = function(t2, r3, i2) { + return new Ft(this, t2, r3, i2); +}, Zt2.prototype.pointFromJSON = function(t2, r3) { + return Ft.fromJSON(this, t2, r3); +}, Ft.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } +}, Ft.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; +}, Ft.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o2)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o2)) } }, n4; +}, Ft.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Ft.prototype.isInfinity = function() { + return this.inf; +}, Ft.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); +}, Ft.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); +}, Ft.prototype.getX = function() { + return this.x.fromRed(); +}, Ft.prototype.getY = function() { + return this.y.fromRed(); +}, Ft.prototype.mul = function(t2) { + return t2 = new K2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); +}, Ft.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2) : this.curve._wnafMulAdd(1, n4, o2, 2); +}, Ft.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2, true) : this.curve._wnafMulAdd(1, n4, o2, 2, true); +}, Ft.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); +}, Ft.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o2) { + return o2.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; +}, Ft.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; }; -const NEVER$1 = INVALID$1; -var z2 = /* @__PURE__ */ Object.freeze({ - __proto__: null, - defaultErrorMap: errorMap$1, - setErrorMap: setErrorMap$1, - getErrorMap: getErrorMap$1, - makeIssue: makeIssue$1, - EMPTY_PATH: EMPTY_PATH$1, - addIssueToContext: addIssueToContext$1, - ParseStatus: ParseStatus$1, - INVALID: INVALID$1, - DIRTY: DIRTY$1, - OK: OK$1, - isAborted: isAborted$1, - isDirty: isDirty$1, - isValid: isValid$1, - isAsync: isAsync$1, - get util() { - return util$1; - }, - get objectUtil() { - return objectUtil$1; - }, - ZodParsedType: ZodParsedType$1, - getParsedType: getParsedType$1, - ZodType: ZodType$1, - ZodString: ZodString$1, - ZodNumber: ZodNumber$1, - ZodBigInt: ZodBigInt$1, - ZodBoolean: ZodBoolean$1, - ZodDate: ZodDate$1, - ZodSymbol: ZodSymbol$1, - ZodUndefined: ZodUndefined$1, - ZodNull: ZodNull$1, - ZodAny: ZodAny$1, - ZodUnknown: ZodUnknown$1, - ZodNever: ZodNever$1, - ZodVoid: ZodVoid$1, - ZodArray: ZodArray$1, - ZodObject: ZodObject$1, - ZodUnion: ZodUnion$1, - ZodDiscriminatedUnion: ZodDiscriminatedUnion$1, - ZodIntersection: ZodIntersection$1, - ZodTuple: ZodTuple$1, - ZodRecord: ZodRecord$1, - ZodMap: ZodMap$1, - ZodSet: ZodSet$1, - ZodFunction: ZodFunction$1, - ZodLazy: ZodLazy$1, - ZodLiteral: ZodLiteral$1, - ZodEnum: ZodEnum$1, - ZodNativeEnum: ZodNativeEnum$1, - ZodPromise: ZodPromise$1, - ZodEffects: ZodEffects$1, - ZodTransformer: ZodEffects$1, - ZodOptional: ZodOptional$1, - ZodNullable: ZodNullable$1, - ZodDefault: ZodDefault$1, - ZodCatch: ZodCatch$1, - ZodNaN: ZodNaN$1, - BRAND: BRAND$1, - ZodBranded: ZodBranded$1, - ZodPipeline: ZodPipeline$1, - custom: custom$1, - Schema: ZodType$1, - ZodSchema: ZodType$1, - late: late$1, - get ZodFirstPartyTypeKind() { - return ZodFirstPartyTypeKind$1; - }, - coerce: coerce$2, - any: anyType$1, - array: arrayType$1, - bigint: bigIntType$1, - boolean: booleanType$1, - date: dateType$1, - discriminatedUnion: discriminatedUnionType$1, - effect: effectsType$1, - "enum": enumType$1, - "function": functionType$1, - "instanceof": instanceOfType$1, - intersection: intersectionType$1, - lazy: lazyType$1, - literal: literalType$1, - map: mapType$1, - nan: nanType$1, - nativeEnum: nativeEnumType$1, - never: neverType$1, - "null": nullType$1, - nullable: nullableType$1, - number: numberType$1, - object: objectType$1, - oboolean: oboolean$1, - onumber: onumber$1, - optional: optionalType$1, - ostring: ostring$1, - pipeline: pipelineType$1, - preprocess: preprocessType$1, - promise: promiseType$1, - record: recordType$1, - set: setType$1, - strictObject: strictObjectType$1, - string: stringType$1, - symbol: symbolType$1, - transformer: effectsType$1, - tuple: tupleType$1, - "undefined": undefinedType$1, - union: unionType$1, - unknown: unknownType$1, - "void": voidType$1, - NEVER: NEVER$1, - ZodIssueCode: ZodIssueCode$1, - quotelessJson: quotelessJson$1, - ZodError: ZodError$1 +function Tt(e2, t2, r3, i2) { + Ze.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K2(0)) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), this.z = new K2(i2, 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; +} +Di(Tt, Ze.BasePoint), Zt2.prototype.jpoint = function(t2, r3, i2) { + return new Tt(this, t2, r3, i2); +}, Tt.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); +}, Tt.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}, Tt.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o2 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o2), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N2 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N2, C2); +}, Tt.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o2 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o2.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o2.redMul(w3)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); +}, Tt.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o2 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N2 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o2), b3); +}, Tt.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}, Tt.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r3 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o2 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o2)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N2, C2); +}, Tt.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h4 = o2.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o2.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N2); +}, Tt.prototype.mul = function(t2, r3) { + return t2 = new K2(t2, r3), this.curve._wnafMul(this, t2); +}, Tt.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n4)).cmpn(0) === 0; +}, Tt.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o2 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } +}, Tt.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Tt.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var qr = cr(function(e2, t2) { + var r3 = t2; + r3.base = Ze, r3.short = ka, r3.mont = null, r3.edwards = null; +}), Kr = cr(function(e2, t2) { + var r3 = t2, i2 = Jt.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr.short(p2) : p2.type === "edwards" ? this.curve = new qr.edwards(p2) : this.curve = new qr.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o2(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o2("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: se.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se.sha384, gRed: false, 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"] }), o2("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: se.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se.sha256, gRed: false, g: ["9"] }), o2("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: se.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o2("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: se.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); }); -const aleoAddressRegex$1 = /^aleo1[a-z0-9]{58}$/i; -const aleoViewKeyRegex$1 = /^AViewKey1[a-z0-9]{44}$/i; -const aleoPrivateKeyRegex$1 = /^APrivateKey1[a-z0-9]{47}$/i; -const aleoTransactionIdRegex$1 = /^at1[a-z0-9]{58}$/i; -const aleoFieldRegex$1 = /^\d+field$/; -const aleoU32$1 = /^\d+u32$/; -const aleoU64$1 = /^\d+u64$/; -z2.string().regex(aleoAddressRegex$1); -z2.string().regex(aleoViewKeyRegex$1); -z2.string().regex(aleoPrivateKeyRegex$1); -z2.string().regex(aleoTransactionIdRegex$1); -z2.string().regex(aleoFieldRegex$1); -z2.string().regex(aleoU32$1); -z2.string().regex(aleoU64$1); -var InputOutputType$1; -(function(InputOutputType2) { - InputOutputType2["Record"] = "record"; - InputOutputType2["OutputRecord"] = "outputRecord"; - InputOutputType2["Public"] = "public"; - InputOutputType2["Private"] = "private"; - InputOutputType2["Constant"] = "constant"; - InputOutputType2["Future"] = "future"; - InputOutputType2["ExternalRecord"] = "external_record"; -})(InputOutputType$1 || (InputOutputType$1 = {})); -var EventType; -(function(EventType2) { - EventType2["Deploy"] = "Deploy"; - EventType2["Execute"] = "Execute"; - EventType2["Send"] = "Send"; - EventType2["Receive"] = "Receive"; - EventType2["Join"] = "Join"; - EventType2["Split"] = "Split"; - EventType2["Shield"] = "Shield"; - EventType2["Unshield"] = "Unshield"; -})(EventType || (EventType = {})); -var EventStatus; -(function(EventStatus2) { - EventStatus2["Creating"] = "Creating"; - EventStatus2["Pending"] = "Pending"; - EventStatus2["Settled"] = "Settled"; - EventStatus2["Failed"] = "Failed"; -})(EventStatus || (EventStatus = {})); -var Visibility; -(function(Visibility2) { - Visibility2["Private"] = "Private"; - Visibility2["Public"] = "Public"; -})(Visibility || (Visibility = {})); -var Network; -(function(Network2) { - Network2["AleoTestnet"] = "AleoTestnet"; - Network2["AleoMainnet"] = "AleoMainnet"; -})(Network || (Network = {})); -var AssetType; -(function(AssetType2) { - AssetType2[AssetType2["ALEO"] = 0] = "ALEO"; -})(AssetType || (AssetType = {})); -z2.nativeEnum(EventType); -z2.nativeEnum(EventStatus); -z2.nativeEnum(Network); -z2.nativeEnum(Visibility); +function Re(e2) { + if (!(this instanceof Re)) + return new Re(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe.toArray(e2.pers, e2.persEnc || "hex"); + Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); +} +var Rf = Re; +Re.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; +}, Re.prototype._hmac = function() { + return new se.hmac(this.hash, this.K); +}, Re.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); +}, Re.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe.toArray(t2, r3), i2 = fe.toArray(i2, n4), Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; +}, Re.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h4 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe.encode(h4, r3); +}; +var Fi = Jt.assert; +function kt2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); +} +var Ti = kt2; +kt2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { pub: r3, pubEnc: i2 }); +}, kt2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { priv: r3, privEnc: i2 }); +}, kt2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; +}, kt2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; +}, kt2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; +}, kt2.prototype._importPrivate = function(t2, r3) { + this.priv = new K2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); +}, kt2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); +}, kt2.prototype.derive = function(t2) { + return t2.validate() || Fi(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); +}, kt2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); +}, kt2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); +}, kt2.prototype.inspect = function() { + return ""; +}; +var qa = Jt.assert; +function Hr(e2, t2) { + if (e2 instanceof Hr) + return e2; + this._importDER(e2, t2) || (qa(e2.r && e2.s, "Signature without r or s"), this.r = new K2(e2.r, 16), this.s = new K2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); +} +var zr = Hr; +function Ka() { + this.place = 0; +} +function Ui(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o2 = 0, h4 = t2.place; o2 < i2; o2++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); +} +function Of(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); +} +Hr.prototype._importDER = function(t2, r3) { + t2 = Jt.toArray(t2, r3); + var i2 = new Ka(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui(t2, i2); + if (o2 === false) + return false; + var h4 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K2(h4), this.s = new K2(b3), this.recoveryParam = null, true; +}; +function ki(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); +} +Hr.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of(r3), i2 = Of(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki(n4, i2.length); + var o2 = n4.concat(i2), h4 = [48]; + return ki(h4, o2.length), h4 = h4.concat(o2), Jt.encode(h4, t2); +}; +var Ha = function() { + throw new Error("unsupported"); +}, Pf = Jt.assert; +function $t(e2) { + if (!(this instanceof $t)) + return new $t(e2); + typeof e2 == "string" && (Pf(Object.prototype.hasOwnProperty.call(Kr, e2), "Unknown curve " + e2), e2 = Kr[e2]), e2 instanceof Kr.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; +} +var za = $t; +$t.prototype.keyPair = function(t2) { + return new Ti(this, t2); +}, $t.prototype.keyFromPrivate = function(t2, r3) { + return Ti.fromPrivate(this, t2, r3); +}, $t.prototype.keyFromPublic = function(t2, r3) { + return Ti.fromPublic(this, t2, r3); +}, $t.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K2(2)); ; ) { + var o2 = new K2(r3.generate(i2)); + if (!(o2.cmp(n4) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } +}, $t.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; +}, $t.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K2(t2, 16)); + for (var o2 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b3 = new Rf({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N2.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr({ r: N2, s: C2, recoveryParam: F2 }); + } + } + } + } + } +}, $t.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr(r3, "hex"); + var o2 = r3.r, h4 = r3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o2).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o2)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o2) === 0); +}, $t.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr(t2, i2); + var n4 = this.n, o2 = new K2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o2).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); +}, $t.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; + } + if (o2.eq(r3)) + return n4; + } + throw new Error("Unable to find valid recovery factor"); +}; +var La = cr(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr, r3.curves = Kr, r3.ec = za, r3.eddsa = null; +}); +La.ec; +var Ff; +(function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; +})(Ff || (Ff = {})); +const go = { 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 } }; +function tr(e2, t2) { + const { message: r3, code: i2 } = go[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; +} +const emitter$1 = new EventEmitter$1(); +let connection = void 0; +async function configureConnection$1(options) { + let disconnectSessions = false; + const thisVersion = pkg$1.version; + const prevVersion = localStorage.getItem("puzzle_sdk_version"); + if (thisVersion !== prevVersion) { + console.log( + `${pkg$1.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" + ); + localStorage.setItem("puzzle_sdk_version", thisVersion); + disconnectSessions = true; + } + connection = new G({ + projectId: options.projectId ?? projectId$1, + metadata: { + name: options.dAppName, + description: options.dAppDescription, + url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", + icons: [options.dAppIconURL] + }, + modalOptions: { ...web3modal_puzzle_props$1 } + }); + if (disconnectSessions) { + localStorage.removeItem("puzzle-hasInjectedConnection"); + try { + disconnectOnVersionChange$1(connection, options.onDisconnect); + } catch (e2) { + console.error(e2); + } + } + connection.onSessionDelete(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + connection.onSessionExpire(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + if (typeof window !== "undefined") { + window.puzzleSdkConnection = connection; + } + return connection; +} +async function disconnectOnVersionChange$1(connection2, onDisconnect) { + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (session) { + console.log("Disconnecting session", session); + onDisconnect && onDisconnect(); + connection2.disconnect({ + topic: session.topic, + reason: tr("USER_DISCONNECTED") + }); + } +} +async function getWalletConnectModalSignClient$1() { + return new Promise((resolve) => { + if (connection) { + resolve(connection); + } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { + resolve(window.puzzleSdkConnection); + } else { + const interval = setInterval(() => { + if (connection) { + clearInterval(interval); + resolve(connection); + } + }, 200); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + }); +} +const checkForDesktopConnection$1 = async (sessionTopic) => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + try { + const res = await window.aleo.puzzleWalletClient.isConnected.query( + { sessionTopic } + ); + if (res) { + localStorage.setItem("puzzle-hasInjectedConnection", "true"); + return true; + } else { + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + } catch (e2) { + console.warn(e2); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } +}; +const hasInjectedConnection$1 = () => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + return false; + } + const puzzleHasDesktopConnection = localStorage.getItem( + "puzzle-hasInjectedConnection" + ); + return puzzleHasDesktopConnection === "true"; +}; var browser$5 = { exports: {} }; var ms; var hasRequiredMs; @@ -16606,11 +23711,11 @@ function requireMs() { return ms; hasRequiredMs = 1; var s2 = 1e3; - var m2 = s2 * 60; - var h4 = m2 * 60; - var d3 = h4 * 24; - var w3 = d3 * 7; - var y3 = d3 * 365.25; + var m3 = s2 * 60; + var h4 = m3 * 60; + var d5 = h4 * 24; + var w3 = d5 * 7; + var y3 = d5 * 365.25; ms = function(val, options) { options = options || {}; var type2 = typeof val; @@ -16634,7 +23739,7 @@ function requireMs() { if (!match) { return; } - var n3 = parseFloat(match[1]); + var n4 = parseFloat(match[1]); var type2 = (match[2] || "ms").toLowerCase(); switch (type2) { case "years": @@ -16642,53 +23747,53 @@ function requireMs() { case "yrs": case "yr": case "y": - return n3 * y3; + return n4 * y3; case "weeks": case "week": case "w": - return n3 * w3; + return n4 * w3; case "days": case "day": case "d": - return n3 * d3; + return n4 * d5; case "hours": case "hour": case "hrs": case "hr": case "h": - return n3 * h4; + return n4 * h4; case "minutes": case "minute": case "mins": case "min": case "m": - return n3 * m2; + return n4 * m3; case "seconds": case "second": case "secs": case "sec": case "s": - return n3 * s2; + return n4 * s2; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": - return n3; + return n4; default: return void 0; } } function fmtShort(ms2) { var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return Math.round(ms2 / d3) + "d"; + if (msAbs >= d5) { + return Math.round(ms2 / d5) + "d"; } if (msAbs >= h4) { return Math.round(ms2 / h4) + "h"; } - if (msAbs >= m2) { - return Math.round(ms2 / m2) + "m"; + if (msAbs >= m3) { + return Math.round(ms2 / m3) + "m"; } if (msAbs >= s2) { return Math.round(ms2 / s2) + "s"; @@ -16697,23 +23802,23 @@ function requireMs() { } function fmtLong(ms2) { var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return plural(ms2, msAbs, d3, "day"); + if (msAbs >= d5) { + return plural(ms2, msAbs, d5, "day"); } if (msAbs >= h4) { return plural(ms2, msAbs, h4, "hour"); } - if (msAbs >= m2) { - return plural(ms2, msAbs, m2, "minute"); + if (msAbs >= m3) { + return plural(ms2, msAbs, m3, "minute"); } if (msAbs >= s2) { return plural(ms2, msAbs, s2, "second"); } return ms2 + " ms"; } - function plural(ms2, msAbs, n3, name2) { - var isPlural = msAbs >= n3 * 1.5; - return Math.round(ms2 / n3) + " " + name2 + (isPlural ? "s" : ""); + function plural(ms2, msAbs, n4, name2) { + var isPlural = msAbs >= n4 * 1.5; + return Math.round(ms2 / n4) + " " + name2 + (isPlural ? "s" : ""); } return ms; } @@ -16762,12 +23867,12 @@ function setup(env2) { args.unshift("%O"); } let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => { if (match === "%%") { return "%"; } index++; - const formatter = createDebug.formatters[format]; + const formatter = createDebug.formatters[format2]; if (typeof formatter === "function") { const val = args[index]; match = formatter.call(self2, val); @@ -17013,15 +24118,15 @@ var common = setup; } } function load() { - let r2; + let r3; try { - r2 = exports2.storage.getItem("debug"); + r3 = exports2.storage.getItem("debug"); } catch (error) { } - if (!r2 && typeof process !== "undefined" && "env" in process) { - r2 = process.env.DEBUG; + if (!r3 && typeof process !== "undefined" && "env" in process) { + r3 = process.env.DEBUG; } - return r2; + return r3; } function localstorage() { try { @@ -17084,19 +24189,19 @@ function createJSONStorage(getStorage, options) { let storage; try { storage = getStorage(); - } catch (e) { + } catch (e2) { return; } const persistStorage = { getItem: (name2) => { - var _a; + var _a2; const parse = (str2) => { if (str2 === null) { return null; } - return JSON.parse(str2, options == null ? void 0 : options.reviver); + return JSON.parse(str2, void 0); }; - const str = (_a = storage.getItem(name2)) != null ? _a : null; + const str = (_a2 = storage.getItem(name2)) != null ? _a2 : null; if (str instanceof Promise) { return str.then(parse); } @@ -17104,15 +24209,15 @@ function createJSONStorage(getStorage, options) { }, setItem: (name2, newValue) => storage.setItem( name2, - JSON.stringify(newValue, options == null ? void 0 : options.replacer) + JSON.stringify(newValue, void 0) ), removeItem: (name2) => storage.removeItem(name2) }; return persistStorage; } -const toThenable = (fn2) => (input) => { +const toThenable = (fn) => (input) => { try { - const result = fn2(input); + const result = fn(input); if (result instanceof Promise) { return result; } @@ -17124,13 +24229,13 @@ const toThenable = (fn2) => (input) => { return this; } }; - } catch (e) { + } catch (e2) { return { then(_onFulfilled) { return this; }, catch(onRejected) { - return toThenable(onRejected)(e); + return toThenable(onRejected)(e2); } }; } @@ -17154,7 +24259,7 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { let storage; try { storage = options.getStorage(); - } catch (e) { + } catch (e2) { } if (!storage) { return config( @@ -17174,8 +24279,8 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { let errorInSync; const thenable = thenableSerialize({ state, version: options.version }).then( (serializedValue) => storage.setItem(options.name, serializedValue) - ).catch((e) => { - errorInSync = e; + ).catch((e2) => { + errorInSync = e2; }); if (errorInSync) { throw errorInSync; @@ -17197,12 +24302,12 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { ); let stateFromStorage; const hydrate = () => { - var _a; + var _a2; if (!storage) return; hasHydrated = false; hydrationListeners.forEach((cb) => cb(get2())); - const postRehydrationCallback = ((_a = options.onRehydrateStorage) == null ? void 0 : _a.call(options, get2())) || void 0; + const postRehydrationCallback = ((_a2 = options.onRehydrateStorage) == null ? void 0 : _a2.call(options, get2())) || void 0; return toThenable(storage.getItem.bind(storage))(options.name).then((storageValue) => { if (storageValue) { return options.deserialize(storageValue); @@ -17224,10 +24329,10 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { } } }).then((migratedState) => { - var _a2; + var _a22; stateFromStorage = options.merge( migratedState, - (_a2 = get2()) != null ? _a2 : configResult + (_a22 = get2()) != null ? _a22 : configResult ); set2(stateFromStorage, true); return setItem(); @@ -17235,8 +24340,8 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0); hasHydrated = true; finishHydrationListeners.forEach((cb) => cb(stateFromStorage)); - }).catch((e) => { - postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e); + }).catch((e2) => { + postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e2); }); }; api.persist = { @@ -17321,15 +24426,15 @@ const newImpl = (config, baseOptions) => (set2, get2, api) => { api.getInitialState = () => configResult; let stateFromStorage; const hydrate = () => { - var _a, _b; + var _a2, _b; if (!storage) return; hasHydrated = false; hydrationListeners.forEach((cb) => { - var _a2; - return cb((_a2 = get2()) != null ? _a2 : configResult); + var _a22; + return cb((_a22 = get2()) != null ? _a22 : configResult); }); - const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get2()) != null ? _a : configResult)) || void 0; + const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0; return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => { if (deserializedStorageValue) { if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) { @@ -17347,10 +24452,10 @@ const newImpl = (config, baseOptions) => (set2, get2, api) => { } } }).then((migratedState) => { - var _a2; + var _a22; stateFromStorage = options.merge( migratedState, - (_a2 = get2()) != null ? _a2 : configResult + (_a22 = get2()) != null ? _a22 : configResult ); set2(stateFromStorage, true); return setItem(); @@ -17359,8 +24464,8 @@ const newImpl = (config, baseOptions) => (set2, get2, api) => { stateFromStorage = get2(); hasHydrated = true; finishHydrationListeners.forEach((cb) => cb(stateFromStorage)); - }).catch((e) => { - postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e); + }).catch((e2) => { + postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e2); }); }; api.persist = { @@ -17461,15 +24566,15 @@ function useRequestQuery({ queryKey, async () => fetchRequest(wcParams, queryKey), queryOptions ?? { - staleTime: queryKey[0] === "getEvent" ? 7500 : 45e3, - refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 3e4, + staleTime: queryKey[0] === "getEvent" ? 7500 : 3e4, + refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 15e3, refetchIntervalInBackground: true, enabled, retry: true } ); } -function useExtensionRequestQuery({ +function useInjectedRequestQuery({ queryKey, wcParams, enabled, @@ -17480,8 +24585,8 @@ function useExtensionRequestQuery({ queryKey, async () => fetchFunction(wcParams), queryOptions ?? { - staleTime: queryKey[0] === "getEvent" ? 7500 : 45e3, - refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 3e4, + staleTime: queryKey[0] === "getEvent" ? 7500 : 3e4, + refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 15e3, refetchIntervalInBackground: true, enabled, retry: true @@ -17497,17 +24602,17 @@ function useRequest(params, fetchFunction) { const response = await fetchRequest(paramsOverride ?? params); setData(response); return response; - } catch (e) { - setError(e); + } catch (e2) { + setError(e2); setLoading(false); - throw e; + throw e2; } finally { setLoading(false); } } return { data, error, loading, request }; } -function useExtensionRequest(params, fetchFunction) { +function useInjectedRequest(params, fetchFunction) { const { data, error, loading, setData, setError, setLoading } = useAsyncAction(); async function request(paramsOverride) { try { @@ -17516,10 +24621,10 @@ function useExtensionRequest(params, fetchFunction) { const response = await fetchFunction(paramsOverride ?? params); setData(response); return response; - } catch (e) { - setError(e); + } catch (e2) { + setError(e2); setLoading(false); - throw e; + throw e2; } finally { setLoading(false); } @@ -17556,9 +24661,11 @@ const useInjectedSubscriptions = ({ } ); return () => { - subscriptions.forEach((subscription) => subscription.unsubscribe()); + subscriptions.forEach((subscription) => { + subscription.unsubscribe(); + }); }; - }, [session == null ? void 0 : session.topic, configs]); + }, [session == null ? void 0 : session.topic, ...configs.flatMap((config) => config.dependencies)]); }; var jsxRuntime = { exports: {} }; var reactJsxRuntime_production_min = {}; @@ -17576,18 +24683,18 @@ function requireReactJsxRuntime_production_min() { if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min; hasRequiredReactJsxRuntime_production_min = 1; - var f2 = React, k2 = Symbol.for("react.element"), l2 = Symbol.for("react.fragment"), m2 = Object.prototype.hasOwnProperty, n3 = f2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p3 = { key: true, ref: true, __self: true, __source: true }; + var f3 = React, k2 = Symbol.for("react.element"), l2 = Symbol.for("react.fragment"), m3 = Object.prototype.hasOwnProperty, n4 = f3.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p2 = { key: true, ref: true, __self: true, __source: true }; function q2(c2, a3, g3) { - var b3, d3 = {}, e = null, h4 = null; - void 0 !== g3 && (e = "" + g3); - void 0 !== a3.key && (e = "" + a3.key); + var b3, d5 = {}, e2 = null, h4 = null; + void 0 !== g3 && (e2 = "" + g3); + void 0 !== a3.key && (e2 = "" + a3.key); void 0 !== a3.ref && (h4 = a3.ref); for (b3 in a3) - m2.call(a3, b3) && !p3.hasOwnProperty(b3) && (d3[b3] = a3[b3]); + m3.call(a3, b3) && !p2.hasOwnProperty(b3) && (d5[b3] = a3[b3]); if (c2 && c2.defaultProps) for (b3 in a3 = c2.defaultProps, a3) - void 0 === d3[b3] && (d3[b3] = a3[b3]); - return { $$typeof: k2, type: c2, key: e, ref: h4, props: d3, _owner: n3.current }; + void 0 === d5[b3] && (d5[b3] = a3[b3]); + return { $$typeof: k2, type: c2, key: e2, ref: h4, props: d5, _owner: n4.current }; } reactJsxRuntime_production_min.Fragment = l2; reactJsxRuntime_production_min.jsx = q2; @@ -17638,28 +24745,28 @@ function requireReactJsxRuntime_development() { return null; } var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - function error(format) { + function error(format2) { { { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } - printWarning("error", format, args); + printWarning("error", format2, args); } } } - function printWarning(level, format, args) { + function printWarning(level, format2, args) { { var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ReactDebugCurrentFrame2.getStackAddendum(); if (stack !== "") { - format += "%s"; + format2 += "%s"; args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { return String(item); }); - argsWithFormat.unshift("Warning: " + format); + argsWithFormat.unshift("Warning: " + format2); Function.prototype.apply.call(console[level], console, argsWithFormat); } } @@ -17860,12 +24967,12 @@ function requireReactJsxRuntime_development() { var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; componentFrameCache = new PossiblyWeakMap(); } - function describeNativeComponentFrame(fn2, construct) { - if (!fn2 || reentry) { + function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) { return ""; } { - var frame = componentFrameCache.get(fn2); + var frame = componentFrameCache.get(fn); if (frame !== void 0) { return frame; } @@ -17896,14 +25003,14 @@ function requireReactJsxRuntime_development() { } catch (x2) { control = x2; } - Reflect.construct(fn2, [], Fake); + Reflect.construct(fn, [], Fake); } else { try { Fake.call(); } catch (x2) { control = x2; } - fn2.call(Fake.prototype); + fn.call(Fake.prototype); } } else { try { @@ -17911,7 +25018,7 @@ function requireReactJsxRuntime_development() { } catch (x2) { control = x2; } - fn2(); + fn(); } } catch (sample) { if (sample && control && typeof sample.stack === "string") { @@ -17930,12 +25037,12 @@ function requireReactJsxRuntime_development() { c2--; if (c2 < 0 || sampleLines[s2] !== controlLines[c2]) { var _frame = "\n" + sampleLines[s2].replace(" at new ", " at "); - if (fn2.displayName && _frame.includes("")) { - _frame = _frame.replace("", fn2.displayName); + if (fn.displayName && _frame.includes("")) { + _frame = _frame.replace("", fn.displayName); } { - if (typeof fn2 === "function") { - componentFrameCache.set(fn2, _frame); + if (typeof fn === "function") { + componentFrameCache.set(fn, _frame); } } return _frame; @@ -17954,18 +25061,18 @@ function requireReactJsxRuntime_development() { } Error.prepareStackTrace = previousPrepareStackTrace; } - var name2 = fn2 ? fn2.displayName || fn2.name : ""; + var name2 = fn ? fn.displayName || fn.name : ""; var syntheticFrame = name2 ? describeBuiltInComponentFrame(name2) : ""; { - if (typeof fn2 === "function") { - componentFrameCache.set(fn2, syntheticFrame); + if (typeof fn === "function") { + componentFrameCache.set(fn, syntheticFrame); } } return syntheticFrame; } - function describeFunctionComponentFrame(fn2, source, ownerFn) { + function describeFunctionComponentFrame(fn, source, ownerFn) { { - return describeNativeComponentFrame(fn2, false); + return describeNativeComponentFrame(fn, false); } } function shouldConstruct(Component) { @@ -18070,7 +25177,7 @@ function requireReactJsxRuntime_development() { try { testStringCoercion(value); return false; - } catch (e) { + } catch (e2) { return true; } } @@ -18283,11 +25390,6 @@ function requireReactJsxRuntime_development() { } function getSourceInfoErrorAddendum(source) { { - if (source !== void 0) { - var fileName = source.fileName.replace(/^.*[\\\/]/, ""); - var lineNumber = source.lineNumber; - return "\n\nCheck your code at " + fileName + ":" + lineNumber + "."; - } return ""; } } @@ -18404,6 +25506,7 @@ function requireReactJsxRuntime_development() { } } } + var didWarnAboutKeySpread = {}; function jsxWithValidation(type2, props, key, isStaticChildren, source, self2) { { var validType = isValidElementType(type2); @@ -18412,7 +25515,7 @@ function requireReactJsxRuntime_development() { if (type2 === void 0 || typeof type2 === "object" && type2 !== null && Object.keys(type2).length === 0) { info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."; } - var sourceInfo = getSourceInfoErrorAddendum(source); + var sourceInfo = getSourceInfoErrorAddendum(); if (sourceInfo) { info += sourceInfo; } else { @@ -18454,6 +25557,20 @@ function requireReactJsxRuntime_development() { } } } + { + if (hasOwnProperty.call(props, "key")) { + var componentName = getComponentNameFromType(type2); + var keys2 = Object.keys(props).filter(function(k2) { + return k2 !== "key"; + }); + var beforeExample = keys2.length > 0 ? "{key: someKey, " + keys2.join(": ..., ") + ": ...}" : "{key: someKey}"; + if (!didWarnAboutKeySpread[componentName + beforeExample]) { + var afterExample = keys2.length > 0 ? "{" + keys2.join(": ..., ") + ": ...}" : "{}"; + error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName); + didWarnAboutKeySpread[componentName + beforeExample] = true; + } + } + } if (type2 === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); } else { @@ -19199,24 +26316,24 @@ var Registry = ( }() ); var __extends = /* @__PURE__ */ function() { - var extendStatics2 = function(d3, b3) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { - d4.__proto__ = b4; - } || function(d4, b4) { - for (var p3 in b4) - if (Object.prototype.hasOwnProperty.call(b4, p3)) - d4[p3] = b4[p3]; + var extendStatics2 = function(d5, b3) { + extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d6, b4) { + d6.__proto__ = b4; + } || function(d6, b4) { + for (var p2 in b4) + if (Object.prototype.hasOwnProperty.call(b4, p2)) + d6[p2] = b4[p2]; }; - return extendStatics2(d3, b3); + return extendStatics2(d5, b3); }; - return function(d3, b3) { + return function(d5, b3) { if (typeof b3 !== "function" && b3 !== null) throw new TypeError("Class extends value " + String(b3) + " is not a constructor or null"); - extendStatics2(d3, b3); + extendStatics2(d5, b3); function __() { - this.constructor = d3; + this.constructor = d5; } - d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); + d5.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); }; }(); var ClassRegistry = ( @@ -19246,26 +26363,26 @@ var ClassRegistry = ( return ClassRegistry2; }(Registry) ); -var __read$3 = function(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +var __read$3 = function(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; }; function valuesOfObj(record) { if ("values" in Object) { @@ -19294,8 +26411,8 @@ function find(record, predicate) { return void 0; } function forEach(record, run) { - Object.entries(record).forEach(function(_a) { - var _b = __read$3(_a, 2), key = _b[0], value = _b[1]; + Object.entries(record).forEach(function(_a2) { + var _b = __read$3(_a2, 2), key = _b[0], value = _b[1]; return run(value, key); }); } @@ -19431,41 +26548,41 @@ var parsePath = function(string2) { }; var __assign$1 = function() { __assign$1 = Object.assign || function(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { + for (var s2, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2)) + t2[p2] = s2[p2]; } return t2; }; return __assign$1.apply(this, arguments); }; -var __read$2 = function(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +var __read$2 = function(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; }; -var __spreadArray$2 = function(to, from2) { - for (var i2 = 0, il = from2.length, j2 = to.length; i2 < il; i2++, j2++) - to[j2] = from2[i2]; - return to; +var __spreadArray$2 = function(to2, from2) { + for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) + to2[j2] = from2[i2]; + return to2; }; function simpleTransformation(isApplicable, annotation, transform, untransform) { return { @@ -19505,13 +26622,13 @@ var simpleRules = [ }); return baseError; }, function(v3, superJson) { - var e = new Error(v3.message); - e.name = v3.name; - e.stack = v3.stack; + var e2 = new Error(v3.message); + e2.name = v3.name; + e2.stack = v3.stack; superJson.allowedErrorProps.forEach(function(prop) { - e[prop] = v3[prop]; + e2[prop] = v3[prop]; }); - return e; + return e2; }), simpleTransformation(isRegExp, "regexp", function(v3) { return "" + v3; @@ -19701,11 +26818,11 @@ var untransformValue = function(json, type2, superJson) { return transformation.untransform(json, superJson); } }; -var getNthKey = function(value, n3) { +var getNthKey = function(value, n4) { var keys2 = value.keys(); - while (n3 > 0) { + while (n4 > 0) { keys2.next(); - n3--; + n4--; } return keys2.next().value; }; @@ -19813,31 +26930,31 @@ var setDeep = function(object, path, mapper) { } return object; }; -var __read$1 = function(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +var __read$1 = function(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; }; -var __spreadArray$1 = function(to, from2) { - for (var i2 = 0, il = from2.length, j2 = to.length; i2 < il; i2++, j2++) - to[j2] = from2[i2]; - return to; +var __spreadArray$1 = function(to2, from2) { + for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) + to2[j2] = from2[i2]; + return to2; }; function traverse(tree, walker2, origin) { if (origin === void 0) { @@ -19852,7 +26969,7 @@ function traverse(tree, walker2, origin) { }); return; } - var _a = __read$1(tree, 2), nodeValue = _a[0], children = _a[1]; + var _a2 = __read$1(tree, 2), nodeValue = _a2[0], children = _a2[1]; if (children) { forEach(children, function(child, key) { traverse(child, walker2, __spreadArray$1(__spreadArray$1([], __read$1(origin)), __read$1(parsePath(key)))); @@ -19878,7 +26995,7 @@ function applyReferentialEqualityAnnotations(plain, annotations) { }); } if (isArray$1(annotations)) { - var _a = __read$1(annotations, 2), root = _a[0], other = _a[1]; + var _a2 = __read$1(annotations, 2), root = _a2[0], other = _a2[1]; root.forEach(function(identicalPath) { plain = setDeep(plain, parsePath(identicalPath), function() { return plain; @@ -19917,7 +27034,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) { return a3.length - b3.length; }); } - var _a = __read$1(paths), representativePath = _a[0], identicalPaths = _a.slice(1); + var _a2 = __read$1(paths), representativePath = _a2[0], identicalPaths = _a2.slice(1); if (representativePath.length === 0) { rootEqualityPaths = identicalPaths.map(stringifyPath); } else { @@ -19935,7 +27052,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) { } } var walker = function(object, identities, superJson, dedupe, path, objectsInThisPath, seenObjects) { - var _a; + var _a2; if (path === void 0) { path = []; } @@ -19974,7 +27091,7 @@ var walker = function(object, identities, superJson, dedupe, path, objectsInThis }; } var transformationResult = transformValue(object, superJson); - var transformed = (_a = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a !== void 0 ? _a : object; + var transformed = (_a2 = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a2 !== void 0 ? _a2 : object; var transformedValue = isArray$1(transformed) ? [] : {}; var innerAnnotations = {}; forEach(transformed, function(value, index) { @@ -20046,51 +27163,51 @@ function copy(target, options = {}) { } var __assign = function() { __assign = Object.assign || function(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { + for (var s2, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2)) + t2[p2] = s2[p2]; } return t2; }; return __assign.apply(this, arguments); }; -var __read = function(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +var __read = function(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; }; -var __spreadArray = function(to, from2) { - for (var i2 = 0, il = from2.length, j2 = to.length; i2 < il; i2++, j2++) - to[j2] = from2[i2]; - return to; +var __spreadArray = function(to2, from2) { + for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) + to2[j2] = from2[i2]; + return to2; }; var SuperJSON = ( /** @class */ function() { - function SuperJSON2(_a) { - var _b = _a === void 0 ? {} : _a, _c = _b.dedupe, dedupe = _c === void 0 ? false : _c; + function SuperJSON2(_a2) { + var _b = _a2 === void 0 ? {} : _a2, _c = _b.dedupe, dedupe = _c === void 0 ? false : _c; this.classRegistry = new ClassRegistry(); this.symbolRegistry = new Registry(function(s2) { - var _a2; - return (_a2 = s2.description) !== null && _a2 !== void 0 ? _a2 : ""; + var _a3; + return (_a3 = s2.description) !== null && _a3 !== void 0 ? _a3 : ""; }); this.customTransformerRegistry = new CustomTransformerRegistry(); this.allowedErrorProps = []; @@ -20138,12 +27255,12 @@ var SuperJSON = ( this.customTransformerRegistry.register(__assign({ name: name2 }, transformer)); }; SuperJSON2.prototype.allowErrorProps = function() { - var _a; + var _a2; var props = []; - for (var _i = 0; _i < arguments.length; _i++) { - props[_i] = arguments[_i]; + for (var _i2 = 0; _i2 < arguments.length; _i2++) { + props[_i2] = arguments[_i2]; } - (_a = this.allowedErrorProps).push.apply(_a, __spreadArray([], __read(props))); + (_a2 = this.allowedErrorProps).push.apply(_a2, __spreadArray([], __read(props))); }; SuperJSON2.defaultInstance = new SuperJSON2(); SuperJSON2.serialize = SuperJSON2.defaultInstance.serialize.bind(SuperJSON2.defaultInstance); @@ -20628,7 +27745,7 @@ const DefaultRenderer = ({ }) : null, expanded ? subEntryPages.length === 1 ? /* @__PURE__ */ React__namespace.createElement(SubEntries, null, subEntries.map(handleEntry)) : /* @__PURE__ */ React__namespace.createElement(SubEntries, null, subEntryPages.map((entries, index) => /* @__PURE__ */ React__namespace.createElement("div", { key: index }, /* @__PURE__ */ React__namespace.createElement(Entry, null, /* @__PURE__ */ React__namespace.createElement(LabelButton, { - onClick: () => setExpandedPages((old) => old.includes(index) ? old.filter((d3) => d3 !== index) : [...old, index]) + onClick: () => setExpandedPages((old) => old.includes(index) ? old.filter((d5) => d5 !== index) : [...old, index]) }, /* @__PURE__ */ React__namespace.createElement(Expander, { expanded }), " [", index * pageSize, " ...", " ", index * pageSize + pageSize - 1, "]"), expandedPages.includes(index) ? /* @__PURE__ */ React__namespace.createElement(SubEntries, null, entries.map(handleEntry)) : null)))) : null) : /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(Label, null, label, ":"), " ", /* @__PURE__ */ React__namespace.createElement(Value, null, displayValue(value)))); @@ -20659,9 +27776,9 @@ function Explorer({ }; if (Array.isArray(value)) { type2 = "array"; - subEntries = value.map((d3, i2) => makeProperty({ + subEntries = value.map((d5, i2) => makeProperty({ label: i2.toString(), - value: d3 + value: d5 })); } else if (value !== null && typeof value === "object" && isIterable(value) && typeof value[Symbol.iterator] === "function") { type2 = "Iterable"; @@ -20737,34 +27854,34 @@ function requireUseSyncExternalStoreShim_production_min() { if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min; hasRequiredUseSyncExternalStoreShim_production_min = 1; - var e = React; + var e2 = React; function h4(a3, b3) { return a3 === b3 && (0 !== a3 || 1 / a3 === 1 / b3) || a3 !== a3 && b3 !== b3; } - var k2 = "function" === typeof Object.is ? Object.is : h4, l2 = e.useState, m2 = e.useEffect, n3 = e.useLayoutEffect, p3 = e.useDebugValue; + var k2 = "function" === typeof Object.is ? Object.is : h4, l2 = e2.useState, m3 = e2.useEffect, n4 = e2.useLayoutEffect, p2 = e2.useDebugValue; function q2(a3, b3) { - var d3 = b3(), f2 = l2({ inst: { value: d3, getSnapshot: b3 } }), c2 = f2[0].inst, g3 = f2[1]; - n3(function() { - c2.value = d3; + var d5 = b3(), f3 = l2({ inst: { value: d5, getSnapshot: b3 } }), c2 = f3[0].inst, g3 = f3[1]; + n4(function() { + c2.value = d5; c2.getSnapshot = b3; - r2(c2) && g3({ inst: c2 }); - }, [a3, d3, b3]); - m2(function() { - r2(c2) && g3({ inst: c2 }); + r3(c2) && g3({ inst: c2 }); + }, [a3, d5, b3]); + m3(function() { + r3(c2) && g3({ inst: c2 }); return a3(function() { - r2(c2) && g3({ inst: c2 }); + r3(c2) && g3({ inst: c2 }); }); }, [a3]); - p3(d3); - return d3; + p2(d5); + return d5; } - function r2(a3) { + function r3(a3) { var b3 = a3.getSnapshot; a3 = a3.value; try { - var d3 = b3(); - return !k2(a3, d3); - } catch (f2) { + var d5 = b3(); + return !k2(a3, d5); + } catch (f3) { return true; } } @@ -20772,7 +27889,7 @@ function requireUseSyncExternalStoreShim_production_min() { return b3(); } var u3 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t2 : q2; - useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u3; + useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e2.useSyncExternalStore ? e2.useSyncExternalStore : u3; return useSyncExternalStoreShim_production_min; } var useSyncExternalStoreShim_development = {}; @@ -20797,35 +27914,35 @@ function requireUseSyncExternalStoreShim_development() { } var React$1 = React; var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - function error(format) { + function error(format2) { { { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } - printWarning("error", format, args); + printWarning("error", format2, args); } } } - function printWarning(level, format, args) { + function printWarning(level, format2, args) { { var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { - format += "%s"; + format2 += "%s"; args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { return String(item); }); - argsWithFormat.unshift("Warning: " + format); + argsWithFormat.unshift("Warning: " + format2); Function.prototype.apply.call(console[level], console, argsWithFormat); } } - function is2(x2, y3) { + function is3(x2, y3) { return x2 === y3 && (x2 !== 0 || 1 / x2 === 1 / y3) || x2 !== x2 && y3 !== y3; } - var objectIs = typeof Object.is === "function" ? Object.is : is2; + var objectIs = typeof Object.is === "function" ? Object.is : is3; var useState = React$1.useState, useEffect = React$1.useEffect, useLayoutEffect = React$1.useLayoutEffect, useDebugValue = React$1.useDebugValue; var didWarnOld18Alpha = false; var didWarnUncachedGetSnapshot = false; @@ -21077,7 +28194,7 @@ function ReactQueryDevtools$1({ style, isOpen: isResolvedOpen, setIsOpen, - onDragStart: (e) => handleDragStart(panelRef.current, e), + onDragStart: (e2) => handleDragStart(panelRef.current, e2), errorTypes }))), !isResolvedOpen ? /* @__PURE__ */ React__namespace.createElement("button", _extends({ type: "button" @@ -21086,9 +28203,9 @@ function ReactQueryDevtools$1({ "aria-controls": "ReactQueryDevtoolsPanel", "aria-haspopup": "true", "aria-expanded": "false", - onClick: (e) => { + onClick: (e2) => { setIsOpen(true); - onToggleClick == null ? void 0 : onToggleClick(e); + onToggleClick == null ? void 0 : onToggleClick(e2); }, style: { background: "none", @@ -21247,7 +28364,7 @@ const ReactQueryDevtoolsPanel = /* @__PURE__ */ React__namespace.forwardRef(func style: { marginInlineStart: ".5em" }, - onChange: (e) => onPositionChange(e.target.value) + onChange: (e2) => onPositionChange(e2.target.value) }, /* @__PURE__ */ React__namespace.createElement("option", { value: "left" }, "Left"), /* @__PURE__ */ React__namespace.createElement("option", { @@ -21267,9 +28384,9 @@ const ReactQueryDevtoolsPanel = /* @__PURE__ */ React__namespace.forwardRef(func placeholder: "Filter", "aria-label": "Filter by queryhash", value: filter != null ? filter : "", - onChange: (e) => setFilter(e.target.value), - onKeyDown: (e) => { - if (e.key === "Escape") + onChange: (e2) => setFilter(e2.target.value), + onKeyDown: (e2) => { + if (e2.key === "Escape") setFilter(""); }, style: { @@ -21279,7 +28396,7 @@ const ReactQueryDevtoolsPanel = /* @__PURE__ */ React__namespace.forwardRef(func }), /* @__PURE__ */ React__namespace.createElement(Select, { "aria-label": "Sort queries", value: sort, - onChange: (e) => setSort(e.target.value), + onChange: (e2) => setSort(e2.target.value), style: { flex: "1", minWidth: 75, @@ -21398,9 +28515,9 @@ const ReactQueryDevtoolsPanel = /* @__PURE__ */ React__namespace.forwardRef(func left: 0, ...otherCloseButtonProps.style }, - onClick: (e) => { + onClick: (e2) => { setIsOpen(false); - onCloseClick == null ? void 0 : onCloseClick(e); + onCloseClick == null ? void 0 : onCloseClick(e2); } }), "Close") : null)); }); @@ -21607,8 +28724,8 @@ const ActiveQuery = ({ style: { marginInlineStart: ".5em" }, - onChange: (e) => { - const errorType = errorTypes.find((t2) => t2.name === e.target.value); + onChange: (e2) => { + const errorType = errorTypes.find((t2) => t2.name === e2.target.value); triggerError(errorType); } }, /* @__PURE__ */ React__namespace.createElement("option", { @@ -21820,7 +28937,9 @@ function useSession() { return session; } const queryClient = new reactQuery.QueryClient(); -const SessionContext = React.createContext(void 0); +const SessionContext = React.createContext( + void 0 +); const PuzzleWalletProvider = ({ dAppName, dAppDescription, @@ -21829,7 +28948,9 @@ const PuzzleWalletProvider = ({ children, debugQuery = false }) => { - const [session, setSession] = React.useState(void 0); + const [session, setSession] = React.useState( + void 0 + ); const _session = useSession(); React.useEffect(() => { setSession(_session); @@ -21875,10 +28996,10 @@ const useAccount = () => { state.setAccount, state.onDisconnect ]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getSelectedAccount" @@ -21907,8 +29028,8 @@ const useAccount = () => { return !!(data == null ? void 0 : data.address); }, onData: (data) => { - var _a, _b; - const network = ((_a = data.chain) == null ? void 0 : _a.split(":")[0]) ?? "aleo"; + var _a2, _b; + const network = ((_a2 = data.chain) == null ? void 0 : _a2.split(":")[0]) ?? "aleo"; const chainId = ((_b = data.chain) == null ? void 0 : _b.split(":")[1]) ?? "1"; setAccount({ network, @@ -21916,7 +29037,8 @@ const useAccount = () => { address: data.address, shortenedAddress: shortenAddress(data.address) }); - } + }, + dependencies: [] } ] }); @@ -21945,7 +29067,7 @@ const useAccount = () => { shortenedAddress: shortenAddress(address) }); }); - useOnSessionDelete(({ params, topic }) => { + useOnSessionDelete(() => { onDisconnect(); }); React.useEffect(() => { @@ -21969,18 +29091,17 @@ const useAccount = () => { loading }; }; -const useBalance = ({ address, multisig }) => { +const useBalance = ({ address, multisig } = {}) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getBalance", params: { - assetId: void 0, address } } @@ -22013,14 +29134,16 @@ const useBalance = ({ address, multisig }) => { condition: () => { return !multisig; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data) => { return !!multisig && (data == null ? void 0 : data.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig, address] } ] }); @@ -22041,7 +29164,7 @@ const useBalance = ({ address, multisig }) => { const balances = response == null ? void 0 : response.balances; return { balances, error, loading }; }; -function useConnect() { +function useConnect(showModal = true) { const session = useWalletSession(); const isConnected = !!session; const { data, error, loading, setData, setError, setLoading } = useAsyncAction(); @@ -22055,11 +29178,18 @@ function useConnect() { requiredNamespaces: { aleo: { methods: wc_aleo_methods$1, - chains: wc_aleo_chains$1, + chains: wc_required_aleo_chains$1, + events: wc_events$1 + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains$1, + methods: wc_aleo_methods$1, events: wc_events$1 } } - }); + }, showModal); setData(response); await checkForDesktopConnection$1(response.topic); const account = response.namespaces["aleo"]["accounts"][0].split(":"); @@ -22070,7 +29200,9 @@ function useConnect() { shortenedAddress: shortenAddress(account[2]) }); emitter$1.emit("session_change"); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + const choice = window.localStorage.getItem( + "WALLETCONNECT_DEEPLINK_CHOICE" + ); if (choice && JSON.parse(choice).name !== "Android") { window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); } @@ -22087,7 +29219,8 @@ function useConnect() { } const useCreateSharedState = () => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22096,7 +29229,7 @@ const useCreateSharedState = () => { } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "createSharedState", @@ -22114,7 +29247,8 @@ const useCreateSharedState = () => { }; const useDecrypt = (ciphertexts) => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22123,7 +29257,7 @@ const useDecrypt = (ciphertexts) => { } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "decrypt", @@ -22161,11 +29295,11 @@ function useDisconnect() { const client = await getWalletConnectModalSignClient$1(); await client.disconnect({ topic: session.topic, - reason: utils$2.getSdkError("USER_DISCONNECTED") + reason: utils$1.getSdkError("USER_DISCONNECTED") }); emitter$1.emit("session_change"); - } catch (e) { - console.warn(e); + } catch (e2) { + console.warn(e2); } useWalletStore.getState().onDisconnect(); } catch (err) { @@ -22180,10 +29314,10 @@ function useDisconnect() { const useEvent = ({ id, address, multisig = false }) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getEvent", @@ -22221,14 +29355,16 @@ const useEvent = ({ id, address, multisig = false }) => { { subscriptionName: "onSelectedAccountSynced", condition: () => !!id && !multisig, - onData: () => refetch() + onData: () => refetch(), + dependencies: [id, multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data) => { return !!id && !!multisig && (data == null ? void 0 : data.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [id, multisig, address] } ] }); @@ -22261,10 +29397,10 @@ const useEvents = ({ filter, page }) => { if ((filter == null ? void 0 : filter.programId) === "") { filter.programId = void 0; } - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getEvents", @@ -22284,7 +29420,7 @@ const useEvents = ({ filter, page }) => { queryKey: [ "useEvents", account == null ? void 0 : account.address, - debouncedFilter, + JSON.stringify(debouncedFilter), page, session == null ? void 0 : session.topic ], @@ -22301,7 +29437,8 @@ const useEvents = ({ filter, page }) => { { subscriptionName: "onSelectedAccountSynced", condition: () => true, - onData: () => refetch() + onData: () => refetch(), + dependencies: [] } ] }); @@ -22330,7 +29467,8 @@ const useEvents = ({ filter, page }) => { }; const useImportSharedState = (seed) => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22339,7 +29477,7 @@ const useImportSharedState = (seed) => { } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "importSharedState", @@ -22349,8 +29487,8 @@ const useImportSharedState = (seed) => { } }, (params) => { - var _a; - return (_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient.importSharedState.mutate(params); + var _a2; + return (_a2 = window.aleo) == null ? void 0 : _a2.puzzleWalletClient.importSharedState.mutate(params); } ); const error = wc_error ? wc_error.message : wc_data && wc_data.error; @@ -22377,10 +29515,10 @@ const useRecords = ({ }) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getRecords", @@ -22403,7 +29541,7 @@ const useRecords = ({ account == null ? void 0 : account.address, address, multisig, - debouncedFilter, + JSON.stringify(debouncedFilter), page, session == null ? void 0 : session.topic ], @@ -22421,14 +29559,16 @@ const useRecords = ({ { subscriptionName: "onSelectedAccountSynced", condition: () => !multisig, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data) => { return !!multisig && (data == null ? void 0 : data.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig, address] } ] }); @@ -22453,6 +29593,7 @@ const useRecords = ({ }; const useRequestCreateEvent = (requestData) => { const session = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { if (typeof input === "string") { return input; @@ -22466,7 +29607,7 @@ const useRequestCreateEvent = (requestData) => { loading } = useRequest({ topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "requestCreateEvent", @@ -22512,8 +29653,8 @@ var util; return util2.objectValues(filtered); }; util2.objectValues = (obj) => { - return util2.objectKeys(obj).map(function(e) { - return obj[e]; + return util2.objectKeys(obj).map(function(e2) { + return obj[e2]; }); }; util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { @@ -22840,7 +29981,7 @@ const makeIssue = (params) => { path: fullPath }; let errorMessage = ""; - const maps = errorMaps.filter((m2) => !!m2).slice().reverse(); + const maps = errorMaps.filter((m3) => !!m3).slice().reverse(); for (const map of maps) { errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; } @@ -23064,11 +30205,11 @@ class ZodType2 { throw result.error; } safeParse(data, params) { - var _a; + var _a2; const ctx = { common: { issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap }, path: (params === null || params === void 0 ? void 0 : params.path) || [], @@ -23424,7 +30565,7 @@ class ZodString2 extends ZodType2 { } else if (check.kind === "url") { try { new URL(input.data); - } catch (_a) { + } catch (_a2) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext(ctx, { validation: "url", @@ -23539,7 +30680,7 @@ class ZodString2 extends ZodType2 { return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); } datetime(options) { - var _a; + var _a2; if (typeof options === "string") { return this._addCheck({ kind: "datetime", @@ -23551,7 +30692,7 @@ class ZodString2 extends ZodType2 { return this._addCheck({ kind: "datetime", precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) }); } @@ -23606,59 +30747,59 @@ class ZodString2 extends ZodType2 { }); } get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); } get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); + return !!this._def.checks.find((ch2) => ch2.kind === "email"); } get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); + return !!this._def.checks.find((ch2) => ch2.kind === "url"); } get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); } get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); } get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); } get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); } get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); } get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); } get minLength() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxLength() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } } ZodString2.create = (params) => { - var _a; + var _a2; return new ZodString2({ checks: [], typeName: ZodFirstPartyTypeKind.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, ...processCreateParams(params) }); }; @@ -23856,38 +30997,38 @@ class ZodNumber2 extends ZodType2 { } get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util.isInteger(ch2.value)); } get isFinite() { let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return Number.isFinite(min) && Number.isFinite(max); @@ -24039,31 +31180,31 @@ class ZodBigInt2 extends ZodType2 { } get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } } ZodBigInt2.create = (params) => { - var _a; + var _a2; return new ZodBigInt2({ checks: [], typeName: ZodFirstPartyTypeKind.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, ...processCreateParams(params) }); }; @@ -24174,20 +31315,20 @@ class ZodDate2 extends ZodType2 { } get minDate() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min != null ? new Date(min) : null; } get maxDate() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max != null ? new Date(max) : null; @@ -24569,8 +31710,8 @@ class ZodObject2 extends ZodType2 { unknownKeys: "strict", ...message !== void 0 ? { errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; if (issue.code === "unrecognized_keys") return { message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError @@ -25388,17 +32529,17 @@ class ZodFunction2 extends ZodType2 { }); } const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; + const fn = ctx.data; if (this._def.returns instanceof ZodPromise2) { return OK(async (...args) => { const error = new ZodError2([]); - const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => { - error.addIssue(makeArgsIssue(args, e)); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { + error.addIssue(makeArgsIssue(args, e2)); throw error; }); - const result = await fn2(...parsedArgs); - const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => { - error.addIssue(makeReturnsIssue(result, e)); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { + error.addIssue(makeReturnsIssue(result, e2)); throw error; }); return parsedReturns; @@ -25409,7 +32550,7 @@ class ZodFunction2 extends ZodType2 { if (!parsedArgs.success) { throw new ZodError2([makeArgsIssue(args, parsedArgs.error)]); } - const result = fn2(...parsedArgs.data); + const result = fn(...parsedArgs.data); const parsedReturns = this._def.returns.safeParse(result, params); if (!parsedReturns.success) { throw new ZodError2([makeReturnsIssue(result, parsedReturns.error)]); @@ -25948,11 +33089,11 @@ class ZodPipeline2 extends ZodType2 { const custom = (check, params = {}, fatal) => { if (check) return ZodAny2.create().superRefine((data, ctx) => { - var _a, _b; + var _a2, _b; if (!check(data)) { - const p3 = typeof params === "function" ? params(data) : params; - const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p3 === "string" ? { message: p3 } : p3; + const p2 = typeof params === "function" ? params(data) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); } }); @@ -26050,7 +33191,7 @@ const coerce = { date: (arg) => ZodDate2.create({ ...arg, coerce: true }) }; const NEVER = INVALID; -var z3 = /* @__PURE__ */ Object.freeze({ +var z = /* @__PURE__ */ Object.freeze({ __proto__: null, defaultErrorMap: errorMap, setErrorMap, @@ -26167,17 +33308,19 @@ var z3 = /* @__PURE__ */ Object.freeze({ const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; +const aleoTransitionIdRegex = /^au1[a-z0-9]{58}$/i; const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; const aleoFieldRegex = /^\d+field$/; const aleoU32 = /^\d+u32$/; const aleoU64 = /^\d+u64$/; -const zodAddress = z3.string().regex(aleoAddressRegex); -const zodViewKey = z3.string().regex(aleoViewKeyRegex); -const zodPrivateKey = z3.string().regex(aleoPrivateKeyRegex); -const zodTransactionId = z3.string().regex(aleoTransactionIdRegex); -const zodField = z3.string().regex(aleoFieldRegex); -const zodU32 = z3.string().regex(aleoU32); -const zodU64 = z3.string().regex(aleoU64); +const zodAddress = z.string().regex(aleoAddressRegex); +const zodViewKey = z.string().regex(aleoViewKeyRegex); +const zodPrivateKey = z.string().regex(aleoPrivateKeyRegex); +z.string().regex(aleoTransitionIdRegex); +const zodTransactionId = z.string().regex(aleoTransactionIdRegex); +const zodField = z.string().regex(aleoFieldRegex); +const zodU32 = z.string().regex(aleoU32); +const zodU64 = z.string().regex(aleoU64); var InputOutputType; (function(InputOutputType2) { InputOutputType2["Record"] = "record"; @@ -26198,6 +33341,9 @@ exports.EventType = void 0; EventType2["Split"] = "Split"; EventType2["Shield"] = "Shield"; EventType2["Unshield"] = "Unshield"; + EventType2["Referral"] = "Referral"; + EventType2["Points"] = "Points"; + EventType2["Raffle"] = "Raffle"; })(exports.EventType || (exports.EventType = {})); exports.EventStatus = void 0; (function(EventStatus2) { @@ -26214,18 +33360,16 @@ exports.Visibility = void 0; exports.Network = void 0; (function(Network2) { Network2["AleoTestnet"] = "AleoTestnet"; + Network2["AleoCanarynet"] = "AleoCanarynet"; Network2["AleoMainnet"] = "AleoMainnet"; })(exports.Network || (exports.Network = {})); -exports.AssetType = void 0; -(function(AssetType2) { - AssetType2[AssetType2["ALEO"] = 0] = "ALEO"; -})(exports.AssetType || (exports.AssetType = {})); -const zodEventType = z3.nativeEnum(exports.EventType); -const zodEventStatus = z3.nativeEnum(exports.EventStatus); -const zodNetwork = z3.nativeEnum(exports.Network); -const zodVisibility = z3.nativeEnum(exports.Visibility); -const useRequestSignature = (message, address) => { +const zodEventType = z.nativeEnum(exports.EventType); +const zodEventStatus = z.nativeEnum(exports.EventStatus); +const zodNetwork = z.nativeEnum(exports.Network); +const zodVisibility = z.nativeEnum(exports.Visibility); +const useRequestSignature = ({ message, address, method, network }) => { const session = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const { request, data: wc_data, @@ -26233,13 +33377,14 @@ const useRequestSignature = (message, address) => { loading } = useRequest({ topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "requestSignature", params: { message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method } } }); @@ -26266,7 +33411,15 @@ const wc_aleo_methods = [ "importSharedState", "requestSignature" ]; -const wc_aleo_chains = ["aleo:1"]; +const wc_required_aleo_chains = ["aleo:1"]; +const wc_optional_aleo_chains = [ + "aleo:0" + // for eventual mainnet +]; +const wc_aleo_chains = [ + ...wc_required_aleo_chains, + ...wc_optional_aleo_chains +]; const wc_events = [ "chainChanged", "accountSelected", @@ -26275,16 +33428,18 @@ const wc_events = [ ]; const projectId = "f0aaeffe71b636da453fce042d79d723"; function isAndroid() { - if (!navigator) { + if (typeof navigator === "undefined") { return false; } return /Android/i.test(navigator.userAgent); } const web3modal_puzzle_props_android = { projectId, - chains: ["aleo:3"], + chains: wc_aleo_chains, enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], mobileWallets: [ { id: "puzzle", @@ -26303,7 +33458,9 @@ const web3modal_puzzle_props_default = { projectId, chains: wc_aleo_chains, enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], mobileWallets: [ { id: "puzzle", @@ -26347,9 +33504,32 @@ const signClient_puzzleProps = { } } }; +const networkToChainId = (network, includePrefix = true) => { + let chain; + switch (network) { + case exports.Network.AleoMainnet: + chain = "aleo:0"; + break; + case exports.Network.AleoCanarynet: + chain = "aleo:0"; + break; + case exports.Network.AleoTestnet: + chain = "aleo:1"; + break; + } + return includePrefix ? chain : chain.replace("aleo:", ""); +}; +const chainIdToNetwork = (chainId) => { + switch (chainId) { + case "aleo:0": + return exports.Network.AleoCanarynet; + case "aleo:1": + return exports.Network.AleoTestnet; + } +}; const name = "@puzzlehq/sdk-core"; const displayName = "Puzzle SDK"; -const version = "0.3.1"; +const version = "0.4.0"; const description = "Your portal to privacy"; const main = "./dist/puzzle.cjs.js"; const module$1 = "./dist/puzzle.es.js"; @@ -26375,8 +33555,8 @@ const repository = { url: "git+https://github.com/puzzlehq/puzzle-sdk.git" }; const dependencies = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", "@walletconnect/types": "^2.11.2", "@walletconnect/utils": "^2.11.2", debug: "^4.3.4", @@ -26436,7 +33616,7 @@ async function configureConnection(options) { localStorage.setItem("puzzle_sdk_version", thisVersion); disconnectSessions = true; } - exports.connection = new modalSignHtml.WalletConnectModalSign({ + exports.connection = new walletconnectModalSignHtml.WalletConnectModalSign({ projectId: options.projectId ?? projectId, metadata: { name: options.dAppName, @@ -26450,8 +33630,8 @@ async function configureConnection(options) { localStorage.removeItem("puzzle-hasInjectedConnection"); try { disconnectOnVersionChange(exports.connection, options.onDisconnect); - } catch (e) { - console.error(e); + } catch (e2) { + console.error(e2); } } exports.connection.onSessionDelete(() => { @@ -26478,7 +33658,7 @@ async function disconnectOnVersionChange(connection2, onDisconnect) { onDisconnect && onDisconnect(); connection2.disconnect({ topic: session.topic, - reason: utils$2.getSdkError("USER_DISCONNECTED") + reason: utils$1.getSdkError("USER_DISCONNECTED") }); } } @@ -26503,9 +33683,10 @@ async function getWalletConnectModalSignClient() { }); } const checkForDesktopConnection = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); localStorage.setItem("puzzle-hasInjectedConnection", "false"); return false; } @@ -26520,16 +33701,16 @@ const checkForDesktopConnection = async (sessionTopic) => { localStorage.setItem("puzzle-hasInjectedConnection", "false"); return false; } - } catch (e) { - console.warn(e); + } catch (e2) { + console.warn(e2); localStorage.setItem("puzzle-hasInjectedConnection", "false"); return false; } }; const hasInjectedConnection = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { return false; } const puzzleHasDesktopConnection = localStorage.getItem( @@ -26537,15 +33718,18 @@ const hasInjectedConnection = () => { ); return puzzleHasDesktopConnection === "true"; }; -const getAccount = async () => { +const getAccount = async (network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await connection2.getSession(); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getSelectedAccount" @@ -26555,36 +33739,39 @@ const getAccount = async () => { try { const response = await window.aleo.puzzleWalletClient.getSelectedAccount.query(query); return response; - } catch (e) { - console.error("getAccount error", e); - return { error: e.message }; + } catch (e2) { + console.error("getAccount error", e2); + return { error: e2.message }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - console.error("getAccount error", e); - const error = e.message; + } catch (e2) { + console.error("getAccount error", e2); + const error = e2.message; return { error }; } }; const getBalance = async ({ - address + address, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await connection2.getSession(); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getBalance", params: { - assetId: void 0, address } } @@ -26593,25 +33780,25 @@ const getBalance = async ({ try { const response = await window.aleo.puzzleWalletClient.getBalance.query(query); return response; - } catch (e) { - const error = e.message; - console.error("getBalance error", e); + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); return { error }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - const error = e.message; - console.error("getBalance error", e); + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); return { error }; } }; -const connect = async () => { +const connect = async (showModal = true) => { const connection2 = await getWalletConnectModalSignClient(); if (!connection2) { - throw new Error("call setConnection() first!"); + throw new Error("call configureConnection() first!"); } const existingSession = await connection2.getSession(); if (existingSession) { @@ -26623,11 +33810,18 @@ const connect = async () => { requiredNamespaces: { aleo: { methods: wc_aleo_methods, - chains: wc_aleo_chains, + chains: wc_required_aleo_chains, + events: wc_events + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains, + methods: wc_aleo_methods, events: wc_events } } - }); + }, showModal); emitter.emit("session_change"); if (newSession) { await checkForDesktopConnection(newSession.topic); @@ -26637,11 +33831,11 @@ const connect = async () => { window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); } return newSession; - } catch (e) { - console.error("connect error", e); + } catch (e2) { + console.error("connect error", e2); } }; -const requestCreateEvent = async (requestData) => { +const requestCreateEvent = async (requestData, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { @@ -26653,10 +33847,13 @@ const requestCreateEvent = async (requestData) => { } return input.plaintext; }); + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } try { const response = await connection2.request({ topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "requestCreateEvent", @@ -26667,21 +33864,24 @@ const requestCreateEvent = async (requestData) => { } }); return response; - } catch (e) { - console.error("createEvent error", e); - const error = e.message; + } catch (e2) { + console.error("createEvent error", e2); + const error = e2.message; return { error }; } }; -const createSharedState = async () => { +const createSharedState = async (network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "createSharedState", @@ -26690,34 +33890,35 @@ const createSharedState = async () => { }; if (hasInjectedConnection()) { try { - const response = await window.aleo.puzzleWalletClient.createSharedState.mutate( - query - ); + const response = await window.aleo.puzzleWalletClient.createSharedState.mutate(query); return response; - } catch (e) { - console.error("createSharedState error", e); - const error = e.message; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; return { error }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - console.error("createSharedState error", e); - const error = e.message; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; return { error }; } }; -const decrypt = async (ciphertexts) => { +const decrypt = async (ciphertexts, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "decrypt", @@ -26730,18 +33931,18 @@ const decrypt = async (ciphertexts) => { try { const response = await window.aleo.puzzleWalletClient.decrypt.query(query); return response; - } catch (e) { - const error = e.message; - console.error("decrypt error", e); + } catch (e2) { + const error = e2.message; + console.error("decrypt error", e2); return { error }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - console.error("decrypt error", e); - return { error: e.message }; + } catch (e2) { + console.error("decrypt error", e2); + return { error: e2.message }; } }; const disconnect = async () => { @@ -26753,33 +33954,37 @@ const disconnect = async () => { try { try { await connection2.disconnect({ - reason: utils$2.getSdkError("USER_DISCONNECTED"), + reason: utils$1.getSdkError("USER_DISCONNECTED"), topic: session.topic }); localStorage.removeItem("puzzle-hasInjectedConnection"); emitter.emit("session_change"); - } catch (e) { - console.warn(e); + } catch (e2) { + console.warn(e2); } return {}; - } catch (e) { - console.error("error disconnecting", e); - const error = e.message; + } catch (e2) { + console.error("error disconnecting", e2); + const error = e2.message; return { error }; } }; const getEvent = async ({ id, - address + address, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { event: void 0, error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getEvent", @@ -26793,9 +33998,9 @@ const getEvent = async ({ try { const response = await window.aleo.puzzleWalletClient.getEvent.query(query); return response; - } catch (e) { - console.error("getEvent error", e); - const error = e.message; + } catch (e2) { + console.error("getEvent error", e2); + const error = e2.message; return { error }; } } @@ -26806,13 +34011,13 @@ const getEvent = async ({ try { const response = await fetchEvent(); return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; return { error }; } }; -const getEvents = async (filter) => { +const getEvents = async (filter, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { @@ -26821,9 +34026,15 @@ const getEvents = async (filter) => { if ((filter == null ? void 0 : filter.programId) === "") { filter.programId = void 0; } + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getEvents", @@ -26837,9 +34048,9 @@ const getEvents = async (filter) => { try { const response = await window.aleo.puzzleWalletClient.getEvents.query(query); return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; return { error }; } } @@ -26850,21 +34061,24 @@ const getEvents = async (filter) => { try { const response = await fetchPage(); return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; return { error }; } }; -const importSharedState = async (seed) => { +const importSharedState = async (seed, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "importSharedState", @@ -26877,34 +34091,38 @@ const importSharedState = async (seed) => { try { const response = await window.aleo.puzzleWalletClient.importSharedState.mutate(query); return response; - } catch (e) { - console.error("importSharedState error", e); - const error = e.message; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; return { error }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - console.error("importSharedState error", e); - const error = e.message; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; return { error }; } }; const getRecords = async ({ address, filter, - page = 0 + page = 0, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getRecords", @@ -26919,9 +34137,9 @@ const getRecords = async ({ try { const response = await window.aleo.puzzleWalletClient.getRecords.query(query); return response; - } catch (e) { - console.error("getRecords error", e); - const error = e.message; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; return { error }; } } @@ -26932,38 +34150,44 @@ const getRecords = async ({ try { const response = await fetchPage(); return response; - } catch (e) { - console.error("getRecords error", e); - const error = e.message; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; return { error }; } }; const requestSignature = async ({ message, - address + address, + network, + method }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } try { const response = await connection2.request({ topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "requestSignature", params: { message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method } } }); return response; - } catch (e) { - console.error("signature error", e); - const error = e.message; + } catch (e2) { + console.error("signature error", e2); + const error = e2.message; return { error }; } }; @@ -26972,9 +34196,8 @@ const log_sdk = debug$1("wallet:sdk"); log_sdk.enabled = true; exports.PAGE_SIZE = PAGE_SIZE; exports.PuzzleWalletProvider = PuzzleWalletProvider; -exports.R$4 = R$4; -exports.T$1 = T$1; -exports.a$3 = a$3; +exports.R$1 = R$1; +exports.T$2 = T$2; exports.aleoAddressRegex = aleoAddressRegex; exports.aleoFieldRegex = aleoFieldRegex; exports.aleoPrivateKeyRegex = aleoPrivateKeyRegex; @@ -26982,6 +34205,7 @@ exports.aleoTransactionIdRegex = aleoTransactionIdRegex; exports.aleoU32 = aleoU32; exports.aleoU64 = aleoU64; exports.aleoViewKeyRegex = aleoViewKeyRegex; +exports.chainIdToNetwork = chainIdToNetwork; exports.checkForDesktopConnection = checkForDesktopConnection; exports.configureConnection = configureConnection; exports.connect = connect; @@ -26997,19 +34221,21 @@ exports.getFormattedRecordPlaintext = getFormattedRecordPlaintext; exports.getRecords = getRecords; exports.getWalletConnectModalSignClient = getWalletConnectModalSignClient; exports.hasInjectedConnection = hasInjectedConnection; +exports.i$1 = i$1; exports.importSharedState = importSharedState; exports.log_sdk = log_sdk; -exports.ne = ne; -exports.oe$1 = oe$1; -exports.p$3 = p$3; +exports.ne$3 = ne$3; +exports.networkToChainId = networkToChainId; +exports.oe$2 = oe$2; +exports.p$2 = p$2; exports.projectId = projectId; exports.queryClient = queryClient; exports.requestCreateEvent = requestCreateEvent; exports.requestSignature = requestSignature; -exports.se = se; +exports.se$3 = se$3; exports.shortenAddress = shortenAddress; exports.signClient_puzzleProps = signClient_puzzleProps; -exports.te$2 = te$2; +exports.te$1 = te$1; exports.useAccount = useAccount; exports.useBalance = useBalance; exports.useConnect = useConnect; @@ -27028,14 +34254,15 @@ exports.useRequestCreateEvent = useRequestCreateEvent; exports.useRequestSignature = useRequestSignature; exports.useSession = useSession; exports.useWalletSession = useWalletSession; -exports.useWalletStore = useWalletStore; exports.wc_aleo_chains = wc_aleo_chains; exports.wc_aleo_methods = wc_aleo_methods; exports.wc_events = wc_events; +exports.wc_optional_aleo_chains = wc_optional_aleo_chains; +exports.wc_required_aleo_chains = wc_required_aleo_chains; exports.web3modal_puzzle_props = web3modal_puzzle_props; exports.web3modal_puzzle_props_android = web3modal_puzzle_props_android; exports.web3modal_puzzle_props_default = web3modal_puzzle_props_default; -exports.y$3 = y$3; +exports.y$4 = y$4; exports.zodAddress = zodAddress; exports.zodEventStatus = zodEventStatus; exports.zodEventType = zodEventType; diff --git a/packages/react/dist/index-B2etef5O-ugHUcay-.cjs b/packages/react/dist/index-f3LbIFb5-BkegnaCo.cjs similarity index 63% rename from packages/react/dist/index-B2etef5O-ugHUcay-.cjs rename to packages/react/dist/index-f3LbIFb5-BkegnaCo.cjs index 6b57b5ca..5a5e861b 100644 --- a/packages/react/dist/index-B2etef5O-ugHUcay-.cjs +++ b/packages/react/dist/index-f3LbIFb5-BkegnaCo.cjs @@ -1,24 +1,24 @@ "use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); -const index = require("./index-DbX1yfTB.cjs"); +const index = require("./index-BHOVivr9.cjs"); /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$3 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); +const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$4 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); let o$4 = class o { constructor(t2, e2, n2) { - if (this._$cssResult$ = true, n2 !== s$3) + if (this._$cssResult$ = true, n2 !== s$4) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t2, this.t = e2; } get styleSheet() { let t2 = this.o; - const s2 = this.t; + const s3 = this.t; if (e$5 && void 0 === t2) { - const e2 = void 0 !== s2 && 1 === s2.length; - e2 && (t2 = n$5.get(s2)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s2, t2)); + const e2 = void 0 !== s3 && 1 === s3.length; + e2 && (t2 = n$5.get(s3)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s3, t2)); } return t2; } @@ -26,24 +26,24 @@ let o$4 = class o { return this.cssText; } }; -const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), i$3 = (t2, ...e2) => { - const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s2, n3) => e3 + ((t3) => { +const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$4), i$3 = (t2, ...e2) => { + const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s3, n3) => e3 + ((t3) => { if (true === t3._$cssResult$) return t3.cssText; if ("number" == typeof t3) return t3; throw Error("Value passed to 'css' function must be a 'css' function result: " + t3 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); - })(s2) + t2[n3 + 1], t2[0]); - return new o$4(n2, t2, s$3); -}, S$2 = (s2, n2) => { - e$5 ? s2.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { + })(s3) + t2[n3 + 1], t2[0]); + return new o$4(n2, t2, s$4); +}, S$2 = (s3, n2) => { + e$5 ? s3.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { const n3 = document.createElement("style"), o3 = t$3.litNonce; - void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s2.appendChild(n3); + void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s3.appendChild(n3); }); -}, c$2 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { +}, c$1 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { let e2 = ""; - for (const s2 of t3.cssRules) - e2 += s2.cssText; + for (const s3 of t3.cssRules) + e2 += s3.cssText; return r$2(e2); })(t2) : t2; /** @@ -51,7 +51,7 @@ const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -var s$2; +var s$3; const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$3 = e$4.reactiveElementPolyfillSupport, n$4 = { toAttribute(t2, i2) { switch (i2) { case Boolean: @@ -63,23 +63,23 @@ const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$ } return t2; }, fromAttribute(t2, i2) { - let s2 = t2; + let s3 = t2; switch (i2) { case Boolean: - s2 = null !== t2; + s3 = null !== t2; break; case Number: - s2 = null === t2 ? null : Number(t2); + s3 = null === t2 ? null : Number(t2); break; case Object: case Array: try { - s2 = JSON.parse(t2); + s3 = JSON.parse(t2); } catch (t3) { - s2 = null; + s3 = null; } } - return s2; + return s3; } }, a$1 = (t2, i2) => i2 !== t2 && (i2 == i2 || t2 == t2), l$3 = { attribute: true, type: String, converter: n$4, reflect: false, hasChanged: a$1 }, d$1 = "finalized"; let u$1 = class u extends HTMLElement { constructor() { @@ -92,23 +92,23 @@ let u$1 = class u extends HTMLElement { static get observedAttributes() { this.finalize(); const t2 = []; - return this.elementProperties.forEach((i2, s2) => { - const e2 = this._$Ep(s2, i2); - void 0 !== e2 && (this._$Ev.set(e2, s2), t2.push(e2)); + return this.elementProperties.forEach((i2, s3) => { + const e2 = this._$Ep(s3, i2); + void 0 !== e2 && (this._$Ev.set(e2, s3), t2.push(e2)); }), t2; } static createProperty(t2, i2 = l$3) { if (i2.state && (i2.attribute = false), this.finalize(), this.elementProperties.set(t2, i2), !i2.noAccessor && !this.prototype.hasOwnProperty(t2)) { - const s2 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s2, i2); + const s3 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s3, i2); void 0 !== e2 && Object.defineProperty(this.prototype, t2, e2); } } - static getPropertyDescriptor(t2, i2, s2) { + static getPropertyDescriptor(t2, i2, s3) { return { get() { return this[i2]; }, set(e2) { const r2 = this[t2]; - this[i2] = e2, this.requestUpdate(t2, r2, s2); + this[i2] = e2, this.requestUpdate(t2, r2, s3); }, configurable: true, enumerable: true }; } static getPropertyOptions(t2) { @@ -121,32 +121,32 @@ let u$1 = class u extends HTMLElement { const t2 = Object.getPrototypeOf(this); if (t2.finalize(), void 0 !== t2.h && (this.h = [...t2.h]), this.elementProperties = new Map(t2.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { const t3 = this.properties, i2 = [...Object.getOwnPropertyNames(t3), ...Object.getOwnPropertySymbols(t3)]; - for (const s2 of i2) - this.createProperty(s2, t3[s2]); + for (const s3 of i2) + this.createProperty(s3, t3[s3]); } return this.elementStyles = this.finalizeStyles(this.styles), true; } static finalizeStyles(i2) { - const s2 = []; + const s3 = []; if (Array.isArray(i2)) { const e2 = new Set(i2.flat(1 / 0).reverse()); for (const i3 of e2) - s2.unshift(c$2(i3)); + s3.unshift(c$1(i3)); } else - void 0 !== i2 && s2.push(c$2(i2)); - return s2; + void 0 !== i2 && s3.push(c$1(i2)); + return s3; } static _$Ep(t2, i2) { - const s2 = i2.attribute; - return false === s2 ? void 0 : "string" == typeof s2 ? s2 : "string" == typeof t2 ? t2.toLowerCase() : void 0; + const s3 = i2.attribute; + return false === s3 ? void 0 : "string" == typeof s3 ? s3 : "string" == typeof t2 ? t2.toLowerCase() : void 0; } _$Eu() { var t2; this._$E_ = new Promise((t3) => this.enableUpdating = t3), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t2 = this.constructor.h) || void 0 === t2 || t2.forEach((t3) => t3(this)); } addController(t2) { - var i2, s2; - (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s2 = t2.hostConnected) || void 0 === s2 || s2.call(t2)); + var i2, s3; + (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s3 = t2.hostConnected) || void 0 === s3 || s3.call(t2)); } removeController(t2) { var i2; @@ -159,8 +159,8 @@ let u$1 = class u extends HTMLElement { } createRenderRoot() { var t2; - const s2 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); - return S$2(s2, this.constructor.elementStyles), s2; + const s3 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); + return S$2(s3, this.constructor.elementStyles), s3; } connectedCallback() { var t2; @@ -178,28 +178,28 @@ let u$1 = class u extends HTMLElement { return null === (i2 = t3.hostDisconnected) || void 0 === i2 ? void 0 : i2.call(t3); }); } - attributeChangedCallback(t2, i2, s2) { - this._$AK(t2, s2); + attributeChangedCallback(t2, i2, s3) { + this._$AK(t2, s3); } - _$EO(t2, i2, s2 = l$3) { + _$EO(t2, i2, s3 = l$3) { var e2; - const r2 = this.constructor._$Ep(t2, s2); - if (void 0 !== r2 && true === s2.reflect) { - const h2 = (void 0 !== (null === (e2 = s2.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s2.converter : n$4).toAttribute(i2, s2.type); + const r2 = this.constructor._$Ep(t2, s3); + if (void 0 !== r2 && true === s3.reflect) { + const h2 = (void 0 !== (null === (e2 = s3.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s3.converter : n$4).toAttribute(i2, s3.type); this._$El = t2, null == h2 ? this.removeAttribute(r2) : this.setAttribute(r2, h2), this._$El = null; } } _$AK(t2, i2) { - var s2; + var s3; const e2 = this.constructor, r2 = e2._$Ev.get(t2); if (void 0 !== r2 && this._$El !== r2) { - const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s2 = t3.converter) || void 0 === s2 ? void 0 : s2.fromAttribute) ? t3.converter : n$4; + const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s3 = t3.converter) || void 0 === s3 ? void 0 : s3.fromAttribute) ? t3.converter : n$4; this._$El = r2, this[r2] = h2.fromAttribute(i2, t3.type), this._$El = null; } } - requestUpdate(t2, i2, s2) { + requestUpdate(t2, i2, s3) { let e2 = true; - void 0 !== t2 && (((s2 = s2 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s2.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s2))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); + void 0 !== t2 && (((s3 = s3 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s3.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s3))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); } async _$Ej() { this.isUpdatePending = true; @@ -220,16 +220,16 @@ let u$1 = class u extends HTMLElement { return; this.hasUpdated, this._$Ei && (this._$Ei.forEach((t3, i3) => this[i3] = t3), this._$Ei = void 0); let i2 = false; - const s2 = this._$AL; + const s3 = this._$AL; try { - i2 = this.shouldUpdate(s2), i2 ? (this.willUpdate(s2), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { + i2 = this.shouldUpdate(s3), i2 ? (this.willUpdate(s3), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { var i3; return null === (i3 = t3.hostUpdate) || void 0 === i3 ? void 0 : i3.call(t3); - }), this.update(s2)) : this._$Ek(); + }), this.update(s3)) : this._$Ek(); } catch (t3) { throw i2 = false, this._$Ek(), t3; } - i2 && this._$AE(s2); + i2 && this._$AE(s3); } willUpdate(t2) { } @@ -260,34 +260,34 @@ let u$1 = class u extends HTMLElement { firstUpdated(t2) { } }; -u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$2 = e$4.reactiveElementVersions) && void 0 !== s$2 ? s$2 : e$4.reactiveElementVersions = []).push("1.6.3"); +u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$3 = e$4.reactiveElementVersions) && void 0 !== s$3 ? s$3 : e$4.reactiveElementVersions = []).push("1.6.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var t$2; -const i$2 = window, s$1 = i$2.trustedTypes, e$3 = s$1 ? s$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c$1 = Array.isArray, v$1 = (t2) => c$1(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), b = w(2), T$1 = Symbol.for("lit-noChange"), A$1 = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); -function P(t2, i2) { +const i$2 = window, s$2 = i$2.trustedTypes, e$3 = s$2 ? s$2.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s3) => ({ _$litType$: t2, strings: i2, values: s3 }), x = w(1), b$1 = w(2), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); +function P$1(t2, i2) { if (!Array.isArray(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array"); return void 0 !== e$3 ? e$3.createHTML(i2) : i2; } const V = (t2, i2) => { - const s2 = t2.length - 1, e2 = []; + const s3 = t2.length - 1, e2 = []; let l2, r2 = 2 === i2 ? "" : "", u3 = f; - for (let i3 = 0; i3 < s2; i3++) { - const s3 = t2[i3]; + for (let i3 = 0; i3 < s3; i3++) { + const s4 = t2[i3]; let d2, c2, v2 = -1, a2 = 0; - for (; a2 < s3.length && (u3.lastIndex = a2, c2 = u3.exec(s3), null !== c2); ) + for (; a2 < s4.length && (u3.lastIndex = a2, c2 = u3.exec(s4), null !== c2); ) a2 = u3.lastIndex, u3 === f ? "!--" === c2[1] ? u3 = _$1 : void 0 !== c2[1] ? u3 = m : void 0 !== c2[2] ? (y.test(c2[2]) && (l2 = RegExp("" === c2[0] ? (u3 = null != l2 ? l2 : f, v2 = -1) : void 0 === c2[1] ? v2 = -2 : (v2 = u3.lastIndex - c2[2].length, d2 = c2[1], u3 = void 0 === c2[3] ? p : '"' === c2[3] ? $ : g) : u3 === $ || u3 === g ? u3 = p : u3 === _$1 || u3 === m ? u3 = f : (u3 = p, l2 = void 0); const w2 = u3 === p && t2[i3 + 1].startsWith("/>") ? " " : ""; - r2 += u3 === f ? s3 + h$1 : v2 >= 0 ? (e2.push(d2), s3.slice(0, v2) + o$2 + s3.slice(v2) + n$3 + w2) : s3 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); + r2 += u3 === f ? s4 + h$1 : v2 >= 0 ? (e2.push(d2), s4.slice(0, v2) + o$2 + s4.slice(v2) + n$3 + w2) : s4 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); } - return [P(t2, r2 + (t2[s2] || "") + (2 === i2 ? "" : "")), e2]; + return [P$1(t2, r2 + (t2[s3] || "") + (2 === i2 ? "" : "")), e2]; }; -class N { +let N$1 = class N { constructor({ strings: t2, _$litType$: i2 }, e2) { let h2; this.parts = []; @@ -303,10 +303,10 @@ class N { const t3 = []; for (const i3 of h2.getAttributeNames()) if (i3.endsWith(o$2) || i3.startsWith(n$3)) { - const s2 = f2[d2++]; - if (t3.push(i3), void 0 !== s2) { - const t4 = h2.getAttribute(s2.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s2); - v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); + const s3 = f2[d2++]; + if (t3.push(i3), void 0 !== s3) { + const t4 = h2.getAttribute(s3.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s3); + v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H$1 : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); } else v2.push({ type: 6, index: r2 }); } @@ -316,9 +316,9 @@ class N { if (y.test(h2.tagName)) { const t3 = h2.textContent.split(n$3), i3 = t3.length - 1; if (i3 > 0) { - h2.textContent = s$1 ? s$1.emptyScript : ""; - for (let s2 = 0; s2 < i3; s2++) - h2.append(t3[s2], u2()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); + h2.textContent = s$2 ? s$2.emptyScript : ""; + for (let s3 = 0; s3 < i3; s3++) + h2.append(t3[s3], u2()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); h2.append(t3[i3], u2()); } } @@ -334,17 +334,17 @@ class N { } } static createElement(t2, i2) { - const s2 = r.createElement("template"); - return s2.innerHTML = t2, s2; + const s3 = r.createElement("template"); + return s3.innerHTML = t2, s3; } -} -function S$1(t2, i2, s2 = t2, e2) { +}; +function S$1(t2, i2, s3 = t2, e2) { var o3, n2, l2, h2; - if (i2 === T$1) + if (i2 === T) return i2; - let r2 = void 0 !== e2 ? null === (o3 = s2._$Co) || void 0 === o3 ? void 0 : o3[e2] : s2._$Cl; + let r2 = void 0 !== e2 ? null === (o3 = s3._$Co) || void 0 === o3 ? void 0 : o3[e2] : s3._$Cl; const u3 = d(i2) ? void 0 : i2._$litDirective$; - return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s2, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s2)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s2._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; + return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s3, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s3)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s3._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; } class M { constructor(t2, i2) { @@ -358,7 +358,7 @@ class M { } u(t2) { var i2; - const { el: { content: s2 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s2, true); + const { el: { content: s3 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s3, true); C.currentNode = o3; let n2 = C.nextNode(), l2 = 0, h2 = 0, u3 = e2[0]; for (; void 0 !== u3; ) { @@ -372,14 +372,14 @@ class M { } v(t2) { let i2 = 0; - for (const s2 of this._$AV) - void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++; + for (const s3 of this._$AV) + void 0 !== s3 && (void 0 !== s3.strings ? (s3._$AI(t2, s3, i2), i2 += s3.strings.length - 2) : s3._$AI(t2[i2])), i2++; } } class R { - constructor(t2, i2, s2, e2) { + constructor(t2, i2, s3, e2) { var o3; - this.type = 2, this._$AH = A$1, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; + this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s3, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; } get _$AU() { var t2, i2; @@ -397,7 +397,7 @@ class R { return this._$AB; } _$AI(t2, i2 = this) { - t2 = S$1(this, t2, i2), d(t2) ? t2 === A$1 || null == t2 || "" === t2 ? (this._$AH !== A$1 && this._$AR(), this._$AH = A$1) : t2 !== this._$AH && t2 !== T$1 && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v$1(t2) ? this.T(t2) : this._(t2); + t2 = S$1(this, t2, i2), d(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v(t2) ? this.T(t2) : this._(t2); } k(t2) { return this._$AA.parentNode.insertBefore(t2, this._$AB); @@ -406,33 +406,33 @@ class R { this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2)); } _(t2) { - this._$AH !== A$1 && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; + this._$AH !== A && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; } g(t2) { var i2; - const { values: s2, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N.createElement(P(e2.h, e2.h[0]), this.options)), e2); + const { values: s3, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N$1.createElement(P$1(e2.h, e2.h[0]), this.options)), e2); if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o3) - this._$AH.v(s2); + this._$AH.v(s3); else { const t3 = new M(o3, this), i3 = t3.u(this.options); - t3.v(s2), this.$(i3), this._$AH = t3; + t3.v(s3), this.$(i3), this._$AH = t3; } } _$AC(t2) { let i2 = E.get(t2.strings); - return void 0 === i2 && E.set(t2.strings, i2 = new N(t2)), i2; + return void 0 === i2 && E.set(t2.strings, i2 = new N$1(t2)), i2; } T(t2) { - c$1(this._$AH) || (this._$AH = [], this._$AR()); + c(this._$AH) || (this._$AH = [], this._$AR()); const i2 = this._$AH; - let s2, e2 = 0; + let s3, e2 = 0; for (const o3 of t2) - e2 === i2.length ? i2.push(s2 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s2 = i2[e2], s2._$AI(o3), e2++; - e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2); + e2 === i2.length ? i2.push(s3 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s3 = i2[e2], s3._$AI(o3), e2++; + e2 < i2.length && (this._$AR(s3 && s3._$AB.nextSibling, e2), i2.length = e2); } _$AR(t2 = this._$AA.nextSibling, i2) { - var s2; - for (null === (s2 = this._$AP) || void 0 === s2 || s2.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { + var s3; + for (null === (s3 = this._$AP) || void 0 === s3 || s3.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { const i3 = t2.nextSibling; t2.remove(), t2 = i3; } @@ -443,8 +443,8 @@ class R { } } class k { - constructor(t2, i2, s2, e2, o3) { - this.type = 1, this._$AH = A$1, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = A$1; + constructor(t2, i2, s3, e2, o3) { + this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s3.length > 2 || "" !== s3[0] || "" !== s3[1] ? (this._$AH = Array(s3.length - 1).fill(new String()), this.strings = s3) : this._$AH = A; } get tagName() { return this.element.tagName; @@ -452,59 +452,59 @@ class k { get _$AU() { return this._$AM._$AU; } - _$AI(t2, i2 = this, s2, e2) { + _$AI(t2, i2 = this, s3, e2) { const o3 = this.strings; let n2 = false; if (void 0 === o3) - t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T$1, n2 && (this._$AH = t2); + t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T, n2 && (this._$AH = t2); else { const e3 = t2; let l2, h2; for (t2 = o3[0], l2 = 0; l2 < o3.length - 1; l2++) - h2 = S$1(this, e3[s2 + l2], i2, l2), h2 === T$1 && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A$1 ? t2 = A$1 : t2 !== A$1 && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; + h2 = S$1(this, e3[s3 + l2], i2, l2), h2 === T && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A ? t2 = A : t2 !== A && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; } n2 && !e2 && this.j(t2); } j(t2) { - t2 === A$1 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); + t2 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); } } -class H extends k { +let H$1 = class H extends k { constructor() { super(...arguments), this.type = 3; } j(t2) { - this.element[this.name] = t2 === A$1 ? void 0 : t2; + this.element[this.name] = t2 === A ? void 0 : t2; } -} -const I = s$1 ? s$1.emptyScript : ""; +}; +const I = s$2 ? s$2.emptyScript : ""; let L$1 = class L extends k { constructor() { super(...arguments), this.type = 4; } j(t2) { - t2 && t2 !== A$1 ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); + t2 && t2 !== A ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); } }; class z extends k { - constructor(t2, i2, s2, e2, o3) { - super(t2, i2, s2, e2, o3), this.type = 5; + constructor(t2, i2, s3, e2, o3) { + super(t2, i2, s3, e2, o3), this.type = 5; } _$AI(t2, i2 = this) { - var s2; - if ((t2 = null !== (s2 = S$1(this, t2, i2, 0)) && void 0 !== s2 ? s2 : A$1) === T$1) + var s3; + if ((t2 = null !== (s3 = S$1(this, t2, i2, 0)) && void 0 !== s3 ? s3 : A) === T) return; - const e2 = this._$AH, o3 = t2 === A$1 && e2 !== A$1 || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A$1 && (e2 === A$1 || o3); + const e2 = this._$AH, o3 = t2 === A && e2 !== A || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A && (e2 === A || o3); o3 && this.element.removeEventListener(this.name, this, e2), n2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2; } handleEvent(t2) { - var i2, s2; - "function" == typeof this._$AH ? this._$AH.call(null !== (s2 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s2 ? s2 : this.element, t2) : this._$AH.handleEvent(t2); + var i2, s3; + "function" == typeof this._$AH ? this._$AH.call(null !== (s3 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s3 ? s3 : this.element, t2) : this._$AH.handleEvent(t2); } } let Z$1 = class Z { - constructor(t2, i2, s2) { - this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s2; + constructor(t2, i2, s3) { + this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s3; } get _$AU() { return this._$AM._$AU; @@ -514,14 +514,14 @@ let Z$1 = class Z { } }; const B$1 = i$2.litHtmlPolyfillSupport; -null == B$1 || B$1(N, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); -const D$1 = (t2, i2, s2) => { +null == B$1 || B$1(N$1, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); +const D$1 = (t2, i2, s3) => { var e2, o3; - const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2; + const n2 = null !== (e2 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== e2 ? e2 : i2; let l2 = n2._$litPart$; if (void 0 === l2) { - const t3 = null !== (o3 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== o3 ? o3 : null; - n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s2 ? s2 : {}); + const t3 = null !== (o3 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== o3 ? o3 : null; + n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s3 ? s3 : {}); } return l2._$AI(t2), l2; }; @@ -531,7 +531,7 @@ const D$1 = (t2, i2, s2) => { * SPDX-License-Identifier: BSD-3-Clause */ var l$1, o$1; -class s extends u$1 { +let s$1 = class s extends u$1 { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } @@ -553,12 +553,12 @@ class s extends u$1 { super.disconnectedCallback(), null === (t2 = this._$Do) || void 0 === t2 || t2.setConnected(false); } render() { - return T$1; + return T; } -} -s.finalized = true, s._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s }); +}; +s$1.finalized = true, s$1._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s$1 }); const n$2 = globalThis.litElementPolyfillSupport; -null == n$2 || n$2({ LitElement: s }); +null == n$2 || n$2({ LitElement: s$1 }); (null !== (o$1 = globalThis.litElementVersions) && void 0 !== o$1 ? o$1 : globalThis.litElementVersions = []).push("3.3.3"); /** * @license @@ -566,8 +566,8 @@ null == n$2 || n$2({ LitElement: s }); * SPDX-License-Identifier: BSD-3-Clause */ const e$2 = (e2) => (n2) => "function" == typeof n2 ? ((e3, n3) => (customElements.define(e3, n3), n3))(e2, n2) : ((e3, n3) => { - const { kind: t2, elements: s2 } = n3; - return { kind: t2, elements: s2, finisher(n4) { + const { kind: t2, elements: s3 } = n3; + return { kind: t2, elements: s3, finisher(n4) { customElements.define(e3, n4); } }; })(e2, n2); @@ -639,23 +639,23 @@ const o2 = e(class extends i { render(t2) { return " " + Object.keys(t2).filter((i2) => t2[i2]).join(" ") + " "; } - update(i2, [s2]) { + update(i2, [s3]) { var r2, o3; if (void 0 === this.it) { this.it = /* @__PURE__ */ new Set(), void 0 !== i2.strings && (this.nt = new Set(i2.strings.join(" ").split(/\s/).filter((t2) => "" !== t2))); - for (const t2 in s2) - s2[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); - return this.render(s2); + for (const t2 in s3) + s3[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); + return this.render(s3); } const e2 = i2.element.classList; this.it.forEach((t2) => { - t2 in s2 || (e2.remove(t2), this.it.delete(t2)); + t2 in s3 || (e2.remove(t2), this.it.delete(t2)); }); - for (const t2 in s2) { - const i3 = !!s2[t2]; + for (const t2 in s3) { + const i3 = !!s3[t2]; i3 === this.it.has(t2) || (null === (o3 = this.nt) || void 0 === o3 ? void 0 : o3.has(t2)) || (i3 ? (e2.add(t2), this.it.add(t2)) : (e2.remove(t2), this.it.delete(t2))); } - return T$1; + return T; } }); function addUniqueItem(array, item) { @@ -1215,12 +1215,8 @@ const getOptions = (options, key) => ( options[key] ? Object.assign(Object.assign({}, options), options[key]) : Object.assign({}, options) ); function resolveElements(elements, selectorCache) { - var _a; if (typeof elements === "string") { - if (selectorCache) { - (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : selectorCache[elements] = document.querySelectorAll(elements); - elements = selectorCache[elements]; - } else { + { elements = document.querySelectorAll(elements); } } else if (elements instanceof Element) { @@ -1334,7 +1330,7 @@ function animate(target, keyframesOrOptions, options) { * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const l = (l2) => null != l2 ? l2 : A$1; +const l = (l2) => null != l2 ? l2 : A; var browser = {}; var canPromise$1 = function() { return typeof Promise === "function" && Promise.prototype && Promise.prototype.then; @@ -1532,13 +1528,13 @@ var alignmentPattern = {}; const pos = exports2.getRowColCoords(version2); const posLength = pos.length; for (let i2 = 0; i2 < posLength; i2++) { - for (let j2 = 0; j2 < posLength; j2++) { - if (i2 === 0 && j2 === 0 || // top-left - i2 === 0 && j2 === posLength - 1 || // bottom-left - i2 === posLength - 1 && j2 === 0) { + for (let j = 0; j < posLength; j++) { + if (i2 === 0 && j === 0 || // top-left + i2 === 0 && j === posLength - 1 || // bottom-left + i2 === posLength - 1 && j === 0) { continue; } - coords.push([pos[i2], pos[j2]]); + coords.push([pos[i2], pos[j]]); } } return coords; @@ -1657,24 +1653,24 @@ var maskPattern = {}; const k2 = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10); return k2 * PenaltyScores.N4; }; - function getMaskAt(maskPattern2, i2, j2) { + function getMaskAt(maskPattern2, i2, j) { switch (maskPattern2) { case exports2.Patterns.PATTERN000: - return (i2 + j2) % 2 === 0; + return (i2 + j) % 2 === 0; case exports2.Patterns.PATTERN001: return i2 % 2 === 0; case exports2.Patterns.PATTERN010: - return j2 % 3 === 0; + return j % 3 === 0; case exports2.Patterns.PATTERN011: - return (i2 + j2) % 3 === 0; + return (i2 + j) % 3 === 0; case exports2.Patterns.PATTERN100: - return (Math.floor(i2 / 2) + Math.floor(j2 / 3)) % 2 === 0; + return (Math.floor(i2 / 2) + Math.floor(j / 3)) % 2 === 0; case exports2.Patterns.PATTERN101: - return i2 * j2 % 2 + i2 * j2 % 3 === 0; + return i2 * j % 2 + i2 * j % 3 === 0; case exports2.Patterns.PATTERN110: - return (i2 * j2 % 2 + i2 * j2 % 3) % 2 === 0; + return (i2 * j % 2 + i2 * j % 3) % 2 === 0; case exports2.Patterns.PATTERN111: - return (i2 * j2 % 3 + (i2 + j2) % 2) % 2 === 0; + return (i2 * j % 3 + (i2 + j) % 2) % 2 === 0; default: throw new Error("bad maskPattern:" + maskPattern2); } @@ -2098,8 +2094,8 @@ galoisField.mul = function mul(x2, y2) { exports2.mul = function mul2(p1, p2) { const coeff = new Uint8Array(p1.length + p2.length - 1); for (let i2 = 0; i2 < p1.length; i2++) { - for (let j2 = 0; j2 < p2.length; j2++) { - coeff[i2 + j2] ^= GF.mul(p1[i2], p2[j2]); + for (let j = 0; j < p2.length; j++) { + coeff[i2 + j] ^= GF.mul(p1[i2], p2[j]); } } return coeff; @@ -2574,12 +2570,12 @@ var kanjiData = KanjiData; var dijkstra = { exports: {} }; (function(module2) { var dijkstra2 = { - single_source_shortest_paths: function(graph, s2, d2) { + single_source_shortest_paths: function(graph, s3, d2) { var predecessors = {}; var costs = {}; - costs[s2] = 0; + costs[s3] = 0; var open = dijkstra2.PriorityQueue.make(); - open.push(s2, 0); + open.push(s3, 0); var closest, u3, v2, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; while (!open.empty()) { closest = open.pop(); @@ -2601,7 +2597,7 @@ var dijkstra = { exports: {} }; } } if (typeof d2 !== "undefined" && typeof costs[d2] === "undefined") { - var msg = ["Could not find a path from ", s2, " to ", d2, "."].join(""); + var msg = ["Could not find a path from ", s3, " to ", d2, "."].join(""); throw new Error(msg); } return predecessors; @@ -2617,8 +2613,8 @@ var dijkstra = { exports: {} }; nodes.reverse(); return nodes; }, - find_path: function(graph, s2, d2) { - var predecessors = dijkstra2.single_source_shortest_paths(graph, s2, d2); + find_path: function(graph, s3, d2) { + var predecessors = dijkstra2.single_source_shortest_paths(graph, s3, d2); return dijkstra2.extract_shortest_path_from_predecessor_list( predecessors, d2 @@ -2706,8 +2702,8 @@ var dijkstraExports = dijkstra.exports; kanjiSegs = []; } const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs); - return segs.sort(function(s1, s2) { - return s1.index - s2.index; + return segs.sort(function(s1, s22) { + return s1.index - s22.index; }).map(function(obj) { return { data: obj.data, @@ -2778,9 +2774,9 @@ var dijkstraExports = dijkstra.exports; for (let i2 = 0; i2 < nodes.length; i2++) { const nodeGroup = nodes[i2]; const currentNodeIds = []; - for (let j2 = 0; j2 < nodeGroup.length; j2++) { - const node = nodeGroup[j2]; - const key = "" + i2 + j2; + for (let j = 0; j < nodeGroup.length; j++) { + const node = nodeGroup[j]; + const key = "" + i2 + j; currentNodeIds.push(key); table[key] = { node, lastCount: 0 }; graph[key] = {}; @@ -3174,12 +3170,12 @@ var utils = {}; const scaledMargin = opts.margin * scale; const palette = [opts.color.light, opts.color.dark]; for (let i2 = 0; i2 < symbolSize; i2++) { - for (let j2 = 0; j2 < symbolSize; j2++) { - let posDst = (i2 * symbolSize + j2) * 4; + for (let j = 0; j < symbolSize; j++) { + let posDst = (i2 * symbolSize + j) * 4; let pxColor = opts.color.light; - if (i2 >= scaledMargin && j2 >= scaledMargin && i2 < symbolSize - scaledMargin && j2 < symbolSize - scaledMargin) { + if (i2 >= scaledMargin && j >= scaledMargin && i2 < symbolSize - scaledMargin && j < symbolSize - scaledMargin) { const iSrc = Math.floor((i2 - scaledMargin) / scale); - const jSrc = Math.floor((j2 - scaledMargin) / scale); + const jSrc = Math.floor((j - scaledMargin) / scale); pxColor = palette[data2[iSrc * size + jSrc] ? 1 : 0]; } imgData[posDst++] = pxColor.r; @@ -3360,150 +3356,54 @@ browser.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL); browser.toString = renderCanvas.bind(null, function(data2, _2, opts) { return SvgRenderer.render(data2, opts); }); -var et = Object.defineProperty, Be = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Ue = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, ve = (e2, o3) => { +var et = Object.defineProperty, Se = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Be = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, fe = (e2, o3) => { for (var r2 in o3 || (o3 = {})) - tt.call(o3, r2) && Ue(e2, r2, o3[r2]); - if (Be) - for (var r2 of Be(o3)) - ot.call(o3, r2) && Ue(e2, r2, o3[r2]); + tt.call(o3, r2) && Be(e2, r2, o3[r2]); + if (Se) + for (var r2 of Se(o3)) + ot.call(o3, r2) && Be(e2, r2, o3[r2]); return e2; }; function rt() { var e2; - const o3 = (e2 = index.ne.state.themeMode) != null ? e2 : "dark", r2 = { - light: { - foreground: { - 1: "rgb(20,20,20)", - 2: "rgb(121,134,134)", - 3: "rgb(158,169,169)" - }, - background: { - 1: "rgb(255,255,255)", - 2: "rgb(241,243,243)", - 3: "rgb(228,231,231)" - }, - overlay: "rgba(0,0,0,0.1)" - }, - dark: { - foreground: { - 1: "rgb(228,231,231)", - 2: "rgb(148,158,158)", - 3: "rgb(110,119,119)" - }, - background: { - 1: "rgb(20,20,20)", - 2: "rgb(39,42,42)", - 3: "rgb(59,64,64)" - }, - overlay: "rgba(255,255,255,0.1)" - } - }[o3]; - return { - "--wcm-color-fg-1": r2.foreground[1], - "--wcm-color-fg-2": r2.foreground[2], - "--wcm-color-fg-3": r2.foreground[3], - "--wcm-color-bg-1": r2.background[1], - "--wcm-color-bg-2": r2.background[2], - "--wcm-color-bg-3": r2.background[3], - "--wcm-color-overlay": r2.overlay - }; + const o3 = (e2 = index.ne$3.state.themeMode) != null ? e2 : "dark", r2 = { light: { foreground: { 1: "rgb(20,20,20)", 2: "rgb(121,134,134)", 3: "rgb(158,169,169)" }, background: { 1: "rgb(255,255,255)", 2: "rgb(241,243,243)", 3: "rgb(228,231,231)" }, overlay: "rgba(0,0,0,0.1)" }, dark: { foreground: { 1: "rgb(228,231,231)", 2: "rgb(148,158,158)", 3: "rgb(110,119,119)" }, background: { 1: "rgb(20,20,20)", 2: "rgb(39,42,42)", 3: "rgb(59,64,64)" }, overlay: "rgba(255,255,255,0.1)" } }[o3]; + return { "--wcm-color-fg-1": r2.foreground[1], "--wcm-color-fg-2": r2.foreground[2], "--wcm-color-fg-3": r2.foreground[3], "--wcm-color-bg-1": r2.background[1], "--wcm-color-bg-2": r2.background[2], "--wcm-color-bg-3": r2.background[3], "--wcm-color-overlay": r2.overlay }; } -function He() { - return { - "--wcm-accent-color": "#3396FF", - "--wcm-accent-fill-color": "#FFFFFF", - "--wcm-z-index": "89", - "--wcm-background-color": "#3396FF", - "--wcm-background-border-radius": "8px", - "--wcm-container-border-radius": "30px", - "--wcm-wallet-icon-border-radius": "15px", - "--wcm-wallet-icon-large-border-radius": "30px", - "--wcm-wallet-icon-small-border-radius": "7px", - "--wcm-input-border-radius": "28px", - "--wcm-button-border-radius": "10px", - "--wcm-notification-border-radius": "36px", - "--wcm-secondary-button-border-radius": "28px", - "--wcm-icon-button-border-radius": "50%", - "--wcm-button-hover-highlight-border-radius": "10px", - "--wcm-text-big-bold-size": "20px", - "--wcm-text-big-bold-weight": "600", - "--wcm-text-big-bold-line-height": "24px", - "--wcm-text-big-bold-letter-spacing": "-0.03em", - "--wcm-text-big-bold-text-transform": "none", - "--wcm-text-xsmall-bold-size": "10px", - "--wcm-text-xsmall-bold-weight": "700", - "--wcm-text-xsmall-bold-line-height": "12px", - "--wcm-text-xsmall-bold-letter-spacing": "0.02em", - "--wcm-text-xsmall-bold-text-transform": "uppercase", - "--wcm-text-xsmall-regular-size": "12px", - "--wcm-text-xsmall-regular-weight": "600", - "--wcm-text-xsmall-regular-line-height": "14px", - "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", - "--wcm-text-xsmall-regular-text-transform": "none", - "--wcm-text-small-thin-size": "14px", - "--wcm-text-small-thin-weight": "500", - "--wcm-text-small-thin-line-height": "16px", - "--wcm-text-small-thin-letter-spacing": "-0.03em", - "--wcm-text-small-thin-text-transform": "none", - "--wcm-text-small-regular-size": "14px", - "--wcm-text-small-regular-weight": "600", - "--wcm-text-small-regular-line-height": "16px", - "--wcm-text-small-regular-letter-spacing": "-0.03em", - "--wcm-text-small-regular-text-transform": "none", - "--wcm-text-medium-regular-size": "16px", - "--wcm-text-medium-regular-weight": "600", - "--wcm-text-medium-regular-line-height": "20px", - "--wcm-text-medium-regular-letter-spacing": "-0.03em", - "--wcm-text-medium-regular-text-transform": "none", - "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", - "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", - "--wcm-success-color": "rgb(38,181,98)", - "--wcm-error-color": "rgb(242, 90, 103)", - "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", - "--wcm-overlay-backdrop-filter": "none" - }; +function Ue() { + return { "--wcm-accent-color": "#3396FF", "--wcm-accent-fill-color": "#FFFFFF", "--wcm-z-index": "89", "--wcm-background-color": "#3396FF", "--wcm-background-border-radius": "8px", "--wcm-container-border-radius": "30px", "--wcm-wallet-icon-border-radius": "15px", "--wcm-wallet-icon-large-border-radius": "30px", "--wcm-wallet-icon-small-border-radius": "7px", "--wcm-input-border-radius": "28px", "--wcm-button-border-radius": "10px", "--wcm-notification-border-radius": "36px", "--wcm-secondary-button-border-radius": "28px", "--wcm-icon-button-border-radius": "50%", "--wcm-button-hover-highlight-border-radius": "10px", "--wcm-text-big-bold-size": "20px", "--wcm-text-big-bold-weight": "600", "--wcm-text-big-bold-line-height": "24px", "--wcm-text-big-bold-letter-spacing": "-0.03em", "--wcm-text-big-bold-text-transform": "none", "--wcm-text-xsmall-bold-size": "10px", "--wcm-text-xsmall-bold-weight": "700", "--wcm-text-xsmall-bold-line-height": "12px", "--wcm-text-xsmall-bold-letter-spacing": "0.02em", "--wcm-text-xsmall-bold-text-transform": "uppercase", "--wcm-text-xsmall-regular-size": "12px", "--wcm-text-xsmall-regular-weight": "600", "--wcm-text-xsmall-regular-line-height": "14px", "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", "--wcm-text-xsmall-regular-text-transform": "none", "--wcm-text-small-thin-size": "14px", "--wcm-text-small-thin-weight": "500", "--wcm-text-small-thin-line-height": "16px", "--wcm-text-small-thin-letter-spacing": "-0.03em", "--wcm-text-small-thin-text-transform": "none", "--wcm-text-small-regular-size": "14px", "--wcm-text-small-regular-weight": "600", "--wcm-text-small-regular-line-height": "16px", "--wcm-text-small-regular-letter-spacing": "-0.03em", "--wcm-text-small-regular-text-transform": "none", "--wcm-text-medium-regular-size": "16px", "--wcm-text-medium-regular-weight": "600", "--wcm-text-medium-regular-line-height": "20px", "--wcm-text-medium-regular-letter-spacing": "-0.03em", "--wcm-text-medium-regular-text-transform": "none", "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", "--wcm-success-color": "rgb(38,181,98)", "--wcm-error-color": "rgb(242, 90, 103)", "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", "--wcm-overlay-backdrop-filter": "none" }; } -const h = { - getPreset(e2) { - return He()[e2]; - }, - setTheme() { - const e2 = document.querySelector(":root"), { themeVariables: o3 } = index.ne.state; - if (e2) { - const r2 = ve(ve(ve({}, rt()), He()), o3); - Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); - } - }, - globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` -}, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; -var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, F = (e2, o3, r2, a2) => { +const h = { getPreset(e2) { + return Ue()[e2]; +}, setTheme() { + const e2 = document.querySelector(":root"), { themeVariables: o3 } = index.ne$3.state; + if (e2) { + const r2 = fe(fe(fe({}, rt()), Ue()), o3); + Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); + } +}, globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` }, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; +var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? it(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && lt(o3, r2, t2), t2; }; -let T = class extends s { +let _ = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.iconLeft = void 0, this.iconRight = void 0, this.onClick = () => null, this.variant = "default"; } render() { - const e2 = { - "wcm-icon-left": this.iconLeft !== void 0, - "wcm-icon-right": this.iconRight !== void 0, - "wcm-ghost": this.variant === "ghost", - "wcm-outline": this.variant === "outline" - }; + const e2 = { "wcm-icon-left": this.iconLeft !== void 0, "wcm-icon-right": this.iconRight !== void 0, "wcm-ghost": this.variant === "ghost", "wcm-outline": this.variant === "outline" }; let o$12 = "inverse"; return this.variant === "ghost" && (o$12 = "secondary"), this.variant === "outline" && (o$12 = "accent"), x``; } }; -T.styles = [h.globalCss, at], F([n$1({ type: Boolean })], T.prototype, "disabled", 2), F([n$1()], T.prototype, "iconLeft", 2), F([n$1()], T.prototype, "iconRight", 2), F([n$1()], T.prototype, "onClick", 2), F([n$1()], T.prototype, "variant", 2), T = F([e$2("wcm-button")], T); +_.styles = [h.globalCss, at], K([n$1({ type: Boolean })], _.prototype, "disabled", 2), K([n$1()], _.prototype, "iconLeft", 2), K([n$1()], _.prototype, "iconRight", 2), K([n$1()], _.prototype, "onClick", 2), K([n$1()], _.prototype, "variant", 2), _ = K([e$2("wcm-button")], _); const nt = i$3`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`; -var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, ue = (e2, o3, r2, a2) => { +var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, xe = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? st(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && ct(o3, r2, t2), t2; }; -let ee = class extends s { +let re = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.variant = "primary"; } @@ -3512,203 +3412,159 @@ let ee = class extends s { return x``; } }; -ee.styles = [h.globalCss, nt], ue([n$1({ type: Boolean })], ee.prototype, "disabled", 2), ue([n$1()], ee.prototype, "variant", 2), ee = ue([e$2("wcm-button-big")], ee); +re.styles = [h.globalCss, nt], xe([n$1({ type: Boolean })], re.prototype, "disabled", 2), xe([n$1()], re.prototype, "variant", 2), re = xe([e$2("wcm-button-big")], re); const dt = i$3`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`; -var mt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, wt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && mt(o3, r2, t2), t2; +var ht = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let be = class extends s { +let ye = class extends s$1 { render() { return x`
`; } }; -be.styles = [h.globalCss, dt], be = wt([e$2("wcm-info-footer")], be); -const v = { - CROSS_ICON: b``, - WALLET_CONNECT_LOGO: b``, - WALLET_CONNECT_ICON: b``, - WALLET_CONNECT_ICON_COLORED: b``, - BACK_ICON: b``, - COPY_ICON: b``, - RETRY_ICON: b``, - DESKTOP_ICON: b``, - MOBILE_ICON: b``, - ARROW_DOWN_ICON: b``, - ARROW_UP_RIGHT_ICON: b``, - ARROW_RIGHT_ICON: b``, - QRCODE_ICON: b``, - SCAN_ICON: b``, - CHECKMARK_ICON: b``, - SEARCH_ICON: b``, - WALLET_PLACEHOLDER: b``, - GLOBE_ICON: b`` -}, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; -var gt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, ut = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? vt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && gt(o3, r2, t2), t2; +ye.styles = [h.globalCss, dt], ye = ht([e$2("wcm-info-footer")], ye); +const b = { CROSS_ICON: b$1``, WALLET_CONNECT_LOGO: b$1``, WALLET_CONNECT_ICON: b$1``, WALLET_CONNECT_ICON_COLORED: b$1``, BACK_ICON: b$1``, COPY_ICON: b$1``, RETRY_ICON: b$1``, DESKTOP_ICON: b$1``, MOBILE_ICON: b$1``, ARROW_DOWN_ICON: b$1``, ARROW_UP_RIGHT_ICON: b$1``, ARROW_RIGHT_ICON: b$1``, QRCODE_ICON: b$1``, SCAN_ICON: b$1``, CHECKMARK_ICON: b$1``, SEARCH_ICON: b$1``, WALLET_PLACEHOLDER: b$1``, GLOBE_ICON: b$1`` }, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; +var ut = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let fe = class extends s { +let $e = class extends s$1 { render() { - return x`
${v.WALLET_CONNECT_LOGO}
`; + return x`
${b.WALLET_CONNECT_LOGO}
`; } }; -fe.styles = [h.globalCss, pt], fe = ut([e$2("wcm-modal-backcard")], fe); +$e.styles = [h.globalCss, pt], $e = ut([e$2("wcm-modal-backcard")], $e); const bt = i$3`main{padding:20px;padding-top:0;width:100%}`; -var ft = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, yt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? xt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ft(o3, r2, t2), t2; +var yt = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let xe = class extends s { +let Ce = class extends s$1 { render() { return x`
`; } }; -xe.styles = [h.globalCss, bt], xe = yt([e$2("wcm-modal-content")], xe); +Ce.styles = [h.globalCss, bt], Ce = yt([e$2("wcm-modal-content")], Ce); const $t = i$3`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`; -var Ct = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, Ot = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? kt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ct(o3, r2, t2), t2; +var Ot = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let ye = class extends s { +let ke = class extends s$1 { render() { return x`
`; } }; -ye.styles = [h.globalCss, $t], ye = Ot([e$2("wcm-modal-footer")], ye); -const Wt = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; -var It = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, te = (e2, o3, r2, a2) => { +ke.styles = [h.globalCss, $t], ke = Ot([e$2("wcm-modal-footer")], ke); +const It = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; +var Wt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, ae = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Et(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && It(o3, r2, t2), t2; + return a2 && t2 && Wt(o3, r2, t2), t2; }; -let S = class extends s { +let B = class extends s$1 { constructor() { super(...arguments), this.title = "", this.onAction = void 0, this.actionIcon = void 0, this.border = false; } backBtnTemplate() { - return x``; + return x``; } actionBtnTemplate() { return x``; } render() { - const e2 = { "wcm-border": this.border }, o$12 = index.T$1.state.history.length > 1, r2 = this.title ? x`${this.title}` : x``; + const e2 = { "wcm-border": this.border }, o$12 = index.T$2.state.history.length > 1, r2 = this.title ? x`${this.title}` : x``; return x`
${o$12 ? this.backBtnTemplate() : null} ${r2} ${this.onAction ? this.actionBtnTemplate() : null}
`; } }; -S.styles = [h.globalCss, Wt], te([n$1()], S.prototype, "title", 2), te([n$1()], S.prototype, "onAction", 2), te([n$1()], S.prototype, "actionIcon", 2), te([n$1({ type: Boolean })], S.prototype, "border", 2), S = te([e$2("wcm-modal-header")], S); -const c = { - MOBILE_BREAKPOINT: 600, - WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", - EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", - getShadowRootElement(e2, o3) { - const r2 = e2.renderRoot.querySelector(o3); - if (!r2) - throw new Error(`${o3} not found`); - return r2; - }, - getWalletIcon({ id: e2, image_id: o3 }) { - const { walletImages: r2 } = index.y$3.state; - return r2 != null && r2[e2] ? r2[e2] : o3 ? index.te$2.getWalletImageUrl(o3) : ""; - }, - getWalletName(e2, o3 = false) { - return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; - }, - isMobileAnimation() { - return window.innerWidth <= c.MOBILE_BREAKPOINT; - }, - async preloadImage(e2) { - const o3 = new Promise((r2, a2) => { - const t2 = new Image(); - t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; - }); - return Promise.race([o3, index.a$3.wait(3e3)]); - }, - getErrorMessage(e2) { - return e2 instanceof Error ? e2.message : "Unknown Error"; - }, - debounce(e2, o3 = 500) { - let r2; - return (...a2) => { - function t2() { - e2(...a2); - } - r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); - }; - }, - handleMobileLinking(e2) { - const { walletConnectUri: o3 } = index.p$3.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - c.setRecentWallet(e2); - function i2(s2) { - let $2 = ""; - t2 ? $2 = index.a$3.formatUniversalUrl(t2, s2, a2) : l2 && ($2 = index.a$3.formatNativeUrl(l2, s2, a2)), index.a$3.openHref($2, "_self"); - } - o3 && i2(o3); - }, - async handleUriCopy() { - const { walletConnectUri: e2 } = index.p$3.state; - if (e2) - try { - await navigator.clipboard.writeText(e2), index.oe$1.openToast("Link copied", "success"); - } catch { - index.oe$1.openToast("Failed to copy", "error"); - } - }, - getCustomImageUrls() { - const { walletImages: e2 } = index.y$3.state, o3 = Object.values(e2 ?? {}); - return Object.values(o3); - }, - truncate(e2, o3 = 8) { - return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; - }, - setRecentWallet(e2) { - try { - localStorage.setItem(c.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); - } catch { - console.info("Unable to set recent wallet"); +B.styles = [h.globalCss, It], ae([n$1()], B.prototype, "title", 2), ae([n$1()], B.prototype, "onAction", 2), ae([n$1()], B.prototype, "actionIcon", 2), ae([n$1({ type: Boolean })], B.prototype, "border", 2), B = ae([e$2("wcm-modal-header")], B); +const s2 = { MOBILE_BREAKPOINT: 600, WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", getShadowRootElement(e2, o3) { + const r2 = e2.renderRoot.querySelector(o3); + if (!r2) + throw new Error(`${o3} not found`); + return r2; +}, getWalletIcon({ id: e2, image_id: o3 }) { + const { walletImages: r2 } = index.y$4.state; + return r2 != null && r2[e2] ? r2[e2] : o3 ? index.te$1.getWalletImageUrl(o3) : ""; +}, getWalletName(e2, o3 = false) { + return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; +}, isMobileAnimation() { + return window.innerWidth <= s2.MOBILE_BREAKPOINT; +}, async preloadImage(e2) { + const o3 = new Promise((r2, a2) => { + const t2 = new Image(); + t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; + }); + return Promise.race([o3, index.i$1.wait(3e3)]); +}, getErrorMessage(e2) { + return e2 instanceof Error ? e2.message : "Unknown Error"; +}, debounce(e2, o3 = 500) { + let r2; + return (...a2) => { + function t2() { + e2(...a2); } - }, - getRecentWallet() { + r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); + }; +}, handleMobileLinking(e2) { + const { walletConnectUri: o3 } = index.p$2.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; + s2.setRecentWallet(e2); + function i2(c2) { + let u3 = ""; + t2 ? u3 = index.i$1.formatUniversalUrl(t2, c2, a2) : l2 && (u3 = index.i$1.formatNativeUrl(l2, c2, a2)), index.i$1.openHref(u3, "_self"); + } + o3 && i2(o3); +}, async handleUriCopy() { + const { walletConnectUri: e2 } = index.p$2.state; + if (e2) try { - const e2 = localStorage.getItem(c.WCM_RECENT_WALLET_DATA); - return e2 ? JSON.parse(e2) : void 0; + await navigator.clipboard.writeText(e2), index.oe$2.openToast("Link copied", "success"); } catch { - console.info("Unable to get recent wallet"); + index.oe$2.openToast("Failed to copy", "error"); } - }, - caseSafeIncludes(e2, o3) { - return e2.toUpperCase().includes(o3.toUpperCase()); - }, - openWalletExplorerUrl() { - index.a$3.openHref(c.EXPLORER_WALLET_URL, "_blank"); - }, - getCachedRouterWalletPlatforms() { - const { desktop: e2, mobile: o3 } = index.a$3.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); - return { isDesktop: r2, isMobile: t2, isWeb: a2 }; - }, - goToConnectingView(e2) { - index.T$1.setData({ Wallet: e2 }); - const o3 = index.a$3.isMobile(), { - isDesktop: r2, - isWeb: a2, - isMobile: t2 - } = c.getCachedRouterWalletPlatforms(); - o3 ? t2 ? index.T$1.push("MobileConnecting") : a2 ? index.T$1.push("WebConnecting") : index.T$1.push("InstallWallet") : r2 ? index.T$1.push("DesktopConnecting") : a2 ? index.T$1.push("WebConnecting") : t2 ? index.T$1.push("MobileQrcodeConnecting") : index.T$1.push("InstallWallet"); - } -}, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; -var Lt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, $e = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Rt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +}, getCustomImageUrls() { + const { walletImages: e2 } = index.y$4.state, o3 = Object.values(e2 ?? {}); + return Object.values(o3); +}, truncate(e2, o3 = 8) { + return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; +}, setRecentWallet(e2) { + try { + localStorage.setItem(s2.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); + } catch { + console.info("Unable to set recent wallet"); + } +}, getRecentWallet() { + try { + const e2 = localStorage.getItem(s2.WCM_RECENT_WALLET_DATA); + return e2 ? JSON.parse(e2) : void 0; + } catch { + console.info("Unable to get recent wallet"); + } +}, caseSafeIncludes(e2, o3) { + return e2.toUpperCase().includes(o3.toUpperCase()); +}, openWalletExplorerUrl() { + index.i$1.openHref(s2.EXPLORER_WALLET_URL, "_blank"); +}, getCachedRouterWalletPlatforms() { + const { desktop: e2, mobile: o3 } = index.i$1.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); + return { isDesktop: r2, isMobile: t2, isWeb: a2 }; +}, goToConnectingView(e2) { + index.T$2.setData({ Wallet: e2 }); + const o3 = index.i$1.isMobile(), { isDesktop: r2, isWeb: a2, isMobile: t2 } = s2.getCachedRouterWalletPlatforms(); + o3 ? t2 ? index.T$2.push("MobileConnecting") : a2 ? index.T$2.push("WebConnecting") : index.T$2.push("InstallWallet") : r2 ? index.T$2.push("DesktopConnecting") : a2 ? index.T$2.push("WebConnecting") : t2 ? index.T$2.push("MobileQrcodeConnecting") : index.T$2.push("InstallWallet"); +} }, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; +var Pt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Lt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Lt(o3, r2, t2), t2; + return a2 && t2 && Pt(o3, r2, t2), t2; }; -let oe = class extends s { +let le = class extends s$1 { constructor() { - super(), this.view = index.T$1.state.view, this.prevView = index.T$1.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = index.T$1.subscribe((e2) => { + super(), this.view = index.T$2.state.view, this.prevView = index.T$2.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = index.T$2.subscribe((e2) => { this.view !== e2.view && this.onChangeRoute(); }); } @@ -3723,10 +3579,10 @@ let oe = class extends s { (e2 = this.unsubscribe) == null || e2.call(this), (o3 = this.resizeObserver) == null || o3.disconnect(); } get routerEl() { - return c.getShadowRootElement(this, ".wcm-router"); + return s2.getShadowRootElement(this, ".wcm-router"); } get contentEl() { - return c.getShadowRootElement(this, ".wcm-content"); + return s2.getShadowRootElement(this, ".wcm-content"); } viewTemplate() { switch (this.view) { @@ -3751,196 +3607,157 @@ let oe = class extends s { } } async onChangeRoute() { - await animate( - this.routerEl, - { opacity: [1, 0], scale: [1, 1.02] }, - { duration: 0.15, delay: 0.1 } - ).finished, this.view = index.T$1.state.view, animate( - this.routerEl, - { opacity: [0, 1], scale: [0.99, 1] }, - { duration: 0.37, delay: 0.05 } - ); + await animate(this.routerEl, { opacity: [1, 0], scale: [1, 1.02] }, { duration: 0.15, delay: 0.1 }).finished, this.view = index.T$2.state.view, animate(this.routerEl, { opacity: [0, 1], scale: [0.99, 1] }, { duration: 0.37, delay: 0.05 }); } render() { return x`
${this.viewTemplate()}
`; } }; -oe.styles = [h.globalCss, Mt], $e([t$1()], oe.prototype, "view", 2), $e([t$1()], oe.prototype, "prevView", 2), oe = $e([e$2("wcm-modal-router")], oe); -const At = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; -var Pt = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, ze = (e2, o3, r2, a2) => { +le.styles = [h.globalCss, Mt], Oe([t$1()], le.prototype, "view", 2), Oe([t$1()], le.prototype, "prevView", 2), le = Oe([e$2("wcm-modal-router")], le); +const Rt = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; +var At = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, He = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Tt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Pt(o3, r2, t2), t2; + return a2 && t2 && At(o3, r2, t2), t2; }; -let ne = class extends s { +let de = class extends s$1 { constructor() { - super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = index.oe$1.subscribe((e2) => { - e2.open ? (this.open = true, this.timeout = setTimeout(() => index.oe$1.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); + super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = index.oe$2.subscribe((e2) => { + e2.open ? (this.open = true, this.timeout = setTimeout(() => index.oe$2.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); }); } disconnectedCallback() { var e2; - (e2 = this.unsubscribe) == null || e2.call(this), clearTimeout(this.timeout), index.oe$1.closeToast(); + (e2 = this.unsubscribe) == null || e2.call(this), clearTimeout(this.timeout), index.oe$2.closeToast(); } render() { - const { message: e2, variant: o$12 } = index.oe$1.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; - return this.open ? x`
${o$12 === "success" ? v.CHECKMARK_ICON : null} ${o$12 === "error" ? v.CROSS_ICON : null}${e2}
` : null; + const { message: e2, variant: o$12 } = index.oe$2.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; + return this.open ? x`
${o$12 === "success" ? b.CHECKMARK_ICON : null} ${o$12 === "error" ? b.CROSS_ICON : null}${e2}
` : null; } }; -ne.styles = [h.globalCss, At], ze([t$1()], ne.prototype, "open", 2), ne = ze([e$2("wcm-modal-toast")], ne); -const jt = 0.1, Ve = 2.5, A = 7; -function Ce(e2, o3, r2) { +de.styles = [h.globalCss, Rt], He([t$1()], de.prototype, "open", 2), de = He([e$2("wcm-modal-toast")], de); +const jt = 0.1, Ve = 2.5, L2 = 7; +function Ie(e2, o3, r2) { return e2 === o3 ? false : (e2 - o3 < 0 ? o3 - e2 : e2 - o3) <= r2 + jt; } function _t(e2, o3) { - const r2 = Array.prototype.slice.call( - browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, - 0 - ), a2 = Math.sqrt(r2.length); - return r2.reduce( - (t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, - [] - ); + const r2 = Array.prototype.slice.call(browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, 0), a2 = Math.sqrt(r2.length); + return r2.reduce((t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, []); } -const Dt = { - generate(e2, o3, r2) { - const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), s2 = o3 / i2.length, $2 = [ - { x: 0, y: 0 }, - { x: 1, y: 0 }, - { x: 0, y: 1 } - ]; - $2.forEach(({ x: y2, y: u3 }) => { - const O = (i2.length - A) * s2 * y2, b$1 = (i2.length - A) * s2 * u3, E2 = 0.45; - for (let M2 = 0; M2 < $2.length; M2 += 1) { - const V2 = s2 * (A - M2 * 2); - l2.push( - b`` - ); +const Dt = { generate(e2, o3, r2) { + const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), c2 = o3 / i2.length, u3 = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }]; + u3.forEach(({ x: $2, y: f2 }) => { + const O = (i2.length - L2) * c2 * $2, x2 = (i2.length - L2) * c2 * f2, E2 = 0.45; + for (let M2 = 0; M2 < u3.length; M2 += 1) { + const Q = c2 * (L2 - M2 * 2); + l2.push(b$1``); + } + }); + const w2 = Math.floor((r2 + 25) / c2), F = i2.length / 2 - w2 / 2, T2 = i2.length / 2 + w2 / 2 - 1, j = []; + i2.forEach(($2, f2) => { + $2.forEach((O, x2) => { + if (i2[f2][x2] && !(f2 < L2 && x2 < L2 || f2 > i2.length - (L2 + 1) && x2 < L2 || f2 < L2 && x2 > i2.length - (L2 + 1)) && !(f2 > F && f2 < T2 && x2 > F && x2 < T2)) { + const E2 = f2 * c2 + c2 / 2, M2 = x2 * c2 + c2 / 2; + j.push([E2, M2]); } }); - const f2 = Math.floor((r2 + 25) / s2), Ne = i2.length / 2 - f2 / 2, Ze = i2.length / 2 + f2 / 2 - 1, Se = []; - i2.forEach((y2, u3) => { - y2.forEach((O, b2) => { - if (i2[u3][b2] && !(u3 < A && b2 < A || u3 > i2.length - (A + 1) && b2 < A || u3 < A && b2 > i2.length - (A + 1)) && !(u3 > Ne && u3 < Ze && b2 > Ne && b2 < Ze)) { - const E2 = u3 * s2 + s2 / 2, M2 = b2 * s2 + s2 / 2; - Se.push([E2, M2]); - } - }); + }); + const oe2 = {}; + return j.forEach(([$2, f2]) => { + oe2[$2] ? oe2[$2].push(f2) : oe2[$2] = [f2]; + }), Object.entries(oe2).map(([$2, f2]) => { + const O = f2.filter((x2) => f2.every((E2) => !Ie(x2, E2, c2))); + return [Number($2), O]; + }).forEach(([$2, f2]) => { + f2.forEach((O) => { + l2.push(b$1``); }); - const J = {}; - return Se.forEach(([y2, u3]) => { - J[y2] ? J[y2].push(u3) : J[y2] = [u3]; - }), Object.entries(J).map(([y2, u3]) => { - const O = u3.filter((b2) => u3.every((E2) => !Ce(b2, E2, s2))); - return [Number(y2), O]; - }).forEach(([y2, u3]) => { - u3.forEach((O) => { - l2.push( - b`` - ); - }); - }), Object.entries(J).filter(([y2, u3]) => u3.length > 1).map(([y2, u3]) => { - const O = u3.filter((b2) => u3.some((E2) => Ce(b2, E2, s2))); - return [Number(y2), O]; - }).map(([y2, u3]) => { - u3.sort((b2, E2) => b2 < E2 ? -1 : 1); - const O = []; - for (const b2 of u3) { - const E2 = O.find((M2) => M2.some((V2) => Ce(b2, V2, s2))); - E2 ? E2.push(b2) : O.push([b2]); - } - return [y2, O.map((b2) => [b2[0], b2[b2.length - 1]])]; - }).forEach(([y2, u3]) => { - u3.forEach(([O, b$1]) => { - l2.push( - b`` - ); - }); - }), l2; - } -}, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; -var Zt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, q = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? St(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + }), Object.entries(oe2).filter(([$2, f2]) => f2.length > 1).map(([$2, f2]) => { + const O = f2.filter((x2) => f2.some((E2) => Ie(x2, E2, c2))); + return [Number($2), O]; + }).map(([$2, f2]) => { + f2.sort((x2, E2) => x2 < E2 ? -1 : 1); + const O = []; + for (const x2 of f2) { + const E2 = O.find((M2) => M2.some((Q) => Ie(x2, Q, c2))); + E2 ? E2.push(x2) : O.push([x2]); + } + return [$2, O.map((x2) => [x2[0], x2[x2.length - 1]])]; + }).forEach(([$2, f2]) => { + f2.forEach(([O, x2]) => { + l2.push(b$1``); + }); + }), l2; +} }, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; +var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Y = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zt(o3, r2, t2), t2; }; -exports.WcmQrCode = class j extends s { +exports.WcmQrCode = class D extends s$1 { constructor() { super(...arguments), this.uri = "", this.size = 0, this.imageId = void 0, this.walletId = void 0, this.imageUrl = void 0; } svgTemplate() { - const e2 = index.ne.state.themeMode === "light" ? this.size : this.size - 36; - return b`${Dt.generate(this.uri, e2, e2 / 4)}`; + const e2 = index.ne$3.state.themeMode === "light" ? this.size : this.size - 36; + return b$1`${Dt.generate(this.uri, e2, e2 / 4)}`; } render() { - const e2 = { "wcm-dark": index.ne.state.themeMode === "dark" }; - return x`
${this.walletId || this.imageUrl ? x`` : v.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; + const e2 = { "wcm-dark": index.ne$3.state.themeMode === "dark" }; + return x`
${this.walletId || this.imageUrl ? x`` : b.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; } }; -exports.WcmQrCode.styles = [h.globalCss, Nt], q([n$1()], exports.WcmQrCode.prototype, "uri", 2), q([n$1({ type: Number })], exports.WcmQrCode.prototype, "size", 2), q([n$1()], exports.WcmQrCode.prototype, "imageId", 2), q([n$1()], exports.WcmQrCode.prototype, "walletId", 2), q([n$1()], exports.WcmQrCode.prototype, "imageUrl", 2), exports.WcmQrCode = q([e$2("wcm-qrcode")], exports.WcmQrCode); -const Bt = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; -var Ut = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +exports.WcmQrCode.styles = [h.globalCss, Nt], Y([n$1()], exports.WcmQrCode.prototype, "uri", 2), Y([n$1({ type: Number })], exports.WcmQrCode.prototype, "size", 2), Y([n$1()], exports.WcmQrCode.prototype, "imageId", 2), Y([n$1()], exports.WcmQrCode.prototype, "walletId", 2), Y([n$1()], exports.WcmQrCode.prototype, "imageUrl", 2), exports.WcmQrCode = Y([e$2("wcm-qrcode")], exports.WcmQrCode); +const St = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; +var Bt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ut(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ut(o3, r2, t2), t2; + return a2 && t2 && Bt(o3, r2, t2), t2; }; -let ce = class extends s { +let me = class extends s$1 { constructor() { super(...arguments), this.onChange = () => null; } render() { - return x` ${v.SEARCH_ICON}`; + return x` ${b.SEARCH_ICON}`; } }; -ce.styles = [h.globalCss, Bt], Fe([n$1()], ce.prototype, "onChange", 2), ce = Fe([e$2("wcm-search-input")], ce); -const zt = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; -var Vt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, qt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ft(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Vt(o3, r2, t2), t2; +me.styles = [h.globalCss, St], qe([n$1()], me.prototype, "onChange", 2), me = qe([e$2("wcm-search-input")], me); +const Ht = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; +var Ft = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let ke = class extends s { +let We = class extends s$1 { render() { return x``; } }; -ke.styles = [h.globalCss, zt], ke = qt([e$2("wcm-spinner")], ke); +We.styles = [h.globalCss, Ht], We = Ft([e$2("wcm-spinner")], We); const Qt = i$3`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`; -var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a2) => { +var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Ee = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Yt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Kt(o3, r2, t2), t2; }; -let re = class extends s { +let ie = class extends s$1 { constructor() { super(...arguments), this.variant = "medium-regular", this.color = "primary"; } render() { - const e2 = { - "wcm-big-bold": this.variant === "big-bold", - "wcm-medium-regular": this.variant === "medium-regular", - "wcm-small-regular": this.variant === "small-regular", - "wcm-small-thin": this.variant === "small-thin", - "wcm-xsmall-regular": this.variant === "xsmall-regular", - "wcm-xsmall-bold": this.variant === "xsmall-bold", - "wcm-color-primary": this.color === "primary", - "wcm-color-secondary": this.color === "secondary", - "wcm-color-tertiary": this.color === "tertiary", - "wcm-color-inverse": this.color === "inverse", - "wcm-color-accnt": this.color === "accent", - "wcm-color-error": this.color === "error" - }; + const e2 = { "wcm-big-bold": this.variant === "big-bold", "wcm-medium-regular": this.variant === "medium-regular", "wcm-small-regular": this.variant === "small-regular", "wcm-small-thin": this.variant === "small-thin", "wcm-xsmall-regular": this.variant === "xsmall-regular", "wcm-xsmall-bold": this.variant === "xsmall-bold", "wcm-color-primary": this.color === "primary", "wcm-color-secondary": this.color === "secondary", "wcm-color-tertiary": this.color === "tertiary", "wcm-color-inverse": this.color === "inverse", "wcm-color-accnt": this.color === "accent", "wcm-color-error": this.color === "error" }; return x``; } }; -re.styles = [h.globalCss, Qt], Oe([n$1()], re.prototype, "variant", 2), Oe([n$1()], re.prototype, "color", 2), re = Oe([e$2("wcm-text")], re); +ie.styles = [h.globalCss, Qt], Ee([n$1()], ie.prototype, "variant", 2), Ee([n$1()], ie.prototype, "color", 2), ie = Ee([e$2("wcm-text")], ie); const Gt = i$3`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`; -var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, _ = (e2, o3, r2, a2) => { +var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, N2 = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xt(o3, r2, t2), t2; }; -let L2 = class extends s { +let P = class extends s$1 { constructor() { super(...arguments), this.onClick = () => null, this.name = "", this.walletId = "", this.label = void 0, this.imageId = void 0, this.installed = false, this.recent = false; } @@ -3948,79 +3765,76 @@ let L2 = class extends s { return this.recent ? x`RECENT` : this.installed ? x`INSTALLED` : null; } handleClick() { - index.R$4.click({ name: "WALLET_BUTTON", walletId: this.walletId }), this.onClick(); + index.R$1.click({ name: "WALLET_BUTTON", walletId: this.walletId }), this.onClick(); } render() { var e2; - return x``; + return x``; } }; -L2.styles = [h.globalCss, Gt], _([n$1()], L2.prototype, "onClick", 2), _([n$1()], L2.prototype, "name", 2), _([n$1()], L2.prototype, "walletId", 2), _([n$1()], L2.prototype, "label", 2), _([n$1()], L2.prototype, "imageId", 2), _([n$1({ type: Boolean })], L2.prototype, "installed", 2), _([n$1({ type: Boolean })], L2.prototype, "recent", 2), L2 = _([e$2("wcm-wallet-button")], L2); +P.styles = [h.globalCss, Gt], N2([n$1()], P.prototype, "onClick", 2), N2([n$1()], P.prototype, "name", 2), N2([n$1()], P.prototype, "walletId", 2), N2([n$1()], P.prototype, "label", 2), N2([n$1()], P.prototype, "imageId", 2), N2([n$1({ type: Boolean })], P.prototype, "installed", 2), N2([n$1({ type: Boolean })], P.prototype, "recent", 2), P = N2([e$2("wcm-wallet-button")], P); const eo = i$3`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a2) => { +var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, we = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? oo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && to(o3, r2, t2), t2; }; -let Q = class extends s { +let G = class extends s$1 { constructor() { super(...arguments), this.walletId = "", this.imageId = void 0, this.imageUrl = void 0; } render() { var e2; - const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : c.getWalletIcon({ id: this.walletId, image_id: this.imageId }); - return x`${o3.length ? x`
${this.id}
` : v.WALLET_PLACEHOLDER}`; + const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : s2.getWalletIcon({ id: this.walletId, image_id: this.imageId }); + return x`${o3.length ? x`
${this.id}
` : b.WALLET_PLACEHOLDER}`; } }; -Q.styles = [h.globalCss, eo], se([n$1()], Q.prototype, "walletId", 2), se([n$1()], Q.prototype, "imageId", 2), se([n$1()], Q.prototype, "imageUrl", 2), Q = se([e$2("wcm-wallet-image")], Q); -var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a2) => { +G.styles = [h.globalCss, eo], we([n$1()], G.prototype, "walletId", 2), we([n$1()], G.prototype, "imageId", 2), we([n$1()], G.prototype, "imageUrl", 2), G = we([e$2("wcm-wallet-image")], G); +var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && ro(o3, r2, t2), t2; }; -let We = class extends s { +let Me = class extends s$1 { constructor() { super(), this.preload = true, this.preloadData(); } async loadImages(e2) { try { - e2 != null && e2.length && await Promise.all(e2.map(async (o3) => c.preloadImage(o3))); + e2 != null && e2.length && await Promise.all(e2.map(async (o3) => s2.preloadImage(o3))); } catch { console.info("Unsuccessful attempt at preloading some images", e2); } } async preloadListings() { - if (index.y$3.state.enableExplorer) { - await index.te$2.getRecomendedWallets(), index.p$3.setIsDataLoaded(true); - const { recomendedWallets: e2 } = index.te$2.state, o3 = e2.map((r2) => c.getWalletIcon(r2)); + if (index.y$4.state.enableExplorer) { + await index.te$1.getRecomendedWallets(), index.p$2.setIsDataLoaded(true); + const { recomendedWallets: e2 } = index.te$1.state, o3 = e2.map((r2) => s2.getWalletIcon(r2)); await this.loadImages(o3); } else - index.p$3.setIsDataLoaded(true); + index.p$2.setIsDataLoaded(true); } async preloadCustomImages() { - const e2 = c.getCustomImageUrls(); + const e2 = s2.getCustomImageUrls(); await this.loadImages(e2); } async preloadData() { try { - this.preload && (this.preload = false, await Promise.all([ - this.preloadListings(), - this.preloadCustomImages() - ])); + this.preload && (this.preload = false, await Promise.all([this.preloadListings(), this.preloadCustomImages()])); } catch (e2) { - console.error(e2), index.oe$1.openToast("Failed preloading", "error"); + console.error(e2), index.oe$2.openToast("Failed preloading", "error"); } } }; -qe([t$1()], We.prototype, "preload", 2), We = qe([e$2("wcm-explorer-context")], We); -var lo = Object.defineProperty, io = Object.getOwnPropertyDescriptor, no = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? io(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && lo(o3, r2, t2), t2; +Fe([t$1()], Me.prototype, "preload", 2), Me = Fe([e$2("wcm-explorer-context")], Me); +var no = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Qe = class extends s { +let Qe = class extends s$1 { constructor() { - super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = index.ne.subscribe(h.setTheme); + super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = index.ne$3.subscribe(h.setTheme); } disconnectedCallback() { var e2; @@ -4029,42 +3843,40 @@ let Qe = class extends s { }; Qe = no([e$2("wcm-theme-context")], Qe); const co = i$3`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var so = Object.defineProperty, mo = Object.getOwnPropertyDescriptor, ho = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? mo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && so(o3, r2, t2), t2; +var wo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ie = class extends s { +let Pe = class extends s$1 { onConnect(e2) { - index.a$3.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + index.i$1.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onGoToQrcode() { - index.T$1.push("Qrcode"); + index.T$2.push("Qrcode"); } render() { - const { recomendedWallets: e2 } = index.te$2.state, o3 = [...e2, ...e2], r2 = index.a$3.RECOMMENDED_WALLET_AMOUNT * 2; - return x`
${v.MOBILE_ICON}WalletConnect
${[ - ...Array(r2) - ].map((a2, t2) => { + const { recomendedWallets: e2 } = index.te$1.state, o3 = [...e2, ...e2], r2 = index.i$1.RECOMMENDED_WALLET_AMOUNT * 2; + return x`
${b.MOBILE_ICON}WalletConnect
${[...Array(r2)].map((a2, t2) => { const l2 = o3[t2 % o3.length]; - return l2 ? x`` : v.WALLET_PLACEHOLDER; + return l2 ? x`` : b.WALLET_PLACEHOLDER; })}
Select Wallet
Choose WalletConnect to see supported apps on your device`; } }; -Ie.styles = [h.globalCss, co], Ie = ho([e$2("wcm-android-wallet-selection")], Ie); -const wo = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; -var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a2) => { +Pe.styles = [h.globalCss, co], Pe = wo([e$2("wcm-android-wallet-selection")], Pe); +const ho = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; +var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, X = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? go(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && po(o3, r2, t2), t2; }; -let D = class extends s { +let Z2 = class extends s$1 { constructor() { super(...arguments), this.walletId = void 0, this.imageId = void 0, this.isError = false, this.isStale = false, this.label = ""; } svgLoaderTemplate() { var e2, o3; - const r2 = (o3 = (e2 = index.ne.state.themeVariables) == null ? void 0 : e2["--wcm-wallet-icon-large-border-radius"]) != null ? o3 : h.getPreset("--wcm-wallet-icon-large-border-radius"); + const r2 = (o3 = (e2 = index.ne$3.state.themeVariables) == null ? void 0 : e2["--wcm-wallet-icon-large-border-radius"]) != null ? o3 : h.getPreset("--wcm-wallet-icon-large-border-radius"); let a2 = 0; r2.includes("%") ? a2 = 88 / 100 * parseInt(r2, 10) : a2 = parseInt(r2, 10), a2 *= 1.17; const t2 = 317 - a2 * 1.57, l2 = 425 - a2 * 1.8; @@ -4075,113 +3887,90 @@ let D = class extends s { return x`
${this.svgLoaderTemplate()}
${this.isError ? "Connection declined" : this.label}`; } }; -D.styles = [h.globalCss, wo], K([n$1()], D.prototype, "walletId", 2), K([n$1()], D.prototype, "imageId", 2), K([n$1({ type: Boolean })], D.prototype, "isError", 2), K([n$1({ type: Boolean })], D.prototype, "isStale", 2), K([n$1()], D.prototype, "label", 2), D = K([e$2("wcm-connector-waiting")], D); -const G = { - manualWallets() { - var e2, o3; - const { mobileWallets: r2, desktopWallets: a2 } = index.y$3.state, t2 = (e2 = G.recentWallet()) == null ? void 0 : e2.id, l2 = index.a$3.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((s2) => t2 !== s2.id); - return (o3 = index.a$3.isMobile() ? i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - mobile: f2, - links: f2 - })) : i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - desktop: f2, - links: f2 - }))) != null ? o3 : []; - }, - recentWallet() { - return c.getRecentWallet(); - }, - recomendedWallets(e2 = false) { - var o3; - const r2 = e2 || (o3 = G.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a2 } = index.te$2.state; - return a2.filter((t2) => r2 !== t2.id); - } -}, Z2 = { - onConnecting(e2) { - c.goToConnectingView(e2); - }, - manualWalletsTemplate() { - return G.manualWallets().map( - (e2) => x`` - ); - }, - recomendedWalletsTemplate(e2 = false) { - return G.recomendedWallets(e2).map( - (o3) => x`` - ); - }, - recentWalletTemplate() { - const e2 = G.recentWallet(); - if (e2) - return x``; - } -}, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; -var uo = Object.defineProperty, bo = Object.getOwnPropertyDescriptor, fo = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? bo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && uo(o3, r2, t2), t2; +Z2.styles = [h.globalCss, ho], X([n$1()], Z2.prototype, "walletId", 2), X([n$1()], Z2.prototype, "imageId", 2), X([n$1({ type: Boolean })], Z2.prototype, "isError", 2), X([n$1({ type: Boolean })], Z2.prototype, "isStale", 2), X([n$1()], Z2.prototype, "label", 2), Z2 = X([e$2("wcm-connector-waiting")], Z2); +const ee = { manualWallets() { + var e2, o3; + const { mobileWallets: r2, desktopWallets: a2 } = index.y$4.state, t2 = (e2 = ee.recentWallet()) == null ? void 0 : e2.id, l2 = index.i$1.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((c2) => t2 !== c2.id); + return (o3 = index.i$1.isMobile() ? i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w2 }) => ({ id: c2, name: u3, mobile: w2, links: w2 })) : i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w2 }) => ({ id: c2, name: u3, desktop: w2, links: w2 }))) != null ? o3 : []; +}, recentWallet() { + return s2.getRecentWallet(); +}, recomendedWallets(e2 = false) { + var o3; + const r2 = e2 || (o3 = ee.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a2 } = index.te$1.state; + return a2.filter((t2) => r2 !== t2.id); +} }, S = { onConnecting(e2) { + s2.goToConnectingView(e2); +}, manualWalletsTemplate() { + return ee.manualWallets().map((e2) => x``); +}, recomendedWalletsTemplate(e2 = false) { + return ee.recomendedWallets(e2).map((o3) => x``); +}, recentWalletTemplate() { + const e2 = ee.recentWallet(); + if (e2) + return x``; +} }, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; +var fo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ee = class extends s { +let Le = class extends s$1 { render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = index.y$3.state, r2 = e2 !== "ALL" && o3, a2 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = index.y$4.state, r2 = e2 !== "ALL" && o3, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 4 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 3) : s2 = l2; - const $2 = Boolean(s2.length); - return x`
${v.MOBILE_ICON}Mobile
${v.SCAN_ICON}Scan with your wallet
${$2 ? x`
${v.DESKTOP_ICON}Desktop
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 3) : c2 = l2; + const u3 = Boolean(c2.length); + return x`
${b.MOBILE_ICON}Mobile
${b.SCAN_ICON}Scan with your wallet
${u3 ? x`
${b.DESKTOP_ICON}Desktop
${c2} ${i2 ? x`` : null}
` : null}`; } }; -Ee.styles = [h.globalCss, vo], Ee = fo([e$2("wcm-desktop-wallet-selection")], Ee); +Le.styles = [h.globalCss, vo], Le = fo([e$2("wcm-desktop-wallet-selection")], Le); const xo = i$3`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`; -var yo = Object.defineProperty, $o = Object.getOwnPropertyDescriptor, Co = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? $o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && yo(o3, r2, t2), t2; +var Co = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Me = class extends s { +let Re = class extends s$1 { render() { - const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = index.y$3.state; + const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = index.y$4.state; return e2 ?? o3 ? x`
By connecting your wallet to this app, you agree to the app's ${e2 ? x`Terms of Service` : null} ${e2 && o3 ? "and" : null} ${o3 ? x`Privacy Policy` : null}
` : null; } }; -Me.styles = [h.globalCss, xo], Me = Co([e$2("wcm-legal-notice")], Me); +Re.styles = [h.globalCss, xo], Re = Co([e$2("wcm-legal-notice")], Re); const ko = i$3`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`; -var Oo = Object.defineProperty, Wo = Object.getOwnPropertyDescriptor, Io = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Wo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Oo(o3, r2, t2), t2; +var Wo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Le = class extends s { +let Ae = class extends s$1 { onQrcode() { - index.T$1.push("Qrcode"); + index.T$2.push("Qrcode"); } render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = index.y$3.state, r2 = e2 !== "ALL" && o3, a2 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = index.y$4.state, r2 = e2 !== "ALL" && o3, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 8 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 7) : s2 = l2; - const $2 = Boolean(s2.length); - return x`${$2 ? x`
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 7) : c2 = l2; + const u3 = Boolean(c2.length); + return x`${u3 ? x`
${c2} ${i2 ? x`` : null}
` : null}`; } }; -Le.styles = [h.globalCss, ko], Le = Io([e$2("wcm-mobile-wallet-selection")], Le); +Ae.styles = [h.globalCss, ko], Ae = Wo([e$2("wcm-mobile-wallet-selection")], Ae); const Eo = i$3`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`; -var Mo = Object.defineProperty, Lo = Object.getOwnPropertyDescriptor, Re = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Lo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var Mo = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, Te = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Mo(o3, r2, t2), t2; }; -exports.WcmModal = class ae extends s { +exports.WcmModal = class ne extends s$1 { constructor() { - super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = index.se.subscribe((e2) => { + super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = index.se$3.subscribe((e2) => { e2.open ? this.onOpenModalEvent() : this.onCloseModalEvent(); }); } @@ -4190,10 +3979,10 @@ exports.WcmModal = class ae extends s { (e2 = this.unsubscribeModal) == null || e2.call(this); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-overlay"); + return s2.getShadowRootElement(this, ".wcm-overlay"); } get containerEl() { - return c.getShadowRootElement(this, ".wcm-container"); + return s2.getShadowRootElement(this, ".wcm-container"); } toggleBodyScroll(e2) { if (document.querySelector("body")) @@ -4201,40 +3990,27 @@ exports.WcmModal = class ae extends s { const o3 = document.getElementById("wcm-styles"); o3 == null ? void 0 : o3.remove(); } else - document.head.insertAdjacentHTML( - "beforeend", - '' - ); + document.head.insertAdjacentHTML("beforeend", ''); } onCloseModal(e2) { - e2.target === e2.currentTarget && index.se.close(); + e2.target === e2.currentTarget && index.se$3.close(); } onOpenModalEvent() { this.toggleBodyScroll(false), this.addKeyboardEvents(), this.open = true, setTimeout(async () => { - const e2 = c.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, - animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished - ]), this.active = true; + const e2 = s2.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished]), this.active = true; }, 0); } async onCloseModalEvent() { this.toggleBodyScroll(true), this.removeKeyboardEvents(); - const e2 = c.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, - animate(this.containerEl, e2, { duration: o3 }).finished - ]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; + const e2 = s2.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, animate(this.containerEl, e2, { duration: o3 }).finished]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; } addKeyboardEvents() { - this.abortController = new AbortController(), window.addEventListener( - "keydown", - (e2) => { - var o3; - e2.key === "Escape" ? index.se.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); - }, - this.abortController - ), this.containerEl.focus(); + this.abortController = new AbortController(), window.addEventListener("keydown", (e2) => { + var o3; + e2.key === "Escape" ? index.se$3.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); + }, this.abortController), this.containerEl.focus(); } removeKeyboardEvents() { var e2; @@ -4245,212 +4021,213 @@ exports.WcmModal = class ae extends s { return x`
${this.open ? x`
` : null}
`; } }; -exports.WcmModal.styles = [h.globalCss, Eo], Re([t$1()], exports.WcmModal.prototype, "open", 2), Re([t$1()], exports.WcmModal.prototype, "active", 2), exports.WcmModal = Re([e$2("wcm-modal")], exports.WcmModal); -const Ro = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; -var Ao = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, le = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +exports.WcmModal.styles = [h.globalCss, Eo], Te([t$1()], exports.WcmModal.prototype, "open", 2), Te([t$1()], exports.WcmModal.prototype, "active", 2), exports.WcmModal = Te([e$2("wcm-modal")], exports.WcmModal); +const Lo = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; +var Ro = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, ce = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ao(o3, r2, t2), t2; + return a2 && t2 && Ro(o3, r2, t2), t2; }; -let B = class extends s { +let U = class extends s$1 { constructor() { super(...arguments), this.isMobile = false, this.isDesktop = false, this.isWeb = false, this.isRetry = false; } onMobile() { - index.a$3.isMobile() ? index.T$1.replace("MobileConnecting") : index.T$1.replace("MobileQrcodeConnecting"); + index.i$1.isMobile() ? index.T$2.replace("MobileConnecting") : index.T$2.replace("MobileQrcodeConnecting"); } onDesktop() { - index.T$1.replace("DesktopConnecting"); + index.T$2.replace("DesktopConnecting"); } onWeb() { - index.T$1.replace("WebConnecting"); + index.T$2.replace("WebConnecting"); } render() { - return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; + return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; } }; -B.styles = [h.globalCss, Ro], le([n$1({ type: Boolean })], B.prototype, "isMobile", 2), le([n$1({ type: Boolean })], B.prototype, "isDesktop", 2), le([n$1({ type: Boolean })], B.prototype, "isWeb", 2), le([n$1({ type: Boolean })], B.prototype, "isRetry", 2), B = le([e$2("wcm-platform-selection")], B); +U.styles = [h.globalCss, Lo], ce([n$1({ type: Boolean })], U.prototype, "isMobile", 2), ce([n$1({ type: Boolean })], U.prototype, "isDesktop", 2), ce([n$1({ type: Boolean })], U.prototype, "isWeb", 2), ce([n$1({ type: Boolean })], U.prototype, "isRetry", 2), U = ce([e$2("wcm-platform-selection")], U); const To = i$3`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var jo = Object.defineProperty, _o = Object.getOwnPropertyDescriptor, Do = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? _o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && jo(o3, r2, t2), t2; +var Do = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ae = class extends s { +let je = class extends s$1 { onClick() { - index.T$1.push("WalletExplorer"); + index.T$2.push("WalletExplorer"); } render() { - const { recomendedWallets: e2 } = index.te$2.state, o3 = G.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); - return x``; + const { recomendedWallets: e2 } = index.te$1.state, o3 = ee.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); + return x``; } }; -Ae.styles = [h.globalCss, To], Ae = Do([e$2("wcm-view-all-wallets-button")], Ae); +je.styles = [h.globalCss, To], je = Do([e$2("wcm-view-all-wallets-button")], je); const No = i$3`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`; -var Zo = Object.defineProperty, So = Object.getOwnPropertyDescriptor, de = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? So(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var Zo = Object.defineProperty, zo = Object.getOwnPropertyDescriptor, he = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zo(o3, r2, t2), t2; }; -let Y = class extends s { +let J = class extends s$1 { constructor() { super(), this.walletId = "", this.imageId = "", this.uri = "", setTimeout(() => { - const { walletConnectUri: e2 } = index.p$3.state; + const { walletConnectUri: e2 } = index.p$2.state; this.uri = e2; }, 0); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-qr-container"); + return s2.getShadowRootElement(this, ".wcm-qr-container"); } render() { return x`
${this.uri ? x`` : x``}
`; } }; -Y.styles = [h.globalCss, No], de([n$1()], Y.prototype, "walletId", 2), de([n$1()], Y.prototype, "imageId", 2), de([t$1()], Y.prototype, "uri", 2), Y = de([e$2("wcm-walletconnect-qr")], Y); -var Bo = Object.defineProperty, Uo = Object.getOwnPropertyDescriptor, Ho = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Uo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Bo(o3, r2, t2), t2; +J.styles = [h.globalCss, No], he([n$1()], J.prototype, "walletId", 2), he([n$1()], J.prototype, "imageId", 2), he([t$1()], J.prototype, "uri", 2), J = he([e$2("wcm-walletconnect-qr")], J); +var Uo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Pe = class extends s { +let _e = class extends s$1 { viewTemplate() { - return index.a$3.isAndroid() ? x`` : index.a$3.isMobile() ? x`` : x``; + return index.i$1.isAndroid() ? x`` : index.i$1.isMobile() ? x`` : x``; } render() { return x`${this.viewTemplate()}`; } }; -Pe.styles = [h.globalCss], Pe = Ho([e$2("wcm-connect-wallet-view")], Pe); -const zo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var Vo = Object.defineProperty, Fo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Fo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +_e.styles = [h.globalCss], _e = Uo([e$2("wcm-connect-wallet-view")], _e); +const Ho = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; +var Vo = Object.defineProperty, qo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? qo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Vo(o3, r2, t2), t2; }; -let me = class extends s { +let pe = class extends s$1 { constructor() { super(), this.isError = false, this.openDesktopApp(); } onFormatAndRedirect(e2) { - const { desktop: o3, name: r2 } = index.a$3.getWalletRouterData(), a2 = o3 == null ? void 0 : o3.native; - if (a2) { - const t2 = index.a$3.formatNativeUrl(a2, e2, r2); - index.a$3.openHref(t2, "_self"); + var o3; + const { desktop: r2, name: a2 } = index.i$1.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native; + if (t2) { + const l2 = index.i$1.formatNativeUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + index.i$1.openHref(l2, "_self"); } } openDesktopApp() { - const { walletConnectUri: e2 } = index.p$3.state, o3 = index.a$3.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = index.p$2.state, o3 = index.i$1.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = index.a$3.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; + const { name: e2, id: o3, image_id: r2 } = index.i$1.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; } }; -me.styles = [h.globalCss, zo], Ke([t$1()], me.prototype, "isError", 2), me = Ke([e$2("wcm-desktop-connecting-view")], me); -const qo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; -var Qo = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, Yo = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ko(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Qo(o3, r2, t2), t2; +pe.styles = [h.globalCss, Ho], Ke([t$1()], pe.prototype, "isError", 2), pe = Ke([e$2("wcm-desktop-connecting-view")], pe); +const Fo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; +var Yo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Te = class extends s { +let De = class extends s$1 { onInstall(e2) { - e2 && index.a$3.openHref(e2, "_blank"); + e2 && index.i$1.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - homepage: a2 - } = index.a$3.getWalletRouterData(); - return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; + const { name: e2, id: o3, image_id: r2, homepage: a2 } = index.i$1.getWalletRouterData(); + return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; } }; -Te.styles = [h.globalCss, qo], Te = Yo([e$2("wcm-install-wallet-view")], Te); +De.styles = [h.globalCss, Fo], De = Yo([e$2("wcm-install-wallet-view")], De); const Go = i$3`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`; var Xo = Object.defineProperty, Jo = Object.getOwnPropertyDescriptor, Ye = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xo(o3, r2, t2), t2; }; -let he = class extends s { +let ge = class extends s$1 { constructor() { super(), this.isError = false, this.openMobileApp(); } onFormatAndRedirect(e2, o3 = false) { - const { mobile: r2, name: a2 } = index.a$3.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - if (t2 && !o3) { - const i2 = index.a$3.formatNativeUrl(t2, e2, a2); - index.a$3.openHref(i2, "_self"); - } else if (l2) { - const i2 = index.a$3.formatUniversalUrl(l2, e2, a2); - index.a$3.openHref(i2, "_self"); + var r2, a2; + const { mobile: t2, name: l2 } = index.i$1.getWalletRouterData(), i2 = t2 == null ? void 0 : t2.native, c2 = t2 == null ? void 0 : t2.universal; + if (i2 && !o3) { + const u3 = index.i$1.formatNativeUrl(i2, e2, l2); + if (l2 === "Puzzle Wallet" && (r2 = window == null ? void 0 : window.aleo) != null && r2.connectPuzzle) { + const w2 = new URL(u3).searchParams, F = w2.get("uri"), T2 = w2.get("requestId"), j = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F, requestId: T2 ?? void 0, sessionTopic: j ?? void 0 } }); + } else + index.i$1.openHref(u3, "_self"); + } else if (c2) { + const u3 = index.i$1.formatUniversalUrl(c2, e2, l2); + if (l2 === "Puzzle Wallet" && (a2 = window == null ? void 0 : window.aleo) != null && a2.connectPuzzle) { + const w2 = new URL(u3).searchParams, F = w2.get("uri"), T2 = w2.get("requestId"), j = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F, requestId: T2 ?? void 0, sessionTopic: j ?? void 0 } }); + } else + index.i$1.openHref(u3, "_self"); } } openMobileApp(e2 = false) { - const { walletConnectUri: o3 } = index.p$3.state, r2 = index.a$3.getWalletRouterData(); - c.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); + const { walletConnectUri: o3 } = index.p$2.state, r2 = index.i$1.getWalletRouterData(); + s2.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); } onGoToAppStore(e2) { - e2 && index.a$3.openHref(e2, "_blank"); + e2 && index.i$1.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - app: a2, - mobile: t2 - } = index.a$3.getWalletRouterData(), { isWeb: l$12 } = c.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, s2 = t2 == null ? void 0 : t2.universal; - return x`Retry${s2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; + const { name: e2, id: o3, image_id: r2, app: a2, mobile: t2 } = index.i$1.getWalletRouterData(), { isWeb: l$12 } = s2.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, c2 = t2 == null ? void 0 : t2.universal; + return x`Retry${c2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; } }; -he.styles = [h.globalCss, Go], Ye([t$1()], he.prototype, "isError", 2), he = Ye([e$2("wcm-mobile-connecting-view")], he); +ge.styles = [h.globalCss, Go], Ye([t$1()], ge.prototype, "isError", 2), ge = Ye([e$2("wcm-mobile-connecting-view")], ge); const er = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var tr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, rr = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? or(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && tr(o3, r2, t2), t2; +var rr = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let je = class extends s { +let Ne = class extends s$1 { render() { - const { name: e2, id: o3, image_id: r2 } = index.a$3.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; + const { name: e2, id: o3, image_id: r2 } = index.i$1.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; } }; -je.styles = [h.globalCss, er], je = rr([e$2("wcm-mobile-qr-connecting-view")], je); -var ar = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, ir = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? lr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ar(o3, r2, t2), t2; +Ne.styles = [h.globalCss, er], Ne = rr([e$2("wcm-mobile-qr-connecting-view")], Ne); +var ir = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let _e = class extends s { +let Ze = class extends s$1 { render() { - return x``; + return x``; } }; -_e.styles = [h.globalCss], _e = ir([e$2("wcm-qrcode-view")], _e); +Ze.styles = [h.globalCss], Ze = ir([e$2("wcm-qrcode-view")], Ze); const nr = i$3`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`; -var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, ie = (e2, o3, r2, a2) => { +var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? sr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && cr(o3, r2, t2), t2; }; -const De = 40; -let U = class extends s { +const ze = 40; +let H2 = class extends s$1 { constructor() { - super(...arguments), this.loading = !index.te$2.state.wallets.listings.length, this.firstFetch = !index.te$2.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = c.debounce((e2) => { - e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, index.te$2.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), index.te$2.resetSearch()); + super(...arguments), this.loading = !index.te$1.state.wallets.listings.length, this.firstFetch = !index.te$1.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = s2.debounce((e2) => { + e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, index.te$1.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), index.te$1.resetSearch()); }); } firstUpdated() { @@ -4461,7 +4238,7 @@ let U = class extends s { (e2 = this.intersectionObserver) == null || e2.disconnect(); } get placeholderEl() { - return c.getShadowRootElement(this, ".wcm-placeholder-block"); + return s2.getShadowRootElement(this, ".wcm-placeholder-block"); } createPaginationObserver() { this.intersectionObserver = new IntersectionObserver(([e2]) => { @@ -4469,92 +4246,68 @@ let U = class extends s { }), this.intersectionObserver.observe(this.placeholderEl); } isLastPage() { - const { wallets: e2, search: o3 } = index.te$2.state, { listings: r2, total: a2 } = this.search ? o3 : e2; - return a2 <= De || r2.length >= a2; + const { wallets: e2, search: o3 } = index.te$1.state, { listings: r2, total: a2 } = this.search ? o3 : e2; + return a2 <= ze || r2.length >= a2; } async fetchWallets() { var e2; - const { wallets: o3, search: r2 } = index.te$2.state, { listings: a2, total: t2, page: l2 } = this.search ? r2 : o3; - if (!this.endReached && (this.firstFetch || t2 > De && a2.length < t2)) + const { wallets: o3, search: r2 } = index.te$1.state, { listings: a2, total: t2, page: l2 } = this.search ? r2 : o3; + if (!this.endReached && (this.firstFetch || t2 > ze && a2.length < t2)) try { this.loading = true; - const i2 = (e2 = index.p$3.state.chains) == null ? void 0 : e2.join(","), { listings: s2 } = await index.te$2.getWallets({ - page: this.firstFetch ? 1 : l2 + 1, - entries: De, - search: this.search, - version: 2, - chains: i2 - }), $2 = s2.map((f2) => c.getWalletIcon(f2)); - await Promise.all([ - ...$2.map(async (f2) => c.preloadImage(f2)), - index.a$3.wait(300) - ]), this.endReached = this.isLastPage(); + const i2 = (e2 = index.p$2.state.chains) == null ? void 0 : e2.join(","), { listings: c2 } = await index.te$1.getWallets({ page: this.firstFetch ? 1 : l2 + 1, entries: ze, search: this.search, version: 2, chains: i2 }), u3 = c2.map((w2) => s2.getWalletIcon(w2)); + await Promise.all([...u3.map(async (w2) => s2.preloadImage(w2)), index.i$1.wait(300)]), this.endReached = this.isLastPage(); } catch (i2) { - console.error(i2), index.oe$1.openToast(c.getErrorMessage(i2), "error"); + console.error(i2), index.oe$2.openToast(s2.getErrorMessage(i2), "error"); } finally { this.loading = false, this.firstFetch = false; } } onConnect(e2) { - index.a$3.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + index.i$1.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onSearchChange(e2) { const { value: o3 } = e2.target; this.searchDebounce(o3); } render() { - const { wallets: e2, search: o$12 } = index.te$2.state, { listings: r2 } = this.search ? o$12 : e2, a2 = this.loading && !r2.length, t2 = this.search.length >= 3; - let l2 = Z2.manualWalletsTemplate(), i2 = Z2.recomendedWalletsTemplate(true); - t2 && (l2 = l2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search)), i2 = i2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search))); - const s2 = !this.loading && !r2.length && !i2.length, $2 = { - "wcm-loading": a2, - "wcm-end-reached": this.endReached || !this.loading, - "wcm-empty": s2 - }; - return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((f2) => x`${f2 ? x`` : null}`)}
${s2 ? x`No results found` : null} ${!s2 && this.loading ? x`` : null}
`; + const { wallets: e2, search: o$12 } = index.te$1.state, { listings: r2 } = this.search ? o$12 : e2, a2 = this.loading && !r2.length, t2 = this.search.length >= 3; + let l2 = S.manualWalletsTemplate(), i2 = S.recomendedWalletsTemplate(true); + t2 && (l2 = l2.filter(({ values: w2 }) => s2.caseSafeIncludes(w2[0], this.search)), i2 = i2.filter(({ values: w2 }) => s2.caseSafeIncludes(w2[0], this.search))); + const c2 = !this.loading && !r2.length && !i2.length, u3 = { "wcm-loading": a2, "wcm-end-reached": this.endReached || !this.loading, "wcm-empty": c2 }; + return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((w2) => x`${w2 ? x`` : null}`)}
${c2 ? x`No results found` : null} ${!c2 && this.loading ? x`` : null}
`; } }; -U.styles = [h.globalCss, nr], ie([t$1()], U.prototype, "loading", 2), ie([t$1()], U.prototype, "firstFetch", 2), ie([t$1()], U.prototype, "search", 2), ie([t$1()], U.prototype, "endReached", 2), U = ie([e$2("wcm-wallet-explorer-view")], U); +H2.styles = [h.globalCss, nr], se([t$1()], H2.prototype, "loading", 2), se([t$1()], H2.prototype, "firstFetch", 2), se([t$1()], H2.prototype, "search", 2), se([t$1()], H2.prototype, "endReached", 2), H2 = se([e$2("wcm-wallet-explorer-view")], H2); const dr = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var mr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? hr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var mr = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? wr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && mr(o3, r2, t2), t2; }; -let we = class extends s { +let ve = class extends s$1 { constructor() { super(), this.isError = false, this.openWebWallet(); } onFormatAndRedirect(e2) { - var _a; - const { desktop: o3, name: r2 } = index.a$3.getWalletRouterData(), a2 = o3 == null ? void 0 : o3.universal; - if (a2) { - const t2 = index.a$3.formatUniversalUrl(a2, e2, r2); - if (r2 === "Puzzle Wallet" && window && ((_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient)) { - const url = new URL(t2); - const params = url.searchParams; - const wcUri = params.get("uri"); - const requestId = params.get("requestId"); - const sessionTopic = params.get("sessionTopic"); - void window.aleo.connectPuzzle({ - wc: { - uri: wcUri, - requestId: requestId ?? void 0, - sessionTopic: sessionTopic ?? void 0 - } - }); - } else { - index.a$3.openHref(t2, "_blank"); - } + var o3; + const { desktop: r2, name: a2 } = index.i$1.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.universal; + if (t2) { + const l2 = index.i$1.formatUniversalUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + index.i$1.openHref(l2, "_blank"); } } openWebWallet() { - const { walletConnectUri: e2 } = index.p$3.state, o3 = index.a$3.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = index.p$2.state, o3 = index.i$1.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = index.a$3.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = c.getCachedRouterWalletPlatforms(), l$12 = index.a$3.isMobile(); - return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; + const { name: e2, id: o3, image_id: r2 } = index.i$1.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = s2.getCachedRouterWalletPlatforms(), l$12 = index.i$1.isMobile(); + return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; } }; -we.styles = [h.globalCss, dr], Ge([t$1()], we.prototype, "isError", 2), we = Ge([e$2("wcm-web-connecting-view")], we); +ve.styles = [h.globalCss, dr], Ge([t$1()], ve.prototype, "isError", 2), ve = Ge([e$2("wcm-web-connecting-view")], ve); diff --git a/packages/core/dist/index-B2etef5O.js b/packages/react/dist/index-f3LbIFb5-DhnEJzKF.js similarity index 64% rename from packages/core/dist/index-B2etef5O.js rename to packages/react/dist/index-f3LbIFb5-DhnEJzKF.js index cc7e0956..f154673b 100644 --- a/packages/core/dist/index-B2etef5O.js +++ b/packages/react/dist/index-f3LbIFb5-DhnEJzKF.js @@ -1,22 +1,22 @@ -import { n as ne$1, s as se$1, T as T$2, o as oe$1, R as R$1, a as a$2, t as te$1, p as p$1, y as y$1 } from "./index-0kpjH3lP.js"; +import { n as ne$3, s as se$3, T as T$2, o as oe$2, R as R$1, i as i$1$1, t as te$1, p as p$2, y as y$4 } from "./index-j7s7E1c2.js"; /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$3 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); +const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$4 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); let o$4 = class o { constructor(t2, e2, n2) { - if (this._$cssResult$ = true, n2 !== s$3) + if (this._$cssResult$ = true, n2 !== s$4) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t2, this.t = e2; } get styleSheet() { let t2 = this.o; - const s2 = this.t; + const s3 = this.t; if (e$5 && void 0 === t2) { - const e2 = void 0 !== s2 && 1 === s2.length; - e2 && (t2 = n$5.get(s2)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s2, t2)); + const e2 = void 0 !== s3 && 1 === s3.length; + e2 && (t2 = n$5.get(s3)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s3, t2)); } return t2; } @@ -24,24 +24,24 @@ let o$4 = class o { return this.cssText; } }; -const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), i$3 = (t2, ...e2) => { - const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s2, n3) => e3 + ((t3) => { +const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$4), i$3 = (t2, ...e2) => { + const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s3, n3) => e3 + ((t3) => { if (true === t3._$cssResult$) return t3.cssText; if ("number" == typeof t3) return t3; throw Error("Value passed to 'css' function must be a 'css' function result: " + t3 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); - })(s2) + t2[n3 + 1], t2[0]); - return new o$4(n2, t2, s$3); -}, S$2 = (s2, n2) => { - e$5 ? s2.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { + })(s3) + t2[n3 + 1], t2[0]); + return new o$4(n2, t2, s$4); +}, S$2 = (s3, n2) => { + e$5 ? s3.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { const n3 = document.createElement("style"), o3 = t$3.litNonce; - void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s2.appendChild(n3); + void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s3.appendChild(n3); }); -}, c$2 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { +}, c$1 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { let e2 = ""; - for (const s2 of t3.cssRules) - e2 += s2.cssText; + for (const s3 of t3.cssRules) + e2 += s3.cssText; return r$2(e2); })(t2) : t2; /** @@ -49,7 +49,7 @@ const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -var s$2; +var s$3; const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$3 = e$4.reactiveElementPolyfillSupport, n$4 = { toAttribute(t2, i2) { switch (i2) { case Boolean: @@ -61,23 +61,23 @@ const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$ } return t2; }, fromAttribute(t2, i2) { - let s2 = t2; + let s3 = t2; switch (i2) { case Boolean: - s2 = null !== t2; + s3 = null !== t2; break; case Number: - s2 = null === t2 ? null : Number(t2); + s3 = null === t2 ? null : Number(t2); break; case Object: case Array: try { - s2 = JSON.parse(t2); + s3 = JSON.parse(t2); } catch (t3) { - s2 = null; + s3 = null; } } - return s2; + return s3; } }, a$1 = (t2, i2) => i2 !== t2 && (i2 == i2 || t2 == t2), l$3 = { attribute: true, type: String, converter: n$4, reflect: false, hasChanged: a$1 }, d$1 = "finalized"; let u$1 = class u extends HTMLElement { constructor() { @@ -90,23 +90,23 @@ let u$1 = class u extends HTMLElement { static get observedAttributes() { this.finalize(); const t2 = []; - return this.elementProperties.forEach((i2, s2) => { - const e2 = this._$Ep(s2, i2); - void 0 !== e2 && (this._$Ev.set(e2, s2), t2.push(e2)); + return this.elementProperties.forEach((i2, s3) => { + const e2 = this._$Ep(s3, i2); + void 0 !== e2 && (this._$Ev.set(e2, s3), t2.push(e2)); }), t2; } static createProperty(t2, i2 = l$3) { if (i2.state && (i2.attribute = false), this.finalize(), this.elementProperties.set(t2, i2), !i2.noAccessor && !this.prototype.hasOwnProperty(t2)) { - const s2 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s2, i2); + const s3 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s3, i2); void 0 !== e2 && Object.defineProperty(this.prototype, t2, e2); } } - static getPropertyDescriptor(t2, i2, s2) { + static getPropertyDescriptor(t2, i2, s3) { return { get() { return this[i2]; }, set(e2) { const r2 = this[t2]; - this[i2] = e2, this.requestUpdate(t2, r2, s2); + this[i2] = e2, this.requestUpdate(t2, r2, s3); }, configurable: true, enumerable: true }; } static getPropertyOptions(t2) { @@ -119,32 +119,32 @@ let u$1 = class u extends HTMLElement { const t2 = Object.getPrototypeOf(this); if (t2.finalize(), void 0 !== t2.h && (this.h = [...t2.h]), this.elementProperties = new Map(t2.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { const t3 = this.properties, i2 = [...Object.getOwnPropertyNames(t3), ...Object.getOwnPropertySymbols(t3)]; - for (const s2 of i2) - this.createProperty(s2, t3[s2]); + for (const s3 of i2) + this.createProperty(s3, t3[s3]); } return this.elementStyles = this.finalizeStyles(this.styles), true; } static finalizeStyles(i2) { - const s2 = []; + const s3 = []; if (Array.isArray(i2)) { const e2 = new Set(i2.flat(1 / 0).reverse()); for (const i3 of e2) - s2.unshift(c$2(i3)); + s3.unshift(c$1(i3)); } else - void 0 !== i2 && s2.push(c$2(i2)); - return s2; + void 0 !== i2 && s3.push(c$1(i2)); + return s3; } static _$Ep(t2, i2) { - const s2 = i2.attribute; - return false === s2 ? void 0 : "string" == typeof s2 ? s2 : "string" == typeof t2 ? t2.toLowerCase() : void 0; + const s3 = i2.attribute; + return false === s3 ? void 0 : "string" == typeof s3 ? s3 : "string" == typeof t2 ? t2.toLowerCase() : void 0; } _$Eu() { var t2; this._$E_ = new Promise((t3) => this.enableUpdating = t3), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t2 = this.constructor.h) || void 0 === t2 || t2.forEach((t3) => t3(this)); } addController(t2) { - var i2, s2; - (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s2 = t2.hostConnected) || void 0 === s2 || s2.call(t2)); + var i2, s3; + (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s3 = t2.hostConnected) || void 0 === s3 || s3.call(t2)); } removeController(t2) { var i2; @@ -157,8 +157,8 @@ let u$1 = class u extends HTMLElement { } createRenderRoot() { var t2; - const s2 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); - return S$2(s2, this.constructor.elementStyles), s2; + const s3 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); + return S$2(s3, this.constructor.elementStyles), s3; } connectedCallback() { var t2; @@ -176,28 +176,28 @@ let u$1 = class u extends HTMLElement { return null === (i2 = t3.hostDisconnected) || void 0 === i2 ? void 0 : i2.call(t3); }); } - attributeChangedCallback(t2, i2, s2) { - this._$AK(t2, s2); + attributeChangedCallback(t2, i2, s3) { + this._$AK(t2, s3); } - _$EO(t2, i2, s2 = l$3) { + _$EO(t2, i2, s3 = l$3) { var e2; - const r2 = this.constructor._$Ep(t2, s2); - if (void 0 !== r2 && true === s2.reflect) { - const h2 = (void 0 !== (null === (e2 = s2.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s2.converter : n$4).toAttribute(i2, s2.type); + const r2 = this.constructor._$Ep(t2, s3); + if (void 0 !== r2 && true === s3.reflect) { + const h2 = (void 0 !== (null === (e2 = s3.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s3.converter : n$4).toAttribute(i2, s3.type); this._$El = t2, null == h2 ? this.removeAttribute(r2) : this.setAttribute(r2, h2), this._$El = null; } } _$AK(t2, i2) { - var s2; + var s3; const e2 = this.constructor, r2 = e2._$Ev.get(t2); if (void 0 !== r2 && this._$El !== r2) { - const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s2 = t3.converter) || void 0 === s2 ? void 0 : s2.fromAttribute) ? t3.converter : n$4; + const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s3 = t3.converter) || void 0 === s3 ? void 0 : s3.fromAttribute) ? t3.converter : n$4; this._$El = r2, this[r2] = h2.fromAttribute(i2, t3.type), this._$El = null; } } - requestUpdate(t2, i2, s2) { + requestUpdate(t2, i2, s3) { let e2 = true; - void 0 !== t2 && (((s2 = s2 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s2.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s2))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); + void 0 !== t2 && (((s3 = s3 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s3.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s3))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); } async _$Ej() { this.isUpdatePending = true; @@ -218,16 +218,16 @@ let u$1 = class u extends HTMLElement { return; this.hasUpdated, this._$Ei && (this._$Ei.forEach((t3, i3) => this[i3] = t3), this._$Ei = void 0); let i2 = false; - const s2 = this._$AL; + const s3 = this._$AL; try { - i2 = this.shouldUpdate(s2), i2 ? (this.willUpdate(s2), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { + i2 = this.shouldUpdate(s3), i2 ? (this.willUpdate(s3), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { var i3; return null === (i3 = t3.hostUpdate) || void 0 === i3 ? void 0 : i3.call(t3); - }), this.update(s2)) : this._$Ek(); + }), this.update(s3)) : this._$Ek(); } catch (t3) { throw i2 = false, this._$Ek(), t3; } - i2 && this._$AE(s2); + i2 && this._$AE(s3); } willUpdate(t2) { } @@ -258,34 +258,34 @@ let u$1 = class u extends HTMLElement { firstUpdated(t2) { } }; -u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$2 = e$4.reactiveElementVersions) && void 0 !== s$2 ? s$2 : e$4.reactiveElementVersions = []).push("1.6.3"); +u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$3 = e$4.reactiveElementVersions) && void 0 !== s$3 ? s$3 : e$4.reactiveElementVersions = []).push("1.6.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var t$2; -const i$2 = window, s$1 = i$2.trustedTypes, e$3 = s$1 ? s$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c$1 = Array.isArray, v$1 = (t2) => c$1(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), b = w(2), T$1 = Symbol.for("lit-noChange"), A$1 = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); -function P(t2, i2) { +const i$2 = window, s$2 = i$2.trustedTypes, e$3 = s$2 ? s$2.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s3) => ({ _$litType$: t2, strings: i2, values: s3 }), x = w(1), b$1 = w(2), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); +function P$1(t2, i2) { if (!Array.isArray(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array"); return void 0 !== e$3 ? e$3.createHTML(i2) : i2; } const V = (t2, i2) => { - const s2 = t2.length - 1, e2 = []; + const s3 = t2.length - 1, e2 = []; let l2, r2 = 2 === i2 ? "" : "", u3 = f; - for (let i3 = 0; i3 < s2; i3++) { - const s3 = t2[i3]; + for (let i3 = 0; i3 < s3; i3++) { + const s4 = t2[i3]; let d2, c2, v2 = -1, a2 = 0; - for (; a2 < s3.length && (u3.lastIndex = a2, c2 = u3.exec(s3), null !== c2); ) + for (; a2 < s4.length && (u3.lastIndex = a2, c2 = u3.exec(s4), null !== c2); ) a2 = u3.lastIndex, u3 === f ? "!--" === c2[1] ? u3 = _$1 : void 0 !== c2[1] ? u3 = m : void 0 !== c2[2] ? (y.test(c2[2]) && (l2 = RegExp("" === c2[0] ? (u3 = null != l2 ? l2 : f, v2 = -1) : void 0 === c2[1] ? v2 = -2 : (v2 = u3.lastIndex - c2[2].length, d2 = c2[1], u3 = void 0 === c2[3] ? p : '"' === c2[3] ? $ : g) : u3 === $ || u3 === g ? u3 = p : u3 === _$1 || u3 === m ? u3 = f : (u3 = p, l2 = void 0); const w2 = u3 === p && t2[i3 + 1].startsWith("/>") ? " " : ""; - r2 += u3 === f ? s3 + h$1 : v2 >= 0 ? (e2.push(d2), s3.slice(0, v2) + o$2 + s3.slice(v2) + n$3 + w2) : s3 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); + r2 += u3 === f ? s4 + h$1 : v2 >= 0 ? (e2.push(d2), s4.slice(0, v2) + o$2 + s4.slice(v2) + n$3 + w2) : s4 + n$3 + (-2 === v2 ? (e2.push(void 0), i3) : w2); } - return [P(t2, r2 + (t2[s2] || "") + (2 === i2 ? "" : "")), e2]; + return [P$1(t2, r2 + (t2[s3] || "") + (2 === i2 ? "" : "")), e2]; }; -class N { +let N$1 = class N { constructor({ strings: t2, _$litType$: i2 }, e2) { let h2; this.parts = []; @@ -301,10 +301,10 @@ class N { const t3 = []; for (const i3 of h2.getAttributeNames()) if (i3.endsWith(o$2) || i3.startsWith(n$3)) { - const s2 = f2[d2++]; - if (t3.push(i3), void 0 !== s2) { - const t4 = h2.getAttribute(s2.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s2); - v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); + const s3 = f2[d2++]; + if (t3.push(i3), void 0 !== s3) { + const t4 = h2.getAttribute(s3.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s3); + v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H$1 : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); } else v2.push({ type: 6, index: r2 }); } @@ -314,9 +314,9 @@ class N { if (y.test(h2.tagName)) { const t3 = h2.textContent.split(n$3), i3 = t3.length - 1; if (i3 > 0) { - h2.textContent = s$1 ? s$1.emptyScript : ""; - for (let s2 = 0; s2 < i3; s2++) - h2.append(t3[s2], u2()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); + h2.textContent = s$2 ? s$2.emptyScript : ""; + for (let s3 = 0; s3 < i3; s3++) + h2.append(t3[s3], u2()), C.nextNode(), v2.push({ type: 2, index: ++r2 }); h2.append(t3[i3], u2()); } } @@ -332,17 +332,17 @@ class N { } } static createElement(t2, i2) { - const s2 = r.createElement("template"); - return s2.innerHTML = t2, s2; + const s3 = r.createElement("template"); + return s3.innerHTML = t2, s3; } -} -function S$1(t2, i2, s2 = t2, e2) { +}; +function S$1(t2, i2, s3 = t2, e2) { var o3, n2, l2, h2; - if (i2 === T$1) + if (i2 === T) return i2; - let r2 = void 0 !== e2 ? null === (o3 = s2._$Co) || void 0 === o3 ? void 0 : o3[e2] : s2._$Cl; + let r2 = void 0 !== e2 ? null === (o3 = s3._$Co) || void 0 === o3 ? void 0 : o3[e2] : s3._$Cl; const u3 = d(i2) ? void 0 : i2._$litDirective$; - return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s2, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s2)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s2._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; + return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s3, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s3)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s3._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; } class M { constructor(t2, i2) { @@ -356,7 +356,7 @@ class M { } u(t2) { var i2; - const { el: { content: s2 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s2, true); + const { el: { content: s3 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s3, true); C.currentNode = o3; let n2 = C.nextNode(), l2 = 0, h2 = 0, u3 = e2[0]; for (; void 0 !== u3; ) { @@ -370,14 +370,14 @@ class M { } v(t2) { let i2 = 0; - for (const s2 of this._$AV) - void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++; + for (const s3 of this._$AV) + void 0 !== s3 && (void 0 !== s3.strings ? (s3._$AI(t2, s3, i2), i2 += s3.strings.length - 2) : s3._$AI(t2[i2])), i2++; } } class R { - constructor(t2, i2, s2, e2) { + constructor(t2, i2, s3, e2) { var o3; - this.type = 2, this._$AH = A$1, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; + this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s3, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; } get _$AU() { var t2, i2; @@ -395,7 +395,7 @@ class R { return this._$AB; } _$AI(t2, i2 = this) { - t2 = S$1(this, t2, i2), d(t2) ? t2 === A$1 || null == t2 || "" === t2 ? (this._$AH !== A$1 && this._$AR(), this._$AH = A$1) : t2 !== this._$AH && t2 !== T$1 && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v$1(t2) ? this.T(t2) : this._(t2); + t2 = S$1(this, t2, i2), d(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v(t2) ? this.T(t2) : this._(t2); } k(t2) { return this._$AA.parentNode.insertBefore(t2, this._$AB); @@ -404,33 +404,33 @@ class R { this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2)); } _(t2) { - this._$AH !== A$1 && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; + this._$AH !== A && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; } g(t2) { var i2; - const { values: s2, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N.createElement(P(e2.h, e2.h[0]), this.options)), e2); + const { values: s3, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N$1.createElement(P$1(e2.h, e2.h[0]), this.options)), e2); if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o3) - this._$AH.v(s2); + this._$AH.v(s3); else { const t3 = new M(o3, this), i3 = t3.u(this.options); - t3.v(s2), this.$(i3), this._$AH = t3; + t3.v(s3), this.$(i3), this._$AH = t3; } } _$AC(t2) { let i2 = E.get(t2.strings); - return void 0 === i2 && E.set(t2.strings, i2 = new N(t2)), i2; + return void 0 === i2 && E.set(t2.strings, i2 = new N$1(t2)), i2; } T(t2) { - c$1(this._$AH) || (this._$AH = [], this._$AR()); + c(this._$AH) || (this._$AH = [], this._$AR()); const i2 = this._$AH; - let s2, e2 = 0; + let s3, e2 = 0; for (const o3 of t2) - e2 === i2.length ? i2.push(s2 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s2 = i2[e2], s2._$AI(o3), e2++; - e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2); + e2 === i2.length ? i2.push(s3 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s3 = i2[e2], s3._$AI(o3), e2++; + e2 < i2.length && (this._$AR(s3 && s3._$AB.nextSibling, e2), i2.length = e2); } _$AR(t2 = this._$AA.nextSibling, i2) { - var s2; - for (null === (s2 = this._$AP) || void 0 === s2 || s2.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { + var s3; + for (null === (s3 = this._$AP) || void 0 === s3 || s3.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { const i3 = t2.nextSibling; t2.remove(), t2 = i3; } @@ -441,8 +441,8 @@ class R { } } class k { - constructor(t2, i2, s2, e2, o3) { - this.type = 1, this._$AH = A$1, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = A$1; + constructor(t2, i2, s3, e2, o3) { + this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s3.length > 2 || "" !== s3[0] || "" !== s3[1] ? (this._$AH = Array(s3.length - 1).fill(new String()), this.strings = s3) : this._$AH = A; } get tagName() { return this.element.tagName; @@ -450,59 +450,59 @@ class k { get _$AU() { return this._$AM._$AU; } - _$AI(t2, i2 = this, s2, e2) { + _$AI(t2, i2 = this, s3, e2) { const o3 = this.strings; let n2 = false; if (void 0 === o3) - t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T$1, n2 && (this._$AH = t2); + t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T, n2 && (this._$AH = t2); else { const e3 = t2; let l2, h2; for (t2 = o3[0], l2 = 0; l2 < o3.length - 1; l2++) - h2 = S$1(this, e3[s2 + l2], i2, l2), h2 === T$1 && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A$1 ? t2 = A$1 : t2 !== A$1 && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; + h2 = S$1(this, e3[s3 + l2], i2, l2), h2 === T && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A ? t2 = A : t2 !== A && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; } n2 && !e2 && this.j(t2); } j(t2) { - t2 === A$1 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); + t2 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); } } -class H extends k { +let H$1 = class H extends k { constructor() { super(...arguments), this.type = 3; } j(t2) { - this.element[this.name] = t2 === A$1 ? void 0 : t2; + this.element[this.name] = t2 === A ? void 0 : t2; } -} -const I = s$1 ? s$1.emptyScript : ""; +}; +const I = s$2 ? s$2.emptyScript : ""; let L$1 = class L extends k { constructor() { super(...arguments), this.type = 4; } j(t2) { - t2 && t2 !== A$1 ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); + t2 && t2 !== A ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); } }; class z extends k { - constructor(t2, i2, s2, e2, o3) { - super(t2, i2, s2, e2, o3), this.type = 5; + constructor(t2, i2, s3, e2, o3) { + super(t2, i2, s3, e2, o3), this.type = 5; } _$AI(t2, i2 = this) { - var s2; - if ((t2 = null !== (s2 = S$1(this, t2, i2, 0)) && void 0 !== s2 ? s2 : A$1) === T$1) + var s3; + if ((t2 = null !== (s3 = S$1(this, t2, i2, 0)) && void 0 !== s3 ? s3 : A) === T) return; - const e2 = this._$AH, o3 = t2 === A$1 && e2 !== A$1 || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A$1 && (e2 === A$1 || o3); + const e2 = this._$AH, o3 = t2 === A && e2 !== A || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A && (e2 === A || o3); o3 && this.element.removeEventListener(this.name, this, e2), n2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2; } handleEvent(t2) { - var i2, s2; - "function" == typeof this._$AH ? this._$AH.call(null !== (s2 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s2 ? s2 : this.element, t2) : this._$AH.handleEvent(t2); + var i2, s3; + "function" == typeof this._$AH ? this._$AH.call(null !== (s3 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s3 ? s3 : this.element, t2) : this._$AH.handleEvent(t2); } } let Z$1 = class Z { - constructor(t2, i2, s2) { - this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s2; + constructor(t2, i2, s3) { + this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s3; } get _$AU() { return this._$AM._$AU; @@ -512,14 +512,14 @@ let Z$1 = class Z { } }; const B$1 = i$2.litHtmlPolyfillSupport; -null == B$1 || B$1(N, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); -const D$1 = (t2, i2, s2) => { +null == B$1 || B$1(N$1, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); +const D$1 = (t2, i2, s3) => { var e2, o3; - const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2; + const n2 = null !== (e2 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== e2 ? e2 : i2; let l2 = n2._$litPart$; if (void 0 === l2) { - const t3 = null !== (o3 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== o3 ? o3 : null; - n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s2 ? s2 : {}); + const t3 = null !== (o3 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== o3 ? o3 : null; + n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s3 ? s3 : {}); } return l2._$AI(t2), l2; }; @@ -529,7 +529,7 @@ const D$1 = (t2, i2, s2) => { * SPDX-License-Identifier: BSD-3-Clause */ var l$1, o$1; -class s extends u$1 { +let s$1 = class s extends u$1 { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } @@ -551,12 +551,12 @@ class s extends u$1 { super.disconnectedCallback(), null === (t2 = this._$Do) || void 0 === t2 || t2.setConnected(false); } render() { - return T$1; + return T; } -} -s.finalized = true, s._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s }); +}; +s$1.finalized = true, s$1._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s$1 }); const n$2 = globalThis.litElementPolyfillSupport; -null == n$2 || n$2({ LitElement: s }); +null == n$2 || n$2({ LitElement: s$1 }); (null !== (o$1 = globalThis.litElementVersions) && void 0 !== o$1 ? o$1 : globalThis.litElementVersions = []).push("3.3.3"); /** * @license @@ -564,8 +564,8 @@ null == n$2 || n$2({ LitElement: s }); * SPDX-License-Identifier: BSD-3-Clause */ const e$2 = (e2) => (n2) => "function" == typeof n2 ? ((e3, n3) => (customElements.define(e3, n3), n3))(e2, n2) : ((e3, n3) => { - const { kind: t2, elements: s2 } = n3; - return { kind: t2, elements: s2, finisher(n4) { + const { kind: t2, elements: s3 } = n3; + return { kind: t2, elements: s3, finisher(n4) { customElements.define(e3, n4); } }; })(e2, n2); @@ -637,23 +637,23 @@ const o2 = e(class extends i { render(t2) { return " " + Object.keys(t2).filter((i2) => t2[i2]).join(" ") + " "; } - update(i2, [s2]) { + update(i2, [s3]) { var r2, o3; if (void 0 === this.it) { this.it = /* @__PURE__ */ new Set(), void 0 !== i2.strings && (this.nt = new Set(i2.strings.join(" ").split(/\s/).filter((t2) => "" !== t2))); - for (const t2 in s2) - s2[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); - return this.render(s2); + for (const t2 in s3) + s3[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); + return this.render(s3); } const e2 = i2.element.classList; this.it.forEach((t2) => { - t2 in s2 || (e2.remove(t2), this.it.delete(t2)); + t2 in s3 || (e2.remove(t2), this.it.delete(t2)); }); - for (const t2 in s2) { - const i3 = !!s2[t2]; + for (const t2 in s3) { + const i3 = !!s3[t2]; i3 === this.it.has(t2) || (null === (o3 = this.nt) || void 0 === o3 ? void 0 : o3.has(t2)) || (i3 ? (e2.add(t2), this.it.add(t2)) : (e2.remove(t2), this.it.delete(t2))); } - return T$1; + return T; } }); function addUniqueItem(array, item) { @@ -1213,12 +1213,8 @@ const getOptions = (options, key) => ( options[key] ? Object.assign(Object.assign({}, options), options[key]) : Object.assign({}, options) ); function resolveElements(elements, selectorCache) { - var _a; if (typeof elements === "string") { - if (selectorCache) { - (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : selectorCache[elements] = document.querySelectorAll(elements); - elements = selectorCache[elements]; - } else { + { elements = document.querySelectorAll(elements); } } else if (elements instanceof Element) { @@ -1332,7 +1328,7 @@ function animate(target, keyframesOrOptions, options) { * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const l = (l2) => null != l2 ? l2 : A$1; +const l = (l2) => null != l2 ? l2 : A; var browser = {}; var canPromise$1 = function() { return typeof Promise === "function" && Promise.prototype && Promise.prototype.then; @@ -1530,13 +1526,13 @@ var alignmentPattern = {}; const pos = exports.getRowColCoords(version2); const posLength = pos.length; for (let i2 = 0; i2 < posLength; i2++) { - for (let j2 = 0; j2 < posLength; j2++) { - if (i2 === 0 && j2 === 0 || // top-left - i2 === 0 && j2 === posLength - 1 || // bottom-left - i2 === posLength - 1 && j2 === 0) { + for (let j = 0; j < posLength; j++) { + if (i2 === 0 && j === 0 || // top-left + i2 === 0 && j === posLength - 1 || // bottom-left + i2 === posLength - 1 && j === 0) { continue; } - coords.push([pos[i2], pos[j2]]); + coords.push([pos[i2], pos[j]]); } } return coords; @@ -1655,24 +1651,24 @@ var maskPattern = {}; const k2 = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10); return k2 * PenaltyScores.N4; }; - function getMaskAt(maskPattern2, i2, j2) { + function getMaskAt(maskPattern2, i2, j) { switch (maskPattern2) { case exports.Patterns.PATTERN000: - return (i2 + j2) % 2 === 0; + return (i2 + j) % 2 === 0; case exports.Patterns.PATTERN001: return i2 % 2 === 0; case exports.Patterns.PATTERN010: - return j2 % 3 === 0; + return j % 3 === 0; case exports.Patterns.PATTERN011: - return (i2 + j2) % 3 === 0; + return (i2 + j) % 3 === 0; case exports.Patterns.PATTERN100: - return (Math.floor(i2 / 2) + Math.floor(j2 / 3)) % 2 === 0; + return (Math.floor(i2 / 2) + Math.floor(j / 3)) % 2 === 0; case exports.Patterns.PATTERN101: - return i2 * j2 % 2 + i2 * j2 % 3 === 0; + return i2 * j % 2 + i2 * j % 3 === 0; case exports.Patterns.PATTERN110: - return (i2 * j2 % 2 + i2 * j2 % 3) % 2 === 0; + return (i2 * j % 2 + i2 * j % 3) % 2 === 0; case exports.Patterns.PATTERN111: - return (i2 * j2 % 3 + (i2 + j2) % 2) % 2 === 0; + return (i2 * j % 3 + (i2 + j) % 2) % 2 === 0; default: throw new Error("bad maskPattern:" + maskPattern2); } @@ -2096,8 +2092,8 @@ galoisField.mul = function mul(x2, y2) { exports.mul = function mul2(p1, p2) { const coeff = new Uint8Array(p1.length + p2.length - 1); for (let i2 = 0; i2 < p1.length; i2++) { - for (let j2 = 0; j2 < p2.length; j2++) { - coeff[i2 + j2] ^= GF.mul(p1[i2], p2[j2]); + for (let j = 0; j < p2.length; j++) { + coeff[i2 + j] ^= GF.mul(p1[i2], p2[j]); } } return coeff; @@ -2572,12 +2568,12 @@ var kanjiData = KanjiData; var dijkstra = { exports: {} }; (function(module) { var dijkstra2 = { - single_source_shortest_paths: function(graph, s2, d2) { + single_source_shortest_paths: function(graph, s3, d2) { var predecessors = {}; var costs = {}; - costs[s2] = 0; + costs[s3] = 0; var open = dijkstra2.PriorityQueue.make(); - open.push(s2, 0); + open.push(s3, 0); var closest, u3, v2, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; while (!open.empty()) { closest = open.pop(); @@ -2599,7 +2595,7 @@ var dijkstra = { exports: {} }; } } if (typeof d2 !== "undefined" && typeof costs[d2] === "undefined") { - var msg = ["Could not find a path from ", s2, " to ", d2, "."].join(""); + var msg = ["Could not find a path from ", s3, " to ", d2, "."].join(""); throw new Error(msg); } return predecessors; @@ -2615,8 +2611,8 @@ var dijkstra = { exports: {} }; nodes.reverse(); return nodes; }, - find_path: function(graph, s2, d2) { - var predecessors = dijkstra2.single_source_shortest_paths(graph, s2, d2); + find_path: function(graph, s3, d2) { + var predecessors = dijkstra2.single_source_shortest_paths(graph, s3, d2); return dijkstra2.extract_shortest_path_from_predecessor_list( predecessors, d2 @@ -2704,8 +2700,8 @@ var dijkstraExports = dijkstra.exports; kanjiSegs = []; } const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs); - return segs.sort(function(s1, s2) { - return s1.index - s2.index; + return segs.sort(function(s1, s22) { + return s1.index - s22.index; }).map(function(obj) { return { data: obj.data, @@ -2776,9 +2772,9 @@ var dijkstraExports = dijkstra.exports; for (let i2 = 0; i2 < nodes.length; i2++) { const nodeGroup = nodes[i2]; const currentNodeIds = []; - for (let j2 = 0; j2 < nodeGroup.length; j2++) { - const node = nodeGroup[j2]; - const key = "" + i2 + j2; + for (let j = 0; j < nodeGroup.length; j++) { + const node = nodeGroup[j]; + const key = "" + i2 + j; currentNodeIds.push(key); table[key] = { node, lastCount: 0 }; graph[key] = {}; @@ -3172,12 +3168,12 @@ var utils = {}; const scaledMargin = opts.margin * scale; const palette = [opts.color.light, opts.color.dark]; for (let i2 = 0; i2 < symbolSize; i2++) { - for (let j2 = 0; j2 < symbolSize; j2++) { - let posDst = (i2 * symbolSize + j2) * 4; + for (let j = 0; j < symbolSize; j++) { + let posDst = (i2 * symbolSize + j) * 4; let pxColor = opts.color.light; - if (i2 >= scaledMargin && j2 >= scaledMargin && i2 < symbolSize - scaledMargin && j2 < symbolSize - scaledMargin) { + if (i2 >= scaledMargin && j >= scaledMargin && i2 < symbolSize - scaledMargin && j < symbolSize - scaledMargin) { const iSrc = Math.floor((i2 - scaledMargin) / scale); - const jSrc = Math.floor((j2 - scaledMargin) / scale); + const jSrc = Math.floor((j - scaledMargin) / scale); pxColor = palette[data2[iSrc * size + jSrc] ? 1 : 0]; } imgData[posDst++] = pxColor.r; @@ -3358,150 +3354,54 @@ browser.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL); browser.toString = renderCanvas.bind(null, function(data2, _2, opts) { return SvgRenderer.render(data2, opts); }); -var et = Object.defineProperty, Be = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Ue = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, ve = (e2, o3) => { +var et = Object.defineProperty, Se = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Be = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, fe = (e2, o3) => { for (var r2 in o3 || (o3 = {})) - tt.call(o3, r2) && Ue(e2, r2, o3[r2]); - if (Be) - for (var r2 of Be(o3)) - ot.call(o3, r2) && Ue(e2, r2, o3[r2]); + tt.call(o3, r2) && Be(e2, r2, o3[r2]); + if (Se) + for (var r2 of Se(o3)) + ot.call(o3, r2) && Be(e2, r2, o3[r2]); return e2; }; function rt() { var e2; - const o3 = (e2 = ne$1.state.themeMode) != null ? e2 : "dark", r2 = { - light: { - foreground: { - 1: "rgb(20,20,20)", - 2: "rgb(121,134,134)", - 3: "rgb(158,169,169)" - }, - background: { - 1: "rgb(255,255,255)", - 2: "rgb(241,243,243)", - 3: "rgb(228,231,231)" - }, - overlay: "rgba(0,0,0,0.1)" - }, - dark: { - foreground: { - 1: "rgb(228,231,231)", - 2: "rgb(148,158,158)", - 3: "rgb(110,119,119)" - }, - background: { - 1: "rgb(20,20,20)", - 2: "rgb(39,42,42)", - 3: "rgb(59,64,64)" - }, - overlay: "rgba(255,255,255,0.1)" - } - }[o3]; - return { - "--wcm-color-fg-1": r2.foreground[1], - "--wcm-color-fg-2": r2.foreground[2], - "--wcm-color-fg-3": r2.foreground[3], - "--wcm-color-bg-1": r2.background[1], - "--wcm-color-bg-2": r2.background[2], - "--wcm-color-bg-3": r2.background[3], - "--wcm-color-overlay": r2.overlay - }; + const o3 = (e2 = ne$3.state.themeMode) != null ? e2 : "dark", r2 = { light: { foreground: { 1: "rgb(20,20,20)", 2: "rgb(121,134,134)", 3: "rgb(158,169,169)" }, background: { 1: "rgb(255,255,255)", 2: "rgb(241,243,243)", 3: "rgb(228,231,231)" }, overlay: "rgba(0,0,0,0.1)" }, dark: { foreground: { 1: "rgb(228,231,231)", 2: "rgb(148,158,158)", 3: "rgb(110,119,119)" }, background: { 1: "rgb(20,20,20)", 2: "rgb(39,42,42)", 3: "rgb(59,64,64)" }, overlay: "rgba(255,255,255,0.1)" } }[o3]; + return { "--wcm-color-fg-1": r2.foreground[1], "--wcm-color-fg-2": r2.foreground[2], "--wcm-color-fg-3": r2.foreground[3], "--wcm-color-bg-1": r2.background[1], "--wcm-color-bg-2": r2.background[2], "--wcm-color-bg-3": r2.background[3], "--wcm-color-overlay": r2.overlay }; } -function He() { - return { - "--wcm-accent-color": "#3396FF", - "--wcm-accent-fill-color": "#FFFFFF", - "--wcm-z-index": "89", - "--wcm-background-color": "#3396FF", - "--wcm-background-border-radius": "8px", - "--wcm-container-border-radius": "30px", - "--wcm-wallet-icon-border-radius": "15px", - "--wcm-wallet-icon-large-border-radius": "30px", - "--wcm-wallet-icon-small-border-radius": "7px", - "--wcm-input-border-radius": "28px", - "--wcm-button-border-radius": "10px", - "--wcm-notification-border-radius": "36px", - "--wcm-secondary-button-border-radius": "28px", - "--wcm-icon-button-border-radius": "50%", - "--wcm-button-hover-highlight-border-radius": "10px", - "--wcm-text-big-bold-size": "20px", - "--wcm-text-big-bold-weight": "600", - "--wcm-text-big-bold-line-height": "24px", - "--wcm-text-big-bold-letter-spacing": "-0.03em", - "--wcm-text-big-bold-text-transform": "none", - "--wcm-text-xsmall-bold-size": "10px", - "--wcm-text-xsmall-bold-weight": "700", - "--wcm-text-xsmall-bold-line-height": "12px", - "--wcm-text-xsmall-bold-letter-spacing": "0.02em", - "--wcm-text-xsmall-bold-text-transform": "uppercase", - "--wcm-text-xsmall-regular-size": "12px", - "--wcm-text-xsmall-regular-weight": "600", - "--wcm-text-xsmall-regular-line-height": "14px", - "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", - "--wcm-text-xsmall-regular-text-transform": "none", - "--wcm-text-small-thin-size": "14px", - "--wcm-text-small-thin-weight": "500", - "--wcm-text-small-thin-line-height": "16px", - "--wcm-text-small-thin-letter-spacing": "-0.03em", - "--wcm-text-small-thin-text-transform": "none", - "--wcm-text-small-regular-size": "14px", - "--wcm-text-small-regular-weight": "600", - "--wcm-text-small-regular-line-height": "16px", - "--wcm-text-small-regular-letter-spacing": "-0.03em", - "--wcm-text-small-regular-text-transform": "none", - "--wcm-text-medium-regular-size": "16px", - "--wcm-text-medium-regular-weight": "600", - "--wcm-text-medium-regular-line-height": "20px", - "--wcm-text-medium-regular-letter-spacing": "-0.03em", - "--wcm-text-medium-regular-text-transform": "none", - "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", - "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", - "--wcm-success-color": "rgb(38,181,98)", - "--wcm-error-color": "rgb(242, 90, 103)", - "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", - "--wcm-overlay-backdrop-filter": "none" - }; +function Ue() { + return { "--wcm-accent-color": "#3396FF", "--wcm-accent-fill-color": "#FFFFFF", "--wcm-z-index": "89", "--wcm-background-color": "#3396FF", "--wcm-background-border-radius": "8px", "--wcm-container-border-radius": "30px", "--wcm-wallet-icon-border-radius": "15px", "--wcm-wallet-icon-large-border-radius": "30px", "--wcm-wallet-icon-small-border-radius": "7px", "--wcm-input-border-radius": "28px", "--wcm-button-border-radius": "10px", "--wcm-notification-border-radius": "36px", "--wcm-secondary-button-border-radius": "28px", "--wcm-icon-button-border-radius": "50%", "--wcm-button-hover-highlight-border-radius": "10px", "--wcm-text-big-bold-size": "20px", "--wcm-text-big-bold-weight": "600", "--wcm-text-big-bold-line-height": "24px", "--wcm-text-big-bold-letter-spacing": "-0.03em", "--wcm-text-big-bold-text-transform": "none", "--wcm-text-xsmall-bold-size": "10px", "--wcm-text-xsmall-bold-weight": "700", "--wcm-text-xsmall-bold-line-height": "12px", "--wcm-text-xsmall-bold-letter-spacing": "0.02em", "--wcm-text-xsmall-bold-text-transform": "uppercase", "--wcm-text-xsmall-regular-size": "12px", "--wcm-text-xsmall-regular-weight": "600", "--wcm-text-xsmall-regular-line-height": "14px", "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", "--wcm-text-xsmall-regular-text-transform": "none", "--wcm-text-small-thin-size": "14px", "--wcm-text-small-thin-weight": "500", "--wcm-text-small-thin-line-height": "16px", "--wcm-text-small-thin-letter-spacing": "-0.03em", "--wcm-text-small-thin-text-transform": "none", "--wcm-text-small-regular-size": "14px", "--wcm-text-small-regular-weight": "600", "--wcm-text-small-regular-line-height": "16px", "--wcm-text-small-regular-letter-spacing": "-0.03em", "--wcm-text-small-regular-text-transform": "none", "--wcm-text-medium-regular-size": "16px", "--wcm-text-medium-regular-weight": "600", "--wcm-text-medium-regular-line-height": "20px", "--wcm-text-medium-regular-letter-spacing": "-0.03em", "--wcm-text-medium-regular-text-transform": "none", "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", "--wcm-success-color": "rgb(38,181,98)", "--wcm-error-color": "rgb(242, 90, 103)", "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", "--wcm-overlay-backdrop-filter": "none" }; } -const h = { - getPreset(e2) { - return He()[e2]; - }, - setTheme() { - const e2 = document.querySelector(":root"), { themeVariables: o3 } = ne$1.state; - if (e2) { - const r2 = ve(ve(ve({}, rt()), He()), o3); - Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); - } - }, - globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` -}, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; -var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, F = (e2, o3, r2, a2) => { +const h = { getPreset(e2) { + return Ue()[e2]; +}, setTheme() { + const e2 = document.querySelector(":root"), { themeVariables: o3 } = ne$3.state; + if (e2) { + const r2 = fe(fe(fe({}, rt()), Ue()), o3); + Object.entries(r2).forEach(([a2, t2]) => e2.style.setProperty(a2, t2)); + } +}, globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` }, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; +var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? it(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && lt(o3, r2, t2), t2; }; -let T = class extends s { +let _ = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.iconLeft = void 0, this.iconRight = void 0, this.onClick = () => null, this.variant = "default"; } render() { - const e2 = { - "wcm-icon-left": this.iconLeft !== void 0, - "wcm-icon-right": this.iconRight !== void 0, - "wcm-ghost": this.variant === "ghost", - "wcm-outline": this.variant === "outline" - }; + const e2 = { "wcm-icon-left": this.iconLeft !== void 0, "wcm-icon-right": this.iconRight !== void 0, "wcm-ghost": this.variant === "ghost", "wcm-outline": this.variant === "outline" }; let o$12 = "inverse"; return this.variant === "ghost" && (o$12 = "secondary"), this.variant === "outline" && (o$12 = "accent"), x``; } }; -T.styles = [h.globalCss, at], F([n$1({ type: Boolean })], T.prototype, "disabled", 2), F([n$1()], T.prototype, "iconLeft", 2), F([n$1()], T.prototype, "iconRight", 2), F([n$1()], T.prototype, "onClick", 2), F([n$1()], T.prototype, "variant", 2), T = F([e$2("wcm-button")], T); +_.styles = [h.globalCss, at], K([n$1({ type: Boolean })], _.prototype, "disabled", 2), K([n$1()], _.prototype, "iconLeft", 2), K([n$1()], _.prototype, "iconRight", 2), K([n$1()], _.prototype, "onClick", 2), K([n$1()], _.prototype, "variant", 2), _ = K([e$2("wcm-button")], _); const nt = i$3`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`; -var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, ue = (e2, o3, r2, a2) => { +var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, xe = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? st(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && ct(o3, r2, t2), t2; }; -let ee = class extends s { +let re = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.variant = "primary"; } @@ -3510,86 +3410,67 @@ let ee = class extends s { return x``; } }; -ee.styles = [h.globalCss, nt], ue([n$1({ type: Boolean })], ee.prototype, "disabled", 2), ue([n$1()], ee.prototype, "variant", 2), ee = ue([e$2("wcm-button-big")], ee); +re.styles = [h.globalCss, nt], xe([n$1({ type: Boolean })], re.prototype, "disabled", 2), xe([n$1()], re.prototype, "variant", 2), re = xe([e$2("wcm-button-big")], re); const dt = i$3`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`; -var mt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, wt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && mt(o3, r2, t2), t2; +var ht = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let be = class extends s { +let ye = class extends s$1 { render() { return x`
`; } }; -be.styles = [h.globalCss, dt], be = wt([e$2("wcm-info-footer")], be); -const v = { - CROSS_ICON: b``, - WALLET_CONNECT_LOGO: b``, - WALLET_CONNECT_ICON: b``, - WALLET_CONNECT_ICON_COLORED: b``, - BACK_ICON: b``, - COPY_ICON: b``, - RETRY_ICON: b``, - DESKTOP_ICON: b``, - MOBILE_ICON: b``, - ARROW_DOWN_ICON: b``, - ARROW_UP_RIGHT_ICON: b``, - ARROW_RIGHT_ICON: b``, - QRCODE_ICON: b``, - SCAN_ICON: b``, - CHECKMARK_ICON: b``, - SEARCH_ICON: b``, - WALLET_PLACEHOLDER: b``, - GLOBE_ICON: b`` -}, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; -var gt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, ut = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? vt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && gt(o3, r2, t2), t2; +ye.styles = [h.globalCss, dt], ye = ht([e$2("wcm-info-footer")], ye); +const b = { CROSS_ICON: b$1``, WALLET_CONNECT_LOGO: b$1``, WALLET_CONNECT_ICON: b$1``, WALLET_CONNECT_ICON_COLORED: b$1``, BACK_ICON: b$1``, COPY_ICON: b$1``, RETRY_ICON: b$1``, DESKTOP_ICON: b$1``, MOBILE_ICON: b$1``, ARROW_DOWN_ICON: b$1``, ARROW_UP_RIGHT_ICON: b$1``, ARROW_RIGHT_ICON: b$1``, QRCODE_ICON: b$1``, SCAN_ICON: b$1``, CHECKMARK_ICON: b$1``, SEARCH_ICON: b$1``, WALLET_PLACEHOLDER: b$1``, GLOBE_ICON: b$1`` }, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; +var ut = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let fe = class extends s { +let $e = class extends s$1 { render() { - return x`
${v.WALLET_CONNECT_LOGO}
`; + return x`
${b.WALLET_CONNECT_LOGO}
`; } }; -fe.styles = [h.globalCss, pt], fe = ut([e$2("wcm-modal-backcard")], fe); +$e.styles = [h.globalCss, pt], $e = ut([e$2("wcm-modal-backcard")], $e); const bt = i$3`main{padding:20px;padding-top:0;width:100%}`; -var ft = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, yt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? xt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ft(o3, r2, t2), t2; +var yt = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let xe = class extends s { +let Ce = class extends s$1 { render() { return x`
`; } }; -xe.styles = [h.globalCss, bt], xe = yt([e$2("wcm-modal-content")], xe); +Ce.styles = [h.globalCss, bt], Ce = yt([e$2("wcm-modal-content")], Ce); const $t = i$3`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`; -var Ct = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, Ot = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? kt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ct(o3, r2, t2), t2; +var Ot = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let ye = class extends s { +let ke = class extends s$1 { render() { return x`
`; } }; -ye.styles = [h.globalCss, $t], ye = Ot([e$2("wcm-modal-footer")], ye); -const Wt = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; -var It = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, te = (e2, o3, r2, a2) => { +ke.styles = [h.globalCss, $t], ke = Ot([e$2("wcm-modal-footer")], ke); +const It = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; +var Wt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, ae = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Et(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && It(o3, r2, t2), t2; + return a2 && t2 && Wt(o3, r2, t2), t2; }; -let S = class extends s { +let B = class extends s$1 { constructor() { super(...arguments), this.title = "", this.onAction = void 0, this.actionIcon = void 0, this.border = false; } backBtnTemplate() { - return x``; + return x``; } actionBtnTemplate() { return x``; @@ -3599,112 +3480,87 @@ let S = class extends s { return x`
${o$12 ? this.backBtnTemplate() : null} ${r2} ${this.onAction ? this.actionBtnTemplate() : null}
`; } }; -S.styles = [h.globalCss, Wt], te([n$1()], S.prototype, "title", 2), te([n$1()], S.prototype, "onAction", 2), te([n$1()], S.prototype, "actionIcon", 2), te([n$1({ type: Boolean })], S.prototype, "border", 2), S = te([e$2("wcm-modal-header")], S); -const c = { - MOBILE_BREAKPOINT: 600, - WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", - EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", - getShadowRootElement(e2, o3) { - const r2 = e2.renderRoot.querySelector(o3); - if (!r2) - throw new Error(`${o3} not found`); - return r2; - }, - getWalletIcon({ id: e2, image_id: o3 }) { - const { walletImages: r2 } = y$1.state; - return r2 != null && r2[e2] ? r2[e2] : o3 ? te$1.getWalletImageUrl(o3) : ""; - }, - getWalletName(e2, o3 = false) { - return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; - }, - isMobileAnimation() { - return window.innerWidth <= c.MOBILE_BREAKPOINT; - }, - async preloadImage(e2) { - const o3 = new Promise((r2, a2) => { - const t2 = new Image(); - t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; - }); - return Promise.race([o3, a$2.wait(3e3)]); - }, - getErrorMessage(e2) { - return e2 instanceof Error ? e2.message : "Unknown Error"; - }, - debounce(e2, o3 = 500) { - let r2; - return (...a2) => { - function t2() { - e2(...a2); - } - r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); - }; - }, - handleMobileLinking(e2) { - const { walletConnectUri: o3 } = p$1.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - c.setRecentWallet(e2); - function i2(s2) { - let $2 = ""; - t2 ? $2 = a$2.formatUniversalUrl(t2, s2, a2) : l2 && ($2 = a$2.formatNativeUrl(l2, s2, a2)), a$2.openHref($2, "_self"); - } - o3 && i2(o3); - }, - async handleUriCopy() { - const { walletConnectUri: e2 } = p$1.state; - if (e2) - try { - await navigator.clipboard.writeText(e2), oe$1.openToast("Link copied", "success"); - } catch { - oe$1.openToast("Failed to copy", "error"); - } - }, - getCustomImageUrls() { - const { walletImages: e2 } = y$1.state, o3 = Object.values(e2 ?? {}); - return Object.values(o3); - }, - truncate(e2, o3 = 8) { - return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; - }, - setRecentWallet(e2) { - try { - localStorage.setItem(c.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); - } catch { - console.info("Unable to set recent wallet"); +B.styles = [h.globalCss, It], ae([n$1()], B.prototype, "title", 2), ae([n$1()], B.prototype, "onAction", 2), ae([n$1()], B.prototype, "actionIcon", 2), ae([n$1({ type: Boolean })], B.prototype, "border", 2), B = ae([e$2("wcm-modal-header")], B); +const s2 = { MOBILE_BREAKPOINT: 600, WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", getShadowRootElement(e2, o3) { + const r2 = e2.renderRoot.querySelector(o3); + if (!r2) + throw new Error(`${o3} not found`); + return r2; +}, getWalletIcon({ id: e2, image_id: o3 }) { + const { walletImages: r2 } = y$4.state; + return r2 != null && r2[e2] ? r2[e2] : o3 ? te$1.getWalletImageUrl(o3) : ""; +}, getWalletName(e2, o3 = false) { + return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; +}, isMobileAnimation() { + return window.innerWidth <= s2.MOBILE_BREAKPOINT; +}, async preloadImage(e2) { + const o3 = new Promise((r2, a2) => { + const t2 = new Image(); + t2.onload = r2, t2.onerror = a2, t2.crossOrigin = "anonymous", t2.src = e2; + }); + return Promise.race([o3, i$1$1.wait(3e3)]); +}, getErrorMessage(e2) { + return e2 instanceof Error ? e2.message : "Unknown Error"; +}, debounce(e2, o3 = 500) { + let r2; + return (...a2) => { + function t2() { + e2(...a2); } - }, - getRecentWallet() { + r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); + }; +}, handleMobileLinking(e2) { + const { walletConnectUri: o3 } = p$2.state, { mobile: r2, name: a2 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; + s2.setRecentWallet(e2); + function i2(c2) { + let u3 = ""; + t2 ? u3 = i$1$1.formatUniversalUrl(t2, c2, a2) : l2 && (u3 = i$1$1.formatNativeUrl(l2, c2, a2)), i$1$1.openHref(u3, "_self"); + } + o3 && i2(o3); +}, async handleUriCopy() { + const { walletConnectUri: e2 } = p$2.state; + if (e2) try { - const e2 = localStorage.getItem(c.WCM_RECENT_WALLET_DATA); - return e2 ? JSON.parse(e2) : void 0; + await navigator.clipboard.writeText(e2), oe$2.openToast("Link copied", "success"); } catch { - console.info("Unable to get recent wallet"); + oe$2.openToast("Failed to copy", "error"); } - }, - caseSafeIncludes(e2, o3) { - return e2.toUpperCase().includes(o3.toUpperCase()); - }, - openWalletExplorerUrl() { - a$2.openHref(c.EXPLORER_WALLET_URL, "_blank"); - }, - getCachedRouterWalletPlatforms() { - const { desktop: e2, mobile: o3 } = a$2.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); - return { isDesktop: r2, isMobile: t2, isWeb: a2 }; - }, - goToConnectingView(e2) { - T$2.setData({ Wallet: e2 }); - const o3 = a$2.isMobile(), { - isDesktop: r2, - isWeb: a2, - isMobile: t2 - } = c.getCachedRouterWalletPlatforms(); - o3 ? t2 ? T$2.push("MobileConnecting") : a2 ? T$2.push("WebConnecting") : T$2.push("InstallWallet") : r2 ? T$2.push("DesktopConnecting") : a2 ? T$2.push("WebConnecting") : t2 ? T$2.push("MobileQrcodeConnecting") : T$2.push("InstallWallet"); - } -}, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; -var Lt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, $e = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Rt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +}, getCustomImageUrls() { + const { walletImages: e2 } = y$4.state, o3 = Object.values(e2 ?? {}); + return Object.values(o3); +}, truncate(e2, o3 = 8) { + return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; +}, setRecentWallet(e2) { + try { + localStorage.setItem(s2.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); + } catch { + console.info("Unable to set recent wallet"); + } +}, getRecentWallet() { + try { + const e2 = localStorage.getItem(s2.WCM_RECENT_WALLET_DATA); + return e2 ? JSON.parse(e2) : void 0; + } catch { + console.info("Unable to get recent wallet"); + } +}, caseSafeIncludes(e2, o3) { + return e2.toUpperCase().includes(o3.toUpperCase()); +}, openWalletExplorerUrl() { + i$1$1.openHref(s2.EXPLORER_WALLET_URL, "_blank"); +}, getCachedRouterWalletPlatforms() { + const { desktop: e2, mobile: o3 } = i$1$1.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a2 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); + return { isDesktop: r2, isMobile: t2, isWeb: a2 }; +}, goToConnectingView(e2) { + T$2.setData({ Wallet: e2 }); + const o3 = i$1$1.isMobile(), { isDesktop: r2, isWeb: a2, isMobile: t2 } = s2.getCachedRouterWalletPlatforms(); + o3 ? t2 ? T$2.push("MobileConnecting") : a2 ? T$2.push("WebConnecting") : T$2.push("InstallWallet") : r2 ? T$2.push("DesktopConnecting") : a2 ? T$2.push("WebConnecting") : t2 ? T$2.push("MobileQrcodeConnecting") : T$2.push("InstallWallet"); +} }, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; +var Pt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Lt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Lt(o3, r2, t2), t2; + return a2 && t2 && Pt(o3, r2, t2), t2; }; -let oe = class extends s { +let le = class extends s$1 { constructor() { super(), this.view = T$2.state.view, this.prevView = T$2.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = T$2.subscribe((e2) => { this.view !== e2.view && this.onChangeRoute(); @@ -3721,10 +3577,10 @@ let oe = class extends s { (e2 = this.unsubscribe) == null || e2.call(this), (o3 = this.resizeObserver) == null || o3.disconnect(); } get routerEl() { - return c.getShadowRootElement(this, ".wcm-router"); + return s2.getShadowRootElement(this, ".wcm-router"); } get contentEl() { - return c.getShadowRootElement(this, ".wcm-content"); + return s2.getShadowRootElement(this, ".wcm-content"); } viewTemplate() { switch (this.view) { @@ -3749,196 +3605,157 @@ let oe = class extends s { } } async onChangeRoute() { - await animate( - this.routerEl, - { opacity: [1, 0], scale: [1, 1.02] }, - { duration: 0.15, delay: 0.1 } - ).finished, this.view = T$2.state.view, animate( - this.routerEl, - { opacity: [0, 1], scale: [0.99, 1] }, - { duration: 0.37, delay: 0.05 } - ); + await animate(this.routerEl, { opacity: [1, 0], scale: [1, 1.02] }, { duration: 0.15, delay: 0.1 }).finished, this.view = T$2.state.view, animate(this.routerEl, { opacity: [0, 1], scale: [0.99, 1] }, { duration: 0.37, delay: 0.05 }); } render() { return x`
${this.viewTemplate()}
`; } }; -oe.styles = [h.globalCss, Mt], $e([t$1()], oe.prototype, "view", 2), $e([t$1()], oe.prototype, "prevView", 2), oe = $e([e$2("wcm-modal-router")], oe); -const At = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; -var Pt = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, ze = (e2, o3, r2, a2) => { +le.styles = [h.globalCss, Mt], Oe([t$1()], le.prototype, "view", 2), Oe([t$1()], le.prototype, "prevView", 2), le = Oe([e$2("wcm-modal-router")], le); +const Rt = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; +var At = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, He = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Tt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Pt(o3, r2, t2), t2; + return a2 && t2 && At(o3, r2, t2), t2; }; -let ne = class extends s { +let de = class extends s$1 { constructor() { - super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = oe$1.subscribe((e2) => { - e2.open ? (this.open = true, this.timeout = setTimeout(() => oe$1.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); + super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = oe$2.subscribe((e2) => { + e2.open ? (this.open = true, this.timeout = setTimeout(() => oe$2.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); }); } disconnectedCallback() { var e2; - (e2 = this.unsubscribe) == null || e2.call(this), clearTimeout(this.timeout), oe$1.closeToast(); + (e2 = this.unsubscribe) == null || e2.call(this), clearTimeout(this.timeout), oe$2.closeToast(); } render() { - const { message: e2, variant: o$12 } = oe$1.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; - return this.open ? x`
${o$12 === "success" ? v.CHECKMARK_ICON : null} ${o$12 === "error" ? v.CROSS_ICON : null}${e2}
` : null; + const { message: e2, variant: o$12 } = oe$2.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; + return this.open ? x`
${o$12 === "success" ? b.CHECKMARK_ICON : null} ${o$12 === "error" ? b.CROSS_ICON : null}${e2}
` : null; } }; -ne.styles = [h.globalCss, At], ze([t$1()], ne.prototype, "open", 2), ne = ze([e$2("wcm-modal-toast")], ne); -const jt = 0.1, Ve = 2.5, A = 7; -function Ce(e2, o3, r2) { +de.styles = [h.globalCss, Rt], He([t$1()], de.prototype, "open", 2), de = He([e$2("wcm-modal-toast")], de); +const jt = 0.1, Ve = 2.5, L2 = 7; +function Ie(e2, o3, r2) { return e2 === o3 ? false : (e2 - o3 < 0 ? o3 - e2 : e2 - o3) <= r2 + jt; } function _t(e2, o3) { - const r2 = Array.prototype.slice.call( - browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, - 0 - ), a2 = Math.sqrt(r2.length); - return r2.reduce( - (t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, - [] - ); + const r2 = Array.prototype.slice.call(browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, 0), a2 = Math.sqrt(r2.length); + return r2.reduce((t2, l2, i2) => (i2 % a2 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, []); } -const Dt = { - generate(e2, o3, r2) { - const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), s2 = o3 / i2.length, $2 = [ - { x: 0, y: 0 }, - { x: 1, y: 0 }, - { x: 0, y: 1 } - ]; - $2.forEach(({ x: y2, y: u3 }) => { - const O = (i2.length - A) * s2 * y2, b$1 = (i2.length - A) * s2 * u3, E2 = 0.45; - for (let M2 = 0; M2 < $2.length; M2 += 1) { - const V2 = s2 * (A - M2 * 2); - l2.push( - b`` - ); +const Dt = { generate(e2, o3, r2) { + const a2 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), c2 = o3 / i2.length, u3 = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }]; + u3.forEach(({ x: $2, y: f2 }) => { + const O = (i2.length - L2) * c2 * $2, x2 = (i2.length - L2) * c2 * f2, E2 = 0.45; + for (let M2 = 0; M2 < u3.length; M2 += 1) { + const Q = c2 * (L2 - M2 * 2); + l2.push(b$1``); + } + }); + const w2 = Math.floor((r2 + 25) / c2), F = i2.length / 2 - w2 / 2, T2 = i2.length / 2 + w2 / 2 - 1, j = []; + i2.forEach(($2, f2) => { + $2.forEach((O, x2) => { + if (i2[f2][x2] && !(f2 < L2 && x2 < L2 || f2 > i2.length - (L2 + 1) && x2 < L2 || f2 < L2 && x2 > i2.length - (L2 + 1)) && !(f2 > F && f2 < T2 && x2 > F && x2 < T2)) { + const E2 = f2 * c2 + c2 / 2, M2 = x2 * c2 + c2 / 2; + j.push([E2, M2]); } }); - const f2 = Math.floor((r2 + 25) / s2), Ne = i2.length / 2 - f2 / 2, Ze = i2.length / 2 + f2 / 2 - 1, Se = []; - i2.forEach((y2, u3) => { - y2.forEach((O, b2) => { - if (i2[u3][b2] && !(u3 < A && b2 < A || u3 > i2.length - (A + 1) && b2 < A || u3 < A && b2 > i2.length - (A + 1)) && !(u3 > Ne && u3 < Ze && b2 > Ne && b2 < Ze)) { - const E2 = u3 * s2 + s2 / 2, M2 = b2 * s2 + s2 / 2; - Se.push([E2, M2]); - } - }); + }); + const oe2 = {}; + return j.forEach(([$2, f2]) => { + oe2[$2] ? oe2[$2].push(f2) : oe2[$2] = [f2]; + }), Object.entries(oe2).map(([$2, f2]) => { + const O = f2.filter((x2) => f2.every((E2) => !Ie(x2, E2, c2))); + return [Number($2), O]; + }).forEach(([$2, f2]) => { + f2.forEach((O) => { + l2.push(b$1``); }); - const J = {}; - return Se.forEach(([y2, u3]) => { - J[y2] ? J[y2].push(u3) : J[y2] = [u3]; - }), Object.entries(J).map(([y2, u3]) => { - const O = u3.filter((b2) => u3.every((E2) => !Ce(b2, E2, s2))); - return [Number(y2), O]; - }).forEach(([y2, u3]) => { - u3.forEach((O) => { - l2.push( - b`` - ); - }); - }), Object.entries(J).filter(([y2, u3]) => u3.length > 1).map(([y2, u3]) => { - const O = u3.filter((b2) => u3.some((E2) => Ce(b2, E2, s2))); - return [Number(y2), O]; - }).map(([y2, u3]) => { - u3.sort((b2, E2) => b2 < E2 ? -1 : 1); - const O = []; - for (const b2 of u3) { - const E2 = O.find((M2) => M2.some((V2) => Ce(b2, V2, s2))); - E2 ? E2.push(b2) : O.push([b2]); - } - return [y2, O.map((b2) => [b2[0], b2[b2.length - 1]])]; - }).forEach(([y2, u3]) => { - u3.forEach(([O, b$1]) => { - l2.push( - b`` - ); - }); - }), l2; - } -}, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; -var Zt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, q = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? St(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + }), Object.entries(oe2).filter(([$2, f2]) => f2.length > 1).map(([$2, f2]) => { + const O = f2.filter((x2) => f2.some((E2) => Ie(x2, E2, c2))); + return [Number($2), O]; + }).map(([$2, f2]) => { + f2.sort((x2, E2) => x2 < E2 ? -1 : 1); + const O = []; + for (const x2 of f2) { + const E2 = O.find((M2) => M2.some((Q) => Ie(x2, Q, c2))); + E2 ? E2.push(x2) : O.push([x2]); + } + return [$2, O.map((x2) => [x2[0], x2[x2.length - 1]])]; + }).forEach(([$2, f2]) => { + f2.forEach(([O, x2]) => { + l2.push(b$1``); + }); + }), l2; +} }, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; +var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Y = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zt(o3, r2, t2), t2; }; -let j = class extends s { +let D = class extends s$1 { constructor() { super(...arguments), this.uri = "", this.size = 0, this.imageId = void 0, this.walletId = void 0, this.imageUrl = void 0; } svgTemplate() { - const e2 = ne$1.state.themeMode === "light" ? this.size : this.size - 36; - return b`${Dt.generate(this.uri, e2, e2 / 4)}`; + const e2 = ne$3.state.themeMode === "light" ? this.size : this.size - 36; + return b$1`${Dt.generate(this.uri, e2, e2 / 4)}`; } render() { - const e2 = { "wcm-dark": ne$1.state.themeMode === "dark" }; - return x`
${this.walletId || this.imageUrl ? x`` : v.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; + const e2 = { "wcm-dark": ne$3.state.themeMode === "dark" }; + return x`
${this.walletId || this.imageUrl ? x`` : b.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; } }; -j.styles = [h.globalCss, Nt], q([n$1()], j.prototype, "uri", 2), q([n$1({ type: Number })], j.prototype, "size", 2), q([n$1()], j.prototype, "imageId", 2), q([n$1()], j.prototype, "walletId", 2), q([n$1()], j.prototype, "imageUrl", 2), j = q([e$2("wcm-qrcode")], j); -const Bt = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; -var Ut = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +D.styles = [h.globalCss, Nt], Y([n$1()], D.prototype, "uri", 2), Y([n$1({ type: Number })], D.prototype, "size", 2), Y([n$1()], D.prototype, "imageId", 2), Y([n$1()], D.prototype, "walletId", 2), Y([n$1()], D.prototype, "imageUrl", 2), D = Y([e$2("wcm-qrcode")], D); +const St = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; +var Bt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ut(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ut(o3, r2, t2), t2; + return a2 && t2 && Bt(o3, r2, t2), t2; }; -let ce = class extends s { +let me = class extends s$1 { constructor() { super(...arguments), this.onChange = () => null; } render() { - return x` ${v.SEARCH_ICON}`; + return x` ${b.SEARCH_ICON}`; } }; -ce.styles = [h.globalCss, Bt], Fe([n$1()], ce.prototype, "onChange", 2), ce = Fe([e$2("wcm-search-input")], ce); -const zt = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; -var Vt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, qt = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ft(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Vt(o3, r2, t2), t2; +me.styles = [h.globalCss, St], qe([n$1()], me.prototype, "onChange", 2), me = qe([e$2("wcm-search-input")], me); +const Ht = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; +var Ft = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let ke = class extends s { +let We = class extends s$1 { render() { return x``; } }; -ke.styles = [h.globalCss, zt], ke = qt([e$2("wcm-spinner")], ke); +We.styles = [h.globalCss, Ht], We = Ft([e$2("wcm-spinner")], We); const Qt = i$3`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`; -var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a2) => { +var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Ee = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Yt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Kt(o3, r2, t2), t2; }; -let re = class extends s { +let ie = class extends s$1 { constructor() { super(...arguments), this.variant = "medium-regular", this.color = "primary"; } render() { - const e2 = { - "wcm-big-bold": this.variant === "big-bold", - "wcm-medium-regular": this.variant === "medium-regular", - "wcm-small-regular": this.variant === "small-regular", - "wcm-small-thin": this.variant === "small-thin", - "wcm-xsmall-regular": this.variant === "xsmall-regular", - "wcm-xsmall-bold": this.variant === "xsmall-bold", - "wcm-color-primary": this.color === "primary", - "wcm-color-secondary": this.color === "secondary", - "wcm-color-tertiary": this.color === "tertiary", - "wcm-color-inverse": this.color === "inverse", - "wcm-color-accnt": this.color === "accent", - "wcm-color-error": this.color === "error" - }; + const e2 = { "wcm-big-bold": this.variant === "big-bold", "wcm-medium-regular": this.variant === "medium-regular", "wcm-small-regular": this.variant === "small-regular", "wcm-small-thin": this.variant === "small-thin", "wcm-xsmall-regular": this.variant === "xsmall-regular", "wcm-xsmall-bold": this.variant === "xsmall-bold", "wcm-color-primary": this.color === "primary", "wcm-color-secondary": this.color === "secondary", "wcm-color-tertiary": this.color === "tertiary", "wcm-color-inverse": this.color === "inverse", "wcm-color-accnt": this.color === "accent", "wcm-color-error": this.color === "error" }; return x``; } }; -re.styles = [h.globalCss, Qt], Oe([n$1()], re.prototype, "variant", 2), Oe([n$1()], re.prototype, "color", 2), re = Oe([e$2("wcm-text")], re); +ie.styles = [h.globalCss, Qt], Ee([n$1()], ie.prototype, "variant", 2), Ee([n$1()], ie.prototype, "color", 2), ie = Ee([e$2("wcm-text")], ie); const Gt = i$3`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`; -var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, _ = (e2, o3, r2, a2) => { +var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, N2 = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xt(o3, r2, t2), t2; }; -let L2 = class extends s { +let P = class extends s$1 { constructor() { super(...arguments), this.onClick = () => null, this.name = "", this.walletId = "", this.label = void 0, this.imageId = void 0, this.installed = false, this.recent = false; } @@ -3950,75 +3767,72 @@ let L2 = class extends s { } render() { var e2; - return x``; + return x``; } }; -L2.styles = [h.globalCss, Gt], _([n$1()], L2.prototype, "onClick", 2), _([n$1()], L2.prototype, "name", 2), _([n$1()], L2.prototype, "walletId", 2), _([n$1()], L2.prototype, "label", 2), _([n$1()], L2.prototype, "imageId", 2), _([n$1({ type: Boolean })], L2.prototype, "installed", 2), _([n$1({ type: Boolean })], L2.prototype, "recent", 2), L2 = _([e$2("wcm-wallet-button")], L2); +P.styles = [h.globalCss, Gt], N2([n$1()], P.prototype, "onClick", 2), N2([n$1()], P.prototype, "name", 2), N2([n$1()], P.prototype, "walletId", 2), N2([n$1()], P.prototype, "label", 2), N2([n$1()], P.prototype, "imageId", 2), N2([n$1({ type: Boolean })], P.prototype, "installed", 2), N2([n$1({ type: Boolean })], P.prototype, "recent", 2), P = N2([e$2("wcm-wallet-button")], P); const eo = i$3`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a2) => { +var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, we = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? oo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && to(o3, r2, t2), t2; }; -let Q = class extends s { +let G = class extends s$1 { constructor() { super(...arguments), this.walletId = "", this.imageId = void 0, this.imageUrl = void 0; } render() { var e2; - const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : c.getWalletIcon({ id: this.walletId, image_id: this.imageId }); - return x`${o3.length ? x`
${this.id}
` : v.WALLET_PLACEHOLDER}`; + const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : s2.getWalletIcon({ id: this.walletId, image_id: this.imageId }); + return x`${o3.length ? x`
${this.id}
` : b.WALLET_PLACEHOLDER}`; } }; -Q.styles = [h.globalCss, eo], se([n$1()], Q.prototype, "walletId", 2), se([n$1()], Q.prototype, "imageId", 2), se([n$1()], Q.prototype, "imageUrl", 2), Q = se([e$2("wcm-wallet-image")], Q); -var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a2) => { +G.styles = [h.globalCss, eo], we([n$1()], G.prototype, "walletId", 2), we([n$1()], G.prototype, "imageId", 2), we([n$1()], G.prototype, "imageUrl", 2), G = we([e$2("wcm-wallet-image")], G); +var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && ro(o3, r2, t2), t2; }; -let We = class extends s { +let Me = class extends s$1 { constructor() { super(), this.preload = true, this.preloadData(); } async loadImages(e2) { try { - e2 != null && e2.length && await Promise.all(e2.map(async (o3) => c.preloadImage(o3))); + e2 != null && e2.length && await Promise.all(e2.map(async (o3) => s2.preloadImage(o3))); } catch { console.info("Unsuccessful attempt at preloading some images", e2); } } async preloadListings() { - if (y$1.state.enableExplorer) { - await te$1.getRecomendedWallets(), p$1.setIsDataLoaded(true); - const { recomendedWallets: e2 } = te$1.state, o3 = e2.map((r2) => c.getWalletIcon(r2)); + if (y$4.state.enableExplorer) { + await te$1.getRecomendedWallets(), p$2.setIsDataLoaded(true); + const { recomendedWallets: e2 } = te$1.state, o3 = e2.map((r2) => s2.getWalletIcon(r2)); await this.loadImages(o3); } else - p$1.setIsDataLoaded(true); + p$2.setIsDataLoaded(true); } async preloadCustomImages() { - const e2 = c.getCustomImageUrls(); + const e2 = s2.getCustomImageUrls(); await this.loadImages(e2); } async preloadData() { try { - this.preload && (this.preload = false, await Promise.all([ - this.preloadListings(), - this.preloadCustomImages() - ])); + this.preload && (this.preload = false, await Promise.all([this.preloadListings(), this.preloadCustomImages()])); } catch (e2) { - console.error(e2), oe$1.openToast("Failed preloading", "error"); + console.error(e2), oe$2.openToast("Failed preloading", "error"); } } }; -qe([t$1()], We.prototype, "preload", 2), We = qe([e$2("wcm-explorer-context")], We); -var lo = Object.defineProperty, io = Object.getOwnPropertyDescriptor, no = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? io(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && lo(o3, r2, t2), t2; +Fe([t$1()], Me.prototype, "preload", 2), Me = Fe([e$2("wcm-explorer-context")], Me); +var no = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Qe = class extends s { +let Qe = class extends s$1 { constructor() { - super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = ne$1.subscribe(h.setTheme); + super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = ne$3.subscribe(h.setTheme); } disconnectedCallback() { var e2; @@ -4027,42 +3841,40 @@ let Qe = class extends s { }; Qe = no([e$2("wcm-theme-context")], Qe); const co = i$3`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var so = Object.defineProperty, mo = Object.getOwnPropertyDescriptor, ho = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? mo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && so(o3, r2, t2), t2; +var wo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ie = class extends s { +let Pe = class extends s$1 { onConnect(e2) { - a$2.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + i$1$1.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onGoToQrcode() { T$2.push("Qrcode"); } render() { - const { recomendedWallets: e2 } = te$1.state, o3 = [...e2, ...e2], r2 = a$2.RECOMMENDED_WALLET_AMOUNT * 2; - return x`
${v.MOBILE_ICON}WalletConnect
${[ - ...Array(r2) - ].map((a2, t2) => { + const { recomendedWallets: e2 } = te$1.state, o3 = [...e2, ...e2], r2 = i$1$1.RECOMMENDED_WALLET_AMOUNT * 2; + return x`
${b.MOBILE_ICON}WalletConnect
${[...Array(r2)].map((a2, t2) => { const l2 = o3[t2 % o3.length]; - return l2 ? x`` : v.WALLET_PLACEHOLDER; + return l2 ? x`` : b.WALLET_PLACEHOLDER; })}
Select Wallet
Choose WalletConnect to see supported apps on your device`; } }; -Ie.styles = [h.globalCss, co], Ie = ho([e$2("wcm-android-wallet-selection")], Ie); -const wo = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; -var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a2) => { +Pe.styles = [h.globalCss, co], Pe = wo([e$2("wcm-android-wallet-selection")], Pe); +const ho = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; +var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, X = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? go(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && po(o3, r2, t2), t2; }; -let D = class extends s { +let Z2 = class extends s$1 { constructor() { super(...arguments), this.walletId = void 0, this.imageId = void 0, this.isError = false, this.isStale = false, this.label = ""; } svgLoaderTemplate() { var e2, o3; - const r2 = (o3 = (e2 = ne$1.state.themeVariables) == null ? void 0 : e2["--wcm-wallet-icon-large-border-radius"]) != null ? o3 : h.getPreset("--wcm-wallet-icon-large-border-radius"); + const r2 = (o3 = (e2 = ne$3.state.themeVariables) == null ? void 0 : e2["--wcm-wallet-icon-large-border-radius"]) != null ? o3 : h.getPreset("--wcm-wallet-icon-large-border-radius"); let a2 = 0; r2.includes("%") ? a2 = 88 / 100 * parseInt(r2, 10) : a2 = parseInt(r2, 10), a2 *= 1.17; const t2 = 317 - a2 * 1.57, l2 = 425 - a2 * 1.8; @@ -4073,113 +3885,90 @@ let D = class extends s { return x`
${this.svgLoaderTemplate()}
${this.isError ? "Connection declined" : this.label}`; } }; -D.styles = [h.globalCss, wo], K([n$1()], D.prototype, "walletId", 2), K([n$1()], D.prototype, "imageId", 2), K([n$1({ type: Boolean })], D.prototype, "isError", 2), K([n$1({ type: Boolean })], D.prototype, "isStale", 2), K([n$1()], D.prototype, "label", 2), D = K([e$2("wcm-connector-waiting")], D); -const G = { - manualWallets() { - var e2, o3; - const { mobileWallets: r2, desktopWallets: a2 } = y$1.state, t2 = (e2 = G.recentWallet()) == null ? void 0 : e2.id, l2 = a$2.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((s2) => t2 !== s2.id); - return (o3 = a$2.isMobile() ? i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - mobile: f2, - links: f2 - })) : i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - desktop: f2, - links: f2 - }))) != null ? o3 : []; - }, - recentWallet() { - return c.getRecentWallet(); - }, - recomendedWallets(e2 = false) { - var o3; - const r2 = e2 || (o3 = G.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a2 } = te$1.state; - return a2.filter((t2) => r2 !== t2.id); - } -}, Z2 = { - onConnecting(e2) { - c.goToConnectingView(e2); - }, - manualWalletsTemplate() { - return G.manualWallets().map( - (e2) => x`` - ); - }, - recomendedWalletsTemplate(e2 = false) { - return G.recomendedWallets(e2).map( - (o3) => x`` - ); - }, - recentWalletTemplate() { - const e2 = G.recentWallet(); - if (e2) - return x``; - } -}, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; -var uo = Object.defineProperty, bo = Object.getOwnPropertyDescriptor, fo = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? bo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && uo(o3, r2, t2), t2; +Z2.styles = [h.globalCss, ho], X([n$1()], Z2.prototype, "walletId", 2), X([n$1()], Z2.prototype, "imageId", 2), X([n$1({ type: Boolean })], Z2.prototype, "isError", 2), X([n$1({ type: Boolean })], Z2.prototype, "isStale", 2), X([n$1()], Z2.prototype, "label", 2), Z2 = X([e$2("wcm-connector-waiting")], Z2); +const ee = { manualWallets() { + var e2, o3; + const { mobileWallets: r2, desktopWallets: a2 } = y$4.state, t2 = (e2 = ee.recentWallet()) == null ? void 0 : e2.id, l2 = i$1$1.isMobile() ? r2 : a2, i2 = l2 == null ? void 0 : l2.filter((c2) => t2 !== c2.id); + return (o3 = i$1$1.isMobile() ? i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w2 }) => ({ id: c2, name: u3, mobile: w2, links: w2 })) : i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w2 }) => ({ id: c2, name: u3, desktop: w2, links: w2 }))) != null ? o3 : []; +}, recentWallet() { + return s2.getRecentWallet(); +}, recomendedWallets(e2 = false) { + var o3; + const r2 = e2 || (o3 = ee.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a2 } = te$1.state; + return a2.filter((t2) => r2 !== t2.id); +} }, S = { onConnecting(e2) { + s2.goToConnectingView(e2); +}, manualWalletsTemplate() { + return ee.manualWallets().map((e2) => x``); +}, recomendedWalletsTemplate(e2 = false) { + return ee.recomendedWallets(e2).map((o3) => x``); +}, recentWalletTemplate() { + const e2 = ee.recentWallet(); + if (e2) + return x``; +} }, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; +var fo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ee = class extends s { +let Le = class extends s$1 { render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$1.state, r2 = e2 !== "ALL" && o3, a2 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$4.state, r2 = e2 !== "ALL" && o3, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 4 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 3) : s2 = l2; - const $2 = Boolean(s2.length); - return x`
${v.MOBILE_ICON}Mobile
${v.SCAN_ICON}Scan with your wallet
${$2 ? x`
${v.DESKTOP_ICON}Desktop
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 3) : c2 = l2; + const u3 = Boolean(c2.length); + return x`
${b.MOBILE_ICON}Mobile
${b.SCAN_ICON}Scan with your wallet
${u3 ? x`
${b.DESKTOP_ICON}Desktop
${c2} ${i2 ? x`` : null}
` : null}`; } }; -Ee.styles = [h.globalCss, vo], Ee = fo([e$2("wcm-desktop-wallet-selection")], Ee); +Le.styles = [h.globalCss, vo], Le = fo([e$2("wcm-desktop-wallet-selection")], Le); const xo = i$3`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`; -var yo = Object.defineProperty, $o = Object.getOwnPropertyDescriptor, Co = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? $o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && yo(o3, r2, t2), t2; +var Co = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Me = class extends s { +let Re = class extends s$1 { render() { - const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = y$1.state; + const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = y$4.state; return e2 ?? o3 ? x`
By connecting your wallet to this app, you agree to the app's ${e2 ? x`Terms of Service` : null} ${e2 && o3 ? "and" : null} ${o3 ? x`Privacy Policy` : null}
` : null; } }; -Me.styles = [h.globalCss, xo], Me = Co([e$2("wcm-legal-notice")], Me); +Re.styles = [h.globalCss, xo], Re = Co([e$2("wcm-legal-notice")], Re); const ko = i$3`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`; -var Oo = Object.defineProperty, Wo = Object.getOwnPropertyDescriptor, Io = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Wo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Oo(o3, r2, t2), t2; +var Wo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Le = class extends s { +let Ae = class extends s$1 { onQrcode() { T$2.push("Qrcode"); } render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$1.state, r2 = e2 !== "ALL" && o3, a2 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a2, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$4.state, r2 = e2 !== "ALL" && o3, a2 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a2, ...t2]; l2 = l2.filter(Boolean); const i2 = l2.length > 8 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 7) : s2 = l2; - const $2 = Boolean(s2.length); - return x`${$2 ? x`
${s2} ${i2 ? x`` : null}
` : null}`; + let c2 = []; + i2 ? c2 = l2.slice(0, 7) : c2 = l2; + const u3 = Boolean(c2.length); + return x`${u3 ? x`
${c2} ${i2 ? x`` : null}
` : null}`; } }; -Le.styles = [h.globalCss, ko], Le = Io([e$2("wcm-mobile-wallet-selection")], Le); +Ae.styles = [h.globalCss, ko], Ae = Wo([e$2("wcm-mobile-wallet-selection")], Ae); const Eo = i$3`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`; -var Mo = Object.defineProperty, Lo = Object.getOwnPropertyDescriptor, Re = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Lo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var Mo = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, Te = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Mo(o3, r2, t2), t2; }; -let ae = class extends s { +let ne = class extends s$1 { constructor() { - super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = se$1.subscribe((e2) => { + super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = se$3.subscribe((e2) => { e2.open ? this.onOpenModalEvent() : this.onCloseModalEvent(); }); } @@ -4188,10 +3977,10 @@ let ae = class extends s { (e2 = this.unsubscribeModal) == null || e2.call(this); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-overlay"); + return s2.getShadowRootElement(this, ".wcm-overlay"); } get containerEl() { - return c.getShadowRootElement(this, ".wcm-container"); + return s2.getShadowRootElement(this, ".wcm-container"); } toggleBodyScroll(e2) { if (document.querySelector("body")) @@ -4199,40 +3988,27 @@ let ae = class extends s { const o3 = document.getElementById("wcm-styles"); o3 == null ? void 0 : o3.remove(); } else - document.head.insertAdjacentHTML( - "beforeend", - '' - ); + document.head.insertAdjacentHTML("beforeend", ''); } onCloseModal(e2) { - e2.target === e2.currentTarget && se$1.close(); + e2.target === e2.currentTarget && se$3.close(); } onOpenModalEvent() { this.toggleBodyScroll(false), this.addKeyboardEvents(), this.open = true, setTimeout(async () => { - const e2 = c.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, - animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished - ]), this.active = true; + const e2 = s2.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished]), this.active = true; }, 0); } async onCloseModalEvent() { this.toggleBodyScroll(true), this.removeKeyboardEvents(); - const e2 = c.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, - animate(this.containerEl, e2, { duration: o3 }).finished - ]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; + const e2 = s2.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, animate(this.containerEl, e2, { duration: o3 }).finished]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; } addKeyboardEvents() { - this.abortController = new AbortController(), window.addEventListener( - "keydown", - (e2) => { - var o3; - e2.key === "Escape" ? se$1.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); - }, - this.abortController - ), this.containerEl.focus(); + this.abortController = new AbortController(), window.addEventListener("keydown", (e2) => { + var o3; + e2.key === "Escape" ? se$3.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); + }, this.abortController), this.containerEl.focus(); } removeKeyboardEvents() { var e2; @@ -4243,19 +4019,19 @@ let ae = class extends s { return x`
${this.open ? x`
` : null}
`; } }; -ae.styles = [h.globalCss, Eo], Re([t$1()], ae.prototype, "open", 2), Re([t$1()], ae.prototype, "active", 2), ae = Re([e$2("wcm-modal")], ae); -const Ro = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; -var Ao = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, le = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +ne.styles = [h.globalCss, Eo], Te([t$1()], ne.prototype, "open", 2), Te([t$1()], ne.prototype, "active", 2), ne = Te([e$2("wcm-modal")], ne); +const Lo = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; +var Ro = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, ce = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? Ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Ao(o3, r2, t2), t2; + return a2 && t2 && Ro(o3, r2, t2), t2; }; -let B = class extends s { +let U = class extends s$1 { constructor() { super(...arguments), this.isMobile = false, this.isDesktop = false, this.isWeb = false, this.isRetry = false; } onMobile() { - a$2.isMobile() ? T$2.replace("MobileConnecting") : T$2.replace("MobileQrcodeConnecting"); + i$1$1.isMobile() ? T$2.replace("MobileConnecting") : T$2.replace("MobileQrcodeConnecting"); } onDesktop() { T$2.replace("DesktopConnecting"); @@ -4264,190 +4040,191 @@ let B = class extends s { T$2.replace("WebConnecting"); } render() { - return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; + return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; } }; -B.styles = [h.globalCss, Ro], le([n$1({ type: Boolean })], B.prototype, "isMobile", 2), le([n$1({ type: Boolean })], B.prototype, "isDesktop", 2), le([n$1({ type: Boolean })], B.prototype, "isWeb", 2), le([n$1({ type: Boolean })], B.prototype, "isRetry", 2), B = le([e$2("wcm-platform-selection")], B); +U.styles = [h.globalCss, Lo], ce([n$1({ type: Boolean })], U.prototype, "isMobile", 2), ce([n$1({ type: Boolean })], U.prototype, "isDesktop", 2), ce([n$1({ type: Boolean })], U.prototype, "isWeb", 2), ce([n$1({ type: Boolean })], U.prototype, "isRetry", 2), U = ce([e$2("wcm-platform-selection")], U); const To = i$3`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -var jo = Object.defineProperty, _o = Object.getOwnPropertyDescriptor, Do = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? _o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && jo(o3, r2, t2), t2; +var Do = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Ae = class extends s { +let je = class extends s$1 { onClick() { T$2.push("WalletExplorer"); } render() { - const { recomendedWallets: e2 } = te$1.state, o3 = G.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); - return x``; + const { recomendedWallets: e2 } = te$1.state, o3 = ee.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); + return x``; } }; -Ae.styles = [h.globalCss, To], Ae = Do([e$2("wcm-view-all-wallets-button")], Ae); +je.styles = [h.globalCss, To], je = Do([e$2("wcm-view-all-wallets-button")], je); const No = i$3`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`; -var Zo = Object.defineProperty, So = Object.getOwnPropertyDescriptor, de = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? So(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var Zo = Object.defineProperty, zo = Object.getOwnPropertyDescriptor, he = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? zo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Zo(o3, r2, t2), t2; }; -let Y = class extends s { +let J = class extends s$1 { constructor() { super(), this.walletId = "", this.imageId = "", this.uri = "", setTimeout(() => { - const { walletConnectUri: e2 } = p$1.state; + const { walletConnectUri: e2 } = p$2.state; this.uri = e2; }, 0); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-qr-container"); + return s2.getShadowRootElement(this, ".wcm-qr-container"); } render() { return x`
${this.uri ? x`` : x``}
`; } }; -Y.styles = [h.globalCss, No], de([n$1()], Y.prototype, "walletId", 2), de([n$1()], Y.prototype, "imageId", 2), de([t$1()], Y.prototype, "uri", 2), Y = de([e$2("wcm-walletconnect-qr")], Y); -var Bo = Object.defineProperty, Uo = Object.getOwnPropertyDescriptor, Ho = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Uo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Bo(o3, r2, t2), t2; +J.styles = [h.globalCss, No], he([n$1()], J.prototype, "walletId", 2), he([n$1()], J.prototype, "imageId", 2), he([t$1()], J.prototype, "uri", 2), J = he([e$2("wcm-walletconnect-qr")], J); +var Uo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Pe = class extends s { +let _e = class extends s$1 { viewTemplate() { - return a$2.isAndroid() ? x`` : a$2.isMobile() ? x`` : x``; + return i$1$1.isAndroid() ? x`` : i$1$1.isMobile() ? x`` : x``; } render() { return x`${this.viewTemplate()}`; } }; -Pe.styles = [h.globalCss], Pe = Ho([e$2("wcm-connect-wallet-view")], Pe); -const zo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var Vo = Object.defineProperty, Fo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Fo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +_e.styles = [h.globalCss], _e = Uo([e$2("wcm-connect-wallet-view")], _e); +const Ho = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; +var Vo = Object.defineProperty, qo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? qo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Vo(o3, r2, t2), t2; }; -let me = class extends s { +let pe = class extends s$1 { constructor() { super(), this.isError = false, this.openDesktopApp(); } onFormatAndRedirect(e2) { - const { desktop: o3, name: r2 } = a$2.getWalletRouterData(), a2 = o3 == null ? void 0 : o3.native; - if (a2) { - const t2 = a$2.formatNativeUrl(a2, e2, r2); - a$2.openHref(t2, "_self"); + var o3; + const { desktop: r2, name: a2 } = i$1$1.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native; + if (t2) { + const l2 = i$1$1.formatNativeUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + i$1$1.openHref(l2, "_self"); } } openDesktopApp() { - const { walletConnectUri: e2 } = p$1.state, o3 = a$2.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = p$2.state, o3 = i$1$1.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = a$2.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; + const { name: e2, id: o3, image_id: r2 } = i$1$1.getWalletRouterData(), { isMobile: a2, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; } }; -me.styles = [h.globalCss, zo], Ke([t$1()], me.prototype, "isError", 2), me = Ke([e$2("wcm-desktop-connecting-view")], me); -const qo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; -var Qo = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, Yo = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? Ko(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && Qo(o3, r2, t2), t2; +pe.styles = [h.globalCss, Ho], Ke([t$1()], pe.prototype, "isError", 2), pe = Ke([e$2("wcm-desktop-connecting-view")], pe); +const Fo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; +var Yo = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let Te = class extends s { +let De = class extends s$1 { onInstall(e2) { - e2 && a$2.openHref(e2, "_blank"); + e2 && i$1$1.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - homepage: a2 - } = a$2.getWalletRouterData(); - return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; + const { name: e2, id: o3, image_id: r2, homepage: a2 } = i$1$1.getWalletRouterData(); + return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; } }; -Te.styles = [h.globalCss, qo], Te = Yo([e$2("wcm-install-wallet-view")], Te); +De.styles = [h.globalCss, Fo], De = Yo([e$2("wcm-install-wallet-view")], De); const Go = i$3`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`; var Xo = Object.defineProperty, Jo = Object.getOwnPropertyDescriptor, Ye = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? Jo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && Xo(o3, r2, t2), t2; }; -let he = class extends s { +let ge = class extends s$1 { constructor() { super(), this.isError = false, this.openMobileApp(); } onFormatAndRedirect(e2, o3 = false) { - const { mobile: r2, name: a2 } = a$2.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - if (t2 && !o3) { - const i2 = a$2.formatNativeUrl(t2, e2, a2); - a$2.openHref(i2, "_self"); - } else if (l2) { - const i2 = a$2.formatUniversalUrl(l2, e2, a2); - a$2.openHref(i2, "_self"); + var r2, a2; + const { mobile: t2, name: l2 } = i$1$1.getWalletRouterData(), i2 = t2 == null ? void 0 : t2.native, c2 = t2 == null ? void 0 : t2.universal; + if (i2 && !o3) { + const u3 = i$1$1.formatNativeUrl(i2, e2, l2); + if (l2 === "Puzzle Wallet" && (r2 = window == null ? void 0 : window.aleo) != null && r2.connectPuzzle) { + const w2 = new URL(u3).searchParams, F = w2.get("uri"), T2 = w2.get("requestId"), j = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F, requestId: T2 ?? void 0, sessionTopic: j ?? void 0 } }); + } else + i$1$1.openHref(u3, "_self"); + } else if (c2) { + const u3 = i$1$1.formatUniversalUrl(c2, e2, l2); + if (l2 === "Puzzle Wallet" && (a2 = window == null ? void 0 : window.aleo) != null && a2.connectPuzzle) { + const w2 = new URL(u3).searchParams, F = w2.get("uri"), T2 = w2.get("requestId"), j = w2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F, requestId: T2 ?? void 0, sessionTopic: j ?? void 0 } }); + } else + i$1$1.openHref(u3, "_self"); } } openMobileApp(e2 = false) { - const { walletConnectUri: o3 } = p$1.state, r2 = a$2.getWalletRouterData(); - c.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); + const { walletConnectUri: o3 } = p$2.state, r2 = i$1$1.getWalletRouterData(); + s2.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); } onGoToAppStore(e2) { - e2 && a$2.openHref(e2, "_blank"); + e2 && i$1$1.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - app: a2, - mobile: t2 - } = a$2.getWalletRouterData(), { isWeb: l$12 } = c.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, s2 = t2 == null ? void 0 : t2.universal; - return x`Retry${s2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; + const { name: e2, id: o3, image_id: r2, app: a2, mobile: t2 } = i$1$1.getWalletRouterData(), { isWeb: l$12 } = s2.getCachedRouterWalletPlatforms(), i2 = a2 == null ? void 0 : a2.ios, c2 = t2 == null ? void 0 : t2.universal; + return x`Retry${c2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; } }; -he.styles = [h.globalCss, Go], Ye([t$1()], he.prototype, "isError", 2), he = Ye([e$2("wcm-mobile-connecting-view")], he); +ge.styles = [h.globalCss, Go], Ye([t$1()], ge.prototype, "isError", 2), ge = Ye([e$2("wcm-mobile-connecting-view")], ge); const er = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var tr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, rr = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? or(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && tr(o3, r2, t2), t2; +var rr = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let je = class extends s { +let Ne = class extends s$1 { render() { - const { name: e2, id: o3, image_id: r2 } = a$2.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; + const { name: e2, id: o3, image_id: r2 } = i$1$1.getWalletRouterData(), { isDesktop: a2, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; } }; -je.styles = [h.globalCss, er], je = rr([e$2("wcm-mobile-qr-connecting-view")], je); -var ar = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, ir = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? lr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a2 && t2 && ar(o3, r2, t2), t2; +Ne.styles = [h.globalCss, er], Ne = rr([e$2("wcm-mobile-qr-connecting-view")], Ne); +var ir = (e2, o3, r2, a2) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; -let _e = class extends s { +let Ze = class extends s$1 { render() { - return x``; + return x``; } }; -_e.styles = [h.globalCss], _e = ir([e$2("wcm-qrcode-view")], _e); +Ze.styles = [h.globalCss], Ze = ir([e$2("wcm-qrcode-view")], Ze); const nr = i$3`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`; -var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, ie = (e2, o3, r2, a2) => { +var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a2) => { for (var t2 = a2 > 1 ? void 0 : a2 ? sr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && cr(o3, r2, t2), t2; }; -const De = 40; -let U = class extends s { +const ze = 40; +let H2 = class extends s$1 { constructor() { - super(...arguments), this.loading = !te$1.state.wallets.listings.length, this.firstFetch = !te$1.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = c.debounce((e2) => { + super(...arguments), this.loading = !te$1.state.wallets.listings.length, this.firstFetch = !te$1.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = s2.debounce((e2) => { e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, te$1.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), te$1.resetSearch()); }); } @@ -4459,7 +4236,7 @@ let U = class extends s { (e2 = this.intersectionObserver) == null || e2.disconnect(); } get placeholderEl() { - return c.getShadowRootElement(this, ".wcm-placeholder-block"); + return s2.getShadowRootElement(this, ".wcm-placeholder-block"); } createPaginationObserver() { this.intersectionObserver = new IntersectionObserver(([e2]) => { @@ -4468,33 +4245,24 @@ let U = class extends s { } isLastPage() { const { wallets: e2, search: o3 } = te$1.state, { listings: r2, total: a2 } = this.search ? o3 : e2; - return a2 <= De || r2.length >= a2; + return a2 <= ze || r2.length >= a2; } async fetchWallets() { var e2; const { wallets: o3, search: r2 } = te$1.state, { listings: a2, total: t2, page: l2 } = this.search ? r2 : o3; - if (!this.endReached && (this.firstFetch || t2 > De && a2.length < t2)) + if (!this.endReached && (this.firstFetch || t2 > ze && a2.length < t2)) try { this.loading = true; - const i2 = (e2 = p$1.state.chains) == null ? void 0 : e2.join(","), { listings: s2 } = await te$1.getWallets({ - page: this.firstFetch ? 1 : l2 + 1, - entries: De, - search: this.search, - version: 2, - chains: i2 - }), $2 = s2.map((f2) => c.getWalletIcon(f2)); - await Promise.all([ - ...$2.map(async (f2) => c.preloadImage(f2)), - a$2.wait(300) - ]), this.endReached = this.isLastPage(); + const i2 = (e2 = p$2.state.chains) == null ? void 0 : e2.join(","), { listings: c2 } = await te$1.getWallets({ page: this.firstFetch ? 1 : l2 + 1, entries: ze, search: this.search, version: 2, chains: i2 }), u3 = c2.map((w2) => s2.getWalletIcon(w2)); + await Promise.all([...u3.map(async (w2) => s2.preloadImage(w2)), i$1$1.wait(300)]), this.endReached = this.isLastPage(); } catch (i2) { - console.error(i2), oe$1.openToast(c.getErrorMessage(i2), "error"); + console.error(i2), oe$2.openToast(s2.getErrorMessage(i2), "error"); } finally { this.loading = false, this.firstFetch = false; } } onConnect(e2) { - a$2.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + i$1$1.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onSearchChange(e2) { const { value: o3 } = e2.target; @@ -4502,61 +4270,46 @@ let U = class extends s { } render() { const { wallets: e2, search: o$12 } = te$1.state, { listings: r2 } = this.search ? o$12 : e2, a2 = this.loading && !r2.length, t2 = this.search.length >= 3; - let l2 = Z2.manualWalletsTemplate(), i2 = Z2.recomendedWalletsTemplate(true); - t2 && (l2 = l2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search)), i2 = i2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search))); - const s2 = !this.loading && !r2.length && !i2.length, $2 = { - "wcm-loading": a2, - "wcm-end-reached": this.endReached || !this.loading, - "wcm-empty": s2 - }; - return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((f2) => x`${f2 ? x`` : null}`)}
${s2 ? x`No results found` : null} ${!s2 && this.loading ? x`` : null}
`; + let l2 = S.manualWalletsTemplate(), i2 = S.recomendedWalletsTemplate(true); + t2 && (l2 = l2.filter(({ values: w2 }) => s2.caseSafeIncludes(w2[0], this.search)), i2 = i2.filter(({ values: w2 }) => s2.caseSafeIncludes(w2[0], this.search))); + const c2 = !this.loading && !r2.length && !i2.length, u3 = { "wcm-loading": a2, "wcm-end-reached": this.endReached || !this.loading, "wcm-empty": c2 }; + return x`
${a2 ? null : l2} ${a2 ? null : i2} ${a2 ? null : r2.map((w2) => x`${w2 ? x`` : null}`)}
${c2 ? x`No results found` : null} ${!c2 && this.loading ? x`` : null}
`; } }; -U.styles = [h.globalCss, nr], ie([t$1()], U.prototype, "loading", 2), ie([t$1()], U.prototype, "firstFetch", 2), ie([t$1()], U.prototype, "search", 2), ie([t$1()], U.prototype, "endReached", 2), U = ie([e$2("wcm-wallet-explorer-view")], U); +H2.styles = [h.globalCss, nr], se([t$1()], H2.prototype, "loading", 2), se([t$1()], H2.prototype, "firstFetch", 2), se([t$1()], H2.prototype, "search", 2), se([t$1()], H2.prototype, "endReached", 2), H2 = se([e$2("wcm-wallet-explorer-view")], H2); const dr = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -var mr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a2) => { - for (var t2 = a2 > 1 ? void 0 : a2 ? hr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) +var mr = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a2) => { + for (var t2 = a2 > 1 ? void 0 : a2 ? wr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) (i2 = e2[l2]) && (t2 = (a2 ? i2(o3, r2, t2) : i2(t2)) || t2); return a2 && t2 && mr(o3, r2, t2), t2; }; -let we = class extends s { +let ve = class extends s$1 { constructor() { super(), this.isError = false, this.openWebWallet(); } onFormatAndRedirect(e2) { - var _a; - const { desktop: o3, name: r2 } = a$2.getWalletRouterData(), a2 = o3 == null ? void 0 : o3.universal; - if (a2) { - const t2 = a$2.formatUniversalUrl(a2, e2, r2); - if (r2 === "Puzzle Wallet" && window && ((_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient)) { - const url = new URL(t2); - const params = url.searchParams; - const wcUri = params.get("uri"); - const requestId = params.get("requestId"); - const sessionTopic = params.get("sessionTopic"); - void window.aleo.connectPuzzle({ - wc: { - uri: wcUri, - requestId: requestId ?? void 0, - sessionTopic: sessionTopic ?? void 0 - } - }); - } else { - a$2.openHref(t2, "_blank"); - } + var o3; + const { desktop: r2, name: a2 } = i$1$1.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.universal; + if (t2) { + const l2 = i$1$1.formatUniversalUrl(t2, e2, a2); + if (a2 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w2 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w2 ?? void 0 } }); + } else + i$1$1.openHref(l2, "_blank"); } } openWebWallet() { - const { walletConnectUri: e2 } = p$1.state, o3 = a$2.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = p$2.state, o3 = i$1$1.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = a$2.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = c.getCachedRouterWalletPlatforms(), l$12 = a$2.isMobile(); - return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; + const { name: e2, id: o3, image_id: r2 } = i$1$1.getWalletRouterData(), { isMobile: a2, isDesktop: t2 } = s2.getCachedRouterWalletPlatforms(), l$12 = i$1$1.isMobile(); + return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; } }; -we.styles = [h.globalCss, dr], Ge([t$1()], we.prototype, "isError", 2), we = Ge([e$2("wcm-web-connecting-view")], we); +ve.styles = [h.globalCss, dr], Ge([t$1()], ve.prototype, "isError", 2), ve = Ge([e$2("wcm-web-connecting-view")], ve); export { - ae as WcmModal, - j as WcmQrCode + ne as WcmModal, + D as WcmQrCode }; diff --git a/packages/react/dist/index-BqFuGgVn.js b/packages/react/dist/index-j7s7E1c2.js similarity index 53% rename from packages/react/dist/index-BqFuGgVn.js rename to packages/react/dist/index-j7s7E1c2.js index 6f6de2c3..d8219cd0 100644 --- a/packages/react/dist/index-BqFuGgVn.js +++ b/packages/react/dist/index-j7s7E1c2.js @@ -5,11 +5,11 @@ import { useQuery, useQueryClient, onlineManager, notifyManager, QueryClient, Qu import EventEmitter$2 from "events"; import { getSdkError } from "@walletconnect/utils"; import { useDebounce } from "use-debounce"; -import { WalletConnectModalSign } from "@walletconnect/modal-sign-html"; +import { WalletConnectModalSign } from "@puzzlehq/walletconnect-modal-sign-html"; import debug$1 from "debug"; const t = Symbol(); -const s = Object.getPrototypeOf, c$2 = /* @__PURE__ */ new WeakMap(), l$2 = (e) => e && (c$2.has(e) ? c$2.get(e) : s(e) === Object.prototype || s(e) === Array.prototype), y$4 = (e) => l$2(e) && e[t] || null, h$4 = (e, t2 = true) => { - c$2.set(e, t2); +const s$1 = Object.getPrototypeOf, c$4 = /* @__PURE__ */ new WeakMap(), l$2 = (e2) => e2 && (c$4.has(e2) ? c$4.get(e2) : s$1(e2) === Object.prototype || s$1(e2) === Array.prototype), y$5 = (e2) => l$2(e2) && e2[t] || null, h$3 = (e2, t2 = true) => { + c$4.set(e2, t2); }; var define_import_meta_env_default$1 = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false }; const isObject = (x2) => typeof x2 === "object" && x2 !== null; @@ -30,7 +30,7 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = return cache[1]; } const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); - h$4(snap, true); + h$3(snap, true); snapCache.set(target, [version2, snap]); Reflect.ownKeys(target).forEach((key) => { if (Object.getOwnPropertyDescriptor(snap, key)) { @@ -45,7 +45,7 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = configurable: true }; if (refSet.has(value)) { - h$4(value, false); + h$3(value, false); } else if (value instanceof Promise) { delete desc.value; desc.get = () => handlePromise(value); @@ -109,11 +109,11 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = } }; const removePropListener = (prop) => { - var _a; + var _a2; const entry = propProxyStates.get(prop); if (entry) { propProxyStates.delete(prop); - (_a = entry[1]) == null ? void 0 : _a.call(entry); + (_a2 = entry[1]) == null ? void 0 : _a2.call(entry); } }; const addListener2 = (listener) => { @@ -159,7 +159,7 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = } removePropListener(prop); if (isObject(value)) { - value = y$4(value) || value; + value = y$5(value) || value; } let nextValue = value; if (value instanceof Promise) { @@ -167,10 +167,10 @@ const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) = value.status = "fulfilled"; value.value = v3; notifyUpdate(["resolve", [prop], v3]); - }).catch((e) => { + }).catch((e2) => { value.status = "rejected"; - value.reason = e; - notifyUpdate(["reject", [prop], e]); + value.reason = e2; + notifyUpdate(["reject", [prop], e2]); }); } else { if (!proxyStateMap.has(value) && canProxy(value)) { @@ -239,10 +239,6 @@ function subscribe(proxyObject, callback, notifyInSync) { let isListenerActive = false; const listener = (op) => { ops.push(op); - if (notifyInSync) { - callback(ops.splice(0)); - return; - } if (!promise) { promise = Promise.resolve().then(() => { promise = void 0; @@ -267,388 +263,240 @@ function snapshot(proxyObject, handlePromise) { const [target, ensureVersion, createSnapshot] = proxyState; return createSnapshot(target, ensureVersion(), handlePromise); } -const o$1 = proxy({ - history: ["ConnectWallet"], - view: "ConnectWallet", - data: void 0 -}), T$1 = { - state: o$1, - subscribe(e) { - return subscribe(o$1, () => e(o$1)); - }, - push(e, t2) { - e !== o$1.view && (o$1.view = e, t2 && (o$1.data = t2), o$1.history.push(e)); - }, - reset(e) { - o$1.view = e, o$1.history = [e]; - }, - replace(e) { - o$1.history.length > 1 && (o$1.history[o$1.history.length - 1] = e, o$1.view = e); - }, - goBack() { - if (o$1.history.length > 1) { - o$1.history.pop(); - const [e] = o$1.history.slice(-1); - o$1.view = e; - } - }, - setData(e) { - o$1.data = e; - } -}, a$3 = { - WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", - WCM_VERSION: "WCM_VERSION", - RECOMMENDED_WALLET_AMOUNT: 9, - isMobile() { - return typeof window < "u" ? Boolean( - window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test( - navigator.userAgent - ) - ) : false; - }, - isAndroid() { - return a$3.isMobile() && navigator.userAgent.toLowerCase().includes("android"); - }, - isIos() { - const e = navigator.userAgent.toLowerCase(); - return a$3.isMobile() && (e.includes("iphone") || e.includes("ipad")); - }, - isHttpUrl(e) { - return e.startsWith("http://") || e.startsWith("https://"); - }, - isArray(e) { - return Array.isArray(e) && e.length > 0; - }, - formatNativeUrl(e, t2, s2) { - if (a$3.isHttpUrl(e)) - return this.formatUniversalUrl(e, t2, s2); - let n3 = e; - n3.includes("://") || (n3 = e.replaceAll("/", "").replaceAll(":", ""), n3 = `${n3}://`), n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - formatUniversalUrl(e, t2, s2) { - if (!a$3.isHttpUrl(e)) - return this.formatNativeUrl(e, t2, s2); - let n3 = e; - n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - async wait(e) { - return new Promise((t2) => { - setTimeout(t2, e); - }); - }, - openHref(e, t2) { - window.open(e, t2, "noreferrer noopener"); - }, - setWalletConnectDeepLink(e, t2) { - try { - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: e, name: t2 }) - ); - } catch { - console.info("Unable to set WalletConnect deep link"); - } - }, - setWalletConnectAndroidDeepLink(e) { - try { - const [t2] = e.split("?"); - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: t2, name: "Android" }) - ); - } catch { - console.info("Unable to set WalletConnect android deep link"); - } - }, - removeWalletConnectDeepLink() { - try { - localStorage.removeItem(a$3.WALLETCONNECT_DEEPLINK_CHOICE); - } catch { - console.info("Unable to remove WalletConnect deep link"); - } - }, - setModalVersionInStorage() { - try { - typeof localStorage < "u" && localStorage.setItem(a$3.WCM_VERSION, "2.6.2"); - } catch { - console.info("Unable to set Web3Modal version in storage"); - } - }, - getWalletRouterData() { - var e; - const t2 = (e = T$1.state.data) == null ? void 0 : e.Wallet; - if (!t2) - throw new Error('Missing "Wallet" view data'); - return t2; - } -}, _$3 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), r$1 = proxy({ - enabled: _$3, - userSessionId: "", - events: [], - connectedWalletId: void 0 -}), R$4 = { - state: r$1, - subscribe(e) { - return subscribe(r$1.events, () => e(snapshot(r$1.events[r$1.events.length - 1]))); - }, - initialize() { - r$1.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (r$1.userSessionId = crypto.randomUUID()); - }, - setConnectedWalletId(e) { - r$1.connectedWalletId = e; - }, - click(e) { - if (r$1.enabled) { - const t2 = { - type: "CLICK", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - }, - track(e) { - if (r$1.enabled) { - const t2 = { - type: "TRACK", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - }, - view(e) { - if (r$1.enabled) { - const t2 = { - type: "VIEW", - name: e.name, - userSessionId: r$1.userSessionId, - timestamp: Date.now(), - data: e - }; - r$1.events.push(t2); - } - } -}, c$1 = proxy({ - chains: void 0, - walletConnectUri: void 0, - isAuth: false, - isCustomDesktop: false, - isCustomMobile: false, - isDataLoaded: false, - isUiLoaded: false -}), p$3 = { - state: c$1, - subscribe(e) { - return subscribe(c$1, () => e(c$1)); - }, - setChains(e) { - c$1.chains = e; - }, - setWalletConnectUri(e) { - c$1.walletConnectUri = e; - }, - setIsCustomDesktop(e) { - c$1.isCustomDesktop = e; - }, - setIsCustomMobile(e) { - c$1.isCustomMobile = e; - }, - setIsDataLoaded(e) { - c$1.isDataLoaded = e; - }, - setIsUiLoaded(e) { - c$1.isUiLoaded = e; - }, - setIsAuth(e) { - c$1.isAuth = e; - } -}, W$2 = proxy({ - projectId: "", - mobileWallets: void 0, - desktopWallets: void 0, - walletImages: void 0, - chains: void 0, - enableAuthMode: false, - enableExplorer: true, - explorerExcludedWalletIds: void 0, - explorerRecommendedWalletIds: void 0, - termsOfServiceUrl: void 0, - privacyPolicyUrl: void 0 -}), y$3 = { - state: W$2, - subscribe(e) { - return subscribe(W$2, () => e(W$2)); - }, - setConfig(e) { - var t2, s2; - R$4.initialize(), p$3.setChains(e.chains), p$3.setIsAuth(Boolean(e.enableAuthMode)), p$3.setIsCustomMobile( - Boolean((t2 = e.mobileWallets) == null ? void 0 : t2.length) - ), p$3.setIsCustomDesktop( - Boolean((s2 = e.desktopWallets) == null ? void 0 : s2.length) - ), a$3.setModalVersionInStorage(), Object.assign(W$2, e); +const o$1 = proxy({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), T$2 = { state: o$1, subscribe(e2) { + return subscribe(o$1, () => e2(o$1)); +}, push(e2, t2) { + e2 !== o$1.view && (o$1.view = e2, t2 && (o$1.data = t2), o$1.history.push(e2)); +}, reset(e2) { + o$1.view = e2, o$1.history = [e2]; +}, replace(e2) { + o$1.history.length > 1 && (o$1.history[o$1.history.length - 1] = e2, o$1.view = e2); +}, goBack() { + if (o$1.history.length > 1) { + o$1.history.pop(); + const [e2] = o$1.history.slice(-1); + o$1.view = e2; + } +}, setData(e2) { + o$1.data = e2; +} }, i$1 = { WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", WCM_VERSION: "WCM_VERSION", RECOMMENDED_WALLET_AMOUNT: 9, isMobile() { + return typeof window < "u" ? Boolean(window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : false; +}, isAndroid() { + return i$1.isMobile() && navigator.userAgent.toLowerCase().includes("android"); +}, isIos() { + const e2 = navigator.userAgent.toLowerCase(); + return i$1.isMobile() && (e2.includes("iphone") || e2.includes("ipad")); +}, isHttpUrl(e2) { + return e2.startsWith("http://") || e2.startsWith("https://"); +}, isArray(e2) { + return Array.isArray(e2) && e2.length > 0; +}, formatNativeUrl(e2, t2, s2) { + if (i$1.isHttpUrl(e2)) + return this.formatUniversalUrl(e2, t2, s2); + let n4 = e2; + n4.includes("://") || (n4 = e2.replaceAll("/", "").replaceAll(":", ""), n4 = `${n4}://`), n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s2); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; +}, formatUniversalUrl(e2, t2, s2) { + if (!i$1.isHttpUrl(e2)) + return this.formatNativeUrl(e2, t2, s2); + let n4 = e2; + n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s2); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; +}, async wait(e2) { + return new Promise((t2) => { + setTimeout(t2, e2); + }); +}, openHref(e2, t2) { + window.open(e2, t2, "noreferrer noopener"); +}, setWalletConnectDeepLink(e2, t2) { + try { + localStorage.setItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: e2, name: t2 })); + } catch { + console.info("Unable to set WalletConnect deep link"); } -}; -var V$2 = Object.defineProperty, D$4 = Object.getOwnPropertySymbols, H$2 = Object.prototype.hasOwnProperty, B$2 = Object.prototype.propertyIsEnumerable, M$1 = (e, t2, s2) => t2 in e ? V$2(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, K$1 = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - H$2.call(t2, s2) && M$1(e, s2, t2[s2]); - if (D$4) - for (var s2 of D$4(t2)) - B$2.call(t2, s2) && M$1(e, s2, t2[s2]); - return e; -}; -const L$2 = "https://explorer-api.walletconnect.com", E$2 = "wcm", O$3 = "js-2.6.2"; -async function w$5(e, t2) { - const s2 = K$1({ sdkType: E$2, sdkVersion: O$3 }, t2), n3 = new URL(e, L$2); - return n3.searchParams.append("projectId", y$3.state.projectId), Object.entries(s2).forEach(([i2, l2]) => { - l2 && n3.searchParams.append(i2, String(l2)); - }), (await fetch(n3)).json(); -} -const m$2 = { - async getDesktopListings(e) { - return w$5("/w3m/v1/getDesktopListings", e); - }, - async getMobileListings(e) { - return w$5("/w3m/v1/getMobileListings", e); - }, - async getInjectedListings(e) { - return w$5("/w3m/v1/getInjectedListings", e); - }, - async getAllListings(e) { - return w$5("/w3m/v1/getAllListings", e); - }, - getWalletImageUrl(e) { - return `${L$2}/w3m/v1/getWalletImage/${e}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; - }, - getAssetImageUrl(e) { - return `${L$2}/w3m/v1/getAssetImage/${e}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; +}, setWalletConnectAndroidDeepLink(e2) { + try { + const [t2] = e2.split("?"); + localStorage.setItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: t2, name: "Android" })); + } catch { + console.info("Unable to set WalletConnect android deep link"); } -}; -var z$3 = Object.defineProperty, j$3 = Object.getOwnPropertySymbols, J$2 = Object.prototype.hasOwnProperty, q$2 = Object.prototype.propertyIsEnumerable, k$2 = (e, t2, s2) => t2 in e ? z$3(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, F$3 = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - J$2.call(t2, s2) && k$2(e, s2, t2[s2]); - if (j$3) - for (var s2 of j$3(t2)) - q$2.call(t2, s2) && k$2(e, s2, t2[s2]); - return e; -}; -const N$3 = a$3.isMobile(), d$2 = proxy({ - wallets: { listings: [], total: 0, page: 1 }, - search: { listings: [], total: 0, page: 1 }, - recomendedWallets: [] -}), te$2 = { - state: d$2, - async getRecomendedWallets() { - const { explorerRecommendedWalletIds: e, explorerExcludedWalletIds: t2 } = y$3.state; - if (e === "NONE" || t2 === "ALL" && !e) - return d$2.recomendedWallets; - if (a$3.isArray(e)) { - const s2 = { recommendedIds: e.join(",") }, { listings: n3 } = await m$2.getAllListings(s2), i2 = Object.values(n3); - i2.sort && i2.sort((l2, v3) => { - const b3 = e.indexOf(l2.id), f2 = e.indexOf(v3.id); - return b3 - f2; - }), d$2.recomendedWallets = i2; - } else { - const { chains: s2, isAuth: n3 } = p$3.state, i2 = s2 == null ? void 0 : s2.join(","), l2 = a$3.isArray(t2), v3 = { - page: 1, - sdks: n3 ? "auth_v1" : void 0, - entries: a$3.RECOMMENDED_WALLET_AMOUNT, - chains: i2, - version: 2, - excludedIds: l2 ? t2.join(",") : void 0 - }, { listings: b3 } = N$3 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); - d$2.recomendedWallets = Object.values(b3); - } - return d$2.recomendedWallets; - }, - async getWallets(e) { - const t2 = F$3({}, e), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n3 } = y$3.state, { recomendedWallets: i2 } = d$2; - if (n3 === "ALL") - return d$2.wallets; - i2.length ? t2.excludedIds = i2.map((x2) => x2.id).join(",") : a$3.isArray(s2) && (t2.excludedIds = s2.join(",")), a$3.isArray(n3) && (t2.excludedIds = [t2.excludedIds, n3].filter(Boolean).join(",")), p$3.state.isAuth && (t2.sdks = "auth_v1"); - const { page: l2, search: v3 } = e, { listings: b3, total: f2 } = N$3 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; - return d$2[U2] = { listings: [...d$2[U2].listings, ...A2], total: f2, page: l2 ?? 1 }, { listings: A2, total: f2 }; - }, - getWalletImageUrl(e) { - return m$2.getWalletImageUrl(e); - }, - getAssetImageUrl(e) { - return m$2.getAssetImageUrl(e); - }, - resetSearch() { - d$2.search = { listings: [], total: 0, page: 1 }; +}, removeWalletConnectDeepLink() { + try { + localStorage.removeItem(i$1.WALLETCONNECT_DEEPLINK_CHOICE); + } catch { + console.info("Unable to remove WalletConnect deep link"); } -}, I$1 = proxy({ open: false }), se = { - state: I$1, - subscribe(e) { - return subscribe(I$1, () => e(I$1)); - }, - async open(e) { - return new Promise((t2) => { - const { isUiLoaded: s2, isDataLoaded: n3 } = p$3.state; - if (a$3.removeWalletConnectDeepLink(), p$3.setWalletConnectUri(e == null ? void 0 : e.uri), p$3.setChains(e == null ? void 0 : e.chains), T$1.reset("ConnectWallet"), s2 && n3) - I$1.open = true, t2(); - else { - const i2 = setInterval(() => { - const l2 = p$3.state; - l2.isUiLoaded && l2.isDataLoaded && (clearInterval(i2), I$1.open = true, t2()); - }, 200); - } - }); - }, - close() { - I$1.open = false; +}, setModalVersionInStorage() { + try { + typeof localStorage < "u" && localStorage.setItem(i$1.WCM_VERSION, "0.0.6"); + } catch { + console.info("Unable to set Web3Modal version in storage"); } -}; -var G$2 = Object.defineProperty, $$2 = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$2 = Object.prototype.propertyIsEnumerable, S$2 = (e, t2, s2) => t2 in e ? G$2(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, Y = (e, t2) => { +}, getWalletRouterData() { + var e2; + const t2 = (e2 = T$2.state.data) == null ? void 0 : e2.Wallet; + if (!t2) + throw new Error('Missing "Wallet" view data'); + return t2; +} }, _$2 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), a$2 = proxy({ enabled: _$2, userSessionId: "", events: [], connectedWalletId: void 0 }), R$1 = { state: a$2, subscribe(e2) { + return subscribe(a$2.events, () => e2(snapshot(a$2.events[a$2.events.length - 1]))); +}, initialize() { + a$2.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (a$2.userSessionId = crypto.randomUUID()); +}, setConnectedWalletId(e2) { + a$2.connectedWalletId = e2; +}, click(e2) { + if (a$2.enabled) { + const t2 = { type: "CLICK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +}, track(e2) { + if (a$2.enabled) { + const t2 = { type: "TRACK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +}, view(e2) { + if (a$2.enabled) { + const t2 = { type: "VIEW", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } +} }, c$3 = proxy({ chains: void 0, walletConnectUri: void 0, isAuth: false, isCustomDesktop: false, isCustomMobile: false, isDataLoaded: false, isUiLoaded: false }), p$2 = { state: c$3, subscribe(e2) { + return subscribe(c$3, () => e2(c$3)); +}, setChains(e2) { + c$3.chains = e2; +}, setWalletConnectUri(e2) { + c$3.walletConnectUri = e2; +}, setIsCustomDesktop(e2) { + c$3.isCustomDesktop = e2; +}, setIsCustomMobile(e2) { + c$3.isCustomMobile = e2; +}, setIsDataLoaded(e2) { + c$3.isDataLoaded = e2; +}, setIsUiLoaded(e2) { + c$3.isUiLoaded = e2; +}, setIsAuth(e2) { + c$3.isAuth = e2; +} }, W = proxy({ projectId: "", mobileWallets: void 0, desktopWallets: void 0, walletImages: void 0, chains: void 0, enableAuthMode: false, enableExplorer: true, explorerExcludedWalletIds: void 0, explorerRecommendedWalletIds: void 0, termsOfServiceUrl: void 0, privacyPolicyUrl: void 0 }), y$4 = { state: W, subscribe(e2) { + return subscribe(W, () => e2(W)); +}, setConfig(e2) { + var t2, s2; + R$1.initialize(), p$2.setChains(e2.chains), p$2.setIsAuth(Boolean(e2.enableAuthMode)), p$2.setIsCustomMobile(Boolean((t2 = e2.mobileWallets) == null ? void 0 : t2.length)), p$2.setIsCustomDesktop(Boolean((s2 = e2.desktopWallets) == null ? void 0 : s2.length)), i$1.setModalVersionInStorage(), Object.assign(W, e2); +} }; +var V$3 = Object.defineProperty, D$2 = Object.getOwnPropertySymbols, H = Object.prototype.hasOwnProperty, B$1 = Object.prototype.propertyIsEnumerable, M$1 = (e2, t2, s2) => t2 in e2 ? V$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, K$4 = (e2, t2) => { for (var s2 in t2 || (t2 = {})) - Q$3.call(t2, s2) && S$2(e, s2, t2[s2]); - if ($$2) - for (var s2 of $$2(t2)) - X$2.call(t2, s2) && S$2(e, s2, t2[s2]); - return e; + H.call(t2, s2) && M$1(e2, s2, t2[s2]); + if (D$2) + for (var s2 of D$2(t2)) + B$1.call(t2, s2) && M$1(e2, s2, t2[s2]); + return e2; +}; +const L$5 = "https://explorer-api.walletconnect.com", E$3 = "wcm", O$3 = "js-0.0.6"; +async function w$4(e2, t2) { + const s2 = K$4({ sdkType: E$3, sdkVersion: O$3 }, t2), n4 = new URL(e2, L$5); + return n4.searchParams.append("projectId", y$4.state.projectId), Object.entries(s2).forEach(([r3, l2]) => { + l2 && n4.searchParams.append(r3, String(l2)); + }), (await fetch(n4)).json(); +} +const m$2 = { async getDesktopListings(e2) { + return w$4("/w3m/v1/getDesktopListings", e2); +}, async getMobileListings(e2) { + return w$4("/w3m/v1/getMobileListings", e2); +}, async getInjectedListings(e2) { + return w$4("/w3m/v1/getInjectedListings", e2); +}, async getAllListings(e2) { + return w$4("/w3m/v1/getAllListings", e2); +}, getWalletImageUrl(e2) { + return `${L$5}/w3m/v1/getWalletImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; +}, getAssetImageUrl(e2) { + return `${L$5}/w3m/v1/getAssetImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; +} }; +var z$4 = Object.defineProperty, j$4 = Object.getOwnPropertySymbols, J$1 = Object.prototype.hasOwnProperty, q$3 = Object.prototype.propertyIsEnumerable, k$4 = (e2, t2, s2) => t2 in e2 ? z$4(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, F$2 = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + J$1.call(t2, s2) && k$4(e2, s2, t2[s2]); + if (j$4) + for (var s2 of j$4(t2)) + q$3.call(t2, s2) && k$4(e2, s2, t2[s2]); + return e2; +}; +const N$2 = i$1.isMobile(), d$4 = proxy({ wallets: { listings: [], total: 0, page: 1 }, search: { listings: [], total: 0, page: 1 }, recomendedWallets: [] }), te$1 = { state: d$4, async getRecomendedWallets() { + const { explorerRecommendedWalletIds: e2, explorerExcludedWalletIds: t2 } = y$4.state; + if (e2 === "NONE" || t2 === "ALL" && !e2) + return d$4.recomendedWallets; + if (i$1.isArray(e2)) { + const s2 = { recommendedIds: e2.join(",") }, { listings: n4 } = await m$2.getAllListings(s2), r3 = Object.values(n4); + n4 && r3.sort && r3.sort((l2, v3) => { + const b3 = e2.indexOf(l2.id), f3 = e2.indexOf(v3.id); + return b3 - f3; + }), d$4.recomendedWallets = r3; + } else { + const { chains: s2, isAuth: n4 } = p$2.state, r3 = s2 == null ? void 0 : s2.join(","), l2 = i$1.isArray(t2), v3 = { page: 1, sdks: n4 ? "auth_v1" : void 0, entries: i$1.RECOMMENDED_WALLET_AMOUNT, chains: r3, version: 2, excludedIds: l2 ? t2.join(",") : void 0 }, { listings: b3 } = N$2 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); + d$4.recomendedWallets = Object.values(b3); + } + return d$4.recomendedWallets; +}, async getWallets(e2) { + const t2 = F$2({}, e2), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n4 } = y$4.state, { recomendedWallets: r3 } = d$4; + if (n4 === "ALL") + return d$4.wallets; + r3.length ? t2.excludedIds = r3.map((x2) => x2.id).join(",") : i$1.isArray(s2) && (t2.excludedIds = s2.join(",")), i$1.isArray(n4) && (t2.excludedIds = [t2.excludedIds, n4].filter(Boolean).join(",")), p$2.state.isAuth && (t2.sdks = "auth_v1"); + const { page: l2, search: v3 } = e2, { listings: b3, total: f3 } = N$2 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; + return d$4[U2] = { listings: [...d$4[U2].listings, ...A2], total: f3, page: l2 ?? 1 }, { listings: A2, total: f3 }; +}, getWalletImageUrl(e2) { + return m$2.getWalletImageUrl(e2); +}, getAssetImageUrl(e2) { + return m$2.getAssetImageUrl(e2); +}, resetSearch() { + d$4.search = { listings: [], total: 0, page: 1 }; +} }, I$3 = proxy({ open: false }), se$3 = { state: I$3, subscribe(e2) { + return subscribe(I$3, () => e2(I$3)); +}, async open(e2) { + return new Promise((t2) => { + const { isUiLoaded: s2, isDataLoaded: n4 } = p$2.state; + if (i$1.removeWalletConnectDeepLink(), p$2.setWalletConnectUri(e2 == null ? void 0 : e2.uri), p$2.setChains(e2 == null ? void 0 : e2.chains), T$2.reset("ConnectWallet"), s2 && n4) + I$3.open = true, t2(); + else { + const r3 = setInterval(() => { + const l2 = p$2.state; + l2.isUiLoaded && l2.isDataLoaded && (clearInterval(r3), I$3.open = true, t2()); + }, 200); + } + }); +}, close() { + I$3.open = false; +} }; +var G$1 = Object.defineProperty, $ = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$1 = Object.prototype.propertyIsEnumerable, S$4 = (e2, t2, s2) => t2 in e2 ? G$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, Y = (e2, t2) => { + for (var s2 in t2 || (t2 = {})) + Q$3.call(t2, s2) && S$4(e2, s2, t2[s2]); + if ($) + for (var s2 of $(t2)) + X$1.call(t2, s2) && S$4(e2, s2, t2[s2]); + return e2; }; -function Z$2() { +function Z$1() { return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; } -const C = proxy({ themeMode: Z$2() ? "dark" : "light" }), ne = { - state: C, - subscribe(e) { - return subscribe(C, () => e(C)); - }, - setThemeConfig(e) { - const { themeMode: t2, themeVariables: s2 } = e; - t2 && (C.themeMode = t2), s2 && (C.themeVariables = Y({}, s2)); - } -}, g$5 = proxy({ open: false, message: "", variant: "success" }), oe$1 = { - state: g$5, - subscribe(e) { - return subscribe(g$5, () => e(g$5)); - }, - openToast(e, t2) { - g$5.open = true, g$5.message = e, g$5.variant = t2; - }, - closeToast() { - g$5.open = false; - } -}; -let d$1 = class d { - constructor(e) { - this.openModal = se.open, this.closeModal = se.close, this.subscribeModal = se.subscribe, this.setTheme = ne.setThemeConfig, ne.setThemeConfig(e), y$3.setConfig(e), this.initUi(); +const C$3 = proxy({ themeMode: Z$1() ? "dark" : "light" }), ne$3 = { state: C$3, subscribe(e2) { + return subscribe(C$3, () => e2(C$3)); +}, setThemeConfig(e2) { + const { themeMode: t2, themeVariables: s2 } = e2; + t2 && (C$3.themeMode = t2), s2 && (C$3.themeVariables = Y({}, s2)); +} }, g$3 = proxy({ open: false, message: "", variant: "success" }), oe$2 = { state: g$3, subscribe(e2) { + return subscribe(g$3, () => e2(g$3)); +}, openToast(e2, t2) { + g$3.open = true, g$3.message = e2, g$3.variant = t2; +}, closeToast() { + g$3.open = false; +} }; +let d$3 = class d { + constructor(e2) { + this.openModal = se$3.open, this.closeModal = se$3.close, this.subscribeModal = se$3.subscribe, this.setTheme = ne$3.setThemeConfig, ne$3.setThemeConfig(e2), y$4.setConfig(e2), this.initUi(); } async initUi() { if (typeof window < "u") { - await import("./index-B2etef5O-C677xVYO.js"); - const e = document.createElement("wcm-modal"); - document.body.insertAdjacentElement("beforeend", e), p$3.setIsUiLoaded(true); + await import("./index-f3LbIFb5-DhnEJzKF.js"); + const e2 = document.createElement("wcm-modal"); + document.body.insertAdjacentElement("beforeend", e2), p$2.setIsUiLoaded(true); } } }; @@ -656,40 +504,40 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win function getDefaultExportFromCjs(x2) { return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; } -function getAugmentedNamespace(n3) { - if (n3.__esModule) - return n3; - var f2 = n3.default; - if (typeof f2 == "function") { +function getAugmentedNamespace(n4) { + if (n4.__esModule) + return n4; + var f3 = n4.default; + if (typeof f3 == "function") { var a3 = function a4() { if (this instanceof a4) { - return Reflect.construct(f2, arguments, this.constructor); + return Reflect.construct(f3, arguments, this.constructor); } - return f2.apply(this, arguments); + return f3.apply(this, arguments); }; - a3.prototype = f2.prototype; + a3.prototype = f3.prototype; } else a3 = {}; Object.defineProperty(a3, "__esModule", { value: true }); - Object.keys(n3).forEach(function(k2) { - var d3 = Object.getOwnPropertyDescriptor(n3, k2); - Object.defineProperty(a3, k2, d3.get ? d3 : { + Object.keys(n4).forEach(function(k2) { + var d5 = Object.getOwnPropertyDescriptor(n4, k2); + Object.defineProperty(a3, k2, d5.get ? d5 : { enumerable: true, get: function() { - return n3[k2]; + return n4[k2]; } }); }); return a3; } var events = { exports: {} }; -var R$3 = typeof Reflect === "object" ? Reflect : null; -var ReflectApply = R$3 && typeof R$3.apply === "function" ? R$3.apply : function ReflectApply2(target, receiver, args) { +var R = typeof Reflect === "object" ? Reflect : null; +var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args) { return Function.prototype.apply.call(target, receiver, args); }; var ReflectOwnKeys; -if (R$3 && typeof R$3.ownKeys === "function") { - ReflectOwnKeys = R$3.ownKeys; +if (R && typeof R.ownKeys === "function") { + ReflectOwnKeys = R.ownKeys; } else if (Object.getOwnPropertySymbols) { ReflectOwnKeys = function ReflectOwnKeys2(target) { return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); @@ -740,11 +588,11 @@ EventEmitter.init = function() { } this._maxListeners = this._maxListeners || void 0; }; -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n3) { - if (typeof n3 !== "number" || n3 < 0 || NumberIsNaN(n3)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n3 + "."); +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n4) { + if (typeof n4 !== "number" || n4 < 0 || NumberIsNaN(n4)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n4 + "."); } - this._maxListeners = n3; + this._maxListeners = n4; return this; }; function _getMaxListeners(that) { @@ -790,7 +638,7 @@ EventEmitter.prototype.emit = function emit(type2) { return true; }; function _addListener(target, type2, listener, prepend) { - var m2; + var m3; var events2; var existing; checkListener(listener); @@ -820,8 +668,8 @@ function _addListener(target, type2, listener, prepend) { } else { existing.push(listener); } - m2 = _getMaxListeners(target); - if (m2 > 0 && existing.length > m2 && !existing.warned) { + m3 = _getMaxListeners(target); + if (m3 > 0 && existing.length > m3 && !existing.warned) { existing.warned = true; var w3 = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type2) + " listeners added. Use emitter.setMaxListeners() to increase limit"); w3.name = "MaxListenersExceededWarning"; @@ -988,9 +836,9 @@ function listenerCount(type2) { EventEmitter.prototype.eventNames = function eventNames() { return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; }; -function arrayClone(arr, n3) { - var copy2 = new Array(n3); - for (var i2 = 0; i2 < n3; ++i2) +function arrayClone(arr, n4) { + var copy2 = new Array(n4); + for (var i2 = 0; i2 < n4; ++i2) copy2[i2] = arr[i2]; return copy2; } @@ -1319,7 +1167,7 @@ function createStorage(options = {}) { }); } return Promise.all([...batches.values()].map((batch) => cb(batch))).then( - (r2) => r2.flat() + (r3) => r3.flat() ); }; const storage = { @@ -1347,7 +1195,7 @@ function createStorage(options = {}) { })), commonOptions ).then( - (r2) => r2.map((item) => ({ + (r3) => r3.map((item) => ({ key: joinKeys(batch.base, item.key), value: destr(item.value) })) @@ -1394,7 +1242,7 @@ function createStorage(options = {}) { async setItems(items, commonOptions) { await runBatch(items, commonOptions, async (batch) => { if (batch.driver.setItems) { - await asyncCall( + return asyncCall( batch.driver.setItems, batch.items.map((item) => ({ key: item.relativeKey, @@ -1500,11 +1348,11 @@ function createStorage(options = {}) { mount.relativeBase, opts ); - const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p3) => key.startsWith(p3))); + const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p2) => key.startsWith(p2))); allKeys.push(...keys2); maskedMounts = [ mount.mountpoint, - ...maskedMounts.filter((p3) => !p3.startsWith(mount.mountpoint)) + ...maskedMounts.filter((p2) => !p2.startsWith(mount.mountpoint)) ]; } return base3 ? allKeys.filter((key) => key.startsWith(base3) && !key.endsWith("$")) : allKeys.filter((key) => !key.endsWith("$")); @@ -1513,14 +1361,14 @@ function createStorage(options = {}) { async clear(base3, opts = {}) { base3 = normalizeBaseKey(base3); await Promise.all( - getMounts(base3, false).map(async (m2) => { - if (m2.driver.clear) { - return asyncCall(m2.driver.clear, m2.relativeBase, opts); + getMounts(base3, false).map(async (m3) => { + if (m3.driver.clear) { + return asyncCall(m3.driver.clear, m3.relativeBase, opts); } - if (m2.driver.removeItem) { - const keys2 = await m2.driver.getKeys(m2.relativeBase || "", opts); + if (m3.driver.removeItem) { + const keys2 = await m3.driver.getKeys(m3.relativeBase || "", opts); return Promise.all( - keys2.map((key) => m2.driver.removeItem(key, opts)) + keys2.map((key) => m3.driver.removeItem(key, opts)) ); } }) @@ -1582,18 +1430,18 @@ function createStorage(options = {}) { }, getMount(key = "") { key = normalizeKey(key) + ":"; - const m2 = getMount(key); + const m3 = getMount(key); return { - driver: m2.driver, - base: m2.base + driver: m3.driver, + base: m3.base }; }, getMounts(base3 = "", opts = {}) { base3 = normalizeKey(base3); const mounts = getMounts(base3, opts.parents); - return mounts.map((m2) => ({ - driver: m2.driver, - base: m2.mountpoint + return mounts.map((m3) => ({ + driver: m3.driver, + base: m3.mountpoint })); } }; @@ -1630,7 +1478,7 @@ function defaultGetStore() { function get(key, customStore = defaultGetStore()) { return customStore("readonly", (store) => promisifyRequest(store.get(key))); } -function set(key, value, customStore = defaultGetStore()) { +function set$1(key, value, customStore = defaultGetStore()) { return customStore("readwrite", (store) => { store.put(value, key); return promisifyRequest(store.transaction); @@ -1683,7 +1531,7 @@ function safeJsonParse(value) { } try { return JSONParse(value); - } catch (_a) { + } catch (_a2) { return value; } } @@ -1691,27 +1539,27 @@ function safeJsonStringify(value) { return typeof value === "string" ? value : JSONStringify(value) || ""; } const x$1 = "idb-keyval"; -var z$2 = (i2 = {}) => { - const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e = (s2) => t2 + s2; - let n3; - return i2.dbName && i2.storeName && (n3 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { - return !(typeof await get(e(s2), n3) > "u"); +var z$3 = (i2 = {}) => { + const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e2 = (s2) => t2 + s2; + let n4; + return i2.dbName && i2.storeName && (n4 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { + return !(typeof await get(e2(s2), n4) > "u"); }, async getItem(s2) { - return await get(e(s2), n3) ?? null; + return await get(e2(s2), n4) ?? null; }, setItem(s2, a3) { - return set(e(s2), a3, n3); + return set$1(e2(s2), a3, n4); }, removeItem(s2) { - return del(e(s2), n3); + return del(e2(s2), n4); }, getKeys() { - return keys(n3); + return keys(n4); }, clear() { - return clear(n3); + return clear(n4); } }; }; -const D$3 = "WALLET_CONNECT_V2_INDEXED_DB", E$1 = "keyvaluestorage"; -let _$2 = class _ { +const D$1 = "WALLET_CONNECT_V2_INDEXED_DB", E$2 = "keyvaluestorage"; +let _$1 = class _ { constructor() { - this.indexedDb = createStorage({ driver: z$2({ dbName: D$3, storeName: E$1 }) }); + this.indexedDb = createStorage({ driver: z$3({ dbName: D$1, storeName: E$2 }) }); } async getKeys() { return this.indexedDb.getKeys(); @@ -1720,103 +1568,103 @@ let _$2 = class _ { return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((t2) => [t2.key, t2.value]); } async getItem(t2) { - const e = await this.indexedDb.getItem(t2); - if (e !== null) - return e; + const e2 = await this.indexedDb.getItem(t2); + if (e2 !== null) + return e2; } - async setItem(t2, e) { - await this.indexedDb.setItem(t2, safeJsonStringify(e)); + async setItem(t2, e2) { + await this.indexedDb.setItem(t2, safeJsonStringify(e2)); } async removeItem(t2) { await this.indexedDb.removeItem(t2); } }; -var l$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c = { exports: {} }; +var l$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c$2 = { exports: {} }; (function() { let i2; function t2() { } - i2 = t2, i2.prototype.getItem = function(e) { - return this.hasOwnProperty(e) ? String(this[e]) : null; - }, i2.prototype.setItem = function(e, n3) { - this[e] = String(n3); - }, i2.prototype.removeItem = function(e) { - delete this[e]; + i2 = t2, i2.prototype.getItem = function(e2) { + return this.hasOwnProperty(e2) ? String(this[e2]) : null; + }, i2.prototype.setItem = function(e2, n4) { + this[e2] = String(n4); + }, i2.prototype.removeItem = function(e2) { + delete this[e2]; }, i2.prototype.clear = function() { - const e = this; - Object.keys(e).forEach(function(n3) { - e[n3] = void 0, delete e[n3]; + const e2 = this; + Object.keys(e2).forEach(function(n4) { + e2[n4] = void 0, delete e2[n4]; }); - }, i2.prototype.key = function(e) { - return e = e || 0, Object.keys(this)[e]; + }, i2.prototype.key = function(e2) { + return e2 = e2 || 0, Object.keys(this)[e2]; }, i2.prototype.__defineGetter__("length", function() { return Object.keys(this).length; - }), typeof l$1 < "u" && l$1.localStorage ? c.exports = l$1.localStorage : typeof window < "u" && window.localStorage ? c.exports = window.localStorage : c.exports = new t2(); + }), typeof l$1 < "u" && l$1.localStorage ? c$2.exports = l$1.localStorage : typeof window < "u" && window.localStorage ? c$2.exports = window.localStorage : c$2.exports = new t2(); })(); -function k$1(i2) { +function k$3(i2) { var t2; return [i2[0], safeJsonParse((t2 = i2[1]) != null ? t2 : "")]; } -class K { +let K$3 = class K { constructor() { - this.localStorage = c.exports; + this.localStorage = c$2.exports; } async getKeys() { return Object.keys(this.localStorage); } async getEntries() { - return Object.entries(this.localStorage).map(k$1); + return Object.entries(this.localStorage).map(k$3); } async getItem(t2) { - const e = this.localStorage.getItem(t2); - if (e !== null) - return safeJsonParse(e); + const e2 = this.localStorage.getItem(t2); + if (e2 !== null) + return safeJsonParse(e2); } - async setItem(t2, e) { - this.localStorage.setItem(t2, safeJsonStringify(e)); + async setItem(t2, e2) { + this.localStorage.setItem(t2, safeJsonStringify(e2)); } async removeItem(t2) { this.localStorage.removeItem(t2); } -} -const N$2 = "wc_storage_version", y$2 = 1, O$2 = async (i2, t2, e) => { - const n3 = N$2, s2 = await t2.getItem(n3); - if (s2 && s2 >= y$2) { - e(t2); +}; +const N$1 = "wc_storage_version", y$3 = 1, O$2 = async (i2, t2, e2) => { + const n4 = N$1, s2 = await t2.getItem(n4); + if (s2 && s2 >= y$3) { + e2(t2); return; } const a3 = await i2.getKeys(); if (!a3.length) { - e(t2); + e2(t2); return; } - const m2 = []; + const m3 = []; for (; a3.length; ) { - const r2 = a3.shift(); - if (!r2) + const r3 = a3.shift(); + if (!r3) continue; - const o2 = r2.toLowerCase(); + const o2 = r3.toLowerCase(); if (o2.includes("wc@") || o2.includes("walletconnect") || o2.includes("wc_") || o2.includes("wallet_connect")) { - const f2 = await i2.getItem(r2); - await t2.setItem(r2, f2), m2.push(r2); + const f3 = await i2.getItem(r3); + await t2.setItem(r3, f3), m3.push(r3); } } - await t2.setItem(n3, y$2), e(t2), j$2(i2, m2); -}, j$2 = async (i2, t2) => { - t2.length && t2.forEach(async (e) => { - await i2.removeItem(e); + await t2.setItem(n4, y$3), e2(t2), j$3(i2, m3); +}, j$3 = async (i2, t2) => { + t2.length && t2.forEach(async (e2) => { + await i2.removeItem(e2); }); }; -let h$3 = class h { +let h$2 = class h { constructor() { - this.initialized = false, this.setInitialized = (e) => { - this.storage = e, this.initialized = true; + this.initialized = false, this.setInitialized = (e2) => { + this.storage = e2, this.initialized = true; }; - const t2 = new K(); + const t2 = new K$3(); this.storage = t2; try { - const e = new _$2(); - O$2(t2, e, this.setInitialized); + const e2 = new _$1(); + O$2(t2, e2, this.setInitialized); } catch { this.initialized = true; } @@ -1830,21 +1678,21 @@ let h$3 = class h { async getItem(t2) { return await this.initialize(), this.storage.getItem(t2); } - async setItem(t2, e) { - return await this.initialize(), this.storage.setItem(t2, e); + async setItem(t2, e2) { + return await this.initialize(), this.storage.setItem(t2, e2); } async removeItem(t2) { return await this.initialize(), this.storage.removeItem(t2); } async initialize() { this.initialized || await new Promise((t2) => { - const e = setInterval(() => { - this.initialized && (clearInterval(e), t2()); + const e2 = setInterval(() => { + this.initialized && (clearInterval(e2), t2()); }, 20); }); } }; -var cjs$5 = {}; +var cjs$4 = {}; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. @@ -1859,56 +1707,56 @@ 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. ***************************************************************************** */ -var extendStatics = function(d3, b3) { - extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { - d4.__proto__ = b4; - } || function(d4, b4) { - for (var p3 in b4) - if (b4.hasOwnProperty(p3)) - d4[p3] = b4[p3]; +var extendStatics = function(d5, b3) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d6, b4) { + d6.__proto__ = b4; + } || function(d6, b4) { + for (var p2 in b4) + if (b4.hasOwnProperty(p2)) + d6[p2] = b4[p2]; }; - return extendStatics(d3, b3); + return extendStatics(d5, b3); }; -function __extends$1(d3, b3) { - extendStatics(d3, b3); +function __extends$1(d5, b3) { + extendStatics(d5, b3); function __() { - this.constructor = d3; + this.constructor = d5; } - d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); + d5.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); } var __assign$2 = function() { __assign$2 = Object.assign || function __assign2(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { + for (var s2, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2)) + t2[p2] = s2[p2]; } return t2; }; return __assign$2.apply(this, arguments); }; -function __rest(s2, e) { +function __rest(s2, e2) { var t2 = {}; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3) && e.indexOf(p3) < 0) - t2[p3] = s2[p3]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0) + t2[p2] = s2[p2]; if (s2 != null && typeof Object.getOwnPropertySymbols === "function") - for (var i2 = 0, p3 = Object.getOwnPropertySymbols(s2); i2 < p3.length; i2++) { - if (e.indexOf(p3[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p3[i2])) - t2[p3[i2]] = s2[p3[i2]]; + for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++) { + if (e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i2])) + t2[p2[i2]] = s2[p2[i2]]; } return t2; } function __decorate(decorators, target, key, desc) { - var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3; + var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d5; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r2 = Reflect.decorate(decorators, target, key, desc); + r3 = Reflect.decorate(decorators, target, key, desc); else for (var i2 = decorators.length - 1; i2 >= 0; i2--) - if (d3 = decorators[i2]) - r2 = (c2 < 3 ? d3(r2) : c2 > 3 ? d3(target, key, r2) : d3(target, key)) || r2; - return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2; + if (d5 = decorators[i2]) + r3 = (c2 < 3 ? d5(r3) : c2 > 3 ? d5(target, key, r3) : d5(target, key)) || r3; + return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3; } function __param(paramIndex, decorator) { return function(target, key) { @@ -1929,15 +1777,15 @@ function __awaiter(thisArg, _arguments, P2, generator) { function fulfilled(value) { try { step(generator.next(value)); - } catch (e) { - reject(e); + } catch (e2) { + reject(e2); } } function rejected(value) { try { step(generator["throw"](value)); - } catch (e) { - reject(e); + } catch (e2) { + reject(e2); } } function step(result) { @@ -1951,21 +1799,21 @@ function __generator(thisArg, body) { if (t2[0] & 1) throw t2[1]; return t2[1]; - }, trys: [], ops: [] }, f2, y3, t2, g3; + }, trys: [], ops: [] }, f3, y3, t2, g3; return g3 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() { return this; }), g3; - function verb(n3) { + function verb(n4) { return function(v3) { - return step([n3, v3]); + return step([n4, v3]); }; } function step(op) { - if (f2) + if (f3) throw new TypeError("Generator is already executing."); while (_3) try { - if (f2 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) + if (f3 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) return t2; if (y3 = 0, t2) op = [op[0] & 2, t2.value]; @@ -2011,31 +1859,31 @@ function __generator(thisArg, body) { continue; } op = body.call(thisArg, _3); - } catch (e) { - op = [6, e]; + } catch (e2) { + op = [6, e2]; y3 = 0; } finally { - f2 = t2 = 0; + f3 = t2 = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } -function __createBinding(o2, m2, k2, k22) { +function __createBinding(o2, m3, k2, k22) { if (k22 === void 0) k22 = k2; - o2[k22] = m2[k2]; + o2[k22] = m3[k2]; } -function __exportStar(m2, exports2) { - for (var p3 in m2) - if (p3 !== "default" && !exports2.hasOwnProperty(p3)) - exports2[p3] = m2[p3]; +function __exportStar(m3, exports2) { + for (var p2 in m3) + if (p2 !== "default" && !exports2.hasOwnProperty(p2)) + exports2[p2] = m3[p2]; } function __values(o2) { - var s2 = typeof Symbol === "function" && Symbol.iterator, m2 = s2 && o2[s2], i2 = 0; - if (m2) - return m2.call(o2); + var s2 = typeof Symbol === "function" && Symbol.iterator, m3 = s2 && o2[s2], i2 = 0; + if (m3) + return m3.call(o2); if (o2 && typeof o2.length === "number") return { next: function() { @@ -2046,39 +1894,39 @@ function __values(o2) { }; throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined."); } -function __read$4(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +function __read$4(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; } function __spread() { - for (var ar2 = [], i2 = 0; i2 < arguments.length; i2++) - ar2 = ar2.concat(__read$4(arguments[i2])); - return ar2; + for (var ar3 = [], i2 = 0; i2 < arguments.length; i2++) + ar3 = ar3.concat(__read$4(arguments[i2])); + return ar3; } function __spreadArrays() { for (var s2 = 0, i2 = 0, il = arguments.length; i2 < il; i2++) s2 += arguments[i2].length; - for (var r2 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) + for (var r3 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) for (var a3 = arguments[i2], j2 = 0, jl = a3.length; j2 < jl; j2++, k2++) - r2[k2] = a3[j2]; - return r2; + r3[k2] = a3[j2]; + return r3; } function __await(v3) { return this instanceof __await ? (this.v = v3, this) : new __await(v3); @@ -2090,23 +1938,23 @@ function __asyncGenerator(thisArg, _arguments, generator) { return i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { return this; }, i2; - function verb(n3) { - if (g3[n3]) - i2[n3] = function(v3) { + function verb(n4) { + if (g3[n4]) + i2[n4] = function(v3) { return new Promise(function(a3, b3) { - q2.push([n3, v3, a3, b3]) > 1 || resume(n3, v3); + q2.push([n4, v3, a3, b3]) > 1 || resume(n4, v3); }); }; } - function resume(n3, v3) { + function resume(n4, v3) { try { - step(g3[n3](v3)); - } catch (e) { - settle(q2[0][3], e); + step(g3[n4](v3)); + } catch (e2) { + settle(q2[0][3], e2); } } - function step(r2) { - r2.value instanceof __await ? Promise.resolve(r2.value.v).then(fulfill, reject) : settle(q2[0][2], r2); + function step(r3) { + r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q2[0][2], r3); } function fulfill(value) { resume("next", value); @@ -2114,41 +1962,41 @@ function __asyncGenerator(thisArg, _arguments, generator) { function reject(value) { resume("throw", value); } - function settle(f2, v3) { - if (f2(v3), q2.shift(), q2.length) + function settle(f3, v3) { + if (f3(v3), q2.shift(), q2.length) resume(q2[0][0], q2[0][1]); } } function __asyncDelegator(o2) { - var i2, p3; - return i2 = {}, verb("next"), verb("throw", function(e) { - throw e; + var i2, p2; + return i2 = {}, verb("next"), verb("throw", function(e2) { + throw e2; }), verb("return"), i2[Symbol.iterator] = function() { return this; }, i2; - function verb(n3, f2) { - i2[n3] = o2[n3] ? function(v3) { - return (p3 = !p3) ? { value: __await(o2[n3](v3)), done: n3 === "return" } : f2 ? f2(v3) : v3; - } : f2; + function verb(n4, f3) { + i2[n4] = o2[n4] ? function(v3) { + return (p2 = !p2) ? { value: __await(o2[n4](v3)), done: n4 === "return" } : f3 ? f3(v3) : v3; + } : f3; } } function __asyncValues(o2) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m2 = o2[Symbol.asyncIterator], i2; - return m2 ? m2.call(o2) : (o2 = typeof __values === "function" ? __values(o2) : o2[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { + var m3 = o2[Symbol.asyncIterator], i2; + return m3 ? m3.call(o2) : (o2 = typeof __values === "function" ? __values(o2) : o2[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { return this; }, i2); - function verb(n3) { - i2[n3] = o2[n3] && function(v3) { + function verb(n4) { + i2[n4] = o2[n4] && function(v3) { return new Promise(function(resolve, reject) { - v3 = o2[n3](v3), settle(resolve, reject, v3.done, v3.value); + v3 = o2[n4](v3), settle(resolve, reject, v3.done, v3.value); }); }; } - function settle(resolve, reject, d3, v3) { + function settle(resolve, reject, d5, v3) { Promise.resolve(v3).then(function(v4) { - resolve({ value: v4, done: d3 }); + resolve({ value: v4, done: d5 }); }, reject); } } @@ -2218,8 +2066,8 @@ const tslib_es6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro }, Symbol.toStringTag, { value: "Module" })); const require$$0$2 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6); var heartbeat$2 = {}; -var cjs$4 = {}; -var utils$1 = {}; +var cjs$3 = {}; +var utils = {}; var delay = {}; var hasRequiredDelay; function requireDelay() { @@ -2239,7 +2087,7 @@ function requireDelay() { return delay; } var convert = {}; -var constants$2 = {}; +var constants$1 = {}; var misc = {}; var hasRequiredMisc; function requireMisc() { @@ -2289,18 +2137,18 @@ function requireTime() { })(time); return time; } -var hasRequiredConstants$2; -function requireConstants$2() { - if (hasRequiredConstants$2) - return constants$2; - hasRequiredConstants$2 = 1; +var hasRequiredConstants$1; +function requireConstants$1() { + if (hasRequiredConstants$1) + return constants$1; + hasRequiredConstants$1 = 1; (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireMisc(), exports2); tslib_1.__exportStar(requireTime(), exports2); - })(constants$2); - return constants$2; + })(constants$1); + return constants$1; } var hasRequiredConvert; function requireConvert() { @@ -2309,7 +2157,7 @@ function requireConvert() { hasRequiredConvert = 1; Object.defineProperty(convert, "__esModule", { value: true }); convert.fromMiliseconds = convert.toMiliseconds = void 0; - const constants_1 = requireConstants$2(); + const constants_1 = requireConstants$1(); function toMiliseconds(seconds) { return seconds * constants_1.ONE_THOUSAND; } @@ -2320,18 +2168,18 @@ function requireConvert() { convert.fromMiliseconds = fromMiliseconds; return convert; } -var hasRequiredUtils$1; -function requireUtils$1() { - if (hasRequiredUtils$1) - return utils$1; - hasRequiredUtils$1 = 1; +var hasRequiredUtils; +function requireUtils() { + if (hasRequiredUtils) + return utils; + hasRequiredUtils = 1; (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireDelay(), exports2); tslib_1.__exportStar(requireConvert(), exports2); - })(utils$1); - return utils$1; + })(utils); + return utils; } var watch$1 = {}; var hasRequiredWatch$1; @@ -2405,18 +2253,18 @@ function requireTypes$1() { (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireUtils$1(), exports2); + tslib_1.__exportStar(requireUtils(), exports2); tslib_1.__exportStar(requireWatch$1(), exports2); tslib_1.__exportStar(requireTypes$1(), exports2); - tslib_1.__exportStar(requireConstants$2(), exports2); -})(cjs$4); + tslib_1.__exportStar(requireConstants$1(), exports2); +})(cjs$3); var types$1 = {}; var heartbeat$1 = {}; -let IEvents$1 = class IEvents { -}; +class IEvents { +} const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, - IEvents: IEvents$1 + IEvents }, Symbol.toStringTag, { value: "Module" })); const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(esm); var hasRequiredHeartbeat$2; @@ -2447,7 +2295,7 @@ function requireTypes() { })(types$1); return types$1; } -var constants$1 = {}; +var constants = {}; var heartbeat = {}; var hasRequiredHeartbeat$1; function requireHeartbeat$1() { @@ -2456,24 +2304,24 @@ function requireHeartbeat$1() { hasRequiredHeartbeat$1 = 1; Object.defineProperty(heartbeat, "__esModule", { value: true }); heartbeat.HEARTBEAT_EVENTS = heartbeat.HEARTBEAT_INTERVAL = void 0; - const time_1 = cjs$4; + const time_1 = cjs$3; heartbeat.HEARTBEAT_INTERVAL = time_1.FIVE_SECONDS; heartbeat.HEARTBEAT_EVENTS = { pulse: "heartbeat_pulse" }; return heartbeat; } -var hasRequiredConstants$1; -function requireConstants$1() { - if (hasRequiredConstants$1) - return constants$1; - hasRequiredConstants$1 = 1; +var hasRequiredConstants; +function requireConstants() { + if (hasRequiredConstants) + return constants; + hasRequiredConstants = 1; (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireHeartbeat$1(), exports2); - })(constants$1); - return constants$1; + })(constants); + return constants; } var hasRequiredHeartbeat; function requireHeartbeat() { @@ -2484,9 +2332,9 @@ function requireHeartbeat() { heartbeat$2.HeartBeat = void 0; const tslib_1 = require$$0$2; const events_1 = eventsExports; - const time_1 = cjs$4; + const time_1 = cjs$3; const types_1 = requireTypes(); - const constants_1 = requireConstants$1(); + const constants_1 = requireConstants(); class HeartBeat extends types_1.IHeartBeat { constructor(opts) { super(opts); @@ -2538,573 +2386,654 @@ function requireHeartbeat() { const tslib_1 = require$$0$2; tslib_1.__exportStar(requireHeartbeat(), exports2); tslib_1.__exportStar(requireTypes(), exports2); - tslib_1.__exportStar(requireConstants$1(), exports2); -})(cjs$5); -var cjs$3 = {}; -var quickFormatUnescaped; -var hasRequiredQuickFormatUnescaped; -function requireQuickFormatUnescaped() { - if (hasRequiredQuickFormatUnescaped) - return quickFormatUnescaped; - hasRequiredQuickFormatUnescaped = 1; - function tryStringify(o2) { - try { - return JSON.stringify(o2); - } catch (e) { - return '"[Circular]"'; - } - } - quickFormatUnescaped = format; - function format(f2, args, opts) { - var ss2 = opts && opts.stringify || tryStringify; - var offset = 1; - if (typeof f2 === "object" && f2 !== null) { - var len = args.length + offset; - if (len === 1) - return f2; - var objects = new Array(len); - objects[0] = ss2(f2); - for (var index = 1; index < len; index++) { - objects[index] = ss2(args[index]); - } - return objects.join(" "); - } - if (typeof f2 !== "string") { - return f2; - } - var argLen = args.length; - if (argLen === 0) - return f2; - var str = ""; - var a3 = 1 - offset; - var lastPos = -1; - var flen = f2 && f2.length || 0; - for (var i2 = 0; i2 < flen; ) { - if (f2.charCodeAt(i2) === 37 && i2 + 1 < flen) { - lastPos = lastPos > -1 ? lastPos : 0; - switch (f2.charCodeAt(i2 + 1)) { - case 100: - case 102: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Number(args[a3]); - lastPos = i2 + 2; - i2++; + tslib_1.__exportStar(requireConstants(), exports2); +})(cjs$4); +function tryStringify(o2) { + try { + return JSON.stringify(o2); + } catch (e2) { + return '"[Circular]"'; + } +} +var quickFormatUnescaped = format$1; +function format$1(f3, args, opts) { + var ss4 = opts && opts.stringify || tryStringify; + var offset = 1; + if (typeof f3 === "object" && f3 !== null) { + var len = args.length + offset; + if (len === 1) + return f3; + var objects = new Array(len); + objects[0] = ss4(f3); + for (var index = 1; index < len; index++) { + objects[index] = ss4(args[index]); + } + return objects.join(" "); + } + if (typeof f3 !== "string") { + return f3; + } + var argLen = args.length; + if (argLen === 0) + return f3; + var str = ""; + var a3 = 1 - offset; + var lastPos = -1; + var flen = f3 && f3.length || 0; + for (var i2 = 0; i2 < flen; ) { + if (f3.charCodeAt(i2) === 37 && i2 + 1 < flen) { + lastPos = lastPos > -1 ? lastPos : 0; + switch (f3.charCodeAt(i2 + 1)) { + case 100: + case 102: + if (a3 >= argLen) break; - case 105: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Math.floor(Number(args[a3])); - lastPos = i2 + 2; - i2++; + if (args[a3] == null) break; - case 79: - case 111: - case 106: - if (a3 >= argLen) - break; - if (args[a3] === void 0) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - var type2 = typeof args[a3]; - if (type2 === "string") { - str += "'" + args[a3] + "'"; - lastPos = i2 + 2; - i2++; - break; - } - if (type2 === "function") { - str += args[a3].name || ""; - lastPos = i2 + 2; - i2++; - break; - } - str += ss2(args[a3]); - lastPos = i2 + 2; - i2++; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Number(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 105: + if (a3 >= argLen) break; - case 115: - if (a3 >= argLen) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += String(args[a3]); + if (args[a3] == null) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Math.floor(Number(args[a3])); + lastPos = i2 + 2; + i2++; + break; + case 79: + case 111: + case 106: + if (a3 >= argLen) + break; + if (args[a3] === void 0) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + var type2 = typeof args[a3]; + if (type2 === "string") { + str += "'" + args[a3] + "'"; lastPos = i2 + 2; i2++; break; - case 37: - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += "%"; + } + if (type2 === "function") { + str += args[a3].name || ""; lastPos = i2 + 2; i2++; - a3--; break; - } - ++a3; + } + str += ss4(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 115: + if (a3 >= argLen) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += String(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 37: + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += "%"; + lastPos = i2 + 2; + i2++; + a3--; + break; } - ++i2; - } - if (lastPos === -1) - return f2; - else if (lastPos < flen) { - str += f2.slice(lastPos); - } - return str; + ++a3; + } + ++i2; + } + if (lastPos === -1) + return f3; + else if (lastPos < flen) { + str += f3.slice(lastPos); + } + return str; +} +const format = quickFormatUnescaped; +var browser$4 = pino; +const _console = pfGlobalThisOrFallback().console || {}; +const stdSerializers = { + mapHttpRequest: mock, + mapHttpResponse: mock, + wrapRequestSerializer: passthrough, + wrapResponseSerializer: passthrough, + wrapErrorSerializer: passthrough, + req: mock, + res: mock, + err: asErrValue +}; +function shouldSerialize(serialize, serializers) { + if (Array.isArray(serialize)) { + const hasToFilter = serialize.filter(function(k2) { + return k2 !== "!stdSerializers.err"; + }); + return hasToFilter; + } else if (serialize === true) { + return Object.keys(serializers); } - return quickFormatUnescaped; -} -var browser$4; -var hasRequiredBrowser; -function requireBrowser() { - if (hasRequiredBrowser) - return browser$4; - hasRequiredBrowser = 1; - const format = requireQuickFormatUnescaped(); - browser$4 = pino; - const _console = pfGlobalThisOrFallback().console || {}; - const stdSerializers = { - mapHttpRequest: mock, - mapHttpResponse: mock, - wrapRequestSerializer: passthrough, - wrapResponseSerializer: passthrough, - wrapErrorSerializer: passthrough, - req: mock, - res: mock, - err: asErrValue + return false; +} +function pino(opts) { + opts = opts || {}; + opts.browser = opts.browser || {}; + const transmit2 = opts.browser.transmit; + if (transmit2 && typeof transmit2.send !== "function") { + throw Error("pino: transmit option must have a send function"); + } + const proto = opts.browser.write || _console; + if (opts.browser.write) + opts.browser.asObject = true; + const serializers = opts.serializers || {}; + const serialize = shouldSerialize(opts.browser.serialize, serializers); + let stdErrSerialize = opts.browser.serialize; + if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) + stdErrSerialize = false; + const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; + if (typeof proto === "function") { + proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; + } + if (opts.enabled === false) + opts.level = "silent"; + const level = opts.level || "info"; + const logger = Object.create(proto); + if (!logger.log) + logger.log = noop$1; + Object.defineProperty(logger, "levelVal", { + get: getLevelVal + }); + Object.defineProperty(logger, "level", { + get: getLevel, + set: setLevel + }); + const setOpts = { + transmit: transmit2, + serialize, + asObject: opts.browser.asObject, + levels, + timestamp: getTimeFunction(opts) }; - function shouldSerialize(serialize, serializers) { - if (Array.isArray(serialize)) { - const hasToFilter = serialize.filter(function(k2) { - return k2 !== "!stdSerializers.err"; - }); - return hasToFilter; - } else if (serialize === true) { - return Object.keys(serializers); + logger.levels = pino.levels; + logger.level = level; + logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop$1; + logger.serializers = serializers; + logger._serialize = serialize; + logger._stdErrSerialize = stdErrSerialize; + logger.child = child; + if (transmit2) + logger._logEvent = createLogEventShape(); + function getLevelVal() { + return this.level === "silent" ? Infinity : this.levels.values[this.level]; + } + function getLevel() { + return this._level; + } + function setLevel(level2) { + if (level2 !== "silent" && !this.levels.values[level2]) { + throw Error("unknown level " + level2); + } + this._level = level2; + set(setOpts, logger, "error", "log"); + set(setOpts, logger, "fatal", "error"); + set(setOpts, logger, "warn", "error"); + set(setOpts, logger, "info", "log"); + set(setOpts, logger, "debug", "log"); + set(setOpts, logger, "trace", "log"); + } + function child(bindings, childOptions) { + if (!bindings) { + throw new Error("missing bindings for child Pino"); + } + childOptions = childOptions || {}; + if (serialize && bindings.serializers) { + childOptions.serializers = bindings.serializers; + } + const childOptionsSerializers = childOptions.serializers; + if (serialize && childOptionsSerializers) { + var childSerializers = Object.assign({}, serializers, childOptionsSerializers); + var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; + delete bindings.serializers; + applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); + } + function Child(parent) { + this._childLevel = (parent._childLevel | 0) + 1; + this.error = bind(parent, bindings, "error"); + this.fatal = bind(parent, bindings, "fatal"); + this.warn = bind(parent, bindings, "warn"); + this.info = bind(parent, bindings, "info"); + this.debug = bind(parent, bindings, "debug"); + this.trace = bind(parent, bindings, "trace"); + if (childSerializers) { + this.serializers = childSerializers; + this._serialize = childSerialize; + } + if (transmit2) { + this._logEvent = createLogEventShape( + [].concat(parent._logEvent.bindings, bindings) + ); + } } - return false; + Child.prototype = this; + return new Child(this); } - function pino(opts) { - opts = opts || {}; - opts.browser = opts.browser || {}; - const transmit2 = opts.browser.transmit; - if (transmit2 && typeof transmit2.send !== "function") { - throw Error("pino: transmit option must have a send function"); - } - const proto = opts.browser.write || _console; - if (opts.browser.write) - opts.browser.asObject = true; - const serializers = opts.serializers || {}; - const serialize = shouldSerialize(opts.browser.serialize, serializers); - let stdErrSerialize = opts.browser.serialize; - if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) - stdErrSerialize = false; - const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; - if (typeof proto === "function") { - proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; - } - if (opts.enabled === false) - opts.level = "silent"; - const level = opts.level || "info"; - const logger = Object.create(proto); - if (!logger.log) - logger.log = noop2; - Object.defineProperty(logger, "levelVal", { - get: getLevelVal - }); - Object.defineProperty(logger, "level", { - get: getLevel, - set: setLevel - }); - const setOpts = { - transmit: transmit2, - serialize, - asObject: opts.browser.asObject, - levels, - timestamp: getTimeFunction(opts) + return logger; +} +pino.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" + } +}; +pino.stdSerializers = stdSerializers; +pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); +function set(opts, logger, level, fallback) { + const proto = Object.getPrototypeOf(logger); + logger[level] = logger.levelVal > logger.levels.values[level] ? noop$1 : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop$1; + wrap(opts, logger, level); +} +function wrap(opts, logger, level) { + if (!opts.transmit && logger[level] === noop$1) + return; + logger[level] = /* @__PURE__ */ function(write) { + return function LOG() { + const ts3 = opts.timestamp(); + const args = new Array(arguments.length); + const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; + for (var i2 = 0; i2 < args.length; i2++) + args[i2] = arguments[i2]; + if (opts.serialize && !opts.asObject) { + applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); + } + if (opts.asObject) + write.call(proto, asObject(this, level, args, ts3)); + else + write.apply(proto, args); + if (opts.transmit) { + const transmitLevel = opts.transmit.level || logger.level; + const transmitValue = pino.levels.values[transmitLevel]; + const methodValue = pino.levels.values[level]; + if (methodValue < transmitValue) + return; + transmit(this, { + ts: ts3, + methodLevel: level, + methodValue, + transmitLevel, + transmitValue: pino.levels.values[opts.transmit.level || logger.level], + send: opts.transmit.send, + val: logger.levelVal + }, args); + } }; - logger.levels = pino.levels; - logger.level = level; - logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop2; - logger.serializers = serializers; - logger._serialize = serialize; - logger._stdErrSerialize = stdErrSerialize; - logger.child = child; - if (transmit2) - logger._logEvent = createLogEventShape(); - function getLevelVal() { - return this.level === "silent" ? Infinity : this.levels.values[this.level]; - } - function getLevel() { - return this._level; - } - function setLevel(level2) { - if (level2 !== "silent" && !this.levels.values[level2]) { - throw Error("unknown level " + level2); - } - this._level = level2; - set2(setOpts, logger, "error", "log"); - set2(setOpts, logger, "fatal", "error"); - set2(setOpts, logger, "warn", "error"); - set2(setOpts, logger, "info", "log"); - set2(setOpts, logger, "debug", "log"); - set2(setOpts, logger, "trace", "log"); - } - function child(bindings, childOptions) { - if (!bindings) { - throw new Error("missing bindings for child Pino"); - } - childOptions = childOptions || {}; - if (serialize && bindings.serializers) { - childOptions.serializers = bindings.serializers; - } - const childOptionsSerializers = childOptions.serializers; - if (serialize && childOptionsSerializers) { - var childSerializers = Object.assign({}, serializers, childOptionsSerializers); - var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; - delete bindings.serializers; - applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); - } - function Child(parent) { - this._childLevel = (parent._childLevel | 0) + 1; - this.error = bind(parent, bindings, "error"); - this.fatal = bind(parent, bindings, "fatal"); - this.warn = bind(parent, bindings, "warn"); - this.info = bind(parent, bindings, "info"); - this.debug = bind(parent, bindings, "debug"); - this.trace = bind(parent, bindings, "trace"); - if (childSerializers) { - this.serializers = childSerializers; - this._serialize = childSerialize; - } - if (transmit2) { - this._logEvent = createLogEventShape( - [].concat(parent._logEvent.bindings, bindings) - ); + }(logger[level]); +} +function asObject(logger, level, args, ts3) { + if (logger._serialize) + applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); + const argsCloned = args.slice(); + let msg = argsCloned[0]; + const o2 = {}; + if (ts3) { + o2.time = ts3; + } + o2.level = pino.levels.values[level]; + let lvl = (logger._childLevel | 0) + 1; + if (lvl < 1) + lvl = 1; + if (msg !== null && typeof msg === "object") { + while (lvl-- && typeof argsCloned[0] === "object") { + Object.assign(o2, argsCloned.shift()); + } + msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; + } else if (typeof msg === "string") + msg = format(argsCloned.shift(), argsCloned); + if (msg !== void 0) + o2.msg = msg; + return o2; +} +function applySerializers(args, serialize, serializers, stdErrSerialize) { + for (const i2 in args) { + if (stdErrSerialize && args[i2] instanceof Error) { + args[i2] = pino.stdSerializers.err(args[i2]); + } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { + for (const k2 in args[i2]) { + if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { + args[i2][k2] = serializers[k2](args[i2][k2]); } } - Child.prototype = this; - return new Child(this); } - return logger; } - pino.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" +} +function bind(parent, bindings, level) { + return function() { + const args = new Array(1 + arguments.length); + args[0] = bindings; + for (var i2 = 1; i2 < args.length; i2++) { + args[i2] = arguments[i2 - 1]; } + return parent[level].apply(this, args); }; - pino.stdSerializers = stdSerializers; - pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); - function set2(opts, logger, level, fallback) { - const proto = Object.getPrototypeOf(logger); - logger[level] = logger.levelVal > logger.levels.values[level] ? noop2 : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop2; - wrap(opts, logger, level); - } - function wrap(opts, logger, level) { - if (!opts.transmit && logger[level] === noop2) - return; - logger[level] = /* @__PURE__ */ function(write) { - return function LOG() { - const ts2 = opts.timestamp(); - const args = new Array(arguments.length); - const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; - for (var i2 = 0; i2 < args.length; i2++) - args[i2] = arguments[i2]; - if (opts.serialize && !opts.asObject) { - applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); - } - if (opts.asObject) - write.call(proto, asObject(this, level, args, ts2)); - else - write.apply(proto, args); - if (opts.transmit) { - const transmitLevel = opts.transmit.level || logger.level; - const transmitValue = pino.levels.values[transmitLevel]; - const methodValue = pino.levels.values[level]; - if (methodValue < transmitValue) - return; - transmit(this, { - ts: ts2, - methodLevel: level, - methodValue, - transmitLevel, - transmitValue: pino.levels.values[opts.transmit.level || logger.level], - send: opts.transmit.send, - val: logger.levelVal - }, args); - } - }; - }(logger[level]); - } - function asObject(logger, level, args, ts2) { - if (logger._serialize) - applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); - const argsCloned = args.slice(); - let msg = argsCloned[0]; - const o2 = {}; - if (ts2) { - o2.time = ts2; - } - o2.level = pino.levels.values[level]; - let lvl = (logger._childLevel | 0) + 1; - if (lvl < 1) - lvl = 1; - if (msg !== null && typeof msg === "object") { - while (lvl-- && typeof argsCloned[0] === "object") { - Object.assign(o2, argsCloned.shift()); - } - msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; - } else if (typeof msg === "string") - msg = format(argsCloned.shift(), argsCloned); - if (msg !== void 0) - o2.msg = msg; - return o2; - } - function applySerializers(args, serialize, serializers, stdErrSerialize) { - for (const i2 in args) { - if (stdErrSerialize && args[i2] instanceof Error) { - args[i2] = pino.stdSerializers.err(args[i2]); - } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { - for (const k2 in args[i2]) { - if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { - args[i2][k2] = serializers[k2](args[i2][k2]); - } - } - } +} +function transmit(logger, opts, args) { + const send = opts.send; + const ts3 = opts.ts; + const methodLevel = opts.methodLevel; + const methodValue = opts.methodValue; + const val = opts.val; + const bindings = logger._logEvent.bindings; + applySerializers( + args, + logger._serialize || Object.keys(logger.serializers), + logger.serializers, + logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize + ); + logger._logEvent.ts = ts3; + logger._logEvent.messages = args.filter(function(arg) { + return bindings.indexOf(arg) === -1; + }); + logger._logEvent.level.label = methodLevel; + logger._logEvent.level.value = methodValue; + send(methodLevel, logger._logEvent, val); + logger._logEvent = createLogEventShape(bindings); +} +function createLogEventShape(bindings) { + return { + ts: 0, + messages: [], + bindings: bindings || [], + level: { label: "", value: 0 } + }; +} +function asErrValue(err) { + const obj = { + type: err.constructor.name, + msg: err.message, + stack: err.stack + }; + for (const key in err) { + if (obj[key] === void 0) { + obj[key] = err[key]; } } - function bind(parent, bindings, level) { - return function() { - const args = new Array(1 + arguments.length); - args[0] = bindings; - for (var i2 = 1; i2 < args.length; i2++) { - args[i2] = arguments[i2 - 1]; - } - return parent[level].apply(this, args); - }; + return obj; +} +function getTimeFunction(opts) { + if (typeof opts.timestamp === "function") { + return opts.timestamp; } - function transmit(logger, opts, args) { - const send = opts.send; - const ts2 = opts.ts; - const methodLevel = opts.methodLevel; - const methodValue = opts.methodValue; - const val = opts.val; - const bindings = logger._logEvent.bindings; - applySerializers( - args, - logger._serialize || Object.keys(logger.serializers), - logger.serializers, - logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize - ); - logger._logEvent.ts = ts2; - logger._logEvent.messages = args.filter(function(arg) { - return bindings.indexOf(arg) === -1; - }); - logger._logEvent.level.label = methodLevel; - logger._logEvent.level.value = methodValue; - send(methodLevel, logger._logEvent, val); - logger._logEvent = createLogEventShape(bindings); + if (opts.timestamp === false) { + return nullTime; } - function createLogEventShape(bindings) { - return { - ts: 0, - messages: [], - bindings: bindings || [], - level: { label: "", value: 0 } - }; + return epochTime; +} +function mock() { + return {}; +} +function passthrough(a3) { + return a3; +} +function noop$1() { +} +function nullTime() { + return false; +} +function epochTime() { + return Date.now(); +} +function unixTime() { + return Math.round(Date.now() / 1e3); +} +function isoTime() { + return new Date(Date.now()).toISOString(); +} +function pfGlobalThisOrFallback() { + function defd(o2) { + return typeof o2 !== "undefined" && o2; } - function asErrValue(err) { - const obj = { - type: err.constructor.name, - msg: err.message, - stack: err.stack - }; - for (const key in err) { - if (obj[key] === void 0) { - obj[key] = err[key]; - } - } - return obj; + try { + if (typeof globalThis !== "undefined") + return globalThis; + Object.defineProperty(Object.prototype, "globalThis", { + get: function() { + delete Object.prototype.globalThis; + return this.globalThis = this; + }, + configurable: true + }); + return globalThis; + } catch (e2) { + return defd(self) || defd(window) || defd(this) || {}; } - function getTimeFunction(opts) { - if (typeof opts.timestamp === "function") { - return opts.timestamp; - } - if (opts.timestamp === false) { - return nullTime; - } - return epochTime; +} +const nt$1 = /* @__PURE__ */ getDefaultExportFromCjs(browser$4); +const c$1 = { level: "info" }, n$3 = "custom_context", l = 1e3 * 1024; +let O$1 = class O { + constructor(e2) { + this.nodeValue = e2, this.sizeInBytes = new TextEncoder().encode(this.nodeValue).length, this.next = null; } - function mock() { - return {}; + get value() { + return this.nodeValue; } - function passthrough(a3) { - return a3; + get size() { + return this.sizeInBytes; } - function noop2() { +}; +let d$2 = class d2 { + constructor(e2) { + this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e2, this.sizeInBytes = 0; } - function nullTime() { - return false; + append(e2) { + const t2 = new O$1(e2); + if (t2.size > this.maxSizeInBytes) + throw new Error(`[LinkedList] Value too big to insert into list: ${e2} with size ${t2.size}`); + for (; this.size + t2.size > this.maxSizeInBytes; ) + this.shift(); + this.head ? (this.tail && (this.tail.next = t2), this.tail = t2) : (this.head = t2, this.tail = t2), this.lengthInNodes++, this.sizeInBytes += t2.size; } - function epochTime() { - return Date.now(); + shift() { + if (!this.head) + return; + const e2 = this.head; + this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e2.size; } - function unixTime() { - return Math.round(Date.now() / 1e3); + toArray() { + const e2 = []; + let t2 = this.head; + for (; t2 !== null; ) + e2.push(t2.value), t2 = t2.next; + return e2; } - function isoTime() { - return new Date(Date.now()).toISOString(); + get length() { + return this.lengthInNodes; } - function pfGlobalThisOrFallback() { - function defd(o2) { - return typeof o2 !== "undefined" && o2; - } - try { - if (typeof globalThis !== "undefined") - return globalThis; - Object.defineProperty(Object.prototype, "globalThis", { - get: function() { - delete Object.prototype.globalThis; - return this.globalThis = this; - }, - configurable: true - }); - return globalThis; - } catch (e) { - return defd(self) || defd(window) || defd(this) || {}; - } + get size() { + return this.sizeInBytes; } - return browser$4; -} -var constants = {}; -var hasRequiredConstants; -function requireConstants() { - if (hasRequiredConstants) - return constants; - hasRequiredConstants = 1; - Object.defineProperty(constants, "__esModule", { value: true }); - constants.PINO_CUSTOM_CONTEXT_KEY = constants.PINO_LOGGER_DEFAULTS = void 0; - constants.PINO_LOGGER_DEFAULTS = { - level: "info" - }; - constants.PINO_CUSTOM_CONTEXT_KEY = "custom_context"; - return constants; -} -var utils = {}; -var hasRequiredUtils; -function requireUtils() { - if (hasRequiredUtils) - return utils; - hasRequiredUtils = 1; - Object.defineProperty(utils, "__esModule", { value: true }); - utils.generateChildLogger = utils.formatChildLoggerContext = utils.getLoggerContext = utils.setBrowserLoggerContext = utils.getBrowserLoggerContext = utils.getDefaultLoggerOptions = void 0; - const constants_1 = requireConstants(); - function getDefaultLoggerOptions(opts) { - return Object.assign(Object.assign({}, opts), { level: (opts === null || opts === void 0 ? void 0 : opts.level) || constants_1.PINO_LOGGER_DEFAULTS.level }); - } - utils.getDefaultLoggerOptions = getDefaultLoggerOptions; - function getBrowserLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - return logger[customContextKey] || ""; - } - utils.getBrowserLoggerContext = getBrowserLoggerContext; - function setBrowserLoggerContext(logger, context, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - logger[customContextKey] = context; - return logger; - } - utils.setBrowserLoggerContext = setBrowserLoggerContext; - function getLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - let context = ""; - if (typeof logger.bindings === "undefined") { - context = getBrowserLoggerContext(logger, customContextKey); - } else { - context = logger.bindings().context || ""; - } - return context; + toOrderedArray() { + return Array.from(this); + } + [Symbol.iterator]() { + let e2 = this.head; + return { next: () => { + if (!e2) + return { done: true, value: null }; + const t2 = e2.value; + return e2 = e2.next, { done: false, value: t2 }; + } }; } - utils.getLoggerContext = getLoggerContext; - function formatChildLoggerContext(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const parentContext = getLoggerContext(logger, customContextKey); - const context = parentContext.trim() ? `${parentContext}/${childContext}` : childContext; - return context; +}; +let L$4 = class L { + constructor(e2, t2 = l) { + this.level = e2 ?? "error", this.levelValue = browser$4.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = t2, this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); } - utils.formatChildLoggerContext = formatChildLoggerContext; - function generateChildLogger(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const context = formatChildLoggerContext(logger, childContext, customContextKey); - const child = logger.child({ context }); - return setBrowserLoggerContext(child, context, customContextKey); + forwardToConsole(e2, t2) { + t2 === browser$4.levels.values.error ? console.error(e2) : t2 === browser$4.levels.values.warn ? console.warn(e2) : t2 === browser$4.levels.values.debug ? console.debug(e2) : t2 === browser$4.levels.values.trace ? console.trace(e2) : console.log(e2); + } + appendToLogs(e2) { + this.logs.append(safeJsonStringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: e2 })); + const t2 = typeof e2 == "string" ? JSON.parse(e2).level : e2.level; + t2 >= this.levelValue && this.forwardToConsole(e2, t2); + } + getLogs() { + return this.logs; + } + clearLogs() { + this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); + } + getLogArray() { + return Array.from(this.logs); + } + logsToBlob(e2) { + const t2 = this.getLogArray(); + return t2.push(safeJsonStringify({ extraMetadata: e2 })), new Blob(t2, { type: "application/json" }); + } +}; +let m$1 = class m { + constructor(e2, t2 = l) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } + downloadLogsBlobInBrowser(e2) { + const t2 = URL.createObjectURL(this.logsToBlob(e2)), o2 = document.createElement("a"); + o2.href = t2, o2.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(o2), o2.click(), document.body.removeChild(o2), URL.revokeObjectURL(t2); + } +}; +class B { + constructor(e2, t2 = l) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); } - utils.generateChildLogger = generateChildLogger; - return utils; } -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.pino = void 0; - const tslib_1 = require$$0$2; - const pino_1 = tslib_1.__importDefault(requireBrowser()); - Object.defineProperty(exports2, "pino", { enumerable: true, get: function() { - return pino_1.default; - } }); - tslib_1.__exportStar(requireConstants(), exports2); - tslib_1.__exportStar(requireUtils(), exports2); -})(cjs$3); -let n$1 = class n extends IEvents$1 { +var x = Object.defineProperty, S$3 = Object.defineProperties, _2 = Object.getOwnPropertyDescriptors, p$1 = Object.getOwnPropertySymbols, T$1 = Object.prototype.hasOwnProperty, z$2 = Object.prototype.propertyIsEnumerable, f$3 = (r3, e2, t2) => e2 in r3 ? x(r3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : r3[e2] = t2, i = (r3, e2) => { + for (var t2 in e2 || (e2 = {})) + T$1.call(e2, t2) && f$3(r3, t2, e2[t2]); + if (p$1) + for (var t2 of p$1(e2)) + z$2.call(e2, t2) && f$3(r3, t2, e2[t2]); + return r3; +}, g$2 = (r3, e2) => S$3(r3, _2(e2)); +function k$2(r3) { + return g$2(i({}, r3), { level: (r3 == null ? void 0 : r3.level) || c$1.level }); +} +function v$2(r3, e2 = n$3) { + return r3[e2] || ""; +} +function b$2(r3, e2, t2 = n$3) { + return r3[t2] = e2, r3; +} +function y$2(r3, e2 = n$3) { + let t2 = ""; + return typeof r3.bindings > "u" ? t2 = v$2(r3, e2) : t2 = r3.bindings().context || "", t2; +} +function w$3(r3, e2, t2 = n$3) { + const o2 = y$2(r3, t2); + return o2.trim() ? `${o2}/${e2}` : e2; +} +function E$1(r3, e2, t2 = n$3) { + const o2 = w$3(r3, e2, t2), a3 = r3.child({ context: o2 }); + return b$2(a3, o2, t2); +} +function C$2(r3) { + var e2, t2; + const o2 = new m$1((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i({}, r3.opts), { level: "trace", browser: g$2(i({}, (t2 = r3.opts) == null ? void 0 : t2.browser), { write: (a3) => o2.write(a3) }) })), chunkLoggerController: o2 }; +} +function I$2(r3) { + var e2; + const t2 = new B((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i({}, r3.opts), { level: "trace" }), t2), chunkLoggerController: t2 }; +} +function A$2(r3) { + return typeof r3.loggerOverride < "u" && typeof r3.loggerOverride != "string" ? { logger: r3.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? C$2(r3) : I$2(r3); +} +let n$2 = class n extends IEvents { constructor(s2) { super(), this.opts = s2, this.protocol = "wc", this.version = 2; } }; -let h$2 = class h2 extends IEvents$1 { +let h$1 = class h2 extends IEvents { constructor(s2, t2) { super(), this.core = s2, this.logger = t2, this.records = /* @__PURE__ */ new Map(); } }; -let a$2 = class a { +let a$1 = class a { constructor(s2, t2) { this.logger = s2, this.core = t2; } }; -let u$1 = class u extends IEvents$1 { +let u$1 = class u extends IEvents { constructor(s2, t2) { super(), this.relayer = s2, this.logger = t2; } }; -let g$4 = class g extends IEvents$1 { +let g$1 = class g extends IEvents { constructor(s2) { super(); } }; -let p$2 = class p { +class p { constructor(s2, t2, o2, M2) { this.core = s2, this.logger = t2, this.name = o2; } -}; -class d2 extends IEvents$1 { +} +let d$1 = class d3 extends IEvents { constructor(s2, t2) { super(), this.relayer = s2, this.logger = t2; } -} -class E extends IEvents$1 { +}; +class E extends IEvents { constructor(s2, t2) { super(), this.core = s2, this.logger = t2; } @@ -3124,7 +3053,7 @@ let b$1 = class b { this.opts = s2, this.protocol = "wc", this.version = 2; } }; -let w$4 = class w { +let w$2 = class w { constructor(s2) { this.client = s2; } @@ -3245,9 +3174,9 @@ var int = {}; (function(exports2) { Object.defineProperty(exports2, "__esModule", { value: true }); function imulShim(a3, b3) { - var ah = a3 >>> 16 & 65535, al = a3 & 65535; + var ah2 = a3 >>> 16 & 65535, al = a3 & 65535; var bh = b3 >>> 16 & 65535, bl = b3 & 65535; - return al * bl + (ah * bl + al * bh << 16 >>> 0) | 0; + return al * bl + (ah2 * bl + al * bh << 16 >>> 0) | 0; } exports2.mul = Math.imul || imulShim; function add(a3, b3) { @@ -3258,21 +3187,21 @@ var int = {}; return a3 - b3 | 0; } exports2.sub = sub; - function rotl(x2, n3) { - return x2 << n3 | x2 >>> 32 - n3; + function rotl(x2, n4) { + return x2 << n4 | x2 >>> 32 - n4; } exports2.rotl = rotl; - function rotr(x2, n3) { - return x2 << 32 - n3 | x2 >>> n3; + function rotr(x2, n4) { + return x2 << 32 - n4 | x2 >>> n4; } exports2.rotr = rotr; - function isIntegerShim(n3) { - return typeof n3 === "number" && isFinite(n3) && Math.floor(n3) === n3; + function isIntegerShim(n4) { + return typeof n4 === "number" && isFinite(n4) && Math.floor(n4) === n4; } exports2.isInteger = Number.isInteger || isIntegerShim; exports2.MAX_SAFE_INTEGER = 9007199254740991; - exports2.isSafeInteger = function(n3) { - return exports2.isInteger(n3) && (n3 >= -exports2.MAX_SAFE_INTEGER && n3 <= exports2.MAX_SAFE_INTEGER); + exports2.isSafeInteger = function(n4) { + return exports2.isInteger(n4) && (n4 >= -exports2.MAX_SAFE_INTEGER && n4 <= exports2.MAX_SAFE_INTEGER); }; })(int); Object.defineProperty(binary, "__esModule", { value: true }); @@ -3394,8 +3323,8 @@ function readInt64BE(array, offset) { offset = 0; } var hi = readInt32BE(array, offset); - var lo = readInt32BE(array, offset + 4); - return hi * 4294967296 + lo - (lo >> 31) * 4294967296; + var lo2 = readInt32BE(array, offset + 4); + return hi * 4294967296 + lo2 - (lo2 >> 31) * 4294967296; } binary.readInt64BE = readInt64BE; function readUint64BE(array, offset) { @@ -3403,26 +3332,26 @@ function readUint64BE(array, offset) { offset = 0; } var hi = readUint32BE(array, offset); - var lo = readUint32BE(array, offset + 4); - return hi * 4294967296 + lo; + var lo2 = readUint32BE(array, offset + 4); + return hi * 4294967296 + lo2; } binary.readUint64BE = readUint64BE; function readInt64LE(array, offset) { if (offset === void 0) { offset = 0; } - var lo = readInt32LE(array, offset); + var lo2 = readInt32LE(array, offset); var hi = readInt32LE(array, offset + 4); - return hi * 4294967296 + lo - (lo >> 31) * 4294967296; + return hi * 4294967296 + lo2 - (lo2 >> 31) * 4294967296; } binary.readInt64LE = readInt64LE; function readUint64LE(array, offset) { if (offset === void 0) { offset = 0; } - var lo = readUint32LE(array, offset); + var lo2 = readUint32LE(array, offset); var hi = readUint32LE(array, offset + 4); - return hi * 4294967296 + lo; + return hi * 4294967296 + lo2; } binary.readUint64LE = readUint64LE; function writeUint64BE(value, out, offset) { @@ -3806,7 +3735,7 @@ var sha512 = {}; }() ); exports2.SHA512 = SHA512; - var K2 = new Int32Array([ + var K3 = new Int32Array([ 1116352408, 3609767458, 1899447441, @@ -3968,16 +3897,16 @@ var sha512 = {}; 1816402316, 1246189591 ]); - function hashBlocks(wh, wl, hh, hl, m2, pos, len) { - var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; + function hashBlocks(wh, wl, hh2, hl, m3, pos, len) { + var ah0 = hh2[0], ah1 = hh2[1], ah2 = hh2[2], ah3 = hh2[3], ah4 = hh2[4], ah5 = hh2[5], ah6 = hh2[6], ah7 = hh2[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; var h4, l2; - var th, tl; - var a3, b3, c2, d3; + var th2, tl; + var a3, b3, c2, d5; while (len >= 128) { for (var i2 = 0; i2 < 16; i2++) { var j2 = 8 * i2 + pos; - wh[i2] = binary_12.readUint32BE(m2, j2); - wl[i2] = binary_12.readUint32BE(m2, j2 + 4); + wh[i2] = binary_12.readUint32BE(m3, j2); + wl[i2] = binary_12.readUint32BE(m3, j2 + 4); } for (var i2 = 0; i2 < 80; i2++) { var bh0 = ah0; @@ -4001,75 +3930,75 @@ var sha512 = {}; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32)); l2 = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32)); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = ah4 & ah5 ^ ~ah4 & ah6; l2 = al4 & al5 ^ ~al4 & al6; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = K2[i2 * 2]; - l2 = K2[i2 * 2 + 1]; + d5 += h4 >>> 16; + h4 = K3[i2 * 2]; + l2 = K3[i2 * 2 + 1]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = wh[i2 % 16]; l2 = wl[i2 % 16]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - th = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + th2 = c2 & 65535 | d5 << 16; tl = a3 & 65535 | b3 << 16; - h4 = th; + h4 = th2; l2 = tl; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32)); l2 = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32)); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2; l2 = al0 & al1 ^ al0 & al2 ^ al1 & al2; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh7 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + bh7 = c2 & 65535 | d5 << 16; bl7 = a3 & 65535 | b3 << 16; h4 = bh3; l2 = bl3; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = th; + d5 = h4 >>> 16; + h4 = th2; l2 = tl; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh3 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + bh3 = c2 & 65535 | d5 << 16; bl3 = a3 & 65535 | b3 << 16; ah1 = bh0; ah2 = bh1; @@ -4094,33 +4023,33 @@ var sha512 = {}; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = wh[(j2 + 9) % 16]; l2 = wl[(j2 + 9) % 16]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 1) % 16]; + d5 += h4 >>> 16; + th2 = wh[(j2 + 1) % 16]; tl = wl[(j2 + 1) % 16]; - h4 = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7; - l2 = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7); + h4 = (th2 >>> 1 | tl << 32 - 1) ^ (th2 >>> 8 | tl << 32 - 8) ^ th2 >>> 7; + l2 = (tl >>> 1 | th2 << 32 - 1) ^ (tl >>> 8 | th2 << 32 - 8) ^ (tl >>> 7 | th2 << 32 - 7); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 14) % 16]; + d5 += h4 >>> 16; + th2 = wh[(j2 + 14) % 16]; tl = wl[(j2 + 14) % 16]; - h4 = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6; - l2 = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6); + h4 = (th2 >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th2 << 32 - (61 - 32)) ^ th2 >>> 6; + l2 = (tl >>> 19 | th2 << 32 - 19) ^ (th2 >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th2 << 32 - 6); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - wh[j2] = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + wh[j2] = c2 & 65535 | d5 << 16; wl[j2] = a3 & 65535 | b3 << 16; } } @@ -4130,136 +4059,136 @@ var sha512 = {}; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[0]; + d5 = h4 >>> 16; + h4 = hh2[0]; l2 = hl[0]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[0] = ah0 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[0] = ah0 = c2 & 65535 | d5 << 16; hl[0] = al0 = a3 & 65535 | b3 << 16; h4 = ah1; l2 = al1; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[1]; + d5 = h4 >>> 16; + h4 = hh2[1]; l2 = hl[1]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[1] = ah1 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[1] = ah1 = c2 & 65535 | d5 << 16; hl[1] = al1 = a3 & 65535 | b3 << 16; h4 = ah2; l2 = al2; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[2]; + d5 = h4 >>> 16; + h4 = hh2[2]; l2 = hl[2]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[2] = ah2 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[2] = ah2 = c2 & 65535 | d5 << 16; hl[2] = al2 = a3 & 65535 | b3 << 16; h4 = ah3; l2 = al3; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[3]; + d5 = h4 >>> 16; + h4 = hh2[3]; l2 = hl[3]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[3] = ah3 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[3] = ah3 = c2 & 65535 | d5 << 16; hl[3] = al3 = a3 & 65535 | b3 << 16; h4 = ah4; l2 = al4; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[4]; + d5 = h4 >>> 16; + h4 = hh2[4]; l2 = hl[4]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[4] = ah4 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[4] = ah4 = c2 & 65535 | d5 << 16; hl[4] = al4 = a3 & 65535 | b3 << 16; h4 = ah5; l2 = al5; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[5]; + d5 = h4 >>> 16; + h4 = hh2[5]; l2 = hl[5]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[5] = ah5 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[5] = ah5 = c2 & 65535 | d5 << 16; hl[5] = al5 = a3 & 65535 | b3 << 16; h4 = ah6; l2 = al6; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[6]; + d5 = h4 >>> 16; + h4 = hh2[6]; l2 = hl[6]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[6] = ah6 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[6] = ah6 = c2 & 65535 | d5 << 16; hl[6] = al6 = a3 & 65535 | b3 << 16; h4 = ah7; l2 = al7; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[7]; + d5 = h4 >>> 16; + h4 = hh2[7]; l2 = hl[7]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[7] = ah7 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[7] = ah7 = c2 & 65535 | d5 << 16; hl[7] = al7 = a3 & 65535 | b3 << 16; pos += 128; len -= 128; @@ -4285,20 +4214,20 @@ var sha512 = {}; exports2.PUBLIC_KEY_LENGTH = 32; exports2.SECRET_KEY_LENGTH = 64; exports2.SEED_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); + function gf2(init) { + const r3 = new Float64Array(16); if (init) { for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; + r3[i2] = init[i2]; } } - return r2; + return r3; } const _9 = new Uint8Array(32); _9[0] = 9; - const gf0 = gf(); - const gf1 = gf([1]); - const D2 = gf([ + const gf0 = gf2(); + const gf1 = gf2([1]); + const D2 = gf2([ 30883, 4953, 19914, @@ -4316,7 +4245,7 @@ var sha512 = {}; 27886, 20995 ]); - const D22 = gf([ + const D22 = gf2([ 61785, 9906, 39828, @@ -4334,7 +4263,7 @@ var sha512 = {}; 55772, 9222 ]); - const X2 = gf([ + const X2 = gf2([ 54554, 36645, 11616, @@ -4352,7 +4281,7 @@ var sha512 = {}; 14035, 8553 ]); - const Y2 = gf([ + const Y2 = gf2([ 26200, 26214, 26214, @@ -4370,7 +4299,7 @@ var sha512 = {}; 26214, 26214 ]); - const I2 = gf([ + const I2 = gf2([ 41136, 18958, 6951, @@ -4388,9 +4317,9 @@ var sha512 = {}; 9344, 11139 ]); - function set25519(r2, a3) { + function set25519(r3, a3) { for (let i2 = 0; i2 < 16; i2++) { - r2[i2] = a3[i2] | 0; + r3[i2] = a3[i2] | 0; } } function car25519(o2) { @@ -4402,33 +4331,33 @@ var sha512 = {}; } o2[0] += c2 - 1 + 37 * (c2 - 1); } - function sel25519(p3, q2, b3) { + function sel25519(p2, q2, b3) { const c2 = ~(b3 - 1); for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; q2[i2] ^= t2; } } - function pack25519(o2, n3) { - const m2 = gf(); - const t2 = gf(); + function pack25519(o2, n4) { + const m3 = gf2(); + const t2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; + t2[i2] = n4[i2]; } car25519(t2); car25519(t2); car25519(t2); for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; + m3[0] = t2[0] - 65517; for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); } for (let i2 = 0; i2 < 16; i2++) { o2[2 * i2] = t2[i2] & 255; @@ -4436,27 +4365,27 @@ var sha512 = {}; } } function verify32(x2, y3) { - let d3 = 0; + let d5 = 0; for (let i2 = 0; i2 < 32; i2++) { - d3 |= x2[i2] ^ y3[i2]; + d5 |= x2[i2] ^ y3[i2]; } - return (1 & d3 - 1 >>> 8) - 1; + return (1 & d5 - 1 >>> 8) - 1; } function neq25519(a3, b3) { const c2 = new Uint8Array(32); - const d3 = new Uint8Array(32); + const d5 = new Uint8Array(32); pack25519(c2, a3); - pack25519(d3, b3); - return verify32(c2, d3); + pack25519(d5, b3); + return verify32(c2, d5); } function par25519(a3) { - const d3 = new Uint8Array(32); - pack25519(d3, a3); - return d3[0] & 1; + const d5 = new Uint8Array(32); + pack25519(d5, a3); + return d5[0] & 1; } - function unpack25519(o2, n3) { + function unpack25519(o2, n4) { for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); + o2[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); } o2[15] &= 32767; } @@ -4471,9 +4400,9 @@ var sha512 = {}; } } function mul(o2, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; v3 = a3[0]; - t0 += v3 * b0; + t0 += v3 * b02; t1 += v3 * b1; t2 += v3 * b22; t3 += v3 * b32; @@ -4490,7 +4419,7 @@ var sha512 = {}; t14 += v3 * b14; t15 += v3 * b15; v3 = a3[1]; - t1 += v3 * b0; + t1 += v3 * b02; t2 += v3 * b1; t3 += v3 * b22; t4 += v3 * b32; @@ -4507,7 +4436,7 @@ var sha512 = {}; t15 += v3 * b14; t16 += v3 * b15; v3 = a3[2]; - t2 += v3 * b0; + t2 += v3 * b02; t3 += v3 * b1; t4 += v3 * b22; t5 += v3 * b32; @@ -4524,7 +4453,7 @@ var sha512 = {}; t16 += v3 * b14; t17 += v3 * b15; v3 = a3[3]; - t3 += v3 * b0; + t3 += v3 * b02; t4 += v3 * b1; t5 += v3 * b22; t6 += v3 * b32; @@ -4541,7 +4470,7 @@ var sha512 = {}; t17 += v3 * b14; t18 += v3 * b15; v3 = a3[4]; - t4 += v3 * b0; + t4 += v3 * b02; t5 += v3 * b1; t6 += v3 * b22; t7 += v3 * b32; @@ -4558,7 +4487,7 @@ var sha512 = {}; t18 += v3 * b14; t19 += v3 * b15; v3 = a3[5]; - t5 += v3 * b0; + t5 += v3 * b02; t6 += v3 * b1; t7 += v3 * b22; t8 += v3 * b32; @@ -4575,7 +4504,7 @@ var sha512 = {}; t19 += v3 * b14; t20 += v3 * b15; v3 = a3[6]; - t6 += v3 * b0; + t6 += v3 * b02; t7 += v3 * b1; t8 += v3 * b22; t9 += v3 * b32; @@ -4592,7 +4521,7 @@ var sha512 = {}; t20 += v3 * b14; t21 += v3 * b15; v3 = a3[7]; - t7 += v3 * b0; + t7 += v3 * b02; t8 += v3 * b1; t9 += v3 * b22; t10 += v3 * b32; @@ -4609,7 +4538,7 @@ var sha512 = {}; t21 += v3 * b14; t22 += v3 * b15; v3 = a3[8]; - t8 += v3 * b0; + t8 += v3 * b02; t9 += v3 * b1; t10 += v3 * b22; t11 += v3 * b32; @@ -4626,7 +4555,7 @@ var sha512 = {}; t22 += v3 * b14; t23 += v3 * b15; v3 = a3[9]; - t9 += v3 * b0; + t9 += v3 * b02; t10 += v3 * b1; t11 += v3 * b22; t12 += v3 * b32; @@ -4643,7 +4572,7 @@ var sha512 = {}; t23 += v3 * b14; t24 += v3 * b15; v3 = a3[10]; - t10 += v3 * b0; + t10 += v3 * b02; t11 += v3 * b1; t12 += v3 * b22; t13 += v3 * b32; @@ -4660,7 +4589,7 @@ var sha512 = {}; t24 += v3 * b14; t25 += v3 * b15; v3 = a3[11]; - t11 += v3 * b0; + t11 += v3 * b02; t12 += v3 * b1; t13 += v3 * b22; t14 += v3 * b32; @@ -4677,7 +4606,7 @@ var sha512 = {}; t25 += v3 * b14; t26 += v3 * b15; v3 = a3[12]; - t12 += v3 * b0; + t12 += v3 * b02; t13 += v3 * b1; t14 += v3 * b22; t15 += v3 * b32; @@ -4694,7 +4623,7 @@ var sha512 = {}; t26 += v3 * b14; t27 += v3 * b15; v3 = a3[13]; - t13 += v3 * b0; + t13 += v3 * b02; t14 += v3 * b1; t15 += v3 * b22; t16 += v3 * b32; @@ -4711,7 +4640,7 @@ var sha512 = {}; t27 += v3 * b14; t28 += v3 * b15; v3 = a3[14]; - t14 += v3 * b0; + t14 += v3 * b02; t15 += v3 * b1; t16 += v3 * b22; t17 += v3 * b32; @@ -4728,7 +4657,7 @@ var sha512 = {}; t28 += v3 * b14; t29 += v3 * b15; v3 = a3[15]; - t15 += v3 * b0; + t15 += v3 * b02; t16 += v3 * b1; t17 += v3 * b22; t18 += v3 * b32; @@ -4880,7 +4809,7 @@ var sha512 = {}; mul(o2, a3, a3); } function inv25519(o2, i2) { - const c2 = gf(); + const c2 = gf2(); let a3; for (a3 = 0; a3 < 16; a3++) { c2[a3] = i2[a3]; @@ -4896,7 +4825,7 @@ var sha512 = {}; } } function pow2523(o2, i2) { - const c2 = gf(); + const c2 = gf2(); let a3; for (a3 = 0; a3 < 16; a3++) { c2[a3] = i2[a3]; @@ -4911,73 +4840,73 @@ var sha512 = {}; o2[a3] = c2[a3]; } } - function edadd(p3, q2) { - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e = gf(), f2 = gf(), g3 = gf(), h4 = gf(), t2 = gf(); - sub(a3, p3[1], p3[0]); + function edadd(p2, q2) { + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(), g3 = gf2(), h4 = gf2(), t2 = gf2(); + sub(a3, p2[1], p2[0]); sub(t2, q2[1], q2[0]); mul(a3, a3, t2); - add(b3, p3[0], p3[1]); + add(b3, p2[0], p2[1]); add(t2, q2[0], q2[1]); mul(b3, b3, t2); - mul(c2, p3[3], q2[3]); + mul(c2, p2[3], q2[3]); mul(c2, c2, D22); - mul(d3, p3[2], q2[2]); - add(d3, d3, d3); - sub(e, b3, a3); - sub(f2, d3, c2); - add(g3, d3, c2); + mul(d5, p2[2], q2[2]); + add(d5, d5, d5); + sub(e2, b3, a3); + sub(f3, d5, c2); + add(g3, d5, c2); add(h4, b3, a3); - mul(p3[0], e, f2); - mul(p3[1], h4, g3); - mul(p3[2], g3, f2); - mul(p3[3], e, h4); + mul(p2[0], e2, f3); + mul(p2[1], h4, g3); + mul(p2[2], g3, f3); + mul(p2[3], e2, h4); } - function cswap(p3, q2, b3) { + function cswap(p2, q2, b3) { for (let i2 = 0; i2 < 4; i2++) { - sel25519(p3[i2], q2[i2], b3); - } - } - function pack(r2, p3) { - const tx = gf(), ty = gf(), zi = gf(); - inv25519(zi, p3[2]); - mul(tx, p3[0], zi); - mul(ty, p3[1], zi); - pack25519(r2, ty); - r2[31] ^= par25519(tx) << 7; - } - function scalarmult(p3, q2, s2) { - set25519(p3[0], gf0); - set25519(p3[1], gf1); - set25519(p3[2], gf1); - set25519(p3[3], gf0); + sel25519(p2[i2], q2[i2], b3); + } + } + function pack(r3, p2) { + const tx = gf2(), ty = gf2(), zi2 = gf2(); + inv25519(zi2, p2[2]); + mul(tx, p2[0], zi2); + mul(ty, p2[1], zi2); + pack25519(r3, ty); + r3[31] ^= par25519(tx) << 7; + } + function scalarmult(p2, q2, s2) { + set25519(p2[0], gf0); + set25519(p2[1], gf1); + set25519(p2[2], gf1); + set25519(p2[3], gf0); for (let i2 = 255; i2 >= 0; --i2) { const b3 = s2[i2 / 8 | 0] >> (i2 & 7) & 1; - cswap(p3, q2, b3); - edadd(q2, p3); - edadd(p3, p3); - cswap(p3, q2, b3); + cswap(p2, q2, b3); + edadd(q2, p2); + edadd(p2, p2); + cswap(p2, q2, b3); } } - function scalarbase(p3, s2) { - const q2 = [gf(), gf(), gf(), gf()]; + function scalarbase(p2, s2) { + const q2 = [gf2(), gf2(), gf2(), gf2()]; set25519(q2[0], X2); set25519(q2[1], Y2); set25519(q2[2], gf1); mul(q2[3], X2, Y2); - scalarmult(p3, q2, s2); + scalarmult(p2, q2, s2); } function generateKeyPairFromSeed(seed) { if (seed.length !== exports2.SEED_LENGTH) { throw new Error(`ed25519: seed must be ${exports2.SEED_LENGTH} bytes`); } - const d3 = (0, sha512_1.hash)(seed); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; + const d5 = (0, sha512_1.hash)(seed); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; const publicKey = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - scalarbase(p3, d3); - pack(publicKey, p3); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + scalarbase(p2, d5); + pack(publicKey, p2); const secretKey = new Uint8Array(64); secretKey.set(seed); secretKey.set(publicKey, 32); @@ -5001,7 +4930,7 @@ var sha512 = {}; return new Uint8Array(secretKey.subarray(32)); } exports2.extractPublicKeyFromSecretKey = extractPublicKeyFromSecretKey; - const L2 = new Float64Array([ + const L4 = new Float64Array([ 237, 211, 245, @@ -5035,7 +4964,7 @@ var sha512 = {}; 0, 16 ]); - function modL(r2, x2) { + function modL(r3, x2) { let carry; let i2; let j2; @@ -5043,7 +4972,7 @@ var sha512 = {}; for (i2 = 63; i2 >= 32; --i2) { carry = 0; for (j2 = i2 - 32, k2 = i2 - 12; j2 < k2; ++j2) { - x2[j2] += carry - 16 * x2[i2] * L2[j2 - (i2 - 32)]; + x2[j2] += carry - 16 * x2[i2] * L4[j2 - (i2 - 32)]; carry = Math.floor((x2[j2] + 128) / 256); x2[j2] -= carry * 256; } @@ -5052,45 +4981,45 @@ var sha512 = {}; } carry = 0; for (j2 = 0; j2 < 32; j2++) { - x2[j2] += carry - (x2[31] >> 4) * L2[j2]; + x2[j2] += carry - (x2[31] >> 4) * L4[j2]; carry = x2[j2] >> 8; x2[j2] &= 255; } for (j2 = 0; j2 < 32; j2++) { - x2[j2] -= carry * L2[j2]; + x2[j2] -= carry * L4[j2]; } for (i2 = 0; i2 < 32; i2++) { x2[i2 + 1] += x2[i2] >> 8; - r2[i2] = x2[i2] & 255; + r3[i2] = x2[i2] & 255; } } - function reduce(r2) { + function reduce(r3) { const x2 = new Float64Array(64); for (let i2 = 0; i2 < 64; i2++) { - x2[i2] = r2[i2]; + x2[i2] = r3[i2]; } for (let i2 = 0; i2 < 64; i2++) { - r2[i2] = 0; + r3[i2] = 0; } - modL(r2, x2); + modL(r3, x2); } function sign(secretKey, message) { const x2 = new Float64Array(64); - const p3 = [gf(), gf(), gf(), gf()]; - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; const signature = new Uint8Array(64); - signature.set(d3.subarray(32), 32); + signature.set(d5.subarray(32), 32); const hs2 = new sha512_1.SHA512(); hs2.update(signature.subarray(32)); hs2.update(message); - const r2 = hs2.digest(); + const r3 = hs2.digest(); hs2.clean(); - reduce(r2); - scalarbase(p3, r2); - pack(signature, p3); + reduce(r3); + scalarbase(p2, r3); + pack(signature, p2); hs2.reset(); hs2.update(signature.subarray(0, 32)); hs2.update(secretKey.subarray(32)); @@ -5098,25 +5027,25 @@ var sha512 = {}; const h4 = hs2.digest(); reduce(h4); for (let i2 = 0; i2 < 32; i2++) { - x2[i2] = r2[i2]; + x2[i2] = r3[i2]; } for (let i2 = 0; i2 < 32; i2++) { for (let j2 = 0; j2 < 32; j2++) { - x2[i2 + j2] += h4[i2] * d3[j2]; + x2[i2 + j2] += h4[i2] * d5[j2]; } } modL(signature.subarray(32), x2); return signature; } exports2.sign = sign; - function unpackneg(r2, p3) { - const t2 = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf(); - set25519(r2[2], gf1); - unpack25519(r2[1], p3); - square(num, r2[1]); + function unpackneg(r3, p2) { + const t2 = gf2(), chk = gf2(), num = gf2(), den = gf2(), den2 = gf2(), den4 = gf2(), den6 = gf2(); + set25519(r3[2], gf1); + unpack25519(r3[1], p2); + square(num, r3[1]); mul(den, num, D2); - sub(num, num, r2[2]); - add(den, r2[2], den); + sub(num, num, r3[2]); + add(den, r3[2], den); square(den2, den); square(den4, den2); mul(den6, den4, den2); @@ -5126,27 +5055,27 @@ var sha512 = {}; mul(t2, t2, num); mul(t2, t2, den); mul(t2, t2, den); - mul(r2[0], t2, den); - square(chk, r2[0]); + mul(r3[0], t2, den); + square(chk, r3[0]); mul(chk, chk, den); if (neq25519(chk, num)) { - mul(r2[0], r2[0], I2); + mul(r3[0], r3[0], I2); } - square(chk, r2[0]); + square(chk, r3[0]); mul(chk, chk, den); if (neq25519(chk, num)) { return -1; } - if (par25519(r2[0]) === p3[31] >> 7) { - sub(r2[0], gf0, r2[0]); + if (par25519(r3[0]) === p2[31] >> 7) { + sub(r3[0], gf0, r3[0]); } - mul(r2[3], r2[0], r2[1]); + mul(r3[3], r3[0], r3[1]); return 0; } function verify(publicKey, message, signature) { const t2 = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - const q2 = [gf(), gf(), gf(), gf()]; + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const q2 = [gf2(), gf2(), gf2(), gf2()]; if (signature.length !== exports2.SIGNATURE_LENGTH) { throw new Error(`ed25519: signature must be ${exports2.SIGNATURE_LENGTH} bytes`); } @@ -5159,10 +5088,10 @@ var sha512 = {}; hs2.update(message); const h4 = hs2.digest(); reduce(h4); - scalarmult(p3, q2, h4); + scalarmult(p2, q2, h4); scalarbase(q2, signature.subarray(32)); - edadd(p3, q2); - pack(t2, p3); + edadd(p2, q2); + pack(t2, p2); if (verify32(signature, t2)) { return false; } @@ -5170,29 +5099,29 @@ var sha512 = {}; } exports2.verify = verify; function convertPublicKeyToX25519(publicKey) { - let q2 = [gf(), gf(), gf(), gf()]; + let q2 = [gf2(), gf2(), gf2(), gf2()]; if (unpackneg(q2, publicKey)) { throw new Error("Ed25519: invalid public key"); } - let a3 = gf(); - let b3 = gf(); + let a3 = gf2(); + let b3 = gf2(); let y3 = q2[1]; add(a3, gf1, y3); sub(b3, gf1, y3); inv25519(b3, b3); mul(a3, a3, b3); - let z32 = new Uint8Array(32); - pack25519(z32, a3); - return z32; + let z2 = new Uint8Array(32); + pack25519(z2, a3); + return z2; } exports2.convertPublicKeyToX25519 = convertPublicKeyToX25519; function convertSecretKeyToX25519(secretKey) { - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const o2 = new Uint8Array(d3.subarray(0, 32)); - (0, wipe_12.wipe)(d3); + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const o2 = new Uint8Array(d5.subarray(0, 32)); + (0, wipe_12.wipe)(d5); return o2; } exports2.convertSecretKeyToX25519 = convertSecretKeyToX25519; @@ -5414,7 +5343,7 @@ class Decoder { } } or(decoder) { - return or$2(this, decoder); + return or$3(this, decoder); } } class ComposedDecoder { @@ -5422,7 +5351,7 @@ class ComposedDecoder { this.decoders = decoders; } or(decoder) { - return or$2(this, decoder); + return or$3(this, decoder); } decode(input) { const prefix = input[0]; @@ -5434,7 +5363,7 @@ class ComposedDecoder { } } } -const or$2 = (left, right) => new ComposedDecoder({ +const or$3 = (left, right) => new ComposedDecoder({ ...left.decoders || { [left.prefix]: left }, ...right.decoders || { [right.prefix]: right } }); @@ -5714,18 +5643,18 @@ const base64$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp base64urlpad }, Symbol.toStringTag, { value: "Module" })); const alphabet = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"); -const alphabetBytesToChars = alphabet.reduce((p3, c2, i2) => { - p3[i2] = c2; - return p3; +const alphabetBytesToChars = alphabet.reduce((p2, c2, i2) => { + p2[i2] = c2; + return p2; }, []); -const alphabetCharsToBytes = alphabet.reduce((p3, c2, i2) => { - p3[c2.codePointAt(0)] = i2; - return p3; +const alphabetCharsToBytes = alphabet.reduce((p2, c2, i2) => { + p2[c2.codePointAt(0)] = i2; + return p2; }, []); function encode(data) { - return data.reduce((p3, c2) => { - p3 += alphabetBytesToChars[c2]; - return p3; + return data.reduce((p2, c2) => { + p2 += alphabetBytesToChars[c2]; + return p2; }, ""); } function decode$1(str) { @@ -5849,7 +5778,7 @@ function encodeJWT(params) { function generateKeyPair(seed = random.randomBytes(KEY_PAIR_SEED_LENGTH)) { return ed25519.generateKeyPairFromSeed(seed); } -async function signJWT(sub, aud, ttl, keyPair, iat = cjs$4.fromMiliseconds(Date.now())) { +async function signJWT(sub, aud, ttl, keyPair, iat = cjs$3.fromMiliseconds(Date.now())) { const header = { alg: JWT_IRIDIUM_ALG, typ: JWT_IRIDIUM_TYP }; const iss = encodeIss(keyPair.publicKey); const exp = iat + ttl; @@ -5858,1334 +5787,2132 @@ async function signJWT(sub, aud, ttl, keyPair, iat = cjs$4.fromMiliseconds(Date. const signature = ed25519.sign(keyPair.secretKey, data); return encodeJWT({ header, payload, signature }); } -var chacha20poly1305 = {}; -var chacha = {}; -Object.defineProperty(chacha, "__esModule", { value: true }); -var binary_1 = binary; -var wipe_1$2 = wipe$1; -var ROUNDS = 20; -function core(out, input, key) { - var j0 = 1634760805; - var j1 = 857760878; - var j2 = 2036477234; - var j3 = 1797285236; - var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; - var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; - var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; - var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; - var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; - var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; - var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; - var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; - var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; - var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; - var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; - var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; - var x0 = j0; - var x1 = j1; - var x2 = j2; - var x3 = j3; - var x4 = j4; - var x5 = j5; - var x6 = j6; - var x7 = j7; - var x8 = j8; - var x9 = j9; - var x10 = j10; - var x11 = j11; - var x12 = j12; - var x13 = j13; - var x14 = j14; - var x15 = j15; - for (var i2 = 0; i2 < ROUNDS; i2 += 2) { - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 16 | x12 << 16; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 12 | x4 << 12; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 16 | x13 << 16; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 12 | x5 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 16 | x14 << 16; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 12 | x6 << 12; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 16 | x15 << 16; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 12 | x7 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 8 | x14 << 8; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 7 | x6 << 7; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 8 | x15 << 8; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 7 | x7 << 7; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 8 | x13 << 8; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 7 | x5 << 7; - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 8 | x12 << 8; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 7 | x4 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 16 | x15 << 16; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 12 | x5 << 12; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 16 | x12 << 16; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 12 | x6 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 16 | x13 << 16; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 12 | x7 << 12; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 16 | x14 << 16; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 12 | x4 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 8 | x13 << 8; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 7 | x7 << 7; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 8 | x14 << 8; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 7 | x4 << 7; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 8 | x12 << 8; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 7 | x6 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 8 | x15 << 8; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 7 | x5 << 7; - } - binary_1.writeUint32LE(x0 + j0 | 0, out, 0); - binary_1.writeUint32LE(x1 + j1 | 0, out, 4); - binary_1.writeUint32LE(x2 + j2 | 0, out, 8); - binary_1.writeUint32LE(x3 + j3 | 0, out, 12); - binary_1.writeUint32LE(x4 + j4 | 0, out, 16); - binary_1.writeUint32LE(x5 + j5 | 0, out, 20); - binary_1.writeUint32LE(x6 + j6 | 0, out, 24); - binary_1.writeUint32LE(x7 + j7 | 0, out, 28); - binary_1.writeUint32LE(x8 + j8 | 0, out, 32); - binary_1.writeUint32LE(x9 + j9 | 0, out, 36); - binary_1.writeUint32LE(x10 + j10 | 0, out, 40); - binary_1.writeUint32LE(x11 + j11 | 0, out, 44); - binary_1.writeUint32LE(x12 + j12 | 0, out, 48); - binary_1.writeUint32LE(x13 + j13 | 0, out, 52); - binary_1.writeUint32LE(x14 + j14 | 0, out, 56); - binary_1.writeUint32LE(x15 + j15 | 0, out, 60); -} -function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - if (key.length !== 32) { - throw new Error("ChaCha: key size must be 32 bytes"); - } - if (dst.length < src2.length) { - throw new Error("ChaCha: destination is shorter than source"); - } - var nc; - var counterLength; - if (nonceInplaceCounterLength === 0) { - if (nonce.length !== 8 && nonce.length !== 12) { - throw new Error("ChaCha nonce must be 8 or 12 bytes"); - } - nc = new Uint8Array(16); - counterLength = nc.length - nonce.length; - nc.set(nonce, counterLength); - } else { - if (nonce.length !== 16) { - throw new Error("ChaCha nonce with counter must be 16 bytes"); +var __spreadArray$3 = function(to2, from2, pack) { + for (var i2 = 0, l2 = from2.length, ar3; i2 < l2; i2++) { + if (ar3 || !(i2 in from2)) { + if (!ar3) + ar3 = Array.prototype.slice.call(from2, 0, i2); + ar3[i2] = from2[i2]; } - nc = nonce; - counterLength = nonceInplaceCounterLength; } - var block = new Uint8Array(64); - for (var i2 = 0; i2 < src2.length; i2 += 64) { - core(block, nc, key); - for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { - dst[j2] = src2[j2] ^ block[j2 - i2]; + return to2.concat(ar3 || Array.prototype.slice.call(from2)); +}; +var BrowserInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BrowserInfo2(name2, version2, os2) { + this.name = name2; + this.version = version2; + this.os = os2; + this.type = "browser"; } - incrementCounter(nc, 0, counterLength); - } - wipe_1$2.wipe(block); - if (nonceInplaceCounterLength === 0) { - wipe_1$2.wipe(nc); + return BrowserInfo2; + }() +); +var NodeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function NodeInfo2(version2) { + this.version = version2; + this.type = "node"; + this.name = "node"; + this.os = process.platform; + } + return NodeInfo2; + }() +); +var SearchBotDeviceInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function SearchBotDeviceInfo2(name2, version2, os2, bot) { + this.name = name2; + this.version = version2; + this.os = os2; + this.bot = bot; + this.type = "bot-device"; + } + return SearchBotDeviceInfo2; + }() +); +var BotInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BotInfo2() { + this.type = "bot"; + this.bot = true; + this.name = "bot"; + this.version = null; + this.os = null; + } + return BotInfo2; + }() +); +var ReactNativeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function ReactNativeInfo2() { + this.type = "react-native"; + this.name = "react-native"; + this.version = null; + this.os = null; + } + return ReactNativeInfo2; + }() +); +var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; +var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; +var REQUIRED_VERSION_PARTS = 3; +var userAgentRules = [ + ["aol", /AOLShield\/([0-9\._]+)/], + ["edge", /Edge\/([0-9\._]+)/], + ["edge-ios", /EdgiOS\/([0-9\._]+)/], + ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], + ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], + ["samsung", /SamsungBrowser\/([0-9\.]+)/], + ["silk", /\bSilk\/([0-9._-]+)\b/], + ["miui", /MiuiBrowser\/([0-9\.]+)$/], + ["beaker", /BeakerBrowser\/([0-9\.]+)/], + ["edge-chromium", /EdgA?\/([0-9\.]+)/], + [ + "chromium-webview", + /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ + ], + ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], + ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], + ["fxios", /FxiOS\/([0-9\.]+)/], + ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], + ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], + ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], + ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], + ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], + ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], + ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ["ie", /MSIE\s(7\.0)/], + ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], + ["android", /Android\s([0-9\.]+)/], + ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ["safari", /Version\/([0-9\._]+).*Safari/], + ["facebook", /FB[AS]V\/([0-9\.]+)/], + ["instagram", /Instagram\s([0-9\.]+)/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ["curl", /^curl\/([0-9\.]+)$/], + ["searchbot", SEARCHBOX_UA_REGEX] +]; +var operatingSystemRules = [ + ["iOS", /iP(hone|od|ad)/], + ["Android OS", /Android/], + ["BlackBerry OS", /BlackBerry|BB10/], + ["Windows Mobile", /IEMobile/], + ["Amazon OS", /Kindle/], + ["Windows 3.11", /Win16/], + ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], + ["Windows 98", /(Windows 98)|(Win98)/], + ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], + ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], + ["Windows Server 2003", /(Windows NT 5.2)/], + ["Windows Vista", /(Windows NT 6.0)/], + ["Windows 7", /(Windows NT 6.1)/], + ["Windows 8", /(Windows NT 6.2)/], + ["Windows 8.1", /(Windows NT 6.3)/], + ["Windows 10", /(Windows NT 10.0)/], + ["Windows ME", /Windows ME/], + ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], + ["Open BSD", /OpenBSD/], + ["Sun OS", /SunOS/], + ["Chrome OS", /CrOS/], + ["Linux", /(Linux)|(X11)/], + ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], + ["QNX", /QNX/], + ["BeOS", /BeOS/], + ["OS/2", /OS\/2/] +]; +function detect(userAgent) { + if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { + return new ReactNativeInfo(); } - return dst; -} -chacha.streamXOR = streamXOR; -function stream(key, nonce, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; + if (typeof navigator !== "undefined") { + return parseUserAgent(navigator.userAgent); } - wipe_1$2.wipe(dst); - return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); + return getNodeVersion(); } -chacha.stream = stream; -function incrementCounter(counter, pos, len) { - var carry = 1; - while (len--) { - carry = carry + (counter[pos] & 255) | 0; - counter[pos] = carry & 255; - carry >>>= 8; - pos++; +function matchUserAgent(ua2) { + return ua2 !== "" && userAgentRules.reduce(function(matched, _a2) { + var browser2 = _a2[0], regex = _a2[1]; + if (matched) { + return matched; + } + var uaMatch = regex.exec(ua2); + return !!uaMatch && [browser2, uaMatch]; + }, false); +} +function parseUserAgent(ua2) { + var matchedRule = matchUserAgent(ua2); + if (!matchedRule) { + return null; } - if (carry > 0) { - throw new Error("ChaCha: counter overflow"); + var name2 = matchedRule[0], match = matchedRule[1]; + if (name2 === "searchbot") { + return new BotInfo(); + } + var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); + if (versionParts) { + if (versionParts.length < REQUIRED_VERSION_PARTS) { + versionParts = __spreadArray$3(__spreadArray$3([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length)); + } + } else { + versionParts = []; + } + var version2 = versionParts.join("."); + var os2 = detectOS(ua2); + var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua2); + if (searchBotMatch && searchBotMatch[1]) { + return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); } + return new BrowserInfo(name2, version2, os2); } -var poly1305 = {}; -var constantTime = {}; -Object.defineProperty(constantTime, "__esModule", { value: true }); -function select(subject, resultIfOne, resultIfZero) { - return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; +function detectOS(ua2) { + for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { + var _a2 = operatingSystemRules[ii], os2 = _a2[0], regex = _a2[1]; + var match = regex.exec(ua2); + if (match) { + return os2; + } + } + return null; } -constantTime.select = select; -function lessOrEqual(a3, b3) { - return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; +function getNodeVersion() { + var isNode = typeof process !== "undefined" && process.version; + return isNode ? new NodeInfo(process.version.slice(1)) : null; } -constantTime.lessOrEqual = lessOrEqual; -function compare(a3, b3) { - if (a3.length !== b3.length) { - return 0; +function createVersionParts(count) { + var output = []; + for (var ii = 0; ii < count; ii++) { + output.push("0"); } - var result = 0; - for (var i2 = 0; i2 < a3.length; i2++) { - result |= a3[i2] ^ b3[i2]; + return output; +} +var cjs$2 = {}; +Object.defineProperty(cjs$2, "__esModule", { value: true }); +cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; +function getFromWindow(name2) { + let res = void 0; + if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { + res = window[name2]; } - return 1 & result - 1 >>> 8; + return res; } -constantTime.compare = compare; -function equal(a3, b3) { - if (a3.length === 0 || b3.length === 0) { - return false; +cjs$2.getFromWindow = getFromWindow; +function getFromWindowOrThrow(name2) { + const res = getFromWindow(name2); + if (!res) { + throw new Error(`${name2} is not defined in Window`); } - return compare(a3, b3) !== 0; + return res; } -constantTime.equal = equal; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var constant_time_12 = constantTime; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 16; - var Poly1305 = ( - /** @class */ - function() { - function Poly13052(key) { - this.digestLength = exports2.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 = false; - var t0 = key[0] | key[1] << 8; - this._r[0] = t0 & 8191; - var t1 = key[2] | key[3] << 8; - this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; - var t2 = key[4] | key[5] << 8; - this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; - var t3 = key[6] | key[7] << 8; - this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; - var t4 = key[8] | key[9] << 8; - this._r[4] = (t3 >>> 4 | t4 << 12) & 255; - this._r[5] = t4 >>> 1 & 8190; - var t5 = key[10] | key[11] << 8; - this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; - var t6 = key[12] | key[13] << 8; - this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; - var t7 = key[14] | key[15] << 8; - this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; - this._r[9] = t7 >>> 5 & 127; - this._pad[0] = key[16] | key[17] << 8; - this._pad[1] = key[18] | key[19] << 8; - this._pad[2] = key[20] | key[21] << 8; - this._pad[3] = key[22] | key[23] << 8; - this._pad[4] = key[24] | key[25] << 8; - this._pad[5] = key[26] | key[27] << 8; - this._pad[6] = key[28] | key[29] << 8; - this._pad[7] = key[30] | key[31] << 8; - } - Poly13052.prototype._blocks = function(m2, mpos, bytes) { - var hibit = this._fin ? 0 : 1 << 11; - var h0 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; - var r0 = this._r[0], r1 = this._r[1], r2 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; - while (bytes >= 16) { - var t0 = m2[mpos + 0] | m2[mpos + 1] << 8; - h0 += t0 & 8191; - var t1 = m2[mpos + 2] | m2[mpos + 3] << 8; - h1 += (t0 >>> 13 | t1 << 3) & 8191; - var t2 = m2[mpos + 4] | m2[mpos + 5] << 8; - h22 += (t1 >>> 10 | t2 << 6) & 8191; - var t3 = m2[mpos + 6] | m2[mpos + 7] << 8; - h32 += (t2 >>> 7 | t3 << 9) & 8191; - var t4 = m2[mpos + 8] | m2[mpos + 9] << 8; - h4 += (t3 >>> 4 | t4 << 12) & 8191; - h5 += t4 >>> 1 & 8191; - var t5 = m2[mpos + 10] | m2[mpos + 11] << 8; - h6 += (t4 >>> 14 | t5 << 2) & 8191; - var t6 = m2[mpos + 12] | m2[mpos + 13] << 8; - h7 += (t5 >>> 11 | t6 << 5) & 8191; - var t7 = m2[mpos + 14] | m2[mpos + 15] << 8; - h8 += (t6 >>> 8 | t7 << 8) & 8191; - h9 += t7 >>> 5 | hibit; - var c2 = 0; - var d0 = c2; - d0 += h0 * r0; - d0 += h1 * (5 * r9); - d0 += h22 * (5 * r8); - d0 += h32 * (5 * r7); - d0 += h4 * (5 * r6); - c2 = d0 >>> 13; - d0 &= 8191; - d0 += h5 * (5 * r5); - d0 += h6 * (5 * r4); - d0 += h7 * (5 * r3); - d0 += h8 * (5 * r2); - d0 += h9 * (5 * r1); - c2 += d0 >>> 13; - d0 &= 8191; - var d1 = c2; - d1 += h0 * r1; - d1 += h1 * r0; - d1 += h22 * (5 * r9); - d1 += h32 * (5 * r8); - d1 += h4 * (5 * r7); - c2 = d1 >>> 13; - d1 &= 8191; - d1 += h5 * (5 * r6); - d1 += h6 * (5 * r5); - d1 += h7 * (5 * r4); - d1 += h8 * (5 * r3); - d1 += h9 * (5 * r2); - c2 += d1 >>> 13; - d1 &= 8191; - var d22 = c2; - d22 += h0 * r2; - d22 += h1 * r1; - d22 += h22 * r0; - d22 += h32 * (5 * r9); - d22 += h4 * (5 * r8); - c2 = d22 >>> 13; - d22 &= 8191; - d22 += h5 * (5 * r7); - d22 += h6 * (5 * r6); - d22 += h7 * (5 * r5); - d22 += h8 * (5 * r4); - d22 += h9 * (5 * r3); - c2 += d22 >>> 13; - d22 &= 8191; - var d3 = c2; - d3 += h0 * r3; - d3 += h1 * r2; - d3 += h22 * r1; - d3 += h32 * r0; - d3 += h4 * (5 * r9); - c2 = d3 >>> 13; - d3 &= 8191; - d3 += h5 * (5 * r8); - d3 += h6 * (5 * r7); - d3 += h7 * (5 * r6); - d3 += h8 * (5 * r5); - d3 += h9 * (5 * r4); - c2 += d3 >>> 13; - d3 &= 8191; - var d4 = c2; - d4 += h0 * r4; - d4 += h1 * r3; - d4 += h22 * r2; - d4 += h32 * r1; - d4 += h4 * r0; - c2 = d4 >>> 13; - d4 &= 8191; - d4 += h5 * (5 * r9); - d4 += h6 * (5 * r8); - d4 += h7 * (5 * r7); - d4 += h8 * (5 * r6); - d4 += h9 * (5 * r5); - c2 += d4 >>> 13; - d4 &= 8191; - var d5 = c2; - d5 += h0 * r5; - d5 += h1 * r4; - d5 += h22 * r3; - d5 += h32 * r2; - d5 += h4 * r1; - c2 = d5 >>> 13; - d5 &= 8191; - d5 += h5 * r0; - d5 += h6 * (5 * r9); - d5 += h7 * (5 * r8); - d5 += h8 * (5 * r7); - d5 += h9 * (5 * r6); - c2 += d5 >>> 13; - d5 &= 8191; - var d6 = c2; - d6 += h0 * r6; - d6 += h1 * r5; - d6 += h22 * r4; - d6 += h32 * r3; - d6 += h4 * r2; - c2 = d6 >>> 13; - d6 &= 8191; - d6 += h5 * r1; - d6 += h6 * r0; - d6 += h7 * (5 * r9); - d6 += h8 * (5 * r8); - d6 += h9 * (5 * r7); - c2 += d6 >>> 13; - d6 &= 8191; - var d7 = c2; - d7 += h0 * r7; - d7 += h1 * r6; - d7 += h22 * r5; - d7 += h32 * r4; - d7 += h4 * r3; - c2 = d7 >>> 13; - d7 &= 8191; - d7 += h5 * r2; - d7 += h6 * r1; - d7 += h7 * r0; - d7 += h8 * (5 * r9); - d7 += h9 * (5 * r8); - c2 += d7 >>> 13; - d7 &= 8191; - var d8 = c2; - d8 += h0 * r8; - d8 += h1 * r7; - d8 += h22 * r6; - d8 += h32 * r5; - d8 += h4 * r4; - c2 = d8 >>> 13; - d8 &= 8191; - d8 += h5 * r3; - d8 += h6 * r2; - d8 += h7 * r1; - d8 += h8 * r0; - d8 += h9 * (5 * r9); - c2 += d8 >>> 13; - d8 &= 8191; - var d9 = c2; - d9 += h0 * r9; - d9 += h1 * r8; - d9 += h22 * r7; - d9 += h32 * r6; - d9 += h4 * r5; - c2 = d9 >>> 13; - d9 &= 8191; - d9 += h5 * r4; - d9 += h6 * r3; - d9 += h7 * r2; - d9 += h8 * r1; - d9 += h9 * r0; - c2 += d9 >>> 13; - d9 &= 8191; - c2 = (c2 << 2) + c2 | 0; - c2 = c2 + d0 | 0; - d0 = c2 & 8191; - c2 = c2 >>> 13; - d1 += c2; - h0 = d0; - h1 = d1; - h22 = d22; - h32 = d3; - h4 = d4; - h5 = d5; - h6 = d6; - h7 = d7; - h8 = d8; - h9 = d9; - mpos += 16; - bytes -= 16; - } - this._h[0] = h0; - this._h[1] = h1; - this._h[2] = h22; - this._h[3] = h32; - this._h[4] = h4; - this._h[5] = h5; - this._h[6] = h6; - this._h[7] = h7; - this._h[8] = h8; - this._h[9] = h9; - }; - Poly13052.prototype.finish = function(mac, macpos) { - if (macpos === void 0) { - macpos = 0; - } - var g3 = new Uint16Array(10); - var c2; - var mask; - var f2; - var i2; - if (this._leftover) { - i2 = this._leftover; - this._buffer[i2++] = 1; - for (; i2 < 16; i2++) { - this._buffer[i2] = 0; +cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; +function getDocumentOrThrow() { + return getFromWindowOrThrow("document"); +} +cjs$2.getDocumentOrThrow = getDocumentOrThrow; +function getDocument() { + return getFromWindow("document"); +} +var getDocument_1 = cjs$2.getDocument = getDocument; +function getNavigatorOrThrow() { + return getFromWindowOrThrow("navigator"); +} +cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; +function getNavigator() { + return getFromWindow("navigator"); +} +var getNavigator_1 = cjs$2.getNavigator = getNavigator; +function getLocationOrThrow() { + return getFromWindowOrThrow("location"); +} +cjs$2.getLocationOrThrow = getLocationOrThrow; +function getLocation() { + return getFromWindow("location"); +} +var getLocation_1 = cjs$2.getLocation = getLocation; +function getCryptoOrThrow() { + return getFromWindowOrThrow("crypto"); +} +cjs$2.getCryptoOrThrow = getCryptoOrThrow; +function getCrypto() { + return getFromWindow("crypto"); +} +cjs$2.getCrypto = getCrypto; +function getLocalStorageOrThrow() { + return getFromWindowOrThrow("localStorage"); +} +cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; +function getLocalStorage() { + return getFromWindow("localStorage"); +} +cjs$2.getLocalStorage = getLocalStorage; +var cjs$1 = {}; +Object.defineProperty(cjs$1, "__esModule", { value: true }); +var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; +const window_getters_1 = cjs$2; +function getWindowMetadata() { + let doc; + let loc; + try { + doc = window_getters_1.getDocumentOrThrow(); + loc = window_getters_1.getLocationOrThrow(); + } catch (e2) { + return null; + } + function getIcons() { + const links = doc.getElementsByTagName("link"); + const icons2 = []; + for (let i2 = 0; i2 < links.length; i2++) { + const link = links[i2]; + const rel = link.getAttribute("rel"); + if (rel) { + if (rel.toLowerCase().indexOf("icon") > -1) { + const href = link.getAttribute("href"); + if (href) { + if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { + let absoluteHref = loc.protocol + "//" + loc.host; + if (href.indexOf("/") === 0) { + absoluteHref += href; + } else { + const path = loc.pathname.split("/"); + path.pop(); + const finalPath = path.join("/"); + absoluteHref += finalPath + "/" + href; + } + icons2.push(absoluteHref); + } else if (href.indexOf("//") === 0) { + const absoluteUrl = loc.protocol + href; + icons2.push(absoluteUrl); + } else { + icons2.push(href); + } } - this._fin = 1; - this._blocks(this._buffer, 0, 16); } - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - for (i2 = 2; i2 < 10; i2++) { - this._h[i2] += c2; - c2 = this._h[i2] >>> 13; - this._h[i2] &= 8191; + } + } + return icons2; + } + function getWindowMetadataOfAny(...args) { + const metaTags = doc.getElementsByTagName("meta"); + for (let i2 = 0; i2 < metaTags.length; i2++) { + const tag = metaTags[i2]; + const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { + if (attr) { + return args.includes(attr); } - this._h[0] += c2 * 5; - c2 = this._h[0] >>> 13; - this._h[0] &= 8191; - this._h[1] += c2; - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - this._h[2] += c2; - g3[0] = this._h[0] + 5; - c2 = g3[0] >>> 13; - g3[0] &= 8191; - for (i2 = 1; i2 < 10; i2++) { - g3[i2] = this._h[i2] + c2; - c2 = g3[i2] >>> 13; - g3[i2] &= 8191; - } - g3[9] -= 1 << 13; - mask = (c2 ^ 1) - 1; - for (i2 = 0; i2 < 10; i2++) { - g3[i2] &= mask; - } - mask = ~mask; - for (i2 = 0; i2 < 10; i2++) { - this._h[i2] = this._h[i2] & mask | g3[i2]; - } - 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; - f2 = this._h[0] + this._pad[0]; - this._h[0] = f2 & 65535; - for (i2 = 1; i2 < 8; i2++) { - f2 = (this._h[i2] + this._pad[i2] | 0) + (f2 >>> 16) | 0; - this._h[i2] = f2 & 65535; - } - mac[macpos + 0] = this._h[0] >>> 0; - mac[macpos + 1] = this._h[0] >>> 8; - mac[macpos + 2] = this._h[1] >>> 0; - mac[macpos + 3] = this._h[1] >>> 8; - mac[macpos + 4] = this._h[2] >>> 0; - mac[macpos + 5] = this._h[2] >>> 8; - mac[macpos + 6] = this._h[3] >>> 0; - mac[macpos + 7] = this._h[3] >>> 8; - mac[macpos + 8] = this._h[4] >>> 0; - mac[macpos + 9] = this._h[4] >>> 8; - mac[macpos + 10] = this._h[5] >>> 0; - mac[macpos + 11] = this._h[5] >>> 8; - mac[macpos + 12] = this._h[6] >>> 0; - mac[macpos + 13] = this._h[6] >>> 8; - mac[macpos + 14] = this._h[7] >>> 0; - mac[macpos + 15] = this._h[7] >>> 8; - this._finished = true; - return this; - }; - Poly13052.prototype.update = function(m2) { - var mpos = 0; - var bytes = m2.length; - var want; - if (this._leftover) { - want = 16 - this._leftover; - if (want > bytes) { - want = bytes; - } - for (var i2 = 0; i2 < want; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; - } - bytes -= want; - mpos += want; - this._leftover += want; - if (this._leftover < 16) { - return this; - } - this._blocks(this._buffer, 0, 16); - this._leftover = 0; - } - if (bytes >= 16) { - want = bytes - bytes % 16; - this._blocks(m2, mpos, want); - mpos += want; - bytes -= want; - } - if (bytes) { - for (var i2 = 0; i2 < bytes; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; - } - this._leftover += bytes; - } - return this; - }; - Poly13052.prototype.digest = function() { - if (this._finished) { - throw new Error("Poly1305 was finished"); + return false; + }); + if (attributes.length && attributes) { + const content = tag.getAttribute("content"); + if (content) { + return content; } - var mac = new Uint8Array(16); - this.finish(mac); - return mac; - }; - Poly13052.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._r); - wipe_12.wipe(this._h); - wipe_12.wipe(this._pad); - this._leftover = 0; - this._fin = 0; - this._finished = true; - return this; - }; - return Poly13052; - }() - ); - exports2.Poly1305 = Poly1305; - function oneTimeAuth(key, data) { - var h4 = new Poly1305(key); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; + } + } + return ""; } - exports2.oneTimeAuth = oneTimeAuth; - function equal2(a3, b3) { - if (a3.length !== exports2.DIGEST_LENGTH || b3.length !== exports2.DIGEST_LENGTH) { - return false; + function getName() { + let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); + if (!name3) { + name3 = doc.title; } - return constant_time_12.equal(a3, b3); + return name3; } - exports2.equal = equal2; -})(poly1305); -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var chacha_1 = chacha; - var poly1305_1 = poly1305; - var wipe_12 = wipe$1; - var binary_12 = binary; - var constant_time_12 = constantTime; - exports2.KEY_LENGTH = 32; - exports2.NONCE_LENGTH = 12; - exports2.TAG_LENGTH = 16; - var ZEROS = new Uint8Array(16); - var ChaCha20Poly1305 = ( - /** @class */ - function() { - function ChaCha20Poly13052(key) { - this.nonceLength = exports2.NONCE_LENGTH; - this.tagLength = exports2.TAG_LENGTH; - if (key.length !== exports2.KEY_LENGTH) { - throw new Error("ChaCha20Poly1305 needs 32-byte key"); - } - this._key = new Uint8Array(key); + function getDescription() { + const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); + return description3; + } + const name2 = getName(); + const description2 = getDescription(); + const url = loc.origin; + const icons = getIcons(); + const meta = { + description: description2, + url, + icons, + name: name2 + }; + return meta; +} +getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; +var queryString = {}; +var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); +var token = "%[a-f0-9]{2}"; +var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); +var multiMatcher = new RegExp("(" + token + ")+", "gi"); +function decodeComponents(components, split) { + try { + return [decodeURIComponent(components.join(""))]; + } catch (err) { + } + if (components.length === 1) { + return components; + } + split = split || 1; + var left = components.slice(0, split); + var right = components.slice(split); + return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); +} +function decode(input) { + try { + return decodeURIComponent(input); + } catch (err) { + var tokens = input.match(singleMatcher) || []; + for (var i2 = 1; i2 < tokens.length; i2++) { + input = decodeComponents(tokens, i2).join(""); + tokens = input.match(singleMatcher) || []; + } + return input; + } +} +function customDecodeURIComponent(input) { + var replaceMap = { + "%FE%FF": "��", + "%FF%FE": "��" + }; + var match = multiMatcher.exec(input); + while (match) { + try { + replaceMap[match[0]] = decodeURIComponent(match[0]); + } catch (err) { + var result = decode(match[0]); + if (result !== match[0]) { + replaceMap[match[0]] = result; } - ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var resultLength = plaintext.length + this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); - } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, plaintext, result, 4); - this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - if (sealed.length < this.tagLength) { - return null; - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var calculatedTag = new Uint8Array(this.tagLength); - this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); - if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { - return null; - } - var resultLength = sealed.length - this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); - } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.clean = function() { - wipe_12.wipe(this._key); - return this; - }; - ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { - var h4 = new poly1305_1.Poly1305(authKey); - if (associatedData) { - h4.update(associatedData); - if (associatedData.length % 16 > 0) { - h4.update(ZEROS.subarray(associatedData.length % 16)); - } - } - h4.update(ciphertext); - if (ciphertext.length % 16 > 0) { - h4.update(ZEROS.subarray(ciphertext.length % 16)); - } - var length = new Uint8Array(8); - if (associatedData) { - binary_12.writeUint64LE(associatedData.length, length); - } - h4.update(length); - binary_12.writeUint64LE(ciphertext.length, length); - h4.update(length); - var tag = h4.digest(); - for (var i2 = 0; i2 < tag.length; i2++) { - tagOut[i2] = tag[i2]; - } - h4.clean(); - wipe_12.wipe(tag); - wipe_12.wipe(length); - }; - return ChaCha20Poly13052; - }() - ); - exports2.ChaCha20Poly1305 = ChaCha20Poly1305; -})(chacha20poly1305); -var hkdf = {}; -var hmac$1 = {}; -var hash = {}; -Object.defineProperty(hash, "__esModule", { value: true }); -function isSerializableHash(h4) { - return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; -} -hash.isSerializableHash = isSerializableHash; -Object.defineProperty(hmac$1, "__esModule", { value: true }); -var hash_1 = hash; -var constant_time_1 = constantTime; -var wipe_1$1 = wipe$1; -var HMAC = ( - /** @class */ - function() { - function HMAC2(hash2, key) { - this._finished = false; - this._inner = new hash2(); - this._outer = new hash2(); - this.blockSize = this._outer.blockSize; - this.digestLength = this._outer.digestLength; - var pad = new Uint8Array(this.blockSize); - if (key.length > this.blockSize) { - this._inner.update(key).finish(pad).clean(); - } else { - pad.set(key); - } - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54; - } - this._inner.update(pad); - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54 ^ 92; - } - this._outer.update(pad); - if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { - this._innerKeyedState = this._inner.saveState(); - this._outerKeyedState = this._outer.saveState(); - } - wipe_1$1.wipe(pad); } - HMAC2.prototype.reset = function() { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); - } - this._inner.restoreState(this._innerKeyedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.clean = function() { - if (hash_1.isSerializableHash(this._inner)) { - this._inner.cleanSavedState(this._innerKeyedState); - } - if (hash_1.isSerializableHash(this._outer)) { - this._outer.cleanSavedState(this._outerKeyedState); - } - this._inner.clean(); - this._outer.clean(); - }; - HMAC2.prototype.update = function(data) { - this._inner.update(data); - return this; - }; - HMAC2.prototype.finish = function(out) { - if (this._finished) { - this._outer.finish(out); - return this; - } - this._inner.finish(out); - this._outer.update(out.subarray(0, this.digestLength)).finish(out); - this._finished = true; - return this; - }; - HMAC2.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - HMAC2.prototype.saveState = function() { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't saveState() because hash doesn't implement it"); - } - return this._inner.saveState(); - }; - HMAC2.prototype.restoreState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't restoreState() because hash doesn't implement it"); - } - this._inner.restoreState(savedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.cleanSavedState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); - } - this._inner.cleanSavedState(savedState); - }; - return HMAC2; - }() -); -hmac$1.HMAC = HMAC; -function hmac(hash2, key, data) { - var h4 = new HMAC(hash2, key); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; + match = multiMatcher.exec(input); + } + replaceMap["%C2"] = "�"; + var entries = Object.keys(replaceMap); + for (var i2 = 0; i2 < entries.length; i2++) { + var key = entries[i2]; + input = input.replace(new RegExp(key, "g"), replaceMap[key]); + } + return input; } -hmac$1.hmac = hmac; -hmac$1.equal = constant_time_1.equal; -Object.defineProperty(hkdf, "__esModule", { value: true }); -var hmac_1 = hmac$1; -var wipe_1 = wipe$1; -var HKDF = ( - /** @class */ - function() { - function HKDF2(hash2, key, salt, info) { - if (salt === void 0) { - salt = new Uint8Array(0); - } - this._counter = new Uint8Array(1); - this._hash = hash2; - this._info = info; - var okm = hmac_1.hmac(this._hash, salt, key); - this._hmac = new hmac_1.HMAC(hash2, okm); - this._buffer = new Uint8Array(this._hmac.digestLength); - this._bufpos = this._buffer.length; +var decodeUriComponent = function(encodedURI) { + if (typeof encodedURI !== "string") { + throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + } + try { + encodedURI = encodedURI.replace(/\+/g, " "); + return decodeURIComponent(encodedURI); + } catch (err) { + return customDecodeURIComponent(encodedURI); + } +}; +var splitOnFirst = (string2, separator) => { + if (!(typeof string2 === "string" && typeof separator === "string")) { + throw new TypeError("Expected the arguments to be of type `string`"); + } + if (separator === "") { + return [string2]; + } + const separatorIndex = string2.indexOf(separator); + if (separatorIndex === -1) { + return [string2]; + } + return [ + string2.slice(0, separatorIndex), + string2.slice(separatorIndex + separator.length) + ]; +}; +var filterObj = function(obj, predicate) { + var ret = {}; + var keys2 = Object.keys(obj); + var isArr = Array.isArray(predicate); + for (var i2 = 0; i2 < keys2.length; i2++) { + var key = keys2[i2]; + var val = obj[key]; + if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { + ret[key] = val; } - HKDF2.prototype._fillBuffer = function() { - this._counter[0]++; - var ctr = this._counter[0]; - if (ctr === 0) { - throw new Error("hkdf: cannot expand more"); - } - this._hmac.reset(); - if (ctr > 1) { - this._hmac.update(this._buffer); - } - if (this._info) { - this._hmac.update(this._info); - } - this._hmac.update(this._counter); - this._hmac.finish(this._buffer); - this._bufpos = 0; - }; - HKDF2.prototype.expand = function(length) { - var out = new Uint8Array(length); - for (var i2 = 0; i2 < out.length; i2++) { - if (this._bufpos === this._buffer.length) { - this._fillBuffer(); - } - out[i2] = this._buffer[this._bufpos++]; - } - return out; - }; - HKDF2.prototype.clean = function() { - this._hmac.clean(); - wipe_1.wipe(this._buffer); - wipe_1.wipe(this._counter); - this._bufpos = 0; - }; - return HKDF2; - }() -); -var HKDF_1 = hkdf.HKDF = HKDF; -var sha256 = {}; + } + return ret; +}; (function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - var binary_12 = binary; - var wipe_12 = wipe$1; - exports2.DIGEST_LENGTH = 32; - exports2.BLOCK_SIZE = 64; - var SHA256 = ( - /** @class */ - function() { - function SHA2562() { - this.digestLength = exports2.DIGEST_LENGTH; - this.blockSize = exports2.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 = false; - this.reset(); - } - SHA2562.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; - }; - SHA2562.prototype.reset = function() { - this._initState(); - this._bufferLength = 0; - this._bytesHashed = 0; - this._finished = false; - return this; - }; - SHA2562.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._temp); - this.reset(); - }; - SHA2562.prototype.update = function(data, dataLength) { - if (dataLength === void 0) { - dataLength = data.length; - } - if (this._finished) { - throw new Error("SHA256: can't update because hash was finished."); - } - var dataPos = 0; - this._bytesHashed += dataLength; - if (this._bufferLength > 0) { - while (this._bufferLength < this.blockSize && dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; + const strictUriEncode$1 = strictUriEncode; + const decodeComponent = decodeUriComponent; + const splitOnFirst$1 = splitOnFirst; + const filterObject = filterObj; + const isNullOrUndefined = (value) => value === null || value === void 0; + const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); + function encoderForArrayFormat(options) { + switch (options.arrayFormat) { + case "index": + return (key) => (result, value) => { + const index = result.length; + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; } - if (this._bufferLength === this.blockSize) { - hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); - this._bufferLength = 0; + if (value === null) { + return [...result, [encode2(key, options), "[", index, "]"].join("")]; } - } - if (dataLength >= this.blockSize) { - dataPos = hashBlocks(this._temp, this._state, data, dataPos, dataLength); - dataLength %= this.blockSize; - } - while (dataLength > 0) { - this._buffer[this._bufferLength++] = data[dataPos++]; - dataLength--; - } - return this; - }; - SHA2562.prototype.finish = function(out) { - if (!this._finished) { - var bytesHashed = this._bytesHashed; - var left = this._bufferLength; - var bitLenHi = bytesHashed / 536870912 | 0; - var bitLenLo = bytesHashed << 3; - var padLength = bytesHashed % 64 < 56 ? 64 : 128; - this._buffer[left] = 128; - for (var i2 = left + 1; i2 < padLength - 8; i2++) { - this._buffer[i2] = 0; + return [ + ...result, + [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") + ]; + }; + case "bracket": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; } - binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); - binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); - hashBlocks(this._temp, this._state, this._buffer, 0, padLength); - this._finished = true; - } - for (var i2 = 0; i2 < this.digestLength / 4; i2++) { - binary_12.writeUint32BE(this._state[i2], out, i2 * 4); - } - return this; - }; - SHA2562.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - SHA2562.prototype.saveState = function() { - if (this._finished) { - throw new Error("SHA256: cannot save finished state"); - } - return { - state: new Int32Array(this._state), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed + if (value === null) { + return [...result, [encode2(key, options), "[]"].join("")]; + } + return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; + }; + case "colon-list-separator": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, [encode2(key, options), ":list="].join("")]; + } + return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; + }; + case "comma": + case "separator": + case "bracket-separator": { + const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + value = value === null ? "" : value; + if (result.length === 0) { + return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; + } + return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; }; - }; - SHA2562.prototype.restoreState = function(savedState) { - this._state.set(savedState.state); - this._bufferLength = savedState.bufferLength; - if (savedState.buffer) { - this._buffer.set(savedState.buffer); - } - this._bytesHashed = savedState.bytesHashed; - this._finished = false; - return this; - }; - SHA2562.prototype.cleanSavedState = function(savedState) { - wipe_12.wipe(savedState.state); - if (savedState.buffer) { - wipe_12.wipe(savedState.buffer); - } - savedState.bufferLength = 0; - savedState.bytesHashed = 0; - }; - return SHA2562; - }() - ); - exports2.SHA256 = SHA256; - var K2 = 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 hashBlocks(w3, v3, p3, pos, len) { - while (len >= 64) { - var a3 = v3[0]; - var b3 = v3[1]; - var c2 = v3[2]; - var d3 = v3[3]; - var e = v3[4]; - var f2 = v3[5]; - var g3 = v3[6]; - var h4 = v3[7]; - for (var i2 = 0; i2 < 16; i2++) { - var j2 = pos + i2 * 4; - w3[i2] = binary_12.readUint32BE(p3, j2); - } - for (var i2 = 16; i2 < 64; i2++) { - var u3 = w3[i2 - 2]; - var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; - u3 = w3[i2 - 15]; - var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; - w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); } - for (var i2 = 0; i2 < 64; i2++) { - var t1 = (((e >>> 6 | e << 32 - 6) ^ (e >>> 11 | e << 32 - 11) ^ (e >>> 25 | e << 32 - 25)) + (e & f2 ^ ~e & g3) | 0) + (h4 + (K2[i2] + w3[i2] | 0) | 0) | 0; - var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; - h4 = g3; - g3 = f2; - f2 = e; - e = d3 + t1 | 0; - d3 = c2; - c2 = b3; - b3 = a3; - a3 = t1 + t2 | 0; - } - v3[0] += a3; - v3[1] += b3; - v3[2] += c2; - v3[3] += d3; - v3[4] += e; - v3[5] += f2; - v3[6] += g3; - v3[7] += h4; - pos += 64; - len -= 64; + default: + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, encode2(key, options)]; + } + return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; + }; } - return pos; } - function hash2(data) { - var h4 = new SHA256(); - h4.update(data); - var digest = h4.digest(); - h4.clean(); - return digest; + function parserForArrayFormat(options) { + let result; + switch (options.arrayFormat) { + case "index": + return (key, value, accumulator) => { + result = /\[(\d*)\]$/.exec(key); + key = key.replace(/\[\d*\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = {}; + } + accumulator[key][result[1]] = value; + }; + case "bracket": + return (key, value, accumulator) => { + result = /(\[\])$/.exec(key); + key = key.replace(/\[\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "colon-list-separator": + return (key, value, accumulator) => { + result = /(:list)$/.exec(key); + key = key.replace(/:list$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "comma": + case "separator": + return (key, value, accumulator) => { + const isArray2 = typeof value === "string" && value.includes(options.arrayFormatSeparator); + const isEncodedArray = typeof value === "string" && !isArray2 && decode2(value, options).includes(options.arrayFormatSeparator); + value = isEncodedArray ? decode2(value, options) : value; + const newValue = isArray2 || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); + accumulator[key] = newValue; + }; + case "bracket-separator": + return (key, value, accumulator) => { + const isArray2 = /(\[\])$/.test(key); + key = key.replace(/\[\]$/, ""); + if (!isArray2) { + accumulator[key] = value ? decode2(value, options) : value; + return; + } + const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); + if (accumulator[key] === void 0) { + accumulator[key] = arrayValue; + return; + } + accumulator[key] = [].concat(accumulator[key], arrayValue); + }; + default: + return (key, value, accumulator) => { + if (accumulator[key] === void 0) { + accumulator[key] = value; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + } } - exports2.hash = hash2; -})(sha256); -var x25519 = {}; -(function(exports2) { - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.sharedKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.scalarMultBase = exports2.scalarMult = exports2.SHARED_KEY_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = void 0; - const random_1 = random; - const wipe_12 = wipe$1; - exports2.PUBLIC_KEY_LENGTH = 32; - exports2.SECRET_KEY_LENGTH = 32; - exports2.SHARED_KEY_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); - if (init) { - for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; - } + function validateArrayFormatSeparator(value) { + if (typeof value !== "string" || value.length !== 1) { + throw new TypeError("arrayFormatSeparator must be single character string"); } - return r2; } - const _9 = new Uint8Array(32); - _9[0] = 9; - const _121665 = gf([56129, 1]); - function car25519(o2) { - let c2 = 1; - for (let i2 = 0; i2 < 16; i2++) { - let v3 = o2[i2] + c2 + 65535; - c2 = Math.floor(v3 / 65536); - o2[i2] = v3 - c2 * 65536; + function encode2(value, options) { + if (options.encode) { + return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); } - o2[0] += c2 - 1 + 37 * (c2 - 1); + return value; } - function sel25519(p3, q2, b3) { - const c2 = ~(b3 - 1); - for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; - q2[i2] ^= t2; + function decode2(value, options) { + if (options.decode) { + return decodeComponent(value); } + return value; } - function pack25519(o2, n3) { - const m2 = gf(); - const t2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; + function keysSorter(input) { + if (Array.isArray(input)) { + return input.sort(); } - car25519(t2); - car25519(t2); - car25519(t2); - for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; - for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; - } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); + if (typeof input === "object") { + return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); } - for (let i2 = 0; i2 < 16; i2++) { - o2[2 * i2] = t2[i2] & 255; - o2[2 * i2 + 1] = t2[i2] >> 8; + return input; + } + function removeHash(input) { + const hashStart = input.indexOf("#"); + if (hashStart !== -1) { + input = input.slice(0, hashStart); } + return input; } - function unpack25519(o2, n3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); + function getHash(url) { + let hash2 = ""; + const hashStart = url.indexOf("#"); + if (hashStart !== -1) { + hash2 = url.slice(hashStart); } - o2[15] &= 32767; + return hash2; } - function add(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] + b3[i2]; + function extract(input) { + input = removeHash(input); + const queryStart = input.indexOf("?"); + if (queryStart === -1) { + return ""; } + return input.slice(queryStart + 1); } - function sub(o2, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o2[i2] = a3[i2] - b3[i2]; + function parseValue(value, options) { + if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { + value = Number(value); + } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { + value = value.toLowerCase() === "true"; } + return value; } - function mul(o2, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; - v3 = a3[0]; - t0 += v3 * b0; - t1 += v3 * b1; - t2 += v3 * b22; - t3 += v3 * b32; - t4 += v3 * b4; - t5 += v3 * b5; - t6 += v3 * b6; - t7 += v3 * b7; - t8 += v3 * b8; - t9 += v3 * b9; - t10 += v3 * b10; - t11 += v3 * b11; - t12 += v3 * b12; - t13 += v3 * b13; - t14 += v3 * b14; - t15 += v3 * b15; - v3 = a3[1]; - t1 += v3 * b0; - t2 += v3 * b1; - t3 += v3 * b22; - t4 += v3 * b32; - t5 += v3 * b4; - t6 += v3 * b5; - t7 += v3 * b6; - t8 += v3 * b7; - t9 += v3 * b8; - t10 += v3 * b9; - t11 += v3 * b10; - t12 += v3 * b11; - t13 += v3 * b12; - t14 += v3 * b13; - t15 += v3 * b14; - t16 += v3 * b15; - v3 = a3[2]; - t2 += v3 * b0; - t3 += v3 * b1; - t4 += v3 * b22; - t5 += v3 * b32; - t6 += v3 * b4; - t7 += v3 * b5; - t8 += v3 * b6; - t9 += v3 * b7; - t10 += v3 * b8; - t11 += v3 * b9; - t12 += v3 * b10; - t13 += v3 * b11; - t14 += v3 * b12; - t15 += v3 * b13; - t16 += v3 * b14; - t17 += v3 * b15; - v3 = a3[3]; - t3 += v3 * b0; - t4 += v3 * b1; - t5 += v3 * b22; - t6 += v3 * b32; - t7 += v3 * b4; - t8 += v3 * b5; - t9 += v3 * b6; - t10 += v3 * b7; - t11 += v3 * b8; - t12 += v3 * b9; - t13 += v3 * b10; - t14 += v3 * b11; - t15 += v3 * b12; - t16 += v3 * b13; + function parse(query, options) { + options = Object.assign({ + decode: true, + sort: true, + arrayFormat: "none", + arrayFormatSeparator: ",", + parseNumbers: false, + parseBooleans: false + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const formatter = parserForArrayFormat(options); + const ret = /* @__PURE__ */ Object.create(null); + if (typeof query !== "string") { + return ret; + } + query = query.trim().replace(/^[?#&]/, ""); + if (!query) { + return ret; + } + for (const param of query.split("&")) { + if (param === "") { + continue; + } + let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); + value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); + formatter(decode2(key, options), value, ret); + } + for (const key of Object.keys(ret)) { + const value = ret[key]; + if (typeof value === "object" && value !== null) { + for (const k2 of Object.keys(value)) { + value[k2] = parseValue(value[k2], options); + } + } else { + ret[key] = parseValue(value, options); + } + } + if (options.sort === false) { + return ret; + } + return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { + const value = ret[key]; + if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { + result[key] = keysSorter(value); + } else { + result[key] = value; + } + return result; + }, /* @__PURE__ */ Object.create(null)); + } + exports2.extract = extract; + exports2.parse = parse; + exports2.stringify = (object, options) => { + if (!object) { + return ""; + } + options = Object.assign({ + encode: true, + strict: true, + arrayFormat: "none", + arrayFormatSeparator: "," + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; + const formatter = encoderForArrayFormat(options); + const objectCopy = {}; + for (const key of Object.keys(object)) { + if (!shouldFilter(key)) { + objectCopy[key] = object[key]; + } + } + const keys2 = Object.keys(objectCopy); + if (options.sort !== false) { + keys2.sort(options.sort); + } + return keys2.map((key) => { + const value = object[key]; + if (value === void 0) { + return ""; + } + if (value === null) { + return encode2(key, options); + } + if (Array.isArray(value)) { + if (value.length === 0 && options.arrayFormat === "bracket-separator") { + return encode2(key, options) + "[]"; + } + return value.reduce(formatter(key), []).join("&"); + } + return encode2(key, options) + "=" + encode2(value, options); + }).filter((x2) => x2.length > 0).join("&"); + }; + exports2.parseUrl = (url, options) => { + options = Object.assign({ + decode: true + }, options); + const [url_, hash2] = splitOnFirst$1(url, "#"); + return Object.assign( + { + url: url_.split("?")[0] || "", + query: parse(extract(url), options) + }, + options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} + ); + }; + exports2.stringifyUrl = (object, options) => { + options = Object.assign({ + encode: true, + strict: true, + [encodeFragmentIdentifier]: true + }, options); + const url = removeHash(object.url).split("?")[0] || ""; + const queryFromUrl = exports2.extract(object.url); + const parsedQueryFromUrl = exports2.parse(queryFromUrl, { sort: false }); + const query = Object.assign(parsedQueryFromUrl, object.query); + let queryString2 = exports2.stringify(query, options); + if (queryString2) { + queryString2 = `?${queryString2}`; + } + let hash2 = getHash(object.url); + if (object.fragmentIdentifier) { + hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + } + return `${url}${queryString2}${hash2}`; + }; + exports2.pick = (input, filter, options) => { + options = Object.assign({ + parseFragmentIdentifier: true, + [encodeFragmentIdentifier]: false + }, options); + const { url, query, fragmentIdentifier } = exports2.parseUrl(input, options); + return exports2.stringifyUrl({ + url, + query: filterObject(query, filter), + fragmentIdentifier + }, options); + }; + exports2.exclude = (input, filter, options) => { + const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); + return exports2.pick(input, exclusionFilter, options); + }; +})(queryString); +var chacha20poly1305 = {}; +var chacha = {}; +Object.defineProperty(chacha, "__esModule", { value: true }); +var binary_1 = binary; +var wipe_1$2 = wipe$1; +var ROUNDS = 20; +function core(out, input, key) { + var j02 = 1634760805; + var j1 = 857760878; + var j2 = 2036477234; + var j3 = 1797285236; + var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; + var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; + var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; + var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; + var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; + var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; + var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; + var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; + var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; + var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; + var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; + var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; + var x02 = j02; + var x1 = j1; + var x2 = j2; + var x3 = j3; + var x4 = j4; + var x5 = j5; + var x6 = j6; + var x7 = j7; + var x8 = j8; + var x9 = j9; + var x10 = j10; + var x11 = j11; + var x12 = j12; + var x13 = j13; + var x14 = j14; + var x15 = j15; + for (var i2 = 0; i2 < ROUNDS; i2 += 2) { + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 16 | x12 << 16; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 12 | x4 << 12; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 16 | x13 << 16; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 12 | x5 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 16 | x14 << 16; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 12 | x6 << 12; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 16 | x15 << 16; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 12 | x7 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 8 | x14 << 8; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 7 | x6 << 7; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 8 | x15 << 8; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 7 | x7 << 7; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 8 | x13 << 8; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 7 | x5 << 7; + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 8 | x12 << 8; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 7 | x4 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 16 | x15 << 16; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 12 | x5 << 12; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 16 | x12 << 16; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 12 | x6 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 16 | x13 << 16; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 12 | x7 << 12; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 16 | x14 << 16; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 12 | x4 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 8 | x13 << 8; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 7 | x7 << 7; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 8 | x14 << 8; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 7 | x4 << 7; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 8 | x12 << 8; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 7 | x6 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 8 | x15 << 8; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 7 | x5 << 7; + } + binary_1.writeUint32LE(x02 + j02 | 0, out, 0); + binary_1.writeUint32LE(x1 + j1 | 0, out, 4); + binary_1.writeUint32LE(x2 + j2 | 0, out, 8); + binary_1.writeUint32LE(x3 + j3 | 0, out, 12); + binary_1.writeUint32LE(x4 + j4 | 0, out, 16); + binary_1.writeUint32LE(x5 + j5 | 0, out, 20); + binary_1.writeUint32LE(x6 + j6 | 0, out, 24); + binary_1.writeUint32LE(x7 + j7 | 0, out, 28); + binary_1.writeUint32LE(x8 + j8 | 0, out, 32); + binary_1.writeUint32LE(x9 + j9 | 0, out, 36); + binary_1.writeUint32LE(x10 + j10 | 0, out, 40); + binary_1.writeUint32LE(x11 + j11 | 0, out, 44); + binary_1.writeUint32LE(x12 + j12 | 0, out, 48); + binary_1.writeUint32LE(x13 + j13 | 0, out, 52); + binary_1.writeUint32LE(x14 + j14 | 0, out, 56); + binary_1.writeUint32LE(x15 + j15 | 0, out, 60); +} +function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + if (key.length !== 32) { + throw new Error("ChaCha: key size must be 32 bytes"); + } + if (dst.length < src2.length) { + throw new Error("ChaCha: destination is shorter than source"); + } + var nc; + var counterLength; + if (nonceInplaceCounterLength === 0) { + if (nonce.length !== 8 && nonce.length !== 12) { + throw new Error("ChaCha nonce must be 8 or 12 bytes"); + } + nc = new Uint8Array(16); + counterLength = nc.length - nonce.length; + nc.set(nonce, counterLength); + } else { + if (nonce.length !== 16) { + throw new Error("ChaCha nonce with counter must be 16 bytes"); + } + nc = nonce; + counterLength = nonceInplaceCounterLength; + } + var block = new Uint8Array(64); + for (var i2 = 0; i2 < src2.length; i2 += 64) { + core(block, nc, key); + for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { + dst[j2] = src2[j2] ^ block[j2 - i2]; + } + incrementCounter(nc, 0, counterLength); + } + wipe_1$2.wipe(block); + if (nonceInplaceCounterLength === 0) { + wipe_1$2.wipe(nc); + } + return dst; +} +chacha.streamXOR = streamXOR; +function stream(key, nonce, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + wipe_1$2.wipe(dst); + return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); +} +chacha.stream = stream; +function incrementCounter(counter, pos, len) { + var carry = 1; + while (len--) { + carry = carry + (counter[pos] & 255) | 0; + counter[pos] = carry & 255; + carry >>>= 8; + pos++; + } + if (carry > 0) { + throw new Error("ChaCha: counter overflow"); + } +} +var poly1305 = {}; +var constantTime = {}; +Object.defineProperty(constantTime, "__esModule", { value: true }); +function select(subject, resultIfOne, resultIfZero) { + return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; +} +constantTime.select = select; +function lessOrEqual(a3, b3) { + return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; +} +constantTime.lessOrEqual = lessOrEqual; +function compare(a3, b3) { + if (a3.length !== b3.length) { + return 0; + } + var result = 0; + for (var i2 = 0; i2 < a3.length; i2++) { + result |= a3[i2] ^ b3[i2]; + } + return 1 & result - 1 >>> 8; +} +constantTime.compare = compare; +function equal(a3, b3) { + if (a3.length === 0 || b3.length === 0) { + return false; + } + return compare(a3, b3) !== 0; +} +constantTime.equal = equal; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var constant_time_12 = constantTime; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 16; + var Poly1305 = ( + /** @class */ + function() { + function Poly13052(key) { + this.digestLength = exports2.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 = false; + var t0 = key[0] | key[1] << 8; + this._r[0] = t0 & 8191; + var t1 = key[2] | key[3] << 8; + this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; + var t2 = key[4] | key[5] << 8; + this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; + var t3 = key[6] | key[7] << 8; + this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; + var t4 = key[8] | key[9] << 8; + this._r[4] = (t3 >>> 4 | t4 << 12) & 255; + this._r[5] = t4 >>> 1 & 8190; + var t5 = key[10] | key[11] << 8; + this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; + var t6 = key[12] | key[13] << 8; + this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; + var t7 = key[14] | key[15] << 8; + this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; + this._r[9] = t7 >>> 5 & 127; + this._pad[0] = key[16] | key[17] << 8; + this._pad[1] = key[18] | key[19] << 8; + this._pad[2] = key[20] | key[21] << 8; + this._pad[3] = key[22] | key[23] << 8; + this._pad[4] = key[24] | key[25] << 8; + this._pad[5] = key[26] | key[27] << 8; + this._pad[6] = key[28] | key[29] << 8; + this._pad[7] = key[30] | key[31] << 8; + } + Poly13052.prototype._blocks = function(m3, mpos, bytes) { + var hibit = this._fin ? 0 : 1 << 11; + var h02 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; + var r0 = this._r[0], r1 = this._r[1], r22 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; + while (bytes >= 16) { + var t0 = m3[mpos + 0] | m3[mpos + 1] << 8; + h02 += t0 & 8191; + var t1 = m3[mpos + 2] | m3[mpos + 3] << 8; + h1 += (t0 >>> 13 | t1 << 3) & 8191; + var t2 = m3[mpos + 4] | m3[mpos + 5] << 8; + h22 += (t1 >>> 10 | t2 << 6) & 8191; + var t3 = m3[mpos + 6] | m3[mpos + 7] << 8; + h32 += (t2 >>> 7 | t3 << 9) & 8191; + var t4 = m3[mpos + 8] | m3[mpos + 9] << 8; + h4 += (t3 >>> 4 | t4 << 12) & 8191; + h5 += t4 >>> 1 & 8191; + var t5 = m3[mpos + 10] | m3[mpos + 11] << 8; + h6 += (t4 >>> 14 | t5 << 2) & 8191; + var t6 = m3[mpos + 12] | m3[mpos + 13] << 8; + h7 += (t5 >>> 11 | t6 << 5) & 8191; + var t7 = m3[mpos + 14] | m3[mpos + 15] << 8; + h8 += (t6 >>> 8 | t7 << 8) & 8191; + h9 += t7 >>> 5 | hibit; + var c2 = 0; + var d02 = c2; + d02 += h02 * r0; + d02 += h1 * (5 * r9); + d02 += h22 * (5 * r8); + d02 += h32 * (5 * r7); + d02 += h4 * (5 * r6); + c2 = d02 >>> 13; + d02 &= 8191; + d02 += h5 * (5 * r5); + d02 += h6 * (5 * r4); + d02 += h7 * (5 * r3); + d02 += h8 * (5 * r22); + d02 += h9 * (5 * r1); + c2 += d02 >>> 13; + d02 &= 8191; + var d1 = c2; + d1 += h02 * r1; + d1 += h1 * r0; + d1 += h22 * (5 * r9); + d1 += h32 * (5 * r8); + d1 += h4 * (5 * r7); + c2 = d1 >>> 13; + d1 &= 8191; + d1 += h5 * (5 * r6); + d1 += h6 * (5 * r5); + d1 += h7 * (5 * r4); + d1 += h8 * (5 * r3); + d1 += h9 * (5 * r22); + c2 += d1 >>> 13; + d1 &= 8191; + var d22 = c2; + d22 += h02 * r22; + d22 += h1 * r1; + d22 += h22 * r0; + d22 += h32 * (5 * r9); + d22 += h4 * (5 * r8); + c2 = d22 >>> 13; + d22 &= 8191; + d22 += h5 * (5 * r7); + d22 += h6 * (5 * r6); + d22 += h7 * (5 * r5); + d22 += h8 * (5 * r4); + d22 += h9 * (5 * r3); + c2 += d22 >>> 13; + d22 &= 8191; + var d32 = c2; + d32 += h02 * r3; + d32 += h1 * r22; + d32 += h22 * r1; + d32 += h32 * r0; + d32 += h4 * (5 * r9); + c2 = d32 >>> 13; + d32 &= 8191; + d32 += h5 * (5 * r8); + d32 += h6 * (5 * r7); + d32 += h7 * (5 * r6); + d32 += h8 * (5 * r5); + d32 += h9 * (5 * r4); + c2 += d32 >>> 13; + d32 &= 8191; + var d42 = c2; + d42 += h02 * r4; + d42 += h1 * r3; + d42 += h22 * r22; + d42 += h32 * r1; + d42 += h4 * r0; + c2 = d42 >>> 13; + d42 &= 8191; + d42 += h5 * (5 * r9); + d42 += h6 * (5 * r8); + d42 += h7 * (5 * r7); + d42 += h8 * (5 * r6); + d42 += h9 * (5 * r5); + c2 += d42 >>> 13; + d42 &= 8191; + var d5 = c2; + d5 += h02 * r5; + d5 += h1 * r4; + d5 += h22 * r3; + d5 += h32 * r22; + d5 += h4 * r1; + c2 = d5 >>> 13; + d5 &= 8191; + d5 += h5 * r0; + d5 += h6 * (5 * r9); + d5 += h7 * (5 * r8); + d5 += h8 * (5 * r7); + d5 += h9 * (5 * r6); + c2 += d5 >>> 13; + d5 &= 8191; + var d6 = c2; + d6 += h02 * r6; + d6 += h1 * r5; + d6 += h22 * r4; + d6 += h32 * r3; + d6 += h4 * r22; + c2 = d6 >>> 13; + d6 &= 8191; + d6 += h5 * r1; + d6 += h6 * r0; + d6 += h7 * (5 * r9); + d6 += h8 * (5 * r8); + d6 += h9 * (5 * r7); + c2 += d6 >>> 13; + d6 &= 8191; + var d7 = c2; + d7 += h02 * r7; + d7 += h1 * r6; + d7 += h22 * r5; + d7 += h32 * r4; + d7 += h4 * r3; + c2 = d7 >>> 13; + d7 &= 8191; + d7 += h5 * r22; + d7 += h6 * r1; + d7 += h7 * r0; + d7 += h8 * (5 * r9); + d7 += h9 * (5 * r8); + c2 += d7 >>> 13; + d7 &= 8191; + var d8 = c2; + d8 += h02 * r8; + d8 += h1 * r7; + d8 += h22 * r6; + d8 += h32 * r5; + d8 += h4 * r4; + c2 = d8 >>> 13; + d8 &= 8191; + d8 += h5 * r3; + d8 += h6 * r22; + d8 += h7 * r1; + d8 += h8 * r0; + d8 += h9 * (5 * r9); + c2 += d8 >>> 13; + d8 &= 8191; + var d9 = c2; + d9 += h02 * r9; + d9 += h1 * r8; + d9 += h22 * r7; + d9 += h32 * r6; + d9 += h4 * r5; + c2 = d9 >>> 13; + d9 &= 8191; + d9 += h5 * r4; + d9 += h6 * r3; + d9 += h7 * r22; + d9 += h8 * r1; + d9 += h9 * r0; + c2 += d9 >>> 13; + d9 &= 8191; + c2 = (c2 << 2) + c2 | 0; + c2 = c2 + d02 | 0; + d02 = c2 & 8191; + c2 = c2 >>> 13; + d1 += c2; + h02 = d02; + h1 = d1; + h22 = d22; + h32 = d32; + h4 = d42; + h5 = d5; + h6 = d6; + h7 = d7; + h8 = d8; + h9 = d9; + mpos += 16; + bytes -= 16; + } + this._h[0] = h02; + this._h[1] = h1; + this._h[2] = h22; + this._h[3] = h32; + this._h[4] = h4; + this._h[5] = h5; + this._h[6] = h6; + this._h[7] = h7; + this._h[8] = h8; + this._h[9] = h9; + }; + Poly13052.prototype.finish = function(mac, macpos) { + if (macpos === void 0) { + macpos = 0; + } + var g3 = new Uint16Array(10); + var c2; + var mask; + var f3; + var i2; + if (this._leftover) { + i2 = this._leftover; + this._buffer[i2++] = 1; + for (; i2 < 16; i2++) { + this._buffer[i2] = 0; + } + this._fin = 1; + this._blocks(this._buffer, 0, 16); + } + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + for (i2 = 2; i2 < 10; i2++) { + this._h[i2] += c2; + c2 = this._h[i2] >>> 13; + this._h[i2] &= 8191; + } + this._h[0] += c2 * 5; + c2 = this._h[0] >>> 13; + this._h[0] &= 8191; + this._h[1] += c2; + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + this._h[2] += c2; + g3[0] = this._h[0] + 5; + c2 = g3[0] >>> 13; + g3[0] &= 8191; + for (i2 = 1; i2 < 10; i2++) { + g3[i2] = this._h[i2] + c2; + c2 = g3[i2] >>> 13; + g3[i2] &= 8191; + } + g3[9] -= 1 << 13; + mask = (c2 ^ 1) - 1; + for (i2 = 0; i2 < 10; i2++) { + g3[i2] &= mask; + } + mask = ~mask; + for (i2 = 0; i2 < 10; i2++) { + this._h[i2] = this._h[i2] & mask | g3[i2]; + } + 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; + f3 = this._h[0] + this._pad[0]; + this._h[0] = f3 & 65535; + for (i2 = 1; i2 < 8; i2++) { + f3 = (this._h[i2] + this._pad[i2] | 0) + (f3 >>> 16) | 0; + this._h[i2] = f3 & 65535; + } + mac[macpos + 0] = this._h[0] >>> 0; + mac[macpos + 1] = this._h[0] >>> 8; + mac[macpos + 2] = this._h[1] >>> 0; + mac[macpos + 3] = this._h[1] >>> 8; + mac[macpos + 4] = this._h[2] >>> 0; + mac[macpos + 5] = this._h[2] >>> 8; + mac[macpos + 6] = this._h[3] >>> 0; + mac[macpos + 7] = this._h[3] >>> 8; + mac[macpos + 8] = this._h[4] >>> 0; + mac[macpos + 9] = this._h[4] >>> 8; + mac[macpos + 10] = this._h[5] >>> 0; + mac[macpos + 11] = this._h[5] >>> 8; + mac[macpos + 12] = this._h[6] >>> 0; + mac[macpos + 13] = this._h[6] >>> 8; + mac[macpos + 14] = this._h[7] >>> 0; + mac[macpos + 15] = this._h[7] >>> 8; + this._finished = true; + return this; + }; + Poly13052.prototype.update = function(m3) { + var mpos = 0; + var bytes = m3.length; + var want; + if (this._leftover) { + want = 16 - this._leftover; + if (want > bytes) { + want = bytes; + } + for (var i2 = 0; i2 < want; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + bytes -= want; + mpos += want; + this._leftover += want; + if (this._leftover < 16) { + return this; + } + this._blocks(this._buffer, 0, 16); + this._leftover = 0; + } + if (bytes >= 16) { + want = bytes - bytes % 16; + this._blocks(m3, mpos, want); + mpos += want; + bytes -= want; + } + if (bytes) { + for (var i2 = 0; i2 < bytes; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + this._leftover += bytes; + } + return this; + }; + Poly13052.prototype.digest = function() { + if (this._finished) { + throw new Error("Poly1305 was finished"); + } + var mac = new Uint8Array(16); + this.finish(mac); + return mac; + }; + Poly13052.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._r); + wipe_12.wipe(this._h); + wipe_12.wipe(this._pad); + this._leftover = 0; + this._fin = 0; + this._finished = true; + return this; + }; + return Poly13052; + }() + ); + exports2.Poly1305 = Poly1305; + function oneTimeAuth(key, data) { + var h4 = new Poly1305(key); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.oneTimeAuth = oneTimeAuth; + function equal2(a3, b3) { + if (a3.length !== exports2.DIGEST_LENGTH || b3.length !== exports2.DIGEST_LENGTH) { + return false; + } + return constant_time_12.equal(a3, b3); + } + exports2.equal = equal2; +})(poly1305); +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var chacha_1 = chacha; + var poly1305_1 = poly1305; + var wipe_12 = wipe$1; + var binary_12 = binary; + var constant_time_12 = constantTime; + exports2.KEY_LENGTH = 32; + exports2.NONCE_LENGTH = 12; + exports2.TAG_LENGTH = 16; + var ZEROS = new Uint8Array(16); + var ChaCha20Poly1305 = ( + /** @class */ + function() { + function ChaCha20Poly13052(key) { + this.nonceLength = exports2.NONCE_LENGTH; + this.tagLength = exports2.TAG_LENGTH; + if (key.length !== exports2.KEY_LENGTH) { + throw new Error("ChaCha20Poly1305 needs 32-byte key"); + } + this._key = new Uint8Array(key); + } + ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var resultLength = plaintext.length + this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, plaintext, result, 4); + this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + if (sealed.length < this.tagLength) { + return null; + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var calculatedTag = new Uint8Array(this.tagLength); + this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); + if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { + return null; + } + var resultLength = sealed.length - this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.clean = function() { + wipe_12.wipe(this._key); + return this; + }; + ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { + var h4 = new poly1305_1.Poly1305(authKey); + if (associatedData) { + h4.update(associatedData); + if (associatedData.length % 16 > 0) { + h4.update(ZEROS.subarray(associatedData.length % 16)); + } + } + h4.update(ciphertext); + if (ciphertext.length % 16 > 0) { + h4.update(ZEROS.subarray(ciphertext.length % 16)); + } + var length = new Uint8Array(8); + if (associatedData) { + binary_12.writeUint64LE(associatedData.length, length); + } + h4.update(length); + binary_12.writeUint64LE(ciphertext.length, length); + h4.update(length); + var tag = h4.digest(); + for (var i2 = 0; i2 < tag.length; i2++) { + tagOut[i2] = tag[i2]; + } + h4.clean(); + wipe_12.wipe(tag); + wipe_12.wipe(length); + }; + return ChaCha20Poly13052; + }() + ); + exports2.ChaCha20Poly1305 = ChaCha20Poly1305; +})(chacha20poly1305); +var hkdf = {}; +var hmac$1 = {}; +var hash = {}; +Object.defineProperty(hash, "__esModule", { value: true }); +function isSerializableHash(h4) { + return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; +} +hash.isSerializableHash = isSerializableHash; +Object.defineProperty(hmac$1, "__esModule", { value: true }); +var hash_1 = hash; +var constant_time_1 = constantTime; +var wipe_1$1 = wipe$1; +var HMAC = ( + /** @class */ + function() { + function HMAC2(hash2, key) { + this._finished = false; + this._inner = new hash2(); + this._outer = new hash2(); + this.blockSize = this._outer.blockSize; + this.digestLength = this._outer.digestLength; + var pad = new Uint8Array(this.blockSize); + if (key.length > this.blockSize) { + this._inner.update(key).finish(pad).clean(); + } else { + pad.set(key); + } + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54; + } + this._inner.update(pad); + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54 ^ 92; + } + this._outer.update(pad); + if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { + this._innerKeyedState = this._inner.saveState(); + this._outerKeyedState = this._outer.saveState(); + } + wipe_1$1.wipe(pad); + } + HMAC2.prototype.reset = function() { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); + } + this._inner.restoreState(this._innerKeyedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.clean = function() { + if (hash_1.isSerializableHash(this._inner)) { + this._inner.cleanSavedState(this._innerKeyedState); + } + if (hash_1.isSerializableHash(this._outer)) { + this._outer.cleanSavedState(this._outerKeyedState); + } + this._inner.clean(); + this._outer.clean(); + }; + HMAC2.prototype.update = function(data) { + this._inner.update(data); + return this; + }; + HMAC2.prototype.finish = function(out) { + if (this._finished) { + this._outer.finish(out); + return this; + } + this._inner.finish(out); + this._outer.update(out.subarray(0, this.digestLength)).finish(out); + this._finished = true; + return this; + }; + HMAC2.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + HMAC2.prototype.saveState = function() { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't saveState() because hash doesn't implement it"); + } + return this._inner.saveState(); + }; + HMAC2.prototype.restoreState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't restoreState() because hash doesn't implement it"); + } + this._inner.restoreState(savedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.cleanSavedState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); + } + this._inner.cleanSavedState(savedState); + }; + return HMAC2; + }() +); +hmac$1.HMAC = HMAC; +function hmac(hash2, key, data) { + var h4 = new HMAC(hash2, key); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; +} +hmac$1.hmac = hmac; +hmac$1.equal = constant_time_1.equal; +Object.defineProperty(hkdf, "__esModule", { value: true }); +var hmac_1 = hmac$1; +var wipe_1 = wipe$1; +var HKDF = ( + /** @class */ + function() { + function HKDF2(hash2, key, salt, info) { + if (salt === void 0) { + salt = new Uint8Array(0); + } + this._counter = new Uint8Array(1); + this._hash = hash2; + this._info = info; + var okm = hmac_1.hmac(this._hash, salt, key); + this._hmac = new hmac_1.HMAC(hash2, okm); + this._buffer = new Uint8Array(this._hmac.digestLength); + this._bufpos = this._buffer.length; + } + HKDF2.prototype._fillBuffer = function() { + this._counter[0]++; + var ctr = this._counter[0]; + if (ctr === 0) { + throw new Error("hkdf: cannot expand more"); + } + this._hmac.reset(); + if (ctr > 1) { + this._hmac.update(this._buffer); + } + if (this._info) { + this._hmac.update(this._info); + } + this._hmac.update(this._counter); + this._hmac.finish(this._buffer); + this._bufpos = 0; + }; + HKDF2.prototype.expand = function(length) { + var out = new Uint8Array(length); + for (var i2 = 0; i2 < out.length; i2++) { + if (this._bufpos === this._buffer.length) { + this._fillBuffer(); + } + out[i2] = this._buffer[this._bufpos++]; + } + return out; + }; + HKDF2.prototype.clean = function() { + this._hmac.clean(); + wipe_1.wipe(this._buffer); + wipe_1.wipe(this._counter); + this._bufpos = 0; + }; + return HKDF2; + }() +); +var HKDF_1 = hkdf.HKDF = HKDF; +var sha256 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + var binary_12 = binary; + var wipe_12 = wipe$1; + exports2.DIGEST_LENGTH = 32; + exports2.BLOCK_SIZE = 64; + var SHA256 = ( + /** @class */ + function() { + function SHA2562() { + this.digestLength = exports2.DIGEST_LENGTH; + this.blockSize = exports2.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 = false; + this.reset(); + } + SHA2562.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; + }; + SHA2562.prototype.reset = function() { + this._initState(); + this._bufferLength = 0; + this._bytesHashed = 0; + this._finished = false; + return this; + }; + SHA2562.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._temp); + this.reset(); + }; + SHA2562.prototype.update = function(data, dataLength) { + if (dataLength === void 0) { + dataLength = data.length; + } + if (this._finished) { + throw new Error("SHA256: can't update because hash was finished."); + } + var dataPos = 0; + this._bytesHashed += dataLength; + if (this._bufferLength > 0) { + while (this._bufferLength < this.blockSize && dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + if (this._bufferLength === this.blockSize) { + hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); + this._bufferLength = 0; + } + } + if (dataLength >= this.blockSize) { + dataPos = hashBlocks(this._temp, this._state, data, dataPos, dataLength); + dataLength %= this.blockSize; + } + while (dataLength > 0) { + this._buffer[this._bufferLength++] = data[dataPos++]; + dataLength--; + } + return this; + }; + SHA2562.prototype.finish = function(out) { + if (!this._finished) { + var bytesHashed = this._bytesHashed; + var left = this._bufferLength; + var bitLenHi = bytesHashed / 536870912 | 0; + var bitLenLo = bytesHashed << 3; + var padLength = bytesHashed % 64 < 56 ? 64 : 128; + this._buffer[left] = 128; + for (var i2 = left + 1; i2 < padLength - 8; i2++) { + this._buffer[i2] = 0; + } + binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); + binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); + hashBlocks(this._temp, this._state, this._buffer, 0, padLength); + this._finished = true; + } + for (var i2 = 0; i2 < this.digestLength / 4; i2++) { + binary_12.writeUint32BE(this._state[i2], out, i2 * 4); + } + return this; + }; + SHA2562.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + SHA2562.prototype.saveState = function() { + if (this._finished) { + throw new Error("SHA256: cannot save finished state"); + } + return { + state: new Int32Array(this._state), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }; + SHA2562.prototype.restoreState = function(savedState) { + this._state.set(savedState.state); + this._bufferLength = savedState.bufferLength; + if (savedState.buffer) { + this._buffer.set(savedState.buffer); + } + this._bytesHashed = savedState.bytesHashed; + this._finished = false; + return this; + }; + SHA2562.prototype.cleanSavedState = function(savedState) { + wipe_12.wipe(savedState.state); + if (savedState.buffer) { + wipe_12.wipe(savedState.buffer); + } + savedState.bufferLength = 0; + savedState.bytesHashed = 0; + }; + return SHA2562; + }() + ); + exports2.SHA256 = SHA256; + var K3 = 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 hashBlocks(w3, v3, p2, pos, len) { + while (len >= 64) { + var a3 = v3[0]; + var b3 = v3[1]; + var c2 = v3[2]; + var d5 = v3[3]; + var e2 = v3[4]; + var f3 = v3[5]; + var g3 = v3[6]; + var h4 = v3[7]; + for (var i2 = 0; i2 < 16; i2++) { + var j2 = pos + i2 * 4; + w3[i2] = binary_12.readUint32BE(p2, j2); + } + for (var i2 = 16; i2 < 64; i2++) { + var u3 = w3[i2 - 2]; + var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; + u3 = w3[i2 - 15]; + var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; + w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); + } + for (var i2 = 0; i2 < 64; i2++) { + var t1 = (((e2 >>> 6 | e2 << 32 - 6) ^ (e2 >>> 11 | e2 << 32 - 11) ^ (e2 >>> 25 | e2 << 32 - 25)) + (e2 & f3 ^ ~e2 & g3) | 0) + (h4 + (K3[i2] + w3[i2] | 0) | 0) | 0; + var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; + h4 = g3; + g3 = f3; + f3 = e2; + e2 = d5 + t1 | 0; + d5 = c2; + c2 = b3; + b3 = a3; + a3 = t1 + t2 | 0; + } + v3[0] += a3; + v3[1] += b3; + v3[2] += c2; + v3[3] += d5; + v3[4] += e2; + v3[5] += f3; + v3[6] += g3; + v3[7] += h4; + pos += 64; + len -= 64; + } + return pos; + } + function hash2(data) { + var h4 = new SHA256(); + h4.update(data); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports2.hash = hash2; +})(sha256); +var x25519 = {}; +(function(exports2) { + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.sharedKey = exports2.generateKeyPair = exports2.generateKeyPairFromSeed = exports2.scalarMultBase = exports2.scalarMult = exports2.SHARED_KEY_LENGTH = exports2.SECRET_KEY_LENGTH = exports2.PUBLIC_KEY_LENGTH = void 0; + const random_1 = random; + const wipe_12 = wipe$1; + exports2.PUBLIC_KEY_LENGTH = 32; + exports2.SECRET_KEY_LENGTH = 32; + exports2.SHARED_KEY_LENGTH = 32; + function gf2(init) { + const r3 = new Float64Array(16); + if (init) { + for (let i2 = 0; i2 < init.length; i2++) { + r3[i2] = init[i2]; + } + } + return r3; + } + const _9 = new Uint8Array(32); + _9[0] = 9; + const _121665 = gf2([56129, 1]); + function car25519(o2) { + let c2 = 1; + for (let i2 = 0; i2 < 16; i2++) { + let v3 = o2[i2] + c2 + 65535; + c2 = Math.floor(v3 / 65536); + o2[i2] = v3 - c2 * 65536; + } + o2[0] += c2 - 1 + 37 * (c2 - 1); + } + function sel25519(p2, q2, b3) { + const c2 = ~(b3 - 1); + for (let i2 = 0; i2 < 16; i2++) { + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; + q2[i2] ^= t2; + } + } + function pack25519(o2, n4) { + const m3 = gf2(); + const t2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + t2[i2] = n4[i2]; + } + car25519(t2); + car25519(t2); + car25519(t2); + for (let j2 = 0; j2 < 2; j2++) { + m3[0] = t2[0] - 65517; + for (let i2 = 1; i2 < 15; i2++) { + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; + } + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); + } + for (let i2 = 0; i2 < 16; i2++) { + o2[2 * i2] = t2[i2] & 255; + o2[2 * i2 + 1] = t2[i2] >> 8; + } + } + function unpack25519(o2, n4) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); + } + o2[15] &= 32767; + } + function add(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] + b3[i2]; + } + } + function sub(o2, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o2[i2] = a3[i2] - b3[i2]; + } + } + function mul(o2, a3, b3) { + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + v3 = a3[0]; + t0 += v3 * b02; + t1 += v3 * b1; + t2 += v3 * b22; + t3 += v3 * b32; + t4 += v3 * b4; + t5 += v3 * b5; + t6 += v3 * b6; + t7 += v3 * b7; + t8 += v3 * b8; + t9 += v3 * b9; + t10 += v3 * b10; + t11 += v3 * b11; + t12 += v3 * b12; + t13 += v3 * b13; + t14 += v3 * b14; + t15 += v3 * b15; + v3 = a3[1]; + t1 += v3 * b02; + t2 += v3 * b1; + t3 += v3 * b22; + t4 += v3 * b32; + t5 += v3 * b4; + t6 += v3 * b5; + t7 += v3 * b6; + t8 += v3 * b7; + t9 += v3 * b8; + t10 += v3 * b9; + t11 += v3 * b10; + t12 += v3 * b11; + t13 += v3 * b12; + t14 += v3 * b13; + t15 += v3 * b14; + t16 += v3 * b15; + v3 = a3[2]; + t2 += v3 * b02; + t3 += v3 * b1; + t4 += v3 * b22; + t5 += v3 * b32; + t6 += v3 * b4; + t7 += v3 * b5; + t8 += v3 * b6; + t9 += v3 * b7; + t10 += v3 * b8; + t11 += v3 * b9; + t12 += v3 * b10; + t13 += v3 * b11; + t14 += v3 * b12; + t15 += v3 * b13; + t16 += v3 * b14; + t17 += v3 * b15; + v3 = a3[3]; + t3 += v3 * b02; + t4 += v3 * b1; + t5 += v3 * b22; + t6 += v3 * b32; + t7 += v3 * b4; + t8 += v3 * b5; + t9 += v3 * b6; + t10 += v3 * b7; + t11 += v3 * b8; + t12 += v3 * b9; + t13 += v3 * b10; + t14 += v3 * b11; + t15 += v3 * b12; + t16 += v3 * b13; t17 += v3 * b14; t18 += v3 * b15; v3 = a3[4]; - t4 += v3 * b0; + t4 += v3 * b02; t5 += v3 * b1; t6 += v3 * b22; t7 += v3 * b32; @@ -7202,7 +7929,7 @@ var x25519 = {}; t18 += v3 * b14; t19 += v3 * b15; v3 = a3[5]; - t5 += v3 * b0; + t5 += v3 * b02; t6 += v3 * b1; t7 += v3 * b22; t8 += v3 * b32; @@ -7219,7 +7946,7 @@ var x25519 = {}; t19 += v3 * b14; t20 += v3 * b15; v3 = a3[6]; - t6 += v3 * b0; + t6 += v3 * b02; t7 += v3 * b1; t8 += v3 * b22; t9 += v3 * b32; @@ -7236,7 +7963,7 @@ var x25519 = {}; t20 += v3 * b14; t21 += v3 * b15; v3 = a3[7]; - t7 += v3 * b0; + t7 += v3 * b02; t8 += v3 * b1; t9 += v3 * b22; t10 += v3 * b32; @@ -7253,7 +7980,7 @@ var x25519 = {}; t21 += v3 * b14; t22 += v3 * b15; v3 = a3[8]; - t8 += v3 * b0; + t8 += v3 * b02; t9 += v3 * b1; t10 += v3 * b22; t11 += v3 * b32; @@ -7270,7 +7997,7 @@ var x25519 = {}; t22 += v3 * b14; t23 += v3 * b15; v3 = a3[9]; - t9 += v3 * b0; + t9 += v3 * b02; t10 += v3 * b1; t11 += v3 * b22; t12 += v3 * b32; @@ -7287,7 +8014,7 @@ var x25519 = {}; t23 += v3 * b14; t24 += v3 * b15; v3 = a3[10]; - t10 += v3 * b0; + t10 += v3 * b02; t11 += v3 * b1; t12 += v3 * b22; t13 += v3 * b32; @@ -7304,7 +8031,7 @@ var x25519 = {}; t24 += v3 * b14; t25 += v3 * b15; v3 = a3[11]; - t11 += v3 * b0; + t11 += v3 * b02; t12 += v3 * b1; t13 += v3 * b22; t14 += v3 * b32; @@ -7321,7 +8048,7 @@ var x25519 = {}; t25 += v3 * b14; t26 += v3 * b15; v3 = a3[12]; - t12 += v3 * b0; + t12 += v3 * b02; t13 += v3 * b1; t14 += v3 * b22; t15 += v3 * b32; @@ -7338,7 +8065,7 @@ var x25519 = {}; t26 += v3 * b14; t27 += v3 * b15; v3 = a3[13]; - t13 += v3 * b0; + t13 += v3 * b02; t14 += v3 * b1; t15 += v3 * b22; t16 += v3 * b32; @@ -7355,7 +8082,7 @@ var x25519 = {}; t27 += v3 * b14; t28 += v3 * b15; v3 = a3[14]; - t14 += v3 * b0; + t14 += v3 * b02; t15 += v3 * b1; t16 += v3 * b22; t17 += v3 * b32; @@ -7372,7 +8099,7 @@ var x25519 = {}; t28 += v3 * b14; t29 += v3 * b15; v3 = a3[15]; - t15 += v3 * b0; + t15 += v3 * b02; t16 += v3 * b1; t17 += v3 * b22; t18 += v3 * b32; @@ -7524,7 +8251,7 @@ var x25519 = {}; mul(o2, a3, a3); } function inv25519(o2, inp) { - const c2 = gf(); + const c2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { c2[i2] = inp[i2]; } @@ -7538,50 +8265,50 @@ var x25519 = {}; o2[i2] = c2[i2]; } } - function scalarMult(n3, p3) { - const z32 = new Uint8Array(32); + function scalarMult(n4, p2) { + const z2 = new Uint8Array(32); const x2 = new Float64Array(80); - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e = gf(), f2 = gf(); + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(); for (let i2 = 0; i2 < 31; i2++) { - z32[i2] = n3[i2]; + z2[i2] = n4[i2]; } - z32[31] = n3[31] & 127 | 64; - z32[0] &= 248; - unpack25519(x2, p3); + z2[31] = n4[31] & 127 | 64; + z2[0] &= 248; + unpack25519(x2, p2); for (let i2 = 0; i2 < 16; i2++) { b3[i2] = x2[i2]; } - a3[0] = d3[0] = 1; + a3[0] = d5[0] = 1; for (let i2 = 254; i2 >= 0; --i2) { - const r2 = z32[i2 >>> 3] >>> (i2 & 7) & 1; - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); - add(e, a3, c2); + const r3 = z2[i2 >>> 3] >>> (i2 & 7) & 1; + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); + add(e2, a3, c2); sub(a3, a3, c2); - add(c2, b3, d3); - sub(b3, b3, d3); - square(d3, e); - square(f2, a3); + add(c2, b3, d5); + sub(b3, b3, d5); + square(d5, e2); + square(f3, a3); mul(a3, c2, a3); - mul(c2, b3, e); - add(e, a3, c2); + mul(c2, b3, e2); + add(e2, a3, c2); sub(a3, a3, c2); square(b3, a3); - sub(c2, d3, f2); + sub(c2, d5, f3); mul(a3, c2, _121665); - add(a3, a3, d3); + add(a3, a3, d5); mul(c2, c2, a3); - mul(a3, d3, f2); - mul(d3, b3, x2); - square(b3, e); - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); + mul(a3, d5, f3); + mul(d5, b3, x2); + square(b3, e2); + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); } for (let i2 = 0; i2 < 16; i2++) { x2[i2 + 16] = a3[i2]; x2[i2 + 32] = c2[i2]; x2[i2 + 48] = b3[i2]; - x2[i2 + 64] = d3[i2]; + x2[i2 + 64] = d5[i2]; } const x32 = x2.subarray(32); const x16 = x2.subarray(16); @@ -7592,8 +8319,8 @@ var x25519 = {}; return q2; } exports2.scalarMult = scalarMult; - function scalarMultBase(n3) { - return scalarMult(n3, _9); + function scalarMultBase(n4) { + return scalarMult(n4, _9); } exports2.scalarMultBase = scalarMultBase; function generateKeyPairFromSeed(seed) { @@ -7608,1442 +8335,4226 @@ var x25519 = {}; }; } exports2.generateKeyPairFromSeed = generateKeyPairFromSeed; - function generateKeyPair2(prng) { - const seed = (0, random_1.randomBytes)(32, prng); - const result = generateKeyPairFromSeed(seed); - (0, wipe_12.wipe)(seed); - return result; - } - exports2.generateKeyPair = generateKeyPair2; - function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { - if (mySecretKey.length !== exports2.PUBLIC_KEY_LENGTH) { - throw new Error("X25519: incorrect secret key length"); - } - if (theirPublicKey.length !== exports2.PUBLIC_KEY_LENGTH) { - throw new Error("X25519: incorrect public key length"); - } - const result = scalarMult(mySecretKey, theirPublicKey); - if (rejectZero) { - let zeros = 0; - for (let i2 = 0; i2 < result.length; i2++) { - zeros |= result[i2]; - } - if (zeros === 0) { - throw new Error("X25519: invalid shared key"); - } - } - return result; - } - exports2.sharedKey = sharedKey; -})(x25519); -var __spreadArray$3 = function(to, from2, pack) { - if (pack || arguments.length === 2) - for (var i2 = 0, l2 = from2.length, ar2; i2 < l2; i2++) { - if (ar2 || !(i2 in from2)) { - if (!ar2) - ar2 = Array.prototype.slice.call(from2, 0, i2); - ar2[i2] = from2[i2]; - } - } - return to.concat(ar2 || Array.prototype.slice.call(from2)); -}; -var BrowserInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BrowserInfo2(name2, version2, os2) { - this.name = name2; - this.version = version2; - this.os = os2; - this.type = "browser"; - } - return BrowserInfo2; - }() -); -var NodeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function NodeInfo2(version2) { - this.version = version2; - this.type = "node"; - this.name = "node"; - this.os = process.platform; - } - return NodeInfo2; - }() -); -var SearchBotDeviceInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function SearchBotDeviceInfo2(name2, version2, os2, bot) { - this.name = name2; - this.version = version2; - this.os = os2; - this.bot = bot; - this.type = "bot-device"; - } - return SearchBotDeviceInfo2; - }() -); -var BotInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BotInfo2() { - this.type = "bot"; - this.bot = true; - this.name = "bot"; - this.version = null; - this.os = null; - } - return BotInfo2; - }() -); -var ReactNativeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function ReactNativeInfo2() { - this.type = "react-native"; - this.name = "react-native"; - this.version = null; - this.os = null; - } - return ReactNativeInfo2; - }() -); -var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; -var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; -var REQUIRED_VERSION_PARTS = 3; -var userAgentRules = [ - ["aol", /AOLShield\/([0-9\._]+)/], - ["edge", /Edge\/([0-9\._]+)/], - ["edge-ios", /EdgiOS\/([0-9\._]+)/], - ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], - ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], - ["samsung", /SamsungBrowser\/([0-9\.]+)/], - ["silk", /\bSilk\/([0-9._-]+)\b/], - ["miui", /MiuiBrowser\/([0-9\.]+)$/], - ["beaker", /BeakerBrowser\/([0-9\.]+)/], - ["edge-chromium", /EdgA?\/([0-9\.]+)/], - [ - "chromium-webview", - /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ - ], - ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], - ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], - ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], - ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], - ["fxios", /FxiOS\/([0-9\.]+)/], - ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], - ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], - ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], - ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], - ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], - ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], - ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], - ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], - ["ie", /MSIE\s(7\.0)/], - ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], - ["android", /Android\s([0-9\.]+)/], - ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], - ["safari", /Version\/([0-9\._]+).*Safari/], - ["facebook", /FB[AS]V\/([0-9\.]+)/], - ["instagram", /Instagram\s([0-9\.]+)/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], - ["curl", /^curl\/([0-9\.]+)$/], - ["searchbot", SEARCHBOX_UA_REGEX] -]; -var operatingSystemRules = [ - ["iOS", /iP(hone|od|ad)/], - ["Android OS", /Android/], - ["BlackBerry OS", /BlackBerry|BB10/], - ["Windows Mobile", /IEMobile/], - ["Amazon OS", /Kindle/], - ["Windows 3.11", /Win16/], - ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], - ["Windows 98", /(Windows 98)|(Win98)/], - ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], - ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], - ["Windows Server 2003", /(Windows NT 5.2)/], - ["Windows Vista", /(Windows NT 6.0)/], - ["Windows 7", /(Windows NT 6.1)/], - ["Windows 8", /(Windows NT 6.2)/], - ["Windows 8.1", /(Windows NT 6.3)/], - ["Windows 10", /(Windows NT 10.0)/], - ["Windows ME", /Windows ME/], - ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], - ["Open BSD", /OpenBSD/], - ["Sun OS", /SunOS/], - ["Chrome OS", /CrOS/], - ["Linux", /(Linux)|(X11)/], - ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], - ["QNX", /QNX/], - ["BeOS", /BeOS/], - ["OS/2", /OS\/2/] -]; -function detect(userAgent) { - if (!!userAgent) { - return parseUserAgent(userAgent); - } - if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { - return new ReactNativeInfo(); - } - if (typeof navigator !== "undefined") { - return parseUserAgent(navigator.userAgent); - } - return getNodeVersion(); -} -function matchUserAgent(ua) { - return ua !== "" && userAgentRules.reduce(function(matched, _a) { - var browser2 = _a[0], regex = _a[1]; - if (matched) { - return matched; - } - var uaMatch = regex.exec(ua); - return !!uaMatch && [browser2, uaMatch]; - }, false); -} -function parseUserAgent(ua) { - var matchedRule = matchUserAgent(ua); - if (!matchedRule) { - return null; - } - var name2 = matchedRule[0], match = matchedRule[1]; - if (name2 === "searchbot") { - return new BotInfo(); - } - var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); - if (versionParts) { - if (versionParts.length < REQUIRED_VERSION_PARTS) { - versionParts = __spreadArray$3(__spreadArray$3([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); - } - } else { - versionParts = []; - } - var version2 = versionParts.join("."); - var os2 = detectOS(ua); - var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua); - if (searchBotMatch && searchBotMatch[1]) { - return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); + function generateKeyPair2(prng) { + const seed = (0, random_1.randomBytes)(32, prng); + const result = generateKeyPairFromSeed(seed); + (0, wipe_12.wipe)(seed); + return result; } - return new BrowserInfo(name2, version2, os2); -} -function detectOS(ua) { - for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { - var _a = operatingSystemRules[ii], os2 = _a[0], regex = _a[1]; - var match = regex.exec(ua); - if (match) { - return os2; + exports2.generateKeyPair = generateKeyPair2; + function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { + if (mySecretKey.length !== exports2.PUBLIC_KEY_LENGTH) { + throw new Error("X25519: incorrect secret key length"); + } + if (theirPublicKey.length !== exports2.PUBLIC_KEY_LENGTH) { + throw new Error("X25519: incorrect public key length"); + } + const result = scalarMult(mySecretKey, theirPublicKey); + if (rejectZero) { + let zeros = 0; + for (let i2 = 0; i2 < result.length; i2++) { + zeros |= result[i2]; + } + if (zeros === 0) { + throw new Error("X25519: invalid shared key"); + } } + return result; } - return null; + exports2.sharedKey = sharedKey; +})(x25519); +const C$1 = { 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" } }; +const Ir$1 = ":"; +function dn(e2) { + const [t2, r3] = e2.split(Ir$1); + return { namespace: t2, reference: r3 }; +} +function _r$1(e2, t2) { + return e2.includes(":") ? [e2] : t2.chains || []; +} +var Qo = Object.defineProperty, bn = Object.getOwnPropertySymbols, Jo = Object.prototype.hasOwnProperty, Go = Object.prototype.propertyIsEnumerable, yn = (e2, t2, r3) => t2 in e2 ? Qo(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, wn = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Jo.call(t2, r3) && yn(e2, r3, t2[r3]); + if (bn) + for (var r3 of bn(t2)) + Go.call(t2, r3) && yn(e2, r3, t2[r3]); + return e2; +}; +const xn = "ReactNative", qt$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, En = "js"; +function pi() { + return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; } -function getNodeVersion() { - var isNode = typeof process !== "undefined" && process.version; - return isNode ? new NodeInfo(process.version.slice(1)) : null; +function er$1() { + return !getDocument_1() && !!getNavigator_1() && navigator.product === xn; } -function createVersionParts(count) { - var output = []; - for (var ii = 0; ii < count; ii++) { - output.push("0"); - } - return output; +function pr$1() { + return !pi() && !!getNavigator_1() && !!getDocument_1(); } -var cjs$2 = {}; -Object.defineProperty(cjs$2, "__esModule", { value: true }); -cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; -function getFromWindow(name2) { - let res = void 0; - if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { - res = window[name2]; +function We$2() { + return er$1() ? qt$1.reactNative : pi() ? qt$1.node : pr$1() ? qt$1.browser : qt$1.unknown; +} +function Wo() { + var e2; + try { + return er$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e2 = global.Application) == null ? void 0 : e2.applicationId : void 0; + } catch { + return; } - return res; } -cjs$2.getFromWindow = getFromWindow; -function getFromWindowOrThrow(name2) { - const res = getFromWindow(name2); - if (!res) { - throw new Error(`${name2} is not defined in Window`); +function Sn(e2, t2) { + let r3 = queryString.parse(e2); + return r3 = wn(wn({}, r3), t2), e2 = queryString.stringify(r3), e2; +} +function Xo() { + return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; +} +function Nn() { + if (We$2() === qt$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { + const { OS: r3, Version: i2 } = global.Platform; + return [r3, i2].join("-"); } - return res; + const e2 = detect(); + if (e2 === null) + return "unknown"; + const t2 = e2.os ? e2.os.replace(" ", "").toLowerCase() : "unknown"; + return e2.type === "browser" ? [t2, e2.name, e2.version].join("-") : [t2, e2.version].join("-"); +} +function In() { + var e2; + const t2 = We$2(); + return t2 === qt$1.browser ? [t2, ((e2 = getLocation_1()) == null ? void 0 : e2.host) || "unknown"].join(":") : t2; +} +function _n(e2, t2, r3) { + const i2 = Nn(), n4 = In(); + return [[e2, t2].join("-"), [En, r3].join("-"), i2, n4].join("/"); +} +function $o({ protocol: e2, version: t2, relayUrl: r3, sdkVersion: i2, auth: n4, projectId: o2, useOnCloseEvent: h4, bundleId: p2 }) { + const b3 = r3.split("?"), m3 = _n(e2, t2, i2), w3 = { auth: n4, ua: m3, projectId: o2, useOnCloseEvent: h4 || void 0, origin: p2 || void 0 }, y3 = Sn(b3[1] || "", w3); + return b3[0] + "?" + y3; +} +function _e$1(e2, t2) { + return e2.filter((r3) => t2.includes(r3)).length === e2.length; +} +function i0(e2) { + return Object.fromEntries(e2.entries()); +} +function n0(e2) { + return new Map(Object.entries(e2)); +} +function a0(e2 = cjs$3.FIVE_MINUTES, t2) { + const r3 = cjs$3.toMiliseconds(e2 || cjs$3.FIVE_MINUTES); + let i2, n4, o2; + return { resolve: (h4) => { + o2 && i2 && (clearTimeout(o2), i2(h4)); + }, reject: (h4) => { + o2 && n4 && (clearTimeout(o2), n4(h4)); + }, done: () => new Promise((h4, p2) => { + o2 = setTimeout(() => { + p2(new Error(t2)); + }, r3), i2 = h4, n4 = p2; + }) }; } -cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; -function getDocumentOrThrow() { - return getFromWindowOrThrow("document"); +function u0(e2, t2, r3) { + return new Promise(async (i2, n4) => { + const o2 = setTimeout(() => n4(new Error(r3)), t2); + try { + const h4 = await e2; + i2(h4); + } catch (h4) { + n4(h4); + } + clearTimeout(o2); + }); } -cjs$2.getDocumentOrThrow = getDocumentOrThrow; -function getDocument() { - return getFromWindow("document"); +function vi(e2, t2) { + if (typeof t2 == "string" && t2.startsWith(`${e2}:`)) + return t2; + if (e2.toLowerCase() === "topic") { + if (typeof t2 != "string") + throw new Error('Value must be "string" for expirer target type: topic'); + return `topic:${t2}`; + } else if (e2.toLowerCase() === "id") { + if (typeof t2 != "number") + throw new Error('Value must be "number" for expirer target type: id'); + return `id:${t2}`; + } + throw new Error(`Unknown expirer target type: ${e2}`); } -var getDocument_1 = cjs$2.getDocument = getDocument; -function getNavigatorOrThrow() { - return getFromWindowOrThrow("navigator"); +function h0(e2) { + return vi("topic", e2); } -cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; -function getNavigator() { - return getFromWindow("navigator"); +function c0(e2) { + return vi("id", e2); } -var getNavigator_1 = cjs$2.getNavigator = getNavigator; -function getLocationOrThrow() { - return getFromWindowOrThrow("location"); +function l0(e2) { + const [t2, r3] = e2.split(":"), i2 = { id: void 0, topic: void 0 }; + if (t2 === "topic" && typeof r3 == "string") + i2.topic = r3; + else if (t2 === "id" && Number.isInteger(Number(r3))) + i2.id = Number(r3); + else + throw new Error(`Invalid target, expected id:number or topic:string, got ${t2}:${r3}`); + return i2; } -cjs$2.getLocationOrThrow = getLocationOrThrow; -function getLocation() { - return getFromWindow("location"); +function d0(e2, t2) { + return cjs$3.fromMiliseconds(Date.now() + cjs$3.toMiliseconds(e2)); } -var getLocation_1 = cjs$2.getLocation = getLocation; -function getCryptoOrThrow() { - return getFromWindowOrThrow("crypto"); +function p0(e2) { + return Date.now() >= cjs$3.toMiliseconds(e2); } -cjs$2.getCryptoOrThrow = getCryptoOrThrow; -function getCrypto() { - return getFromWindow("crypto"); +function v0(e2, t2) { + return `${e2}${t2 ? `:${t2}` : ""}`; } -cjs$2.getCrypto = getCrypto; -function getLocalStorageOrThrow() { - return getFromWindowOrThrow("localStorage"); +function ge$1(e2 = [], t2 = []) { + return [.../* @__PURE__ */ new Set([...e2, ...t2])]; } -cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; -function getLocalStorage() { - return getFromWindow("localStorage"); +async function m0({ id: e2, topic: t2, wcDeepLink: r3 }) { + try { + if (!r3) + return; + const i2 = typeof r3 == "string" ? JSON.parse(r3) : r3; + let n4 = i2 == null ? void 0 : i2.href; + if (typeof n4 != "string") + return; + n4.endsWith("/") && (n4 = n4.slice(0, -1)); + const o2 = `${n4}/wc?requestId=${e2}&sessionTopic=${t2}`, h4 = We$2(); + h4 === qt$1.browser ? o2.startsWith("https://") || o2.startsWith("http://") ? window.open(o2, "_blank", "noreferrer noopener") : window.open(o2, "_self", "noreferrer noopener") : h4 === qt$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(o2); + } catch (i2) { + console.error(i2); + } } -cjs$2.getLocalStorage = getLocalStorage; -var cjs$1 = {}; -Object.defineProperty(cjs$1, "__esModule", { value: true }); -var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; -const window_getters_1 = cjs$2; -function getWindowMetadata() { - let doc; - let loc; +async function g0(e2, t2) { try { - doc = window_getters_1.getDocumentOrThrow(); - loc = window_getters_1.getLocationOrThrow(); - } catch (e) { - return null; + return await e2.getItem(t2) || (pr$1() ? localStorage.getItem(t2) : void 0); + } catch (r3) { + console.error(r3); } - function getIcons() { - const links = doc.getElementsByTagName("link"); - const icons2 = []; - for (let i2 = 0; i2 < links.length; i2++) { - const link = links[i2]; - const rel = link.getAttribute("rel"); - if (rel) { - if (rel.toLowerCase().indexOf("icon") > -1) { - const href = link.getAttribute("href"); - if (href) { - if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { - let absoluteHref = loc.protocol + "//" + loc.host; - if (href.indexOf("/") === 0) { - absoluteHref += href; - } else { - const path = loc.pathname.split("/"); - path.pop(); - const finalPath = path.join("/"); - absoluteHref += finalPath + "/" + href; - } - icons2.push(absoluteHref); - } else if (href.indexOf("//") === 0) { - const absoluteUrl = loc.protocol + href; - icons2.push(absoluteUrl); - } else { - icons2.push(href); - } - } - } +} +var On$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function A0$1(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; +} +var Pn$1 = { exports: {} }; +/** +* [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 +*/ +(function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On$1 : o2 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s2(u3, E2, u3).update(B2)[_3](); + }; + }, H2 = function(u3, E2, _3) { + return function(B2, R2) { + return new s2(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s2(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H2(u3, E2, "hex"); + return _3.create = function(B2) { + return new s2(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H2, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s2(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s2(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N2[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; } + return this; + }, s2.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s2.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s2.call(this, u3, E2, _3); } - return icons2; - } - function getWindowMetadataOfAny(...args) { - const metaTags = doc.getElementsByTagName("meta"); - for (let i2 = 0; i2 < metaTags.length; i2++) { - const tag = metaTags[i2]; - const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { - if (attr) { - return args.includes(attr); - } - return false; - }); - if (attributes.length && attributes) { - const content = tag.getAttribute("content"); - if (content) { - return content; - } + v3.prototype = new s2(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne, Ie; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z2 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z2 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _3 = D2 ^ (Z2 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne = u3[42] << 2 | u3[43] >>> 30, Ie = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne, u3[45] = Me2 ^ ~Se2 & Ie, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne & St2, u3[47] = Se2 ^ ~Ie & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne ^ ~St2 & Ve2, u3[49] = Ie ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); +})(Pn$1); +var b0 = Pn$1.exports; +const y0$1 = "logger/5.7.0"; +let Dn$1 = false, Fn$1 = false; +const Cr$2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let Tn$1 = Cr$2.default, gi$1 = null; +function w0$1() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); } - } - return ""; + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; } - function getName() { - let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); - if (!name3) { - name3 = doc.title; - } - return name3; + return null; +} +const Un$1 = w0$1(); +var Ai$1; +(function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; +})(Ai$1 || (Ai$1 = {})); +var re$2; +(function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; +})(re$2 || (re$2 = {})); +const kn$1 = "0123456789abcdef"; +let L$3 = class L2 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); } - function getDescription() { - const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); - return description3; + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr$2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn$1 > Cr$2[i2]) && console.log.apply(console, r3); } - const name2 = getName(); - const description2 = getDescription(); - const url = loc.origin; - const icons = getIcons(); - const meta = { - description: description2, - url, - icons, - name: name2 - }; - return meta; -} -getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; -var queryString = {}; -var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); -var token = "%[a-f0-9]{2}"; -var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); -var multiMatcher = new RegExp("(" + token + ")+", "gi"); -function decodeComponents(components, split) { - try { - return [decodeURIComponent(components.join(""))]; - } catch (err) { + debug(...t2) { + this._log(L2.levels.DEBUG, t2); } - if (components.length === 1) { - return components; + info(...t2) { + this._log(L2.levels.INFO, t2); } - split = split || 1; - var left = components.slice(0, split); - var right = components.slice(split); - return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); -} -function decode(input) { - try { - return decodeURIComponent(input); - } catch (err) { - var tokens = input.match(singleMatcher) || []; - for (var i2 = 1; i2 < tokens.length; i2++) { - input = decodeComponents(tokens, i2).join(""); - tokens = input.match(singleMatcher) || []; - } - return input; + warn(...t2) { + this._log(L2.levels.WARNING, t2); } -} -function customDecodeURIComponent(input) { - var replaceMap = { - "%FE%FF": "��", - "%FF%FE": "��" - }; - var match = multiMatcher.exec(input); - while (match) { - try { - replaceMap[match[0]] = decodeURIComponent(match[0]); - } catch (err) { - var result = decode(match[0]); - if (result !== match[0]) { - replaceMap[match[0]] = result; + makeError(t2, r3, i2) { + if (Fn$1) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L2.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn$1[m3[y3] >> 4], w3 += kn$1[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o2 = t2; + let h4 = ""; + switch (r3) { + case re$2.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; } + case re$2.CALL_EXCEPTION: + case re$2.INSUFFICIENT_FUNDS: + case re$2.MISSING_NEW: + case re$2.NONCE_EXPIRED: + case re$2.REPLACEMENT_UNDERPRICED: + case re$2.TRANSACTION_REPLACED: + case re$2.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; } - match = multiMatcher.exec(input); + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; } - replaceMap["%C2"] = "�"; - var entries = Object.keys(replaceMap); - for (var i2 = 0; i2 < entries.length; i2++) { - var key = entries[i2]; - input = input.replace(new RegExp(key, "g"), replaceMap[key]); + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); } - return input; -} -var decodeUriComponent = function(encodedURI) { - if (typeof encodedURI !== "string") { - throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L2.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); } - try { - encodedURI = encodedURI.replace(/\+/g, " "); - return decodeURIComponent(encodedURI); - } catch (err) { - return customDecodeURIComponent(encodedURI); + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); } -}; -var splitOnFirst = (string2, separator) => { - if (!(typeof string2 === "string" && typeof separator === "string")) { - throw new TypeError("Expected the arguments to be of type `string`"); + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); } - if (separator === "") { - return [string2]; + checkNormalize(t2) { + Un$1 && this.throwError("platform missing String.prototype.normalize", L2.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un$1 }); } - const separatorIndex = string2.indexOf(separator); - if (separatorIndex === -1) { - return [string2]; + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L2.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); } - return [ - string2.slice(0, separatorIndex), - string2.slice(separatorIndex + separator.length) - ]; -}; -var filterObj = function(obj, predicate) { - var ret = {}; - var keys2 = Object.keys(obj); - var isArr = Array.isArray(predicate); - for (var i2 = 0; i2 < keys2.length; i2++) { - var key = keys2[i2]; - var val = obj[key]; - if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { - ret[key] = val; + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L2.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L2.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); + } + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r3.name }); + } + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L2.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L2.errors.MISSING_NEW, { name: r3.name }); + } + static globalLogger() { + return gi$1 || (gi$1 = new L2(y0$1)), gi$1; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn$1) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L2.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } + Fn$1 = !!t2, Dn$1 = !!r3; } - return ret; -}; -(function(exports2) { - const strictUriEncode$1 = strictUriEncode; - const decodeComponent = decodeUriComponent; - const splitOnFirst$1 = splitOnFirst; - const filterObject = filterObj; - const isNullOrUndefined = (value) => value === null || value === void 0; - const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); - function encoderForArrayFormat(options) { - switch (options.arrayFormat) { - case "index": - return (key) => (result, value) => { - const index = result.length; - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[", index, "]"].join("")]; - } - return [ - ...result, - [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") - ]; - }; - case "bracket": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[]"].join("")]; - } - return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; - }; - case "colon-list-separator": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), ":list="].join("")]; - } - return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; - }; - case "comma": - case "separator": - case "bracket-separator": { - const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - value = value === null ? "" : value; - if (result.length === 0) { - return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; - } - return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; - }; - } - default: - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, encode2(key, options)]; - } - return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; - }; + static setLogLevel(t2) { + const r3 = Cr$2[t2.toLowerCase()]; + if (r3 == null) { + L2.globalLogger().warn("invalid log level - " + t2); + return; } + Tn$1 = r3; } - function parserForArrayFormat(options) { - let result; - switch (options.arrayFormat) { - case "index": - return (key, value, accumulator) => { - result = /\[(\d*)\]$/.exec(key); - key = key.replace(/\[\d*\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = {}; - } - accumulator[key][result[1]] = value; - }; - case "bracket": - return (key, value, accumulator) => { - result = /(\[\])$/.exec(key); - key = key.replace(/\[\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "colon-list-separator": - return (key, value, accumulator) => { - result = /(:list)$/.exec(key); - key = key.replace(/:list$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "comma": - case "separator": - return (key, value, accumulator) => { - const isArray2 = typeof value === "string" && value.includes(options.arrayFormatSeparator); - const isEncodedArray = typeof value === "string" && !isArray2 && decode2(value, options).includes(options.arrayFormatSeparator); - value = isEncodedArray ? decode2(value, options) : value; - const newValue = isArray2 || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); - accumulator[key] = newValue; - }; - case "bracket-separator": - return (key, value, accumulator) => { - const isArray2 = /(\[\])$/.test(key); - key = key.replace(/\[\]$/, ""); - if (!isArray2) { - accumulator[key] = value ? decode2(value, options) : value; - return; - } - const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); - if (accumulator[key] === void 0) { - accumulator[key] = arrayValue; - return; - } - accumulator[key] = [].concat(accumulator[key], arrayValue); - }; - default: - return (key, value, accumulator) => { - if (accumulator[key] === void 0) { - accumulator[key] = value; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; + static from(t2) { + return new L2(t2); + } +}; +L$3.errors = re$2, L$3.levels = Ai$1; +const x0$1 = "bytes/5.7.0", Dt$2 = new L$3(x0$1); +function qn$1(e2) { + return !!e2.toHexString; +} +function rr$2(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr$2(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; +} +function M0(e2) { + return Qt$1(e2) && !(e2.length % 2) || ir$2(e2); +} +function Kn$1(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; +} +function ir$2(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn$1(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn$1(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; +} +function Ot$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr$2(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2) && (e2 = e2.toHexString()), Qt$1(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr$2(new Uint8Array(i2)); + } + return ir$2(e2) ? rr$2(new Uint8Array(e2)) : Dt$2.throwArgumentError("invalid arrayify value", "value", e2); +} +function E0(e2) { + const t2 = e2.map((n4) => Ot$2(n4)), r3 = t2.reduce((n4, o2) => n4 + o2.length, 0), i2 = new Uint8Array(r3); + return t2.reduce((n4, o2) => (i2.set(o2, n4), n4 + o2.length), 0), rr$2(i2); +} +function S0(e2, t2) { + e2 = Ot$2(e2), e2.length > t2 && Dt$2.throwArgumentError("value out of range", "value", arguments[0]); + const r3 = new Uint8Array(t2); + return r3.set(e2, t2 - e2.length), rr$2(r3); +} +function Qt$1(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2 && e2.length !== 2 + 2 * t2); +} +const bi$1 = "0123456789abcdef"; +function Kt$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi$1[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2)) + return e2.toHexString(); + if (Qt$1(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir$2(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi$1[(n4 & 240) >> 4] + bi$1[n4 & 15]; + } + return r3; + } + return Dt$2.throwArgumentError("invalid hexlify value", "value", e2); +} +function N0(e2) { + if (typeof e2 != "string") + e2 = Kt$2(e2); + else if (!Qt$1(e2) || e2.length % 2) + return null; + return (e2.length - 2) / 2; +} +function Hn(e2, t2, r3) { + return typeof e2 != "string" ? e2 = Kt$2(e2) : (!Qt$1(e2) || e2.length % 2) && Dt$2.throwArgumentError("invalid hexData", "value", e2), t2 = 2 + 2 * t2, r3 != null ? "0x" + e2.substring(t2, 2 + 2 * r3) : "0x" + e2.substring(t2); +} +function oe$1(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt$2(e2) : Qt$1(e2) || Dt$2.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt$2.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; +} +function zn(e2) { + const t2 = { r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0, yParityAndS: "0x", compact: "0x" }; + if (M0(e2)) { + let r3 = Ot$2(e2); + r3.length === 64 ? (t2.v = 27 + (r3[32] >> 7), r3[32] &= 127, t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64))) : r3.length === 65 ? (t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64)), t2.v = r3[64]) : Dt$2.throwArgumentError("invalid signature string", "signature", e2), t2.v < 27 && (t2.v === 0 || t2.v === 1 ? t2.v += 27 : Dt$2.throwArgumentError("signature invalid v byte", "signature", e2)), t2.recoveryParam = 1 - t2.v % 2, t2.recoveryParam && (r3[32] |= 128), t2._vs = Kt$2(r3.slice(32, 64)); + } else { + if (t2.r = e2.r, t2.s = e2.s, t2.v = e2.v, t2.recoveryParam = e2.recoveryParam, t2._vs = e2._vs, t2._vs != null) { + const n4 = S0(Ot$2(t2._vs), 32); + t2._vs = Kt$2(n4); + const o2 = n4[0] >= 128 ? 1 : 0; + t2.recoveryParam == null ? t2.recoveryParam = o2 : t2.recoveryParam !== o2 && Dt$2.throwArgumentError("signature recoveryParam mismatch _vs", "signature", e2), n4[0] &= 127; + const h4 = Kt$2(n4); + t2.s == null ? t2.s = h4 : t2.s !== h4 && Dt$2.throwArgumentError("signature v mismatch _vs", "signature", e2); + } + if (t2.recoveryParam == null) + t2.v == null ? Dt$2.throwArgumentError("signature missing v and recoveryParam", "signature", e2) : t2.v === 0 || t2.v === 1 ? t2.recoveryParam = t2.v : t2.recoveryParam = 1 - t2.v % 2; + else if (t2.v == null) + t2.v = 27 + t2.recoveryParam; + else { + const n4 = t2.v === 0 || t2.v === 1 ? t2.v : 1 - t2.v % 2; + t2.recoveryParam !== n4 && Dt$2.throwArgumentError("signature recoveryParam mismatch v", "signature", e2); + } + t2.r == null || !Qt$1(t2.r) ? Dt$2.throwArgumentError("signature missing or invalid r", "signature", e2) : t2.r = oe$1(t2.r, 32), t2.s == null || !Qt$1(t2.s) ? Dt$2.throwArgumentError("signature missing or invalid s", "signature", e2) : t2.s = oe$1(t2.s, 32); + const r3 = Ot$2(t2.s); + r3[0] >= 128 && Dt$2.throwArgumentError("signature s out of range", "signature", e2), t2.recoveryParam && (r3[0] |= 128); + const i2 = Kt$2(r3); + t2._vs && (Qt$1(t2._vs) || Dt$2.throwArgumentError("signature invalid _vs", "signature", e2), t2._vs = oe$1(t2._vs, 32)), t2._vs == null ? t2._vs = i2 : t2._vs !== i2 && Dt$2.throwArgumentError("signature _vs mismatch v and s", "signature", e2); + } + return t2.yParityAndS = t2._vs, t2.compact = t2.r + t2.yParityAndS.substring(2), t2; +} +function yi(e2) { + return "0x" + b0.keccak_256(Ot$2(e2)); +} +var Ln$1 = { exports: {} }, I0$1 = {}, _0$1 = Object.freeze({ __proto__: null, default: I0$1 }), B0$1 = A0$1(_0$1); +(function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; + } + function o2(A2, f3, a3) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r3.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0$1.Buffer; + } catch { } + o2.isBN = function(f3) { + return f3 instanceof o2 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o2.wordSize && Array.isArray(f3.words); + }, o2.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o2.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o2.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o2.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o2.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + } + this._strip(); + }; + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o2.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v3 = c2; v3 < l2; v3 += d5) + s2 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o2.prototype._move = function(f3) { + w3(f3, this); + }, o2.prototype.clone = function() { + var f3 = new o2(null); + return this.copy(f3), f3; + }, o2.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o2.prototype.inspect = y3; + } + else + o2.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s2 = I2[f3], v3 = N2[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s2 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o2.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o2.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o2.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o2.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o2.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o2.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; + } + return f3; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o2.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o2.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o2.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o2.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o2.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o2.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o2.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o2.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o2.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o2.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o2.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o2.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o2.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o2.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o2.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s2, f3.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s2 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s2] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s2] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s2, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te = d5[6] | 0, et2 = Te & 8191, rt2 = Te >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le = g3[3] | 0, vt2 = Le & 8191, mt2 = Le >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s2 = Math.imul(u3, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s2 = s2 + Math.imul(u3, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s2 = s2 + Math.imul(u3, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s2 = s2 + Math.imul(u3, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ne >>> 26) | 0, Ne &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v3 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s2 = s2 + Math.imul(u3, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v3 = v3 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s2 = s2 + Math.imul(u3, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v3 = v3 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s2 = s2 + Math.imul(u3, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v3 = v3 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s2 = s2 + Math.imul(u3, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v3 = v3 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s2 = s2 + Math.imul(u3, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v3 = v3 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s2 = s2 + Math.imul(u3, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v3 = v3 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v3 = v3 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v3 = v3 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v3 = v3 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v3 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne, x2[4] = Ie, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s2 = Math.max(0, g3 - A2.length + 1); s2 <= l2; s2++) { + var v3 = g3 - s2, k2 = A2.words[v3] | 0, u3 = f3.words[s2] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o2.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o2.prototype.mul = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o2.prototype.mulf = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o2.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o2.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o2.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o2(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o2.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o2.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v3 !== 0 || s2 >= d5); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o2.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o2.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o2.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o2.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o2.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o2.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o2.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o2.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o2.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o2.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o2.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s2; + if (a3 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v3 = 0; v3 < s2.length; v3++) + s2.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s2 && (s2.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s2 && (s2.words[u3] = E2); + } + return s2 && s2._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s2 || null, mod: d5 }; + }, o2.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o2(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o2(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o2(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o2.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o2.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o2.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o2.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o2.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o2.prototype.modn = function(f3) { + return this.modrn(f3); + }, o2.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o2.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o2.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s2), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s2 = 0, v3 = 1; !(c2.words[0] & v3) && s2 < 26; ++s2, v3 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o2.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o2.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o2.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o2.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; + } + } + return a3; + }, o2.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o2.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o2.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o2.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o2.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o2.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o2.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o2.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o2.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o2.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o2.red = function(f3) { + return new Y2(f3); + }, o2.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o2.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o2.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o2.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o2.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o2.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o2.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o2.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o2.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o2(f3, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o2(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o2._prime = function(f3) { + if (H2[f3]) + return H2[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H2[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o2._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v3 = this.pow(s2, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o2(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o2(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s2 = a3.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s2 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o2.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o2(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On$1); +})(Ln$1); +var K$2 = Ln$1.exports; +const jn$1 = "bignumber/5.7.0"; +var Rr$2 = K$2.BN; +const Ae$1 = new L$3(jn$1), wi$1 = {}, Qn$1 = 9007199254740991; +function C0$1(e2) { + return e2 != null && (V$2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt$1(e2) || typeof e2 == "bigint" || ir$2(e2)); +} +let Jn$1 = false; +let V$2 = class V { + constructor(t2, r3) { + t2 !== wi$1 && Ae$1.throwError("cannot call constructor directly; use BigNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); } - function validateArrayFormatSeparator(value) { - if (typeof value !== "string" || value.length !== 1) { - throw new TypeError("arrayFormatSeparator must be single character string"); - } + fromTwos(t2) { + return Lt$2(j$2(this).fromTwos(t2)); } - function encode2(value, options) { - if (options.encode) { - return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); - } - return value; + toTwos(t2) { + return Lt$2(j$2(this).toTwos(t2)); } - function decode2(value, options) { - if (options.decode) { - return decodeComponent(value); - } - return value; + abs() { + return this._hex[0] === "-" ? V.from(this._hex.substring(1)) : this; } - function keysSorter(input) { - if (Array.isArray(input)) { - return input.sort(); - } - if (typeof input === "object") { - return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); - } - return input; + add(t2) { + return Lt$2(j$2(this).add(j$2(t2))); } - function removeHash(input) { - const hashStart = input.indexOf("#"); - if (hashStart !== -1) { - input = input.slice(0, hashStart); - } - return input; + sub(t2) { + return Lt$2(j$2(this).sub(j$2(t2))); } - function getHash(url) { - let hash2 = ""; - const hashStart = url.indexOf("#"); - if (hashStart !== -1) { - hash2 = url.slice(hashStart); - } - return hash2; + div(t2) { + return V.from(t2).isZero() && Wt$3("division-by-zero", "div"), Lt$2(j$2(this).div(j$2(t2))); } - function extract(input) { - input = removeHash(input); - const queryStart = input.indexOf("?"); - if (queryStart === -1) { - return ""; - } - return input.slice(queryStart + 1); + mul(t2) { + return Lt$2(j$2(this).mul(j$2(t2))); } - function parseValue(value, options) { - if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { - value = Number(value); - } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { - value = value.toLowerCase() === "true"; - } - return value; + mod(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("division-by-zero", "mod"), Lt$2(j$2(this).umod(r3)); } - function parse(query, options) { - options = Object.assign({ - decode: true, - sort: true, - arrayFormat: "none", - arrayFormatSeparator: ",", - parseNumbers: false, - parseBooleans: false - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const formatter = parserForArrayFormat(options); - const ret = /* @__PURE__ */ Object.create(null); - if (typeof query !== "string") { - return ret; - } - query = query.trim().replace(/^[?#&]/, ""); - if (!query) { - return ret; + pow(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("negative-power", "pow"), Lt$2(j$2(this).pow(r3)); + } + and(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "and"), Lt$2(j$2(this).and(r3)); + } + or(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "or"), Lt$2(j$2(this).or(r3)); + } + xor(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "xor"), Lt$2(j$2(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "mask"), Lt$2(j$2(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shl"), Lt$2(j$2(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shr"), Lt$2(j$2(this).shrn(t2)); + } + eq(t2) { + return j$2(this).eq(j$2(t2)); + } + lt(t2) { + return j$2(this).lt(j$2(t2)); + } + lte(t2) { + return j$2(this).lte(j$2(t2)); + } + gt(t2) { + return j$2(this).gt(j$2(t2)); + } + gte(t2) { + return j$2(this).gte(j$2(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j$2(this).isZero(); + } + toNumber() { + try { + return j$2(this).toNumber(); + } catch { + Wt$3("overflow", "toNumber", this.toString()); } - for (const param of query.split("&")) { - if (param === "") { - continue; - } - let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); - value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); - formatter(decode2(key, options), value, ret); + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { } - for (const key of Object.keys(ret)) { - const value = ret[key]; - if (typeof value === "object" && value !== null) { - for (const k2 of Object.keys(value)) { - value[k2] = parseValue(value[k2], options); - } + return Ae$1.throwError("this platform does not support BigInt", L$3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn$1 || (Jn$1 = true, Ae$1.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae$1.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L$3.errors.UNEXPECTED_ARGUMENT, {}) : Ae$1.throwError("BigNumber.toString does not accept parameters", L$3.errors.UNEXPECTED_ARGUMENT, {})), j$2(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V(wi$1, vr$1(t2)) : t2.match(/^-?[0-9]+$/) ? new V(wi$1, vr$1(new Rr$2(t2))) : Ae$1.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt$3("underflow", "BigNumber.from", t2), (t2 >= Qn$1 || t2 <= -Qn$1) && Wt$3("overflow", "BigNumber.from", t2), V.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V.from(r3.toString()); + if (ir$2(r3)) + return V.from(Kt$2(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V.from(i2); } else { - ret[key] = parseValue(value, options); - } + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt$1(i2) || i2[0] === "-" && Qt$1(i2.substring(1)))) + return V.from(i2); + } + return Ae$1.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } +}; +function vr$1(e2) { + if (typeof e2 != "string") + return vr$1(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae$1.throwArgumentError("invalid hex", "value", e2), e2 = vr$1(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; +} +function Lt$2(e2) { + return V$2.from(vr$1(e2)); +} +function j$2(e2) { + const t2 = V$2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr$2("-" + t2.substring(3), 16) : new Rr$2(t2.substring(2), 16); +} +function Wt$3(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae$1.throwError(e2, L$3.errors.NUMERIC_FAULT, i2); +} +function R0(e2) { + return new Rr$2(e2, 36).toString(16); +} +const Ht$3 = new L$3(jn$1), mr$2 = {}, Gn$1 = V$2.from(0), Yn$1 = V$2.from(-1); +function Vn$1(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht$3.throwError(e2, L$3.errors.NUMERIC_FAULT, n4); +} +let gr$2 = "0"; +for (; gr$2.length < 256; ) + gr$2 += gr$2; +function xi$1(e2) { + if (typeof e2 != "number") + try { + e2 = V$2.from(e2).toNumber(); + } catch { } - if (options.sort === false) { - return ret; + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr$2.substring(0, e2) : Ht$3.throwArgumentError("invalid decimal size", "decimals", e2); +} +function Mi$1(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + e2 = V$2.from(e2); + const i2 = e2.lt(Gn$1); + i2 && (e2 = e2.mul(Yn$1)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o2 : e2 = o2 + "." + n4, i2 && (e2 = "-" + e2), e2; +} +function be$2(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht$3.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht$3.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht$3.throwArgumentError("too many decimal points", "value", e2); + let o2 = n4[0], h4 = n4[1]; + for (o2 || (o2 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn$1("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V$2.from(o2), b3 = V$2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn$1)), m3; +} +let dr$2 = class dr { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi$1(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht$3.throwArgumentError("invalid fixed format", "format", t2), r3 = o2[1] !== "u", i2 = parseInt(o2[2]), n4 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht$3.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o2("signed", "boolean", r3), i2 = o2("width", "number", i2), n4 = o2("decimals", "number", n4); + } + return i2 % 8 && Ht$3.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht$3.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr(mr$2, r3, i2, n4); + } +}; +let Ut$2 = class Ut { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht$3.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn$1.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn$1.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht$3.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut.from("1" + gr$2.substring(0, t2), this.format), n4 = O0$1.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); + } + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht$3.throwArgumentError("invalid byte width", "width", t2); + const r3 = V$2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe$1(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0$1(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut.fromString(Mi$1(t2, r3), dr$2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3), n4 = be$2(t2, i2.decimals); + !i2.signed && n4.lt(Gn$1) && Vn$1("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n4.toTwos(i2.width).toHexString() : (o2 = n4.toHexString(), o2 = oe$1(o2, i2.width / 8)); + const h4 = Mi$1(n4, i2.decimals); + return new Ut(mr$2, o2, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3); + if (Ot$2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V$2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o2 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi$1(n4, i2.decimals); + return new Ut(mr$2, o2, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut.fromString(t2, r3); + if (ir$2(t2)) + return Ut.fromBytes(t2, r3); + try { + return Ut.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L$3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht$3.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } +}; +const Wn$1 = Ut$2.from(1), O0$1 = Ut$2.from("0.5"), P0 = "strings/5.7.0", Xn = new L$3(P0); +var Or$2; +(function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; +})(Or$2 || (Or$2 = {})); +var nr$2; +(function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; +})(nr$2 || (nr$2 = {})); +function Ei(e2, t2 = Or$2.current) { + t2 != Or$2.current && (Xn.checkNormalize(), e2 = e2.normalize(t2)); + let r3 = []; + for (let i2 = 0; i2 < e2.length; i2++) { + const n4 = e2.charCodeAt(i2); + if (n4 < 128) + r3.push(n4); + else if (n4 < 2048) + r3.push(n4 >> 6 | 192), r3.push(n4 & 63 | 128); + else if ((n4 & 64512) == 55296) { + i2++; + const o2 = e2.charCodeAt(i2); + if (i2 >= e2.length || (o2 & 64512) !== 56320) + throw new Error("invalid utf-8 string"); + const h4 = 65536 + ((n4 & 1023) << 10) + (o2 & 1023); + r3.push(h4 >> 18 | 240), r3.push(h4 >> 12 & 63 | 128), r3.push(h4 >> 6 & 63 | 128), r3.push(h4 & 63 | 128); + } else + r3.push(n4 >> 12 | 224), r3.push(n4 >> 6 & 63 | 128), r3.push(n4 & 63 | 128); + } + return Ot$2(r3); +} +function T0$1(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; +} +function Si$1(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; + }); + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o2 = n4.split(":"); + r3 += parseInt(o2[0], 16), i2[r3] = t2(o2[1]); + }), i2; +} +function $n$1(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); +} +$n$1("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si$1("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si$1("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si$1("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0$1), $n$1("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function U0$1(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot$2(t2); +} +function ef$1(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o2, h4) { + i2.call(o2, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); + }); + }; + return n4(e2, t2), r3; +} +function k0$1(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; +} +function q0$1(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y3; H2++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H2 < o2[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; } - return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { - const value = ret[key]; - if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { - result[key] = keysSorter(value); - } else { - result[key] = value; + }); +} +function K0$1(e2) { + let t2 = 0; + return () => e2[t2++]; +} +function H0$1(e2) { + return K0$1(q0$1(e2)); +} +function z0$1(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; +} +function L0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; +} +function rf$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; +} +function j0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0$1(t2()); + return r3; +} +function Pr$2(e2, t2) { + let r3 = rf$1(e2(), e2), i2 = e2(), n4 = rf$1(i2, e2), o2 = L0$1(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o2[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; +} +function Q0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0$1(r3, e2)); + } + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0$1(r3, e2)); + } + return k0$1(ef$1(t2)); +} +function J0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); + } + return t2; +} +function nf$1(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0$1(e2, r3).forEach((o2, h4) => i2[h4].push(o2)); + return i2; +} +function G0$1(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0$1(t2), o2 = nf$1(n4.length, 1 + e2, t2); + return ef$1(o2.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; + }); + })); +} +function Y0$1(e2, t2) { + let r3 = 1 + t2(); + return nf$1(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); +} +function V0$1(e2) { + let t2 = Pr$2(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr$2(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o2 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o2, fe0f: h4, save: p2, check: b3 }; + } +} +function W0$1() { + return H0$1(U0$1("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); +} +const Dr$2 = W0$1(); +new Set(Pr$2(Dr$2)), new Set(Pr$2(Dr$2)), Q0$1(Dr$2), V0$1(Dr$2); +const X0$1 = new Uint8Array(32); +X0$1.fill(0); +const Z0 = `Ethereum Signed Message: +`; +function ff(e2) { + return typeof e2 == "string" && (e2 = Ei(e2)), yi(E0([Ei(Z0), Ei(String(e2.length)), e2])); +} +const ts$2 = "address/5.7.0", Ar$1 = new L$3(ts$2); +function of(e2) { + Qt$1(e2, 20) || Ar$1.throwArgumentError("invalid address", "address", e2), e2 = e2.toLowerCase(); + const t2 = e2.substring(2).split(""), r3 = new Uint8Array(40); + for (let n4 = 0; n4 < 40; n4++) + r3[n4] = t2[n4].charCodeAt(0); + const i2 = Ot$2(yi(r3)); + for (let n4 = 0; n4 < 40; n4 += 2) + i2[n4 >> 1] >> 4 >= 8 && (t2[n4] = t2[n4].toUpperCase()), (i2[n4 >> 1] & 15) >= 8 && (t2[n4 + 1] = t2[n4 + 1].toUpperCase()); + return "0x" + t2.join(""); +} +const es$2 = 9007199254740991; +function rs$2(e2) { + return Math.log10 ? Math.log10(e2) : Math.log(e2) / Math.LN10; +} +const Ni = {}; +for (let e2 = 0; e2 < 10; e2++) + Ni[String(e2)] = String(e2); +for (let e2 = 0; e2 < 26; e2++) + Ni[String.fromCharCode(65 + e2)] = String(10 + e2); +const sf = Math.floor(rs$2(es$2)); +function is$2(e2) { + e2 = e2.toUpperCase(), e2 = e2.substring(4) + e2.substring(0, 2) + "00"; + let t2 = e2.split("").map((i2) => Ni[i2]).join(""); + for (; t2.length >= sf; ) { + let i2 = t2.substring(0, sf); + t2 = parseInt(i2, 10) % 97 + t2.substring(i2.length); + } + let r3 = String(98 - parseInt(t2, 10) % 97); + for (; r3.length < 2; ) + r3 = "0" + r3; + return r3; +} +function ns$1(e2) { + let t2 = null; + if (typeof e2 != "string" && Ar$1.throwArgumentError("invalid address", "address", e2), e2.match(/^(0x)?[0-9a-fA-F]{40}$/)) + e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), t2 = of(e2), e2.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && t2 !== e2 && Ar$1.throwArgumentError("bad address checksum", "address", e2); + else if (e2.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + for (e2.substring(2, 4) !== is$2(e2) && Ar$1.throwArgumentError("bad icap checksum", "address", e2), t2 = R0(e2.substring(4)); t2.length < 40; ) + t2 = "0" + t2; + t2 = of("0x" + t2); + } else + Ar$1.throwArgumentError("invalid address", "address", e2); + return t2; +} +function br$1(e2, t2, r3) { + Object.defineProperty(e2, t2, { enumerable: true, value: r3, writable: false }); +} +const os$2 = new Uint8Array(32); +os$2.fill(0), V$2.from(-1); +const ss$3 = V$2.from(0), as$2 = V$2.from(1); +V$2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe$1(as$2.toHexString(), 32), oe$1(ss$3.toHexString(), 32); +var se$2 = {}, Q$2 = {}, yr$2 = af$1; +function af$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +af$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var Ii$1 = { exports: {} }; +typeof Object.create == "function" ? Ii$1.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); +} : Ii$1.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; + } +}; +var us$2 = yr$2, hs$2 = Ii$1.exports; +Q$2.inherits = hs$2; +function cs$2(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; +} +function ls$2(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o2 = e2.charCodeAt(n4); + o2 < 128 ? r3[i2++] = o2 : o2 < 2048 ? (r3[i2++] = o2 >> 6 | 192, r3[i2++] = o2 & 63 | 128) : cs$2(e2, n4) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o2 >> 18 | 240, r3[i2++] = o2 >> 12 & 63 | 128, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128) : (r3[i2++] = o2 >> 12 | 224, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128); } - return result; - }, /* @__PURE__ */ Object.create(null)); + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; +} +Q$2.toArray = ls$2; +function ds$2(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf$1(e2[r3].toString(16)); + return t2; +} +Q$2.toHex = ds$2; +function uf$1(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; +} +Q$2.htonl = uf$1; +function ps$2(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf$1(n4)), r3 += cf$1(n4.toString(16)); } - exports2.extract = extract; - exports2.parse = parse; - exports2.stringify = (object, options) => { - if (!object) { - return ""; - } - options = Object.assign({ - encode: true, - strict: true, - arrayFormat: "none", - arrayFormatSeparator: "," - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; - const formatter = encoderForArrayFormat(options); - const objectCopy = {}; - for (const key of Object.keys(object)) { - if (!shouldFilter(key)) { - objectCopy[key] = object[key]; + return r3; +} +Q$2.toHex32 = ps$2; +function hf$1(e2) { + return e2.length === 1 ? "0" + e2 : e2; +} +Q$2.zero2 = hf$1; +function cf$1(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; +} +Q$2.zero8 = cf$1; +function vs$2(e2, t2, r3, i2) { + var n4 = r3 - t2; + us$2(n4 % 4 === 0); + for (var o2 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o2.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h4] = b3 >>> 0; + } + return o2; +} +Q$2.join32 = vs$2; +function ms$3(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r3[n4] = o2 >>> 24, r3[n4 + 1] = o2 >>> 16 & 255, r3[n4 + 2] = o2 >>> 8 & 255, r3[n4 + 3] = o2 & 255) : (r3[n4 + 3] = o2 >>> 24, r3[n4 + 2] = o2 >>> 16 & 255, r3[n4 + 1] = o2 >>> 8 & 255, r3[n4] = o2 & 255); + } + return r3; +} +Q$2.split32 = ms$3; +function gs$2(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; +} +Q$2.rotr32 = gs$2; +function As$2(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; +} +Q$2.rotl32 = As$2; +function bs$2(e2, t2) { + return e2 + t2 >>> 0; +} +Q$2.sum32 = bs$2; +function ys$2(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; +} +Q$2.sum32_3 = ys$2; +function ws$2(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; +} +Q$2.sum32_4 = ws$2; +function xs$2(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; +} +Q$2.sum32_5 = xs$2; +function Ms$2(e2, t2, r3, i2) { + var n4 = e2[t2], o2 = e2[t2 + 1], h4 = i2 + o2 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; +} +Q$2.sum64 = Ms$2; +function Es$2(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o2 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o2 >>> 0; +} +Q$2.sum64_hi = Es$2; +function Ss$2(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; +} +Q$2.sum64_lo = Ss$2; +function Ns$2(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o2 >>> 0, b3 += m3 < o2 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; +} +Q$2.sum64_4_hi = Ns$2; +function Is$2(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = t2 + i2 + o2 + p2; + return b3 >>> 0; +} +Q$2.sum64_4_lo = Is$2; +function _s$2(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o2 >>> 0, w3 += y3 < o2 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; +} +Q$2.sum64_5_hi = _s$2; +function Bs$2(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = t2 + i2 + o2 + p2 + m3; + return w3 >>> 0; +} +Q$2.sum64_5_lo = Bs$2; +function Cs$2(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; +} +Q$2.rotr64_hi = Cs$2; +function Rs$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q$2.rotr64_lo = Rs$2; +function Os$2(e2, t2, r3) { + return e2 >>> r3; +} +Q$2.shr64_hi = Os$2; +function Ps$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q$2.shr64_lo = Ps$2; +var fr$1 = {}, lf$1 = Q$2, Ds$2 = yr$2; +function Fr$2() { + 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; +} +fr$1.BlockHash = Fr$2, Fr$2.prototype.update = function(t2, r3) { + if (t2 = lf$1.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf$1.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; +}, Fr$2.prototype.digest = function(t2) { + return this.update(this._pad()), Ds$2(this.pending === null), this._digest(t2); +}, Fr$2.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n4[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 & 255; + } else + for (n4[o2++] = t2 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + return n4; +}; +var or$2 = {}, ae$1 = {}, Fs$2 = Q$2, ue$1 = Fs$2.rotr32; +function Ts$2(e2, t2, r3, i2) { + if (e2 === 0) + return df$1(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf$1(t2, r3, i2); + if (e2 === 2) + return pf$1(t2, r3, i2); +} +ae$1.ft_1 = Ts$2; +function df$1(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; +} +ae$1.ch32 = df$1; +function pf$1(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; +} +ae$1.maj32 = pf$1; +function vf$1(e2, t2, r3) { + return e2 ^ t2 ^ r3; +} +ae$1.p32 = vf$1; +function Us$2(e2) { + return ue$1(e2, 2) ^ ue$1(e2, 13) ^ ue$1(e2, 22); +} +ae$1.s0_256 = Us$2; +function ks$2(e2) { + return ue$1(e2, 6) ^ ue$1(e2, 11) ^ ue$1(e2, 25); +} +ae$1.s1_256 = ks$2; +function qs$2(e2) { + return ue$1(e2, 7) ^ ue$1(e2, 18) ^ e2 >>> 3; +} +ae$1.g0_256 = qs$2; +function Ks$2(e2) { + return ue$1(e2, 17) ^ ue$1(e2, 19) ^ e2 >>> 10; +} +ae$1.g1_256 = Ks$2; +var sr$2 = Q$2, Hs$2 = fr$1, zs$2 = ae$1, _i$1 = sr$2.rotl32, wr$1 = sr$2.sum32, Ls$2 = sr$2.sum32_5, js$2 = zs$2.ft_1, mf$1 = Hs$2.BlockHash, Qs$2 = [1518500249, 1859775393, 2400959708, 3395469782]; +function he$1() { + if (!(this instanceof he$1)) + return new he$1(); + mf$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); +} +sr$2.inherits(he$1, mf$1); +var Js$2 = he$1; +he$1.blockSize = 512, he$1.outSize = 160, he$1.hmacStrength = 80, he$1.padLength = 64, he$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i$1(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls$2(_i$1(o2, 5), js$2(w3, h4, p2, b3), m3, i2[n4], Qs$2[w3]); + m3 = b3, b3 = p2, p2 = _i$1(h4, 30), h4 = o2, o2 = y3; + } + this.h[0] = wr$1(this.h[0], o2), this.h[1] = wr$1(this.h[1], h4), this.h[2] = wr$1(this.h[2], p2), this.h[3] = wr$1(this.h[3], b3), this.h[4] = wr$1(this.h[4], m3); +}, he$1.prototype._digest = function(t2) { + return t2 === "hex" ? sr$2.toHex32(this.h, "big") : sr$2.split32(this.h, "big"); +}; +var ar$2 = Q$2, Gs$2 = fr$1, ur$2 = ae$1, Ys$2 = yr$2, ie$3 = ar$2.sum32, Vs$2 = ar$2.sum32_4, Ws$2 = ar$2.sum32_5, Xs$2 = ur$2.ch32, Zs$2 = ur$2.maj32, $s$2 = ur$2.s0_256, ta$1 = ur$2.s1_256, ea$1 = ur$2.g0_256, ra$1 = ur$2.g1_256, gf$1 = Gs$2.BlockHash, ia$1 = [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 ce$1() { + if (!(this instanceof ce$1)) + return new ce$1(); + gf$1.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia$1, this.W = new Array(64); +} +ar$2.inherits(ce$1, gf$1); +var Af$1 = ce$1; +ce$1.blockSize = 512, ce$1.outSize = 256, ce$1.hmacStrength = 192, ce$1.padLength = 64, ce$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs$2(ra$1(i2[n4 - 2]), i2[n4 - 7], ea$1(i2[n4 - 15]), i2[n4 - 16]); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys$2(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws$2(S2, ta$1(m3), Xs$2(m3, w3, y3), this.k[n4], i2[n4]), N2 = ie$3($s$2(o2), Zs$2(o2, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie$3(b3, I2), b3 = p2, p2 = h4, h4 = o2, o2 = ie$3(I2, N2); + } + this.h[0] = ie$3(this.h[0], o2), this.h[1] = ie$3(this.h[1], h4), this.h[2] = ie$3(this.h[2], p2), this.h[3] = ie$3(this.h[3], b3), this.h[4] = ie$3(this.h[4], m3), this.h[5] = ie$3(this.h[5], w3), this.h[6] = ie$3(this.h[6], y3), this.h[7] = ie$3(this.h[7], S2); +}, ce$1.prototype._digest = function(t2) { + return t2 === "hex" ? ar$2.toHex32(this.h, "big") : ar$2.split32(this.h, "big"); +}; +var Bi$1 = Q$2, bf$1 = Af$1; +function ye$2() { + if (!(this instanceof ye$2)) + return new ye$2(); + bf$1.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; +} +Bi$1.inherits(ye$2, bf$1); +var na$1 = ye$2; +ye$2.blockSize = 512, ye$2.outSize = 224, ye$2.hmacStrength = 192, ye$2.padLength = 64, ye$2.prototype._digest = function(t2) { + return t2 === "hex" ? Bi$1.toHex32(this.h.slice(0, 7), "big") : Bi$1.split32(this.h.slice(0, 7), "big"); +}; +var jt$2 = Q$2, fa$1 = fr$1, oa$1 = yr$2, le$1 = jt$2.rotr64_hi, de$2 = jt$2.rotr64_lo, yf$1 = jt$2.shr64_hi, wf$1 = jt$2.shr64_lo, Be$3 = jt$2.sum64, Ci$1 = jt$2.sum64_hi, Ri$1 = jt$2.sum64_lo, sa$1 = jt$2.sum64_4_hi, aa$1 = jt$2.sum64_4_lo, ua$1 = jt$2.sum64_5_hi, ha$1 = jt$2.sum64_5_lo, xf$1 = fa$1.BlockHash, ca$1 = [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 ne$2() { + if (!(this instanceof ne$2)) + return new ne$2(); + xf$1.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca$1, this.W = new Array(160); +} +jt$2.inherits(ne$2, xf$1); +var Mf$1 = ne$2; +ne$2.blockSize = 1024, ne$2.outSize = 512, ne$2.hmacStrength = 192, ne$2.padLength = 128, ne$2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o2 = xa$1(i2[n4 - 4], i2[n4 - 3]), h4 = Ma$1(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya$1(i2[n4 - 30], i2[n4 - 29]), w3 = wa$1(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa$1(o2, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa$1(o2, h4, p2, b3, m3, w3, y3, S2); + } +}, ne$2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o2 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa$1(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa$1(S2, I2), W2 = ba$1(S2, I2), Rt2 = la$1(S2, I2, N2, C2, F2), Yt3 = da$1(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua$1(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha$1(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H2 = ma$1(n4, o2), z2 = ga$1(n4, o2), Pt2 = pa$1(n4, o2, h4, p2, b3), W2 = va$1(n4, o2, h4, p2, b3, m3); + var d5 = Ci$1(H2, z2, Pt2, W2), g3 = Ri$1(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci$1(w3, y3, a3, c2), I2 = Ri$1(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o2, n4 = Ci$1(a3, c2, d5, g3), o2 = Ri$1(a3, c2, d5, g3); + } + Be$3(this.h, 0, n4, o2), Be$3(this.h, 2, h4, p2), Be$3(this.h, 4, b3, m3), Be$3(this.h, 6, w3, y3), Be$3(this.h, 8, S2, I2), Be$3(this.h, 10, N2, C2), Be$3(this.h, 12, F2, U2), Be$3(this.h, 14, J2, Bt2); +}, ne$2.prototype._digest = function(t2) { + return t2 === "hex" ? jt$2.toHex32(this.h, "big") : jt$2.split32(this.h, "big"); +}; +function la$1(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ ~e2 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function da$1(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ ~t2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function pa$1(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function va$1(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function ma$1(e2, t2) { + var r3 = le$1(e2, t2, 28), i2 = le$1(t2, e2, 2), n4 = le$1(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ga$1(e2, t2) { + var r3 = de$2(e2, t2, 28), i2 = de$2(t2, e2, 2), n4 = de$2(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Aa$1(e2, t2) { + var r3 = le$1(e2, t2, 14), i2 = le$1(e2, t2, 18), n4 = le$1(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ba$1(e2, t2) { + var r3 = de$2(e2, t2, 14), i2 = de$2(e2, t2, 18), n4 = de$2(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ya$1(e2, t2) { + var r3 = le$1(e2, t2, 1), i2 = le$1(e2, t2, 8), n4 = yf$1(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function wa$1(e2, t2) { + var r3 = de$2(e2, t2, 1), i2 = de$2(e2, t2, 8), n4 = wf$1(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function xa$1(e2, t2) { + var r3 = le$1(e2, t2, 19), i2 = le$1(t2, e2, 29), n4 = yf$1(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Ma$1(e2, t2) { + var r3 = de$2(e2, t2, 19), i2 = de$2(t2, e2, 29), n4 = wf$1(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +var Oi$1 = Q$2, Ef$1 = Mf$1; +function we$1() { + if (!(this instanceof we$1)) + return new we$1(); + Ef$1.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; +} +Oi$1.inherits(we$1, Ef$1); +var Ea$1 = we$1; +we$1.blockSize = 1024, we$1.outSize = 384, we$1.hmacStrength = 192, we$1.padLength = 128, we$1.prototype._digest = function(t2) { + return t2 === "hex" ? Oi$1.toHex32(this.h.slice(0, 12), "big") : Oi$1.split32(this.h.slice(0, 12), "big"); +}, or$2.sha1 = Js$2, or$2.sha224 = na$1, or$2.sha256 = Af$1, or$2.sha384 = Ea$1, or$2.sha512 = Mf$1; +var Sf$1 = {}, Xe$3 = Q$2, Sa$1 = fr$1, Tr$2 = Xe$3.rotl32, Nf$1 = Xe$3.sum32, xr$2 = Xe$3.sum32_3, If$1 = Xe$3.sum32_4, _f$1 = Sa$1.BlockHash; +function pe$2() { + if (!(this instanceof pe$2)) + return new pe$2(); + _f$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; +} +Xe$3.inherits(pe$2, _f$1), Sf$1.ripemd160 = pe$2, pe$2.blockSize = 512, pe$2.outSize = 160, pe$2.hmacStrength = 192, pe$2.padLength = 64, pe$2.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o2 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o2, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf$1(Tr$2(If$1(i2, Bf$1(I2, n4, o2, h4), t2[_a$1[I2] + r3], Na$1(I2)), Ca$1[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr$2(o2, 10), o2 = n4, n4 = N2, N2 = Nf$1(Tr$2(If$1(b3, Bf$1(79 - I2, m3, w3, y3), t2[Ba$1[I2] + r3], Ia$1(I2)), Ra$1[I2]), S2), b3 = S2, S2 = y3, y3 = Tr$2(w3, 10), w3 = m3, m3 = N2; + } + N2 = xr$2(this.h[1], o2, y3), this.h[1] = xr$2(this.h[2], h4, S2), this.h[2] = xr$2(this.h[3], p2, b3), this.h[3] = xr$2(this.h[4], i2, m3), this.h[4] = xr$2(this.h[0], n4, w3), this.h[0] = N2; +}, pe$2.prototype._digest = function(t2) { + return t2 === "hex" ? Xe$3.toHex32(this.h, "little") : Xe$3.split32(this.h, "little"); +}; +function Bf$1(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); +} +function Na$1(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; +} +function Ia$1(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; +} +var _a$1 = [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], Ba$1 = [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], Ca$1 = [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], Ra$1 = [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], Oa$1 = Q$2, Pa$1 = yr$2; +function hr$2(e2, t2, r3) { + if (!(this instanceof hr$2)) + return new hr$2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa$1.toArray(t2, r3)); +} +var Da$1 = hr$2; +hr$2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa$1(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); +}, hr$2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; +}, hr$2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); +}, function(e2) { + var t2 = e2; + t2.utils = Q$2, t2.common = fr$1, t2.sha = or$2, t2.ripemd = Sf$1, t2.hmac = Da$1, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; +}(se$2); +function cr$2(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa$1(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; +} +function Fa$1() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var Pi$1 = Cf$1; +function Cf$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +Cf$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var fe$2 = cr$2(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); } + return b3; + } + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; + } + r3.zero2 = n4; + function o2(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o2, r3.encode = function(p2, b3) { + return b3 === "hex" ? o2(p2) : p2; + }; +}), Jt$3 = cr$2(function(e2, t2) { + var r3 = t2; + r3.assert = Pi$1, r3.toArray = fe$2.toArray, r3.zero2 = fe$2.zero2, r3.toHex = fe$2.toHex, r3.encode = fe$2.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N2 = 0; N2 < y3.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N2] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N2 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o2(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o2; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K$2(b3, "hex", "le"); + } + r3.intFromLE = p2; +}), Ur$2 = Jt$3.getNAF, Ta$1 = Jt$3.getJSF, kr$2 = Jt$3.assert; +function Ce$1(e2, t2) { + this.type = e2, this.p = new K$2(t2.p, 16), this.red = t2.prime ? K$2.red(t2.prime) : K$2.mont(this.p), this.zero = new K$2(0).toRed(this.red), this.one = new K$2(1).toRed(this.red), this.two = new K$2(2).toRed(this.red), this.n = t2.n && new K$2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); +} +var Ze$2 = Ce$1; +Ce$1.prototype.point = function() { + throw new Error("Not implemented"); +}, Ce$1.prototype.validate = function() { + throw new Error("Not implemented"); +}, Ce$1.prototype._fixedNafMul = function(t2, r3) { + kr$2(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur$2(r3, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); +}, Ce$1.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o2 = n4.points, h4 = Ur$2(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr$2(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o2[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o2[w3 - 1 >> 1]) : p2 = p2.add(o2[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; +}, Ce$1.prototype._wnafMulAdd = function(t2, r3, i2, n4, o2) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N2 = w3 - 1, C2 = w3; + if (h4[N2] !== 1 || h4[C2] !== 1) { + b3[N2] = Ur$2(i2[N2], h4[N2], this._bitLength), b3[C2] = Ur$2(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N2].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; } - const keys2 = Object.keys(objectCopy); - if (options.sort !== false) { - keys2.sort(options.sort); + var F2 = [r3[N2], null, null, r3[C2]]; + r3[N2].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N2].add(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())) : r3[N2].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].add(r3[C2].neg())) : (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta$1(i2[N2], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N2] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N2][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; } - return keys2.map((key) => { - const value = object[key]; - if (value === void 0) { - return ""; - } - if (value === null) { - return encode2(key, options); - } - if (Array.isArray(value)) { - if (value.length === 0 && options.arrayFormat === "bracket-separator") { - return encode2(key, options) + "[]"; + if (w3 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o2 ? H2 : H2.toP(); +}; +function Xt$3(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; +} +Ce$1.BasePoint = Xt$3, Xt$3.prototype.eq = function() { + throw new Error("Not implemented"); +}, Xt$3.prototype.validate = function() { + return this.curve.validate(this); +}, Ce$1.prototype.decodePoint = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr$2(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr$2(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); +}, Xt$3.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); +}, Xt$3.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); +}, Xt$3.prototype.encode = function(t2, r3) { + return Jt$3.encode(this._encode(r3), t2); +}, Xt$3.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; +}, Xt$3.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; +}, Xt$3.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o2 = 0; o2 < r3; o2 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; +}, Xt$3.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r3[o2] = r3[o2 - 1].add(n4); + return { wnd: t2, points: r3 }; +}, Xt$3.prototype._getBeta = function() { + return null; +}, Xt$3.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; +}; +var Di$1 = cr$2(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; +}), Ua$1 = Jt$3.assert; +function Zt$2(e2) { + Ze$2.call(this, "short", e2), this.a = new K$2(e2.a, 16).toRed(this.red), this.b = new K$2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +Di$1(Zt$2, Ze$2); +var ka$1 = Zt$2; +Zt$2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K$2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K$2(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua$1(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K$2(p2.a, 16), b: new K$2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } +}, Zt$2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K$2.mont(t2), i2 = new K$2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o2 = new K$2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o2).fromRed(), p2 = n4.redSub(o2).fromRed(); + return [h4, p2]; +}, Zt$2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o2 = new K$2(1), h4 = new K$2(0), p2 = new K$2(0), b3 = new K$2(1), m3, w3, y3, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o2, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o2, o2 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m3, N2 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y3, b: S2 }, { a: I2, b: N2 }]; +}, Zt$2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o2 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b3 = h4.mul(n4.a), m3 = o2.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; +}, Zt$2.prototype.pointFromX = function(t2, r3) { + t2 = new K$2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n4.fromRed().isOdd(); + return (r3 && !o2 || !r3 && o2) && (n4 = n4.redNeg()), this.point(t2, n4); +}, Zt$2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o2 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; +}, Zt$2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o2 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o2[h4 * 2] = p2.k1, o2[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o2, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o2[y3] = null; + return w3; +}; +function Ft$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); +} +Di$1(Ft$2, Ze$2.BasePoint), Zt$2.prototype.point = function(t2, r3, i2) { + return new Ft$2(this, t2, r3, i2); +}, Zt$2.prototype.pointFromJSON = function(t2, r3) { + return Ft$2.fromJSON(this, t2, r3); +}, Ft$2.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } +}, Ft$2.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; +}, Ft$2.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o2)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o2)) } }, n4; +}, Ft$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Ft$2.prototype.isInfinity = function() { + return this.inf; +}, Ft$2.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); +}, Ft$2.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); +}, Ft$2.prototype.getX = function() { + return this.x.fromRed(); +}, Ft$2.prototype.getY = function() { + return this.y.fromRed(); +}, Ft$2.prototype.mul = function(t2) { + return t2 = new K$2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); +}, Ft$2.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2) : this.curve._wnafMulAdd(1, n4, o2, 2); +}, Ft$2.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2, true) : this.curve._wnafMulAdd(1, n4, o2, 2, true); +}, Ft$2.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); +}, Ft$2.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o2) { + return o2.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; +}, Ft$2.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; +}; +function Tt$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K$2(0)) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), this.z = new K$2(i2, 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; +} +Di$1(Tt$2, Ze$2.BasePoint), Zt$2.prototype.jpoint = function(t2, r3, i2) { + return new Tt$2(this, t2, r3, i2); +}, Tt$2.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); +}, Tt$2.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}, Tt$2.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o2 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o2), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N2 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N2, C2); +}, Tt$2.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o2 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o2.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o2.redMul(w3)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); +}, Tt$2.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o2 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N2 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o2), b3); +}, Tt$2.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}, Tt$2.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r3 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt$2.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt$2.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o2 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o2)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N2, C2); +}, Tt$2.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h4 = o2.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o2.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N2); +}, Tt$2.prototype.mul = function(t2, r3) { + return t2 = new K$2(t2, r3), this.curve._wnafMul(this, t2); +}, Tt$2.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n4)).cmpn(0) === 0; +}, Tt$2.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o2 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } +}, Tt$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Tt$2.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var qr$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.base = Ze$2, r3.short = ka$1, r3.mont = null, r3.edwards = null; +}), Kr$1 = cr$2(function(e2, t2) { + var r3 = t2, i2 = Jt$3.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr$1.short(p2) : p2.type === "edwards" ? this.curve = new qr$1.edwards(p2) : this.curve = new qr$1.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o2(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o2("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: se$2.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se$2.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se$2.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se$2.sha384, gRed: false, 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"] }), o2("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: se$2.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se$2.sha256, gRed: false, g: ["9"] }), o2("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: se$2.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o2("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: se$2.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); +}); +function Re$2(e2) { + if (!(this instanceof Re$2)) + return new Re$2(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe$2.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe$2.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe$2.toArray(e2.pers, e2.persEnc || "hex"); + Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); +} +var Rf$1 = Re$2; +Re$2.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; +}, Re$2.prototype._hmac = function() { + return new se$2.hmac(this.hash, this.K); +}, Re$2.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); +}, Re$2.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe$2.toArray(t2, r3), i2 = fe$2.toArray(i2, n4), Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; +}, Re$2.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe$2.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h4 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe$2.encode(h4, r3); +}; +var Fi$1 = Jt$3.assert; +function kt$2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); +} +var Ti$1 = kt$2; +kt$2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { pub: r3, pubEnc: i2 }); +}, kt$2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { priv: r3, privEnc: i2 }); +}, kt$2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; +}, kt$2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; +}, kt$2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; +}, kt$2.prototype._importPrivate = function(t2, r3) { + this.priv = new K$2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); +}, kt$2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi$1(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi$1(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); +}, kt$2.prototype.derive = function(t2) { + return t2.validate() || Fi$1(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); +}, kt$2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); +}, kt$2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); +}, kt$2.prototype.inspect = function() { + return ""; +}; +var qa$1 = Jt$3.assert; +function Hr$1(e2, t2) { + if (e2 instanceof Hr$1) + return e2; + this._importDER(e2, t2) || (qa$1(e2.r && e2.s, "Signature without r or s"), this.r = new K$2(e2.r, 16), this.s = new K$2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); +} +var zr$2 = Hr$1; +function Ka$1() { + this.place = 0; +} +function Ui$1(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o2 = 0, h4 = t2.place; o2 < i2; o2++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); +} +function Of$1(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); +} +Hr$1.prototype._importDER = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = new Ka$1(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui$1(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui$1(t2, i2); + if (o2 === false) + return false; + var h4 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui$1(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K$2(h4), this.s = new K$2(b3), this.recoveryParam = null, true; +}; +function ki$1(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); +} +Hr$1.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of$1(r3), i2 = Of$1(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki$1(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki$1(n4, i2.length); + var o2 = n4.concat(i2), h4 = [48]; + return ki$1(h4, o2.length), h4 = h4.concat(o2), Jt$3.encode(h4, t2); +}; +var Ha$1 = function() { + throw new Error("unsupported"); +}, Pf$1 = Jt$3.assert; +function $t$2(e2) { + if (!(this instanceof $t$2)) + return new $t$2(e2); + typeof e2 == "string" && (Pf$1(Object.prototype.hasOwnProperty.call(Kr$1, e2), "Unknown curve " + e2), e2 = Kr$1[e2]), e2 instanceof Kr$1.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; +} +var za$1 = $t$2; +$t$2.prototype.keyPair = function(t2) { + return new Ti$1(this, t2); +}, $t$2.prototype.keyFromPrivate = function(t2, r3) { + return Ti$1.fromPrivate(this, t2, r3); +}, $t$2.prototype.keyFromPublic = function(t2, r3) { + return Ti$1.fromPublic(this, t2, r3); +}, $t$2.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf$1({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha$1(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K$2(2)); ; ) { + var o2 = new K$2(r3.generate(i2)); + if (!(o2.cmp(n4) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } +}, $t$2.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; +}, $t$2.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K$2(t2, 16)); + for (var o2 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b3 = new Rf$1({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K$2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K$2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N2.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr$2({ r: N2, s: C2, recoveryParam: F2 }); + } } - return value.reduce(formatter(key), []).join("&"); } - return encode2(key, options) + "=" + encode2(value, options); - }).filter((x2) => x2.length > 0).join("&"); - }; - exports2.parseUrl = (url, options) => { - options = Object.assign({ - decode: true - }, options); - const [url_, hash2] = splitOnFirst$1(url, "#"); - return Object.assign( - { - url: url_.split("?")[0] || "", - query: parse(extract(url), options) - }, - options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} - ); - }; - exports2.stringifyUrl = (object, options) => { - options = Object.assign({ - encode: true, - strict: true, - [encodeFragmentIdentifier]: true - }, options); - const url = removeHash(object.url).split("?")[0] || ""; - const queryFromUrl = exports2.extract(object.url); - const parsedQueryFromUrl = exports2.parse(queryFromUrl, { sort: false }); - const query = Object.assign(parsedQueryFromUrl, object.query); - let queryString2 = exports2.stringify(query, options); - if (queryString2) { - queryString2 = `?${queryString2}`; } - let hash2 = getHash(object.url); - if (object.fragmentIdentifier) { - hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + } +}, $t$2.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K$2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr$2(r3, "hex"); + var o2 = r3.r, h4 = r3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o2).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o2)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o2) === 0); +}, $t$2.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf$1((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr$2(t2, i2); + var n4 = this.n, o2 = new K$2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o2).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); +}, $t$2.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr$2(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; } - return `${url}${queryString2}${hash2}`; - }; - exports2.pick = (input, filter, options) => { - options = Object.assign({ - parseFragmentIdentifier: true, - [encodeFragmentIdentifier]: false - }, options); - const { url, query, fragmentIdentifier } = exports2.parseUrl(input, options); - return exports2.stringifyUrl({ - url, - query: filterObject(query, filter), - fragmentIdentifier - }, options); - }; - exports2.exclude = (input, filter, options) => { - const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); - return exports2.pick(input, exclusionFilter, options); - }; -})(queryString); -const RELAY_JSONRPC = { - waku: { - publish: "waku_publish", - batchPublish: "waku_batchPublish", - subscribe: "waku_subscribe", - batchSubscribe: "waku_batchSubscribe", - subscription: "waku_subscription", - unsubscribe: "waku_unsubscribe", - batchUnsubscribe: "waku_batchUnsubscribe" - }, - irn: { - publish: "irn_publish", - batchPublish: "irn_batchPublish", - subscribe: "irn_subscribe", - batchSubscribe: "irn_batchSubscribe", - subscription: "irn_subscription", - unsubscribe: "irn_unsubscribe", - batchUnsubscribe: "irn_batchUnsubscribe" - }, - iridium: { - publish: "iridium_publish", - batchPublish: "iridium_batchPublish", - subscribe: "iridium_subscribe", - batchSubscribe: "iridium_batchSubscribe", - subscription: "iridium_subscription", - unsubscribe: "iridium_unsubscribe", - batchUnsubscribe: "iridium_batchUnsubscribe" + if (o2.eq(r3)) + return n4; } + throw new Error("Unable to find valid recovery factor"); }; -function L$1(e, n3) { - return e.includes(":") ? [e] : n3.chains || []; +var La$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt$3, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr$1, r3.curves = Kr$1, r3.ec = za$1, r3.eddsa = null; +}), ja = La$1.ec; +const Qa = "signing-key/5.7.0", qi = new L$3(Qa); +let Ki = null; +function ve() { + return Ki || (Ki = new ja("secp256k1")), Ki; } -const J$1 = "base10", p$1 = "base16", F$2 = "base64pad", H$1 = "utf8", Q$2 = 0, _$1 = 1, Dn = 0, Te = 1, Z$1 = 12, X$1 = 32; -function kn() { - const e = x25519.generateKeyPair(); - return { privateKey: toString(e.secretKey, p$1), publicKey: toString(e.publicKey, p$1) }; +class Ja { + constructor(t2) { + br$1(this, "curve", "secp256k1"), br$1(this, "privateKey", Kt$2(t2)), N0(this.privateKey) !== 32 && qi.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)); + br$1(this, "publicKey", "0x" + r3.getPublic(false, "hex")), br$1(this, "compressedPublicKey", "0x" + r3.getPublic(true, "hex")), br$1(this, "_isSigningKey", true); + } + _addPoint(t2) { + const r3 = ve().keyFromPublic(Ot$2(this.publicKey)), i2 = ve().keyFromPublic(Ot$2(t2)); + return "0x" + r3.pub.add(i2.pub).encodeCompressed("hex"); + } + signDigest(t2) { + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)), i2 = Ot$2(t2); + i2.length !== 32 && qi.throwArgumentError("bad digest length", "digest", t2); + const n4 = r3.sign(i2, { canonical: true }); + return zn({ recoveryParam: n4.recoveryParam, r: oe$1("0x" + n4.r.toString(16), 32), s: oe$1("0x" + n4.s.toString(16), 32) }); + } + computeSharedSecret(t2) { + const r3 = ve().keyFromPrivate(Ot$2(this.privateKey)), i2 = ve().keyFromPublic(Ot$2(Df(t2))); + return oe$1("0x" + r3.derive(i2.getPublic()).toString(16), 32); + } + static isSigningKey(t2) { + return !!(t2 && t2._isSigningKey); + } } -function Vn() { - const e = random.randomBytes(X$1); - return toString(e, p$1); +function Ga(e2, t2) { + const r3 = zn(t2), i2 = { r: Ot$2(r3.r), s: Ot$2(r3.s) }; + return "0x" + ve().recoverPubKey(Ot$2(e2), i2, r3.recoveryParam).encode("hex", false); } -function Mn(e, n3) { - const t2 = x25519.sharedKey(fromString(e, p$1), fromString(n3, p$1), true), r2 = new HKDF_1(sha256.SHA256, t2).expand(X$1); - return toString(r2, p$1); +function Df(e2, t2) { + const r3 = Ot$2(e2); + if (r3.length === 32) { + const i2 = new Ja(r3); + return i2.publicKey; + } else { + if (r3.length === 33) + return "0x" + ve().keyFromPublic(r3).getPublic(false, "hex"); + if (r3.length === 65) + return Kt$2(r3); + } + return qi.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} +var Ff$1; +(function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; +})(Ff$1 || (Ff$1 = {})); +function Va(e2) { + const t2 = Df(e2); + return ns$1(Hn(yi(Hn(t2, 1)), 12)); +} +function Wa(e2, t2) { + return Va(Ga(Ot$2(e2), t2)); +} +const Xa = "https://rpc.walletconnect.com/v1"; +async function Tf(e2, t2, r3, i2, n4, o2) { + switch (r3.t) { + case "eip191": + return Uf(e2, t2, r3.s); + case "eip1271": + return await kf(e2, t2, r3.s, i2, n4, o2); + default: + throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r3.t}`); + } } -function Kn(e) { - const n3 = sha256.hash(fromString(e, p$1)); - return toString(n3, p$1); +function Uf(e2, t2, r3) { + return Wa(ff(t2), r3).toLowerCase() === e2.toLowerCase(); } -function Ln(e) { - const n3 = sha256.hash(fromString(e, H$1)); - return toString(n3, p$1); +async function kf(e2, t2, r3, i2, n4, o2) { + try { + const h4 = "0x1626ba7e", p2 = "0000000000000000000000000000000000000000000000000000000000000040", b3 = "0000000000000000000000000000000000000000000000000000000000000041", m3 = r3.substring(2), w3 = ff(t2).substring(2), y3 = h4 + w3 + p2 + b3 + m3, S2 = await fetch(`${o2 || Xa}/?chainId=${i2}&projectId=${n4}`, { method: "POST", body: JSON.stringify({ id: Za(), jsonrpc: "2.0", method: "eth_call", params: [{ to: e2, data: y3 }, "latest"] }) }), { result: I2 } = await S2.json(); + return I2 ? I2.slice(0, h4.length).toLowerCase() === h4.toLowerCase() : false; + } catch (h4) { + return console.error("isValidEip1271Signature: ", h4), false; + } +} +function Za() { + return Date.now() + Math.floor(Math.random() * 1e3); +} +var $a = Object.defineProperty, tu = Object.defineProperties, eu = Object.getOwnPropertyDescriptors, qf = Object.getOwnPropertySymbols, ru = Object.prototype.hasOwnProperty, iu = Object.prototype.propertyIsEnumerable, Kf = (e2, t2, r3) => t2 in e2 ? $a(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, Hi$1 = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + ru.call(t2, r3) && Kf(e2, r3, t2[r3]); + if (qf) + for (var r3 of qf(t2)) + iu.call(t2, r3) && Kf(e2, r3, t2[r3]); + return e2; +}, Hf = (e2, t2) => tu(e2, eu(t2)); +const nu = "did:pkh:", Lr$1 = (e2) => e2 == null ? void 0 : e2.split(":"), zi = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return e2.includes(nu) ? t2[3] : t2[1]; +}, fu = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2[2] + ":" + t2[3]; +}, Li = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2.pop(); +}; +async function ou(e2) { + const { cacao: t2, projectId: r3 } = e2, { s: i2, p: n4 } = t2, o2 = zf(n4, n4.iss), h4 = Li(n4.iss); + return await Tf(h4, o2, i2, zi(n4.iss), r3); +} +const zf = (e2, t2) => { + const r3 = `${e2.domain} wants you to sign in with your Ethereum account:`, i2 = Li(t2); + if (!e2.aud && !e2.uri) + throw new Error("Either `aud` or `uri` is required to construct the message"); + let n4 = e2.statement || void 0; + const o2 = `URI: ${e2.aud || e2.uri}`, h4 = `Version: ${e2.version}`, p2 = `Chain ID: ${zi(t2)}`, b3 = `Nonce: ${e2.nonce}`, m3 = `Issued At: ${e2.iat}`, w3 = e2.resources ? `Resources:${e2.resources.map((S2) => ` +- ${S2}`).join("")}` : void 0, y3 = Qr(e2.resources); + if (y3) { + const S2 = Oe(y3); + n4 = Ji$1(n4, S2); + } + return [r3, i2, "", n4, "", o2, h4, p2, b3, m3, w3].filter((S2) => S2 != null).join(` +`); +}; +function Jf(e2) { + return Buffer.from(JSON.stringify(e2)).toString("base64"); +} +function Gf(e2) { + return JSON.parse(Buffer.from(e2, "base64").toString("utf-8")); +} +function me$1(e2) { + if (!e2) + throw new Error("No recap provided, value is undefined"); + if (!e2.att) + throw new Error("No `att` property found"); + const t2 = Object.keys(e2.att); + if (!(t2 != null && t2.length)) + throw new Error("No resources found in `att` property"); + t2.forEach((r3) => { + const i2 = e2.att[r3]; + if (Array.isArray(i2)) + throw new Error(`Resource must be an object: ${r3}`); + if (typeof i2 != "object") + throw new Error(`Resource must be an object: ${r3}`); + if (!Object.keys(i2).length) + throw new Error(`Resource object is empty: ${r3}`); + Object.keys(i2).forEach((n4) => { + const o2 = i2[n4]; + if (!Array.isArray(o2)) + throw new Error(`Ability limits ${n4} must be an array of objects, found: ${o2}`); + if (!o2.length) + throw new Error(`Value of ${n4} is empty array, must be an array with objects`); + o2.forEach((h4) => { + if (typeof h4 != "object") + throw new Error(`Ability limits (${n4}) must be an array of objects, found: ${h4}`); + }); + }); + }); } -function Pe(e) { - return fromString(`${e}`, J$1); +function Yf(e2, t2, r3, i2 = {}) { + return r3 == null ? void 0 : r3.sort((n4, o2) => n4.localeCompare(o2)), { att: { [e2]: ji(t2, r3, i2) } }; } -function j$1(e) { - return Number(toString(e, J$1)); +function ji(e2, t2, r3 = {}) { + t2 = t2 == null ? void 0 : t2.sort((n4, o2) => n4.localeCompare(o2)); + const i2 = t2.map((n4) => ({ [`${e2}/${n4}`]: [r3] })); + return Object.assign({}, ...i2); } -function xn(e) { - const n3 = Pe(typeof e.type < "u" ? e.type : Q$2); - if (j$1(n3) === _$1 && typeof e.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - const t2 = typeof e.senderPublicKey < "u" ? fromString(e.senderPublicKey, p$1) : void 0, r2 = typeof e.iv < "u" ? fromString(e.iv, p$1) : random.randomBytes(Z$1), o2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e.symKey, p$1)).seal(r2, fromString(e.message, H$1)); - return Re({ type: n3, sealed: o2, iv: r2, senderPublicKey: t2 }); +function jr(e2) { + return me$1(e2), `urn:recap:${Jf(e2).replace(/=/g, "")}`; } -function Fn(e) { - const n3 = new chacha20poly1305.ChaCha20Poly1305(fromString(e.symKey, p$1)), { sealed: t2, iv: r2 } = ee$1(e.encoded), o2 = n3.open(r2, t2); - if (o2 === null) - throw new Error("Failed to decrypt"); - return toString(o2, H$1); +function Oe(e2) { + const t2 = Gf(e2.replace("urn:recap:", "")); + return me$1(t2), t2; } -function Re(e) { - if (j$1(e.type) === _$1) { - if (typeof e.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - return toString(concat([e.type, e.senderPublicKey, e.iv, e.sealed]), F$2); - } - return toString(concat([e.type, e.iv, e.sealed]), F$2); +function cu(e2, t2, r3) { + const i2 = Yf(e2, t2, r3); + return jr(i2); } -function ee$1(e) { - const n3 = fromString(e, F$2), t2 = n3.slice(Dn, Te), r2 = Te; - if (j$1(t2) === _$1) { - const d3 = r2 + X$1, l2 = d3 + Z$1, c2 = n3.slice(r2, d3), u3 = n3.slice(d3, l2), a3 = n3.slice(l2); - return { type: t2, sealed: a3, iv: u3, senderPublicKey: c2 }; - } - const o2 = r2 + Z$1, s2 = n3.slice(r2, o2), i2 = n3.slice(o2); - return { type: t2, sealed: i2, iv: s2 }; +function Qi$1(e2) { + return e2 && e2.includes("urn:recap:"); } -function Hn(e, n3) { - const t2 = ee$1(e); - return Ae({ type: j$1(t2.type), senderPublicKey: typeof t2.senderPublicKey < "u" ? toString(t2.senderPublicKey, p$1) : void 0, receiverPublicKey: n3 == null ? void 0 : n3.receiverPublicKey }); +function lu(e2, t2) { + const r3 = Oe(e2), i2 = Oe(t2), n4 = Wf(r3, i2); + return jr(n4); } -function Ae(e) { - const n3 = (e == null ? void 0 : e.type) || Q$2; - if (n3 === _$1) { - if (typeof (e == null ? void 0 : e.senderPublicKey) > "u") - throw new Error("missing sender public key"); - if (typeof (e == null ? void 0 : e.receiverPublicKey) > "u") - throw new Error("missing receiver public key"); - } - return { type: n3, senderPublicKey: e == null ? void 0 : e.senderPublicKey, receiverPublicKey: e == null ? void 0 : e.receiverPublicKey }; +function Wf(e2, t2) { + me$1(e2), me$1(t2); + const r3 = Object.keys(e2.att).concat(Object.keys(t2.att)).sort((n4, o2) => n4.localeCompare(o2)), i2 = { att: {} }; + return r3.forEach((n4) => { + var o2, h4; + Object.keys(((o2 = e2.att) == null ? void 0 : o2[n4]) || {}).concat(Object.keys(((h4 = t2.att) == null ? void 0 : h4[n4]) || {})).sort((p2, b3) => p2.localeCompare(b3)).forEach((p2) => { + var b3, m3; + i2.att[n4] = Hf(Hi$1({}, i2.att[n4]), { [p2]: ((b3 = e2.att[n4]) == null ? void 0 : b3[p2]) || ((m3 = t2.att[n4]) == null ? void 0 : m3[p2]) }); + }); + }), i2; +} +function Ji$1(e2 = "", t2) { + me$1(t2); + const r3 = "I further authorize the stated URI to perform the following actions on my behalf: "; + if (e2.includes(r3)) + return e2; + const i2 = []; + let n4 = 0; + Object.keys(t2.att).forEach((p2) => { + const b3 = Object.keys(t2.att[p2]).map((y3) => ({ ability: y3.split("/")[0], action: y3.split("/")[1] })); + b3.sort((y3, S2) => y3.action.localeCompare(S2.action)); + const m3 = {}; + b3.forEach((y3) => { + m3[y3.ability] || (m3[y3.ability] = []), m3[y3.ability].push(y3.action); + }); + const w3 = Object.keys(m3).map((y3) => (n4++, `(${n4}) '${y3}': '${m3[y3].join("', '")}' for '${p2}'.`)); + i2.push(w3.join(", ").replace(".,", ".")); + }); + const o2 = i2.join(" "), h4 = `${r3}${o2}`; + return `${e2 ? e2 + " " : ""}${h4}`; } -function qn(e) { - return e.type === _$1 && typeof e.senderPublicKey == "string" && typeof e.receiverPublicKey == "string"; +function du(e2) { + var t2; + const r3 = Oe(e2); + me$1(r3); + const i2 = (t2 = r3.att) == null ? void 0 : t2.eip155; + return i2 ? Object.keys(i2).map((n4) => n4.split("/")[1]) : []; +} +function pu(e2) { + const t2 = Oe(e2); + me$1(t2); + const r3 = []; + return Object.values(t2.att).forEach((i2) => { + Object.values(i2).forEach((n4) => { + var o2; + (o2 = n4 == null ? void 0 : n4[0]) != null && o2.chains && r3.push(n4[0].chains); + }); + }), [...new Set(r3.flat())]; } -var Bn = Object.defineProperty, Ue$1 = Object.getOwnPropertySymbols, Gn = Object.prototype.hasOwnProperty, Wn = Object.prototype.propertyIsEnumerable, _e = (e, n3, t2) => n3 in e ? Bn(e, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[n3] = t2, $e$1 = (e, n3) => { - for (var t2 in n3 || (n3 = {})) - Gn.call(n3, t2) && _e(e, t2, n3[t2]); - if (Ue$1) - for (var t2 of Ue$1(n3)) - Wn.call(n3, t2) && _e(e, t2, n3[t2]); - return e; -}; -const Ce = "ReactNative", m$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, De$1 = "js"; -function te$1() { - return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; +function Qr(e2) { + if (!e2) + return; + const t2 = e2 == null ? void 0 : e2[e2.length - 1]; + return Qi$1(t2) ? t2 : void 0; } -function $$1() { - return !getDocument_1() && !!getNavigator_1() && navigator.product === Ce; +const Gi = "base10", zt$1 = "base16", Jr = "base64pad", Gr = "utf8", Yi$1 = 0, lr$1 = 1, vu = 0, Zf = 1, Vi = 12, Wi$1 = 32; +function mu() { + const e2 = x25519.generateKeyPair(); + return { privateKey: toString(e2.secretKey, zt$1), publicKey: toString(e2.publicKey, zt$1) }; } -function D$2() { - return !te$1() && !!getNavigator_1() && !!getDocument_1(); +function gu() { + const e2 = random.randomBytes(Wi$1); + return toString(e2, zt$1); } -function R$2() { - return $$1() ? m$1.reactNative : te$1() ? m$1.node : D$2() ? m$1.browser : m$1.unknown; +function Au(e2, t2) { + const r3 = x25519.sharedKey(fromString(e2, zt$1), fromString(t2, zt$1), true), i2 = new HKDF_1(sha256.SHA256, r3).expand(Wi$1); + return toString(i2, zt$1); } -function Jn() { - var e; - try { - return $$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e = global.Application) == null ? void 0 : e.applicationId : void 0; - } catch { - return; - } +function bu(e2) { + const t2 = sha256.hash(fromString(e2, zt$1)); + return toString(t2, zt$1); } -function ke$1(e, n3) { - let t2 = queryString.parse(e); - return t2 = $e$1($e$1({}, t2), n3), e = queryString.stringify(t2), e; +function yu(e2) { + const t2 = sha256.hash(fromString(e2, Gr)); + return toString(t2, zt$1); } -function Qn() { - return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; +function $f(e2) { + return fromString(`${e2}`, Gi); } -function Ve$1() { - if (R$2() === m$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { - const { OS: t2, Version: r2 } = global.Platform; - return [t2, r2].join("-"); - } - const e = detect(); - if (e === null) - return "unknown"; - const n3 = e.os ? e.os.replace(" ", "").toLowerCase() : "unknown"; - return e.type === "browser" ? [n3, e.name, e.version].join("-") : [n3, e.version].join("-"); -} -function Me$1() { - var e; - const n3 = R$2(); - return n3 === m$1.browser ? [n3, ((e = getLocation_1()) == null ? void 0 : e.host) || "unknown"].join(":") : n3; -} -function Ke$1(e, n3, t2) { - const r2 = Ve$1(), o2 = Me$1(); - return [[e, n3].join("-"), [De$1, t2].join("-"), r2, o2].join("/"); -} -function Xn({ protocol: e, version: n3, relayUrl: t2, sdkVersion: r2, auth: o2, projectId: s2, useOnCloseEvent: i2, bundleId: d3 }) { - const l2 = t2.split("?"), c2 = Ke$1(e, n3, r2), u3 = { auth: o2, ua: c2, projectId: s2, useOnCloseEvent: i2 || void 0, origin: d3 || void 0 }, a3 = ke$1(l2[1] || "", u3); - return l2[0] + "?" + a3; -} -function O$1(e, n3) { - return e.filter((t2) => n3.includes(t2)).length === e.length; -} -function rt$1(e) { - return Object.fromEntries(e.entries()); -} -function ot$1(e) { - return new Map(Object.entries(e)); -} -function at$1(e = cjs$4.FIVE_MINUTES, n3) { - const t2 = cjs$4.toMiliseconds(e || cjs$4.FIVE_MINUTES); - let r2, o2, s2; - return { resolve: (i2) => { - s2 && r2 && (clearTimeout(s2), r2(i2)); - }, reject: (i2) => { - s2 && o2 && (clearTimeout(s2), o2(i2)); - }, done: () => new Promise((i2, d3) => { - s2 = setTimeout(() => { - d3(new Error(n3)); - }, t2), r2 = i2, o2 = d3; - }) }; +function Mr(e2) { + return Number(toString(e2, Gi)); } -function ut$1(e, n3, t2) { - return new Promise(async (r2, o2) => { - const s2 = setTimeout(() => o2(new Error(t2)), n3); - try { - const i2 = await e; - r2(i2); - } catch (i2) { - o2(i2); - } - clearTimeout(s2); - }); +function wu(e2) { + const t2 = $f(typeof e2.type < "u" ? e2.type : Yi$1); + if (Mr(t2) === lr$1 && typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + const r3 = typeof e2.senderPublicKey < "u" ? fromString(e2.senderPublicKey, zt$1) : void 0, i2 = typeof e2.iv < "u" ? fromString(e2.iv, zt$1) : random.randomBytes(Vi), n4 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)).seal(i2, fromString(e2.message, Gr)); + return to({ type: t2, sealed: n4, iv: i2, senderPublicKey: r3 }); } -function re(e, n3) { - if (typeof n3 == "string" && n3.startsWith(`${e}:`)) - return n3; - if (e.toLowerCase() === "topic") { - if (typeof n3 != "string") - throw new Error('Value must be "string" for expirer target type: topic'); - return `topic:${n3}`; - } else if (e.toLowerCase() === "id") { - if (typeof n3 != "number") - throw new Error('Value must be "number" for expirer target type: id'); - return `id:${n3}`; - } - throw new Error(`Unknown expirer target type: ${e}`); +function xu(e2) { + const t2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)), { sealed: r3, iv: i2 } = Xi$1(e2.encoded), n4 = t2.open(i2, r3); + if (n4 === null) + throw new Error("Failed to decrypt"); + return toString(n4, Gr); } -function lt$1(e) { - return re("topic", e); +function to(e2) { + if (Mr(e2.type) === lr$1) { + if (typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + return toString(concat([e2.type, e2.senderPublicKey, e2.iv, e2.sealed]), Jr); + } + return toString(concat([e2.type, e2.iv, e2.sealed]), Jr); } -function dt$1(e) { - return re("id", e); +function Xi$1(e2) { + const t2 = fromString(e2, Jr), r3 = t2.slice(vu, Zf), i2 = Zf; + if (Mr(r3) === lr$1) { + const p2 = i2 + Wi$1, b3 = p2 + Vi, m3 = t2.slice(i2, p2), w3 = t2.slice(p2, b3), y3 = t2.slice(b3); + return { type: r3, sealed: y3, iv: w3, senderPublicKey: m3 }; + } + const n4 = i2 + Vi, o2 = t2.slice(i2, n4), h4 = t2.slice(n4); + return { type: r3, sealed: h4, iv: o2 }; } -function ft$1(e) { - const [n3, t2] = e.split(":"), r2 = { id: void 0, topic: void 0 }; - if (n3 === "topic" && typeof t2 == "string") - r2.topic = t2; - else if (n3 === "id" && Number.isInteger(Number(t2))) - r2.id = Number(t2); - else - throw new Error(`Invalid target, expected id:number or topic:string, got ${n3}:${t2}`); - return r2; +function Mu(e2, t2) { + const r3 = Xi$1(e2); + return eo({ type: Mr(r3.type), senderPublicKey: typeof r3.senderPublicKey < "u" ? toString(r3.senderPublicKey, zt$1) : void 0, receiverPublicKey: t2 == null ? void 0 : t2.receiverPublicKey }); } -function pt$1(e, n3) { - return cjs$4.fromMiliseconds((n3 || Date.now()) + cjs$4.toMiliseconds(e)); +function eo(e2) { + const t2 = (e2 == null ? void 0 : e2.type) || Yi$1; + if (t2 === lr$1) { + if (typeof (e2 == null ? void 0 : e2.senderPublicKey) > "u") + throw new Error("missing sender public key"); + if (typeof (e2 == null ? void 0 : e2.receiverPublicKey) > "u") + throw new Error("missing receiver public key"); + } + return { type: t2, senderPublicKey: e2 == null ? void 0 : e2.senderPublicKey, receiverPublicKey: e2 == null ? void 0 : e2.receiverPublicKey }; } -function mt$1(e) { - return Date.now() >= cjs$4.toMiliseconds(e); +function Eu(e2) { + return e2.type === lr$1 && typeof e2.senderPublicKey == "string" && typeof e2.receiverPublicKey == "string"; } -function yt$1(e, n3) { - return `${e}${n3 ? `:${n3}` : ""}`; +const ro = "irn"; +function Su(e2) { + return (e2 == null ? void 0 : e2.relay) || { protocol: ro }; } -async function gt$1({ id: e, topic: n3, wcDeepLink: t2 }) { - try { - if (!t2) - return; - const r2 = typeof t2 == "string" ? JSON.parse(t2) : t2; - let o2 = r2 == null ? void 0 : r2.href; - if (typeof o2 != "string") - return; - o2.endsWith("/") && (o2 = o2.slice(0, -1)); - const s2 = `${o2}/wc?requestId=${e}&sessionTopic=${n3}`, i2 = R$2(); - i2 === m$1.browser ? s2.startsWith("https://") ? window.open(s2, "_blank", "noreferrer noopener") : window.open(s2, "_self", "noreferrer noopener") : i2 === m$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(s2); - } catch (r2) { - console.error(r2); - } +function Nu(e2) { + const t2 = C$1[e2]; + if (typeof t2 > "u") + throw new Error(`Relay Protocol not supported: ${e2}`); + return t2; } -async function ht$1(e, n3) { - try { - return await e.getItem(n3) || (D$2() ? localStorage.getItem(n3) : void 0); - } catch (t2) { - console.error(t2); - } -} -const He$1 = "irn"; -function vt$1(e) { - return (e == null ? void 0 : e.relay) || { protocol: He$1 }; -} -function Et$1(e) { - const n3 = RELAY_JSONRPC[e]; - if (typeof n3 > "u") - throw new Error(`Relay Protocol not supported: ${e}`); - return n3; -} -var bt$1 = Object.defineProperty, Nt$1 = Object.defineProperties, Ot$1 = Object.getOwnPropertyDescriptors, qe$1 = Object.getOwnPropertySymbols, St$1 = Object.prototype.hasOwnProperty, wt$1 = Object.prototype.propertyIsEnumerable, Be$1 = (e, n3, t2) => n3 in e ? bt$1(e, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[n3] = t2, It$1 = (e, n3) => { - for (var t2 in n3 || (n3 = {})) - St$1.call(n3, t2) && Be$1(e, t2, n3[t2]); - if (qe$1) - for (var t2 of qe$1(n3)) - wt$1.call(n3, t2) && Be$1(e, t2, n3[t2]); - return e; -}, Tt$1 = (e, n3) => Nt$1(e, Ot$1(n3)); -function Ge$1(e, n3 = "-") { - const t2 = {}, r2 = "relay" + n3; - return Object.keys(e).forEach((o2) => { - if (o2.startsWith(r2)) { - const s2 = o2.replace(r2, ""), i2 = e[o2]; - t2[s2] = i2; - } +var Iu = Object.defineProperty, _u = Object.defineProperties, Bu = Object.getOwnPropertyDescriptors, io = Object.getOwnPropertySymbols, Cu = Object.prototype.hasOwnProperty, Ru = Object.prototype.propertyIsEnumerable, no = (e2, t2, r3) => t2 in e2 ? Iu(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, fo = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Cu.call(t2, r3) && no(e2, r3, t2[r3]); + if (io) + for (var r3 of io(t2)) + Ru.call(t2, r3) && no(e2, r3, t2[r3]); + return e2; +}, Ou = (e2, t2) => _u(e2, Bu(t2)); +function oo(e2, t2 = "-") { + const r3 = {}, i2 = "relay" + t2; + return Object.keys(e2).forEach((n4) => { + if (n4.startsWith(i2)) { + const o2 = n4.replace(i2, ""), h4 = e2[n4]; + r3[o2] = h4; + } + }), r3; +} +function Pu(e2) { + e2 = e2.includes("wc://") ? e2.replace("wc://", "") : e2, e2 = e2.includes("wc:") ? e2.replace("wc:", "") : e2; + const t2 = e2.indexOf(":"), r3 = e2.indexOf("?") !== -1 ? e2.indexOf("?") : void 0, i2 = e2.substring(0, t2), n4 = e2.substring(t2 + 1, r3).split("@"), o2 = typeof r3 < "u" ? e2.substring(r3) : "", h4 = queryString.parse(o2), p2 = typeof h4.methods == "string" ? h4.methods.split(",") : void 0; + return { protocol: i2, topic: so(n4[0]), version: parseInt(n4[1], 10), symKey: h4.symKey, relay: oo(h4), methods: p2, expiryTimestamp: h4.expiryTimestamp ? parseInt(h4.expiryTimestamp, 10) : void 0 }; +} +function so(e2) { + return e2.startsWith("//") ? e2.substring(2) : e2; +} +function ao(e2, t2 = "-") { + const r3 = "relay", i2 = {}; + return Object.keys(e2).forEach((n4) => { + const o2 = r3 + t2 + n4; + e2[n4] && (i2[o2] = e2[n4]); + }), i2; +} +function Du(e2) { + return `${e2.protocol}:${e2.topic}@${e2.version}?` + queryString.stringify(fo(Ou(fo({ symKey: e2.symKey }, ao(e2.relay)), { expiryTimestamp: e2.expiryTimestamp }), e2.methods ? { methods: e2.methods.join(",") } : {})); +} +function $e$1(e2) { + const t2 = []; + return e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2.push(`${i2}:${n4}`); }), t2; } -function Pt$1(e) { - e = e.includes("wc://") ? e.replace("wc://", "") : e, e = e.includes("wc:") ? e.replace("wc:", "") : e; - const n3 = e.indexOf(":"), t2 = e.indexOf("?") !== -1 ? e.indexOf("?") : void 0, r2 = e.substring(0, n3), o2 = e.substring(n3 + 1, t2).split("@"), s2 = typeof t2 < "u" ? e.substring(t2) : "", i2 = queryString.parse(s2); - return { protocol: r2, topic: We$1(o2[0]), version: parseInt(o2[1], 10), symKey: i2.symKey, relay: Ge$1(i2), expiryTimestamp: i2.expiryTimestamp ? parseInt(i2.expiryTimestamp, 10) : void 0 }; -} -function We$1(e) { - return e.startsWith("//") ? e.substring(2) : e; -} -function ze(e, n3 = "-") { - const t2 = "relay", r2 = {}; - return Object.keys(e).forEach((o2) => { - const s2 = t2 + n3 + o2; - e[o2] && (r2[s2] = e[o2]); - }), r2; -} -function Rt$1(e) { - return `${e.protocol}:${e.topic}@${e.version}?` + queryString.stringify(Tt$1(It$1({ symKey: e.symKey }, ze(e.relay)), { expiryTimestamp: e.expiryTimestamp })); -} -function A$1(e) { - const n3 = []; - return e.forEach((t2) => { - const [r2, o2] = t2.split(":"); - n3.push(`${r2}:${o2}`); - }), n3; -} -function Qe$1(e) { - const n3 = []; - return Object.values(e).forEach((t2) => { - n3.push(...A$1(t2.accounts)); - }), n3; -} -function Ze$1(e, n3) { +function co(e2) { const t2 = []; - return Object.values(e).forEach((r2) => { - A$1(r2.accounts).includes(n3) && t2.push(...r2.methods); + return Object.values(e2).forEach((r3) => { + t2.push(...$e$1(r3.accounts)); }), t2; } -function Xe$1(e, n3) { - const t2 = []; - return Object.values(e).forEach((r2) => { - A$1(r2.accounts).includes(n3) && t2.push(...r2.events); +function lo(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.methods); + }), r3; +} +function po(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.events); + }), r3; +} +function mo(e2) { + const t2 = {}; + return e2 == null ? void 0 : e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2[i2] || (t2[i2] = { accounts: [], chains: [], events: [] }), t2[i2].accounts.push(r3), t2[i2].chains.push(`${i2}:${n4}`); }), t2; } -const nn = { 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 } }, tn = { 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 N$1(e, n3) { - const { message: t2, code: r2 } = tn[e]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; +function ju(e2, t2) { + t2 = t2.map((i2) => i2.replace("did:pkh:", "")); + const r3 = mo(t2); + for (const [i2, n4] of Object.entries(r3)) + n4.methods ? n4.methods = ge$1(n4.methods, e2) : n4.methods = e2, n4.events = ["chainChanged", "accountsChanged"]; + return r3; +} +const go$1 = { 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 } }, Ao = { 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 xe(e2, t2) { + const { message: r3, code: i2 } = Ao[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; } -function U$2(e, n3) { - const { message: t2, code: r2 } = nn[e]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; +function tr$2(e2, t2) { + const { message: r3, code: i2 } = go$1[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; } -function k(e, n3) { - return Array.isArray(e) ? typeof n3 < "u" && e.length ? e.every(n3) : true : false; +function Er(e2, t2) { + return Array.isArray(e2) ? true : false; } -function B$1(e) { - return Object.getPrototypeOf(e) === Object.prototype && Object.keys(e).length; +function Yr(e2) { + return Object.getPrototypeOf(e2) === Object.prototype && Object.keys(e2).length; } -function w$3(e) { - return typeof e > "u"; +function Pe(e2) { + return typeof e2 > "u"; } -function g$3(e, n3) { - return n3 && w$3(e) ? true : typeof e == "string" && !!e.trim().length; +function Gt$1(e2, t2) { + return t2 && Pe(e2) ? true : typeof e2 == "string" && !!e2.trim().length; } -function G$1(e, n3) { - return n3 && w$3(e) ? true : typeof e == "number" && !isNaN(e); +function Vr(e2, t2) { + return typeof e2 == "number" && !isNaN(e2); } -function Mt$1(e, n3) { - const { requiredNamespaces: t2 } = n3, r2 = Object.keys(e.namespaces), o2 = Object.keys(t2); - let s2 = true; - return O$1(o2, r2) ? (r2.forEach((i2) => { - const { accounts: d3, methods: l2, events: c2 } = e.namespaces[i2], u3 = A$1(d3), a3 = t2[i2]; - (!O$1(L$1(i2, a3), u3) || !O$1(a3.methods, l2) || !O$1(a3.events, c2)) && (s2 = false); - }), s2) : false; +function Qu(e2, t2) { + const { requiredNamespaces: r3 } = t2, i2 = Object.keys(e2.namespaces), n4 = Object.keys(r3); + let o2 = true; + return _e$1(n4, i2) ? (i2.forEach((h4) => { + const { accounts: p2, methods: b3, events: m3 } = e2.namespaces[h4], w3 = $e$1(p2), y3 = r3[h4]; + (!_e$1(_r$1(h4, y3), w3) || !_e$1(y3.methods, b3) || !_e$1(y3.events, m3)) && (o2 = false); + }), o2) : false; } -function V$1(e) { - return g$3(e, false) && e.includes(":") ? e.split(":").length === 2 : false; +function Sr$1(e2) { + return Gt$1(e2, false) && e2.includes(":") ? e2.split(":").length === 2 : false; } -function rn(e) { - if (g$3(e, false) && e.includes(":")) { - const n3 = e.split(":"); - if (n3.length === 3) { - const t2 = n3[0] + ":" + n3[1]; - return !!n3[2] && V$1(t2); +function bo(e2) { + if (Gt$1(e2, false) && e2.includes(":")) { + const t2 = e2.split(":"); + if (t2.length === 3) { + const r3 = t2[0] + ":" + t2[1]; + return !!t2[2] && Sr$1(r3); } } return false; } -function Kt$1(e) { - if (g$3(e, false)) +function Ju(e2) { + if (Gt$1(e2, false)) try { - return typeof new URL(e) < "u"; + return typeof new URL(e2) < "u"; } catch { return false; } return false; } -function Lt$1(e) { - var n3; - return (n3 = e == null ? void 0 : e.proposer) == null ? void 0 : n3.publicKey; -} -function xt$1(e) { - return e == null ? void 0 : e.topic; +function Gu(e2) { + var t2; + return (t2 = e2 == null ? void 0 : e2.proposer) == null ? void 0 : t2.publicKey; } -function Ft$1(e, n3) { - let t2 = null; - return g$3(e == null ? void 0 : e.publicKey, false) || (t2 = N$1("MISSING_OR_INVALID", `${n3} controller public key should be a string`)), t2; -} -function ie(e) { - let n3 = true; - return k(e) ? e.length && (n3 = e.every((t2) => g$3(t2, false))) : n3 = false, n3; -} -function on(e, n3, t2) { - let r2 = null; - return k(n3) && n3.length ? n3.forEach((o2) => { - r2 || V$1(o2) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, chain ${o2} should be a string and conform to "namespace:chainId" format`)); - }) : V$1(e) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, 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"] }`)), r2; -} -function sn(e, n3, t2) { - let r2 = null; - return Object.entries(e).forEach(([o2, s2]) => { - if (r2) - return; - const i2 = on(o2, L$1(o2, s2), `${n3} ${t2}`); - i2 && (r2 = i2); - }), r2; +function Yu(e2) { + return e2 == null ? void 0 : e2.topic; } -function cn(e, n3) { - let t2 = null; - return k(e) ? e.forEach((r2) => { - t2 || rn(r2) || (t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, account ${r2} should be a string and conform to "namespace:chainId:address" format`)); - }) : t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), t2; +function Vu(e2, t2) { + let r3 = null; + return Gt$1(e2 == null ? void 0 : e2.publicKey, false) || (r3 = xe("MISSING_OR_INVALID", `${t2} controller public key should be a string`)), r3; } -function an(e, n3) { - let t2 = null; - return Object.values(e).forEach((r2) => { - if (t2) - return; - const o2 = cn(r2 == null ? void 0 : r2.accounts, `${n3} namespace`); - o2 && (t2 = o2); - }), t2; +function tn(e2) { + let t2 = true; + return Er(e2) ? e2.length && (t2 = e2.every((r3) => Gt$1(r3, false))) : t2 = false, t2; } -function un(e, n3) { - let t2 = null; - return ie(e == null ? void 0 : e.methods) ? ie(e == null ? void 0 : e.events) || (t2 = U$2("UNSUPPORTED_EVENTS", `${n3}, events should be an array of strings or empty array for no events`)) : t2 = U$2("UNSUPPORTED_METHODS", `${n3}, methods should be an array of strings or empty array for no methods`), t2; +function yo(e2, t2, r3) { + let i2 = null; + return Er(t2) && t2.length ? t2.forEach((n4) => { + i2 || Sr$1(n4) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, chain ${n4} should be a string and conform to "namespace:chainId" format`)); + }) : Sr$1(e2) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, 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"] }`)), i2; } -function ce$2(e, n3) { - let t2 = null; - return Object.values(e).forEach((r2) => { - if (t2) +function wo(e2, t2, r3) { + let i2 = null; + return Object.entries(e2).forEach(([n4, o2]) => { + if (i2) return; - const o2 = un(r2, `${n3}, namespace`); - o2 && (t2 = o2); - }), t2; -} -function Ht$1(e, n3, t2) { - let r2 = null; - if (e && B$1(e)) { - const o2 = ce$2(e, n3); - o2 && (r2 = o2); - const s2 = sn(e, n3, t2); - s2 && (r2 = s2); + const h4 = yo(n4, _r$1(n4, o2), `${t2} ${r3}`); + h4 && (i2 = h4); + }), i2; +} +function xo(e2, t2) { + let r3 = null; + return Er(e2) ? e2.forEach((i2) => { + r3 || bo(i2) || (r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, account ${i2} should be a string and conform to "namespace:chainId:address" format`)); + }) : r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), r3; +} +function Mo(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = xo(i2 == null ? void 0 : i2.accounts, `${t2} namespace`); + n4 && (r3 = n4); + }), r3; +} +function Eo(e2, t2) { + let r3 = null; + return tn(e2 == null ? void 0 : e2.methods) ? tn(e2 == null ? void 0 : e2.events) || (r3 = tr$2("UNSUPPORTED_EVENTS", `${t2}, events should be an array of strings or empty array for no events`)) : r3 = tr$2("UNSUPPORTED_METHODS", `${t2}, methods should be an array of strings or empty array for no methods`), r3; +} +function en(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = Eo(i2, `${t2}, namespace`); + n4 && (r3 = n4); + }), r3; +} +function Wu(e2, t2, r3) { + let i2 = null; + if (e2 && Yr(e2)) { + const n4 = en(e2, t2); + n4 && (i2 = n4); + const o2 = wo(e2, t2, r3); + o2 && (i2 = o2); } else - r2 = N$1("MISSING_OR_INVALID", `${n3}, ${t2} should be an object with data`); - return r2; -} -function ln(e, n3) { - let t2 = null; - if (e && B$1(e)) { - const r2 = ce$2(e, n3); - r2 && (t2 = r2); - const o2 = an(e, n3); - o2 && (t2 = o2); + i2 = xe("MISSING_OR_INVALID", `${t2}, ${r3} should be an object with data`); + return i2; +} +function So(e2, t2) { + let r3 = null; + if (e2 && Yr(e2)) { + const i2 = en(e2, t2); + i2 && (r3 = i2); + const n4 = Mo(e2, t2); + n4 && (r3 = n4); } else - t2 = N$1("MISSING_OR_INVALID", `${n3}, namespaces should be an object with data`); - return t2; + r3 = xe("MISSING_OR_INVALID", `${t2}, namespaces should be an object with data`); + return r3; } -function dn(e) { - return g$3(e.protocol, true); +function No(e2) { + return Gt$1(e2.protocol, true); } -function qt$1(e, n3) { - let t2 = false; - return n3 && !e ? t2 = true : e && k(e) && e.length && e.forEach((r2) => { - t2 = dn(r2); - }), t2; +function Xu(e2, t2) { + let r3 = false; + return !e2 ? r3 = true : e2 && Er(e2) && e2.length && e2.forEach((i2) => { + r3 = No(i2); + }), r3; } -function Bt$1(e) { - return typeof e == "number"; +function Zu(e2) { + return typeof e2 == "number"; } -function Gt$1(e) { - return typeof e < "u" && typeof e !== null; +function $u(e2) { + return typeof e2 < "u" && typeof e2 !== null; } -function Wt(e) { - return !(!e || typeof e != "object" || !e.code || !G$1(e.code, false) || !e.message || !g$3(e.message, false)); +function th(e2) { + return !(!e2 || typeof e2 != "object" || !e2.code || !Vr(e2.code) || !e2.message || !Gt$1(e2.message, false)); } -function zt$1(e) { - return !(w$3(e) || !g$3(e.method, false)); +function eh(e2) { + return !(Pe(e2) || !Gt$1(e2.method, false)); } -function Yt$1(e) { - return !(w$3(e) || w$3(e.result) && w$3(e.error) || !G$1(e.id, false) || !g$3(e.jsonrpc, false)); +function rh(e2) { + return !(Pe(e2) || Pe(e2.result) && Pe(e2.error) || !Vr(e2.id) || !Gt$1(e2.jsonrpc, false)); } -function Jt$1(e) { - return !(w$3(e) || !g$3(e.name, false)); +function ih(e2) { + return !(Pe(e2) || !Gt$1(e2.name, false)); } -function Qt(e, n3) { - return !(!V$1(n3) || !Qe$1(e).includes(n3)); +function nh(e2, t2) { + return !(!Sr$1(t2) || !co(e2).includes(t2)); } -function Zt(e, n3, t2) { - return g$3(t2, false) ? Ze$1(e, n3).includes(t2) : false; +function fh(e2, t2, r3) { + return Gt$1(r3, false) ? lo(e2, t2).includes(r3) : false; } -function Xt(e, n3, t2) { - return g$3(t2, false) ? Xe$1(e, n3).includes(t2) : false; +function oh(e2, t2, r3) { + return Gt$1(r3, false) ? po(e2, t2).includes(r3) : false; } -function fn(e, n3, t2) { - let r2 = null; - const o2 = er$1(e), s2 = nr$1(n3), i2 = Object.keys(o2), d3 = Object.keys(s2), l2 = pn(Object.keys(e)), c2 = pn(Object.keys(n3)), u3 = l2.filter((a3) => !c2.includes(a3)); - return u3.length && (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces keys don't satisfy requiredNamespaces. - Required: ${u3.toString()} - Received: ${Object.keys(n3).toString()}`)), O$1(i2, d3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces chains don't satisfy required namespaces. - Required: ${i2.toString()} - Approved: ${d3.toString()}`)), Object.keys(n3).forEach((a3) => { - if (!a3.includes(":") || r2) +function Io(e2, t2, r3) { + let i2 = null; + const n4 = sh(e2), o2 = ah(t2), h4 = Object.keys(n4), p2 = Object.keys(o2), b3 = _o(Object.keys(e2)), m3 = _o(Object.keys(t2)), w3 = b3.filter((y3) => !m3.includes(y3)); + return w3.length && (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces keys don't satisfy requiredNamespaces. + Required: ${w3.toString()} + Received: ${Object.keys(t2).toString()}`)), _e$1(h4, p2) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces chains don't satisfy required namespaces. + Required: ${h4.toString()} + Approved: ${p2.toString()}`)), Object.keys(t2).forEach((y3) => { + if (!y3.includes(":") || i2) return; - const b3 = A$1(n3[a3].accounts); - b3.includes(a3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces accounts don't satisfy namespace accounts for ${a3} - Required: ${a3} - Approved: ${b3.toString()}`)); - }), i2.forEach((a3) => { - r2 || (O$1(o2[a3].methods, s2[a3].methods) ? O$1(o2[a3].events, s2[a3].events) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces events don't satisfy namespace events for ${a3}`)) : r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces methods don't satisfy namespace methods for ${a3}`)); - }), r2; -} -function er$1(e) { - const n3 = {}; - return Object.keys(e).forEach((t2) => { - var r2; - t2.includes(":") ? n3[t2] = e[t2] : (r2 = e[t2].chains) == null || r2.forEach((o2) => { - n3[o2] = { methods: e[t2].methods, events: e[t2].events }; + const S2 = $e$1(t2[y3].accounts); + S2.includes(y3) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces accounts don't satisfy namespace accounts for ${y3} + Required: ${y3} + Approved: ${S2.toString()}`)); + }), h4.forEach((y3) => { + i2 || (_e$1(n4[y3].methods, o2[y3].methods) ? _e$1(n4[y3].events, o2[y3].events) || (i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces events don't satisfy namespace events for ${y3}`)) : i2 = xe("NON_CONFORMING_NAMESPACES", `${r3} namespaces methods don't satisfy namespace methods for ${y3}`)); + }), i2; +} +function sh(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + var i2; + r3.includes(":") ? t2[r3] = e2[r3] : (i2 = e2[r3].chains) == null || i2.forEach((n4) => { + t2[n4] = { methods: e2[r3].methods, events: e2[r3].events }; }); - }), n3; + }), t2; } -function pn(e) { - return [...new Set(e.map((n3) => n3.includes(":") ? n3.split(":")[0] : n3))]; +function _o(e2) { + return [...new Set(e2.map((t2) => t2.includes(":") ? t2.split(":")[0] : t2))]; } -function nr$1(e) { - const n3 = {}; - return Object.keys(e).forEach((t2) => { - if (t2.includes(":")) - n3[t2] = e[t2]; +function ah(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + if (r3.includes(":")) + t2[r3] = e2[r3]; else { - const r2 = A$1(e[t2].accounts); - r2 == null ? void 0 : r2.forEach((o2) => { - n3[o2] = { accounts: e[t2].accounts.filter((s2) => s2.includes(`${o2}:`)), methods: e[t2].methods, events: e[t2].events }; + const i2 = $e$1(e2[r3].accounts); + i2 == null ? void 0 : i2.forEach((n4) => { + t2[n4] = { accounts: e2[r3].accounts.filter((o2) => o2.includes(`${n4}:`)), methods: e2[r3].methods, events: e2[r3].events }; }); } - }), n3; + }), t2; } -function tr$1(e, n3) { - return G$1(e, false) && e <= n3.max && e >= n3.min; +function uh(e2, t2) { + return Vr(e2) && e2 <= t2.max && e2 >= t2.min; } -function rr$1() { - const e = R$2(); - return new Promise((n3) => { - switch (e) { - case m$1.browser: - n3(mn()); +function hh() { + const e2 = We$2(); + return new Promise((t2) => { + switch (e2) { + case qt$1.browser: + t2(Bo()); break; - case m$1.reactNative: - n3(yn()); + case qt$1.reactNative: + t2(Co()); break; - case m$1.node: - n3(gn()); + case qt$1.node: + t2(Ro()); break; default: - n3(true); + t2(true); } }); } -function mn() { - return D$2() && (navigator == null ? void 0 : navigator.onLine); +function Bo() { + return pr$1() && (navigator == null ? void 0 : navigator.onLine); } -async function yn() { - if ($$1() && typeof global < "u" && global != null && global.NetInfo) { - const e = await (global == null ? void 0 : global.NetInfo.fetch()); - return e == null ? void 0 : e.isConnected; +async function Co() { + if (er$1() && typeof global < "u" && global != null && global.NetInfo) { + const e2 = await (global == null ? void 0 : global.NetInfo.fetch()); + return e2 == null ? void 0 : e2.isConnected; } return true; } -function gn() { +function Ro() { return true; } -function or$1(e) { - switch (R$2()) { - case m$1.browser: - hn(e); +function ch(e2) { + switch (We$2()) { + case qt$1.browser: + Oo(e2); break; - case m$1.reactNative: - vn(e); + case qt$1.reactNative: + Po(e2); break; } } -function hn(e) { - !$$1() && D$2() && (window.addEventListener("online", () => e(true)), window.addEventListener("offline", () => e(false))); +function Oo(e2) { + !er$1() && pr$1() && (window.addEventListener("online", () => e2(true)), window.addEventListener("offline", () => e2(false))); } -function vn(e) { - $$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((n3) => e(n3 == null ? void 0 : n3.isConnected))); +function Po(e2) { + er$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((t2) => e2(t2 == null ? void 0 : t2.isConnected))); } -const ae$1 = {}; -let sr$1 = class sr { - static get(n3) { - return ae$1[n3]; +const rn = {}; +class lh { + static get(t2) { + return rn[t2]; } - static set(n3, t2) { - ae$1[n3] = t2; + static set(t2, r3) { + rn[t2] = r3; } - static delete(n3) { - delete ae$1[n3]; + static delete(t2) { + delete rn[t2]; } -}; +} const PARSE_ERROR = "PARSE_ERROR"; const INVALID_REQUEST = "INVALID_REQUEST"; const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; @@ -9070,14 +12581,14 @@ function getError(type2) { return STANDARD_ERROR_MAP[type2]; } function getErrorByCode(code) { - const match = Object.values(STANDARD_ERROR_MAP).find((e) => e.code === code); + const match = Object.values(STANDARD_ERROR_MAP).find((e2) => e2.code === code); if (!match) { return STANDARD_ERROR_MAP[DEFAULT_ERROR]; } return match; } -function parseConnectionError(e, url, type2) { - return e.message.includes("getaddrinfo ENOTFOUND") || e.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${type2} RPC url at ${url}`) : e; +function parseConnectionError(e2, url, type2) { + return e2.message.includes("getaddrinfo ENOTFOUND") || e2.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${type2} RPC url at ${url}`) : e2; } var cjs = {}; var crypto$1 = {}; @@ -9158,7 +12669,7 @@ function formatJsonRpcError(id, error, data) { return { id, jsonrpc: "2.0", - error: formatErrorMessage(error, data) + error: formatErrorMessage(error) }; } function formatErrorMessage(error, data) { @@ -9168,26 +12679,23 @@ function formatErrorMessage(error, data) { if (typeof error === "string") { error = Object.assign(Object.assign({}, getError(SERVER_ERROR)), { message: error }); } - if (typeof data !== "undefined") { - error.data = data; - } if (isReservedErrorCode(error.code)) { error = getErrorByCode(error.code); } return error; } -class IEvents2 { +class e { } -class IBaseJsonRpcProvider extends IEvents2 { +let n$1 = class n2 extends e { constructor() { super(); } -} -class IJsonRpcProvider extends IBaseJsonRpcProvider { - constructor(connection2) { +}; +let r$1 = class r extends n$1 { + constructor(c2) { super(); } -} +}; const WS_REGEX = "^wss?:"; function getUrlProtocol(url) { const matches = url.match(new RegExp(/^\w+:/, "gi")); @@ -9222,7 +12730,7 @@ function isJsonRpcResult(payload) { function isJsonRpcError(payload) { return "error" in payload; } -class JsonRpcProvider extends IJsonRpcProvider { +class JsonRpcProvider extends r$1 { constructor(connection2) { super(connection2); this.events = new eventsExports.EventEmitter(); @@ -9258,8 +12766,8 @@ class JsonRpcProvider extends IJsonRpcProvider { if (!this.connection.connected) { try { await this.open(); - } catch (e) { - reject(e); + } catch (e2) { + reject(e2); } } this.events.on(`${request.id}`, (response) => { @@ -9271,8 +12779,8 @@ class JsonRpcProvider extends IJsonRpcProvider { }); try { await this.connection.send(request, context); - } catch (e) { - reject(e); + } catch (e2) { + reject(e2); } }); } @@ -9323,17 +12831,17 @@ class JsonRpcProvider extends IJsonRpcProvider { this.hasRegisteredEventListeners = true; } } -const w$2 = () => 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 : (() => { +const w$1 = () => 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 : (() => { try { return (() => {try { return require("ws") } catch (e) { } })(); - } catch (e) { + } catch (e2) { } -})(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a$1 = (c2) => c2.split("?")[0], h$1 = 10, S$1 = w$2(); -class f { - constructor(e) { - if (this.url = e, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(e)) - throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`); - this.url = e; +})(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a2 = (c2) => c2.split("?")[0], h3 = 10, S$2 = w$1(); +let f$2 = class f { + constructor(e2) { + if (this.url = e2, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(e2)) + throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); + this.url = e2; } get connected() { return typeof this.socket < "u"; @@ -9341,94 +12849,94 @@ class f { get connecting() { return this.registering; } - on(e, t2) { - this.events.on(e, t2); + on(e2, t2) { + this.events.on(e2, t2); } - once(e, t2) { - this.events.once(e, t2); + once(e2, t2) { + this.events.once(e2, t2); } - off(e, t2) { - this.events.off(e, t2); + off(e2, t2) { + this.events.off(e2, t2); } - removeListener(e, t2) { - this.events.removeListener(e, t2); + removeListener(e2, t2) { + this.events.removeListener(e2, t2); } - async open(e = this.url) { - await this.register(e); + async open(e2 = this.url) { + await this.register(e2); } async close() { - return new Promise((e, t2) => { + return new Promise((e2, t2) => { if (typeof this.socket > "u") { t2(new Error("Connection already closed")); return; } - this.socket.onclose = (n3) => { - this.onClose(n3), e(); + this.socket.onclose = (n4) => { + this.onClose(n4), e2(); }, this.socket.close(); }); } - async send(e) { + async send(e2) { typeof this.socket > "u" && (this.socket = await this.register()); try { - this.socket.send(safeJsonStringify(e)); + this.socket.send(safeJsonStringify(e2)); } catch (t2) { - this.onError(e.id, t2); + this.onError(e2.id, t2); } } - register(e = this.url) { - if (!isWsUrl(e)) - throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`); + register(e2 = this.url) { + if (!isWsUrl(e2)) + throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); if (this.registering) { const t2 = this.events.getMaxListeners(); - return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n3, o2) => { + return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n4, o2) => { this.events.once("register_error", (s2) => { this.resetMaxListeners(), o2(s2); }), this.events.once("open", () => { if (this.resetMaxListeners(), typeof this.socket > "u") return o2(new Error("WebSocket connection is missing or invalid")); - n3(this.socket); + n4(this.socket); }); }); } - return this.url = e, this.registering = true, new Promise((t2, n3) => { - const o2 = new URLSearchParams(e).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e) }, i2 = new S$1(e, [], s2); - b2() ? i2.onerror = (r2) => { - const l2 = r2; - n3(this.emitError(l2.error)); - } : i2.on("error", (r2) => { - n3(this.emitError(r2)); + return this.url = e2, this.registering = true, new Promise((t2, n4) => { + const o2 = new URLSearchParams(e2).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o2 } } : { rejectUnauthorized: !isLocalhostUrl(e2) }, i2 = new S$2(e2, [], s2); + b2() ? i2.onerror = (r3) => { + const l2 = r3; + n4(this.emitError(l2.error)); + } : i2.on("error", (r3) => { + n4(this.emitError(r3)); }), i2.onopen = () => { this.onOpen(i2), t2(i2); }; }); } - onOpen(e) { - e.onmessage = (t2) => this.onPayload(t2), e.onclose = (t2) => this.onClose(t2), this.socket = e, this.registering = false, this.events.emit("open"); + onOpen(e2) { + e2.onmessage = (t2) => this.onPayload(t2), e2.onclose = (t2) => this.onClose(t2), this.socket = e2, this.registering = false, this.events.emit("open"); } - onClose(e) { - this.socket = void 0, this.registering = false, this.events.emit("close", e); + onClose(e2) { + this.socket = void 0, this.registering = false, this.events.emit("close", e2); } - onPayload(e) { - if (typeof e.data > "u") + onPayload(e2) { + if (typeof e2.data > "u") return; - const t2 = typeof e.data == "string" ? safeJsonParse(e.data) : e.data; + const t2 = typeof e2.data == "string" ? safeJsonParse(e2.data) : e2.data; this.events.emit("payload", t2); } - onError(e, t2) { - const n3 = this.parseError(t2), o2 = n3.message || n3.toString(), s2 = formatJsonRpcError(e, o2); + onError(e2, t2) { + const n4 = this.parseError(t2), o2 = n4.message || n4.toString(), s2 = formatJsonRpcError(e2, o2); this.events.emit("payload", s2); } - parseError(e, t2 = this.url) { - return parseConnectionError(e, a$1(t2), "WS"); + parseError(e2, t2 = this.url) { + return parseConnectionError(e2, a2(t2), "WS"); } resetMaxListeners() { - this.events.getMaxListeners() > h$1 && this.events.setMaxListeners(h$1); + this.events.getMaxListeners() > h3 && this.events.setMaxListeners(h3); } - emitError(e) { - const t2 = this.parseError(new Error((e == null ? void 0 : e.message) || `WebSocket connection failed for host: ${a$1(this.url)}`)); + emitError(e2) { + const t2 = this.parseError(new Error((e2 == null ? void 0 : e2.message) || `WebSocket connection failed for host: ${a2(this.url)}`)); return this.events.emit("register_error", t2), t2; } -} +}; var lodash_isequal = { exports: {} }; lodash_isequal.exports; (function(module2, exports2) { @@ -9454,7 +12962,7 @@ lodash_isequal.exports; var nodeUtil = function() { try { return freeProcess && freeProcess.binding && freeProcess.binding("util"); - } catch (e) { + } catch (e2) { } }(); var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; @@ -9484,9 +12992,9 @@ lodash_isequal.exports; } return false; } - function baseTimes(n3, iteratee) { - var index = -1, result = Array(n3); - while (++index < n3) { + function baseTimes(n4, iteratee) { + var index = -1, result = Array(n4); + while (++index < n4) { result[index] = iteratee(index); } return result; @@ -9722,7 +13230,7 @@ lodash_isequal.exports; function arrayLikeKeys(value, inherited) { var isArr = isArray2(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray2(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. + if (hasOwnProperty.call(value, key) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. @@ -9961,7 +13469,7 @@ lodash_isequal.exports; try { value[symToStringTag] = void 0; var unmasked = true; - } catch (e) { + } catch (e2) { } var result = nativeObjectToString.call(value); if (unmasked) { @@ -10025,11 +13533,11 @@ lodash_isequal.exports; if (func != null) { try { return funcToString.call(func); - } catch (e) { + } catch (e2) { } try { return func + ""; - } catch (e) { + } catch (e2) { } } return ""; @@ -10080,9 +13588,9 @@ lodash_isequal.exports; module2.exports = isEqual; })(lodash_isequal, lodash_isequal.exports); var lodash_isequalExports = lodash_isequal.exports; -const Gi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); -function unfetch_module(e, n3) { - return n3 = n3 || {}, new Promise(function(t2, r2) { +const Yi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); +function unfetch_module(e2, n4) { + return n4 = n4 || {}, new Promise(function(t2, r3) { var s2 = new XMLHttpRequest(), o2 = [], u3 = [], i2 = {}, a3 = function() { return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() { return Promise.resolve(s2.responseText); @@ -10094,19 +13602,19 @@ function unfetch_module(e, n3) { return o2; }, entries: function() { return u3; - }, get: function(e2) { - return i2[e2.toLowerCase()]; - }, has: function(e2) { - return e2.toLowerCase() in i2; + }, get: function(e3) { + return i2[e3.toLowerCase()]; + }, has: function(e3) { + return e3.toLowerCase() in i2; } } }; }; - for (var l2 in s2.open(n3.method || "get", e, true), s2.onload = function() { - s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e2, n4, t3) { - o2.push(n4 = n4.toLowerCase()), u3.push([n4, t3]), i2[n4] = i2[n4] ? i2[n4] + "," + t3 : t3; + for (var l2 in s2.open(n4.method || "get", e2, true), s2.onload = function() { + s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e3, n5, t3) { + o2.push(n5 = n5.toLowerCase()), u3.push([n5, t3]), i2[n5] = i2[n5] ? i2[n5] + "," + t3 : t3; }), t2(a3()); - }, s2.onerror = r2, s2.withCredentials = "include" == n3.credentials, n3.headers) - s2.setRequestHeader(l2, n3.headers[l2]); - s2.send(n3.body || null); + }, s2.onerror = r3, s2.withCredentials = "include" == n4.credentials, n4.headers) + s2.setRequestHeader(l2, n4.headers[l2]); + s2.send(n4.body || null); }); } const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ @@ -10115,289 +13623,289 @@ const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de }, Symbol.toStringTag, { value: "Module" })); const require$$0 = /* @__PURE__ */ getAugmentedNamespace(unfetch_module$1); var browser$2 = fetch || (self.fetch = require$$0.default || require$$0); -const Yi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); -function Hi(n3, e) { - if (n3.length >= 255) +const Hi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); +function Ji(n4, e2) { + if (n4.length >= 255) throw new TypeError("Alphabet too long"); for (var t2 = new Uint8Array(256), i2 = 0; i2 < t2.length; i2++) t2[i2] = 255; - for (var s2 = 0; s2 < n3.length; s2++) { - var r2 = n3.charAt(s2), o2 = r2.charCodeAt(0); + for (var s2 = 0; s2 < n4.length; s2++) { + var r3 = n4.charAt(s2), o2 = r3.charCodeAt(0); if (t2[o2] !== 255) - throw new TypeError(r2 + " is ambiguous"); + throw new TypeError(r3 + " is ambiguous"); t2[o2] = s2; } - var a3 = n3.length, h4 = n3.charAt(0), l2 = Math.log(a3) / Math.log(256), d3 = Math.log(256) / Math.log(a3); - function p3(u3) { + var a3 = n4.length, h4 = n4.charAt(0), l2 = Math.log(a3) / Math.log(256), d5 = Math.log(256) / Math.log(a3); + function g3(u3) { if (u3 instanceof Uint8Array || (ArrayBuffer.isView(u3) ? u3 = new Uint8Array(u3.buffer, u3.byteOffset, u3.byteLength) : Array.isArray(u3) && (u3 = Uint8Array.from(u3))), !(u3 instanceof Uint8Array)) throw new TypeError("Expected Uint8Array"); if (u3.length === 0) return ""; - for (var m2 = 0, z32 = 0, I2 = 0, _3 = u3.length; I2 !== _3 && u3[I2] === 0; ) - I2++, m2++; - for (var T2 = (_3 - I2) * d3 + 1 >>> 0, f2 = new Uint8Array(T2); I2 !== _3; ) { - for (var S2 = u3[I2], A2 = 0, C2 = T2 - 1; (S2 !== 0 || A2 < z32) && C2 !== -1; C2--, A2++) - S2 += 256 * f2[C2] >>> 0, f2[C2] = S2 % a3 >>> 0, S2 = S2 / a3 >>> 0; - if (S2 !== 0) + for (var p2 = 0, _3 = 0, D2 = 0, P2 = u3.length; D2 !== P2 && u3[D2] === 0; ) + D2++, p2++; + for (var x2 = (P2 - D2) * d5 + 1 >>> 0, E2 = new Uint8Array(x2); D2 !== P2; ) { + for (var O3 = u3[D2], N2 = 0, R2 = x2 - 1; (O3 !== 0 || N2 < _3) && R2 !== -1; R2--, N2++) + O3 += 256 * E2[R2] >>> 0, E2[R2] = O3 % a3 >>> 0, O3 = O3 / a3 >>> 0; + if (O3 !== 0) throw new Error("Non-zero carry"); - z32 = A2, I2++; + _3 = N2, D2++; } - for (var x2 = T2 - z32; x2 !== T2 && f2[x2] === 0; ) - x2++; - for (var j2 = h4.repeat(m2); x2 < T2; ++x2) - j2 += n3.charAt(f2[x2]); + for (var A2 = x2 - _3; A2 !== x2 && E2[A2] === 0; ) + A2++; + for (var j2 = h4.repeat(p2); A2 < x2; ++A2) + j2 += n4.charAt(E2[A2]); return j2; } - function y3(u3) { + function m3(u3) { if (typeof u3 != "string") throw new TypeError("Expected String"); if (u3.length === 0) return new Uint8Array(); - var m2 = 0; - if (u3[m2] !== " ") { - for (var z32 = 0, I2 = 0; u3[m2] === h4; ) - z32++, m2++; - for (var _3 = (u3.length - m2) * l2 + 1 >>> 0, T2 = new Uint8Array(_3); u3[m2]; ) { - var f2 = t2[u3.charCodeAt(m2)]; - if (f2 === 255) + var p2 = 0; + if (u3[p2] !== " ") { + for (var _3 = 0, D2 = 0; u3[p2] === h4; ) + _3++, p2++; + for (var P2 = (u3.length - p2) * l2 + 1 >>> 0, x2 = new Uint8Array(P2); u3[p2]; ) { + var E2 = t2[u3.charCodeAt(p2)]; + if (E2 === 255) return; - for (var S2 = 0, A2 = _3 - 1; (f2 !== 0 || S2 < I2) && A2 !== -1; A2--, S2++) - f2 += a3 * T2[A2] >>> 0, T2[A2] = f2 % 256 >>> 0, f2 = f2 / 256 >>> 0; - if (f2 !== 0) + for (var O3 = 0, N2 = P2 - 1; (E2 !== 0 || O3 < D2) && N2 !== -1; N2--, O3++) + E2 += a3 * x2[N2] >>> 0, x2[N2] = E2 % 256 >>> 0, E2 = E2 / 256 >>> 0; + if (E2 !== 0) throw new Error("Non-zero carry"); - I2 = S2, m2++; + D2 = O3, p2++; } - if (u3[m2] !== " ") { - for (var C2 = _3 - I2; C2 !== _3 && T2[C2] === 0; ) - C2++; - for (var x2 = new Uint8Array(z32 + (_3 - C2)), j2 = z32; C2 !== _3; ) - x2[j2++] = T2[C2++]; - return x2; + if (u3[p2] !== " ") { + for (var R2 = P2 - D2; R2 !== P2 && x2[R2] === 0; ) + R2++; + for (var A2 = new Uint8Array(_3 + (P2 - R2)), j2 = _3; R2 !== P2; ) + A2[j2++] = x2[R2++]; + return A2; } } } - function M2(u3) { - var m2 = y3(u3); - if (m2) - return m2; - throw new Error(`Non-${e} character`); + function L4(u3) { + var p2 = m3(u3); + if (p2) + return p2; + throw new Error(`Non-${e2} character`); } - return { encode: p3, decodeUnsafe: y3, decode: M2 }; + return { encode: g3, decodeUnsafe: m3, decode: L4 }; } -var Ji = Hi, Xi = Ji; -const Ne = (n3) => { - if (n3 instanceof Uint8Array && n3.constructor.name === "Uint8Array") - return n3; - if (n3 instanceof ArrayBuffer) - return new Uint8Array(n3); - if (ArrayBuffer.isView(n3)) - return new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength); +var Xi = Ji, Wi = Xi; +const Ue$1 = (n4) => { + if (n4 instanceof Uint8Array && n4.constructor.name === "Uint8Array") + return n4; + if (n4 instanceof ArrayBuffer) + return new Uint8Array(n4); + if (ArrayBuffer.isView(n4)) + return new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength); throw new Error("Unknown type, must be binary type"); -}, Wi = (n3) => new TextEncoder().encode(n3), Qi = (n3) => new TextDecoder().decode(n3); -class Zi { - constructor(e, t2, i2) { - this.name = e, this.prefix = t2, this.baseEncode = i2; - } - encode(e) { - if (e instanceof Uint8Array) - return `${this.prefix}${this.baseEncode(e)}`; +}, Qi = (n4) => new TextEncoder().encode(n4), Zi = (n4) => new TextDecoder().decode(n4); +let es$1 = class es { + constructor(e2, t2, i2) { + this.name = e2, this.prefix = t2, this.baseEncode = i2; + } + encode(e2) { + if (e2 instanceof Uint8Array) + return `${this.prefix}${this.baseEncode(e2)}`; throw Error("Unknown type, must be binary type"); } -} -class es { - constructor(e, t2, i2) { - if (this.name = e, this.prefix = t2, t2.codePointAt(0) === void 0) +}; +let ts$1 = class ts { + constructor(e2, t2, i2) { + if (this.name = e2, this.prefix = t2, t2.codePointAt(0) === void 0) throw new Error("Invalid prefix character"); this.prefixCodePoint = t2.codePointAt(0), this.baseDecode = i2; } - 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)); + decode(e2) { + if (typeof e2 == "string") { + if (e2.codePointAt(0) !== this.prefixCodePoint) + throw Error(`Unable to decode multibase string ${JSON.stringify(e2)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); + return this.baseDecode(e2.slice(this.prefix.length)); } else throw Error("Can only multibase decode strings"); } - or(e) { - return Ue(this, e); + or(e2) { + return $e(this, e2); } -} -class ts { - constructor(e) { - this.decoders = e; +}; +let is$1 = class is { + constructor(e2) { + this.decoders = e2; } - or(e) { - return Ue(this, e); + or(e2) { + return $e(this, e2); } - decode(e) { - const t2 = e[0], i2 = this.decoders[t2]; + decode(e2) { + const t2 = e2[0], i2 = this.decoders[t2]; if (i2) - return i2.decode(e); - throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + return i2.decode(e2); + throw RangeError(`Unable to decode multibase string ${JSON.stringify(e2)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); } -} -const Ue = (n3, e) => new ts({ ...n3.decoders || { [n3.prefix]: n3 }, ...e.decoders || { [e.prefix]: e } }); -class is { - constructor(e, t2, i2, s2) { - this.name = e, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new Zi(e, t2, i2), this.decoder = new es(e, t2, s2); +}; +const $e = (n4, e2) => new is$1({ ...n4.decoders || { [n4.prefix]: n4 }, ...e2.decoders || { [e2.prefix]: e2 } }); +let ss$2 = class ss { + constructor(e2, t2, i2, s2) { + this.name = e2, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new es$1(e2, t2, i2), this.decoder = new ts$1(e2, t2, s2); } - encode(e) { - return this.encoder.encode(e); + encode(e2) { + return this.encoder.encode(e2); } - decode(e) { - return this.decoder.decode(e); + decode(e2) { + return this.decoder.decode(e2); } -} -const W$1 = ({ name: n3, prefix: e, encode: t2, decode: i2 }) => new is(n3, e, t2, i2), B = ({ prefix: n3, name: e, alphabet: t2 }) => { - const { encode: i2, decode: s2 } = Xi(t2, e); - return W$1({ prefix: n3, name: e, encode: i2, decode: (r2) => Ne(s2(r2)) }); -}, ss = (n3, e, t2, i2) => { +}; +const Q$1 = ({ name: n4, prefix: e2, encode: t2, decode: i2 }) => new ss$2(n4, e2, t2, i2), K$1 = ({ prefix: n4, name: e2, alphabet: t2 }) => { + const { encode: i2, decode: s2 } = Wi(t2, e2); + return Q$1({ prefix: n4, name: e2, encode: i2, decode: (r3) => Ue$1(s2(r3)) }); +}, rs$1 = (n4, e2, t2, i2) => { const s2 = {}; - for (let d3 = 0; d3 < e.length; ++d3) - s2[e[d3]] = d3; - let r2 = n3.length; - for (; n3[r2 - 1] === "="; ) - --r2; - const o2 = new Uint8Array(r2 * t2 / 8 | 0); + for (let d5 = 0; d5 < e2.length; ++d5) + s2[e2[d5]] = d5; + let r3 = n4.length; + for (; n4[r3 - 1] === "="; ) + --r3; + const o2 = new Uint8Array(r3 * t2 / 8 | 0); let a3 = 0, h4 = 0, l2 = 0; - for (let d3 = 0; d3 < r2; ++d3) { - const p3 = s2[n3[d3]]; - if (p3 === void 0) + for (let d5 = 0; d5 < r3; ++d5) { + const g3 = s2[n4[d5]]; + if (g3 === void 0) throw new SyntaxError(`Non-${i2} character`); - h4 = h4 << t2 | p3, a3 += t2, a3 >= 8 && (a3 -= 8, o2[l2++] = 255 & h4 >> a3); + h4 = h4 << t2 | g3, a3 += t2, a3 >= 8 && (a3 -= 8, o2[l2++] = 255 & h4 >> a3); } if (a3 >= t2 || 255 & h4 << 8 - a3) throw new SyntaxError("Unexpected end of data"); return o2; -}, rs = (n3, e, t2) => { - const i2 = e[e.length - 1] === "=", s2 = (1 << t2) - 1; - let r2 = "", o2 = 0, a3 = 0; - for (let h4 = 0; h4 < n3.length; ++h4) - for (a3 = a3 << 8 | n3[h4], o2 += 8; o2 > t2; ) - o2 -= t2, r2 += e[s2 & a3 >> o2]; - if (o2 && (r2 += e[s2 & a3 << t2 - o2]), i2) - for (; r2.length * t2 & 7; ) - r2 += "="; - return r2; -}, g$2 = ({ name: n3, prefix: e, bitsPerChar: t2, alphabet: i2 }) => W$1({ prefix: e, name: n3, encode(s2) { - return rs(s2, i2, t2); +}, ns = (n4, e2, t2) => { + const i2 = e2[e2.length - 1] === "=", s2 = (1 << t2) - 1; + let r3 = "", o2 = 0, a3 = 0; + for (let h4 = 0; h4 < n4.length; ++h4) + for (a3 = a3 << 8 | n4[h4], o2 += 8; o2 > t2; ) + o2 -= t2, r3 += e2[s2 & a3 >> o2]; + if (o2 && (r3 += e2[s2 & a3 << t2 - o2]), i2) + for (; r3.length * t2 & 7; ) + r3 += "="; + return r3; +}, y2 = ({ name: n4, prefix: e2, bitsPerChar: t2, alphabet: i2 }) => Q$1({ prefix: e2, name: n4, encode(s2) { + return ns(s2, i2, t2); }, decode(s2) { - return ss(s2, i2, t2, n3); -} }), ns = W$1({ prefix: "\0", name: "identity", encode: (n3) => Qi(n3), decode: (n3) => Wi(n3) }); -var os = Object.freeze({ __proto__: null, identity: ns }); -const as$1 = g$2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); -var hs$1 = Object.freeze({ __proto__: null, base2: as$1 }); -const cs$1 = g$2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); -var us$1 = Object.freeze({ __proto__: null, base8: cs$1 }); -const ls$1 = B({ prefix: "9", name: "base10", alphabet: "0123456789" }); -var ds$1 = Object.freeze({ __proto__: null, base10: ls$1 }); -const gs$1 = g$2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), ps$1 = g$2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); -var Ds = Object.freeze({ __proto__: null, base16: gs$1, base16upper: ps$1 }); -const ys = g$2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), ms$1 = g$2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), bs = g$2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), fs = g$2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), Es = g$2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), ws = g$2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), vs = g$2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Is = g$2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), Cs = g$2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); -var Rs = Object.freeze({ __proto__: null, base32: ys, base32upper: ms$1, base32pad: bs, base32padupper: fs, base32hex: Es, base32hexupper: ws, base32hexpad: vs, base32hexpadupper: Is, base32z: Cs }); -const _s = B({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ts = B({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); -var Ss = Object.freeze({ __proto__: null, base36: _s, base36upper: Ts }); -const Ps = B({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), xs = B({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); -var Os = Object.freeze({ __proto__: null, base58btc: Ps, base58flickr: xs }); -const As = g$2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), zs = g$2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ns = g$2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us = g$2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); -var Ls = Object.freeze({ __proto__: null, base64: As, base64pad: zs, base64url: Ns, base64urlpad: Us }); -const Le = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), $s = Le.reduce((n3, e, t2) => (n3[t2] = e, n3), []), Fs = Le.reduce((n3, e, t2) => (n3[e.codePointAt(0)] = t2, n3), []); -function Ms(n3) { - return n3.reduce((e, t2) => (e += $s[t2], e), ""); -} -function ks(n3) { - const e = []; - for (const t2 of n3) { - const i2 = Fs[t2.codePointAt(0)]; + return rs$1(s2, i2, t2, n4); +} }), os$1 = Q$1({ prefix: "\0", name: "identity", encode: (n4) => Zi(n4), decode: (n4) => Qi(n4) }); +var as$1 = Object.freeze({ __proto__: null, identity: os$1 }); +const hs$1 = y2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); +var cs$1 = Object.freeze({ __proto__: null, base2: hs$1 }); +const ls$1 = y2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); +var us$1 = Object.freeze({ __proto__: null, base8: ls$1 }); +const ds$1 = K$1({ prefix: "9", name: "base10", alphabet: "0123456789" }); +var gs$1 = Object.freeze({ __proto__: null, base10: ds$1 }); +const ps$1 = y2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), Ds$1 = y2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); +var ys$1 = Object.freeze({ __proto__: null, base16: ps$1, base16upper: Ds$1 }); +const ms$2 = y2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), bs$1 = y2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), fs = y2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), Es$1 = y2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), ws$1 = y2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), vs$1 = y2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), Is$1 = y2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Cs$1 = y2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), _s$1 = y2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); +var Rs$1 = Object.freeze({ __proto__: null, base32: ms$2, base32upper: bs$1, base32pad: fs, base32padupper: Es$1, base32hex: ws$1, base32hexupper: vs$1, base32hexpad: Is$1, base32hexpadupper: Cs$1, base32z: _s$1 }); +const Ts$1 = K$1({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ss$1 = K$1({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); +var Ps$1 = Object.freeze({ __proto__: null, base36: Ts$1, base36upper: Ss$1 }); +const xs$1 = K$1({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), Os$1 = K$1({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); +var As$1 = Object.freeze({ __proto__: null, base58btc: xs$1, base58flickr: Os$1 }); +const zs$1 = y2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), Ns$1 = y2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ls$1 = y2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us$1 = y2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); +var $s$1 = Object.freeze({ __proto__: null, base64: zs$1, base64pad: Ns$1, base64url: Ls$1, base64urlpad: Us$1 }); +const Fe$1 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), Fs$1 = Fe$1.reduce((n4, e2, t2) => (n4[t2] = e2, n4), []), ks$1 = Fe$1.reduce((n4, e2, t2) => (n4[e2.codePointAt(0)] = t2, n4), []); +function Bs$1(n4) { + return n4.reduce((e2, t2) => (e2 += Fs$1[t2], e2), ""); +} +function Ms$1(n4) { + const e2 = []; + for (const t2 of n4) { + const i2 = ks$1[t2.codePointAt(0)]; if (i2 === void 0) throw new Error(`Non-base256emoji character: ${t2}`); - e.push(i2); - } - return new Uint8Array(e); -} -const Ks = W$1({ prefix: "🚀", name: "base256emoji", encode: Ms, decode: ks }); -var Bs = Object.freeze({ __proto__: null, base256emoji: Ks }), Vs = Fe, $e = 128, qs = 127, js = ~qs, Gs = Math.pow(2, 31); -function Fe(n3, e, t2) { - e = e || [], t2 = t2 || 0; - for (var i2 = t2; n3 >= Gs; ) - e[t2++] = n3 & 255 | $e, n3 /= 128; - for (; n3 & js; ) - e[t2++] = n3 & 255 | $e, n3 >>>= 7; - return e[t2] = n3 | 0, Fe.bytes = t2 - i2 + 1, e; -} -var Ys = he$1, Hs = 128, Me = 127; -function he$1(n3, i2) { - var t2 = 0, i2 = i2 || 0, s2 = 0, r2 = i2, o2, a3 = n3.length; + e2.push(i2); + } + return new Uint8Array(e2); +} +const Ks$1 = Q$1({ prefix: "🚀", name: "base256emoji", encode: Bs$1, decode: Ms$1 }); +var Vs$1 = Object.freeze({ __proto__: null, base256emoji: Ks$1 }), qs$1 = Be$2, ke$1 = 128, js$1 = 127, Gs$1 = ~js$1, Ys$1 = Math.pow(2, 31); +function Be$2(n4, e2, t2) { + e2 = e2 || [], t2 = t2 || 0; + for (var i2 = t2; n4 >= Ys$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 /= 128; + for (; n4 & Gs$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 >>>= 7; + return e2[t2] = n4 | 0, Be$2.bytes = t2 - i2 + 1, e2; +} +var Hs$1 = de$1, Js$1 = 128, Me = 127; +function de$1(n4, i2) { + var t2 = 0, i2 = i2 || 0, s2 = 0, r3 = i2, o2, a3 = n4.length; do { - if (r2 >= a3) - throw he$1.bytes = 0, new RangeError("Could not decode varint"); - o2 = n3[r2++], t2 += s2 < 28 ? (o2 & Me) << s2 : (o2 & Me) * Math.pow(2, s2), s2 += 7; - } while (o2 >= Hs); - return he$1.bytes = r2 - i2, t2; -} -var Js = Math.pow(2, 7), Xs = Math.pow(2, 14), Ws = Math.pow(2, 21), Qs = Math.pow(2, 28), Zs = Math.pow(2, 35), er = Math.pow(2, 42), tr = Math.pow(2, 49), ir = Math.pow(2, 56), sr2 = Math.pow(2, 63), rr = function(n3) { - return n3 < Js ? 1 : n3 < Xs ? 2 : n3 < Ws ? 3 : n3 < Qs ? 4 : n3 < Zs ? 5 : n3 < er ? 6 : n3 < tr ? 7 : n3 < ir ? 8 : n3 < sr2 ? 9 : 10; -}, nr = { encode: Vs, decode: Ys, encodingLength: rr }, ke = nr; -const Ke = (n3, e, t2 = 0) => (ke.encode(n3, e, t2), e), Be = (n3) => ke.encodingLength(n3), ce$1 = (n3, e) => { - const t2 = e.byteLength, i2 = Be(n3), s2 = i2 + Be(t2), r2 = new Uint8Array(s2 + t2); - return Ke(n3, r2, 0), Ke(t2, r2, i2), r2.set(e, s2), new or(n3, t2, e, r2); -}; -class or { - constructor(e, t2, i2, s2) { - this.code = e, this.size = t2, this.digest = i2, this.bytes = s2; - } -} -const Ve = ({ name: n3, code: e, encode: t2 }) => new ar(n3, e, t2); -class ar { - constructor(e, t2, i2) { - this.name = e, this.code = t2, this.encode = i2; - } - digest(e) { - if (e instanceof Uint8Array) { - const t2 = this.encode(e); - return t2 instanceof Uint8Array ? ce$1(this.code, t2) : t2.then((i2) => ce$1(this.code, i2)); + if (r3 >= a3) + throw de$1.bytes = 0, new RangeError("Could not decode varint"); + o2 = n4[r3++], t2 += s2 < 28 ? (o2 & Me) << s2 : (o2 & Me) * Math.pow(2, s2), s2 += 7; + } while (o2 >= Js$1); + return de$1.bytes = r3 - i2, t2; +} +var Xs$1 = Math.pow(2, 7), Ws$1 = Math.pow(2, 14), Qs$1 = Math.pow(2, 21), Zs$1 = Math.pow(2, 28), er = Math.pow(2, 35), tr$1 = Math.pow(2, 42), ir$1 = Math.pow(2, 49), sr$1 = Math.pow(2, 56), rr$1 = Math.pow(2, 63), nr$1 = function(n4) { + return n4 < Xs$1 ? 1 : n4 < Ws$1 ? 2 : n4 < Qs$1 ? 3 : n4 < Zs$1 ? 4 : n4 < er ? 5 : n4 < tr$1 ? 6 : n4 < ir$1 ? 7 : n4 < sr$1 ? 8 : n4 < rr$1 ? 9 : 10; +}, or$1 = { encode: qs$1, decode: Hs$1, encodingLength: nr$1 }, Ke$1 = or$1; +const Ve = (n4, e2, t2 = 0) => (Ke$1.encode(n4, e2, t2), e2), qe = (n4) => Ke$1.encodingLength(n4), ge = (n4, e2) => { + const t2 = e2.byteLength, i2 = qe(n4), s2 = i2 + qe(t2), r3 = new Uint8Array(s2 + t2); + return Ve(n4, r3, 0), Ve(t2, r3, i2), r3.set(e2, s2), new ar$1(n4, t2, e2, r3); +}; +let ar$1 = class ar { + constructor(e2, t2, i2, s2) { + this.code = e2, this.size = t2, this.digest = i2, this.bytes = s2; + } +}; +const je$1 = ({ name: n4, code: e2, encode: t2 }) => new hr$1(n4, e2, t2); +let hr$1 = class hr { + constructor(e2, t2, i2) { + this.name = e2, this.code = t2, this.encode = i2; + } + digest(e2) { + if (e2 instanceof Uint8Array) { + const t2 = this.encode(e2); + return t2 instanceof Uint8Array ? ge(this.code, t2) : t2.then((i2) => ge(this.code, i2)); } else throw Error("Unknown type, must be binary type"); } -} -const qe = (n3) => async (e) => new Uint8Array(await crypto.subtle.digest(n3, e)), hr = Ve({ name: "sha2-256", code: 18, encode: qe("SHA-256") }), cr = Ve({ name: "sha2-512", code: 19, encode: qe("SHA-512") }); -var ur = Object.freeze({ __proto__: null, sha256: hr, sha512: cr }); -const je = 0, lr = "identity", Ge = Ne, dr = (n3) => ce$1(je, Ge(n3)), gr = { code: je, name: lr, encode: Ge, digest: dr }; -var pr = Object.freeze({ __proto__: null, identity: gr }); +}; +const Ge$1 = (n4) => async (e2) => new Uint8Array(await crypto.subtle.digest(n4, e2)), cr$1 = je$1({ name: "sha2-256", code: 18, encode: Ge$1("SHA-256") }), lr = je$1({ name: "sha2-512", code: 19, encode: Ge$1("SHA-512") }); +var ur$1 = Object.freeze({ __proto__: null, sha256: cr$1, sha512: lr }); +const Ye$1 = 0, dr$1 = "identity", He$1 = Ue$1, gr$1 = (n4) => ge(Ye$1, He$1(n4)), pr = { code: Ye$1, name: dr$1, encode: He$1, digest: gr$1 }; +var Dr$1 = Object.freeze({ __proto__: null, identity: pr }); new TextEncoder(), new TextDecoder(); -const Ye = { ...os, ...hs$1, ...us$1, ...ds$1, ...Ds, ...Rs, ...Ss, ...Os, ...Ls, ...Bs }; -({ ...ur, ...pr }); -function He(n3) { - return globalThis.Buffer != null ? new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength) : n3; -} -function Dr(n3 = 0) { - return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? He(globalThis.Buffer.allocUnsafe(n3)) : new Uint8Array(n3); -} -function Je(n3, e, t2, i2) { - return { name: n3, prefix: e, encoder: { name: n3, prefix: e, encode: t2 }, decoder: { decode: i2 } }; -} -const Xe = Je("utf8", "u", (n3) => "u" + new TextDecoder("utf8").decode(n3), (n3) => new TextEncoder().encode(n3.substring(1))), ue$1 = Je("ascii", "a", (n3) => { - let e = "a"; - for (let t2 = 0; t2 < n3.length; t2++) - e += String.fromCharCode(n3[t2]); - return e; -}, (n3) => { - n3 = n3.substring(1); - const e = Dr(n3.length); - for (let t2 = 0; t2 < n3.length; t2++) - e[t2] = n3.charCodeAt(t2); - return e; -}), yr = { utf8: Xe, "utf-8": Xe, hex: Ye.base16, latin1: ue$1, ascii: ue$1, binary: ue$1, ...Ye }; -function mr(n3, e = "utf8") { - const t2 = yr[e]; +const Je$1 = { ...as$1, ...cs$1, ...us$1, ...gs$1, ...ys$1, ...Rs$1, ...Ps$1, ...As$1, ...$s$1, ...Vs$1 }; +({ ...ur$1, ...Dr$1 }); +function Xe$2(n4) { + return globalThis.Buffer != null ? new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength) : n4; +} +function yr$1(n4 = 0) { + return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? Xe$2(globalThis.Buffer.allocUnsafe(n4)) : new Uint8Array(n4); +} +function We$1(n4, e2, t2, i2) { + return { name: n4, prefix: e2, encoder: { name: n4, prefix: e2, encode: t2 }, decoder: { decode: i2 } }; +} +const Qe$1 = We$1("utf8", "u", (n4) => "u" + new TextDecoder("utf8").decode(n4), (n4) => new TextEncoder().encode(n4.substring(1))), pe$1 = We$1("ascii", "a", (n4) => { + let e2 = "a"; + for (let t2 = 0; t2 < n4.length; t2++) + e2 += String.fromCharCode(n4[t2]); + return e2; +}, (n4) => { + n4 = n4.substring(1); + const e2 = yr$1(n4.length); + for (let t2 = 0; t2 < n4.length; t2++) + e2[t2] = n4.charCodeAt(t2); + return e2; +}), mr$1 = { utf8: Qe$1, "utf-8": Qe$1, hex: Je$1.base16, latin1: pe$1, ascii: pe$1, binary: pe$1, ...Je$1 }; +function br(n4, e2 = "utf8") { + const t2 = mr$1[e2]; if (!t2) - throw new Error(`Unsupported encoding "${e}"`); - return (e === "utf8" || e === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? He(globalThis.Buffer.from(n3, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n3}`); + throw new Error(`Unsupported encoding "${e2}"`); + return (e2 === "utf8" || e2 === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? Xe$2(globalThis.Buffer.from(n4, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n4}`); } -const le$1 = "wc", We = 2, Q$1 = "core", O = `${le$1}@2:${Q$1}:`, Qe = { name: Q$1, logger: "error" }, Ze = { database: ":memory:" }, et = "crypto", de$1 = "client_ed25519_seed", tt = cjs$4.ONE_DAY, it = "keychain", st = "0.3", rt = "messages", nt = "0.3", ot = cjs$4.SIX_HOURS, at = "publisher", ht = "irn", ct = "error", ge$1 = "wss://relay.walletconnect.com", pe$1 = "wss://relay.walletconnect.org", ut = "relayer", D$1 = { 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" }, lt = "_subscription", P$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, dt = cjs$4.ONE_SECOND, gt = "2.11.2", pt = 1e4, Dt = "0.3", yt = "WALLETCONNECT_CLIENT_ID", w$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, mt = "subscription", bt = "0.3", ft = cjs$4.FIVE_SECONDS * 1e3, Et = "pairing", wt = "0.3", $ = { wc_pairingDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 } } }, V = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, R$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, vt = "history", It = "0.3", Ct = "expirer", v2 = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Rt = "0.3", Z = "verify-api", F$1 = "https://verify.walletconnect.com", ee = "https://verify.walletconnect.org", _t = [F$1, ee], Tt = "echo", St = "https://echo.walletconnect.com"; -class Pt { - constructor(e, t2) { - this.core = e, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = it, this.version = st, this.initialized = false, this.storagePrefix = O, this.init = async () => { +const De = "wc", Ze$1 = 2, Z = "core", z$1 = `${De}@2:${Z}:`, et = { name: Z, logger: "error" }, tt = { database: ":memory:" }, it = "crypto", ye$1 = "client_ed25519_seed", st = cjs$3.ONE_DAY, rt = "keychain", nt = "0.3", ot = "messages", at = "0.3", ht = cjs$3.SIX_HOURS, ct = "publisher", lt = "irn", ut = "error", me = "wss://relay.walletconnect.com", be$1 = "wss://relay.walletconnect.org", dt = "relayer", v2 = { 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" }, gt = "_subscription", f$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, pt = cjs$3.ONE_SECOND, Dt$1 = "2.12.2", yt = 1e4, mt = "0.3", bt = "WALLETCONNECT_CLIENT_ID", S$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, ft = "subscription", Et = "0.3", wt = cjs$3.FIVE_SECONDS * 1e3, vt = "pairing", It = "0.3", F$1 = { wc_pairingDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 } } }, V$1 = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, I$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, Ct = "history", _t = "0.3", Rt = "expirer", C = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Tt$1 = "0.3", ee = "verify-api", k$1 = "https://verify.walletconnect.com", te = "https://verify.walletconnect.org", St = [k$1, te], Pt = "echo", xt = "https://echo.walletconnect.com"; +let Ot$1 = class Ot { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = rt, this.version = nt, this.initialized = false, this.storagePrefix = z$1, this.init = async () => { if (!this.initialized) { const i2 = await this.getKeyChain(); typeof i2 < "u" && (this.keychain = i2), this.initialized = true; @@ -10408,126 +13916,126 @@ class Pt { this.isInitialized(); const s2 = this.keychain.get(i2); if (typeof s2 > "u") { - const { message: r2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${i2}`); - throw new Error(r2); + const { message: r3 } = xe("NO_MATCHING_KEY", `${this.name}: ${i2}`); + throw new Error(r3); } return s2; }, this.del = async (i2) => { this.isInitialized(), this.keychain.delete(i2), await this.persist(); - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.core = e2, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } - async setKeyChain(e) { - await this.core.storage.setItem(this.storageKey, rt$1(e)); + async setKeyChain(e2) { + await this.core.storage.setItem(this.storageKey, i0(e2)); } async getKeyChain() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? ot$1(e) : void 0; + const e2 = await this.core.storage.getItem(this.storageKey); + return typeof e2 < "u" ? n0(e2) : void 0; } async persist() { await this.setKeyChain(this.keychain); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } -} -class xt { - constructor(e, t2, i2) { - this.core = e, this.logger = t2, this.name = et, this.initialized = false, this.init = async () => { +}; +class At { + constructor(e2, t2, i2) { + this.core = e2, this.logger = t2, this.name = it, this.initialized = false, this.init = async () => { this.initialized || (await this.keychain.init(), this.initialized = true); }, this.hasKeys = (s2) => (this.isInitialized(), this.keychain.has(s2)), this.getClientId = async () => { this.isInitialized(); - const s2 = await this.getClientSeed(), r2 = generateKeyPair(s2); - return encodeIss(r2.publicKey); + const s2 = await this.getClientSeed(), r3 = generateKeyPair(s2); + return encodeIss(r3.publicKey); }, this.generateKeyPair = () => { this.isInitialized(); - const s2 = kn(); + const s2 = mu(); return this.setPrivateKey(s2.publicKey, s2.privateKey); }, this.signJWT = async (s2) => { this.isInitialized(); - const r2 = await this.getClientSeed(), o2 = generateKeyPair(r2), a3 = Vn(), h4 = tt; + const r3 = await this.getClientSeed(), o2 = generateKeyPair(r3), a3 = gu(), h4 = st; return await signJWT(a3, s2, h4, o2); - }, this.generateSharedKey = (s2, r2, o2) => { + }, this.generateSharedKey = (s2, r3, o2) => { this.isInitialized(); - const a3 = this.getPrivateKey(s2), h4 = Mn(a3, r2); + const a3 = this.getPrivateKey(s2), h4 = Au(a3, r3); return this.setSymKey(h4, o2); - }, this.setSymKey = async (s2, r2) => { + }, this.setSymKey = async (s2, r3) => { this.isInitialized(); - const o2 = r2 || Kn(s2); + const o2 = r3 || bu(s2); return await this.keychain.set(o2, s2), o2; }, this.deleteKeyPair = async (s2) => { this.isInitialized(), await this.keychain.del(s2); }, this.deleteSymKey = async (s2) => { this.isInitialized(), await this.keychain.del(s2); - }, this.encode = async (s2, r2, o2) => { + }, this.encode = async (s2, r3, o2) => { this.isInitialized(); - const a3 = Ae(o2), h4 = safeJsonStringify(r2); - if (qn(a3)) { - const y3 = a3.senderPublicKey, M2 = a3.receiverPublicKey; - s2 = await this.generateSharedKey(y3, M2); - } - const l2 = this.getSymKey(s2), { type: d3, senderPublicKey: p3 } = a3; - return xn({ type: d3, symKey: l2, message: h4, senderPublicKey: p3 }); - }, this.decode = async (s2, r2, o2) => { + const a3 = eo(o2), h4 = safeJsonStringify(r3); + if (Eu(a3)) { + const m3 = a3.senderPublicKey, L4 = a3.receiverPublicKey; + s2 = await this.generateSharedKey(m3, L4); + } + const l2 = this.getSymKey(s2), { type: d5, senderPublicKey: g3 } = a3; + return wu({ type: d5, symKey: l2, message: h4, senderPublicKey: g3 }); + }, this.decode = async (s2, r3, o2) => { this.isInitialized(); - const a3 = Hn(r2, o2); - if (qn(a3)) { + const a3 = Mu(r3, o2); + if (Eu(a3)) { const h4 = a3.receiverPublicKey, l2 = a3.senderPublicKey; s2 = await this.generateSharedKey(h4, l2); } try { - const h4 = this.getSymKey(s2), l2 = Fn({ symKey: h4, encoded: r2 }); + const h4 = this.getSymKey(s2), l2 = xu({ symKey: h4, encoded: r3 }); return safeJsonParse(l2); } catch (h4) { this.logger.error(`Failed to decode message from topic: '${s2}', clientId: '${await this.getClientId()}'`), this.logger.error(h4); } }, this.getPayloadType = (s2) => { - const r2 = ee$1(s2); - return j$1(r2.type); + const r3 = Xi$1(s2); + return Mr(r3.type); }, this.getPayloadSenderPublicKey = (s2) => { - const r2 = ee$1(s2); - return r2.senderPublicKey ? toString(r2.senderPublicKey, p$1) : void 0; - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.keychain = i2 || new Pt(this.core, this.logger); + const r3 = Xi$1(s2); + return r3.senderPublicKey ? toString(r3.senderPublicKey, zt$1) : void 0; + }, this.core = e2, this.logger = E$1(t2, this.name), this.keychain = i2 || new Ot$1(this.core, this.logger); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } - async setPrivateKey(e, t2) { - return await this.keychain.set(e, t2), e; + async setPrivateKey(e2, t2) { + return await this.keychain.set(e2, t2), e2; } - getPrivateKey(e) { - return this.keychain.get(e); + getPrivateKey(e2) { + return this.keychain.get(e2); } async getClientSeed() { - let e = ""; + let e2 = ""; try { - e = this.keychain.get(de$1); + e2 = this.keychain.get(ye$1); } catch { - e = Vn(), await this.keychain.set(de$1, e); + e2 = gu(), await this.keychain.set(ye$1, e2); } - return mr(e, "base16"); + return br(e2, "base16"); } - getSymKey(e) { - return this.keychain.get(e); + getSymKey(e2) { + return this.keychain.get(e2); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } } -class Ot extends a$2 { - constructor(e, t2) { - super(e, t2), this.logger = e, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = rt, this.version = nt, this.initialized = false, this.storagePrefix = O, this.init = async () => { +class zt extends a$1 { + constructor(e2, t2) { + super(e2, t2), this.logger = e2, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = ot, this.version = at, this.initialized = false, this.storagePrefix = z$1, this.init = async () => { if (!this.initialized) { this.logger.trace("Initialized"); try { @@ -10541,63 +14049,62 @@ class Ot extends a$2 { } }, this.set = async (i2, s2) => { this.isInitialized(); - const r2 = Ln(s2); + const r3 = yu(s2); let o2 = this.messages.get(i2); - return typeof o2 > "u" && (o2 = {}), typeof o2[r2] < "u" || (o2[r2] = s2, this.messages.set(i2, o2), await this.persist()), r2; + return typeof o2 > "u" && (o2 = {}), typeof o2[r3] < "u" || (o2[r3] = s2, this.messages.set(i2, o2), await this.persist()), r3; }, this.get = (i2) => { this.isInitialized(); let s2 = this.messages.get(i2); return typeof s2 > "u" && (s2 = {}), s2; }, this.has = (i2, s2) => { this.isInitialized(); - const r2 = this.get(i2), o2 = Ln(s2); - return typeof r2[o2] < "u"; + const r3 = this.get(i2), o2 = yu(s2); + return typeof r3[o2] < "u"; }, this.del = async (i2) => { this.isInitialized(), this.messages.delete(i2), await this.persist(); - }, this.logger = cjs$3.generateChildLogger(e, this.name), this.core = t2; + }, this.logger = E$1(e2, this.name), this.core = t2; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } - async setRelayerMessages(e) { - await this.core.storage.setItem(this.storageKey, rt$1(e)); + async setRelayerMessages(e2) { + await this.core.storage.setItem(this.storageKey, i0(e2)); } async getRelayerMessages() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? ot$1(e) : void 0; + const e2 = await this.core.storage.getItem(this.storageKey); + return typeof e2 < "u" ? n0(e2) : void 0; } async persist() { await this.setRelayerMessages(this.messages); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } } -class vr extends u$1 { - constructor(e, t2) { - super(e, t2), this.relayer = e, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = at, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$4.toMiliseconds(cjs$4.TEN_SECONDS * 2), this.needsTransportRestart = false, this.publish = async (i2, s2, r2) => { +class Ir extends u$1 { + constructor(e2, t2) { + super(e2, t2), this.relayer = e2, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = ct, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.failedPublishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_SECOND), this.needsTransportRestart = false, this.publish = async (i2, s2, r3) => { var o2; - this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); + this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r3 } }); + const a3 = (r3 == null ? void 0 : r3.ttl) || ht, h4 = Su(r3), l2 = (r3 == null ? void 0 : r3.prompt) || false, d5 = (r3 == null ? void 0 : r3.tag) || 0, g3 = (r3 == null ? void 0 : r3.id) || getBigIntRpcId().toString(), m3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d5, id: g3 } }, L4 = `Failed to publish payload, please try again. id:${g3} tag:${d5}`, u3 = Date.now(); + let p2, _3 = 1; try { - const a3 = (r2 == null ? void 0 : r2.ttl) || ot, h4 = vt$1(r2), l2 = (r2 == null ? void 0 : r2.prompt) || false, d3 = (r2 == null ? void 0 : r2.tag) || 0, p3 = (r2 == null ? void 0 : r2.id) || getBigIntRpcId().toString(), y3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d3, id: p3 } }, M2 = setTimeout(() => this.queue.set(p3, y3), this.publishTimeout); - try { - await await ut$1(this.rpcPublish(i2, s2, a3, h4, l2, d3, p3), this.publishTimeout, `Failed to publish payload, please try again. id:${p3} tag:${d3}`), this.removeRequestFromQueue(p3), this.relayer.events.emit(D$1.publish, y3); - } catch (u3) { - if (this.logger.debug("Publishing Payload stalled"), this.needsTransportRestart = true, (o2 = r2 == null ? void 0 : r2.internal) != null && o2.throwOnFailedPublish) - throw this.removeRequestFromQueue(p3), u3; - return; - } finally { - clearTimeout(M2); + for (; p2 === void 0; ) { + if (Date.now() - u3 > this.publishTimeout) + throw new Error(L4); + this.logger.trace({ id: g3, attempts: _3 }, `publisher.publish - attempt ${_3}`), p2 = await await u0(this.rpcPublish(i2, s2, a3, h4, l2, d5, g3).catch((D2) => this.logger.warn(D2)), this.publishTimeout, L4), _3++, p2 || await new Promise((D2) => setTimeout(D2, this.failedPublishTimeout)); } - this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); - } catch (a3) { - throw this.logger.debug("Failed to Publish Payload"), this.logger.error(a3), a3; + this.relayer.events.emit(v2.publish, m3), this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { id: g3, topic: i2, message: s2, opts: r3 } }); + } catch (D2) { + if (this.logger.debug("Failed to Publish Payload"), this.logger.error(D2), (o2 = r3 == null ? void 0 : r3.internal) != null && o2.throwOnFailedPublish) + throw D2; + this.queue.set(g3, m3); } }, this.on = (i2, s2) => { this.events.on(i2, s2); @@ -10607,58 +14114,58 @@ class vr extends u$1 { this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); - }, this.relayer = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.registerEventListeners(); + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.registerEventListeners(); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } - rpcPublish(e, t2, i2, s2, r2, o2, a3) { - var h4, l2, d3, p3; - const y3 = { method: Et$1(s2.protocol).publish, params: { topic: e, message: t2, ttl: i2, prompt: r2, tag: o2 }, id: a3 }; - return w$3((h4 = y3.params) == null ? void 0 : h4.prompt) && ((l2 = y3.params) == null || delete l2.prompt), w$3((d3 = y3.params) == null ? void 0 : d3.tag) && ((p3 = y3.params) == null || delete p3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: y3 }), this.relayer.request(y3); + rpcPublish(e2, t2, i2, s2, r3, o2, a3) { + var h4, l2, d5, g3; + const m3 = { method: Nu(s2.protocol).publish, params: { topic: e2, message: t2, ttl: i2, prompt: r3, tag: o2 }, id: a3 }; + return Pe((h4 = m3.params) == null ? void 0 : h4.prompt) && ((l2 = m3.params) == null || delete l2.prompt), Pe((d5 = m3.params) == null ? void 0 : d5.tag) && ((g3 = m3.params) == null || delete g3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: m3 }), this.relayer.request(m3); } - removeRequestFromQueue(e) { - this.queue.delete(e); + removeRequestFromQueue(e2) { + this.queue.delete(e2); } checkQueue() { - this.queue.forEach(async (e) => { - const { topic: t2, message: i2, opts: s2 } = e; + this.queue.forEach(async (e2) => { + const { topic: t2, message: i2, opts: s2 } = e2; await this.publish(t2, i2, s2); }); } registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { if (this.needsTransportRestart) { - this.needsTransportRestart = false, this.relayer.events.emit(D$1.connection_stalled); + this.needsTransportRestart = false, this.relayer.events.emit(v2.connection_stalled); return; } this.checkQueue(); - }), this.relayer.on(D$1.message_ack, (e) => { - this.removeRequestFromQueue(e.id.toString()); + }), this.relayer.on(v2.message_ack, (e2) => { + this.removeRequestFromQueue(e2.id.toString()); }); } } -class Ir { +let Cr$1 = class Cr { constructor() { - this.map = /* @__PURE__ */ new Map(), this.set = (e, t2) => { - const i2 = this.get(e); - this.exists(e, t2) || this.map.set(e, [...i2, t2]); - }, this.get = (e) => this.map.get(e) || [], this.exists = (e, t2) => this.get(e).includes(t2), this.delete = (e, t2) => { + this.map = /* @__PURE__ */ new Map(), this.set = (e2, t2) => { + const i2 = this.get(e2); + this.exists(e2, t2) || this.map.set(e2, [...i2, t2]); + }, this.get = (e2) => this.map.get(e2) || [], this.exists = (e2, t2) => this.get(e2).includes(t2), this.delete = (e2, t2) => { if (typeof t2 > "u") { - this.map.delete(e); + this.map.delete(e2); return; } - if (!this.map.has(e)) + if (!this.map.has(e2)) return; - const i2 = this.get(e); - if (!this.exists(e, t2)) + const i2 = this.get(e2); + if (!this.exists(e2, t2)) return; - const s2 = i2.filter((r2) => r2 !== t2); + const s2 = i2.filter((r3) => r3 !== t2); if (!s2.length) { - this.map.delete(e); + this.map.delete(e2); return; } - this.map.set(e, s2); + this.map.set(e2, s2); }, this.clear = () => { this.map.clear(); }; @@ -10666,28 +14173,28 @@ class Ir { get topics() { return Array.from(this.map.keys()); } -} -var Cr = Object.defineProperty, Rr = Object.defineProperties, _r = Object.getOwnPropertyDescriptors, At = Object.getOwnPropertySymbols, Tr = Object.prototype.hasOwnProperty, Sr = Object.prototype.propertyIsEnumerable, zt = (n3, e, t2) => e in n3 ? Cr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, q$1 = (n3, e) => { - for (var t2 in e || (e = {})) - Tr.call(e, t2) && zt(n3, t2, e[t2]); - if (At) - for (var t2 of At(e)) - Sr.call(e, t2) && zt(n3, t2, e[t2]); - return n3; -}, De = (n3, e) => Rr(n3, _r(e)); -class Nt extends d2 { - constructor(e, t2) { - super(e, t2), this.relayer = e, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Ir(), this.events = new eventsExports.EventEmitter(), this.name = mt, this.version = bt, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = O, this.subscribeTimeout = 1e4, this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { +}; +var _r = Object.defineProperty, Rr$1 = Object.defineProperties, Tr$1 = Object.getOwnPropertyDescriptors, Nt = Object.getOwnPropertySymbols, Sr = Object.prototype.hasOwnProperty, Pr$1 = Object.prototype.propertyIsEnumerable, Lt$1 = (n4, e2, t2) => e2 in n4 ? _r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, q$2 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Sr.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + if (Nt) + for (var t2 of Nt(e2)) + Pr$1.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + return n4; +}, fe$1 = (n4, e2) => Rr$1(n4, Tr$1(e2)); +let Ut$1 = class Ut2 extends d$1 { + constructor(e2, t2) { + super(e2, t2), this.relayer = e2, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Cr$1(), this.events = new eventsExports.EventEmitter(), this.name = ft, this.version = Et, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = z$1, this.subscribeTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), this.clientId = await this.relayer.core.crypto.getClientId()); }, this.subscribe = async (i2, s2) => { await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }); try { - const r2 = vt$1(s2), o2 = { topic: i2, relay: r2 }; + const r3 = Su(s2), o2 = { topic: i2, relay: r3 }; this.pending.set(i2, o2); - const a3 = await this.rpcSubscribe(i2, r2); - return this.onSubscribe(a3, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }), a3; - } catch (r2) { - throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r2), r2; + const a3 = await this.rpcSubscribe(i2, r3); + return typeof a3 == "string" && (this.onSubscribe(a3, o2), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } })), a3; + } catch (r3) { + throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r3), r3; } }, this.unsubscribe = async (i2, s2) => { await this.restartToComplete(), this.isInitialized(), typeof (s2 == null ? void 0 : s2.id) < "u" ? await this.unsubscribeById(i2, s2.id, s2) : await this.unsubscribeByTopic(i2, s2); @@ -10695,11 +14202,11 @@ class Nt extends d2 { if (this.topics.includes(i2)) return true; const s2 = `${this.pendingSubscriptionWatchLabel}_${i2}`; - return await new Promise((r2, o2) => { - const a3 = new cjs$4.Watch(); + return await new Promise((r3, o2) => { + const a3 = new cjs$3.Watch(); a3.start(s2); const h4 = setInterval(() => { - !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r2(true)), a3.elapsed(s2) >= ft && (clearInterval(h4), a3.stop(s2), o2(new Error("Subscription resolution timeout"))); + !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r3(true)), a3.elapsed(s2) >= wt && (clearInterval(h4), a3.stop(s2), o2(new Error("Subscription resolution timeout"))); }, this.pollingInterval); }).catch(() => false); }, this.on = (i2, s2) => { @@ -10710,12 +14217,16 @@ class Nt extends d2 { this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); + }, this.start = async () => { + await this.onConnect(); + }, this.stop = async () => { + await this.onDisconnect(); }, this.restart = async () => { this.restartInProgress = true, await this.restore(), await this.reset(), this.restartInProgress = false; - }, this.relayer = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.clientId = ""; + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.clientId = ""; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.relayer.core.customStoragePrefix + "//" + this.name; @@ -10732,10 +14243,10 @@ class Nt extends d2 { get topics() { return this.topicMap.topics; } - hasSubscription(e, t2) { + hasSubscription(e2, t2) { let i2 = false; try { - i2 = this.getSubscription(e).topic === t2; + i2 = this.getSubscription(e2).topic === t2; } catch { } return i2; @@ -10746,303 +14257,326 @@ class Nt extends d2 { onDisable() { this.cached = this.values, this.subscriptions.clear(), this.topicMap.clear(); } - async unsubscribeByTopic(e, t2) { - const i2 = this.topicMap.get(e); - await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e, s2, t2))); + async unsubscribeByTopic(e2, t2) { + const i2 = this.topicMap.get(e2); + await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e2, s2, t2))); } - async unsubscribeById(e, t2, i2) { - this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: t2, opts: i2 } }); + async unsubscribeById(e2, t2, i2) { + this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); try { - const s2 = vt$1(i2); - await this.rpcUnsubscribe(e, t2, s2); - const r2 = U$2("USER_DISCONNECTED", `${this.name}, ${e}`); - await this.onUnsubscribe(e, t2, r2), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: t2, opts: i2 } }); + const s2 = Su(i2); + await this.rpcUnsubscribe(e2, t2, s2); + const r3 = tr$2("USER_DISCONNECTED", `${this.name}, ${e2}`); + await this.onUnsubscribe(e2, t2, r3), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); } catch (s2) { throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s2), s2; } } - async rpcSubscribe(e, t2) { - const i2 = { method: Et$1(t2.protocol).subscribe, params: { topic: e } }; + async rpcSubscribe(e2, t2) { + const i2 = { method: Nu(t2.protocol).subscribe, params: { topic: e2 } }; this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); try { - await await ut$1(this.relayer.request(i2), this.subscribeTimeout); + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout) ? yu(e2 + this.clientId) : null; } catch { - this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(D$1.connection_stalled); + this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(v2.connection_stalled); } - return Ln(e + this.clientId); + return null; } - async rpcBatchSubscribe(e) { - if (!e.length) + async rpcBatchSubscribe(e2) { + if (!e2.length) return; - const t2 = e[0].relay, i2 = { method: Et$1(t2.protocol).batchSubscribe, params: { topics: e.map((s2) => s2.topic) } }; + const t2 = e2[0].relay, i2 = { method: Nu(t2.protocol).batchSubscribe, params: { topics: e2.map((s2) => s2.topic) } }; this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); try { - return await await ut$1(this.relayer.request(i2), this.subscribeTimeout); + return await await u0(this.relayer.request(i2).catch((s2) => this.logger.warn(s2)), this.subscribeTimeout); } catch { - this.logger.debug("Outgoing Relay Payload stalled"), this.relayer.events.emit(D$1.connection_stalled); + this.relayer.events.emit(v2.connection_stalled); } } - rpcUnsubscribe(e, t2, i2) { - const s2 = { method: Et$1(i2.protocol).unsubscribe, params: { topic: e, id: t2 } }; + rpcUnsubscribe(e2, t2, i2) { + const s2 = { method: Nu(i2.protocol).unsubscribe, params: { topic: e2, id: t2 } }; return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s2 }), this.relayer.request(s2); } - onSubscribe(e, t2) { - this.setSubscription(e, De(q$1({}, t2), { id: e })), this.pending.delete(t2.topic); + onSubscribe(e2, t2) { + this.setSubscription(e2, fe$1(q$2({}, t2), { id: e2 })), this.pending.delete(t2.topic); } - onBatchSubscribe(e) { - e.length && e.forEach((t2) => { - this.setSubscription(t2.id, q$1({}, t2)), this.pending.delete(t2.topic); + onBatchSubscribe(e2) { + e2.length && e2.forEach((t2) => { + this.setSubscription(t2.id, q$2({}, t2)), this.pending.delete(t2.topic); }); } - async onUnsubscribe(e, t2, i2) { - this.events.removeAllListeners(t2), this.hasSubscription(t2, e) && this.deleteSubscription(t2, i2), await this.relayer.messages.del(e); + async onUnsubscribe(e2, t2, i2) { + this.events.removeAllListeners(t2), this.hasSubscription(t2, e2) && this.deleteSubscription(t2, i2), await this.relayer.messages.del(e2); } - async setRelayerSubscriptions(e) { - await this.relayer.core.storage.setItem(this.storageKey, e); + async setRelayerSubscriptions(e2) { + await this.relayer.core.storage.setItem(this.storageKey, e2); } async getRelayerSubscriptions() { return await this.relayer.core.storage.getItem(this.storageKey); } - setSubscription(e, t2) { - this.subscriptions.has(e) || (this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e, subscription: t2 }), this.addSubscription(e, t2)); + setSubscription(e2, t2) { + this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e2, subscription: t2 }), this.addSubscription(e2, t2); } - addSubscription(e, t2) { - this.subscriptions.set(e, q$1({}, t2)), this.topicMap.set(t2.topic, e), this.events.emit(w$1.created, t2); + addSubscription(e2, t2) { + this.subscriptions.set(e2, q$2({}, t2)), this.topicMap.set(t2.topic, e2), this.events.emit(S$1.created, t2); } - getSubscription(e) { - this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e }); - const t2 = this.subscriptions.get(e); + getSubscription(e2) { + this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e2 }); + const t2 = this.subscriptions.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw new Error(i2); } return t2; } - deleteSubscription(e, t2) { - this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e, reason: t2 }); - const i2 = this.getSubscription(e); - this.subscriptions.delete(e), this.topicMap.delete(i2.topic, e), this.events.emit(w$1.deleted, De(q$1({}, i2), { reason: t2 })); + deleteSubscription(e2, t2) { + this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e2, reason: t2 }); + const i2 = this.getSubscription(e2); + this.subscriptions.delete(e2), this.topicMap.delete(i2.topic, e2), this.events.emit(S$1.deleted, fe$1(q$2({}, i2), { reason: t2 })); } async persist() { - await this.setRelayerSubscriptions(this.values), this.events.emit(w$1.sync); + await this.setRelayerSubscriptions(this.values), this.events.emit(S$1.sync); } async reset() { if (this.cached.length) { - const e = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); - for (let t2 = 0; t2 < e; t2++) { + const e2 = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); + for (let t2 = 0; t2 < e2; t2++) { const i2 = this.cached.splice(0, this.batchSubscribeTopicsLimit); await this.batchSubscribe(i2); } } - this.events.emit(w$1.resubscribed); + this.events.emit(S$1.resubscribed); } async restore() { try { - const e = await this.getRelayerSubscriptions(); - if (typeof e > "u" || !e.length) + const e2 = await this.getRelayerSubscriptions(); + if (typeof e2 > "u" || !e2.length) return; if (this.subscriptions.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); } - 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); + this.cached = e2, this.logger.debug(`Successfully Restored subscriptions for ${this.name}`), this.logger.trace({ type: "method", method: "restore", subscriptions: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore subscriptions for ${this.name}`), this.logger.error(e2); } } - async batchSubscribe(e) { - if (!e.length) + async batchSubscribe(e2) { + if (!e2.length) return; - const t2 = await this.rpcBatchSubscribe(e); - k(t2) && this.onBatchSubscribe(t2.map((i2, s2) => De(q$1({}, e[s2]), { id: i2 }))); + const t2 = await this.rpcBatchSubscribe(e2); + Er(t2) && this.onBatchSubscribe(t2.map((i2, s2) => fe$1(q$2({}, e2[s2]), { id: i2 }))); } async onConnect() { - this.restartInProgress || (await this.restart(), this.onEnable()); + await this.restart(), this.onEnable(); } onDisconnect() { this.onDisable(); } async checkPending() { - if (!this.initialized || this.relayer.transportExplicitlyClosed) + if (!this.initialized || !this.relayer.connected) return; - const e = []; + const e2 = []; this.pending.forEach((t2) => { - e.push(t2); - }), await this.batchSubscribe(e); + e2.push(t2); + }), await this.batchSubscribe(e2); } registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, async () => { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, async () => { await this.checkPending(); - }), this.relayer.on(D$1.connect, async () => { - await this.onConnect(); - }), this.relayer.on(D$1.disconnect, () => { - this.onDisconnect(); - }), this.events.on(w$1.created, async (e) => { - const t2 = w$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), await this.persist(); - }), this.events.on(w$1.deleted, async (e) => { - const t2 = w$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), await this.persist(); + }), this.events.on(S$1.created, async (e2) => { + const t2 = S$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); + }), this.events.on(S$1.deleted, async (e2) => { + const t2 = S$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); }); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } async restartToComplete() { - this.restartInProgress && await new Promise((e) => { + this.restartInProgress && await new Promise((e2) => { const t2 = setInterval(() => { - this.restartInProgress || (clearInterval(t2), e()); + this.restartInProgress || (clearInterval(t2), e2()); }, this.pollingInterval); }); } -} -var Pr = Object.defineProperty, Ut = Object.getOwnPropertySymbols, xr = Object.prototype.hasOwnProperty, Or = Object.prototype.propertyIsEnumerable, Lt = (n3, e, t2) => e in n3 ? Pr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, Ar = (n3, e) => { - for (var t2 in e || (e = {})) - xr.call(e, t2) && Lt(n3, t2, e[t2]); - if (Ut) - for (var t2 of Ut(e)) - Or.call(e, t2) && Lt(n3, t2, e[t2]); - return n3; }; -class $t extends g$4 { - constructor(e) { - super(e), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = ut, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.request = async (t2) => { +var xr$1 = Object.defineProperty, $t$1 = Object.getOwnPropertySymbols, Or$1 = Object.prototype.hasOwnProperty, Ar = Object.prototype.propertyIsEnumerable, Ft$1 = (n4, e2, t2) => e2 in n4 ? xr$1(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, zr$1 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Or$1.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + if ($t$1) + for (var t2 of $t$1(e2)) + Ar.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + return n4; +}; +let kt$1 = class kt extends g$1 { + constructor(e2) { + super(e2), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = dt, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled", "interrupted"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.heartBeatTimeout = cjs$3.toMiliseconds(cjs$3.THIRTY_SECONDS + cjs$3.ONE_SECOND), this.request = async (t2) => { + var i2, s2; this.logger.debug("Publishing Request Payload"); - const i2 = t2.id; + const r3 = t2.id || getBigIntRpcId().toString(); + await this.toEstablishConnection(); try { - await this.toEstablishConnection(); - const s2 = this.provider.request(t2); - return this.requestsInFlight.set(i2, { promise: s2, request: t2 }), await s2; - } catch (s2) { - throw this.logger.debug("Failed to Publish Request"), this.logger.error(s2), s2; + const o2 = this.provider.request(t2); + this.requestsInFlight.set(r3, { promise: o2, request: t2 }), this.logger.trace({ id: r3, method: t2.method, topic: (i2 = t2.params) == null ? void 0 : i2.topic }, "relayer.request - attempt to publish..."); + const a3 = await new Promise(async (h4, l2) => { + const d5 = () => { + l2(new Error(`relayer.request - publish interrupted, id: ${r3}`)); + }; + this.provider.on(f$1.disconnect, d5); + const g3 = await o2; + this.provider.off(f$1.disconnect, d5), h4(g3); + }); + return this.logger.trace({ id: r3, method: t2.method, topic: (s2 = t2.params) == null ? void 0 : s2.topic }, "relayer.request - published"), a3; + } catch (o2) { + throw this.logger.debug(`Failed to Publish Request: ${r3}`), o2; } finally { - this.requestsInFlight.delete(i2); + this.requestsInFlight.delete(r3); } + }, this.resetPingTimeout = () => { + if (pi()) + try { + clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => { + var t2, i2, s2; + (s2 = (i2 = (t2 = this.provider) == null ? void 0 : t2.connection) == null ? void 0 : i2.socket) == null || s2.terminate(); + }, this.heartBeatTimeout); + } catch (t2) { + this.logger.warn(t2); + } }, this.onPayloadHandler = (t2) => { - this.onProviderPayload(t2); + this.onProviderPayload(t2), this.resetPingTimeout(); }, this.onConnectHandler = () => { - this.events.emit(D$1.connect); + this.startPingTimeout(), this.events.emit(v2.connect); }, this.onDisconnectHandler = () => { this.onProviderDisconnect(); }, this.onProviderErrorHandler = (t2) => { - this.logger.error(t2), this.events.emit(D$1.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); + this.logger.error(t2), this.events.emit(v2.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); }, this.registerProviderListeners = () => { - this.provider.on(P$1.payload, this.onPayloadHandler), this.provider.on(P$1.connect, this.onConnectHandler), this.provider.on(P$1.disconnect, this.onDisconnectHandler), this.provider.on(P$1.error, this.onProviderErrorHandler); - }, this.core = e.core, this.logger = typeof e.logger < "u" && typeof e.logger != "string" ? cjs$3.generateChildLogger(e.logger, this.name) : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: e.logger || ct })), this.messages = new Ot(this.logger, e.core), this.subscriber = new Nt(this, this.logger), this.publisher = new vr(this, this.logger), this.relayUrl = (e == null ? void 0 : e.relayUrl) || ge$1, this.projectId = e.projectId, this.bundleId = Jn(), this.provider = {}; + this.provider.on(f$1.payload, this.onPayloadHandler), this.provider.on(f$1.connect, this.onConnectHandler), this.provider.on(f$1.disconnect, this.onDisconnectHandler), this.provider.on(f$1.error, this.onProviderErrorHandler); + }, this.core = e2.core, this.logger = typeof e2.logger < "u" && typeof e2.logger != "string" ? E$1(e2.logger, this.name) : nt$1(k$2({ level: e2.logger || ut })), this.messages = new zt(this.logger, e2.core), this.subscriber = new Ut$1(this, this.logger), this.publisher = new Ir(this, this.logger), this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me, this.projectId = e2.projectId, this.bundleId = Wo(), this.provider = {}; } async init() { this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); try { await this.transportOpen(); } catch { - this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$1}...`), await this.restartTransport(pe$1); + this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${be$1}...`), await this.restartTransport(be$1); } this.initialized = true, setTimeout(async () => { - this.subscriber.topics.length === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); - }, pt); + this.subscriber.topics.length === 0 && this.subscriber.pending.size === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); + }, yt); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get connected() { - return this.provider.connection.connected; + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 1; } get connecting() { - return this.provider.connection.connecting; + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 0; } - async publish(e, t2, i2) { - this.isInitialized(), await this.publisher.publish(e, t2, i2), await this.recordMessageEvent({ topic: e, message: t2, publishedAt: Date.now() }); + async publish(e2, t2, i2) { + this.isInitialized(), await this.publisher.publish(e2, t2, i2), await this.recordMessageEvent({ topic: e2, message: t2, publishedAt: Date.now() }); } - async subscribe(e, t2) { + async subscribe(e2, t2) { var i2; this.isInitialized(); - let s2 = ((i2 = this.subscriber.topicMap.get(e)) == null ? void 0 : i2[0]) || ""; - if (s2) - return s2; - let r2; + let s2 = ((i2 = this.subscriber.topicMap.get(e2)) == null ? void 0 : i2[0]) || "", r3; const o2 = (a3) => { - a3.topic === e && (this.subscriber.off(w$1.created, o2), r2()); + a3.topic === e2 && (this.subscriber.off(S$1.created, o2), r3()); }; return await Promise.all([new Promise((a3) => { - r2 = a3, this.subscriber.on(w$1.created, o2); + r3 = a3, this.subscriber.on(S$1.created, o2); }), new Promise(async (a3) => { - s2 = await this.subscriber.subscribe(e, t2), a3(); + s2 = await this.subscriber.subscribe(e2, t2) || s2, a3(); })]), s2; } - async unsubscribe(e, t2) { - this.isInitialized(), await this.subscriber.unsubscribe(e, t2); + async unsubscribe(e2, t2) { + this.isInitialized(), await this.subscriber.unsubscribe(e2, t2); } - on(e, t2) { - this.events.on(e, t2); + on(e2, t2) { + this.events.on(e2, t2); } - once(e, t2) { - this.events.once(e, t2); + once(e2, t2) { + this.events.once(e2, t2); } - off(e, t2) { - this.events.off(e, t2); + off(e2, t2) { + this.events.off(e2, t2); } - removeListener(e, t2) { - this.events.removeListener(e, t2); + removeListener(e2, t2) { + this.events.removeListener(e2, t2); } - async transportClose() { - this.requestsInFlight.size > 0 && (this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."), this.requestsInFlight.forEach(async (e) => { - await e.promise; - })), this.transportExplicitlyClosed = true, this.hasExperiencedNetworkDisruption && this.connected ? await ut$1(this.provider.disconnect(), 1e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.connected && await this.provider.disconnect(); - } - async transportOpen(e) { - if (this.transportExplicitlyClosed = false, await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress) { - e && e !== this.relayUrl && (this.relayUrl = e, await this.transportClose(), await this.createProvider()), this.connectionAttemptInProgress = true; + async transportDisconnect() { + if (!this.hasExperiencedNetworkDisruption && this.connected && this.requestsInFlight.size > 0) try { - await Promise.all([new Promise((t2) => { - if (!this.initialized) - return t2(); - this.subscriber.once(w$1.resubscribed, () => { - t2(); - }); - }), new Promise(async (t2, i2) => { - try { - await ut$1(this.provider.connect(), 1e4, `Socket stalled when trying to connect to ${this.relayUrl}`); - } catch (s2) { - i2(s2); - return; - } - t2(); - })]); - } catch (t2) { - this.logger.error(t2); - const i2 = t2; - if (!this.isConnectionStalled(i2.message)) - throw t2; - this.provider.events.emit(P$1.disconnect); - } finally { - this.connectionAttemptInProgress = false, this.hasExperiencedNetworkDisruption = false; + await Promise.all(Array.from(this.requestsInFlight.values()).map((e2) => e2.promise)); + } catch (e2) { + this.logger.warn(e2); } + this.hasExperiencedNetworkDisruption || this.connected ? await u0(this.provider.disconnect(), 2e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.onProviderDisconnect(); + } + async transportClose() { + this.transportExplicitlyClosed = true, await this.transportDisconnect(); + } + async transportOpen(e2) { + await this.confirmOnlineStateOrThrow(), e2 && e2 !== this.relayUrl && (this.relayUrl = e2, await this.transportDisconnect(), await this.createProvider()), this.connectionAttemptInProgress = true, this.transportExplicitlyClosed = false; + try { + await new Promise(async (t2, i2) => { + const s2 = () => { + this.provider.off(f$1.disconnect, s2), i2(new Error("Connection interrupted while trying to subscribe")); + }; + this.provider.on(f$1.disconnect, s2), await u0(this.provider.connect(), cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), `Socket stalled when trying to connect to ${this.relayUrl}`).catch((r3) => { + i2(r3); + }), await this.subscriber.start(), this.hasExperiencedNetworkDisruption = false, t2(); + }); + } catch (t2) { + this.logger.error(t2); + const i2 = t2; + if (!this.isConnectionStalled(i2.message)) + throw t2; + } finally { + this.connectionAttemptInProgress = false; } } - async restartTransport(e) { - await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress && (this.relayUrl = e || this.relayUrl, await this.transportClose(), await this.createProvider(), await this.transportOpen()); + async restartTransport(e2) { + this.connectionAttemptInProgress || (this.relayUrl = e2 || this.relayUrl, await this.confirmOnlineStateOrThrow(), await this.transportClose(), await this.createProvider(), await this.transportOpen()); } async confirmOnlineStateOrThrow() { - if (!await rr$1()) + if (!await hh()) throw new Error("No internet connection detected. Please restart your network and try again."); } - isConnectionStalled(e) { - return this.staleConnectionErrors.some((t2) => e.includes(t2)); + startPingTimeout() { + var e2, t2, i2, s2, r3; + if (pi()) + try { + (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) != null && t2.socket && ((r3 = (s2 = (i2 = this.provider) == null ? void 0 : i2.connection) == null ? void 0 : s2.socket) == null || r3.once("ping", () => { + this.resetPingTimeout(); + })), this.resetPingTimeout(); + } catch (o2) { + this.logger.warn(o2); + } + } + isConnectionStalled(e2) { + return this.staleConnectionErrors.some((t2) => e2.includes(t2)); } async createProvider() { this.provider.connection && this.unregisterProviderListeners(); - const e = await this.core.crypto.signJWT(this.relayUrl); - this.provider = new JsonRpcProvider(new f(Xn({ sdkVersion: gt, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); + const e2 = await this.core.crypto.signJWT(this.relayUrl); + this.provider = new JsonRpcProvider(new f$2($o({ sdkVersion: Dt$1, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e2, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); } - async recordMessageEvent(e) { - const { topic: t2, message: i2 } = e; + async recordMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; await this.messages.set(t2, i2); } - async shouldIgnoreMessageEvent(e) { - const { topic: t2, message: i2 } = e; + async shouldIgnoreMessageEvent(e2) { + const { topic: t2, message: i2 } = e2; if (!i2 || i2.length === 0) return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; if (!await this.subscriber.isSubscribed(t2)) @@ -11050,86 +14584,76 @@ class $t extends g$4 { const s2 = this.messages.has(t2, i2); return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; } - async onProviderPayload(e) { - if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e }), isJsonRpcRequest(e)) { - if (!e.method.endsWith(lt)) + async onProviderPayload(e2) { + if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e2 }), isJsonRpcRequest(e2)) { + if (!e2.method.endsWith(gt)) return; - const t2 = e.params, { topic: i2, message: s2, publishedAt: r2 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r2 }; - this.logger.debug("Emitting Relayer Payload"), this.logger.trace(Ar({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e), await this.onMessageEvent(o2); + const t2 = e2.params, { topic: i2, message: s2, publishedAt: r3 } = t2.data, o2 = { topic: i2, message: s2, publishedAt: r3 }; + this.logger.debug("Emitting Relayer Payload"), this.logger.trace(zr$1({ type: "event", event: t2.id }, o2)), this.events.emit(t2.id, o2), await this.acknowledgePayload(e2), await this.onMessageEvent(o2); } else - isJsonRpcResponse(e) && this.events.emit(D$1.message_ack, e); + isJsonRpcResponse(e2) && this.events.emit(v2.message_ack, e2); } - async onMessageEvent(e) { - await this.shouldIgnoreMessageEvent(e) || (this.events.emit(D$1.message, e), await this.recordMessageEvent(e)); + async onMessageEvent(e2) { + await this.shouldIgnoreMessageEvent(e2) || (this.events.emit(v2.message, e2), await this.recordMessageEvent(e2)); } - async acknowledgePayload(e) { - const t2 = formatJsonRpcResult(e.id, true); + async acknowledgePayload(e2) { + const t2 = formatJsonRpcResult(e2.id, true); await this.provider.connection.send(t2); } unregisterProviderListeners() { - this.provider.off(P$1.payload, this.onPayloadHandler), this.provider.off(P$1.connect, this.onConnectHandler), this.provider.off(P$1.disconnect, this.onDisconnectHandler), this.provider.off(P$1.error, this.onProviderErrorHandler); + this.provider.off(f$1.payload, this.onPayloadHandler), this.provider.off(f$1.connect, this.onConnectHandler), this.provider.off(f$1.disconnect, this.onDisconnectHandler), this.provider.off(f$1.error, this.onProviderErrorHandler); } async registerEventListeners() { - this.events.on(D$1.connection_stalled, () => { - this.restartTransport().catch((t2) => this.logger.error(t2)); - }); - let e = await rr$1(); - or$1(async (t2) => { - this.initialized && e !== t2 && (e = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportClose().catch((i2) => this.logger.error(i2)))); + let e2 = await hh(); + ch(async (t2) => { + e2 !== t2 && (e2 = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportDisconnect(), this.transportExplicitlyClosed = false)); }); } - onProviderDisconnect() { - this.events.emit(D$1.disconnect), this.attemptToReconnect(); - } - attemptToReconnect() { - this.transportExplicitlyClosed || (this.logger.info("attemptToReconnect called. Connecting..."), setTimeout(async () => { - await this.restartTransport().catch((e) => this.logger.error(e)); - }, cjs$4.toMiliseconds(dt))); + async onProviderDisconnect() { + await this.subscriber.stop(), this.events.emit(v2.disconnect), this.connectionAttemptInProgress = false, !this.transportExplicitlyClosed && setTimeout(async () => { + await this.transportOpen().catch((e2) => this.logger.error(e2)); + }, cjs$3.toMiliseconds(pt)); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } async toEstablishConnection() { - if (await this.confirmOnlineStateOrThrow(), !this.connected) { - if (this.connectionAttemptInProgress) - return await new Promise((e) => { - const t2 = setInterval(() => { - this.connected && (clearInterval(t2), e()); - }, this.connectionStatusPollingInterval); - }); - await this.restartTransport(); - } - } -} -var zr = Object.defineProperty, Ft = Object.getOwnPropertySymbols, Nr = Object.prototype.hasOwnProperty, Ur = Object.prototype.propertyIsEnumerable, Mt = (n3, e, t2) => e in n3 ? zr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, kt = (n3, e) => { - for (var t2 in e || (e = {})) - Nr.call(e, t2) && Mt(n3, t2, e[t2]); - if (Ft) - for (var t2 of Ft(e)) - Ur.call(e, t2) && Mt(n3, t2, e[t2]); - return n3; -}; -class Kt extends p$2 { - constructor(e, t2, i2, s2 = O, r2 = void 0) { - super(e, t2, i2, s2), this.core = e, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = Dt, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { + await this.confirmOnlineStateOrThrow(), !this.connected && (this.connectionAttemptInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.connected && (clearInterval(t2), e2()); + }, this.connectionStatusPollingInterval); + }), await this.transportOpen()); + } +}; +var Nr = Object.defineProperty, Bt$1 = Object.getOwnPropertySymbols, Lr = Object.prototype.hasOwnProperty, Ur$1 = Object.prototype.propertyIsEnumerable, Mt = (n4, e2, t2) => e2 in n4 ? Nr(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Kt$1 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Lr.call(e2, t2) && Mt(n4, t2, e2[t2]); + if (Bt$1) + for (var t2 of Bt$1(e2)) + Ur$1.call(e2, t2) && Mt(n4, t2, e2[t2]); + return n4; +}; +class Vt extends p { + constructor(e2, t2, i2, s2 = z$1, r3 = void 0) { + super(e2, t2, i2, s2), this.core = e2, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = mt, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.recentlyDeleted = [], this.recentlyDeletedLimit = 200, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o2) => { - this.getKey && o2 !== null && !w$3(o2) ? this.map.set(this.getKey(o2), o2) : Lt$1(o2) ? this.map.set(o2.id, o2) : xt$1(o2) && this.map.set(o2.topic, o2); + this.getKey && o2 !== null && !Pe(o2) ? this.map.set(this.getKey(o2), o2) : Gu(o2) ? this.map.set(o2.id, o2) : Yu(o2) && this.map.set(o2.topic, o2); }), this.cached = [], this.initialized = true); }, this.set = async (o2, a3) => { this.isInitialized(), this.map.has(o2) ? await this.update(o2, a3) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o2, value: a3 }), this.map.set(o2, a3), await this.persist()); - }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a3) => Object.keys(o2).every((h4) => Gi(a3[h4], o2[h4]))) : this.values), this.update = async (o2, a3) => { + }, this.get = (o2) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o2 }), this.getData(o2)), this.getAll = (o2) => (this.isInitialized(), o2 ? this.values.filter((a3) => Object.keys(o2).every((h4) => Yi(a3[h4], o2[h4]))) : this.values), this.update = async (o2, a3) => { this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o2, update: a3 }); - const h4 = kt(kt({}, this.getData(o2)), a3); + const h4 = Kt$1(Kt$1({}, this.getData(o2)), a3); this.map.set(o2, h4), await this.persist(); }, this.delete = async (o2, a3) => { - this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a3 }), this.map.delete(o2), await this.persist()); - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.storagePrefix = s2, this.getKey = r2; + this.isInitialized(), this.map.has(o2) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o2, reason: a3 }), this.map.delete(o2), this.addToRecentlyDeleted(o2), await this.persist()); + }, this.logger = E$1(t2, this.name), this.storagePrefix = s2, this.getKey = r3; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11143,16 +14667,23 @@ class Kt extends p$2 { get values() { return Array.from(this.map.values()); } - async setDataStore(e) { - await this.core.storage.setItem(this.storageKey, e); + addToRecentlyDeleted(e2) { + this.recentlyDeleted.push(e2), this.recentlyDeleted.length >= this.recentlyDeletedLimit && this.recentlyDeleted.splice(0, this.recentlyDeletedLimit / 2); + } + async setDataStore(e2) { + await this.core.storage.setItem(this.storageKey, e2); } async getDataStore() { return await this.core.storage.getItem(this.storageKey); } - getData(e) { - const t2 = this.map.get(e); + getData(e2) { + const t2 = this.map.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); + if (this.recentlyDeleted.includes(e2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e2}`); + throw this.logger.error(s2), new Error(s2); + } + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw this.logger.error(i2), new Error(i2); } return t2; @@ -11162,53 +14693,53 @@ class Kt extends p$2 { } async restore() { try { - const e = await this.getDataStore(); - if (typeof e > "u" || !e.length) + const e2 = await this.getDataStore(); + if (typeof e2 > "u" || !e2.length) return; if (this.map.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } - 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); + this.cached = e2, this.logger.debug(`Successfully Restored value for ${this.name}`), this.logger.trace({ type: "method", method: "restore", value: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore value for ${this.name}`), this.logger.error(e2); } } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } } -class Bt { - constructor(e, t2) { - this.core = e, this.logger = t2, this.name = Et, this.version = wt, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = O, this.ignoredPayloadTypes = [_$1], this.registeredMethods = [], this.init = async () => { +class qt { + constructor(e2, t2) { + this.core = e2, this.logger = t2, this.name = vt, this.version = It, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = z$1, this.ignoredPayloadTypes = [lr$1], this.registeredMethods = [], this.init = async () => { this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); }, this.register = ({ methods: i2 }) => { this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; - }, this.create = async () => { + }, this.create = async (i2) => { this.isInitialized(); - const i2 = Vn(), s2 = await this.core.crypto.setSymKey(i2), r2 = pt$1(cjs$4.FIVE_MINUTES), o2 = { protocol: ht }, a3 = { topic: s2, expiry: r2, relay: o2, active: false }, h4 = Rt$1({ protocol: this.core.protocol, version: this.core.version, topic: s2, symKey: i2, relay: o2, expiryTimestamp: r2 }); - return await this.pairings.set(s2, a3), await this.core.relayer.subscribe(s2), this.core.expirer.set(s2, r2), { topic: s2, uri: h4 }; + const s2 = gu(), r3 = await this.core.crypto.setSymKey(s2), o2 = d0(cjs$3.FIVE_MINUTES), a3 = { protocol: lt }, h4 = { topic: r3, expiry: o2, relay: a3, active: false }, l2 = Du({ protocol: this.core.protocol, version: this.core.version, topic: r3, symKey: s2, relay: a3, expiryTimestamp: o2, methods: i2 == null ? void 0 : i2.methods }); + return await this.pairings.set(r3, h4), await this.core.relayer.subscribe(r3), this.core.expirer.set(r3, o2), { topic: r3, uri: l2 }; }, this.pair = async (i2) => { this.isInitialized(), this.isValidPair(i2); - const { topic: s2, symKey: r2, relay: o2, expiryTimestamp: a3 } = Pt$1(i2.uri); - let h4; - if (this.pairings.keys.includes(s2) && (h4 = this.pairings.get(s2), h4.active)) + const { topic: s2, symKey: r3, relay: o2, expiryTimestamp: a3, methods: h4 } = Pu(i2.uri); + let l2; + if (this.pairings.keys.includes(s2) && (l2 = this.pairings.get(s2), l2.active)) throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); - const l2 = a3 || pt$1(cjs$4.FIVE_MINUTES), d3 = { topic: s2, relay: o2, expiry: l2, active: false }; - return await this.pairings.set(s2, d3), this.core.expirer.set(s2, l2), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V.create, d3), this.core.crypto.keychain.has(s2) || (await this.core.crypto.setSymKey(r2, s2), await this.core.relayer.subscribe(s2, { relay: o2 })), d3; + const d5 = a3 || d0(cjs$3.FIVE_MINUTES), g3 = { topic: s2, relay: o2, expiry: d5, active: false, methods: h4 }; + return await this.pairings.set(s2, g3), this.core.expirer.set(s2, d5), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V$1.create, g3), this.core.crypto.keychain.has(s2) || await this.core.crypto.setSymKey(r3, s2), await this.core.relayer.subscribe(s2, { relay: o2 }), g3; }, this.activate = async ({ topic: i2 }) => { this.isInitialized(); - const s2 = pt$1(cjs$4.THIRTY_DAYS); + const s2 = d0(cjs$3.THIRTY_DAYS); await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); }, this.ping = async (i2) => { this.isInitialized(), await this.isValidPing(i2); const { topic: s2 } = i2; if (this.pairings.keys.includes(s2)) { - const r2 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a3, reject: h4 } = at$1(); - this.events.once(yt$1("pairing_ping", r2), ({ error: l2 }) => { + const r3 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o2, resolve: a3, reject: h4 } = a0(); + this.events.once(v0("pairing_ping", r3), ({ error: l2 }) => { l2 ? h4(l2) : a3(); }), await o2(); } @@ -11219,174 +14750,174 @@ class Bt { }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { this.isInitialized(), await this.isValidDisconnect(i2); const { topic: s2 } = i2; - this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", U$2("USER_DISCONNECTED")), await this.deletePairing(s2)); - }, this.sendRequest = async (i2, s2, r2) => { - const o2 = formatJsonRpcRequest(s2, r2), a3 = await this.core.crypto.encode(i2, o2), h4 = $[s2].req; + this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", tr$2("USER_DISCONNECTED")), await this.deletePairing(s2)); + }, this.sendRequest = async (i2, s2, r3) => { + const o2 = formatJsonRpcRequest(s2, r3), a3 = await this.core.crypto.encode(i2, o2), h4 = F$1[s2].req; return this.core.history.set(i2, o2), this.core.relayer.publish(i2, a3, h4), o2.id; - }, this.sendResult = async (i2, s2, r2) => { - const o2 = formatJsonRpcResult(i2, r2), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = $[h4.request.method].res; + }, this.sendResult = async (i2, s2, r3) => { + const o2 = formatJsonRpcResult(i2, r3), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = F$1[h4.request.method].res; await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); - }, this.sendError = async (i2, s2, r2) => { - const o2 = formatJsonRpcError(i2, r2), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = $[h4.request.method] ? $[h4.request.method].res : $.unregistered_method.res; + }, this.sendError = async (i2, s2, r3) => { + const o2 = formatJsonRpcError(i2, r3), a3 = await this.core.crypto.encode(s2, o2), h4 = await this.core.history.get(s2, i2), l2 = F$1[h4.request.method] ? F$1[h4.request.method].res : F$1.unregistered_method.res; await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o2); }, this.deletePairing = async (i2, s2) => { - await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, U$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); + await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, tr$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); }, this.cleanup = async () => { - const i2 = this.pairings.getAll().filter((s2) => mt$1(s2.expiry)); + const i2 = this.pairings.getAll().filter((s2) => p0(s2.expiry)); await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); }, this.onRelayEventRequest = (i2) => { - const { topic: s2, payload: r2 } = i2; - switch (r2.method) { + const { topic: s2, payload: r3 } = i2; + switch (r3.method) { case "wc_pairingPing": - return this.onPairingPingRequest(s2, r2); + return this.onPairingPingRequest(s2, r3); case "wc_pairingDelete": - return this.onPairingDeleteRequest(s2, r2); + return this.onPairingDeleteRequest(s2, r3); default: - return this.onUnknownRpcMethodRequest(s2, r2); + return this.onUnknownRpcMethodRequest(s2, r3); } }, this.onRelayEventResponse = async (i2) => { - const { topic: s2, payload: r2 } = i2, o2 = (await this.core.history.get(s2, r2.id)).request.method; + const { topic: s2, payload: r3 } = i2, o2 = (await this.core.history.get(s2, r3.id)).request.method; switch (o2) { case "wc_pairingPing": - return this.onPairingPingResponse(s2, r2); + return this.onPairingPingResponse(s2, r3); default: return this.onUnknownRpcMethodResponse(o2); } }, this.onPairingPingRequest = async (i2, s2) => { - const { id: r2 } = s2; + const { id: r3 } = s2; try { - this.isValidPing({ topic: i2 }), await this.sendResult(r2, i2, true), this.events.emit(V.ping, { id: r2, topic: i2 }); + this.isValidPing({ topic: i2 }), await this.sendResult(r3, i2, true), this.events.emit(V$1.ping, { id: r3, topic: i2 }); } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); + await this.sendError(r3, i2, o2), this.logger.error(o2); } }, this.onPairingPingResponse = (i2, s2) => { - const { id: r2 } = s2; + const { id: r3 } = s2; setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("pairing_ping", r2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("pairing_ping", r2), { error: s2.error }); + isJsonRpcResult(s2) ? this.events.emit(v0("pairing_ping", r3), {}) : isJsonRpcError(s2) && this.events.emit(v0("pairing_ping", r3), { error: s2.error }); }, 500); }, this.onPairingDeleteRequest = async (i2, s2) => { - const { id: r2 } = s2; + const { id: r3 } = s2; try { - this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V.delete, { id: r2, topic: i2 }); + this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V$1.delete, { id: r3, topic: i2 }); } catch (o2) { - await this.sendError(r2, i2, o2), this.logger.error(o2); + await this.sendError(r3, i2, o2), this.logger.error(o2); } }, this.onUnknownRpcMethodRequest = async (i2, s2) => { - const { id: r2, method: o2 } = s2; + const { id: r3, method: o2 } = s2; try { if (this.registeredMethods.includes(o2)) return; - const a3 = U$2("WC_METHOD_UNSUPPORTED", o2); - await this.sendError(r2, i2, a3), this.logger.error(a3); + const a3 = tr$2("WC_METHOD_UNSUPPORTED", o2); + await this.sendError(r3, i2, a3), this.logger.error(a3); } catch (a3) { - await this.sendError(r2, i2, a3), this.logger.error(a3); + await this.sendError(r3, i2, a3), this.logger.error(a3); } }, this.onUnknownRpcMethodResponse = (i2) => { - this.registeredMethods.includes(i2) || this.logger.error(U$2("WC_METHOD_UNSUPPORTED", i2)); + this.registeredMethods.includes(i2) || this.logger.error(tr$2("WC_METHOD_UNSUPPORTED", i2)); }, this.isValidPair = (i2) => { var s2; - if (!Gt$1(i2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `pair() params: ${i2}`); + if (!$u(i2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `pair() params: ${i2}`); throw new Error(o2); } - if (!Kt$1(i2.uri)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); + if (!Ju(i2.uri)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); throw new Error(o2); } - const r2 = Pt$1(i2.uri); - if (!((s2 = r2 == null ? void 0 : r2.relay) != null && s2.protocol)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", "pair() uri#relay-protocol"); + const r3 = Pu(i2.uri); + if (!((s2 = r3 == null ? void 0 : r3.relay) != null && s2.protocol)) { + const { message: o2 } = xe("MISSING_OR_INVALID", "pair() uri#relay-protocol"); throw new Error(o2); } - if (!(r2 != null && r2.symKey)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", "pair() uri#symKey"); + if (!(r3 != null && r3.symKey)) { + const { message: o2 } = xe("MISSING_OR_INVALID", "pair() uri#symKey"); throw new Error(o2); } - if (r2 != null && r2.expiryTimestamp && cjs$4.toMiliseconds(r2 == null ? void 0 : r2.expiryTimestamp) < Date.now()) { - const { message: o2 } = N$1("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); + if (r3 != null && r3.expiryTimestamp && cjs$3.toMiliseconds(r3 == null ? void 0 : r3.expiryTimestamp) < Date.now()) { + const { message: o2 } = xe("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); throw new Error(o2); } }, this.isValidPing = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `ping() params: ${i2}`); - throw new Error(r2); + if (!$u(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `ping() params: ${i2}`); + throw new Error(r3); } const { topic: s2 } = i2; await this.isValidPairingTopic(s2); }, this.isValidDisconnect = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${i2}`); - throw new Error(r2); + if (!$u(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `disconnect() params: ${i2}`); + throw new Error(r3); } const { topic: s2 } = i2; await this.isValidPairingTopic(s2); }, this.isValidPairingTopic = async (i2) => { - if (!g$3(i2, false)) { - const { message: s2 } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); + if (!Gt$1(i2, false)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); throw new Error(s2); } if (!this.pairings.keys.includes(i2)) { - const { message: s2 } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); + const { message: s2 } = xe("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); throw new Error(s2); } - if (mt$1(this.pairings.get(i2).expiry)) { + if (p0(this.pairings.get(i2).expiry)) { await this.deletePairing(i2); - const { message: s2 } = N$1("EXPIRED", `pairing topic: ${i2}`); + const { message: s2 } = xe("EXPIRED", `pairing topic: ${i2}`); throw new Error(s2); } - }, this.core = e, this.logger = cjs$3.generateChildLogger(t2, this.name), this.pairings = new Kt(this.core, this.logger, this.name, this.storagePrefix); + }, this.core = e2, this.logger = E$1(t2, this.name), this.pairings = new Vt(this.core, this.logger, this.name, this.storagePrefix); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } registerRelayerEvents() { - this.core.relayer.on(D$1.message, async (e) => { - const { topic: t2, message: i2 } = e; + this.core.relayer.on(v2.message, async (e2) => { + const { topic: t2, message: i2 } = e2; if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) return; const s2 = await this.core.crypto.decode(t2, i2); try { isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); - } catch (r2) { - this.logger.error(r2); + } catch (r3) { + this.logger.error(r3); } }); } registerExpirerEvents() { - this.core.expirer.on(v2.expired, async (e) => { - const { topic: t2 } = ft$1(e.target); - t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V.expire, { topic: t2 })); + this.core.expirer.on(C.expired, async (e2) => { + const { topic: t2 } = l0(e2.target); + t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V$1.expire, { topic: t2 })); }); } } -class Vt extends h$2 { - constructor(e, t2) { - super(e, t2), this.core = e, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = vt, this.version = It, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { +let jt$1 = class jt extends h$1 { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = _t, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.set = (i2, s2, r2) => { - if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r2 }), this.records.has(s2.id)) + }, this.set = (i2, s2, r3) => { + if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r3 }), this.records.has(s2.id)) return; - const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r2, expiry: pt$1(cjs$4.THIRTY_DAYS) }; - this.records.set(o2.id, o2), this.events.emit(R$1.created, o2); + const o2 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r3, expiry: d0(cjs$3.THIRTY_DAYS) }; + this.records.set(o2.id, o2), this.persist(), this.events.emit(I$1.created, o2); }, this.resolve = async (i2) => { if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) return; const s2 = await this.getRecord(i2.id); - typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.events.emit(R$1.updated, s2)); + typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.persist(), this.events.emit(I$1.updated, s2)); }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { - this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r2) => { - if (r2.topic === i2) { - if (typeof s2 < "u" && r2.id !== s2) + this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r3) => { + if (r3.topic === i2) { + if (typeof s2 < "u" && r3.id !== s2) return; - this.records.delete(r2.id), this.events.emit(R$1.deleted, r2); + this.records.delete(r3.id), this.events.emit(I$1.deleted, r3); } - }); + }), this.persist(); }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { this.events.on(i2, s2); }, this.once = (i2, s2) => { @@ -11395,10 +14926,10 @@ class Vt extends h$2 { this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11413,79 +14944,81 @@ class Vt extends h$2 { return Array.from(this.records.values()); } get pending() { - const e = []; + const e2 = []; return this.values.forEach((t2) => { if (typeof t2.response < "u") return; const i2 = { topic: t2.topic, request: formatJsonRpcRequest(t2.request.method, t2.request.params, t2.id), chainId: t2.chainId }; - return e.push(i2); - }), e; + return e2.push(i2); + }), e2; } - async setJsonRpcRecords(e) { - await this.core.storage.setItem(this.storageKey, e); + async setJsonRpcRecords(e2) { + await this.core.storage.setItem(this.storageKey, e2); } async getJsonRpcRecords() { return await this.core.storage.getItem(this.storageKey); } - getRecord(e) { + getRecord(e2) { this.isInitialized(); - const t2 = this.records.get(e); + const t2 = this.records.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw new Error(i2); } return t2; } async persist() { - await this.setJsonRpcRecords(this.values), this.events.emit(R$1.sync); + await this.setJsonRpcRecords(this.values), this.events.emit(I$1.sync); } async restore() { try { - const e = await this.getJsonRpcRecords(); - if (typeof e > "u" || !e.length) + const e2 = await this.getJsonRpcRecords(); + if (typeof e2 > "u" || !e2.length) return; if (this.records.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } - 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); + this.cached = e2, this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", records: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(e2); } } registerEventListeners() { - this.events.on(R$1.created, (e) => { - const t2 = R$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.events.on(R$1.updated, (e) => { - const t2 = R$1.updated; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.events.on(R$1.deleted, (e) => { - const t2 = R$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e }), this.persist(); - }), this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { + this.events.on(I$1.created, (e2) => { + const t2 = I$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.updated, (e2) => { + const t2 = I$1.updated; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.deleted, (e2) => { + const t2 = I$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { this.cleanup(); }); } cleanup() { try { - this.records.forEach((e) => { - cjs$4.toMiliseconds(e.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${e.id}`), this.delete(e.topic, e.id)); - }); - } catch (e) { - this.logger.warn(e); + this.isInitialized(); + let e2 = false; + this.records.forEach((t2) => { + cjs$3.toMiliseconds(t2.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${t2.id}`), this.records.delete(t2.id), this.events.emit(I$1.deleted, t2, false), e2 = true); + }), e2 && this.persist(); + } catch (e2) { + this.logger.warn(e2); } } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } -} -class qt extends E { - constructor(e, t2) { - super(e, t2), this.core = e, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = Rt, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { +}; +class Gt extends E { + constructor(e2, t2) { + super(e2, t2), this.core = e2, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Rt, this.version = Tt$1, this.cached = [], this.initialized = false, this.storagePrefix = z$1, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); }, this.has = (i2) => { try { @@ -11496,16 +15029,16 @@ class qt extends E { } }, this.set = (i2, s2) => { this.isInitialized(); - const r2 = this.formatTarget(i2), o2 = { target: r2, expiry: s2 }; - this.expirations.set(r2, o2), this.checkExpiry(r2, o2), this.events.emit(v2.created, { target: r2, expiration: o2 }); + const r3 = this.formatTarget(i2), o2 = { target: r3, expiry: s2 }; + this.expirations.set(r3, o2), this.checkExpiry(r3, o2), this.events.emit(C.created, { target: r3, expiration: o2 }); }, this.get = (i2) => { this.isInitialized(); const s2 = this.formatTarget(i2); return this.getExpiration(s2); }, this.del = (i2) => { if (this.isInitialized(), this.has(i2)) { - const s2 = this.formatTarget(i2), r2 = this.getExpiration(s2); - this.expirations.delete(s2), this.events.emit(v2.deleted, { target: s2, expiration: r2 }); + const s2 = this.formatTarget(i2), r3 = this.getExpiration(s2); + this.expirations.delete(s2), this.events.emit(C.deleted, { target: s2, expiration: r3 }); } }, this.on = (i2, s2) => { this.events.on(i2, s2); @@ -11515,10 +15048,10 @@ class qt extends E { this.events.off(i2, s2); }, this.removeListener = (i2, s2) => { this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11532,92 +15065,92 @@ class qt extends E { get values() { return Array.from(this.expirations.values()); } - formatTarget(e) { - if (typeof e == "string") - return lt$1(e); - if (typeof e == "number") - return dt$1(e); - const { message: t2 } = N$1("UNKNOWN_TYPE", `Target type: ${typeof e}`); + formatTarget(e2) { + if (typeof e2 == "string") + return h0(e2); + if (typeof e2 == "number") + return c0(e2); + const { message: t2 } = xe("UNKNOWN_TYPE", `Target type: ${typeof e2}`); throw new Error(t2); } - async setExpirations(e) { - await this.core.storage.setItem(this.storageKey, e); + async setExpirations(e2) { + await this.core.storage.setItem(this.storageKey, e2); } async getExpirations() { return await this.core.storage.getItem(this.storageKey); } async persist() { - await this.setExpirations(this.values), this.events.emit(v2.sync); + await this.setExpirations(this.values), this.events.emit(C.sync); } async restore() { try { - const e = await this.getExpirations(); - if (typeof e > "u" || !e.length) + const e2 = await this.getExpirations(); + if (typeof e2 > "u" || !e2.length) return; if (this.expirations.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } - 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); + this.cached = e2, this.logger.debug(`Successfully Restored expirations for ${this.name}`), this.logger.trace({ type: "method", method: "restore", expirations: this.values }); + } catch (e2) { + this.logger.debug(`Failed to Restore expirations for ${this.name}`), this.logger.error(e2); } } - getExpiration(e) { - const t2 = this.expirations.get(e); + getExpiration(e2) { + const t2 = this.expirations.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw this.logger.error(i2), new Error(i2); + const { message: i2 } = xe("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.warn(i2), new Error(i2); } return t2; } - checkExpiry(e, t2) { + checkExpiry(e2, t2) { const { expiry: i2 } = t2; - cjs$4.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e, t2); + cjs$3.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e2, t2); } - expire(e, t2) { - this.expirations.delete(e), this.events.emit(v2.expired, { target: e, expiration: t2 }); + expire(e2, t2) { + this.expirations.delete(e2), this.events.emit(C.expired, { target: e2, expiration: t2 }); } checkExpirations() { - this.core.relayer.connected && this.expirations.forEach((e, t2) => this.checkExpiry(t2, e)); + this.core.relayer.connected && this.expirations.forEach((e2, t2) => this.checkExpiry(t2, e2)); } registerEventListeners() { - this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(v2.created, (e) => { - const t2 = v2.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }), this.events.on(v2.expired, (e) => { - const t2 = v2.expired; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); - }), this.events.on(v2.deleted, (e) => { - const t2 = v2.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e }), this.persist(); + this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(C.created, (e2) => { + const t2 = C.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C.expired, (e2) => { + const t2 = C.expired; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); + }), this.events.on(C.deleted, (e2) => { + const t2 = C.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); }); } isInitialized() { if (!this.initialized) { - const { message: e } = N$1("NOT_INITIALIZED", this.name); - throw new Error(e); + const { message: e2 } = xe("NOT_INITIALIZED", this.name); + throw new Error(e2); } } } -class jt extends y$1 { - constructor(e, t2) { - super(e, t2), this.projectId = e, this.logger = t2, this.name = Z, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { - if (this.verifyDisabled || $$1() || !D$2()) +let Yt$1 = class Yt extends y$1 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.name = ee, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { + if (this.verifyDisabled || er$1() || !pr$1()) return; const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; try { await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2); + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3); } if (!this.initialized) { - this.removeIframe(), this.verifyUrl = ee; + this.removeIframe(), this.verifyUrl = te; try { await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2), this.verifyDisabled = true; + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3), this.verifyDisabled = true; } } }, this.register = async (i2) => { @@ -11626,17 +15159,17 @@ class jt extends y$1 { if (this.isDevEnv) return ""; const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - let r2; + let r3; try { - r2 = await this.fetchAttestation(i2.attestationId, s2); + r3 = await this.fetchAttestation(i2.attestationId, s2); } catch (o2) { - this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r2 = await this.fetchAttestation(i2.attestationId, ee); + this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o2), r3 = await this.fetchAttestation(i2.attestationId, te); } - return r2; + return r3; }, this.fetchAttestation = async (i2, s2) => { this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); - const r2 = this.startAbortTimer(cjs$4.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); - return clearTimeout(r2), o2.status === 200 ? await o2.json() : void 0; + const r3 = this.startAbortTimer(cjs$3.ONE_SECOND * 2), o2 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); + return clearTimeout(r3), o2.status === 200 ? await o2.json() : void 0; }, this.addToQueue = (i2) => { this.queue.push(i2); }, this.processQueue = () => { @@ -11651,1197 +15184,1247 @@ class jt extends y$1 { } }, this.createIframe = async () => { let i2; - const s2 = (r2) => { - r2.data === "verify_ready" && (this.initialized = true, this.processQueue(), window.removeEventListener("message", s2), i2()); + const s2 = (r3) => { + r3.data === "verify_ready" && (this.onInit(), window.removeEventListener("message", s2), i2()); }; - await Promise.race([new Promise((r2) => { - if (document.getElementById(Z)) - return r2(); + await Promise.race([new Promise((r3) => { + const o2 = document.getElementById(ee); + if (o2) + return this.iframe = o2, this.onInit(), r3(); window.addEventListener("message", s2); - const o2 = document.createElement("iframe"); - o2.id = Z, o2.src = `${this.verifyUrl}/${this.projectId}`, o2.style.display = "none", document.body.append(o2), this.iframe = o2, i2 = r2; - }), new Promise((r2, o2) => setTimeout(() => { + const a3 = document.createElement("iframe"); + a3.id = ee, a3.src = `${this.verifyUrl}/${this.projectId}`, a3.style.display = "none", document.body.append(a3), this.iframe = a3, i2 = r3; + }), new Promise((r3, o2) => setTimeout(() => { window.removeEventListener("message", s2), o2("verify iframe load timeout"); - }, cjs$4.toMiliseconds(cjs$4.FIVE_SECONDS)))]); + }, cjs$3.toMiliseconds(cjs$3.FIVE_SECONDS)))]); + }, this.onInit = () => { + this.initialized = true, this.processQueue(); }, this.removeIframe = () => { this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); }, this.getVerifyUrl = (i2) => { - let s2 = i2 || F$1; - return _t.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${F$1}`), s2 = F$1), s2; - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.verifyUrl = F$1, this.abortController = new AbortController(), this.isDevEnv = te$1() && process.env.IS_VITEST; + let s2 = i2 || k$1; + return St.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${k$1}`), s2 = k$1), s2; + }, this.logger = E$1(t2, this.name), this.verifyUrl = k$1, this.abortController = new AbortController(), this.isDevEnv = pi() && process.env.IS_VITEST; } get context() { - return cjs$3.getLoggerContext(this.logger); - } - startAbortTimer(e) { - return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$4.toMiliseconds(e)); - } -} -class Gt extends v$1 { - constructor(e, t2) { - super(e, t2), this.projectId = e, this.logger = t2, this.context = Tt, this.registerDeviceToken = async (i2) => { - const { clientId: s2, token: r2, notificationType: o2, enableEncrypted: a3 = false } = i2, h4 = `${St}/${this.projectId}/clients`; - await Yi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r2, always_raw: a3 }) }); - }, this.logger = cjs$3.generateChildLogger(t2, this.context); - } -} -var Lr = Object.defineProperty, Yt = Object.getOwnPropertySymbols, $r = Object.prototype.hasOwnProperty, Fr = Object.prototype.propertyIsEnumerable, Ht = (n3, e, t2) => e in n3 ? Lr(n3, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e] = t2, Jt = (n3, e) => { - for (var t2 in e || (e = {})) - $r.call(e, t2) && Ht(n3, t2, e[t2]); - if (Yt) - for (var t2 of Yt(e)) - Fr.call(e, t2) && Ht(n3, t2, e[t2]); - return n3; -}; -class te extends n$1 { - constructor(e) { - super(e), this.protocol = le$1, this.version = We, this.name = Q$1, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (i2, s2) => this.events.on(i2, s2), this.once = (i2, s2) => this.events.once(i2, s2), this.off = (i2, s2) => this.events.off(i2, s2), this.removeListener = (i2, s2) => this.events.removeListener(i2, s2), this.projectId = e == null ? void 0 : e.projectId, this.relayUrl = (e == null ? void 0 : e.relayUrl) || ge$1, this.customStoragePrefix = e != null && e.customStoragePrefix ? `:${e.customStoragePrefix}` : ""; - const t2 = typeof (e == null ? void 0 : e.logger) < "u" && typeof (e == null ? void 0 : e.logger) != "string" ? e.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (e == null ? void 0 : e.logger) || Qe.logger })); - this.logger = cjs$3.generateChildLogger(t2, this.name), this.heartbeat = new cjs$5.HeartBeat(), this.crypto = new xt(this, this.logger, e == null ? void 0 : e.keychain), this.history = new Vt(this, this.logger), this.expirer = new qt(this, this.logger), this.storage = e != null && e.storage ? e.storage : new h$3(Jt(Jt({}, Ze), e == null ? void 0 : e.storageOptions)), this.relayer = new $t({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new Bt(this, this.logger), this.verify = new jt(this.projectId || "", this.logger), this.echoClient = new Gt(this.projectId || "", this.logger); - } - static async init(e) { - const t2 = new te(e); + return y$2(this.logger); + } + startAbortTimer(e2) { + return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$3.toMiliseconds(e2)); + } +}; +let Ht$2 = class Ht extends v$1 { + constructor(e2, t2) { + super(e2, t2), this.projectId = e2, this.logger = t2, this.context = Pt, this.registerDeviceToken = async (i2) => { + const { clientId: s2, token: r3, notificationType: o2, enableEncrypted: a3 = false } = i2, h4 = `${xt}/${this.projectId}/clients`; + await Hi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o2, token: r3, always_raw: a3 }) }); + }, this.logger = E$1(t2, this.context); + } +}; +var $r = Object.defineProperty, Jt$2 = Object.getOwnPropertySymbols, Fr$1 = Object.prototype.hasOwnProperty, kr$1 = Object.prototype.propertyIsEnumerable, Xt$2 = (n4, e2, t2) => e2 in n4 ? $r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Wt$2 = (n4, e2) => { + for (var t2 in e2 || (e2 = {})) + Fr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + if (Jt$2) + for (var t2 of Jt$2(e2)) + kr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + return n4; +}; +let ie$2 = class ie extends n$2 { + constructor(e2) { + var t2; + super(e2), this.protocol = De, this.version = Ze$1, this.name = Z, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (o2, a3) => this.events.on(o2, a3), this.once = (o2, a3) => this.events.once(o2, a3), this.off = (o2, a3) => this.events.off(o2, a3), this.removeListener = (o2, a3) => this.events.removeListener(o2, a3), this.projectId = e2 == null ? void 0 : e2.projectId, this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me, this.customStoragePrefix = e2 != null && e2.customStoragePrefix ? `:${e2.customStoragePrefix}` : ""; + const i2 = k$2({ level: typeof (e2 == null ? void 0 : e2.logger) == "string" && e2.logger ? e2.logger : et.logger }), { logger: s2, chunkLoggerController: r3 } = A$2({ opts: i2, maxSizeInBytes: e2 == null ? void 0 : e2.maxLogBlobSizeInBytes, loggerOverride: e2 == null ? void 0 : e2.logger }); + this.logChunkController = r3, (t2 = this.logChunkController) != null && t2.downloadLogsBlobInBrowser && (window.downloadLogsBlobInBrowser = async () => { + var o2, a3; + (o2 = this.logChunkController) != null && o2.downloadLogsBlobInBrowser && ((a3 = this.logChunkController) == null || a3.downloadLogsBlobInBrowser({ clientId: await this.crypto.getClientId() })); + }), this.logger = E$1(s2, this.name), this.heartbeat = new cjs$4.HeartBeat(), this.crypto = new At(this, this.logger, e2 == null ? void 0 : e2.keychain), this.history = new jt$1(this, this.logger), this.expirer = new Gt(this, this.logger), this.storage = e2 != null && e2.storage ? e2.storage : new h$2(Wt$2(Wt$2({}, tt), e2 == null ? void 0 : e2.storageOptions)), this.relayer = new kt$1({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new qt(this, this.logger), this.verify = new Yt$1(this.projectId || "", this.logger), this.echoClient = new Ht$2(this.projectId || "", this.logger); + } + static async init(e2) { + const t2 = new ie(e2); await t2.initialize(); const i2 = await t2.crypto.getClientId(); - return await t2.storage.setItem(yt, i2), t2; + return await t2.storage.setItem(bt, i2), t2; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } async start() { this.initialized || await this.initialize(); } + async getLogsBlob() { + var e2; + return (e2 = this.logChunkController) == null ? void 0 : e2.logsToBlob({ clientId: await this.crypto.getClientId() }); + } 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.initialized = true, 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; - } - } -} -const Mr = te; -const J = "wc", F = 2, X = "client", G = `${J}@${F}:${X}:`, M = { name: X, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, H = "WALLETCONNECT_DEEPLINK_CHOICE", oe = "proposal", ae = "Proposal expired", ce = "session", L = cjs$4.SEVEN_DAYS, le = "engine", R = { wc_sessionPropose: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1114 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1115 } } }, U$1 = { min: cjs$4.FIVE_MINUTES, max: cjs$4.SEVEN_DAYS }, I = { idle: "IDLE", active: "ACTIVE" }, pe = "request", he = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"]; -var as = Object.defineProperty, cs = Object.defineProperties, ls = Object.getOwnPropertyDescriptors, de = Object.getOwnPropertySymbols, ps = Object.prototype.hasOwnProperty, hs = Object.prototype.propertyIsEnumerable, ue = (w3, r2, e) => r2 in w3 ? as(w3, r2, { enumerable: true, configurable: true, writable: true, value: e }) : w3[r2] = e, g$1 = (w3, r2) => { - for (var e in r2 || (r2 = {})) - ps.call(r2, e) && ue(w3, e, r2[e]); - if (de) - for (var e of de(r2)) - hs.call(r2, e) && ue(w3, e, r2[e]); - return w3; -}, D = (w3, r2) => cs(w3, ls(r2)); -class ds extends w$4 { - constructor(r2) { - super(r2), this.name = le, this.events = new EventEmitter$1(), this.initialized = false, this.ignoredPayloadTypes = [_$1], this.requestQueue = { state: I.idle, queue: [] }, this.sessionRequestQueue = { state: I.idle, queue: [] }, this.requestQueueDelay = cjs$4.ONE_SECOND, this.init = async () => { - this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(R) }), this.initialized = true, setTimeout(() => { + } catch (e2) { + throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`, e2), this.logger.error(e2.message), e2; + } + } +}; +const Br = ie$2; +const Se = "wc", Ee = 2, _e = "client", se$1 = `${Se}@${Ee}:${_e}:`, ie$1 = { name: _e, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, Re$1 = "WALLETCONNECT_DEEPLINK_CHOICE", Ke = "proposal", Ue = "Proposal expired", Ge = "session", L$2 = cjs$3.SEVEN_DAYS, ke = "engine", q$1 = { wc_sessionPropose: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1114 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1115 } }, wc_sessionAuthenticate: { req: { ttl: cjs$3.ONE_HOUR, prompt: true, tag: 1116 }, res: { ttl: cjs$3.ONE_HOUR, prompt: false, tag: 1117 } } }, re$1 = { min: cjs$3.FIVE_MINUTES, max: cjs$3.SEVEN_DAYS }, A$1 = { idle: "IDLE", active: "ACTIVE" }, Fe = "request", je = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"], Qe = "wc", ze = "auth", He = "authKeys", Ye = "pairingTopics", Xe$1 = "requests", X = `${Qe}@${1.5}:${ze}:`, J = `${X}:PUB_KEY`; +var Ht$1 = Object.defineProperty, Yt2 = Object.defineProperties, Xt$1 = Object.getOwnPropertyDescriptors, Je = Object.getOwnPropertySymbols, Jt$1 = Object.prototype.hasOwnProperty, Bt = Object.prototype.propertyIsEnumerable, Be$1 = (S2, n4, t2) => n4 in S2 ? Ht$1(S2, n4, { enumerable: true, configurable: true, writable: true, value: t2 }) : S2[n4] = t2, m2 = (S2, n4) => { + for (var t2 in n4 || (n4 = {})) + Jt$1.call(n4, t2) && Be$1(S2, t2, n4[t2]); + if (Je) + for (var t2 of Je(n4)) + Bt.call(n4, t2) && Be$1(S2, t2, n4[t2]); + return S2; +}, F = (S2, n4) => Yt2(S2, Xt$1(n4)); +let Wt$1 = class Wt extends w$2 { + constructor(n4) { + super(n4), this.name = ke, this.events = new EventEmitter$1(), this.initialized = false, this.requestQueue = { state: A$1.idle, queue: [] }, this.sessionRequestQueue = { state: A$1.idle, queue: [] }, this.requestQueueDelay = cjs$3.ONE_SECOND, this.expectedPairingMethodMap = /* @__PURE__ */ new Map(), this.recentlyDeletedMap = /* @__PURE__ */ new Map(), this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(q$1) }), this.initialized = true, setTimeout(() => { this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay))); - }, this.connect = async (e) => { + }, cjs$3.toMiliseconds(this.requestQueueDelay))); + }, this.connect = async (t2) => { + await this.isInitialized(); + const e2 = F(m2({}, t2), { requiredNamespaces: t2.requiredNamespaces || {}, optionalNamespaces: t2.optionalNamespaces || {} }); + await this.isValidConnect(e2); + const { pairingTopic: s2, requiredNamespaces: i2, optionalNamespaces: r3, sessionProperties: o2, relays: a3 } = e2; + let c2 = s2, d5, p2 = false; + try { + c2 && (p2 = this.client.core.pairing.pairings.get(c2).active); + } catch (f3) { + throw this.client.logger.error(`connect() -> pairing.get(${c2}) failed`), f3; + } + if (!c2 || !p2) { + const { topic: f3, uri: v3 } = await this.client.core.pairing.create(); + c2 = f3, d5 = v3; + } + if (!c2) { + const { message: f3 } = xe("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); + throw new Error(f3); + } + const g3 = await this.client.core.crypto.generateKeyPair(), h4 = q$1.wc_sessionPropose.req.ttl || cjs$3.FIVE_MINUTES, y3 = d0(h4), w3 = m2({ requiredNamespaces: i2, optionalNamespaces: r3, relays: a3 ?? [{ protocol: lt }], proposer: { publicKey: g3, metadata: this.client.metadata }, expiryTimestamp: y3 }, o2 && { sessionProperties: o2 }), { reject: I2, resolve: D2, done: E2 } = a0(h4, Ue); + this.events.once(v0("session_connect"), async ({ error: f3, session: v3 }) => { + if (f3) + I2(f3); + else if (v3) { + v3.self.publicKey = g3; + const j2 = F(m2({}, v3), { requiredNamespaces: w3.requiredNamespaces, optionalNamespaces: w3.optionalNamespaces }); + await this.client.session.set(v3.topic, j2), await this.setExpiry(v3.topic, v3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: v3.peer.metadata }), D2(j2); + } + }); + const P2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: w3, throwOnFailedPublish: true }); + return await this.setProposal(P2, m2({ id: P2 }, w3)), { uri: d5, approval: E2 }; + }, this.pair = async (t2) => { + await this.isInitialized(); + try { + return await this.client.core.pairing.pair(t2); + } catch (e2) { + throw this.client.logger.error("pair() failed"), e2; + } + }, this.approve = async (t2) => { + await this.isInitialized(); + try { + await this.isValidApprove(t2); + } catch (E2) { + throw this.client.logger.error("approve() -> isValidApprove() failed"), E2; + } + const { id: e2, relayProtocol: s2, namespaces: i2, sessionProperties: r3, sessionConfig: o2 } = t2; + let a3; + try { + a3 = this.client.proposal.get(e2); + } catch (E2) { + throw this.client.logger.error(`approve() -> proposal.get(${e2}) failed`), E2; + } + let { pairingTopic: c2, proposer: d5, requiredNamespaces: p2, optionalNamespaces: g3 } = a3; + c2 = c2 || ""; + const h4 = await this.client.core.crypto.generateKeyPair(), y3 = d5.publicKey, w3 = await this.client.core.crypto.generateSharedKey(h4, y3), I2 = m2(m2({ relay: { protocol: s2 ?? "irn" }, namespaces: i2, pairingTopic: c2, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: d0(L$2) }, r3 && { sessionProperties: r3 }), o2 && { sessionConfig: o2 }); + await this.client.core.relayer.subscribe(w3); + const D2 = F(m2({}, I2), { topic: w3, requiredNamespaces: p2, optionalNamespaces: g3, pairingTopic: c2, acknowledged: false, self: I2.controller, peer: { publicKey: d5.publicKey, metadata: d5.metadata }, controller: h4 }); + await this.client.session.set(w3, D2); + try { + await this.sendResult({ id: e2, topic: c2, result: { relay: { protocol: s2 ?? "irn" }, responderPublicKey: h4 }, throwOnFailedPublish: true }), await this.sendRequest({ topic: w3, method: "wc_sessionSettle", params: I2, throwOnFailedPublish: true }); + } catch (E2) { + throw this.client.logger.error(E2), this.client.session.delete(w3, tr$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(w3), E2; + } + return await this.client.core.pairing.updateMetadata({ topic: c2, metadata: d5.metadata }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: c2 }), await this.setExpiry(w3, d0(L$2)), { topic: w3, acknowledged: () => new Promise((E2) => setTimeout(() => E2(this.client.session.get(w3)), 500)) }; + }, this.reject = async (t2) => { + await this.isInitialized(); + try { + await this.isValidReject(t2); + } catch (r3) { + throw this.client.logger.error("reject() -> isValidReject() failed"), r3; + } + const { id: e2, reason: s2 } = t2; + let i2; + try { + i2 = this.client.proposal.get(e2).pairingTopic; + } catch (r3) { + throw this.client.logger.error(`reject() -> proposal.get(${e2}) failed`), r3; + } + i2 && (await this.sendError({ id: e2, topic: i2, error: s2 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED"))); + }, this.update = async (t2) => { + await this.isInitialized(); + try { + await this.isValidUpdate(t2); + } catch (p2) { + throw this.client.logger.error("update() -> isValidUpdate() failed"), p2; + } + const { topic: e2, namespaces: s2 } = t2, { done: i2, resolve: r3, reject: o2 } = a0(), a3 = payloadId(), c2 = getBigIntRpcId().toString(), d5 = this.client.session.get(e2).namespaces; + return this.events.once(v0("session_update", a3), ({ error: p2 }) => { + p2 ? o2(p2) : r3(); + }), await this.client.session.update(e2, { namespaces: s2 }), this.sendRequest({ topic: e2, method: "wc_sessionUpdate", params: { namespaces: s2 }, throwOnFailedPublish: true, clientRpcId: a3, relayRpcId: c2 }).catch((p2) => { + this.client.logger.error(p2), this.client.session.update(e2, { namespaces: d5 }), o2(p2); + }), { acknowledged: i2 }; + }, this.extend = async (t2) => { + await this.isInitialized(); + try { + await this.isValidExtend(t2); + } catch (a3) { + throw this.client.logger.error("extend() -> isValidExtend() failed"), a3; + } + const { topic: e2 } = t2, s2 = payloadId(), { done: i2, resolve: r3, reject: o2 } = a0(); + return this.events.once(v0("session_extend", s2), ({ error: a3 }) => { + a3 ? o2(a3) : r3(); + }), await this.setExpiry(e2, d0(L$2)), this.sendRequest({ topic: e2, method: "wc_sessionExtend", params: {}, clientRpcId: s2, throwOnFailedPublish: true }).catch((a3) => { + o2(a3); + }), { acknowledged: i2 }; + }, this.request = async (t2) => { + await this.isInitialized(); + try { + await this.isValidRequest(t2); + } catch (h4) { + throw this.client.logger.error("request() -> isValidRequest() failed"), h4; + } + const { chainId: e2, request: s2, topic: i2, expiry: r3 = q$1.wc_sessionRequest.req.ttl } = t2, o2 = this.client.session.get(i2), a3 = payloadId(), c2 = getBigIntRpcId().toString(), { done: d5, resolve: p2, reject: g3 } = a0(r3, "Request expired. Please try again."); + return this.events.once(v0("session_request", a3), ({ error: h4, result: y3 }) => { + h4 ? g3(h4) : p2(y3); + }), await Promise.all([new Promise(async (h4) => { + await this.sendRequest({ clientRpcId: a3, relayRpcId: c2, topic: i2, method: "wc_sessionRequest", params: { request: F(m2({}, s2), { expiryTimestamp: d0(r3) }), chainId: e2 }, expiry: r3, throwOnFailedPublish: true }).catch((y3) => g3(y3)), this.client.events.emit("session_request_sent", { topic: i2, request: s2, chainId: e2, id: a3 }), h4(); + }), new Promise(async (h4) => { + var y3; + if (!((y3 = o2.sessionConfig) != null && y3.disableDeepLink)) { + const w3 = await g0(this.client.core.storage, Re$1); + m0({ id: a3, topic: i2, wcDeepLink: w3 }); + } + h4(); + }), d5()]).then((h4) => h4[2]); + }, this.respond = async (t2) => { + await this.isInitialized(), await this.isValidRespond(t2); + const { topic: e2, response: s2 } = t2, { id: i2 } = s2; + isJsonRpcResult(s2) ? await this.sendResult({ id: i2, topic: e2, result: s2.result, throwOnFailedPublish: true }) : isJsonRpcError(s2) && await this.sendError({ id: i2, topic: e2, error: s2.error }), this.cleanupAfterResponse(t2); + }, this.ping = async (t2) => { await this.isInitialized(); - const s2 = D(g$1({}, e), { requiredNamespaces: e.requiredNamespaces || {}, optionalNamespaces: e.optionalNamespaces || {} }); - await this.isValidConnect(s2); - const { pairingTopic: t2, requiredNamespaces: i2, optionalNamespaces: n3, sessionProperties: o2, relays: a3 } = s2; - let c2 = t2, p3, d3 = false; - if (c2 && (d3 = this.client.core.pairing.pairings.get(c2).active), !c2 || !d3) { - const { topic: T2, uri: _3 } = await this.client.core.pairing.create(); - c2 = T2, p3 = _3; - } - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = R.wc_sessionPropose.req.ttl || cjs$4.FIVE_MINUTES, m2 = pt$1(N2), f2 = g$1({ requiredNamespaces: i2, optionalNamespaces: n3, relays: a3 ?? [{ protocol: ht }], proposer: { publicKey: h4, metadata: this.client.metadata }, expiryTimestamp: m2 }, o2 && { sessionProperties: o2 }), { reject: k2, resolve: O2, done: we } = at$1(N2, ae); - if (this.events.once(yt$1("session_connect"), async ({ error: T2, session: _3 }) => { - if (T2) - k2(T2); - else if (_3) { - _3.self.publicKey = h4; - const B2 = D(g$1({}, _3), { requiredNamespaces: f2.requiredNamespaces, optionalNamespaces: f2.optionalNamespaces }); - await this.client.session.set(_3.topic, B2), await this.setExpiry(_3.topic, _3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: _3.peer.metadata }), O2(B2); - } - }), !c2) { - const { message: T2 } = N$1("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); - throw new Error(T2); - } - const W2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: f2, throwOnFailedPublish: true }); - return await this.setProposal(W2, g$1({ id: W2 }, f2)), { uri: p3, approval: we }; - }, this.pair = async (e) => (await this.isInitialized(), await this.client.core.pairing.pair(e)), this.approve = async (e) => { - await this.isInitialized(), await this.isValidApprove(e); - const { id: s2, relayProtocol: t2, namespaces: i2, sessionProperties: n3 } = e, o2 = this.client.proposal.get(s2); - let { pairingTopic: a3, proposer: c2, requiredNamespaces: p3, optionalNamespaces: d3 } = o2; - a3 = a3 || ""; - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = c2.publicKey, m2 = await this.client.core.crypto.generateSharedKey(h4, N2); - a3 && s2 && (await this.client.core.pairing.updateMetadata({ topic: a3, metadata: c2.metadata }), await this.sendResult({ id: s2, topic: a3, result: { relay: { protocol: t2 ?? "irn" }, responderPublicKey: h4 } }), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: a3 })); - const f2 = g$1({ relay: { protocol: t2 ?? "irn" }, namespaces: i2, pairingTopic: a3, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: pt$1(L) }, n3 && { sessionProperties: n3 }); - await this.client.core.relayer.subscribe(m2); - const k2 = D(g$1({}, f2), { topic: m2, requiredNamespaces: p3, optionalNamespaces: d3, pairingTopic: a3, acknowledged: false, self: f2.controller, peer: { publicKey: c2.publicKey, metadata: c2.metadata }, controller: h4 }); - await this.client.session.set(m2, k2); try { - await this.sendRequest({ topic: m2, method: "wc_sessionSettle", params: f2, throwOnFailedPublish: true }); - } catch (O2) { - throw this.client.logger.error(O2), this.client.session.delete(m2, U$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(m2), O2; - } - return await this.setExpiry(m2, pt$1(L)), { topic: m2, acknowledged: () => new Promise((O2) => setTimeout(() => O2(this.client.session.get(m2)), 500)) }; - }, this.reject = async (e) => { - await this.isInitialized(), await this.isValidReject(e); - const { id: s2, reason: t2 } = e, { pairingTopic: i2 } = this.client.proposal.get(s2); - i2 && (await this.sendError(s2, i2, t2), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED"))); - }, this.update = async (e) => { - await this.isInitialized(), await this.isValidUpdate(e); - const { topic: s2, namespaces: t2 } = e, i2 = await this.sendRequest({ topic: s2, method: "wc_sessionUpdate", params: { namespaces: t2 } }), { done: n3, resolve: o2, reject: a3 } = at$1(); - return this.events.once(yt$1("session_update", i2), ({ error: c2 }) => { - c2 ? a3(c2) : o2(); - }), await this.client.session.update(s2, { namespaces: t2 }), { acknowledged: n3 }; - }, this.extend = async (e) => { - await this.isInitialized(), await this.isValidExtend(e); - const { topic: s2 } = e, t2 = await this.sendRequest({ topic: s2, method: "wc_sessionExtend", params: {} }), { done: i2, resolve: n3, reject: o2 } = at$1(); - return this.events.once(yt$1("session_extend", t2), ({ error: a3 }) => { - a3 ? o2(a3) : n3(); - }), await this.setExpiry(s2, pt$1(L)), { acknowledged: i2 }; - }, this.request = async (e) => { - await this.isInitialized(), await this.isValidRequest(e); - const { chainId: s2, request: t2, topic: i2, expiry: n3 = R.wc_sessionRequest.req.ttl } = e, o2 = payloadId(), { done: a3, resolve: c2, reject: p3 } = at$1(n3, "Request expired. Please try again."); - return this.events.once(yt$1("session_request", o2), ({ error: d3, result: h4 }) => { - d3 ? p3(d3) : c2(h4); - }), await Promise.all([new Promise(async (d3) => { - await this.sendRequest({ clientRpcId: o2, topic: i2, method: "wc_sessionRequest", params: { request: D(g$1({}, t2), { expiryTimestamp: pt$1(n3) }), chainId: s2 }, expiry: n3, throwOnFailedPublish: true }).catch((h4) => p3(h4)), this.client.events.emit("session_request_sent", { topic: i2, request: t2, chainId: s2, id: o2 }), d3(); - }), new Promise(async (d3) => { - const h4 = await ht$1(this.client.core.storage, H); - gt$1({ id: o2, topic: i2, wcDeepLink: h4 }), d3(); - }), a3()]).then((d3) => d3[2]); - }, this.respond = async (e) => { - await this.isInitialized(), await this.isValidRespond(e); - const { topic: s2, response: t2 } = e, { id: i2 } = t2; - isJsonRpcResult(t2) ? await this.sendResult({ id: i2, topic: s2, result: t2.result, throwOnFailedPublish: true }) : isJsonRpcError(t2) && await this.sendError(i2, s2, t2.error), this.cleanupAfterResponse(e); - }, this.ping = async (e) => { - await this.isInitialized(), await this.isValidPing(e); - const { topic: s2 } = e; - if (this.client.session.keys.includes(s2)) { - const t2 = await this.sendRequest({ topic: s2, method: "wc_sessionPing", params: {} }), { done: i2, resolve: n3, reject: o2 } = at$1(); - this.events.once(yt$1("session_ping", t2), ({ error: a3 }) => { - a3 ? o2(a3) : n3(); - }), await i2(); + await this.isValidPing(t2); + } catch (s2) { + throw this.client.logger.error("ping() -> isValidPing() failed"), s2; + } + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) { + const s2 = payloadId(), i2 = getBigIntRpcId().toString(), { done: r3, resolve: o2, reject: a3 } = a0(); + this.events.once(v0("session_ping", s2), ({ error: c2 }) => { + c2 ? a3(c2) : o2(); + }), await Promise.all([this.sendRequest({ topic: e2, method: "wc_sessionPing", params: {}, throwOnFailedPublish: true, clientRpcId: s2, relayRpcId: i2 }), r3()]); } else - this.client.core.pairing.pairings.keys.includes(s2) && await this.client.core.pairing.ping({ topic: s2 }); - }, this.emit = async (e) => { - await this.isInitialized(), await this.isValidEmit(e); - const { topic: s2, event: t2, chainId: i2 } = e; - await this.sendRequest({ topic: s2, method: "wc_sessionEvent", params: { event: t2, chainId: i2 } }); - }, this.disconnect = async (e) => { - await this.isInitialized(), await this.isValidDisconnect(e); - const { topic: s2 } = e; - if (this.client.session.keys.includes(s2)) - await this.sendRequest({ topic: s2, method: "wc_sessionDelete", params: U$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: s2, emitEvent: false }); - else if (this.client.core.pairing.pairings.keys.includes(s2)) - await this.client.core.pairing.disconnect({ topic: s2 }); + this.client.core.pairing.pairings.keys.includes(e2) && await this.client.core.pairing.ping({ topic: e2 }); + }, this.emit = async (t2) => { + await this.isInitialized(), await this.isValidEmit(t2); + const { topic: e2, event: s2, chainId: i2 } = t2, r3 = getBigIntRpcId().toString(); + await this.sendRequest({ topic: e2, method: "wc_sessionEvent", params: { event: s2, chainId: i2 }, throwOnFailedPublish: true, relayRpcId: r3 }); + }, this.disconnect = async (t2) => { + await this.isInitialized(), await this.isValidDisconnect(t2); + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) + await this.sendRequest({ topic: e2, method: "wc_sessionDelete", params: tr$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: e2, emitEvent: false }); + else if (this.client.core.pairing.pairings.keys.includes(e2)) + await this.client.core.pairing.disconnect({ topic: e2 }); else { - const { message: t2 } = N$1("MISMATCHED_TOPIC", `Session or pairing topic not found: ${s2}`); - throw new Error(t2); + const { message: s2 } = xe("MISMATCHED_TOPIC", `Session or pairing topic not found: ${e2}`); + throw new Error(s2); + } + }, this.find = (t2) => (this.isInitialized(), this.client.session.getAll().filter((e2) => Qu(e2, t2))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (t2) => { + this.isInitialized(), this.isValidAuthenticate(t2); + const { chains: e2, statement: s2 = "", uri: i2, domain: r3, nonce: o2, type: a3, exp: c2, nbf: d5, methods: p2 = [] } = t2, g3 = [...t2.resources || []], { topic: h4, uri: y3 } = await this.client.core.pairing.create({ methods: ["wc_sessionAuthenticate"] }); + this.client.logger.info({ message: "Generated new pairing", pairing: { topic: h4, uri: y3 } }); + const w3 = await this.client.core.crypto.generateKeyPair(), I2 = bu(w3); + if (await Promise.all([this.client.auth.authKeys.set(J, { responseTopic: I2, publicKey: w3 }), this.client.auth.pairingTopics.set(I2, { topic: I2, pairingTopic: h4 })]), await this.client.core.relayer.subscribe(I2), this.client.logger.info(`sending request to new pairing topic: ${h4}`), p2.length > 0) { + const { namespace: O3 } = dn(e2[0]); + let _3 = cu(O3, "request", p2); + Qr(g3) && (_3 = lu(_3, g3.pop())), g3.push(_3); + } + const D2 = d0(q$1.wc_sessionPropose.req.ttl), E2 = { authPayload: { type: a3 ?? "caip122", chains: e2, statement: s2, aud: i2, domain: r3, version: "1", nonce: o2, iat: (/* @__PURE__ */ new Date()).toISOString(), exp: c2, nbf: d5, resources: g3 }, requester: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, P2 = { eip155: { chains: e2, methods: [.../* @__PURE__ */ new Set(["personal_sign", ...p2])], events: ["chainChanged", "accountsChanged"] } }, f3 = { requiredNamespaces: {}, optionalNamespaces: P2, relays: [{ protocol: "irn" }], proposer: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, { done: v3, resolve: j2, reject: oe2 } = a0(q$1.wc_sessionAuthenticate.req.ttl, "Request expired"), B2 = async ({ error: O3, session: _3 }) => { + if (this.events.off(v0("session_request", M2), ae2), O3) + oe2(O3); + else if (_3) { + _3.self.publicKey = w3, await this.client.session.set(_3.topic, _3), await this.setExpiry(_3.topic, _3.expiry), h4 && await this.client.core.pairing.updateMetadata({ topic: h4, metadata: _3.peer.metadata }); + const Q2 = this.client.session.get(_3.topic); + j2({ session: Q2 }); + } + }, ae2 = async (O3) => { + if (O3.error) { + const z2 = tr$2("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate"); + return O3.error.code === z2.code ? void 0 : (this.events.off(v0("session_connect"), B2), oe2(O3.error.message)); + } + this.events.off(v0("session_connect"), B2); + const { cacaos: _3, responder: Q2 } = O3.result, le2 = [], Ie = []; + for (const z2 of _3) { + await ou({ cacao: z2, projectId: this.client.core.projectId }) || (this.client.logger.error(z2, "Signature verification failed"), oe2(tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"))); + const { p: he2 } = z2, pe2 = Qr(he2.resources), fe2 = [fu(he2.iss)], Ze2 = Li(he2.iss); + if (pe2) { + const de2 = du(pe2), et2 = pu(pe2); + le2.push(...de2), fe2.push(...et2); + } + for (const de2 of fe2) + Ie.push(`${de2}:${Ze2}`); + } + const W2 = await this.client.core.crypto.generateSharedKey(w3, Q2.publicKey); + let Z2; + le2.length > 0 && (Z2 = { topic: W2, acknowledged: true, self: { publicKey: w3, metadata: this.client.metadata }, peer: Q2, controller: Q2.publicKey, expiry: d0(L$2), requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: h4, namespaces: ju([...new Set(le2)], [...new Set(Ie)]) }, await this.client.core.relayer.subscribe(W2), await this.client.session.set(W2, Z2), Z2 = this.client.session.get(W2)), j2({ auths: _3, session: Z2 }); + }, M2 = payloadId(), ce2 = payloadId(); + this.events.once(v0("session_connect"), B2), this.events.once(v0("session_request", M2), ae2); + try { + await Promise.all([this.sendRequest({ topic: h4, method: "wc_sessionAuthenticate", params: E2, expiry: t2.expiry, throwOnFailedPublish: true, clientRpcId: M2 }), this.sendRequest({ topic: h4, method: "wc_sessionPropose", params: f3, expiry: q$1.wc_sessionPropose.req.ttl, throwOnFailedPublish: true, clientRpcId: ce2 })]); + } catch (O3) { + throw this.events.off(v0("session_connect"), B2), this.events.off(v0("session_request", M2), ae2), O3; } - }, this.find = (e) => (this.isInitialized(), this.client.session.getAll().filter((s2) => Mt$1(s2, e))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.cleanupDuplicatePairings = async (e) => { - if (e.pairingTopic) + return await this.setProposal(ce2, m2({ id: ce2 }, f3)), await this.client.auth.requests.set(M2, { authPayload: E2.authPayload, requester: E2.requester, expiryTimestamp: D2, id: M2, pairingTopic: h4, verifyContext: {} }), { uri: y3, response: v3 }; + }, this.approveSessionAuthenticate = async (t2) => { + this.isInitialized(); + const { id: e2, auths: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o2 }, d5 = [], p2 = []; + for (const y3 of s2) { + if (!await ou({ cacao: y3, projectId: this.client.core.projectId })) { + const P2 = tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"); + throw await this.sendError({ id: e2, topic: a3, error: P2, encodeOpts: c2 }), new Error(P2.message); + } + const { p: w3 } = y3, I2 = Qr(w3.resources), D2 = [fu(w3.iss)], E2 = Li(w3.iss); + if (I2) { + const P2 = du(I2), f3 = pu(I2); + d5.push(...P2), D2.push(...f3); + } + for (const P2 of D2) + p2.push(`${P2}:${E2}`); + } + const g3 = await this.client.core.crypto.generateSharedKey(o2, r3); + let h4; + return (d5 == null ? void 0 : d5.length) > 0 && (h4 = { topic: g3, acknowledged: true, self: { publicKey: o2, metadata: this.client.metadata }, peer: { publicKey: r3, metadata: i2.requester.metadata }, controller: r3, expiry: d0(L$2), authentication: s2, requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: "", namespaces: ju([...new Set(d5)], [...new Set(p2)]) }, await this.client.core.relayer.subscribe(g3), await this.client.session.set(g3, h4)), await this.sendResult({ topic: a3, id: e2, result: { cacaos: s2, responder: { publicKey: o2, metadata: this.client.metadata } }, encodeOpts: c2, throwOnFailedPublish: true }), await this.client.auth.requests.delete(e2, { message: "fullfilled", code: 0 }), await this.client.core.pairing.activate({ topic: i2.pairingTopic }), { session: h4 }; + }, this.rejectSessionAuthenticate = async (t2) => { + await this.isInitialized(); + const { id: e2, reason: s2 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o2 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o2 }; + await this.sendError({ id: e2, topic: a3, error: s2, encodeOpts: c2 }), await this.client.auth.requests.delete(e2, { message: "rejected", code: 0 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")); + }, this.formatAuthMessage = (t2) => { + this.isInitialized(); + const { request: e2, iss: s2 } = t2; + return zf(e2, s2); + }, this.cleanupDuplicatePairings = async (t2) => { + if (t2.pairingTopic) try { - const s2 = this.client.core.pairing.pairings.get(e.pairingTopic), t2 = this.client.core.pairing.pairings.getAll().filter((i2) => { - var n3, o2; - return ((n3 = i2.peerMetadata) == null ? void 0 : n3.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === e.peer.metadata.url && i2.topic && i2.topic !== s2.topic; + const e2 = this.client.core.pairing.pairings.get(t2.pairingTopic), s2 = this.client.core.pairing.pairings.getAll().filter((i2) => { + var r3, o2; + return ((r3 = i2.peerMetadata) == null ? void 0 : r3.url) && ((o2 = i2.peerMetadata) == null ? void 0 : o2.url) === t2.peer.metadata.url && i2.topic && i2.topic !== e2.topic; }); - if (t2.length === 0) + if (s2.length === 0) return; - this.client.logger.info(`Cleaning up ${t2.length} duplicate pairing(s)`), await Promise.all(t2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.deleteSession = async (e) => { - const { topic: s2, expirerHasDeleted: t2 = false, emitEvent: i2 = true, id: n3 = 0 } = e, { self: o2 } = this.client.session.get(s2); - await this.client.core.relayer.unsubscribe(s2), await this.client.session.delete(s2, U$2("USER_DISCONNECTED")), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(s2) && await this.client.core.crypto.deleteSymKey(s2), t2 || this.client.core.expirer.del(s2), this.client.core.storage.removeItem(H).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { - a3.topic === s2 && this.deletePendingSessionRequest(a3.id, U$2("USER_DISCONNECTED")); - }), i2 && this.client.events.emit("session_delete", { id: n3, topic: s2 }); - }, this.deleteProposal = async (e, s2) => { - await Promise.all([this.client.proposal.delete(e, U$2("USER_DISCONNECTED")), s2 ? Promise.resolve() : this.client.core.expirer.del(e)]); - }, this.deletePendingSessionRequest = async (e, s2, t2 = false) => { - await Promise.all([this.client.pendingRequest.delete(e, s2), t2 ? Promise.resolve() : this.client.core.expirer.del(e)]), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== e), t2 && (this.sessionRequestQueue.state = I.idle, this.client.events.emit("session_request_expire", { id: e })); - }, this.setExpiry = async (e, s2) => { - this.client.session.keys.includes(e) && await this.client.session.update(e, { expiry: s2 }), this.client.core.expirer.set(e, s2); - }, this.setProposal = async (e, s2) => { - await this.client.proposal.set(e, s2), this.client.core.expirer.set(e, pt$1(R.wc_sessionPropose.req.ttl)); - }, this.setPendingSessionRequest = async (e) => { - const { id: s2, topic: t2, params: i2, verifyContext: n3 } = e, o2 = i2.request.expiryTimestamp || pt$1(R.wc_sessionRequest.req.ttl); - await this.client.pendingRequest.set(s2, { id: s2, topic: t2, params: i2, verifyContext: n3 }), o2 && this.client.core.expirer.set(s2, o2); - }, this.sendRequest = async (e) => { - const { topic: s2, method: t2, params: i2, expiry: n3, relayRpcId: o2, clientRpcId: a3, throwOnFailedPublish: c2 } = e, p3 = formatJsonRpcRequest(t2, i2, a3); - if (D$2() && he.includes(t2)) { - const N2 = Ln(JSON.stringify(p3)); - this.client.core.verify.register({ attestationId: N2 }); - } - const d3 = await this.client.core.crypto.encode(s2, p3), h4 = R[t2].req; - return n3 && (h4.ttl = n3), o2 && (h4.id = o2), this.client.core.history.set(s2, p3), c2 ? (h4.internal = D(g$1({}, h4.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, d3, h4)) : this.client.core.relayer.publish(s2, d3, h4).catch((N2) => this.client.logger.error(N2)), p3.id; - }, this.sendResult = async (e) => { - const { id: s2, topic: t2, result: i2, throwOnFailedPublish: n3 } = e, o2 = formatJsonRpcResult(s2, i2), a3 = await this.client.core.crypto.encode(t2, o2), c2 = await this.client.core.history.get(t2, s2), p3 = R[c2.request.method].res; - n3 ? (p3.internal = D(g$1({}, p3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(t2, a3, p3)) : this.client.core.relayer.publish(t2, a3, p3).catch((d3) => this.client.logger.error(d3)), await this.client.core.history.resolve(o2); - }, this.sendError = async (e, s2, t2) => { - const i2 = formatJsonRpcError(e, t2), n3 = await this.client.core.crypto.encode(s2, i2), o2 = await this.client.core.history.get(s2, e), a3 = R[o2.request.method].res; - this.client.core.relayer.publish(s2, n3, a3), await this.client.core.history.resolve(i2); + this.client.logger.info(`Cleaning up ${s2.length} duplicate pairing(s)`), await Promise.all(s2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.deleteSession = async (t2) => { + const { topic: e2, expirerHasDeleted: s2 = false, emitEvent: i2 = true, id: r3 = 0 } = t2, { self: o2 } = this.client.session.get(e2); + await this.client.core.relayer.unsubscribe(e2), await this.client.session.delete(e2, tr$2("USER_DISCONNECTED")), this.addToRecentlyDeleted(e2, "session"), this.client.core.crypto.keychain.has(o2.publicKey) && await this.client.core.crypto.deleteKeyPair(o2.publicKey), this.client.core.crypto.keychain.has(e2) && await this.client.core.crypto.deleteSymKey(e2), s2 || this.client.core.expirer.del(e2), this.client.core.storage.removeItem(Re$1).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { + a3.topic === e2 && this.deletePendingSessionRequest(a3.id, tr$2("USER_DISCONNECTED")); + }), i2 && this.client.events.emit("session_delete", { id: r3, topic: e2 }); + }, this.deleteProposal = async (t2, e2) => { + await Promise.all([this.client.proposal.delete(t2, tr$2("USER_DISCONNECTED")), e2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "proposal"); + }, this.deletePendingSessionRequest = async (t2, e2, s2 = false) => { + await Promise.all([this.client.pendingRequest.delete(t2, e2), s2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== t2), s2 && (this.sessionRequestQueue.state = A$1.idle, this.client.events.emit("session_request_expire", { id: t2 })); + }, this.setExpiry = async (t2, e2) => { + this.client.session.keys.includes(t2) && await this.client.session.update(t2, { expiry: e2 }), this.client.core.expirer.set(t2, e2); + }, this.setProposal = async (t2, e2) => { + await this.client.proposal.set(t2, e2), this.client.core.expirer.set(t2, d0(q$1.wc_sessionPropose.req.ttl)); + }, this.setPendingSessionRequest = async (t2) => { + const { id: e2, topic: s2, params: i2, verifyContext: r3 } = t2, o2 = i2.request.expiryTimestamp || d0(q$1.wc_sessionRequest.req.ttl); + await this.client.pendingRequest.set(e2, { id: e2, topic: s2, params: i2, verifyContext: r3 }), o2 && this.client.core.expirer.set(e2, o2); + }, this.sendRequest = async (t2) => { + const { topic: e2, method: s2, params: i2, expiry: r3, relayRpcId: o2, clientRpcId: a3, throwOnFailedPublish: c2 } = t2, d5 = formatJsonRpcRequest(s2, i2, a3); + if (pr$1() && je.includes(s2)) { + const h4 = yu(JSON.stringify(d5)); + this.client.core.verify.register({ attestationId: h4 }); + } + let p2; + try { + p2 = await this.client.core.crypto.encode(e2, d5); + } catch (h4) { + throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e2} failed`), h4; + } + const g3 = q$1[s2].req; + return r3 && (g3.ttl = r3), o2 && (g3.id = o2), this.client.core.history.set(e2, d5), c2 ? (g3.internal = F(m2({}, g3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(e2, p2, g3)) : this.client.core.relayer.publish(e2, p2, g3).catch((h4) => this.client.logger.error(h4)), d5.id; + }, this.sendResult = async (t2) => { + const { id: e2, topic: s2, result: i2, throwOnFailedPublish: r3, encodeOpts: o2 } = t2, a3 = formatJsonRpcResult(e2, i2); + let c2; + try { + c2 = await this.client.core.crypto.encode(s2, a3, o2); + } catch (g3) { + throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s2} failed`), g3; + } + let d5; + try { + d5 = await this.client.core.history.get(s2, e2); + } catch (g3) { + throw this.client.logger.error(`sendResult() -> history.get(${s2}, ${e2}) failed`), g3; + } + const p2 = q$1[d5.request.method].res; + r3 ? (p2.internal = F(m2({}, p2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, c2, p2)) : this.client.core.relayer.publish(s2, c2, p2).catch((g3) => this.client.logger.error(g3)), await this.client.core.history.resolve(a3); + }, this.sendError = async (t2) => { + const { id: e2, topic: s2, error: i2, encodeOpts: r3 } = t2, o2 = formatJsonRpcError(e2, i2); + let a3; + try { + a3 = await this.client.core.crypto.encode(s2, o2, r3); + } catch (p2) { + throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s2} failed`), p2; + } + let c2; + try { + c2 = await this.client.core.history.get(s2, e2); + } catch (p2) { + throw this.client.logger.error(`sendError() -> history.get(${s2}, ${e2}) failed`), p2; + } + const d5 = q$1[c2.request.method].res; + this.client.core.relayer.publish(s2, a3, d5), await this.client.core.history.resolve(o2); }, this.cleanup = async () => { - const e = [], s2 = []; - this.client.session.getAll().forEach((t2) => { + const t2 = [], e2 = []; + this.client.session.getAll().forEach((s2) => { let i2 = false; - mt$1(t2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(t2.topic) || (i2 = true), i2 && e.push(t2.topic); - }), this.client.proposal.getAll().forEach((t2) => { - mt$1(t2.expiryTimestamp) && s2.push(t2.id); - }), await Promise.all([...e.map((t2) => this.deleteSession({ topic: t2 })), ...s2.map((t2) => this.deleteProposal(t2))]); - }, this.onRelayEventRequest = async (e) => { - this.requestQueue.queue.push(e), await this.processRequestsQueue(); + p0(s2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(s2.topic) || (i2 = true), i2 && t2.push(s2.topic); + }), this.client.proposal.getAll().forEach((s2) => { + p0(s2.expiryTimestamp) && e2.push(s2.id); + }), await Promise.all([...t2.map((s2) => this.deleteSession({ topic: s2 })), ...e2.map((s2) => this.deleteProposal(s2))]); + }, this.onRelayEventRequest = async (t2) => { + this.requestQueue.queue.push(t2), await this.processRequestsQueue(); }, this.processRequestsQueue = async () => { - if (this.requestQueue.state === I.active) { + if (this.requestQueue.state === A$1.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 = I.active; - const e = this.requestQueue.queue.shift(); - if (e) + this.requestQueue.state = A$1.active; + const t2 = this.requestQueue.queue.shift(); + if (t2) try { - this.processRequest(e), await new Promise((s2) => setTimeout(s2, 300)); - } catch (s2) { - this.client.logger.warn(s2); + this.processRequest(t2), await new Promise((e2) => setTimeout(e2, 300)); + } catch (e2) { + this.client.logger.warn(e2); } } - this.requestQueue.state = I.idle; - }, this.processRequest = (e) => { - const { topic: s2, payload: t2 } = e, i2 = t2.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeRequest(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleRequest(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateRequest(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendRequest(s2, t2); - case "wc_sessionPing": - return this.onSessionPingRequest(s2, t2); - case "wc_sessionDelete": - return this.onSessionDeleteRequest(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequest(s2, t2); - case "wc_sessionEvent": - return this.onSessionEventRequest(s2, t2); - default: - return this.client.logger.info(`Unsupported request method ${i2}`); - } - }, this.onRelayEventResponse = async (e) => { - const { topic: s2, payload: t2 } = e, i2 = (await this.client.core.history.get(s2, t2.id)).request.method; + this.requestQueue.state = A$1.idle; + }, this.processRequest = (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = s2.method; + if (!this.shouldIgnorePairingRequest({ topic: e2, requestMethod: i2 })) + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeRequest(e2, s2); + case "wc_sessionSettle": + return this.onSessionSettleRequest(e2, s2); + case "wc_sessionUpdate": + return this.onSessionUpdateRequest(e2, s2); + case "wc_sessionExtend": + return this.onSessionExtendRequest(e2, s2); + case "wc_sessionPing": + return this.onSessionPingRequest(e2, s2); + case "wc_sessionDelete": + return this.onSessionDeleteRequest(e2, s2); + case "wc_sessionRequest": + return this.onSessionRequest(e2, s2); + case "wc_sessionEvent": + return this.onSessionEventRequest(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateRequest(e2, s2); + default: + return this.client.logger.info(`Unsupported request method ${i2}`); + } + }, this.onRelayEventResponse = async (t2) => { + const { topic: e2, payload: s2 } = t2, i2 = (await this.client.core.history.get(e2, s2.id)).request.method; switch (i2) { case "wc_sessionPropose": - return this.onSessionProposeResponse(s2, t2); + return this.onSessionProposeResponse(e2, s2); case "wc_sessionSettle": - return this.onSessionSettleResponse(s2, t2); + return this.onSessionSettleResponse(e2, s2); case "wc_sessionUpdate": - return this.onSessionUpdateResponse(s2, t2); + return this.onSessionUpdateResponse(e2, s2); case "wc_sessionExtend": - return this.onSessionExtendResponse(s2, t2); + return this.onSessionExtendResponse(e2, s2); case "wc_sessionPing": - return this.onSessionPingResponse(s2, t2); + return this.onSessionPingResponse(e2, s2); case "wc_sessionRequest": - return this.onSessionRequestResponse(s2, t2); + return this.onSessionRequestResponse(e2, s2); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateResponse(e2, s2); default: return this.client.logger.info(`Unsupported response method ${i2}`); } - }, this.onRelayEventUnknownPayload = (e) => { - const { topic: s2 } = e, { message: t2 } = N$1("MISSING_OR_INVALID", `Decoded payload on topic ${s2} is not identifiable as a JSON-RPC request or a response.`); - throw new Error(t2); - }, this.onSessionProposeRequest = async (e, s2) => { - const { params: t2, id: i2 } = s2; + }, this.onRelayEventUnknownPayload = (t2) => { + const { topic: e2 } = t2, { message: s2 } = xe("MISSING_OR_INVALID", `Decoded payload on topic ${e2} is not identifiable as a JSON-RPC request or a response.`); + throw new Error(s2); + }, this.shouldIgnorePairingRequest = (t2) => { + const { topic: e2, requestMethod: s2 } = t2, i2 = this.expectedPairingMethodMap.get(e2); + return !i2 || i2.includes(s2) ? false : !!(i2.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0); + }, this.onSessionProposeRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; try { - this.isValidConnect(g$1({}, s2.params)); - const n3 = t2.expiryTimestamp || pt$1(R.wc_sessionPropose.req.ttl), o2 = g$1({ id: i2, pairingTopic: e, expiryTimestamp: n3 }, t2); + this.isValidConnect(m2({}, e2.params)); + const r3 = s2.expiryTimestamp || d0(q$1.wc_sessionPropose.req.ttl), o2 = m2({ id: i2, pairingTopic: t2, expiryTimestamp: r3 }, s2); await this.setProposal(i2, o2); - const a3 = Ln(JSON.stringify(s2)), c2 = await this.getVerifyContext(a3, o2.proposer.metadata); + const a3 = yu(JSON.stringify(e2)), c2 = await this.getVerifyContext(a3, o2.proposer.metadata); this.client.events.emit("session_proposal", { id: i2, params: o2, verifyContext: c2 }); - } catch (n3) { - await this.sendError(i2, e, n3), this.client.logger.error(n3); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); } - }, this.onSessionProposeResponse = async (e, s2) => { - const { id: t2 } = s2; - if (isJsonRpcResult(s2)) { - const { result: i2 } = s2; + }, this.onSessionProposeResponse = async (t2, e2) => { + const { id: s2 } = e2; + if (isJsonRpcResult(e2)) { + const { result: i2 } = e2; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); - const n3 = this.client.proposal.get(t2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: n3 }); - const o2 = n3.proposer.publicKey; + const r3 = this.client.proposal.get(s2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: r3 }); + const o2 = r3.proposer.publicKey; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o2 }); const a3 = i2.responderPublicKey; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a3 }); const c2 = await this.client.core.crypto.generateSharedKey(o2, a3); this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); - const p3 = await this.client.core.relayer.subscribe(c2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: p3 }), await this.client.core.pairing.activate({ topic: e }); - } else - isJsonRpcError(s2) && (await this.client.proposal.delete(t2, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_connect"), { error: s2.error })); - }, this.onSessionSettleRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; + const d5 = await this.client.core.relayer.subscribe(c2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: d5 }), await this.client.core.pairing.activate({ topic: t2 }); + } else if (isJsonRpcError(e2)) { + await this.client.proposal.delete(s2, tr$2("USER_DISCONNECTED")); + const i2 = v0("session_connect"); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners, 954`); + this.events.emit(v0("session_connect"), { error: e2.error }); + } + }, this.onSessionSettleRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; try { this.isValidSessionSettleRequest(i2); - const { relay: n3, controller: o2, expiry: a3, namespaces: c2, sessionProperties: p3, pairingTopic: d3 } = s2.params, h4 = g$1({ topic: e, relay: n3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: d3, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, p3 && { sessionProperties: p3 }); - await this.sendResult({ id: s2.id, topic: e, result: true }), this.events.emit(yt$1("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionSettleResponse = async (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? (await this.client.session.update(e, { acknowledged: true }), this.events.emit(yt$1("session_approve", t2), {})) : isJsonRpcError(s2) && (await this.client.session.delete(e, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_approve", t2), { error: s2.error })); - }, this.onSessionUpdateRequest = async (e, s2) => { - const { params: t2, id: i2 } = s2; + const { relay: r3, controller: o2, expiry: a3, namespaces: c2, sessionProperties: d5, pairingTopic: p2, sessionConfig: g3 } = e2.params, h4 = m2(m2({ topic: t2, relay: r3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: p2, requiredNamespaces: {}, optionalNamespaces: {}, controller: o2.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o2.publicKey, metadata: o2.metadata } }, d5 && { sessionProperties: d5 }), g3 && { sessionConfig: g3 }); + await this.sendResult({ id: e2.id, topic: t2, result: true, throwOnFailedPublish: true }); + const y3 = v0("session_connect"); + if (this.events.listenerCount(y3) === 0) + throw new Error(`emitting ${y3} without any listeners 997`); + this.events.emit(v0("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionSettleResponse = async (t2, e2) => { + const { id: s2 } = e2; + isJsonRpcResult(e2) ? (await this.client.session.update(t2, { acknowledged: true }), this.events.emit(v0("session_approve", s2), {})) : isJsonRpcError(e2) && (await this.client.session.delete(t2, tr$2("USER_DISCONNECTED")), this.events.emit(v0("session_approve", s2), { error: e2.error })); + }, this.onSessionUpdateRequest = async (t2, e2) => { + const { params: s2, id: i2 } = e2; try { - const n3 = `${e}_session_update`, o2 = sr$1.get(n3); + const r3 = `${t2}_session_update`, o2 = lh.get(r3); if (o2 && this.isRequestOutOfSync(o2, i2)) { - this.client.logger.info(`Discarding out of sync request - ${i2}`); + this.client.logger.info(`Discarding out of sync request - ${i2}`), this.sendError({ id: i2, topic: t2, error: tr$2("INVALID_UPDATE_REQUEST") }); return; } - this.isValidUpdate(g$1({ topic: e }, t2)), await this.client.session.update(e, { namespaces: t2.namespaces }), await this.sendResult({ id: i2, topic: e, result: true }), this.client.events.emit("session_update", { id: i2, topic: e, params: t2 }), sr$1.set(n3, i2); - } catch (n3) { - await this.sendError(i2, e, n3), this.client.logger.error(n3); - } - }, this.isRequestOutOfSync = (e, s2) => parseInt(s2.toString().slice(0, -3)) <= parseInt(e.toString().slice(0, -3)), this.onSessionUpdateResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_update", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_update", t2), { error: s2.error }); - }, this.onSessionExtendRequest = async (e, s2) => { - const { id: t2 } = s2; + this.isValidUpdate(m2({ topic: t2 }, s2)); + try { + lh.set(r3, i2), await this.client.session.update(t2, { namespaces: s2.namespaces }), await this.sendResult({ id: i2, topic: t2, result: true, throwOnFailedPublish: true }); + } catch (a3) { + throw lh.delete(r3), a3; + } + this.client.events.emit("session_update", { id: i2, topic: t2, params: s2 }); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.isRequestOutOfSync = (t2, e2) => parseInt(e2.toString().slice(0, -3)) <= parseInt(t2.toString().slice(0, -3)), this.onSessionUpdateResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_update", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_update", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_update", s2), { error: e2.error }); + }, this.onSessionExtendRequest = async (t2, e2) => { + const { id: s2 } = e2; try { - this.isValidExtend({ topic: e }), await this.setExpiry(e, pt$1(L)), await this.sendResult({ id: t2, topic: e, result: true }), this.client.events.emit("session_extend", { id: t2, topic: e }); + this.isValidExtend({ topic: t2 }), await this.setExpiry(t2, d0(L$2)), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_extend", { id: s2, topic: t2 }); } catch (i2) { - await this.sendError(t2, e, i2), this.client.logger.error(i2); - } - }, this.onSessionExtendResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_extend", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_extend", t2), { error: s2.error }); - }, this.onSessionPingRequest = async (e, s2) => { - const { id: t2 } = s2; + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionExtendResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_extend", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_extend", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_extend", s2), { error: e2.error }); + }, this.onSessionPingRequest = async (t2, e2) => { + const { id: s2 } = e2; try { - this.isValidPing({ topic: e }), await this.sendResult({ id: t2, topic: e, result: true }), this.client.events.emit("session_ping", { id: t2, topic: e }); + this.isValidPing({ topic: t2 }), await this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_ping", { id: s2, topic: t2 }); } catch (i2) { - await this.sendError(t2, e, i2), this.client.logger.error(i2); + await this.sendError({ id: s2, topic: t2, error: i2 }), this.client.logger.error(i2); } - }, this.onSessionPingResponse = (e, s2) => { - const { id: t2 } = s2; + }, this.onSessionPingResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_ping", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_ping", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_ping", t2), { error: s2.error }); + isJsonRpcResult(e2) ? this.events.emit(v0("session_ping", s2), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_ping", s2), { error: e2.error }); }, 500); - }, this.onSessionDeleteRequest = async (e, s2) => { - const { id: t2 } = s2; + }, this.onSessionDeleteRequest = async (t2, e2) => { + const { id: s2 } = e2; try { - this.isValidDisconnect({ topic: e, reason: s2.params }), await Promise.all([new Promise((i2) => { - this.client.core.relayer.once(D$1.publish, async () => { - i2(await this.deleteSession({ topic: e, id: t2 })); + this.isValidDisconnect({ topic: t2, reason: e2.params }), await Promise.all([new Promise((i2) => { + this.client.core.relayer.once(v2.publish, async () => { + i2(await this.deleteSession({ topic: t2, id: s2 })); }); - }), this.sendResult({ id: t2, topic: e, result: true }), this.cleanupPendingSentRequestsForTopic({ topic: e, error: U$2("USER_DISCONNECTED") })]); + }), this.sendResult({ id: s2, topic: t2, result: true, throwOnFailedPublish: true }), this.cleanupPendingSentRequestsForTopic({ topic: t2, error: tr$2("USER_DISCONNECTED") })]); } catch (i2) { this.client.logger.error(i2); } - }, this.onSessionRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; + }, this.onSessionRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; try { - this.isValidRequest(g$1({ topic: e }, i2)); - const n3 = Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, t2))), o2 = this.client.session.get(e), a3 = await this.getVerifyContext(n3, o2.peer.metadata), c2 = { id: t2, topic: e, params: i2, verifyContext: a3 }; + await this.isValidRequest(m2({ topic: t2 }, i2)); + const r3 = yu(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, s2))), o2 = this.client.session.get(t2), a3 = await this.getVerifyContext(r3, o2.peer.metadata), c2 = { id: s2, topic: t2, params: i2, verifyContext: a3 }; await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.onSessionRequestResponse = (e, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_request", t2), { result: s2.result }) : isJsonRpcError(s2) && this.events.emit(yt$1("session_request", t2), { error: s2.error }); - }, this.onSessionEventRequest = async (e, s2) => { - const { id: t2, params: i2 } = s2; + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionRequestResponse = (t2, e2) => { + const { id: s2 } = e2, i2 = v0("session_request", s2); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionEventRequest = async (t2, e2) => { + const { id: s2, params: i2 } = e2; try { - const n3 = `${e}_session_event_${i2.event.name}`, o2 = sr$1.get(n3); - if (o2 && this.isRequestOutOfSync(o2, t2)) { - this.client.logger.info(`Discarding out of sync request - ${t2}`); + const r3 = `${t2}_session_event_${i2.event.name}`, o2 = lh.get(r3); + if (o2 && this.isRequestOutOfSync(o2, s2)) { + this.client.logger.info(`Discarding out of sync request - ${s2}`); return; } - this.isValidEmit(g$1({ topic: e }, i2)), this.client.events.emit("session_event", { id: t2, topic: e, params: i2 }), sr$1.set(n3, t2); - } catch (n3) { - await this.sendError(t2, e, n3), this.client.logger.error(n3); - } - }, this.addSessionRequestToSessionRequestQueue = (e) => { - this.sessionRequestQueue.queue.push(e); - }, this.cleanupAfterResponse = (e) => { - this.deletePendingSessionRequest(e.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { - this.sessionRequestQueue.state = I.idle, this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay)); - }, this.cleanupPendingSentRequestsForTopic = ({ topic: e, error: s2 }) => { - const t2 = this.client.core.history.pending; - t2.length > 0 && t2.filter((i2) => i2.topic === e && i2.request.method === "wc_sessionRequest").forEach((i2) => { - this.events.emit(yt$1("session_request", i2.request.id), { error: s2 }); + this.isValidEmit(m2({ topic: t2 }, i2)), this.client.events.emit("session_event", { id: s2, topic: t2, params: i2 }), lh.set(r3, s2); + } catch (r3) { + await this.sendError({ id: s2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionAuthenticateResponse = (t2, e2) => { + const { id: s2 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionAuthenticateResponse", topic: t2, payload: e2 }), isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s2), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s2), { error: e2.error }); + }, this.onSessionAuthenticateRequest = async (t2, e2) => { + const { requester: s2, authPayload: i2, expiryTimestamp: r3 } = e2.params, o2 = yu(JSON.stringify(e2)), a3 = await this.getVerifyContext(o2, this.client.metadata), c2 = { requester: s2, pairingTopic: t2, id: e2.id, authPayload: i2, verifyContext: a3, expiryTimestamp: r3 }; + await this.client.auth.requests.set(e2.id, c2), this.client.events.emit("session_authenticate", { topic: t2, params: e2.params, id: e2.id }); + }, this.addSessionRequestToSessionRequestQueue = (t2) => { + this.sessionRequestQueue.queue.push(t2); + }, this.cleanupAfterResponse = (t2) => { + this.deletePendingSessionRequest(t2.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { + this.sessionRequestQueue.state = A$1.idle, this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay)); + }, this.cleanupPendingSentRequestsForTopic = ({ topic: t2, error: e2 }) => { + const s2 = this.client.core.history.pending; + s2.length > 0 && s2.filter((i2) => i2.topic === t2 && i2.request.method === "wc_sessionRequest").forEach((i2) => { + const r3 = i2.request.id, o2 = v0("session_request", r3); + if (this.events.listenerCount(o2) === 0) + throw new Error(`emitting ${o2} without any listeners`); + this.events.emit(v0("session_request", i2.request.id), { error: e2 }); }); }, this.processSessionRequestQueue = () => { - if (this.sessionRequestQueue.state === I.active) { + if (this.sessionRequestQueue.state === A$1.active) { this.client.logger.info("session request queue is already active."); return; } - const e = this.sessionRequestQueue.queue[0]; - if (!e) { + const t2 = this.sessionRequestQueue.queue[0]; + if (!t2) { this.client.logger.info("session request queue is empty."); return; } try { - this.sessionRequestQueue.state = I.active, this.client.events.emit("session_request", e); - } catch (s2) { - this.client.logger.error(s2); + this.sessionRequestQueue.state = A$1.active, this.client.events.emit("session_request", t2); + } catch (e2) { + this.client.logger.error(e2); } - }, this.onPairingCreated = (e) => { - if (e.active) + }, this.onPairingCreated = (t2) => { + if (t2.methods && this.expectedPairingMethodMap.set(t2.topic, t2.methods), t2.active) return; - const s2 = this.client.proposal.getAll().find((t2) => t2.pairingTopic === e.topic); - s2 && this.onSessionProposeRequest(e.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: s2.requiredNamespaces, optionalNamespaces: s2.optionalNamespaces, relays: s2.relays, proposer: s2.proposer, sessionProperties: s2.sessionProperties }, s2.id)); - }, this.isValidConnect = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(e)}`); + const e2 = this.client.proposal.getAll().find((s2) => s2.pairingTopic === t2.topic); + e2 && this.onSessionProposeRequest(t2.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: e2.requiredNamespaces, optionalNamespaces: e2.optionalNamespaces, relays: e2.relays, proposer: e2.proposer, sessionProperties: e2.sessionProperties }, e2.id)); + }, this.isValidConnect = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(t2)}`); throw new Error(a3); } - const { pairingTopic: s2, requiredNamespaces: t2, optionalNamespaces: i2, sessionProperties: n3, relays: o2 } = e; - if (w$3(s2) || await this.isValidPairingTopic(s2), !qt$1(o2, true)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() relays: ${o2}`); + const { pairingTopic: e2, requiredNamespaces: s2, optionalNamespaces: i2, sessionProperties: r3, relays: o2 } = t2; + if (Pe(e2) || await this.isValidPairingTopic(e2), !Xu(o2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `connect() relays: ${o2}`); throw new Error(a3); } - !w$3(t2) && B$1(t2) !== 0 && this.validateNamespaces(t2, "requiredNamespaces"), !w$3(i2) && B$1(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.validateNamespaces = (e, s2) => { - const t2 = Ht$1(e, "connect()", s2); - if (t2) - throw new Error(t2.message); - }, this.isValidApprove = async (e) => { - if (!Gt$1(e)) - throw new Error(N$1("MISSING_OR_INVALID", `approve() params: ${e}`).message); - const { id: s2, namespaces: t2, relayProtocol: i2, sessionProperties: n3 } = e; - await this.isValidProposalId(s2); - const o2 = this.client.proposal.get(s2), a3 = ln(t2, "approve()"); + !Pe(s2) && Yr(s2) !== 0 && this.validateNamespaces(s2, "requiredNamespaces"), !Pe(i2) && Yr(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), Pe(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.validateNamespaces = (t2, e2) => { + const s2 = Wu(t2, "connect()", e2); + if (s2) + throw new Error(s2.message); + }, this.isValidApprove = async (t2) => { + if (!$u(t2)) + throw new Error(xe("MISSING_OR_INVALID", `approve() params: ${t2}`).message); + const { id: e2, namespaces: s2, relayProtocol: i2, sessionProperties: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2); + const o2 = this.client.proposal.get(e2), a3 = So(s2, "approve()"); if (a3) throw new Error(a3.message); - const c2 = fn(o2.requiredNamespaces, t2, "approve()"); + const c2 = Io(o2.requiredNamespaces, s2, "approve()"); if (c2) throw new Error(c2.message); - if (!g$3(i2, true)) { - const { message: p3 } = N$1("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); - throw new Error(p3); - } - w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.isValidReject = async (e) => { - if (!Gt$1(e)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() params: ${e}`); + if (!Gt$1(i2, true)) { + const { message: d5 } = xe("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); + throw new Error(d5); + } + Pe(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.isValidReject = async (t2) => { + if (!$u(t2)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `reject() params: ${t2}`); throw new Error(i2); } - const { id: s2, reason: t2 } = e; - if (await this.isValidProposalId(s2), !Wt(t2)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(t2)}`); + const { id: e2, reason: s2 } = t2; + if (this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2), !th(s2)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(s2)}`); throw new Error(i2); } - }, this.isValidSessionSettleRequest = (e) => { - if (!Gt$1(e)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${e}`); + }, this.isValidSessionSettleRequest = (t2) => { + if (!$u(t2)) { + const { message: c2 } = xe("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${t2}`); throw new Error(c2); } - const { relay: s2, controller: t2, namespaces: i2, expiry: n3 } = e; - if (!dn(s2)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); + const { relay: e2, controller: s2, namespaces: i2, expiry: r3 } = t2; + if (!No(e2)) { + const { message: c2 } = xe("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); throw new Error(c2); } - const o2 = Ft$1(t2, "onSessionSettleRequest()"); + const o2 = Vu(s2, "onSessionSettleRequest()"); if (o2) throw new Error(o2.message); - const a3 = ln(i2, "onSessionSettleRequest()"); + const a3 = So(i2, "onSessionSettleRequest()"); if (a3) throw new Error(a3.message); - if (mt$1(n3)) { - const { message: c2 } = N$1("EXPIRED", "onSessionSettleRequest()"); + if (p0(r3)) { + const { message: c2 } = xe("EXPIRED", "onSessionSettleRequest()"); throw new Error(c2); } - }, this.isValidUpdate = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `update() params: ${e}`); + }, this.isValidUpdate = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `update() params: ${t2}`); throw new Error(a3); } - const { topic: s2, namespaces: t2 } = e; - await this.isValidSessionTopic(s2); - const i2 = this.client.session.get(s2), n3 = ln(t2, "update()"); - if (n3) - throw new Error(n3.message); - const o2 = fn(i2.requiredNamespaces, t2, "update()"); + const { topic: e2, namespaces: s2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const i2 = this.client.session.get(e2), r3 = So(s2, "update()"); + if (r3) + throw new Error(r3.message); + const o2 = Io(i2.requiredNamespaces, s2, "update()"); if (o2) throw new Error(o2.message); - }, this.isValidExtend = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `extend() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionTopic(s2); - }, this.isValidRequest = async (e) => { - if (!Gt$1(e)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() params: ${e}`); + }, this.isValidExtend = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `extend() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + }, this.isValidRequest = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() params: ${t2}`); throw new Error(a3); } - const { topic: s2, request: t2, chainId: i2, expiry: n3 } = e; - await this.isValidSessionTopic(s2); - const { namespaces: o2 } = this.client.session.get(s2); - if (!Qt(o2, i2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() chainId: ${i2}`); + const { topic: e2, request: s2, chainId: i2, expiry: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const { namespaces: o2 } = this.client.session.get(e2); + if (!nh(o2, i2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() chainId: ${i2}`); throw new Error(a3); } - if (!zt$1(t2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() ${JSON.stringify(t2)}`); + if (!eh(s2)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() ${JSON.stringify(s2)}`); throw new Error(a3); } - if (!Zt(o2, i2, t2.method)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() method: ${t2.method}`); + if (!fh(o2, i2, s2.method)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() method: ${s2.method}`); throw new Error(a3); } - if (n3 && !tr$1(n3, U$1)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() expiry: ${n3}. Expiry must be a number (in seconds) between ${U$1.min} and ${U$1.max}`); + if (r3 && !uh(r3, re$1)) { + const { message: a3 } = xe("MISSING_OR_INVALID", `request() expiry: ${r3}. Expiry must be a number (in seconds) between ${re$1.min} and ${re$1.max}`); throw new Error(a3); } - }, this.isValidRespond = async (e) => { - var s2; - if (!Gt$1(e)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() params: ${e}`); - throw new Error(n3); + }, this.isValidRespond = async (t2) => { + var e2; + if (!$u(t2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `respond() params: ${t2}`); + throw new Error(r3); } - const { topic: t2, response: i2 } = e; + const { topic: s2, response: i2 } = t2; try { - await this.isValidSessionTopic(t2); - } catch (n3) { - throw (s2 = e == null ? void 0 : e.response) != null && s2.id && this.cleanupAfterResponse(e), n3; - } - if (!Yt$1(i2)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); - throw new Error(n3); - } - }, this.isValidPing = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `ping() params: ${e}`); - throw new Error(t2); - } - const { topic: s2 } = e; - await this.isValidSessionOrPairingTopic(s2); - }, this.isValidEmit = async (e) => { - if (!Gt$1(e)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() params: ${e}`); + await this.isValidSessionTopic(s2); + } catch (r3) { + throw (e2 = t2 == null ? void 0 : t2.response) != null && e2.id && this.cleanupAfterResponse(t2), r3; + } + if (!rh(i2)) { + const { message: r3 } = xe("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); + throw new Error(r3); + } + }, this.isValidPing = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `ping() params: ${t2}`); + throw new Error(s2); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidEmit = async (t2) => { + if (!$u(t2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() params: ${t2}`); throw new Error(o2); } - const { topic: s2, event: t2, chainId: i2 } = e; - await this.isValidSessionTopic(s2); - const { namespaces: n3 } = this.client.session.get(s2); - if (!Qt(n3, i2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() chainId: ${i2}`); + const { topic: e2, event: s2, chainId: i2 } = t2; + await this.isValidSessionTopic(e2); + const { namespaces: r3 } = this.client.session.get(e2); + if (!nh(r3, i2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() chainId: ${i2}`); throw new Error(o2); } - if (!Jt$1(t2)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); + if (!ih(s2)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); throw new Error(o2); } - if (!Xt(n3, i2, t2.name)) { - const { message: o2 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); + if (!oh(r3, i2, s2.name)) { + const { message: o2 } = xe("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s2)}`); throw new Error(o2); } - }, this.isValidDisconnect = async (e) => { - if (!Gt$1(e)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${e}`); - throw new Error(t2); + }, this.isValidDisconnect = async (t2) => { + if (!$u(t2)) { + const { message: s2 } = xe("MISSING_OR_INVALID", `disconnect() params: ${t2}`); + throw new Error(s2); } - const { topic: s2 } = e; - await this.isValidSessionOrPairingTopic(s2); - }, this.getVerifyContext = async (e, s2) => { - const t2 = { verified: { verifyUrl: s2.verifyUrl || F$1, validation: "UNKNOWN", origin: s2.url || "" } }; + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidAuthenticate = (t2) => { + const { chains: e2, uri: s2, domain: i2, nonce: r3 } = t2; + if (!Array.isArray(e2) || e2.length === 0) + throw new Error("chains is required and must be a non-empty array"); + if (!Gt$1(s2, false)) + throw new Error("uri is required parameter"); + if (!Gt$1(i2, false)) + throw new Error("domain is required parameter"); + if (!Gt$1(r3, false)) + throw new Error("nonce is required parameter"); + if ([...new Set(e2.map((a3) => dn(a3).namespace))].length > 1) + throw new Error("Multi-namespace requests are not supported. Please request single namespace only."); + const { namespace: o2 } = dn(e2[0]); + if (o2 !== "eip155") + throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains."); + }, this.getVerifyContext = async (t2, e2) => { + const s2 = { verified: { verifyUrl: e2.verifyUrl || k$1, validation: "UNKNOWN", origin: e2.url || "" } }; try { - const i2 = await this.client.core.verify.resolve({ attestationId: e, verifyUrl: s2.verifyUrl }); - i2 && (t2.verified.origin = i2.origin, t2.verified.isScam = i2.isScam, t2.verified.validation = i2.origin === new URL(s2.url).origin ? "VALID" : "INVALID"); + const i2 = await this.client.core.verify.resolve({ attestationId: t2, verifyUrl: e2.verifyUrl }); + i2 && (s2.verified.origin = i2.origin, s2.verified.isScam = i2.isScam, s2.verified.validation = i2.origin === new URL(e2.url).origin ? "VALID" : "INVALID"); } catch (i2) { this.client.logger.info(i2); } - return this.client.logger.info(`Verify context: ${JSON.stringify(t2)}`), t2; - }, this.validateSessionProps = (e, s2) => { - Object.values(e).forEach((t2) => { - if (!g$3(t2, false)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `${s2} must be in Record format. Received: ${JSON.stringify(t2)}`); + return this.client.logger.info(`Verify context: ${JSON.stringify(s2)}`), s2; + }, this.validateSessionProps = (t2, e2) => { + Object.values(t2).forEach((s2) => { + if (!Gt$1(s2, false)) { + const { message: i2 } = xe("MISSING_OR_INVALID", `${e2} must be in Record format. Received: ${JSON.stringify(s2)}`); throw new Error(i2); } }); + }, this.getPendingAuthRequest = (t2) => { + const e2 = this.client.auth.requests.get(t2); + return typeof e2 == "object" ? e2 : void 0; + }, this.addToRecentlyDeleted = (t2, e2) => { + if (this.recentlyDeletedMap.set(t2, e2), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) { + let s2 = 0; + const i2 = this.recentlyDeletedLimit / 2; + for (const r3 of this.recentlyDeletedMap.keys()) { + if (s2++ >= i2) + break; + this.recentlyDeletedMap.delete(r3); + } + } + }, this.checkRecentlyDeleted = (t2) => { + const e2 = this.recentlyDeletedMap.get(t2); + if (e2) { + const { message: s2 } = xe("MISSING_OR_INVALID", `Record was recently deleted - ${e2}: ${t2}`); + throw new Error(s2); + } }; } async isInitialized() { if (!this.initialized) { - const { message: r2 } = N$1("NOT_INITIALIZED", this.name); - throw new Error(r2); + const { message: n4 } = xe("NOT_INITIALIZED", this.name); + throw new Error(n4); } await this.client.core.relayer.confirmOnlineStateOrThrow(); } registerRelayerEvents() { - this.client.core.relayer.on(D$1.message, async (r2) => { - const { topic: e, message: s2 } = r2; - if (this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s2))) - return; - const t2 = await this.client.core.crypto.decode(e, s2); + this.client.core.relayer.on(v2.message, async (n4) => { + const { topic: t2, message: e2 } = n4, { publicKey: s2 } = this.client.auth.authKeys.keys.includes(J) ? this.client.auth.authKeys.get(J) : { responseTopic: void 0, publicKey: void 0 }, i2 = await this.client.core.crypto.decode(t2, e2, { receiverPublicKey: s2 }); try { - isJsonRpcRequest(t2) ? (this.client.core.history.set(e, t2), this.onRelayEventRequest({ topic: e, payload: t2 })) : isJsonRpcResponse(t2) ? (await this.client.core.history.resolve(t2), await this.onRelayEventResponse({ topic: e, payload: t2 }), this.client.core.history.delete(e, t2.id)) : this.onRelayEventUnknownPayload({ topic: e, payload: t2 }); - } catch (i2) { - this.client.logger.error(i2); + isJsonRpcRequest(i2) ? (this.client.core.history.set(t2, i2), this.onRelayEventRequest({ topic: t2, payload: i2 })) : isJsonRpcResponse(i2) ? (await this.client.core.history.resolve(i2), await this.onRelayEventResponse({ topic: t2, payload: i2 }), this.client.core.history.delete(t2, i2.id)) : this.onRelayEventUnknownPayload({ topic: t2, payload: i2 }); + } catch (r3) { + this.client.logger.error(r3); } }); } registerExpirerEvents() { - this.client.core.expirer.on(v2.expired, async (r2) => { - const { topic: e, id: s2 } = ft$1(r2.target); - if (s2 && this.client.pendingRequest.keys.includes(s2)) - return await this.deletePendingSessionRequest(s2, N$1("EXPIRED"), true); - e ? this.client.session.keys.includes(e) && (await this.deleteSession({ topic: e, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: e })) : s2 && (await this.deleteProposal(s2, true), this.client.events.emit("proposal_expire", { id: s2 })); + this.client.core.expirer.on(C.expired, async (n4) => { + const { topic: t2, id: e2 } = l0(n4.target); + if (e2 && this.client.pendingRequest.keys.includes(e2)) + return await this.deletePendingSessionRequest(e2, xe("EXPIRED"), true); + t2 ? this.client.session.keys.includes(t2) && (await this.deleteSession({ topic: t2, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: t2 })) : e2 && (await this.deleteProposal(e2, true), this.client.events.emit("proposal_expire", { id: e2 })); }); } registerPairingEvents() { - this.client.core.pairing.events.on(V.create, (r2) => this.onPairingCreated(r2)); + this.client.core.pairing.events.on(V$1.create, (n4) => this.onPairingCreated(n4)), this.client.core.pairing.events.on(V$1.delete, (n4) => { + this.addToRecentlyDeleted(n4.topic, "pairing"); + }); } - isValidPairingTopic(r2) { - if (!g$3(r2, false)) { - const { message: e } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${r2}`); - throw new Error(e); + isValidPairingTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `pairing topic should be a string: ${n4}`); + throw new Error(t2); } - if (!this.client.core.pairing.pairings.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${r2}`); - throw new Error(e); + if (!this.client.core.pairing.pairings.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `pairing topic doesn't exist: ${n4}`); + throw new Error(t2); } - if (mt$1(this.client.core.pairing.pairings.get(r2).expiry)) { - const { message: e } = N$1("EXPIRED", `pairing topic: ${r2}`); - throw new Error(e); + if (p0(this.client.core.pairing.pairings.get(n4).expiry)) { + const { message: t2 } = xe("EXPIRED", `pairing topic: ${n4}`); + throw new Error(t2); } } - async isValidSessionTopic(r2) { - if (!g$3(r2, false)) { - const { message: e } = N$1("MISSING_OR_INVALID", `session topic should be a string: ${r2}`); - throw new Error(e); + async isValidSessionTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `session topic should be a string: ${n4}`); + throw new Error(t2); } - if (!this.client.session.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `session topic doesn't exist: ${r2}`); - throw new Error(e); + if (this.checkRecentlyDeleted(n4), !this.client.session.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `session topic doesn't exist: ${n4}`); + throw new Error(t2); } - if (mt$1(this.client.session.get(r2).expiry)) { - await this.deleteSession({ topic: r2 }); - const { message: e } = N$1("EXPIRED", `session topic: ${r2}`); - throw new Error(e); + if (p0(this.client.session.get(n4).expiry)) { + await this.deleteSession({ topic: n4 }); + const { message: t2 } = xe("EXPIRED", `session topic: ${n4}`); + throw new Error(t2); } - if (!this.client.core.crypto.keychain.has(r2)) { - const { message: e } = N$1("MISSING_OR_INVALID", `session topic does not exist in keychain: ${r2}`); - throw await this.deleteSession({ topic: r2 }), new Error(e); + if (!this.client.core.crypto.keychain.has(n4)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `session topic does not exist in keychain: ${n4}`); + throw await this.deleteSession({ topic: n4 }), new Error(t2); } } - async isValidSessionOrPairingTopic(r2) { - if (this.client.session.keys.includes(r2)) - await this.isValidSessionTopic(r2); - else if (this.client.core.pairing.pairings.keys.includes(r2)) - this.isValidPairingTopic(r2); - else if (g$3(r2, false)) { - const { message: e } = N$1("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${r2}`); - throw new Error(e); + async isValidSessionOrPairingTopic(n4) { + if (this.checkRecentlyDeleted(n4), this.client.session.keys.includes(n4)) + await this.isValidSessionTopic(n4); + else if (this.client.core.pairing.pairings.keys.includes(n4)) + this.isValidPairingTopic(n4); + else if (Gt$1(n4, false)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${n4}`); + throw new Error(t2); } else { - const { message: e } = N$1("MISSING_OR_INVALID", `session or pairing topic should be a string: ${r2}`); - throw new Error(e); - } - } - async isValidProposalId(r2) { - if (!Bt$1(r2)) { - const { message: e } = N$1("MISSING_OR_INVALID", `proposal id should be a number: ${r2}`); - throw new Error(e); - } - if (!this.client.proposal.keys.includes(r2)) { - const { message: e } = N$1("NO_MATCHING_KEY", `proposal id doesn't exist: ${r2}`); - throw new Error(e); - } - if (mt$1(this.client.proposal.get(r2).expiryTimestamp)) { - await this.deleteProposal(r2); - const { message: e } = N$1("EXPIRED", `proposal id: ${r2}`); - throw new Error(e); - } - } -} -class us extends Kt { - constructor(r2, e) { - super(r2, e, oe, G), this.core = r2, this.logger = e; - } -} -class ge extends Kt { - constructor(r2, e) { - super(r2, e, ce, G), this.core = r2, this.logger = e; - } -} -class gs extends Kt { - constructor(r2, e) { - super(r2, e, pe, G, (s2) => s2.id), this.core = r2, this.logger = e; - } -} -class Q extends b$1 { - constructor(r2) { - super(r2), this.protocol = J, this.version = F, this.name = M.name, this.events = new eventsExports.EventEmitter(), this.on = (s2, t2) => this.events.on(s2, t2), this.once = (s2, t2) => this.events.once(s2, t2), this.off = (s2, t2) => this.events.off(s2, t2), this.removeListener = (s2, t2) => this.events.removeListener(s2, t2), this.removeAllListeners = (s2) => this.events.removeAllListeners(s2), this.connect = async (s2) => { - try { - return await this.engine.connect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.pair = async (s2) => { - try { - return await this.engine.pair(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.approve = async (s2) => { - try { - return await this.engine.approve(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.reject = async (s2) => { - try { - return await this.engine.reject(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.update = async (s2) => { - try { - return await this.engine.update(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.extend = async (s2) => { - try { - return await this.engine.extend(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.request = async (s2) => { - try { - return await this.engine.request(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.respond = async (s2) => { - try { - return await this.engine.respond(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.ping = async (s2) => { - try { - return await this.engine.ping(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.emit = async (s2) => { - try { - return await this.engine.emit(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.disconnect = async (s2) => { - try { - return await this.engine.disconnect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.find = (s2) => { - try { - return this.engine.find(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.getPendingSessionRequests = () => { - try { - return this.engine.getPendingSessionRequests(); - } catch (s2) { - throw this.logger.error(s2.message), s2; - } - }, this.name = (r2 == null ? void 0 : r2.name) || M.name, this.metadata = (r2 == null ? void 0 : r2.metadata) || Qn(); - const e = typeof (r2 == null ? void 0 : r2.logger) < "u" && typeof (r2 == null ? void 0 : r2.logger) != "string" ? r2.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (r2 == null ? void 0 : r2.logger) || M.logger })); - this.core = (r2 == null ? void 0 : r2.core) || new Mr(r2), this.logger = cjs$3.generateChildLogger(e, this.name), this.session = new ge(this.core, this.logger), this.proposal = new us(this.core, this.logger), this.pendingRequest = new gs(this.core, this.logger), this.engine = new ds(this); - } - static async init(r2) { - const e = new Q(r2); - return await e.initialize(), e; - } - get context() { - return cjs$3.getLoggerContext(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.engine.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); - } catch (r2) { - throw this.logger.info("SignClient Initialization Failure"), this.logger.error(r2.message), r2; - } - } -} -var P = Object.defineProperty, x = Object.defineProperties, N = Object.getOwnPropertyDescriptors, j = Object.getOwnPropertySymbols, U = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable, W = (e, t2, s2) => t2 in e ? P(e, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e[t2] = s2, q = (e, t2) => { - for (var s2 in t2 || (t2 = {})) - U.call(t2, s2) && W(e, s2, t2[s2]); - if (j) - for (var s2 of j(t2)) - T.call(t2, s2) && W(e, s2, t2[s2]); - return e; -}, A = (e, t2) => x(e, N(t2)), S = (e, t2, s2) => { - if (!t2.has(e)) - throw TypeError("Cannot " + s2); -}, a2 = (e, t2, s2) => (S(e, t2, "read from private field"), s2 ? s2.call(e) : t2.get(e)), l = (e, t2, s2) => { - if (t2.has(e)) - throw TypeError("Cannot add the same private member more than once"); - t2 instanceof WeakSet ? t2.add(e) : t2.set(e, s2); -}, y2 = (e, t2, s2, d3) => (S(e, t2, "write to private field"), d3 ? d3.call(e, s2) : t2.set(e, s2), s2), o = (e, t2, s2) => (S(e, t2, "access private method"), s2), h3, p2, w2, i, u2, _2, n2, r, m, g2; -let z$1 = class z { - constructor(t2) { - l(this, u2), l(this, n2), l(this, m), l(this, h3, void 0), l(this, p2, void 0), l(this, w2, void 0), l(this, i, void 0), y2(this, h3, t2), y2(this, p2, o(this, u2, _2).call(this)), o(this, n2, r).call(this); - } - async connect(t2) { - const { requiredNamespaces: s2, optionalNamespaces: d3 } = t2; - return new Promise(async (C2, b3) => { - await o(this, n2, r).call(this); - const E2 = a2(this, p2).subscribeModal((c2) => { - c2.open || (E2(), b3(new Error("Modal closed"))); - }), { uri: O2, approval: I2 } = await a2(this, i).connect(t2); - if (O2) { - const c2 = /* @__PURE__ */ new Set(); - s2 && Object.values(s2).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), d3 && Object.values(d3).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), await a2(this, p2).openModal({ uri: O2, chains: Array.from(c2) }); - } - try { - const c2 = await I2(); - C2(c2); - } catch (c2) { - b3(c2); - } finally { - E2(), a2(this, p2).closeModal(); - } - }); - } - async disconnect(t2) { - await o(this, n2, r).call(this), await a2(this, i).disconnect(t2); - } - async request(t2) { - return await o(this, n2, r).call(this), await a2(this, i).request(t2); - } - async getSessions() { - return await o(this, n2, r).call(this), a2(this, i).session.getAll(); - } - async getSession() { - return await o(this, n2, r).call(this), a2(this, i).session.getAll().at(-1); - } - async onSessionEvent(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_event", t2); - } - async offSessionEvent(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_event", t2); - } - async onSessionUpdate(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_update", t2); - } - async offSessionUpdate(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_update", t2); - } - async onSessionDelete(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_delete", t2); - } - async offSessionDelete(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_delete", t2); - } - async onSessionExpire(t2) { - await o(this, n2, r).call(this), a2(this, i).on("session_expire", t2); - } - async offSessionExpire(t2) { - await o(this, n2, r).call(this), a2(this, i).off("session_expire", t2); - } -}; -h3 = /* @__PURE__ */ new WeakMap(), p2 = /* @__PURE__ */ new WeakMap(), w2 = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), u2 = /* @__PURE__ */ new WeakSet(), _2 = function() { - const { modalOptions: e, projectId: t2 } = a2(this, h3); - return new d$1(A(q({}, e), { projectId: t2 })); -}, n2 = /* @__PURE__ */ new WeakSet(), r = async function() { - return a2(this, i) ? true : (!a2(this, w2) && typeof window < "u" && y2(this, w2, o(this, m, g2).call(this)), a2(this, w2)); -}, m = /* @__PURE__ */ new WeakSet(), g2 = async function() { - y2(this, i, await Q.init({ metadata: a2(this, h3).metadata, projectId: a2(this, h3).projectId, relayUrl: a2(this, h3).relayUrl })); - const e = await a2(this, i).core.crypto.getClientId(); - try { - localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e); - } catch { - console.info("Unable to set client id"); - } -}; -const wc_aleo_methods$1 = [ - "decrypt", - "disconnect", - "getSelectedAccount", - "getBalance", - "getRecords", - "requestCreateEvent", - "getEvent", - "getEvents", - "createSharedState", - "importSharedState", - "requestSignature" -]; -const wc_aleo_chains$1 = ["aleo:1"]; -const wc_events$1 = [ - "chainChanged", - "accountSelected", - "selectedAccountSynced", - "sharedAccountSynced" -]; -const projectId$1 = "f0aaeffe71b636da453fce042d79d723"; -function isAndroid$1() { - if (!navigator) { - return false; - } - return /Android/i.test(navigator.userAgent); -} -const web3modal_puzzle_props_android$1 = { - projectId: projectId$1, - chains: ["aleo:3"], - enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png" - } -}; -const web3modal_puzzle_props_default$1 = { - projectId: projectId$1, - chains: wc_aleo_chains$1, - enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" - } - } - ], - desktopWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "", - universal: "https://walletconnect.puzzle.online/" - } - }, - { - id: "avail", - name: "Avail Wallet", - links: { - native: "avail://", - universal: "https://avail.global" - } + const { message: t2 } = xe("MISSING_OR_INVALID", `session or pairing topic should be a string: ${n4}`); + throw new Error(t2); } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png", - avail: "https://i.imgur.com/GxNn8BO.png" } -}; -const web3modal_puzzle_props$1 = isAndroid$1() ? web3modal_puzzle_props_android$1 : web3modal_puzzle_props_default$1; -const name$1 = "@puzzlehq/sdk-core"; -const displayName$1 = "Puzzle SDK"; -const version$1 = "0.3.1"; -const description$1 = "Your portal to privacy"; -const main$1 = "./dist/puzzle.cjs.js"; -const module$1 = "./dist/puzzle.es.js"; -const browser$1 = "./dist/puzzle.umd.js"; -const types$3 = "./dist/types/src/index.d.ts"; -const exports$1 = { - ".": { - "import": "./dist/puzzle.es.js", - require: "./dist/puzzle.cjs.js", - browser: "./dist/puzzle.umd.js", - types: "./dist/types/src/index.d.ts" + async isValidProposalId(n4) { + if (!Zu(n4)) { + const { message: t2 } = xe("MISSING_OR_INVALID", `proposal id should be a number: ${n4}`); + throw new Error(t2); + } + if (!this.client.proposal.keys.includes(n4)) { + const { message: t2 } = xe("NO_MATCHING_KEY", `proposal id doesn't exist: ${n4}`); + throw new Error(t2); + } + if (p0(this.client.proposal.get(n4).expiryTimestamp)) { + await this.deleteProposal(n4); + const { message: t2 } = xe("EXPIRED", `proposal id: ${n4}`); + throw new Error(t2); + } } }; -const type$1 = "module"; -const scripts$1 = { - "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", - "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, - build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", - "type-check": "tsc --noEmit" -}; -const repository$1 = { - type: "git", - url: "git+https://github.com/puzzlehq/puzzle-sdk.git" -}; -const dependencies$1 = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", - "@walletconnect/types": "^2.11.2", - "@walletconnect/utils": "^2.11.2", - debug: "^4.3.4", - events: "^3.3.0", - ws: "^8.16.0" -}; -const peerDependencies$1 = { - buffer: "^6.0.3" -}; -const keywords$1 = [ - "puzzle", - "cryptocurrency wallet", - "privacy", - "aleo", - "web3", - "crypto", - "typescript" -]; -const author$1 = "Puzzle"; -const license$1 = "ISC"; -const bugs$1 = { - url: "https://github.com/puzzlehq/puzzle-sdk/issues" -}; -const homepage$1 = "https://github.com/puzzlehq/puzzle-sdk#readme"; -const pkg$1 = { - name: name$1, - displayName: displayName$1, - version: version$1, - description: description$1, - main: main$1, - module: module$1, - browser: browser$1, - types: types$3, - "private": false, - exports: exports$1, - type: type$1, - scripts: scripts$1, - repository: repository$1, - dependencies: dependencies$1, - peerDependencies: peerDependencies$1, - keywords: keywords$1, - author: author$1, - license: license$1, - bugs: bugs$1, - homepage: homepage$1 +let Zt$1 = class Zt extends Vt { + constructor(n4, t2) { + super(n4, t2, Ke, se$1), this.core = n4, this.logger = t2; + } }; -const emitter$1 = new EventEmitter$1(); -let connection$1 = void 0; -async function configureConnection$1(options) { - let disconnectSessions = false; - const thisVersion = pkg$1.version; - const prevVersion = localStorage.getItem("puzzle_sdk_version"); - if (thisVersion !== prevVersion) { - console.log( - `${pkg$1.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" - ); - localStorage.setItem("puzzle_sdk_version", thisVersion); - disconnectSessions = true; +class We extends Vt { + constructor(n4, t2) { + super(n4, t2, Ge, se$1), this.core = n4, this.logger = t2; } - connection$1 = new z$1({ - projectId: options.projectId ?? projectId$1, - metadata: { - name: options.dAppName, - description: options.dAppDescription, - url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", - icons: [options.dAppIconURL] - }, - modalOptions: { ...web3modal_puzzle_props$1 } - }); - if (disconnectSessions) { - localStorage.removeItem("puzzle-hasInjectedConnection"); - try { - disconnectOnVersionChange$1(connection$1, options.onDisconnect); - } catch (e) { - console.error(e); - } +} +class es2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Fe, se$1, (e2) => e2.id), this.core = n4, this.logger = t2; } - connection$1.onSessionDelete(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - connection$1.onSessionExpire(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); +} +class ts2 extends Vt { + constructor(n4, t2) { + super(n4, t2, He, X, () => J), this.core = n4, this.logger = t2; } - if (typeof window !== "undefined") { - window.puzzleSdkConnection = connection$1; +} +let ss$1 = class ss2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Ye, X), this.core = n4, this.logger = t2; + } +}; +class is2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Xe$1, X, (e2) => e2.id), this.core = n4, this.logger = t2; } - return connection$1; } -async function disconnectOnVersionChange$1(connection2, onDisconnect) { - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (session) { - console.log("Disconnecting session", session); - onDisconnect && onDisconnect(); - connection2.disconnect({ - topic: session.topic, - reason: U$2("USER_DISCONNECTED") - }); +class rs { + constructor(n4, t2) { + this.core = n4, this.logger = t2, this.authKeys = new ts2(this.core, this.logger), this.pairingTopics = new ss$1(this.core, this.logger), this.requests = new is2(this.core, this.logger); + } + async init() { + await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init(); } } -async function getWalletConnectModalSignClient$1() { - return new Promise((resolve) => { - if (connection$1) { - resolve(connection$1); - } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { - resolve(window.puzzleSdkConnection); - } else { - const interval = setInterval(() => { - if (connection$1) { - clearInterval(interval); - resolve(connection$1); +let ne$1 = class ne extends b$1 { + constructor(n4) { + super(n4), this.protocol = Se, this.version = Ee, this.name = ie$1.name, this.events = new eventsExports.EventEmitter(), this.on = (e2, s2) => this.events.on(e2, s2), this.once = (e2, s2) => this.events.once(e2, s2), this.off = (e2, s2) => this.events.off(e2, s2), this.removeListener = (e2, s2) => this.events.removeListener(e2, s2), this.removeAllListeners = (e2) => this.events.removeAllListeners(e2), this.connect = async (e2) => { + try { + return await this.engine.connect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.pair = async (e2) => { + try { + return await this.engine.pair(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approve = async (e2) => { + try { + return await this.engine.approve(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.reject = async (e2) => { + try { + return await this.engine.reject(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.update = async (e2) => { + try { + return await this.engine.update(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.extend = async (e2) => { + try { + return await this.engine.extend(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.request = async (e2) => { + try { + return await this.engine.request(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.respond = async (e2) => { + try { + return await this.engine.respond(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.ping = async (e2) => { + try { + return await this.engine.ping(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.emit = async (e2) => { + try { + return await this.engine.emit(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.disconnect = async (e2) => { + try { + return await this.engine.disconnect(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.find = (e2) => { + try { + return this.engine.find(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.getPendingSessionRequests = () => { + try { + return this.engine.getPendingSessionRequests(); + } catch (e2) { + throw this.logger.error(e2.message), e2; + } + }, this.authenticate = async (e2) => { + try { + return await this.engine.authenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.formatAuthMessage = (e2) => { + try { + return this.engine.formatAuthMessage(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.approveSessionAuthenticate = async (e2) => { + try { + return await this.engine.approveSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.rejectSessionAuthenticate = async (e2) => { + try { + return await this.engine.rejectSessionAuthenticate(e2); + } catch (s2) { + throw this.logger.error(s2.message), s2; + } + }, this.name = (n4 == null ? void 0 : n4.name) || ie$1.name, this.metadata = (n4 == null ? void 0 : n4.metadata) || Xo(); + const t2 = typeof (n4 == null ? void 0 : n4.logger) < "u" && typeof (n4 == null ? void 0 : n4.logger) != "string" ? n4.logger : nt$1(k$2({ level: (n4 == null ? void 0 : n4.logger) || ie$1.logger })); + this.core = (n4 == null ? void 0 : n4.core) || new Br(n4), this.logger = E$1(t2, this.name), this.session = new We(this.core, this.logger), this.proposal = new Zt$1(this.core, this.logger), this.pendingRequest = new es2(this.core, this.logger), this.engine = new Wt$1(this), this.auth = new rs(this.core, this.logger); + } + static async init(n4) { + const t2 = new ne(n4); + return await t2.initialize(), t2; + } + get context() { + return y$2(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.engine.init(), await this.auth.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); + } catch (n4) { + throw this.logger.info("SignClient Initialization Failure"), this.logger.error(n4.message), n4; + } + } +}; +var N = Object.defineProperty, T = Object.defineProperties, U = Object.getOwnPropertyDescriptors, I = Object.getOwnPropertySymbols, A = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable, M = (e2, t2, a3) => t2 in e2 ? N(e2, t2, { enumerable: true, configurable: true, writable: true, value: a3 }) : e2[t2] = a3, q = (e2, t2) => { + for (var a3 in t2 || (t2 = {})) + A.call(t2, a3) && M(e2, a3, t2[a3]); + if (I) + for (var a3 of I(t2)) + D.call(t2, a3) && M(e2, a3, t2[a3]); + return e2; +}, L$1 = (e2, t2) => T(e2, U(t2)), g2 = (e2, t2, a3) => { + if (!t2.has(e2)) + throw TypeError("Cannot " + a3); +}, s = (e2, t2, a3) => (g2(e2, t2, "read from private field"), a3 ? a3.call(e2) : t2.get(e2)), d4 = (e2, t2, a3) => { + if (t2.has(e2)) + throw TypeError("Cannot add the same private member more than once"); + t2 instanceof WeakSet ? t2.add(e2) : t2.set(e2, a3); +}, S = (e2, t2, a3, h4) => (g2(e2, t2, "write to private field"), t2.set(e2, a3), a3), n3 = (e2, t2, a3) => (g2(e2, t2, "access private method"), a3), w2, f2, u2, o, O2, k, r2, c, j$1, P; +class G { + constructor(t2) { + d4(this, O2), d4(this, r2), d4(this, j$1), d4(this, w2, void 0), d4(this, f2, void 0), d4(this, u2, void 0), d4(this, o, void 0), S(this, w2, t2), S(this, f2, n3(this, O2, k).call(this)), n3(this, r2, c).call(this); + } + async connect(t2, a3 = true) { + const { requiredNamespaces: h4, optionalNamespaces: y3 } = t2; + return new Promise(async (W2, E2) => { + var _3, C2; + if (await n3(this, r2, c).call(this), a3) { + const p2 = s(this, f2).subscribeModal((i2) => { + i2.open || (p2(), E2(new Error("Modal closed"))); + }), { uri: v3, approval: m3 } = await s(this, o).connect(t2); + if (v3) { + const i2 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), y3 && Object.values(y3).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), await s(this, f2).openModal({ uri: v3, chains: Array.from(i2) }); } - }, 200); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - }); -} -const checkForDesktopConnection$1 = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; + try { + const i2 = await m3(); + W2(i2); + } catch (i2) { + E2(i2); + } finally { + p2(), s(this, f2).closeModal(); + } + } else { + const { uri: p2, approval: v3 } = await s(this, o).connect(t2); + if (p2) { + const m3 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }), y3 && Object.values(y3).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }); + try { + if ((_3 = window == null ? void 0 : window.aleo) != null && _3.connectPuzzle) { + (C2 = window == null ? void 0 : window.aleo) == null || C2.connectPuzzle({ wc: { uri: p2 } }); + const i2 = await v3(); + W2(i2); + } else + throw new Error("window.aleo.connectPuzzle is undefined! Set showModal to true."); + } catch (i2) { + console.error(i2), E2(i2); + } + } + } + }); + } + async disconnect(t2) { + await n3(this, r2, c).call(this), await s(this, o).disconnect(t2); + } + async request(t2) { + return await n3(this, r2, c).call(this), await s(this, o).request(t2); } - try { - const res = await window.aleo.puzzleWalletClient.isConnected.query( - { sessionTopic } - ); - if (res) { - localStorage.setItem("puzzle-hasInjectedConnection", "true"); - return true; - } else { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - } catch (e) { - console.warn(e); - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; + async getSessions() { + return await n3(this, r2, c).call(this), s(this, o).session.getAll(); } -}; -const hasInjectedConnection$1 = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - return false; + async getSession() { + return await n3(this, r2, c).call(this), s(this, o).session.getAll().at(-1); + } + async onSessionEvent(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_event", t2); + } + async offSessionEvent(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_event", t2); + } + async onSessionUpdate(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_update", t2); + } + async offSessionUpdate(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_update", t2); + } + async onSessionDelete(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_delete", t2); + } + async offSessionDelete(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_delete", t2); + } + async onSessionExpire(t2) { + await n3(this, r2, c).call(this), s(this, o).on("session_expire", t2); + } + async offSessionExpire(t2) { + await n3(this, r2, c).call(this), s(this, o).off("session_expire", t2); + } +} +w2 = /* @__PURE__ */ new WeakMap(), f2 = /* @__PURE__ */ new WeakMap(), u2 = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), O2 = /* @__PURE__ */ new WeakSet(), k = function() { + const { modalOptions: e2, projectId: t2 } = s(this, w2); + return new d$3(L$1(q({}, e2), { projectId: t2 })); +}, r2 = /* @__PURE__ */ new WeakSet(), c = async function() { + return s(this, o) ? true : (!s(this, u2) && typeof window < "u" && S(this, u2, n3(this, j$1, P).call(this)), s(this, u2)); +}, j$1 = /* @__PURE__ */ new WeakSet(), P = async function() { + S(this, o, await ne$1.init({ metadata: s(this, w2).metadata, projectId: s(this, w2).projectId, relayUrl: s(this, w2).relayUrl })); + const e2 = await s(this, o).core.crypto.getClientId(); + try { + localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e2); + } catch { + console.info("Unable to set client id"); } - const puzzleHasDesktopConnection = localStorage.getItem( - "puzzle-hasInjectedConnection" - ); - return puzzleHasDesktopConnection === "true"; }; var util$1; (function(util2) { @@ -12869,8 +16452,8 @@ var util$1; return util2.objectValues(filtered); }; util2.objectValues = (obj) => { - return util2.objectKeys(obj).map(function(e) { - return obj[e]; + return util2.objectKeys(obj).map(function(e2) { + return obj[e2]; }); }; util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { @@ -13197,7 +16780,7 @@ const makeIssue$1 = (params) => { path: fullPath }; let errorMessage = ""; - const maps = errorMaps.filter((m2) => !!m2).slice().reverse(); + const maps = errorMaps.filter((m3) => !!m3).slice().reverse(); for (const map of maps) { errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; } @@ -13421,11 +17004,11 @@ let ZodType$1 = class ZodType { throw result.error; } safeParse(data, params) { - var _a; + var _a2; const ctx = { common: { issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap }, path: (params === null || params === void 0 ? void 0 : params.path) || [], @@ -13781,7 +17364,7 @@ let ZodString$1 = class ZodString extends ZodType$1 { } else if (check.kind === "url") { try { new URL(input.data); - } catch (_a) { + } catch (_a2) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { validation: "url", @@ -13896,7 +17479,7 @@ let ZodString$1 = class ZodString extends ZodType$1 { return this._addCheck({ kind: "ip", ...errorUtil$1.errToObj(options) }); } datetime(options) { - var _a; + var _a2; if (typeof options === "string") { return this._addCheck({ kind: "datetime", @@ -13908,7 +17491,7 @@ let ZodString$1 = class ZodString extends ZodType$1 { return this._addCheck({ kind: "datetime", precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, ...errorUtil$1.errToObj(options === null || options === void 0 ? void 0 : options.message) }); } @@ -13934,116 +17517,346 @@ let ZodString$1 = class ZodString extends ZodType$1 { ...errorUtil$1.errToObj(message) }); } - endsWith(value, message) { + endsWith(value, message) { + return this._addCheck({ + kind: "endsWith", + value, + ...errorUtil$1.errToObj(message) + }); + } + min(minLength, message) { + return this._addCheck({ + kind: "min", + value: minLength, + ...errorUtil$1.errToObj(message) + }); + } + max(maxLength, message) { + return this._addCheck({ + kind: "max", + value: maxLength, + ...errorUtil$1.errToObj(message) + }); + } + length(len, message) { + return this._addCheck({ + kind: "length", + value: len, + ...errorUtil$1.errToObj(message) + }); + } + get isDatetime() { + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); + } + get isEmail() { + return !!this._def.checks.find((ch2) => ch2.kind === "email"); + } + get isURL() { + return !!this._def.checks.find((ch2) => ch2.kind === "url"); + } + get isEmoji() { + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); + } + get isUUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); + } + get isCUID() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); + } + get isCUID2() { + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); + } + get isULID() { + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); + } + get isIP() { + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); + } + get minLength() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxLength() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } +}; +ZodString$1.create = (params) => { + var _a2; + return new ZodString$1({ + checks: [], + typeName: ZodFirstPartyTypeKind$1.ZodString, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams$1(params) + }); +}; +function floatSafeRemainder$1(val, step) { + const valDecCount = (val.toString().split(".")[1] || "").length; + const stepDecCount = (step.toString().split(".")[1] || "").length; + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; + const valInt = parseInt(val.toFixed(decCount).replace(".", "")); + const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); + return valInt % stepInt / Math.pow(10, decCount); +} +let ZodNumber$1 = class ZodNumber extends ZodType$1 { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + this.step = this.multipleOf; + } + _parse(input) { + if (this._def.coerce) { + input.data = Number(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.number) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext$1(ctx2, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.number, + received: ctx2.parsedType + }); + return INVALID$1; + } + let ctx = void 0; + const status = new ParseStatus$1(); + for (const check of this._def.checks) { + if (check.kind === "int") { + if (!util$1.isInteger(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: "integer", + received: "float", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_small, + minimum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + maximum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (floatSafeRemainder$1(input.data, check.value) !== 0) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "finite") { + if (!Number.isFinite(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.not_finite, + message: check.message + }); + status.dirty(); + } + } else { + util$1.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil$1.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil$1.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil$1.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil$1.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new ZodNumber({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil$1.toString(message) + } + ] + }); + } + _addCheck(check) { + return new ZodNumber({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + int(message) { + return this._addCheck({ + kind: "int", + message: errorUtil$1.toString(message) + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: false, + message: errorUtil$1.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: false, + message: errorUtil$1.toString(message) + }); + } + nonpositive(message) { return this._addCheck({ - kind: "endsWith", - value, - ...errorUtil$1.errToObj(message) + kind: "max", + value: 0, + inclusive: true, + message: errorUtil$1.toString(message) }); } - min(minLength, message) { + nonnegative(message) { return this._addCheck({ kind: "min", - value: minLength, - ...errorUtil$1.errToObj(message) + value: 0, + inclusive: true, + message: errorUtil$1.toString(message) }); } - max(maxLength, message) { + multipleOf(value, message) { return this._addCheck({ - kind: "max", - value: maxLength, - ...errorUtil$1.errToObj(message) + kind: "multipleOf", + value, + message: errorUtil$1.toString(message) }); } - length(len, message) { + finite(message) { return this._addCheck({ - kind: "length", - value: len, - ...errorUtil$1.errToObj(message) + kind: "finite", + message: errorUtil$1.toString(message) }); } - get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); - } - get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); - } - get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); - } - get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); - } - get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); - } - get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); - } - get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); - } - get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); - } - get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); + safe(message) { + return this._addCheck({ + kind: "min", + inclusive: true, + value: Number.MIN_SAFE_INTEGER, + message: errorUtil$1.toString(message) + })._addCheck({ + kind: "max", + inclusive: true, + value: Number.MAX_SAFE_INTEGER, + message: errorUtil$1.toString(message) + }); } - get minLength() { + get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } - get maxLength() { + get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } + get isInt() { + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util$1.isInteger(ch2.value)); + } + get isFinite() { + let max = null, min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { + return true; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return Number.isFinite(min) && Number.isFinite(max); + } }; -ZodString$1.create = (params) => { - var _a; - return new ZodString$1({ +ZodNumber$1.create = (params) => { + return new ZodNumber$1({ checks: [], - typeName: ZodFirstPartyTypeKind$1.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + typeName: ZodFirstPartyTypeKind$1.ZodNumber, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, ...processCreateParams$1(params) }); }; -function floatSafeRemainder$1(val, step) { - const valDecCount = (val.toString().split(".")[1] || "").length; - const stepDecCount = (step.toString().split(".")[1] || "").length; - const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; - const valInt = parseInt(val.toFixed(decCount).replace(".", "")); - const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); - return valInt % stepInt / Math.pow(10, decCount); -} -let ZodNumber$1 = class ZodNumber extends ZodType$1 { +let ZodBigInt$1 = class ZodBigInt extends ZodType$1 { constructor() { super(...arguments); this.min = this.gte; this.max = this.lte; - this.step = this.multipleOf; } _parse(input) { if (this._def.coerce) { - input.data = Number(input.data); + input.data = BigInt(input.data); } const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.number) { + if (parsedType !== ZodParsedType$1.bigint) { const ctx2 = this._getOrReturnCtx(input); addIssueToContext$1(ctx2, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.number, + expected: ZodParsedType$1.bigint, received: ctx2.parsedType }); return INVALID$1; @@ -14051,27 +17864,15 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { let ctx = void 0; const status = new ParseStatus$1(); for (const check of this._def.checks) { - if (check.kind === "int") { - if (!util$1.isInteger(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: "integer", - received: "float", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "min") { + if (check.kind === "min") { const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; if (tooSmall) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { code: ZodIssueCode$1.too_small, + type: "bigint", minimum: check.value, - type: "number", inclusive: check.inclusive, - exact: false, message: check.message }); status.dirty(); @@ -14082,16 +17883,15 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { code: ZodIssueCode$1.too_big, + type: "bigint", maximum: check.value, - type: "number", inclusive: check.inclusive, - exact: false, message: check.message }); status.dirty(); } } else if (check.kind === "multipleOf") { - if (floatSafeRemainder$1(input.data, check.value) !== 0) { + if (input.data % check.value !== BigInt(0)) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { code: ZodIssueCode$1.not_multiple_of, @@ -14100,15 +17900,6 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { }); status.dirty(); } - } else if (check.kind === "finite") { - if (!Number.isFinite(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.not_finite, - message: check.message - }); - status.dirty(); - } } else { util$1.assertNever(check); } @@ -14128,7 +17919,7 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { return this.setLimit("max", value, false, errorUtil$1.toString(message)); } setLimit(kind, value, inclusive, message) { - return new ZodNumber({ + return new ZodBigInt({ ...this._def, checks: [ ...this._def.checks, @@ -14138,2449 +17929,5763 @@ let ZodNumber$1 = class ZodNumber extends ZodType$1 { inclusive, message: errorUtil$1.toString(message) } - ] - }); + ] + }); + } + _addCheck(check) { + return new ZodBigInt({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: false, + message: errorUtil$1.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: false, + message: errorUtil$1.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: true, + message: errorUtil$1.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: true, + message: errorUtil$1.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil$1.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max; + } +}; +ZodBigInt$1.create = (params) => { + var _a2; + return new ZodBigInt$1({ + checks: [], + typeName: ZodFirstPartyTypeKind$1.ZodBigInt, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams$1(params) + }); +}; +let ZodBoolean$1 = class ZodBoolean extends ZodType$1 { + _parse(input) { + if (this._def.coerce) { + input.data = Boolean(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.boolean) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.boolean, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodBoolean$1.create = (params) => { + return new ZodBoolean$1({ + typeName: ZodFirstPartyTypeKind$1.ZodBoolean, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams$1(params) + }); +}; +let ZodDate$1 = class ZodDate extends ZodType$1 { + _parse(input) { + if (this._def.coerce) { + input.data = new Date(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.date) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext$1(ctx2, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.date, + received: ctx2.parsedType + }); + return INVALID$1; + } + if (isNaN(input.data.getTime())) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext$1(ctx2, { + code: ZodIssueCode$1.invalid_date + }); + return INVALID$1; + } + const status = new ParseStatus$1(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.getTime() < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_small, + message: check.message, + inclusive: true, + exact: false, + minimum: check.value, + type: "date" + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.getTime() > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + message: check.message, + inclusive: true, + exact: false, + maximum: check.value, + type: "date" + }); + status.dirty(); + } + } else { + util$1.assertNever(check); + } + } + return { + status: status.value, + value: new Date(input.data.getTime()) + }; } _addCheck(check) { - return new ZodNumber({ + return new ZodDate({ ...this._def, checks: [...this._def.checks, check] }); } - int(message) { - return this._addCheck({ - kind: "int", - message: errorUtil$1.toString(message) - }); - } - positive(message) { + min(minDate, message) { return this._addCheck({ kind: "min", - value: 0, - inclusive: false, + value: minDate.getTime(), message: errorUtil$1.toString(message) }); } - negative(message) { + max(maxDate, message) { return this._addCheck({ kind: "max", - value: 0, - inclusive: false, + value: maxDate.getTime(), message: errorUtil$1.toString(message) }); } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: 0, - inclusive: true, - message: errorUtil$1.toString(message) + get minDate() { + let min = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } + } + return min != null ? new Date(min) : null; + } + get maxDate() { + let max = null; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; + } + } + return max != null ? new Date(max) : null; + } +}; +ZodDate$1.create = (params) => { + return new ZodDate$1({ + checks: [], + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + typeName: ZodFirstPartyTypeKind$1.ZodDate, + ...processCreateParams$1(params) + }); +}; +let ZodSymbol$1 = class ZodSymbol extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.symbol) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.symbol, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodSymbol$1.create = (params) => { + return new ZodSymbol$1({ + typeName: ZodFirstPartyTypeKind$1.ZodSymbol, + ...processCreateParams$1(params) + }); +}; +let ZodUndefined$1 = class ZodUndefined extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.undefined, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodUndefined$1.create = (params) => { + return new ZodUndefined$1({ + typeName: ZodFirstPartyTypeKind$1.ZodUndefined, + ...processCreateParams$1(params) + }); +}; +let ZodNull$1 = class ZodNull extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.null) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.null, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodNull$1.create = (params) => { + return new ZodNull$1({ + typeName: ZodFirstPartyTypeKind$1.ZodNull, + ...processCreateParams$1(params) + }); +}; +let ZodAny$1 = class ZodAny extends ZodType$1 { + constructor() { + super(...arguments); + this._any = true; + } + _parse(input) { + return OK$1(input.data); + } +}; +ZodAny$1.create = (params) => { + return new ZodAny$1({ + typeName: ZodFirstPartyTypeKind$1.ZodAny, + ...processCreateParams$1(params) + }); +}; +let ZodUnknown$1 = class ZodUnknown extends ZodType$1 { + constructor() { + super(...arguments); + this._unknown = true; + } + _parse(input) { + return OK$1(input.data); + } +}; +ZodUnknown$1.create = (params) => { + return new ZodUnknown$1({ + typeName: ZodFirstPartyTypeKind$1.ZodUnknown, + ...processCreateParams$1(params) + }); +}; +let ZodNever$1 = class ZodNever extends ZodType$1 { + _parse(input) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.never, + received: ctx.parsedType + }); + return INVALID$1; + } +}; +ZodNever$1.create = (params) => { + return new ZodNever$1({ + typeName: ZodFirstPartyTypeKind$1.ZodNever, + ...processCreateParams$1(params) + }); +}; +let ZodVoid$1 = class ZodVoid extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.void, + received: ctx.parsedType + }); + return INVALID$1; + } + return OK$1(input.data); + } +}; +ZodVoid$1.create = (params) => { + return new ZodVoid$1({ + typeName: ZodFirstPartyTypeKind$1.ZodVoid, + ...processCreateParams$1(params) + }); +}; +let ZodArray$1 = class ZodArray extends ZodType$1 { + _parse(input) { + const { ctx, status } = this._processInputParams(input); + const def = this._def; + if (ctx.parsedType !== ZodParsedType$1.array) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.array, + received: ctx.parsedType + }); + return INVALID$1; + } + if (def.exactLength !== null) { + const tooBig = ctx.data.length > def.exactLength.value; + const tooSmall = ctx.data.length < def.exactLength.value; + if (tooBig || tooSmall) { + addIssueToContext$1(ctx, { + code: tooBig ? ZodIssueCode$1.too_big : ZodIssueCode$1.too_small, + minimum: tooSmall ? def.exactLength.value : void 0, + maximum: tooBig ? def.exactLength.value : void 0, + type: "array", + inclusive: true, + exact: true, + message: def.exactLength.message + }); + status.dirty(); + } + } + if (def.minLength !== null) { + if (ctx.data.length < def.minLength.value) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_small, + minimum: def.minLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.minLength.message + }); + status.dirty(); + } + } + if (def.maxLength !== null) { + if (ctx.data.length > def.maxLength.value) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + maximum: def.maxLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.maxLength.message + }); + status.dirty(); + } + } + if (ctx.common.async) { + return Promise.all([...ctx.data].map((item, i2) => { + return def.type._parseAsync(new ParseInputLazyPath$1(ctx, item, ctx.path, i2)); + })).then((result2) => { + return ParseStatus$1.mergeArray(status, result2); + }); + } + const result = [...ctx.data].map((item, i2) => { + return def.type._parseSync(new ParseInputLazyPath$1(ctx, item, ctx.path, i2)); }); + return ParseStatus$1.mergeArray(status, result); } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: 0, - inclusive: true, - message: errorUtil$1.toString(message) - }); + get element() { + return this._def.type; } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil$1.toString(message) + min(minLength, message) { + return new ZodArray({ + ...this._def, + minLength: { value: minLength, message: errorUtil$1.toString(message) } }); } - finite(message) { - return this._addCheck({ - kind: "finite", - message: errorUtil$1.toString(message) + max(maxLength, message) { + return new ZodArray({ + ...this._def, + maxLength: { value: maxLength, message: errorUtil$1.toString(message) } }); } - safe(message) { - return this._addCheck({ - kind: "min", - inclusive: true, - value: Number.MIN_SAFE_INTEGER, - message: errorUtil$1.toString(message) - })._addCheck({ - kind: "max", - inclusive: true, - value: Number.MAX_SAFE_INTEGER, - message: errorUtil$1.toString(message) + length(len, message) { + return new ZodArray({ + ...this._def, + exactLength: { value: len, message: errorUtil$1.toString(message) } }); } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } - get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util$1.isInteger(ch.value)); - } - get isFinite() { - let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { - return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return Number.isFinite(min) && Number.isFinite(max); + nonempty(message) { + return this.min(1, message); } }; -ZodNumber$1.create = (params) => { - return new ZodNumber$1({ - checks: [], - typeName: ZodFirstPartyTypeKind$1.ZodNumber, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, +ZodArray$1.create = (schema, params) => { + return new ZodArray$1({ + type: schema, + minLength: null, + maxLength: null, + exactLength: null, + typeName: ZodFirstPartyTypeKind$1.ZodArray, ...processCreateParams$1(params) }); }; -let ZodBigInt$1 = class ZodBigInt extends ZodType$1 { +function deepPartialify$1(schema) { + if (schema instanceof ZodObject$1) { + const newShape = {}; + for (const key in schema.shape) { + const fieldSchema = schema.shape[key]; + newShape[key] = ZodOptional$1.create(deepPartialify$1(fieldSchema)); + } + return new ZodObject$1({ + ...schema._def, + shape: () => newShape + }); + } else if (schema instanceof ZodArray$1) { + return new ZodArray$1({ + ...schema._def, + type: deepPartialify$1(schema.element) + }); + } else if (schema instanceof ZodOptional$1) { + return ZodOptional$1.create(deepPartialify$1(schema.unwrap())); + } else if (schema instanceof ZodNullable$1) { + return ZodNullable$1.create(deepPartialify$1(schema.unwrap())); + } else if (schema instanceof ZodTuple$1) { + return ZodTuple$1.create(schema.items.map((item) => deepPartialify$1(item))); + } else { + return schema; + } +} +let ZodObject$1 = class ZodObject extends ZodType$1 { constructor() { super(...arguments); - this.min = this.gte; - this.max = this.lte; + this._cached = null; + this.nonstrict = this.passthrough; + this.augment = this.extend; + } + _getCached() { + if (this._cached !== null) + return this._cached; + const shape = this._def.shape(); + const keys2 = util$1.objectKeys(shape); + return this._cached = { shape, keys: keys2 }; } _parse(input) { - if (this._def.coerce) { - input.data = BigInt(input.data); - } const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.bigint) { + if (parsedType !== ZodParsedType$1.object) { const ctx2 = this._getOrReturnCtx(input); addIssueToContext$1(ctx2, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.bigint, + expected: ZodParsedType$1.object, received: ctx2.parsedType }); return INVALID$1; } - let ctx = void 0; - const status = new ParseStatus$1(); - for (const check of this._def.checks) { - if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - type: "bigint", - minimum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); + const { status, ctx } = this._processInputParams(input); + const { shape, keys: shapeKeys } = this._getCached(); + const extraKeys = []; + if (!(this._def.catchall instanceof ZodNever$1 && this._def.unknownKeys === "strip")) { + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - type: "bigint", - maximum: check.value, - inclusive: check.inclusive, - message: check.message + } + } + const pairs = []; + for (const key of shapeKeys) { + const keyValidator = shape[key]; + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: keyValidator._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, key)), + alwaysSet: key in ctx.data + }); + } + if (this._def.catchall instanceof ZodNever$1) { + const unknownKeys = this._def.unknownKeys; + if (unknownKeys === "passthrough") { + for (const key of extraKeys) { + pairs.push({ + key: { status: "valid", value: key }, + value: { status: "valid", value: ctx.data[key] } }); - status.dirty(); } - } else if (check.kind === "multipleOf") { - if (input.data % check.value !== BigInt(0)) { - ctx = this._getOrReturnCtx(input, ctx); + } else if (unknownKeys === "strict") { + if (extraKeys.length > 0) { addIssueToContext$1(ctx, { - code: ZodIssueCode$1.not_multiple_of, - multipleOf: check.value, - message: check.message + code: ZodIssueCode$1.unrecognized_keys, + keys: extraKeys }); status.dirty(); } - } else { - util$1.assertNever(check); + } else if (unknownKeys === "strip") + ; + else { + throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); + } + } else { + const catchall = this._def.catchall; + for (const key of extraKeys) { + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: catchall._parse( + new ParseInputLazyPath$1(ctx, value, ctx.path, key) + //, ctx.child(key), value, getParsedType(value) + ), + alwaysSet: key in ctx.data + }); } } - return { status: status.value, value: input.data }; - } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil$1.toString(message)); - } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil$1.toString(message)); + if (ctx.common.async) { + return Promise.resolve().then(async () => { + const syncPairs = []; + for (const pair of pairs) { + const key = await pair.key; + syncPairs.push({ + key, + value: await pair.value, + alwaysSet: pair.alwaysSet + }); + } + return syncPairs; + }).then((syncPairs) => { + return ParseStatus$1.mergeObjectSync(status, syncPairs); + }); + } else { + return ParseStatus$1.mergeObjectSync(status, pairs); + } } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil$1.toString(message)); + get shape() { + return this._def.shape(); } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil$1.toString(message)); + strict(message) { + errorUtil$1.errToObj; + return new ZodObject({ + ...this._def, + unknownKeys: "strict", + ...message !== void 0 ? { + errorMap: (issue, ctx) => { + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + if (issue.code === "unrecognized_keys") + return { + message: (_d = errorUtil$1.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError + }; + return { + message: defaultError + }; + } + } : {} + }); } - setLimit(kind, value, inclusive, message) { - return new ZodBigInt({ + strip() { + return new ZodObject({ ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil$1.toString(message) - } - ] + unknownKeys: "strip" }); } - _addCheck(check) { - return new ZodBigInt({ + passthrough() { + return new ZodObject({ ...this._def, - checks: [...this._def.checks, check] + unknownKeys: "passthrough" }); } - positive(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: false, - message: errorUtil$1.toString(message) + // const AugmentFactory = + // (def: Def) => + // ( + // augmentation: Augmentation + // ): ZodObject< + // extendShape, Augmentation>, + // Def["unknownKeys"], + // Def["catchall"] + // > => { + // return new ZodObject({ + // ...def, + // shape: () => ({ + // ...def.shape(), + // ...augmentation, + // }), + // }) as any; + // }; + extend(augmentation) { + return new ZodObject({ + ...this._def, + shape: () => ({ + ...this._def.shape(), + ...augmentation + }) }); } - negative(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: false, - message: errorUtil$1.toString(message) + /** + * Prior to zod@1.0.12 there was a bug in the + * inferred type of merged objects. Please + * upgrade if you are experiencing issues. + */ + merge(merging) { + const merged = new ZodObject({ + unknownKeys: merging._def.unknownKeys, + catchall: merging._def.catchall, + shape: () => ({ + ...this._def.shape(), + ...merging._def.shape() + }), + typeName: ZodFirstPartyTypeKind$1.ZodObject }); + return merged; } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: true, - message: errorUtil$1.toString(message) + // merge< + // Incoming extends AnyZodObject, + // Augmentation extends Incoming["shape"], + // NewOutput extends { + // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation + // ? Augmentation[k]["_output"] + // : k extends keyof Output + // ? Output[k] + // : never; + // }, + // NewInput extends { + // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation + // ? Augmentation[k]["_input"] + // : k extends keyof Input + // ? Input[k] + // : never; + // } + // >( + // merging: Incoming + // ): ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"], + // NewOutput, + // NewInput + // > { + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + setKey(key, schema) { + return this.augment({ [key]: schema }); + } + // merge( + // merging: Incoming + // ): //ZodObject = (merging) => { + // ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"] + // > { + // // const mergedShape = objectUtil.mergeShapes( + // // this._def.shape(), + // // merging._def.shape() + // // ); + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + catchall(index) { + return new ZodObject({ + ...this._def, + catchall: index }); } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: true, - message: errorUtil$1.toString(message) + pick(mask) { + const shape = {}; + util$1.objectKeys(mask).forEach((key) => { + if (mask[key] && this.shape[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ + ...this._def, + shape: () => shape }); } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil$1.toString(message) + omit(mask) { + const shape = {}; + util$1.objectKeys(this.shape).forEach((key) => { + if (!mask[key]) { + shape[key] = this.shape[key]; + } + }); + return new ZodObject({ + ...this._def, + shape: () => shape }); } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + /** + * @deprecated + */ + deepPartial() { + return deepPartialify$1(this); + } + partial(mask) { + const newShape = {}; + util$1.objectKeys(this.shape).forEach((key) => { + const fieldSchema = this.shape[key]; + if (mask && !mask[key]) { + newShape[key] = fieldSchema; + } else { + newShape[key] = fieldSchema.optional(); } - } - return min; + }); + return new ZodObject({ + ...this._def, + shape: () => newShape + }); } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + required(mask) { + const newShape = {}; + util$1.objectKeys(this.shape).forEach((key) => { + if (mask && !mask[key]) { + newShape[key] = this.shape[key]; + } else { + const fieldSchema = this.shape[key]; + let newField = fieldSchema; + while (newField instanceof ZodOptional$1) { + newField = newField._def.innerType; + } + newShape[key] = newField; } - } - return max; + }); + return new ZodObject({ + ...this._def, + shape: () => newShape + }); + } + keyof() { + return createZodEnum$1(util$1.objectKeys(this.shape)); } }; -ZodBigInt$1.create = (params) => { - var _a; - return new ZodBigInt$1({ - checks: [], - typeName: ZodFirstPartyTypeKind$1.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, +ZodObject$1.create = (shape, params) => { + return new ZodObject$1({ + shape: () => shape, + unknownKeys: "strip", + catchall: ZodNever$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodObject, ...processCreateParams$1(params) }); }; -let ZodBoolean$1 = class ZodBoolean extends ZodType$1 { +ZodObject$1.strictCreate = (shape, params) => { + return new ZodObject$1({ + shape: () => shape, + unknownKeys: "strict", + catchall: ZodNever$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodObject, + ...processCreateParams$1(params) + }); +}; +ZodObject$1.lazycreate = (shape, params) => { + return new ZodObject$1({ + shape, + unknownKeys: "strip", + catchall: ZodNever$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodObject, + ...processCreateParams$1(params) + }); +}; +let ZodUnion$1 = class ZodUnion extends ZodType$1 { _parse(input) { - if (this._def.coerce) { - input.data = Boolean(input.data); + const { ctx } = this._processInputParams(input); + const options = this._def.options; + function handleResults(results) { + for (const result of results) { + if (result.result.status === "valid") { + return result.result; + } + } + for (const result of results) { + if (result.result.status === "dirty") { + ctx.common.issues.push(...result.ctx.common.issues); + return result.result; + } + } + const unionErrors = results.map((result) => new ZodError$1(result.ctx.common.issues)); + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_union, + unionErrors + }); + return INVALID$1; } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.boolean) { - const ctx = this._getOrReturnCtx(input); + if (ctx.common.async) { + return Promise.all(options.map(async (option) => { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + return { + result: await option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }), + ctx: childCtx + }; + })).then(handleResults); + } else { + let dirty = void 0; + const issues = []; + for (const option of options) { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + const result = option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }); + if (result.status === "valid") { + return result; + } else if (result.status === "dirty" && !dirty) { + dirty = { result, ctx: childCtx }; + } + if (childCtx.common.issues.length) { + issues.push(childCtx.common.issues); + } + } + if (dirty) { + ctx.common.issues.push(...dirty.ctx.common.issues); + return dirty.result; + } + const unionErrors = issues.map((issues2) => new ZodError$1(issues2)); addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.boolean, - received: ctx.parsedType + code: ZodIssueCode$1.invalid_union, + unionErrors }); return INVALID$1; } - return OK$1(input.data); + } + get options() { + return this._def.options; } }; -ZodBoolean$1.create = (params) => { - return new ZodBoolean$1({ - typeName: ZodFirstPartyTypeKind$1.ZodBoolean, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, +ZodUnion$1.create = (types2, params) => { + return new ZodUnion$1({ + options: types2, + typeName: ZodFirstPartyTypeKind$1.ZodUnion, ...processCreateParams$1(params) }); }; -let ZodDate$1 = class ZodDate extends ZodType$1 { +const getDiscriminator$1 = (type2) => { + if (type2 instanceof ZodLazy$1) { + return getDiscriminator$1(type2.schema); + } else if (type2 instanceof ZodEffects$1) { + return getDiscriminator$1(type2.innerType()); + } else if (type2 instanceof ZodLiteral$1) { + return [type2.value]; + } else if (type2 instanceof ZodEnum$1) { + return type2.options; + } else if (type2 instanceof ZodNativeEnum$1) { + return Object.keys(type2.enum); + } else if (type2 instanceof ZodDefault$1) { + return getDiscriminator$1(type2._def.innerType); + } else if (type2 instanceof ZodUndefined$1) { + return [void 0]; + } else if (type2 instanceof ZodNull$1) { + return [null]; + } else { + return null; + } +}; +let ZodDiscriminatedUnion$1 = class ZodDiscriminatedUnion extends ZodType$1 { _parse(input) { - if (this._def.coerce) { - input.data = new Date(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.date) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext$1(ctx2, { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.object) { + addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.date, - received: ctx2.parsedType + expected: ZodParsedType$1.object, + received: ctx.parsedType }); return INVALID$1; } - if (isNaN(input.data.getTime())) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext$1(ctx2, { - code: ZodIssueCode$1.invalid_date + const discriminator = this.discriminator; + const discriminatorValue = ctx.data[discriminator]; + const option = this.optionsMap.get(discriminatorValue); + if (!option) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_union_discriminator, + options: Array.from(this.optionsMap.keys()), + path: [discriminator] }); return INVALID$1; } - const status = new ParseStatus$1(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.getTime() < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - message: check.message, - inclusive: true, - exact: false, - minimum: check.value, - type: "date" - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.getTime() > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - message: check.message, - inclusive: true, - exact: false, - maximum: check.value, - type: "date" - }); - status.dirty(); - } - } else { - util$1.assertNever(check); - } + if (ctx.common.async) { + return option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } else { + return option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); } - return { - status: status.value, - value: new Date(input.data.getTime()) - }; } - _addCheck(check) { - return new ZodDate({ - ...this._def, - checks: [...this._def.checks, check] - }); + get discriminator() { + return this._def.discriminator; } - min(minDate, message) { - return this._addCheck({ - kind: "min", - value: minDate.getTime(), - message: errorUtil$1.toString(message) - }); + get options() { + return this._def.options; } - max(maxDate, message) { - return this._addCheck({ - kind: "max", - value: maxDate.getTime(), - message: errorUtil$1.toString(message) + get optionsMap() { + return this._def.optionsMap; + } + /** + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must + * have a different value for each object in the union. + * @param discriminator the name of the discriminator property + * @param types an array of object schemas + * @param params + */ + static create(discriminator, options, params) { + const optionsMap = /* @__PURE__ */ new Map(); + for (const type2 of options) { + const discriminatorValues = getDiscriminator$1(type2.shape[discriminator]); + if (!discriminatorValues) { + throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); + } + for (const value of discriminatorValues) { + if (optionsMap.has(value)) { + throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); + } + optionsMap.set(value, type2); + } + } + return new ZodDiscriminatedUnion({ + typeName: ZodFirstPartyTypeKind$1.ZodDiscriminatedUnion, + discriminator, + options, + optionsMap, + ...processCreateParams$1(params) }); } - get minDate() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; +}; +function mergeValues$1(a3, b3) { + const aType = getParsedType$1(a3); + const bType = getParsedType$1(b3); + if (a3 === b3) { + return { valid: true, data: a3 }; + } else if (aType === ZodParsedType$1.object && bType === ZodParsedType$1.object) { + const bKeys = util$1.objectKeys(b3); + const sharedKeys = util$1.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1); + const newObj = { ...a3, ...b3 }; + for (const key of sharedKeys) { + const sharedValue = mergeValues$1(a3[key], b3[key]); + if (!sharedValue.valid) { + return { valid: false }; } + newObj[key] = sharedValue.data; } - return min != null ? new Date(min) : null; + return { valid: true, data: newObj }; + } else if (aType === ZodParsedType$1.array && bType === ZodParsedType$1.array) { + if (a3.length !== b3.length) { + return { valid: false }; + } + const newArray = []; + for (let index = 0; index < a3.length; index++) { + const itemA = a3[index]; + const itemB = b3[index]; + const sharedValue = mergeValues$1(itemA, itemB); + if (!sharedValue.valid) { + return { valid: false }; + } + newArray.push(sharedValue.data); + } + return { valid: true, data: newArray }; + } else if (aType === ZodParsedType$1.date && bType === ZodParsedType$1.date && +a3 === +b3) { + return { valid: true, data: a3 }; + } else { + return { valid: false }; } - get maxDate() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; +} +let ZodIntersection$1 = class ZodIntersection extends ZodType$1 { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const handleParsed = (parsedLeft, parsedRight) => { + if (isAborted$1(parsedLeft) || isAborted$1(parsedRight)) { + return INVALID$1; } + const merged = mergeValues$1(parsedLeft.value, parsedRight.value); + if (!merged.valid) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_intersection_types + }); + return INVALID$1; + } + if (isDirty$1(parsedLeft) || isDirty$1(parsedRight)) { + status.dirty(); + } + return { status: status.value, value: merged.data }; + }; + if (ctx.common.async) { + return Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)); + } else { + return handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); } - return max != null ? new Date(max) : null; } }; -ZodDate$1.create = (params) => { - return new ZodDate$1({ - checks: [], - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - typeName: ZodFirstPartyTypeKind$1.ZodDate, +ZodIntersection$1.create = (left, right, params) => { + return new ZodIntersection$1({ + left, + right, + typeName: ZodFirstPartyTypeKind$1.ZodIntersection, ...processCreateParams$1(params) }); }; -let ZodSymbol$1 = class ZodSymbol extends ZodType$1 { +let ZodTuple$1 = class ZodTuple extends ZodType$1 { _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.symbol) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.array) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.symbol, + expected: ZodParsedType$1.array, received: ctx.parsedType }); return INVALID$1; } - return OK$1(input.data); - } -}; -ZodSymbol$1.create = (params) => { - return new ZodSymbol$1({ - typeName: ZodFirstPartyTypeKind$1.ZodSymbol, - ...processCreateParams$1(params) - }); -}; -let ZodUndefined$1 = class ZodUndefined extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.undefined) { - const ctx = this._getOrReturnCtx(input); + if (ctx.data.length < this._def.items.length) { addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.undefined, - received: ctx.parsedType + code: ZodIssueCode$1.too_small, + minimum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" }); return INVALID$1; } - return OK$1(input.data); + const rest = this._def.rest; + if (!rest && ctx.data.length > this._def.items.length) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + maximum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + status.dirty(); + } + const items = [...ctx.data].map((item, itemIndex) => { + const schema = this._def.items[itemIndex] || this._def.rest; + if (!schema) + return null; + return schema._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, itemIndex)); + }).filter((x2) => !!x2); + if (ctx.common.async) { + return Promise.all(items).then((results) => { + return ParseStatus$1.mergeArray(status, results); + }); + } else { + return ParseStatus$1.mergeArray(status, items); + } + } + get items() { + return this._def.items; + } + rest(rest) { + return new ZodTuple({ + ...this._def, + rest + }); } }; -ZodUndefined$1.create = (params) => { - return new ZodUndefined$1({ - typeName: ZodFirstPartyTypeKind$1.ZodUndefined, +ZodTuple$1.create = (schemas, params) => { + if (!Array.isArray(schemas)) { + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + } + return new ZodTuple$1({ + items: schemas, + typeName: ZodFirstPartyTypeKind$1.ZodTuple, + rest: null, ...processCreateParams$1(params) }); }; -let ZodNull$1 = class ZodNull extends ZodType$1 { +let ZodRecord$1 = class ZodRecord extends ZodType$1 { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.null) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.object) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.null, + expected: ZodParsedType$1.object, received: ctx.parsedType }); return INVALID$1; } - return OK$1(input.data); - } -}; -ZodNull$1.create = (params) => { - return new ZodNull$1({ - typeName: ZodFirstPartyTypeKind$1.ZodNull, - ...processCreateParams$1(params) - }); -}; -let ZodAny$1 = class ZodAny extends ZodType$1 { - constructor() { - super(...arguments); - this._any = true; - } - _parse(input) { - return OK$1(input.data); - } -}; -ZodAny$1.create = (params) => { - return new ZodAny$1({ - typeName: ZodFirstPartyTypeKind$1.ZodAny, - ...processCreateParams$1(params) - }); -}; -let ZodUnknown$1 = class ZodUnknown extends ZodType$1 { - constructor() { - super(...arguments); - this._unknown = true; + const pairs = []; + const keyType = this._def.keyType; + const valueType = this._def.valueType; + for (const key in ctx.data) { + pairs.push({ + key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath$1(ctx, ctx.data[key], ctx.path, key)) + }); + } + if (ctx.common.async) { + return ParseStatus$1.mergeObjectAsync(status, pairs); + } else { + return ParseStatus$1.mergeObjectSync(status, pairs); + } } - _parse(input) { - return OK$1(input.data); + get element() { + return this._def.valueType; } -}; -ZodUnknown$1.create = (params) => { - return new ZodUnknown$1({ - typeName: ZodFirstPartyTypeKind$1.ZodUnknown, - ...processCreateParams$1(params) - }); -}; -let ZodNever$1 = class ZodNever extends ZodType$1 { - _parse(input) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.never, - received: ctx.parsedType + static create(first, second, third) { + if (second instanceof ZodType$1) { + return new ZodRecord({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind$1.ZodRecord, + ...processCreateParams$1(third) + }); + } + return new ZodRecord({ + keyType: ZodString$1.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind$1.ZodRecord, + ...processCreateParams$1(second) }); - return INVALID$1; } }; -ZodNever$1.create = (params) => { - return new ZodNever$1({ - typeName: ZodFirstPartyTypeKind$1.ZodNever, - ...processCreateParams$1(params) - }); -}; -let ZodVoid$1 = class ZodVoid extends ZodType$1 { +let ZodMap$1 = class ZodMap extends ZodType$1 { _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.undefined) { - const ctx = this._getOrReturnCtx(input); + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.map) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.void, + expected: ZodParsedType$1.map, received: ctx.parsedType }); return INVALID$1; } - return OK$1(input.data); + const keyType = this._def.keyType; + const valueType = this._def.valueType; + const pairs = [...ctx.data.entries()].map(([key, value], index) => { + return { + key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, [index, "key"])), + value: valueType._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, [index, "value"])) + }; + }); + if (ctx.common.async) { + const finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (const pair of pairs) { + const key = await pair.key; + const value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID$1; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + const finalMap = /* @__PURE__ */ new Map(); + for (const pair of pairs) { + const key = pair.key; + const value = pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID$1; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } } }; -ZodVoid$1.create = (params) => { - return new ZodVoid$1({ - typeName: ZodFirstPartyTypeKind$1.ZodVoid, +ZodMap$1.create = (keyType, valueType, params) => { + return new ZodMap$1({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind$1.ZodMap, ...processCreateParams$1(params) }); }; -let ZodArray$1 = class ZodArray extends ZodType$1 { +let ZodSet$1 = class ZodSet extends ZodType$1 { _parse(input) { - const { ctx, status } = this._processInputParams(input); - const def = this._def; - if (ctx.parsedType !== ZodParsedType$1.array) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.set) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.array, + expected: ZodParsedType$1.set, received: ctx.parsedType }); return INVALID$1; } - if (def.exactLength !== null) { - const tooBig = ctx.data.length > def.exactLength.value; - const tooSmall = ctx.data.length < def.exactLength.value; - if (tooBig || tooSmall) { - addIssueToContext$1(ctx, { - code: tooBig ? ZodIssueCode$1.too_big : ZodIssueCode$1.too_small, - minimum: tooSmall ? def.exactLength.value : void 0, - maximum: tooBig ? def.exactLength.value : void 0, - type: "array", - inclusive: true, - exact: true, - message: def.exactLength.message - }); - status.dirty(); - } - } - if (def.minLength !== null) { - if (ctx.data.length < def.minLength.value) { + const def = this._def; + if (def.minSize !== null) { + if (ctx.data.size < def.minSize.value) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.too_small, - minimum: def.minLength.value, - type: "array", + minimum: def.minSize.value, + type: "set", inclusive: true, exact: false, - message: def.minLength.message + message: def.minSize.message }); status.dirty(); } } - if (def.maxLength !== null) { - if (ctx.data.length > def.maxLength.value) { + if (def.maxSize !== null) { + if (ctx.data.size > def.maxSize.value) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.too_big, - maximum: def.maxLength.value, - type: "array", + maximum: def.maxSize.value, + type: "set", inclusive: true, exact: false, - message: def.maxLength.message + message: def.maxSize.message }); status.dirty(); } } - if (ctx.common.async) { - return Promise.all([...ctx.data].map((item, i2) => { - return def.type._parseAsync(new ParseInputLazyPath$1(ctx, item, ctx.path, i2)); - })).then((result2) => { - return ParseStatus$1.mergeArray(status, result2); - }); - } - const result = [...ctx.data].map((item, i2) => { - return def.type._parseSync(new ParseInputLazyPath$1(ctx, item, ctx.path, i2)); - }); - return ParseStatus$1.mergeArray(status, result); - } - get element() { - return this._def.type; - } - min(minLength, message) { - return new ZodArray({ - ...this._def, - minLength: { value: minLength, message: errorUtil$1.toString(message) } - }); - } - max(maxLength, message) { - return new ZodArray({ - ...this._def, - maxLength: { value: maxLength, message: errorUtil$1.toString(message) } - }); - } - length(len, message) { - return new ZodArray({ - ...this._def, - exactLength: { value: len, message: errorUtil$1.toString(message) } - }); - } - nonempty(message) { - return this.min(1, message); - } -}; -ZodArray$1.create = (schema, params) => { - return new ZodArray$1({ - type: schema, - minLength: null, - maxLength: null, - exactLength: null, - typeName: ZodFirstPartyTypeKind$1.ZodArray, - ...processCreateParams$1(params) - }); -}; -function deepPartialify$1(schema) { - if (schema instanceof ZodObject$1) { - const newShape = {}; - for (const key in schema.shape) { - const fieldSchema = schema.shape[key]; - newShape[key] = ZodOptional$1.create(deepPartialify$1(fieldSchema)); - } - return new ZodObject$1({ - ...schema._def, - shape: () => newShape - }); - } else if (schema instanceof ZodArray$1) { - return new ZodArray$1({ - ...schema._def, - type: deepPartialify$1(schema.element) - }); - } else if (schema instanceof ZodOptional$1) { - return ZodOptional$1.create(deepPartialify$1(schema.unwrap())); - } else if (schema instanceof ZodNullable$1) { - return ZodNullable$1.create(deepPartialify$1(schema.unwrap())); - } else if (schema instanceof ZodTuple$1) { - return ZodTuple$1.create(schema.items.map((item) => deepPartialify$1(item))); - } else { - return schema; - } -} -let ZodObject$1 = class ZodObject extends ZodType$1 { - constructor() { - super(...arguments); - this._cached = null; - this.nonstrict = this.passthrough; - this.augment = this.extend; - } - _getCached() { - if (this._cached !== null) - return this._cached; - const shape = this._def.shape(); - const keys2 = util$1.objectKeys(shape); - return this._cached = { shape, keys: keys2 }; - } - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.object) { - const ctx2 = this._getOrReturnCtx(input); - addIssueToContext$1(ctx2, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.object, - received: ctx2.parsedType - }); - return INVALID$1; - } - const { status, ctx } = this._processInputParams(input); - const { shape, keys: shapeKeys } = this._getCached(); - const extraKeys = []; - if (!(this._def.catchall instanceof ZodNever$1 && this._def.unknownKeys === "strip")) { - for (const key in ctx.data) { - if (!shapeKeys.includes(key)) { - extraKeys.push(key); - } - } - } - const pairs = []; - for (const key of shapeKeys) { - const keyValidator = shape[key]; - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: keyValidator._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, key)), - alwaysSet: key in ctx.data - }); - } - if (this._def.catchall instanceof ZodNever$1) { - const unknownKeys = this._def.unknownKeys; - if (unknownKeys === "passthrough") { - for (const key of extraKeys) { - pairs.push({ - key: { status: "valid", value: key }, - value: { status: "valid", value: ctx.data[key] } - }); - } - } else if (unknownKeys === "strict") { - if (extraKeys.length > 0) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.unrecognized_keys, - keys: extraKeys - }); - status.dirty(); - } - } else if (unknownKeys === "strip") - ; - else { - throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); - } - } else { - const catchall = this._def.catchall; - for (const key of extraKeys) { - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: catchall._parse( - new ParseInputLazyPath$1(ctx, value, ctx.path, key) - //, ctx.child(key), value, getParsedType(value) - ), - alwaysSet: key in ctx.data - }); + const valueType = this._def.valueType; + function finalizeSet(elements2) { + const parsedSet = /* @__PURE__ */ new Set(); + for (const element of elements2) { + if (element.status === "aborted") + return INVALID$1; + if (element.status === "dirty") + status.dirty(); + parsedSet.add(element.value); } + return { status: status.value, value: parsedSet }; } + const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, i2))); if (ctx.common.async) { - return Promise.resolve().then(async () => { - const syncPairs = []; - for (const pair of pairs) { - const key = await pair.key; - syncPairs.push({ - key, - value: await pair.value, - alwaysSet: pair.alwaysSet - }); - } - return syncPairs; - }).then((syncPairs) => { - return ParseStatus$1.mergeObjectSync(status, syncPairs); - }); + return Promise.all(elements).then((elements2) => finalizeSet(elements2)); } else { - return ParseStatus$1.mergeObjectSync(status, pairs); + return finalizeSet(elements); } } - get shape() { - return this._def.shape(); - } - strict(message) { - errorUtil$1.errToObj; - return new ZodObject({ + min(minSize, message) { + return new ZodSet({ ...this._def, - unknownKeys: "strict", - ...message !== void 0 ? { - errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; - if (issue.code === "unrecognized_keys") - return { - message: (_d = errorUtil$1.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError - }; - return { - message: defaultError - }; - } - } : {} + minSize: { value: minSize, message: errorUtil$1.toString(message) } }); } - strip() { - return new ZodObject({ + max(maxSize, message) { + return new ZodSet({ ...this._def, - unknownKeys: "strip" + maxSize: { value: maxSize, message: errorUtil$1.toString(message) } }); } - passthrough() { - return new ZodObject({ - ...this._def, - unknownKeys: "passthrough" - }); + size(size, message) { + return this.min(size, message).max(size, message); } - // const AugmentFactory = - // (def: Def) => - // ( - // augmentation: Augmentation - // ): ZodObject< - // extendShape, Augmentation>, - // Def["unknownKeys"], - // Def["catchall"] - // > => { - // return new ZodObject({ - // ...def, - // shape: () => ({ - // ...def.shape(), - // ...augmentation, - // }), - // }) as any; - // }; - extend(augmentation) { - return new ZodObject({ - ...this._def, - shape: () => ({ - ...this._def.shape(), - ...augmentation - }) - }); + nonempty(message) { + return this.min(1, message); } - /** - * Prior to zod@1.0.12 there was a bug in the - * inferred type of merged objects. Please - * upgrade if you are experiencing issues. - */ - merge(merging) { - const merged = new ZodObject({ - unknownKeys: merging._def.unknownKeys, - catchall: merging._def.catchall, - shape: () => ({ - ...this._def.shape(), - ...merging._def.shape() - }), - typeName: ZodFirstPartyTypeKind$1.ZodObject - }); - return merged; +}; +ZodSet$1.create = (valueType, params) => { + return new ZodSet$1({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind$1.ZodSet, + ...processCreateParams$1(params) + }); +}; +let ZodFunction$1 = class ZodFunction extends ZodType$1 { + constructor() { + super(...arguments); + this.validate = this.implement; } - // merge< - // Incoming extends AnyZodObject, - // Augmentation extends Incoming["shape"], - // NewOutput extends { - // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation - // ? Augmentation[k]["_output"] - // : k extends keyof Output - // ? Output[k] - // : never; - // }, - // NewInput extends { - // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation - // ? Augmentation[k]["_input"] - // : k extends keyof Input - // ? Input[k] - // : never; - // } - // >( - // merging: Incoming - // ): ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"], - // NewOutput, - // NewInput - // > { - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - setKey(key, schema) { - return this.augment({ [key]: schema }); + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.function) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.function, + received: ctx.parsedType + }); + return INVALID$1; + } + function makeArgsIssue(args, error) { + return makeIssue$1({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap$1(), + errorMap$1 + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode$1.invalid_arguments, + argumentsError: error + } + }); + } + function makeReturnsIssue(returns, error) { + return makeIssue$1({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap$1(), + errorMap$1 + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode$1.invalid_return_type, + returnTypeError: error + } + }); + } + const params = { errorMap: ctx.common.contextualErrorMap }; + const fn = ctx.data; + if (this._def.returns instanceof ZodPromise$1) { + return OK$1(async (...args) => { + const error = new ZodError$1([]); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { + error.addIssue(makeArgsIssue(args, e2)); + throw error; + }); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { + error.addIssue(makeReturnsIssue(result, e2)); + throw error; + }); + return parsedReturns; + }); + } else { + return OK$1((...args) => { + const parsedArgs = this._def.args.safeParse(args, params); + if (!parsedArgs.success) { + throw new ZodError$1([makeArgsIssue(args, parsedArgs.error)]); + } + const result = fn(...parsedArgs.data); + const parsedReturns = this._def.returns.safeParse(result, params); + if (!parsedReturns.success) { + throw new ZodError$1([makeReturnsIssue(result, parsedReturns.error)]); + } + return parsedReturns.data; + }); + } } - // merge( - // merging: Incoming - // ): //ZodObject = (merging) => { - // ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"] - // > { - // // const mergedShape = objectUtil.mergeShapes( - // // this._def.shape(), - // // merging._def.shape() - // // ); - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - catchall(index) { - return new ZodObject({ - ...this._def, - catchall: index - }); + parameters() { + return this._def.args; } - pick(mask) { - const shape = {}; - util$1.objectKeys(mask).forEach((key) => { - if (mask[key] && this.shape[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ + returnType() { + return this._def.returns; + } + args(...items) { + return new ZodFunction({ ...this._def, - shape: () => shape + args: ZodTuple$1.create(items).rest(ZodUnknown$1.create()) }); } - omit(mask) { - const shape = {}; - util$1.objectKeys(this.shape).forEach((key) => { - if (!mask[key]) { - shape[key] = this.shape[key]; - } - }); - return new ZodObject({ + returns(returnType) { + return new ZodFunction({ ...this._def, - shape: () => shape + returns: returnType }); } - /** - * @deprecated - */ - deepPartial() { - return deepPartialify$1(this); + implement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; } - partial(mask) { - const newShape = {}; - util$1.objectKeys(this.shape).forEach((key) => { - const fieldSchema = this.shape[key]; - if (mask && !mask[key]) { - newShape[key] = fieldSchema; - } else { - newShape[key] = fieldSchema.optional(); - } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape - }); + strictImplement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; } - required(mask) { - const newShape = {}; - util$1.objectKeys(this.shape).forEach((key) => { - if (mask && !mask[key]) { - newShape[key] = this.shape[key]; - } else { - const fieldSchema = this.shape[key]; - let newField = fieldSchema; - while (newField instanceof ZodOptional$1) { - newField = newField._def.innerType; - } - newShape[key] = newField; - } - }); - return new ZodObject({ - ...this._def, - shape: () => newShape + static create(args, returns, params) { + return new ZodFunction({ + args: args ? args : ZodTuple$1.create([]).rest(ZodUnknown$1.create()), + returns: returns || ZodUnknown$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodFunction, + ...processCreateParams$1(params) }); } - keyof() { - return createZodEnum$1(util$1.objectKeys(this.shape)); +}; +let ZodLazy$1 = class ZodLazy extends ZodType$1 { + get schema() { + return this._def.getter(); + } + _parse(input) { + const { ctx } = this._processInputParams(input); + const lazySchema = this._def.getter(); + return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); } }; -ZodObject$1.create = (shape, params) => { - return new ZodObject$1({ - shape: () => shape, - unknownKeys: "strip", - catchall: ZodNever$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodObject, +ZodLazy$1.create = (getter, params) => { + return new ZodLazy$1({ + getter, + typeName: ZodFirstPartyTypeKind$1.ZodLazy, ...processCreateParams$1(params) }); }; -ZodObject$1.strictCreate = (shape, params) => { - return new ZodObject$1({ - shape: () => shape, - unknownKeys: "strict", - catchall: ZodNever$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodObject, +let ZodLiteral$1 = class ZodLiteral extends ZodType$1 { + _parse(input) { + if (input.data !== this._def.value) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + received: ctx.data, + code: ZodIssueCode$1.invalid_literal, + expected: this._def.value + }); + return INVALID$1; + } + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } +}; +ZodLiteral$1.create = (value, params) => { + return new ZodLiteral$1({ + value, + typeName: ZodFirstPartyTypeKind$1.ZodLiteral, ...processCreateParams$1(params) }); }; -ZodObject$1.lazycreate = (shape, params) => { - return new ZodObject$1({ - shape, - unknownKeys: "strip", - catchall: ZodNever$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodObject, +function createZodEnum$1(values, params) { + return new ZodEnum$1({ + values, + typeName: ZodFirstPartyTypeKind$1.ZodEnum, ...processCreateParams$1(params) }); +} +let ZodEnum$1 = class ZodEnum extends ZodType$1 { + _parse(input) { + if (typeof input.data !== "string") { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext$1(ctx, { + expected: util$1.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode$1.invalid_type + }); + return INVALID$1; + } + if (this._def.values.indexOf(input.data) === -1) { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext$1(ctx, { + received: ctx.data, + code: ZodIssueCode$1.invalid_enum_value, + options: expectedValues + }); + return INVALID$1; + } + return OK$1(input.data); + } + get options() { + return this._def.values; + } + get enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Values() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + extract(values) { + return ZodEnum.create(values); + } + exclude(values) { + return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + } }; -let ZodUnion$1 = class ZodUnion extends ZodType$1 { +ZodEnum$1.create = createZodEnum$1; +let ZodNativeEnum$1 = class ZodNativeEnum extends ZodType$1 { _parse(input) { - const { ctx } = this._processInputParams(input); - const options = this._def.options; - function handleResults(results) { - for (const result of results) { - if (result.result.status === "valid") { - return result.result; - } - } - for (const result of results) { - if (result.result.status === "dirty") { - ctx.common.issues.push(...result.ctx.common.issues); - return result.result; - } - } - const unionErrors = results.map((result) => new ZodError$1(result.ctx.common.issues)); + const nativeEnumValues = util$1.getValidEnumValues(this._def.values); + const ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType$1.string && ctx.parsedType !== ZodParsedType$1.number) { + const expectedValues = util$1.objectValues(nativeEnumValues); addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_union, - unionErrors + expected: util$1.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode$1.invalid_type }); return INVALID$1; } - if (ctx.common.async) { - return Promise.all(options.map(async (option) => { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - return { - result: await option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }), - ctx: childCtx - }; - })).then(handleResults); - } else { - let dirty = void 0; - const issues = []; - for (const option of options) { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - const result = option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }); - if (result.status === "valid") { - return result; - } else if (result.status === "dirty" && !dirty) { - dirty = { result, ctx: childCtx }; - } - if (childCtx.common.issues.length) { - issues.push(childCtx.common.issues); - } - } - if (dirty) { - ctx.common.issues.push(...dirty.ctx.common.issues); - return dirty.result; - } - const unionErrors = issues.map((issues2) => new ZodError$1(issues2)); + if (nativeEnumValues.indexOf(input.data) === -1) { + const expectedValues = util$1.objectValues(nativeEnumValues); addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_union, - unionErrors + received: ctx.data, + code: ZodIssueCode$1.invalid_enum_value, + options: expectedValues }); return INVALID$1; } + return OK$1(input.data); } - get options() { - return this._def.options; + get enum() { + return this._def.values; } }; -ZodUnion$1.create = (types2, params) => { - return new ZodUnion$1({ - options: types2, - typeName: ZodFirstPartyTypeKind$1.ZodUnion, +ZodNativeEnum$1.create = (values, params) => { + return new ZodNativeEnum$1({ + values, + typeName: ZodFirstPartyTypeKind$1.ZodNativeEnum, ...processCreateParams$1(params) }); }; -const getDiscriminator$1 = (type2) => { - if (type2 instanceof ZodLazy$1) { - return getDiscriminator$1(type2.schema); - } else if (type2 instanceof ZodEffects$1) { - return getDiscriminator$1(type2.innerType()); - } else if (type2 instanceof ZodLiteral$1) { - return [type2.value]; - } else if (type2 instanceof ZodEnum$1) { - return type2.options; - } else if (type2 instanceof ZodNativeEnum$1) { - return Object.keys(type2.enum); - } else if (type2 instanceof ZodDefault$1) { - return getDiscriminator$1(type2._def.innerType); - } else if (type2 instanceof ZodUndefined$1) { - return [void 0]; - } else if (type2 instanceof ZodNull$1) { - return [null]; - } else { - return null; +let ZodPromise$1 = class ZodPromise extends ZodType$1 { + unwrap() { + return this._def.type; } -}; -let ZodDiscriminatedUnion$1 = class ZodDiscriminatedUnion extends ZodType$1 { _parse(input) { const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.object) { + if (ctx.parsedType !== ZodParsedType$1.promise && ctx.common.async === false) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.object, + expected: ZodParsedType$1.promise, received: ctx.parsedType }); return INVALID$1; } - const discriminator = this.discriminator; - const discriminatorValue = ctx.data[discriminator]; - const option = this.optionsMap.get(discriminatorValue); - if (!option) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_union_discriminator, - options: Array.from(this.optionsMap.keys()), - path: [discriminator] - }); - return INVALID$1; - } - if (ctx.common.async) { - return option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } else { - return option._parseSync({ - data: ctx.data, + const promisified = ctx.parsedType === ZodParsedType$1.promise ? ctx.data : Promise.resolve(ctx.data); + return OK$1(promisified.then((data) => { + return this._def.type.parseAsync(data, { path: ctx.path, - parent: ctx + errorMap: ctx.common.contextualErrorMap }); - } - } - get discriminator() { - return this._def.discriminator; - } - get options() { - return this._def.options; - } - get optionsMap() { - return this._def.optionsMap; - } - /** - * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. - * However, it only allows a union of objects, all of which need to share a discriminator property. This property must - * have a different value for each object in the union. - * @param discriminator the name of the discriminator property - * @param types an array of object schemas - * @param params - */ - static create(discriminator, options, params) { - const optionsMap = /* @__PURE__ */ new Map(); - for (const type2 of options) { - const discriminatorValues = getDiscriminator$1(type2.shape[discriminator]); - if (!discriminatorValues) { - throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); - } - for (const value of discriminatorValues) { - if (optionsMap.has(value)) { - throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); - } - optionsMap.set(value, type2); - } - } - return new ZodDiscriminatedUnion({ - typeName: ZodFirstPartyTypeKind$1.ZodDiscriminatedUnion, - discriminator, - options, - optionsMap, - ...processCreateParams$1(params) - }); + })); } }; -function mergeValues$1(a3, b3) { - const aType = getParsedType$1(a3); - const bType = getParsedType$1(b3); - if (a3 === b3) { - return { valid: true, data: a3 }; - } else if (aType === ZodParsedType$1.object && bType === ZodParsedType$1.object) { - const bKeys = util$1.objectKeys(b3); - const sharedKeys = util$1.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1); - const newObj = { ...a3, ...b3 }; - for (const key of sharedKeys) { - const sharedValue = mergeValues$1(a3[key], b3[key]); - if (!sharedValue.valid) { - return { valid: false }; - } - newObj[key] = sharedValue.data; - } - return { valid: true, data: newObj }; - } else if (aType === ZodParsedType$1.array && bType === ZodParsedType$1.array) { - if (a3.length !== b3.length) { - return { valid: false }; - } - const newArray = []; - for (let index = 0; index < a3.length; index++) { - const itemA = a3[index]; - const itemB = b3[index]; - const sharedValue = mergeValues$1(itemA, itemB); - if (!sharedValue.valid) { - return { valid: false }; - } - newArray.push(sharedValue.data); - } - return { valid: true, data: newArray }; - } else if (aType === ZodParsedType$1.date && bType === ZodParsedType$1.date && +a3 === +b3) { - return { valid: true, data: a3 }; - } else { - return { valid: false }; +ZodPromise$1.create = (schema, params) => { + return new ZodPromise$1({ + type: schema, + typeName: ZodFirstPartyTypeKind$1.ZodPromise, + ...processCreateParams$1(params) + }); +}; +let ZodEffects$1 = class ZodEffects extends ZodType$1 { + innerType() { + return this._def.schema; + } + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind$1.ZodEffects ? this._def.schema.sourceType() : this._def.schema; } -} -let ZodIntersection$1 = class ZodIntersection extends ZodType$1 { _parse(input) { const { status, ctx } = this._processInputParams(input); - const handleParsed = (parsedLeft, parsedRight) => { - if (isAborted$1(parsedLeft) || isAborted$1(parsedRight)) { - return INVALID$1; - } - const merged = mergeValues$1(parsedLeft.value, parsedRight.value); - if (!merged.valid) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_intersection_types + const effect = this._def.effect || null; + if (effect.type === "preprocess") { + const processed = effect.transform(ctx.data); + if (ctx.common.async) { + return Promise.resolve(processed).then((processed2) => { + return this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + }); + }); + } else { + return this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx }); - return INVALID$1; } - if (isDirty$1(parsedLeft) || isDirty$1(parsedRight)) { - status.dirty(); + } + const checkCtx = { + addIssue: (arg) => { + addIssueToContext$1(ctx, arg); + if (arg.fatal) { + status.abort(); + } else { + status.dirty(); + } + }, + get path() { + return ctx.path; } - return { status: status.value, value: merged.data }; }; - if (ctx.common.async) { - return Promise.all([ - this._def.left._parseAsync({ + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); + if (effect.type === "refinement") { + const executeRefinement = (acc) => { + const result = effect.refinement(acc, checkCtx); + if (ctx.common.async) { + return Promise.resolve(result); + } + if (result instanceof Promise) { + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + } + return acc; + }; + if (ctx.common.async === false) { + const inner = this._def.schema._parseSync({ data: ctx.data, path: ctx.path, parent: ctx - }), - this._def.right._parseAsync({ + }); + if (inner.status === "aborted") + return INVALID$1; + if (inner.status === "dirty") + status.dirty(); + executeRefinement(inner.value); + return { status: status.value, value: inner.value }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { + if (inner.status === "aborted") + return INVALID$1; + if (inner.status === "dirty") + status.dirty(); + return executeRefinement(inner.value).then(() => { + return { status: status.value, value: inner.value }; + }); + }); + } + } + if (effect.type === "transform") { + if (ctx.common.async === false) { + const base3 = this._def.schema._parseSync({ data: ctx.data, - path: ctx.path, - parent: ctx - }) - ]).then(([left, right]) => handleParsed(left, right)); - } else { - return handleParsed(this._def.left._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), this._def.right._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - })); + path: ctx.path, + parent: ctx + }); + if (!isValid$1(base3)) + return base3; + const result = effect.transform(base3.value, checkCtx); + if (result instanceof Promise) { + throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + } + return { status: status.value, value: result }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { + if (!isValid$1(base3)) + return base3; + return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); + }); + } } + util$1.assertNever(effect); } }; -ZodIntersection$1.create = (left, right, params) => { - return new ZodIntersection$1({ - left, - right, - typeName: ZodFirstPartyTypeKind$1.ZodIntersection, +ZodEffects$1.create = (schema, effect, params) => { + return new ZodEffects$1({ + schema, + typeName: ZodFirstPartyTypeKind$1.ZodEffects, + effect, ...processCreateParams$1(params) }); }; -let ZodTuple$1 = class ZodTuple extends ZodType$1 { +ZodEffects$1.createWithPreprocess = (preprocess, schema, params) => { + return new ZodEffects$1({ + schema, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind$1.ZodEffects, + ...processCreateParams$1(params) + }); +}; +let ZodOptional$1 = class ZodOptional extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.array) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.array, - received: ctx.parsedType - }); - return INVALID$1; - } - if (ctx.data.length < this._def.items.length) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - minimum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - return INVALID$1; - } - const rest = this._def.rest; - if (!rest && ctx.data.length > this._def.items.length) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - maximum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - status.dirty(); - } - const items = [...ctx.data].map((item, itemIndex) => { - const schema = this._def.items[itemIndex] || this._def.rest; - if (!schema) - return null; - return schema._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, itemIndex)); - }).filter((x2) => !!x2); - if (ctx.common.async) { - return Promise.all(items).then((results) => { - return ParseStatus$1.mergeArray(status, results); - }); - } else { - return ParseStatus$1.mergeArray(status, items); + const parsedType = this._getType(input); + if (parsedType === ZodParsedType$1.undefined) { + return OK$1(void 0); } + return this._def.innerType._parse(input); } - get items() { - return this._def.items; - } - rest(rest) { - return new ZodTuple({ - ...this._def, - rest - }); + unwrap() { + return this._def.innerType; } }; -ZodTuple$1.create = (schemas, params) => { - if (!Array.isArray(schemas)) { - throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); - } - return new ZodTuple$1({ - items: schemas, - typeName: ZodFirstPartyTypeKind$1.ZodTuple, - rest: null, +ZodOptional$1.create = (type2, params) => { + return new ZodOptional$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodOptional, ...processCreateParams$1(params) }); }; -let ZodRecord$1 = class ZodRecord extends ZodType$1 { - get keySchema() { - return this._def.keyType; - } - get valueSchema() { - return this._def.valueType; - } +let ZodNullable$1 = class ZodNullable extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.object) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.object, - received: ctx.parsedType - }); - return INVALID$1; - } - const pairs = []; - const keyType = this._def.keyType; - const valueType = this._def.valueType; - for (const key in ctx.data) { - pairs.push({ - key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, key)), - value: valueType._parse(new ParseInputLazyPath$1(ctx, ctx.data[key], ctx.path, key)) - }); - } - if (ctx.common.async) { - return ParseStatus$1.mergeObjectAsync(status, pairs); - } else { - return ParseStatus$1.mergeObjectSync(status, pairs); + const parsedType = this._getType(input); + if (parsedType === ZodParsedType$1.null) { + return OK$1(null); } + return this._def.innerType._parse(input); } - get element() { - return this._def.valueType; + unwrap() { + return this._def.innerType; } - static create(first, second, third) { - if (second instanceof ZodType$1) { - return new ZodRecord({ - keyType: first, - valueType: second, - typeName: ZodFirstPartyTypeKind$1.ZodRecord, - ...processCreateParams$1(third) - }); +}; +ZodNullable$1.create = (type2, params) => { + return new ZodNullable$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodNullable, + ...processCreateParams$1(params) + }); +}; +let ZodDefault$1 = class ZodDefault extends ZodType$1 { + _parse(input) { + const { ctx } = this._processInputParams(input); + let data = ctx.data; + if (ctx.parsedType === ZodParsedType$1.undefined) { + data = this._def.defaultValue(); } - return new ZodRecord({ - keyType: ZodString$1.create(), - valueType: first, - typeName: ZodFirstPartyTypeKind$1.ZodRecord, - ...processCreateParams$1(second) + return this._def.innerType._parse({ + data, + path: ctx.path, + parent: ctx }); } + removeDefault() { + return this._def.innerType; + } }; -let ZodMap$1 = class ZodMap extends ZodType$1 { +ZodDefault$1.create = (type2, params) => { + return new ZodDefault$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodDefault, + defaultValue: typeof params.default === "function" ? params.default : () => params.default, + ...processCreateParams$1(params) + }); +}; +let ZodCatch$1 = class ZodCatch extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.map) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.map, - received: ctx.parsedType - }); - return INVALID$1; - } - const keyType = this._def.keyType; - const valueType = this._def.valueType; - const pairs = [...ctx.data.entries()].map(([key, value], index) => { - return { - key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, [index, "key"])), - value: valueType._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, [index, "value"])) - }; - }); - if (ctx.common.async) { - const finalMap = /* @__PURE__ */ new Map(); - return Promise.resolve().then(async () => { - for (const pair of pairs) { - const key = await pair.key; - const value = await pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID$1; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - }); - } else { - const finalMap = /* @__PURE__ */ new Map(); - for (const pair of pairs) { - const key = pair.key; - const value = pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID$1; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); + const { ctx } = this._processInputParams(input); + const newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] } - return { status: status.value, value: finalMap }; + }; + const result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx + } + }); + if (isAsync$1(result)) { + return result.then((result2) => { + return { + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError$1(newCtx.common.issues); + } + }) + }; + }); + } else { + return { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError$1(newCtx.common.issues); + } + }) + }; } } + removeCatch() { + return this._def.innerType; + } }; -ZodMap$1.create = (keyType, valueType, params) => { - return new ZodMap$1({ - valueType, - keyType, - typeName: ZodFirstPartyTypeKind$1.ZodMap, +ZodCatch$1.create = (type2, params) => { + return new ZodCatch$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodCatch, + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, ...processCreateParams$1(params) }); }; -let ZodSet$1 = class ZodSet extends ZodType$1 { +let ZodNaN$1 = class ZodNaN extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.set) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.nan) { + const ctx = this._getOrReturnCtx(input); addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.set, + expected: ZodParsedType$1.nan, received: ctx.parsedType }); return INVALID$1; } - const def = this._def; - if (def.minSize !== null) { - if (ctx.data.size < def.minSize.value) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - minimum: def.minSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.minSize.message - }); - status.dirty(); - } - } - if (def.maxSize !== null) { - if (ctx.data.size > def.maxSize.value) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - maximum: def.maxSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.maxSize.message + return { status: "valid", value: input.data }; + } +}; +ZodNaN$1.create = (params) => { + return new ZodNaN$1({ + typeName: ZodFirstPartyTypeKind$1.ZodNaN, + ...processCreateParams$1(params) + }); +}; +const BRAND$1 = Symbol("zod_brand"); +let ZodBranded$1 = class ZodBranded extends ZodType$1 { + _parse(input) { + const { ctx } = this._processInputParams(input); + const data = ctx.data; + return this._def.type._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + unwrap() { + return this._def.type; + } +}; +let ZodPipeline$1 = class ZodPipeline extends ZodType$1 { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.common.async) { + const handleAsync = async () => { + const inResult = await this._def.in._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx }); - status.dirty(); - } - } - const valueType = this._def.valueType; - function finalizeSet(elements2) { - const parsedSet = /* @__PURE__ */ new Set(); - for (const element of elements2) { - if (element.status === "aborted") + if (inResult.status === "aborted") return INVALID$1; - if (element.status === "dirty") + if (inResult.status === "dirty") { status.dirty(); - parsedSet.add(element.value); - } - return { status: status.value, value: parsedSet }; - } - const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, i2))); - if (ctx.common.async) { - return Promise.all(elements).then((elements2) => finalizeSet(elements2)); + return DIRTY$1(inResult.value); + } else { + return this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + }; + return handleAsync(); } else { - return finalizeSet(elements); + const inResult = this._def.in._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID$1; + if (inResult.status === "dirty") { + status.dirty(); + return { + status: "dirty", + value: inResult.value + }; + } else { + return this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } } } - min(minSize, message) { - return new ZodSet({ - ...this._def, - minSize: { value: minSize, message: errorUtil$1.toString(message) } + static create(a3, b3) { + return new ZodPipeline({ + in: a3, + out: b3, + typeName: ZodFirstPartyTypeKind$1.ZodPipeline }); } - max(maxSize, message) { - return new ZodSet({ - ...this._def, - maxSize: { value: maxSize, message: errorUtil$1.toString(message) } +}; +const custom$1 = (check, params = {}, fatal) => { + if (check) + return ZodAny$1.create().superRefine((data, ctx) => { + var _a2, _b; + if (!check(data)) { + const p2 = typeof params === "function" ? params(data) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; + ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); + } }); - } - size(size, message) { - return this.min(size, message).max(size, message); - } - nonempty(message) { - return this.min(1, message); - } + return ZodAny$1.create(); }; -ZodSet$1.create = (valueType, params) => { - return new ZodSet$1({ - valueType, - minSize: null, - maxSize: null, - typeName: ZodFirstPartyTypeKind$1.ZodSet, - ...processCreateParams$1(params) - }); +const late$1 = { + object: ZodObject$1.lazycreate +}; +var ZodFirstPartyTypeKind$1; +(function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; + ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; + ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; + ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; + ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; + ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; + ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; + ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; + ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; + ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; + ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; + ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; + ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; + ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; + ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; + ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; + ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; + ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; + ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; + ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; + ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; + ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; + ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; + ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; + ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; + ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; + ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; + ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; + ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; + ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; + ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; + ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; + ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; + ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; + ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; +})(ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {})); +const instanceOfType$1 = (cls, params = { + message: `Input not instance of ${cls.name}` +}) => custom$1((data) => data instanceof cls, params); +const stringType$1 = ZodString$1.create; +const numberType$1 = ZodNumber$1.create; +const nanType$1 = ZodNaN$1.create; +const bigIntType$1 = ZodBigInt$1.create; +const booleanType$1 = ZodBoolean$1.create; +const dateType$1 = ZodDate$1.create; +const symbolType$1 = ZodSymbol$1.create; +const undefinedType$1 = ZodUndefined$1.create; +const nullType$1 = ZodNull$1.create; +const anyType$1 = ZodAny$1.create; +const unknownType$1 = ZodUnknown$1.create; +const neverType$1 = ZodNever$1.create; +const voidType$1 = ZodVoid$1.create; +const arrayType$1 = ZodArray$1.create; +const objectType$1 = ZodObject$1.create; +const strictObjectType$1 = ZodObject$1.strictCreate; +const unionType$1 = ZodUnion$1.create; +const discriminatedUnionType$1 = ZodDiscriminatedUnion$1.create; +const intersectionType$1 = ZodIntersection$1.create; +const tupleType$1 = ZodTuple$1.create; +const recordType$1 = ZodRecord$1.create; +const mapType$1 = ZodMap$1.create; +const setType$1 = ZodSet$1.create; +const functionType$1 = ZodFunction$1.create; +const lazyType$1 = ZodLazy$1.create; +const literalType$1 = ZodLiteral$1.create; +const enumType$1 = ZodEnum$1.create; +const nativeEnumType$1 = ZodNativeEnum$1.create; +const promiseType$1 = ZodPromise$1.create; +const effectsType$1 = ZodEffects$1.create; +const optionalType$1 = ZodOptional$1.create; +const nullableType$1 = ZodNullable$1.create; +const preprocessType$1 = ZodEffects$1.createWithPreprocess; +const pipelineType$1 = ZodPipeline$1.create; +const ostring$1 = () => stringType$1().optional(); +const onumber$1 = () => numberType$1().optional(); +const oboolean$1 = () => booleanType$1().optional(); +const coerce$2 = { + string: (arg) => ZodString$1.create({ ...arg, coerce: true }), + number: (arg) => ZodNumber$1.create({ ...arg, coerce: true }), + boolean: (arg) => ZodBoolean$1.create({ + ...arg, + coerce: true + }), + bigint: (arg) => ZodBigInt$1.create({ ...arg, coerce: true }), + date: (arg) => ZodDate$1.create({ ...arg, coerce: true }) }; -let ZodFunction$1 = class ZodFunction extends ZodType$1 { - constructor() { - super(...arguments); - this.validate = this.implement; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.function) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.function, - received: ctx.parsedType - }); - return INVALID$1; - } - function makeArgsIssue(args, error) { - return makeIssue$1({ - data: args, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap$1(), - errorMap$1 - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode$1.invalid_arguments, - argumentsError: error - } - }); - } - function makeReturnsIssue(returns, error) { - return makeIssue$1({ - data: returns, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap$1(), - errorMap$1 - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode$1.invalid_return_type, - returnTypeError: error - } - }); - } - const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; - if (this._def.returns instanceof ZodPromise$1) { - return OK$1(async (...args) => { - const error = new ZodError$1([]); - const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => { - error.addIssue(makeArgsIssue(args, e)); - throw error; - }); - const result = await fn2(...parsedArgs); - const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => { - error.addIssue(makeReturnsIssue(result, e)); - throw error; - }); - return parsedReturns; - }); - } else { - return OK$1((...args) => { - const parsedArgs = this._def.args.safeParse(args, params); - if (!parsedArgs.success) { - throw new ZodError$1([makeArgsIssue(args, parsedArgs.error)]); - } - const result = fn2(...parsedArgs.data); - const parsedReturns = this._def.returns.safeParse(result, params); - if (!parsedReturns.success) { - throw new ZodError$1([makeReturnsIssue(result, parsedReturns.error)]); - } - return parsedReturns.data; - }); - } +const NEVER$1 = INVALID$1; +var z$5 = /* @__PURE__ */ Object.freeze({ + __proto__: null, + defaultErrorMap: errorMap$1, + setErrorMap: setErrorMap$1, + getErrorMap: getErrorMap$1, + makeIssue: makeIssue$1, + EMPTY_PATH: EMPTY_PATH$1, + addIssueToContext: addIssueToContext$1, + ParseStatus: ParseStatus$1, + INVALID: INVALID$1, + DIRTY: DIRTY$1, + OK: OK$1, + isAborted: isAborted$1, + isDirty: isDirty$1, + isValid: isValid$1, + isAsync: isAsync$1, + get util() { + return util$1; + }, + get objectUtil() { + return objectUtil$1; + }, + ZodParsedType: ZodParsedType$1, + getParsedType: getParsedType$1, + ZodType: ZodType$1, + ZodString: ZodString$1, + ZodNumber: ZodNumber$1, + ZodBigInt: ZodBigInt$1, + ZodBoolean: ZodBoolean$1, + ZodDate: ZodDate$1, + ZodSymbol: ZodSymbol$1, + ZodUndefined: ZodUndefined$1, + ZodNull: ZodNull$1, + ZodAny: ZodAny$1, + ZodUnknown: ZodUnknown$1, + ZodNever: ZodNever$1, + ZodVoid: ZodVoid$1, + ZodArray: ZodArray$1, + ZodObject: ZodObject$1, + ZodUnion: ZodUnion$1, + ZodDiscriminatedUnion: ZodDiscriminatedUnion$1, + ZodIntersection: ZodIntersection$1, + ZodTuple: ZodTuple$1, + ZodRecord: ZodRecord$1, + ZodMap: ZodMap$1, + ZodSet: ZodSet$1, + ZodFunction: ZodFunction$1, + ZodLazy: ZodLazy$1, + ZodLiteral: ZodLiteral$1, + ZodEnum: ZodEnum$1, + ZodNativeEnum: ZodNativeEnum$1, + ZodPromise: ZodPromise$1, + ZodEffects: ZodEffects$1, + ZodTransformer: ZodEffects$1, + ZodOptional: ZodOptional$1, + ZodNullable: ZodNullable$1, + ZodDefault: ZodDefault$1, + ZodCatch: ZodCatch$1, + ZodNaN: ZodNaN$1, + BRAND: BRAND$1, + ZodBranded: ZodBranded$1, + ZodPipeline: ZodPipeline$1, + custom: custom$1, + Schema: ZodType$1, + ZodSchema: ZodType$1, + late: late$1, + get ZodFirstPartyTypeKind() { + return ZodFirstPartyTypeKind$1; + }, + coerce: coerce$2, + any: anyType$1, + array: arrayType$1, + bigint: bigIntType$1, + boolean: booleanType$1, + date: dateType$1, + discriminatedUnion: discriminatedUnionType$1, + effect: effectsType$1, + "enum": enumType$1, + "function": functionType$1, + "instanceof": instanceOfType$1, + intersection: intersectionType$1, + lazy: lazyType$1, + literal: literalType$1, + map: mapType$1, + nan: nanType$1, + nativeEnum: nativeEnumType$1, + never: neverType$1, + "null": nullType$1, + nullable: nullableType$1, + number: numberType$1, + object: objectType$1, + oboolean: oboolean$1, + onumber: onumber$1, + optional: optionalType$1, + ostring: ostring$1, + pipeline: pipelineType$1, + preprocess: preprocessType$1, + promise: promiseType$1, + record: recordType$1, + set: setType$1, + strictObject: strictObjectType$1, + string: stringType$1, + symbol: symbolType$1, + transformer: effectsType$1, + tuple: tupleType$1, + "undefined": undefinedType$1, + union: unionType$1, + unknown: unknownType$1, + "void": voidType$1, + NEVER: NEVER$1, + ZodIssueCode: ZodIssueCode$1, + quotelessJson: quotelessJson$1, + ZodError: ZodError$1 +}); +const aleoAddressRegex$1 = /^aleo1[a-z0-9]{58}$/i; +const aleoViewKeyRegex$1 = /^AViewKey1[a-z0-9]{44}$/i; +const aleoPrivateKeyRegex$1 = /^APrivateKey1[a-z0-9]{47}$/i; +const aleoTransitionIdRegex$1 = /^au1[a-z0-9]{58}$/i; +const aleoTransactionIdRegex$1 = /^at1[a-z0-9]{58}$/i; +const aleoFieldRegex$1 = /^\d+field$/; +const aleoU32$1 = /^\d+u32$/; +const aleoU64$1 = /^\d+u64$/; +z$5.string().regex(aleoAddressRegex$1); +z$5.string().regex(aleoViewKeyRegex$1); +z$5.string().regex(aleoPrivateKeyRegex$1); +z$5.string().regex(aleoTransitionIdRegex$1); +z$5.string().regex(aleoTransactionIdRegex$1); +z$5.string().regex(aleoFieldRegex$1); +z$5.string().regex(aleoU32$1); +z$5.string().regex(aleoU64$1); +var InputOutputType$1; +(function(InputOutputType2) { + InputOutputType2["Record"] = "record"; + InputOutputType2["OutputRecord"] = "outputRecord"; + InputOutputType2["Public"] = "public"; + InputOutputType2["Private"] = "private"; + InputOutputType2["Constant"] = "constant"; + InputOutputType2["Future"] = "future"; + InputOutputType2["ExternalRecord"] = "external_record"; +})(InputOutputType$1 || (InputOutputType$1 = {})); +var EventType$1; +(function(EventType2) { + EventType2["Deploy"] = "Deploy"; + EventType2["Execute"] = "Execute"; + EventType2["Send"] = "Send"; + EventType2["Receive"] = "Receive"; + EventType2["Join"] = "Join"; + EventType2["Split"] = "Split"; + EventType2["Shield"] = "Shield"; + EventType2["Unshield"] = "Unshield"; + EventType2["Referral"] = "Referral"; + EventType2["Points"] = "Points"; + EventType2["Raffle"] = "Raffle"; +})(EventType$1 || (EventType$1 = {})); +var EventStatus$1; +(function(EventStatus2) { + EventStatus2["Creating"] = "Creating"; + EventStatus2["Pending"] = "Pending"; + EventStatus2["Settled"] = "Settled"; + EventStatus2["Failed"] = "Failed"; +})(EventStatus$1 || (EventStatus$1 = {})); +var Visibility$1; +(function(Visibility2) { + Visibility2["Private"] = "Private"; + Visibility2["Public"] = "Public"; +})(Visibility$1 || (Visibility$1 = {})); +var Network$1; +(function(Network2) { + Network2["AleoTestnet"] = "AleoTestnet"; + Network2["AleoCanarynet"] = "AleoCanarynet"; + Network2["AleoMainnet"] = "AleoMainnet"; +})(Network$1 || (Network$1 = {})); +z$5.nativeEnum(EventType$1); +z$5.nativeEnum(EventStatus$1); +z$5.nativeEnum(Network$1); +z$5.nativeEnum(Visibility$1); +const wc_aleo_methods$1 = [ + "decrypt", + "disconnect", + "getSelectedAccount", + "getBalance", + "getRecords", + "requestCreateEvent", + "getEvent", + "getEvents", + "createSharedState", + "importSharedState", + "requestSignature" +]; +const wc_required_aleo_chains$1 = ["aleo:1"]; +const wc_optional_aleo_chains$1 = [ + "aleo:0" + // for eventual mainnet +]; +const wc_aleo_chains$1 = [ + ...wc_required_aleo_chains$1, + ...wc_optional_aleo_chains$1 +]; +const wc_events$1 = [ + "chainChanged", + "accountSelected", + "selectedAccountSynced", + "sharedAccountSynced" +]; +const projectId$1 = "f0aaeffe71b636da453fce042d79d723"; +function isAndroid$1() { + if (typeof navigator === "undefined") { + return false; } - parameters() { - return this._def.args; + return /Android/i.test(navigator.userAgent); +} +const web3modal_puzzle_props_android$1 = { + projectId: projectId$1, + chains: wc_aleo_chains$1, + enableExplorer: true, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png" } - returnType() { - return this._def.returns; +}; +const web3modal_puzzle_props_default$1 = { + projectId: projectId$1, + chains: wc_aleo_chains$1, + enableExplorer: false, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } + } + ], + desktopWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "", + universal: "https://walletconnect.puzzle.online/" + } + }, + { + id: "avail", + name: "Avail Wallet", + links: { + native: "avail://", + universal: "https://avail.global" + } + } + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png", + avail: "https://i.imgur.com/GxNn8BO.png" } - args(...items) { - return new ZodFunction({ - ...this._def, - args: ZodTuple$1.create(items).rest(ZodUnknown$1.create()) - }); +}; +const web3modal_puzzle_props$1 = isAndroid$1() ? web3modal_puzzle_props_android$1 : web3modal_puzzle_props_default$1; +const name$1 = "@puzzlehq/sdk-core"; +const displayName$1 = "Puzzle SDK"; +const version$1 = "0.4.0"; +const description$1 = "Your portal to privacy"; +const main$1 = "./dist/puzzle.cjs.js"; +const module$1 = "./dist/puzzle.es.js"; +const browser$1 = "./dist/puzzle.umd.js"; +const types$3 = "./dist/types/src/index.d.ts"; +const exports$1 = { + ".": { + "import": "./dist/puzzle.es.js", + require: "./dist/puzzle.cjs.js", + browser: "./dist/puzzle.umd.js", + types: "./dist/types/src/index.d.ts" } - returns(returnType) { - return new ZodFunction({ - ...this._def, - returns: returnType +}; +const type$1 = "module"; +const scripts$1 = { + "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", + "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, + build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", + "type-check": "tsc --noEmit" +}; +const repository$1 = { + type: "git", + url: "git+https://github.com/puzzlehq/puzzle-sdk.git" +}; +const dependencies$1 = { + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", + "@walletconnect/types": "^2.11.2", + "@walletconnect/utils": "^2.11.2", + debug: "^4.3.4", + events: "^3.3.0", + ws: "^8.16.0" +}; +const peerDependencies$1 = { + buffer: "^6.0.3" +}; +const keywords$1 = [ + "puzzle", + "cryptocurrency wallet", + "privacy", + "aleo", + "web3", + "crypto", + "typescript" +]; +const author$1 = "Puzzle"; +const license$1 = "ISC"; +const bugs$1 = { + url: "https://github.com/puzzlehq/puzzle-sdk/issues" +}; +const homepage$1 = "https://github.com/puzzlehq/puzzle-sdk#readme"; +const pkg$1 = { + name: name$1, + displayName: displayName$1, + version: version$1, + description: description$1, + main: main$1, + module: module$1, + browser: browser$1, + types: types$3, + "private": false, + exports: exports$1, + type: type$1, + scripts: scripts$1, + repository: repository$1, + dependencies: dependencies$1, + peerDependencies: peerDependencies$1, + keywords: keywords$1, + author: author$1, + license: license$1, + bugs: bugs$1, + homepage: homepage$1 +}; +var On = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function A0(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; +} +var Pn = { exports: {} }; +/** +* [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 +*/ +(function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o2 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On : o2 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N2 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s2(u3, E2, u3).update(B2)[_3](); + }; + }, H2 = function(u3, E2, _3) { + return function(B2, R2) { + return new s2(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s2(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H2(u3, E2, "hex"); + return _3.create = function(B2) { + return new s2(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H2, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s2(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s2(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s2.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N2[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N2[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N2[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N2[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; + } + return this; + }, s2.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s2.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s2.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s2.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s2.prototype.toString = s2.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s2.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s2.prototype.buffer = s2.prototype.arrayBuffer, s2.prototype.digest = s2.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s2.call(this, u3, E2, _3); + } + v3.prototype = new s2(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s2.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z2, Fe2, $2, tt2, Te, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne, Ie; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z2 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z2 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z2 >>> 31), _3 = D2 ^ (Z2 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne = u3[42] << 2 | u3[43] >>> 30, Ie = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne, u3[45] = Me2 ^ ~Se2 & Ie, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne & St2, u3[47] = Se2 ^ ~Ie & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne ^ ~St2 & Ve2, u3[49] = Ie ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); +})(Pn); +const y0 = "logger/5.7.0"; +let Dn = false, Fn = false; +const Cr2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let Tn = Cr2.default, gi = null; +function w0() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; } - implement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - strictImplement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - static create(args, returns, params) { - return new ZodFunction({ - args: args ? args : ZodTuple$1.create([]).rest(ZodUnknown$1.create()), - returns: returns || ZodUnknown$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodFunction, - ...processCreateParams$1(params) - }); + return null; +} +const Un = w0(); +var Ai; +(function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; +})(Ai || (Ai = {})); +var re; +(function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; +})(re || (re = {})); +const kn = "0123456789abcdef"; +class L3 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); } -}; -let ZodLazy$1 = class ZodLazy extends ZodType$1 { - get schema() { - return this._def.getter(); + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn > Cr2[i2]) && console.log.apply(console, r3); } - _parse(input) { - const { ctx } = this._processInputParams(input); - const lazySchema = this._def.getter(); - return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + debug(...t2) { + this._log(L3.levels.DEBUG, t2); } -}; -ZodLazy$1.create = (getter, params) => { - return new ZodLazy$1({ - getter, - typeName: ZodFirstPartyTypeKind$1.ZodLazy, - ...processCreateParams$1(params) - }); -}; -let ZodLiteral$1 = class ZodLiteral extends ZodType$1 { - _parse(input) { - if (input.data !== this._def.value) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_literal, - expected: this._def.value - }); - return INVALID$1; - } - return { status: "valid", value: input.data }; + info(...t2) { + this._log(L3.levels.INFO, t2); } - get value() { - return this._def.value; + warn(...t2) { + this._log(L3.levels.WARNING, t2); } -}; -ZodLiteral$1.create = (value, params) => { - return new ZodLiteral$1({ - value, - typeName: ZodFirstPartyTypeKind$1.ZodLiteral, - ...processCreateParams$1(params) - }); -}; -function createZodEnum$1(values, params) { - return new ZodEnum$1({ - values, - typeName: ZodFirstPartyTypeKind$1.ZodEnum, - ...processCreateParams$1(params) - }); -} -let ZodEnum$1 = class ZodEnum extends ZodType$1 { - _parse(input) { - if (typeof input.data !== "string") { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext$1(ctx, { - expected: util$1.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode$1.invalid_type - }); - return INVALID$1; - } - if (this._def.values.indexOf(input.data) === -1) { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_enum_value, - options: expectedValues - }); - return INVALID$1; + makeError(t2, r3, i2) { + if (Fn) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L3.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn[m3[y3] >> 4], w3 += kn[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o2 = t2; + let h4 = ""; + switch (r3) { + case re.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; + } + case re.CALL_EXCEPTION: + case re.INSUFFICIENT_FUNDS: + case re.MISSING_NEW: + case re.NONCE_EXPIRED: + case re.REPLACEMENT_UNDERPRICED: + case re.TRANSACTION_REPLACED: + case re.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; } - return OK$1(input.data); + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o2, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; } - get options() { - return this._def.values; + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); } - get enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L3.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); } - get Values() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); } - get Enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); } - extract(values) { - return ZodEnum.create(values); + checkNormalize(t2) { + Un && this.throwError("platform missing String.prototype.normalize", L3.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un }); } - exclude(values) { - return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); } -}; -ZodEnum$1.create = createZodEnum$1; -let ZodNativeEnum$1 = class ZodNativeEnum extends ZodType$1 { - _parse(input) { - const nativeEnumValues = util$1.getValidEnumValues(this._def.values); - const ctx = this._getOrReturnCtx(input); - if (ctx.parsedType !== ZodParsedType$1.string && ctx.parsedType !== ZodParsedType$1.number) { - const expectedValues = util$1.objectValues(nativeEnumValues); - addIssueToContext$1(ctx, { - expected: util$1.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode$1.invalid_type - }); - return INVALID$1; - } - if (nativeEnumValues.indexOf(input.data) === -1) { - const expectedValues = util$1.objectValues(nativeEnumValues); - addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_enum_value, - options: expectedValues - }); - return INVALID$1; - } - return OK$1(input.data); + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L3.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L3.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); } - get enum() { - return this._def.values; + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); } -}; -ZodNativeEnum$1.create = (values, params) => { - return new ZodNativeEnum$1({ - values, - typeName: ZodFirstPartyTypeKind$1.ZodNativeEnum, - ...processCreateParams$1(params) - }); -}; -let ZodPromise$1 = class ZodPromise extends ZodType$1 { - unwrap() { - return this._def.type; + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L3.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.promise && ctx.common.async === false) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.promise, - received: ctx.parsedType - }); - return INVALID$1; + static globalLogger() { + return gi || (gi = new L3(y0)), gi; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } - const promisified = ctx.parsedType === ZodParsedType$1.promise ? ctx.data : Promise.resolve(ctx.data); - return OK$1(promisified.then((data) => { - return this._def.type.parseAsync(data, { - path: ctx.path, - errorMap: ctx.common.contextualErrorMap - }); - })); + Fn = !!t2, Dn = !!r3; } -}; -ZodPromise$1.create = (schema, params) => { - return new ZodPromise$1({ - type: schema, - typeName: ZodFirstPartyTypeKind$1.ZodPromise, - ...processCreateParams$1(params) - }); -}; -let ZodEffects$1 = class ZodEffects extends ZodType$1 { - innerType() { - return this._def.schema; + static setLogLevel(t2) { + const r3 = Cr2[t2.toLowerCase()]; + if (r3 == null) { + L3.globalLogger().warn("invalid log level - " + t2); + return; + } + Tn = r3; } - sourceType() { - return this._def.schema._def.typeName === ZodFirstPartyTypeKind$1.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + static from(t2) { + return new L3(t2); } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const effect = this._def.effect || null; - if (effect.type === "preprocess") { - const processed = effect.transform(ctx.data); - if (ctx.common.async) { - return Promise.resolve(processed).then((processed2) => { - return this._def.schema._parseAsync({ - data: processed2, - path: ctx.path, - parent: ctx - }); - }); - } else { - return this._def.schema._parseSync({ - data: processed, - path: ctx.path, - parent: ctx - }); - } +} +L3.errors = re, L3.levels = Ai; +const x0 = "bytes/5.7.0", Dt = new L3(x0); +function qn(e2) { + return !!e2.toHexString; +} +function rr(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; +} +function Kn(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; +} +function ir(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; +} +function Ot2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2) && (e2 = e2.toHexString()), Qt(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr(new Uint8Array(i2)); + } + return ir(e2) ? rr(new Uint8Array(e2)) : Dt.throwArgumentError("invalid arrayify value", "value", e2); +} +function Qt(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2); +} +const bi = "0123456789abcdef"; +function Kt(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2)) + return e2.toHexString(); + if (Qt(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi[(n4 & 240) >> 4] + bi[n4 & 15]; + } + return r3; + } + return Dt.throwArgumentError("invalid hexlify value", "value", e2); +} +function oe(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt(e2) : Qt(e2) || Dt.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; +} +var Ln = { exports: {} }, I0 = {}, _0 = Object.freeze({ __proto__: null, default: I0 }), B0 = A0(_0); +(function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; } - const checkCtx = { - addIssue: (arg) => { - addIssueToContext$1(ctx, arg); - if (arg.fatal) { - status.abort(); - } else { - status.dirty(); - } - }, - get path() { - return ctx.path; + function o2(A2, f3, a3) { + if (o2.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o2 : r3.BN = o2, o2.BN = o2, o2.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0.Buffer; + } catch { + } + o2.isBN = function(f3) { + return f3 instanceof o2 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o2.wordSize && Array.isArray(f3.words); + }, o2.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o2.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o2.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o2.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o2.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o2.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; } + this._strip(); }; - checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); - if (effect.type === "refinement") { - const executeRefinement = (acc) => { - const result = effect.refinement(acc, checkCtx); - if (ctx.common.async) { - return Promise.resolve(result); - } - if (result instanceof Promise) { - throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); - } - return acc; - }; - if (ctx.common.async === false) { - const inner = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inner.status === "aborted") - return INVALID$1; - if (inner.status === "dirty") - status.dirty(); - executeRefinement(inner.value); - return { status: status.value, value: inner.value }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { - if (inner.status === "aborted") - return INVALID$1; - if (inner.status === "dirty") - status.dirty(); - return executeRefinement(inner.value).then(() => { - return { status: status.value, value: inner.value }; - }); - }); + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o2.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s2 = 0, v3 = c2; v3 < l2; v3 += d5) + s2 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + if (M2 !== 0) { + var k2 = 1; + for (s2 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s2 < 67108864 ? this.words[0] += s2 : this._iaddn(s2); + } + this._strip(); + }, o2.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o2.prototype._move = function(f3) { + w3(f3, this); + }, o2.prototype.clone = function() { + var f3 = new o2(null); + return this.copy(f3), f3; + }, o2.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o2.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o2.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o2.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o2.prototype.inspect = y3; + } + else + o2.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N2 = [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]; + o2.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s2 = I2[f3], v3 = N2[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s2 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o2.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o2.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o2.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o2.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o2.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o2.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o2.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o2.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o2.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o2.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o2.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o2.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; } - } - if (effect.type === "transform") { - if (ctx.common.async === false) { - const base3 = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (!isValid$1(base3)) - return base3; - const result = effect.transform(base3.value, checkCtx); - if (result instanceof Promise) { - throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + return f3; + }, o2.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o2.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o2.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o2.prototype.isNeg = function() { + return this.negative !== 0; + }, o2.prototype.neg = function() { + return this.clone().ineg(); + }, o2.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o2.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o2.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o2.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o2.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o2.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o2.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o2.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o2.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o2.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o2.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o2.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o2.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o2.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o2.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o2.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o2.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o2.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o2.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o2.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s2 = 1; s2 < c2; s2++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s2, f3.length - 1), E2 = Math.max(0, s2 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s2 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s2] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s2] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s2, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z2 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te = d5[6] | 0, et2 = Te & 8191, rt2 = Te >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le = g3[3] | 0, vt2 = Le & 8191, mt2 = Le >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s2 = Math.imul(u3, ht2), s2 = s2 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s2 = Math.imul(B2, ht2), s2 = s2 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s2 = s2 + Math.imul(u3, lt2) | 0, s2 = s2 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s2 = Math.imul(P2, ht2), s2 = s2 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s2 = s2 + Math.imul(B2, lt2) | 0, s2 = s2 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s2 = s2 + Math.imul(u3, pt2) | 0, s2 = s2 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s2 = Math.imul(D2, ht2), s2 = s2 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s2 = s2 + Math.imul(P2, lt2) | 0, s2 = s2 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s2 = s2 + Math.imul(B2, pt2) | 0, s2 = s2 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s2 = s2 + Math.imul(u3, mt2) | 0, s2 = s2 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ne >>> 26) | 0, Ne &= 67108863, l2 = Math.imul(X2, ut2), s2 = Math.imul(X2, ht2), s2 = s2 + Math.imul(Z2, ut2) | 0, v3 = Math.imul(Z2, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s2 = s2 + Math.imul(D2, lt2) | 0, s2 = s2 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s2 = s2 + Math.imul(P2, pt2) | 0, s2 = s2 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s2 = s2 + Math.imul(B2, mt2) | 0, s2 = s2 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s2 = s2 + Math.imul(u3, At2) | 0, s2 = s2 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, l2 = Math.imul($2, ut2), s2 = Math.imul($2, ht2), s2 = s2 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s2 = s2 + Math.imul(X2, lt2) | 0, s2 = s2 + Math.imul(Z2, ct2) | 0, v3 = v3 + Math.imul(Z2, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s2 = s2 + Math.imul(D2, pt2) | 0, s2 = s2 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s2 = s2 + Math.imul(P2, mt2) | 0, s2 = s2 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s2 = s2 + Math.imul(B2, At2) | 0, s2 = s2 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s2 = s2 + Math.imul(u3, yt2) | 0, s2 = s2 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s2 = Math.imul(et2, ht2), s2 = s2 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s2 = s2 + Math.imul($2, lt2) | 0, s2 = s2 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s2 = s2 + Math.imul(X2, pt2) | 0, s2 = s2 + Math.imul(Z2, dt2) | 0, v3 = v3 + Math.imul(Z2, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s2 = s2 + Math.imul(D2, mt2) | 0, s2 = s2 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s2 = s2 + Math.imul(P2, At2) | 0, s2 = s2 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s2 = s2 + Math.imul(B2, yt2) | 0, s2 = s2 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s2 = s2 + Math.imul(u3, xt2) | 0, s2 = s2 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s2 = Math.imul(it2, ht2), s2 = s2 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s2 = s2 + Math.imul(et2, lt2) | 0, s2 = s2 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s2 = s2 + Math.imul($2, pt2) | 0, s2 = s2 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s2 = s2 + Math.imul(X2, mt2) | 0, s2 = s2 + Math.imul(Z2, vt2) | 0, v3 = v3 + Math.imul(Z2, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s2 = s2 + Math.imul(D2, At2) | 0, s2 = s2 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s2 = s2 + Math.imul(P2, yt2) | 0, s2 = s2 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s2 = s2 + Math.imul(B2, xt2) | 0, s2 = s2 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s2 = s2 + Math.imul(u3, Et2) | 0, s2 = s2 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s2 = Math.imul(ft2, ht2), s2 = s2 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s2 = s2 + Math.imul(it2, lt2) | 0, s2 = s2 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s2 = s2 + Math.imul(et2, pt2) | 0, s2 = s2 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s2 = s2 + Math.imul($2, mt2) | 0, s2 = s2 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s2 = s2 + Math.imul(X2, At2) | 0, s2 = s2 + Math.imul(Z2, gt2) | 0, v3 = v3 + Math.imul(Z2, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s2 = s2 + Math.imul(D2, yt2) | 0, s2 = s2 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s2 = s2 + Math.imul(P2, xt2) | 0, s2 = s2 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s2 = s2 + Math.imul(B2, Et2) | 0, s2 = s2 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s2 = s2 + Math.imul(u3, Nt2) | 0, s2 = s2 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s2 = Math.imul(st2, ht2), s2 = s2 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s2 = s2 + Math.imul(ft2, lt2) | 0, s2 = s2 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s2 = s2 + Math.imul(it2, pt2) | 0, s2 = s2 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s2 = s2 + Math.imul(et2, mt2) | 0, s2 = s2 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s2 = s2 + Math.imul($2, At2) | 0, s2 = s2 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s2 = s2 + Math.imul(X2, yt2) | 0, s2 = s2 + Math.imul(Z2, bt2) | 0, v3 = v3 + Math.imul(Z2, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s2 = s2 + Math.imul(D2, xt2) | 0, s2 = s2 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s2 = s2 + Math.imul(P2, Et2) | 0, s2 = s2 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s2 = s2 + Math.imul(B2, Nt2) | 0, s2 = s2 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s2 = s2 + Math.imul(u3, _t2) | 0, s2 = s2 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s2 = Math.imul(st2, lt2), s2 = s2 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s2 = s2 + Math.imul(ft2, pt2) | 0, s2 = s2 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s2 = s2 + Math.imul(it2, mt2) | 0, s2 = s2 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s2 = s2 + Math.imul(et2, At2) | 0, s2 = s2 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s2 = s2 + Math.imul($2, yt2) | 0, s2 = s2 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s2 = s2 + Math.imul(X2, xt2) | 0, s2 = s2 + Math.imul(Z2, wt2) | 0, v3 = v3 + Math.imul(Z2, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s2 = s2 + Math.imul(D2, Et2) | 0, s2 = s2 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s2 = s2 + Math.imul(P2, Nt2) | 0, s2 = s2 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s2 = s2 + Math.imul(B2, _t2) | 0, s2 = s2 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s2 = Math.imul(st2, pt2), s2 = s2 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s2 = s2 + Math.imul(ft2, mt2) | 0, s2 = s2 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s2 = s2 + Math.imul(it2, At2) | 0, s2 = s2 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s2 = s2 + Math.imul(et2, yt2) | 0, s2 = s2 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s2 = s2 + Math.imul($2, xt2) | 0, s2 = s2 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s2 = s2 + Math.imul(X2, Et2) | 0, s2 = s2 + Math.imul(Z2, Mt2) | 0, v3 = v3 + Math.imul(Z2, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s2 = s2 + Math.imul(D2, Nt2) | 0, s2 = s2 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s2 = s2 + Math.imul(P2, _t2) | 0, s2 = s2 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s2 = Math.imul(st2, mt2), s2 = s2 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s2 = s2 + Math.imul(ft2, At2) | 0, s2 = s2 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s2 = s2 + Math.imul(it2, yt2) | 0, s2 = s2 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s2 = s2 + Math.imul(et2, xt2) | 0, s2 = s2 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s2 = s2 + Math.imul($2, Et2) | 0, s2 = s2 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s2 = s2 + Math.imul(X2, Nt2) | 0, s2 = s2 + Math.imul(Z2, St2) | 0, v3 = v3 + Math.imul(Z2, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s2 = s2 + Math.imul(D2, _t2) | 0, s2 = s2 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s2 = Math.imul(st2, At2), s2 = s2 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s2 = s2 + Math.imul(ft2, yt2) | 0, s2 = s2 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s2 = s2 + Math.imul(it2, xt2) | 0, s2 = s2 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s2 = s2 + Math.imul(et2, Et2) | 0, s2 = s2 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s2 = s2 + Math.imul($2, Nt2) | 0, s2 = s2 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s2 = s2 + Math.imul(X2, _t2) | 0, s2 = s2 + Math.imul(Z2, It2) | 0, v3 = v3 + Math.imul(Z2, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s2 = Math.imul(st2, yt2), s2 = s2 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s2 = s2 + Math.imul(ft2, xt2) | 0, s2 = s2 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s2 = s2 + Math.imul(it2, Et2) | 0, s2 = s2 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s2 = s2 + Math.imul(et2, Nt2) | 0, s2 = s2 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s2 = s2 + Math.imul($2, _t2) | 0, s2 = s2 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s2 = Math.imul(st2, xt2), s2 = s2 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s2 = s2 + Math.imul(ft2, Et2) | 0, s2 = s2 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s2 = s2 + Math.imul(it2, Nt2) | 0, s2 = s2 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s2 = s2 + Math.imul(et2, _t2) | 0, s2 = s2 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s2 = Math.imul(st2, Et2), s2 = s2 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s2 = s2 + Math.imul(ft2, Nt2) | 0, s2 = s2 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s2 = s2 + Math.imul(it2, _t2) | 0, s2 = s2 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s2 = Math.imul(st2, Nt2), s2 = s2 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s2 = s2 + Math.imul(ft2, _t2) | 0, s2 = s2 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + M2 = (v3 + (s2 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s2 = Math.imul(st2, _t2), s2 = s2 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s2 & 8191) << 13) | 0; + return M2 = (v3 + (s2 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne, x2[4] = Ie, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s2 = Math.max(0, g3 - A2.length + 1); s2 <= l2; s2++) { + var v3 = g3 - s2, k2 = A2.words[v3] | 0, u3 = f3.words[s2] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o2.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o2.prototype.mul = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o2.prototype.mulf = function(f3) { + var a3 = new o2(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o2.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o2.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o2.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o2.prototype.sqr = function() { + return this.mul(this); + }, o2.prototype.isqr = function() { + return this.imul(this.clone()); + }, o2.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o2(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o2.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o2.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o2.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s2 = 0; s2 < x2; s2++) + l2.words[s2] = this.words[s2]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s2 = 0; s2 < this.length; s2++) + this.words[s2] = this.words[s2 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s2 = this.length - 1; s2 >= 0 && (v3 !== 0 || s2 >= d5); s2--) { + var k2 = this.words[s2] | 0; + this.words[s2] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o2.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o2.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o2.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o2.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o2.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o2.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o2.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o2.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o2.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o2.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o2.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o2.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o2.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o2.prototype.iabs = function() { + return this.negative = 0, this; + }, o2.prototype.abs = function() { + return this.clone().iabs(); + }, o2.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o2.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s2; + if (a3 !== "mod") { + s2 = new o2(null), s2.length = l2 + 1, s2.words = new Array(s2.length); + for (var v3 = 0; v3 < s2.length; v3++) + s2.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s2 && (s2.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s2 && (s2.words[u3] = E2); + } + return s2 && s2._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s2 || null, mod: d5 }; + }, o2.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o2(0), mod: new o2(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o2(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o2(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o2(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o2.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o2.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o2.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o2.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o2.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o2.prototype.modn = function(f3) { + return this.modrn(f3); + }, o2.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o2.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o2.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = new o2(0), M2 = new o2(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s2 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s2), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s2), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o2.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o2(1), g3 = new o2(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s2 = 0, v3 = 1; !(c2.words[0] & v3) && s2 < 26; ++s2, v3 <<= 1) + ; + if (s2 > 0) + for (c2.iushrn(s2); s2-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o2.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o2.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o2.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o2.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o2.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o2.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o2.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o2.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o2.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o2.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; } - return { status: status.value, value: result }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { - if (!isValid$1(base3)) - return base3; - return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); - }); } - } - util$1.assertNever(effect); + return a3; + }, o2.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o2.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o2.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o2.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o2.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o2.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o2.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o2.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o2.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o2.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o2.red = function(f3) { + return new Y2(f3); + }, o2.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o2.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o2.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o2.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o2.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o2.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o2.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o2.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o2.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o2.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o2.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o2.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o2.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o2.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o2.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o2.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o2.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H2 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o2(f3, 16), this.n = this.p.bitLength(), this.k = new o2(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o2(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o2._prime = function(f3) { + if (H2[f3]) + return H2[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H2[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o2._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o2(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o2(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s2 = this.m.bitLength(); + for (s2 = new o2(2 * s2 * s2).toRed(this); this.pow(s2, l2).cmp(M2) !== 0; ) + s2.redIAdd(M2); + for (var v3 = this.pow(s2, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o2(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o2(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o2(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s2 = a3.bitLength() % 26; + for (s2 === 0 && (s2 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s2 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; + } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s2 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o2.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o2(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o2(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On); +})(Ln); +var K2 = Ln.exports; +const jn = "bignumber/5.7.0"; +var Rr = K2.BN; +const Ae = new L3(jn), wi = {}, Qn = 9007199254740991; +function C0(e2) { + return e2 != null && (V2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt(e2) || typeof e2 == "bigint" || ir(e2)); +} +let Jn = false; +class V2 { + constructor(t2, r3) { + t2 !== wi && Ae.throwError("cannot call constructor directly; use BigNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); + } + fromTwos(t2) { + return Lt(j(this).fromTwos(t2)); + } + toTwos(t2) { + return Lt(j(this).toTwos(t2)); + } + abs() { + return this._hex[0] === "-" ? V2.from(this._hex.substring(1)) : this; + } + add(t2) { + return Lt(j(this).add(j(t2))); + } + sub(t2) { + return Lt(j(this).sub(j(t2))); + } + div(t2) { + return V2.from(t2).isZero() && Wt2("division-by-zero", "div"), Lt(j(this).div(j(t2))); + } + mul(t2) { + return Lt(j(this).mul(j(t2))); + } + mod(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("division-by-zero", "mod"), Lt(j(this).umod(r3)); + } + pow(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("negative-power", "pow"), Lt(j(this).pow(r3)); + } + and(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "and"), Lt(j(this).and(r3)); + } + or(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "or"), Lt(j(this).or(r3)); + } + xor(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "xor"), Lt(j(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "mask"), Lt(j(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shl"), Lt(j(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shr"), Lt(j(this).shrn(t2)); } -}; -ZodEffects$1.create = (schema, effect, params) => { - return new ZodEffects$1({ - schema, - typeName: ZodFirstPartyTypeKind$1.ZodEffects, - effect, - ...processCreateParams$1(params) - }); -}; -ZodEffects$1.createWithPreprocess = (preprocess, schema, params) => { - return new ZodEffects$1({ - schema, - effect: { type: "preprocess", transform: preprocess }, - typeName: ZodFirstPartyTypeKind$1.ZodEffects, - ...processCreateParams$1(params) - }); -}; -let ZodOptional$1 = class ZodOptional extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType$1.undefined) { - return OK$1(void 0); - } - return this._def.innerType._parse(input); + eq(t2) { + return j(this).eq(j(t2)); } - unwrap() { - return this._def.innerType; + lt(t2) { + return j(this).lt(j(t2)); } -}; -ZodOptional$1.create = (type2, params) => { - return new ZodOptional$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodOptional, - ...processCreateParams$1(params) - }); -}; -let ZodNullable$1 = class ZodNullable extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType$1.null) { - return OK$1(null); + lte(t2) { + return j(this).lte(j(t2)); + } + gt(t2) { + return j(this).gt(j(t2)); + } + gte(t2) { + return j(this).gte(j(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j(this).isZero(); + } + toNumber() { + try { + return j(this).toNumber(); + } catch { + Wt2("overflow", "toNumber", this.toString()); } - return this._def.innerType._parse(input); + return null; } - unwrap() { - return this._def.innerType; + toBigInt() { + try { + return BigInt(this.toString()); + } catch { + } + return Ae.throwError("this platform does not support BigInt", L3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); } -}; -ZodNullable$1.create = (type2, params) => { - return new ZodNullable$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodNullable, - ...processCreateParams$1(params) - }); -}; -let ZodDefault$1 = class ZodDefault extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - let data = ctx.data; - if (ctx.parsedType === ZodParsedType$1.undefined) { - data = this._def.defaultValue(); + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn || (Jn = true, Ae.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L3.errors.UNEXPECTED_ARGUMENT, {}) : Ae.throwError("BigNumber.toString does not accept parameters", L3.errors.UNEXPECTED_ARGUMENT, {})), j(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V2) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V2(wi, vr(t2)) : t2.match(/^-?[0-9]+$/) ? new V2(wi, vr(new Rr(t2))) : Ae.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt2("underflow", "BigNumber.from", t2), (t2 >= Qn || t2 <= -Qn) && Wt2("overflow", "BigNumber.from", t2), V2.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V2.from(r3.toString()); + if (ir(r3)) + return V2.from(Kt(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V2.from(i2); + } else { + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt(i2) || i2[0] === "-" && Qt(i2.substring(1)))) + return V2.from(i2); + } + return Ae.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } +} +function vr(e2) { + if (typeof e2 != "string") + return vr(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae.throwArgumentError("invalid hex", "value", e2), e2 = vr(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; +} +function Lt(e2) { + return V2.from(vr(e2)); +} +function j(e2) { + const t2 = V2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr("-" + t2.substring(3), 16) : new Rr(t2.substring(2), 16); +} +function Wt2(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae.throwError(e2, L3.errors.NUMERIC_FAULT, i2); +} +const Ht2 = new L3(jn), mr = {}, Gn = V2.from(0), Yn = V2.from(-1); +function Vn(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht2.throwError(e2, L3.errors.NUMERIC_FAULT, n4); +} +let gr = "0"; +for (; gr.length < 256; ) + gr += gr; +function xi(e2) { + if (typeof e2 != "number") + try { + e2 = V2.from(e2).toNumber(); + } catch { } - return this._def.innerType._parse({ - data, - path: ctx.path, - parent: ctx - }); + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr.substring(0, e2) : Ht2.throwArgumentError("invalid decimal size", "decimals", e2); +} +function Mi(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + e2 = V2.from(e2); + const i2 = e2.lt(Gn); + i2 && (e2 = e2.mul(Yn)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o2 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o2 : e2 = o2 + "." + n4, i2 && (e2 = "-" + e2), e2; +} +function be(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht2.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht2.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht2.throwArgumentError("too many decimal points", "value", e2); + let o2 = n4[0], h4 = n4[1]; + for (o2 || (o2 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V2.from(o2), b3 = V2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn)), m3; +} +class dr2 { + constructor(t2, r3, i2, n4) { + t2 !== mr && Ht2.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr2) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o2 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o2 || Ht2.throwArgumentError("invalid fixed format", "format", t2), r3 = o2[1] !== "u", i2 = parseInt(o2[2]), n4 = parseInt(o2[3]); + } + } else if (t2) { + const o2 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht2.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o2("signed", "boolean", r3), i2 = o2("width", "number", i2), n4 = o2("decimals", "number", n4); + } + return i2 % 8 && Ht2.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht2.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr2(mr, r3, i2, n4); + } +} +class Ut3 { + constructor(t2, r3, i2, n4) { + t2 !== mr && Ht2.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht2.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht2.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut3.from("1" + gr.substring(0, t2), this.format), n4 = O0.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); } - removeDefault() { - return this._def.innerType; + isZero() { + return this._value === "0.0" || this._value === "0"; } -}; -ZodDefault$1.create = (type2, params) => { - return new ZodDefault$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodDefault, - defaultValue: typeof params.default === "function" ? params.default : () => params.default, - ...processCreateParams$1(params) + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht2.throwArgumentError("invalid byte width", "width", t2); + const r3 = V2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut3.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut3.fromString(Mi(t2, r3), dr2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3), n4 = be(t2, i2.decimals); + !i2.signed && n4.lt(Gn) && Vn("unsigned value cannot be negative", "overflow", "value", t2); + let o2 = null; + i2.signed ? o2 = n4.toTwos(i2.width).toHexString() : (o2 = n4.toHexString(), o2 = oe(o2, i2.width / 8)); + const h4 = Mi(n4, i2.decimals); + return new Ut3(mr, o2, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3); + if (Ot2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o2 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi(n4, i2.decimals); + return new Ut3(mr, o2, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut3.fromString(t2, r3); + if (ir(t2)) + return Ut3.fromBytes(t2, r3); + try { + return Ut3.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht2.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } +} +const Wn = Ut3.from(1), O0 = Ut3.from("0.5"); +var Or; +(function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; +})(Or || (Or = {})); +var nr; +(function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; +})(nr || (nr = {})); +function T0(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; +} +function Si(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; }); -}; -let ZodCatch$1 = class ZodCatch extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const newCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - } - }; - const result = this._def.innerType._parse({ - data: newCtx.data, - path: newCtx.path, - parent: { - ...newCtx - } + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o2 = n4.split(":"); + r3 += parseInt(o2[0], 16), i2[r3] = t2(o2[1]); + }), i2; +} +function $n(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); +} +$n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0), $n("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function U0(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot2(t2); +} +function ef(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o2, h4) { + i2.call(o2, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); }); - if (isAsync$1(result)) { - return result.then((result2) => { - return { - status: "valid", - value: result2.status === "valid" ? result2.value : this._def.catchValue({ - get error() { - return new ZodError$1(newCtx.common.issues); - } - }) - }; - }); - } else { - return { - status: "valid", - value: result.status === "valid" ? result.value : this._def.catchValue({ - get error() { - return new ZodError$1(newCtx.common.issues); - } - }) - }; + }; + return n4(e2, t2), r3; +} +function k0(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; +} +function q0(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o2 = [0, 1]; + for (let H2 = 1; H2 < i2; H2++) + o2.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N2 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H2 = 0; H2 < y3; H2++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H2 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H2 < o2[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o2[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o2[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N2; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H2) => { + switch (H2 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H2 - 1; } + }); +} +function K0(e2) { + let t2 = 0; + return () => e2[t2++]; +} +function H0(e2) { + return K0(q0(e2)); +} +function z0(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; +} +function L0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; +} +function rf(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; +} +function j0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0(t2()); + return r3; +} +function Pr(e2, t2) { + let r3 = rf(e2(), e2), i2 = e2(), n4 = rf(i2, e2), o2 = L0(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o2[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; +} +function Q0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0(r3, e2)); } - removeCatch() { - return this._def.innerType; + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0(r3, e2)); } -}; -ZodCatch$1.create = (type2, params) => { - return new ZodCatch$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodCatch, - catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, - ...processCreateParams$1(params) - }); -}; -let ZodNaN$1 = class ZodNaN extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.nan) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.nan, - received: ctx.parsedType - }); - return INVALID$1; - } - return { status: "valid", value: input.data }; + return k0(ef(t2)); +} +function J0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); } -}; -ZodNaN$1.create = (params) => { - return new ZodNaN$1({ - typeName: ZodFirstPartyTypeKind$1.ZodNaN, - ...processCreateParams$1(params) - }); -}; -const BRAND$1 = Symbol("zod_brand"); -let ZodBranded$1 = class ZodBranded extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const data = ctx.data; - return this._def.type._parse({ - data, - path: ctx.path, - parent: ctx + return t2; +} +function nf(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0(e2, r3).forEach((o2, h4) => i2[h4].push(o2)); + return i2; +} +function G0(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0(t2), o2 = nf(n4.length, 1 + e2, t2); + return ef(o2.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; }); - } - unwrap() { - return this._def.type; + })); +} +function Y0(e2, t2) { + let r3 = 1 + t2(); + return nf(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); +} +function V0(e2) { + let t2 = Pr(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o2 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o2, fe0f: h4, save: p2, check: b3 }; + } +} +function W0() { + return H0(U0("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); +} +const Dr = W0(); +new Set(Pr(Dr)), new Set(Pr(Dr)), Q0(Dr), V0(Dr); +const X0 = new Uint8Array(32); +X0.fill(0); +const os = new Uint8Array(32); +os.fill(0), V2.from(-1); +const ss3 = V2.from(0), as = V2.from(1); +V2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe(as.toHexString(), 32), oe(ss3.toHexString(), 32); +var se = {}, Q = {}, yr = af; +function af(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +af.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var Ii = { exports: {} }; +typeof Object.create == "function" ? Ii.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); +} : Ii.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; } }; -let ZodPipeline$1 = class ZodPipeline extends ZodType$1 { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.common.async) { - const handleAsync = async () => { - const inResult = await this._def.in._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID$1; - if (inResult.status === "dirty") { - status.dirty(); - return DIRTY$1(inResult.value); - } else { - return this._def.out._parseAsync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - }; - return handleAsync(); - } else { - const inResult = this._def.in._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID$1; - if (inResult.status === "dirty") { - status.dirty(); - return { - status: "dirty", - value: inResult.value - }; - } else { - return this._def.out._parseSync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); +var us = yr, hs = Ii.exports; +Q.inherits = hs; +function cs(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; +} +function ls(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o2 = e2.charCodeAt(n4); + o2 < 128 ? r3[i2++] = o2 : o2 < 2048 ? (r3[i2++] = o2 >> 6 | 192, r3[i2++] = o2 & 63 | 128) : cs(e2, n4) ? (o2 = 65536 + ((o2 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o2 >> 18 | 240, r3[i2++] = o2 >> 12 & 63 | 128, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128) : (r3[i2++] = o2 >> 12 | 224, r3[i2++] = o2 >> 6 & 63 | 128, r3[i2++] = o2 & 63 | 128); + } + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; +} +Q.toArray = ls; +function ds(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf(e2[r3].toString(16)); + return t2; +} +Q.toHex = ds; +function uf(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; +} +Q.htonl = uf; +function ps(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf(n4)), r3 += cf(n4.toString(16)); + } + return r3; +} +Q.toHex32 = ps; +function hf(e2) { + return e2.length === 1 ? "0" + e2 : e2; +} +Q.zero2 = hf; +function cf(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; +} +Q.zero8 = cf; +function vs(e2, t2, r3, i2) { + var n4 = r3 - t2; + us(n4 % 4 === 0); + for (var o2 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o2.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o2[h4] = b3 >>> 0; + } + return o2; +} +Q.join32 = vs; +function ms$1(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o2 = e2[i2]; + t2 === "big" ? (r3[n4] = o2 >>> 24, r3[n4 + 1] = o2 >>> 16 & 255, r3[n4 + 2] = o2 >>> 8 & 255, r3[n4 + 3] = o2 & 255) : (r3[n4 + 3] = o2 >>> 24, r3[n4 + 2] = o2 >>> 16 & 255, r3[n4 + 1] = o2 >>> 8 & 255, r3[n4] = o2 & 255); + } + return r3; +} +Q.split32 = ms$1; +function gs(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; +} +Q.rotr32 = gs; +function As(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; +} +Q.rotl32 = As; +function bs(e2, t2) { + return e2 + t2 >>> 0; +} +Q.sum32 = bs; +function ys(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; +} +Q.sum32_3 = ys; +function ws(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; +} +Q.sum32_4 = ws; +function xs(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; +} +Q.sum32_5 = xs; +function Ms(e2, t2, r3, i2) { + var n4 = e2[t2], o2 = e2[t2 + 1], h4 = i2 + o2 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; +} +Q.sum64 = Ms; +function Es(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o2 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o2 >>> 0; +} +Q.sum64_hi = Es; +function Ss(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; +} +Q.sum64_lo = Ss; +function Ns(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o2 >>> 0, b3 += m3 < o2 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; +} +Q.sum64_4_hi = Ns; +function Is(e2, t2, r3, i2, n4, o2, h4, p2) { + var b3 = t2 + i2 + o2 + p2; + return b3 >>> 0; +} +Q.sum64_4_lo = Is; +function _s(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o2 >>> 0, w3 += y3 < o2 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; +} +Q.sum64_5_hi = _s; +function Bs(e2, t2, r3, i2, n4, o2, h4, p2, b3, m3) { + var w3 = t2 + i2 + o2 + p2 + m3; + return w3 >>> 0; +} +Q.sum64_5_lo = Bs; +function Cs(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; +} +Q.rotr64_hi = Cs; +function Rs(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q.rotr64_lo = Rs; +function Os(e2, t2, r3) { + return e2 >>> r3; +} +Q.shr64_hi = Os; +function Ps(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; +} +Q.shr64_lo = Ps; +var fr = {}, lf = Q, Ds = yr; +function Fr() { + 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; +} +fr.BlockHash = Fr, Fr.prototype.update = function(t2, r3) { + if (t2 = lf.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; +}, Fr.prototype.digest = function(t2) { + return this.update(this._pad()), Ds(this.pending === null), this._digest(t2); +}, Fr.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o2 = 1; o2 < i2; o2++) + n4[o2] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 & 255; + } else + for (n4[o2++] = t2 & 255, n4[o2++] = t2 >>> 8 & 255, n4[o2++] = t2 >>> 16 & 255, n4[o2++] = t2 >>> 24 & 255, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, n4[o2++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o2++] = 0; + return n4; +}; +var or = {}, ae = {}, Fs = Q, ue = Fs.rotr32; +function Ts(e2, t2, r3, i2) { + if (e2 === 0) + return df(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf(t2, r3, i2); + if (e2 === 2) + return pf(t2, r3, i2); +} +ae.ft_1 = Ts; +function df(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; +} +ae.ch32 = df; +function pf(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; +} +ae.maj32 = pf; +function vf(e2, t2, r3) { + return e2 ^ t2 ^ r3; +} +ae.p32 = vf; +function Us(e2) { + return ue(e2, 2) ^ ue(e2, 13) ^ ue(e2, 22); +} +ae.s0_256 = Us; +function ks(e2) { + return ue(e2, 6) ^ ue(e2, 11) ^ ue(e2, 25); +} +ae.s1_256 = ks; +function qs(e2) { + return ue(e2, 7) ^ ue(e2, 18) ^ e2 >>> 3; +} +ae.g0_256 = qs; +function Ks(e2) { + return ue(e2, 17) ^ ue(e2, 19) ^ e2 >>> 10; +} +ae.g1_256 = Ks; +var sr = Q, Hs = fr, zs = ae, _i = sr.rotl32, wr = sr.sum32, Ls = sr.sum32_5, js = zs.ft_1, mf = Hs.BlockHash, Qs = [1518500249, 1859775393, 2400959708, 3395469782]; +function he() { + if (!(this instanceof he)) + return new he(); + mf.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); +} +sr.inherits(he, mf); +var Js = he; +he.blockSize = 512, he.outSize = 160, he.hmacStrength = 80, he.padLength = 64, he.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls(_i(o2, 5), js(w3, h4, p2, b3), m3, i2[n4], Qs[w3]); + m3 = b3, b3 = p2, p2 = _i(h4, 30), h4 = o2, o2 = y3; + } + this.h[0] = wr(this.h[0], o2), this.h[1] = wr(this.h[1], h4), this.h[2] = wr(this.h[2], p2), this.h[3] = wr(this.h[3], b3), this.h[4] = wr(this.h[4], m3); +}, he.prototype._digest = function(t2) { + return t2 === "hex" ? sr.toHex32(this.h, "big") : sr.split32(this.h, "big"); +}; +var ar2 = Q, Gs = fr, ur = ae, Ys = yr, ie2 = ar2.sum32, Vs = ar2.sum32_4, Ws = ar2.sum32_5, Xs = ur.ch32, Zs = ur.maj32, $s = ur.s0_256, ta = ur.s1_256, ea = ur.g0_256, ra = ur.g1_256, gf = Gs.BlockHash, ia = [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 ce() { + if (!(this instanceof ce)) + return new ce(); + gf.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia, this.W = new Array(64); +} +ar2.inherits(ce, gf); +var Af = ce; +ce.blockSize = 512, ce.outSize = 256, ce.hmacStrength = 192, ce.padLength = 64, ce.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs(ra(i2[n4 - 2]), i2[n4 - 7], ea(i2[n4 - 15]), i2[n4 - 16]); + var o2 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws(S2, ta(m3), Xs(m3, w3, y3), this.k[n4], i2[n4]), N2 = ie2($s(o2), Zs(o2, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie2(b3, I2), b3 = p2, p2 = h4, h4 = o2, o2 = ie2(I2, N2); + } + this.h[0] = ie2(this.h[0], o2), this.h[1] = ie2(this.h[1], h4), this.h[2] = ie2(this.h[2], p2), this.h[3] = ie2(this.h[3], b3), this.h[4] = ie2(this.h[4], m3), this.h[5] = ie2(this.h[5], w3), this.h[6] = ie2(this.h[6], y3), this.h[7] = ie2(this.h[7], S2); +}, ce.prototype._digest = function(t2) { + return t2 === "hex" ? ar2.toHex32(this.h, "big") : ar2.split32(this.h, "big"); +}; +var Bi = Q, bf = Af; +function ye() { + if (!(this instanceof ye)) + return new ye(); + bf.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; +} +Bi.inherits(ye, bf); +var na = ye; +ye.blockSize = 512, ye.outSize = 224, ye.hmacStrength = 192, ye.padLength = 64, ye.prototype._digest = function(t2) { + return t2 === "hex" ? Bi.toHex32(this.h.slice(0, 7), "big") : Bi.split32(this.h.slice(0, 7), "big"); +}; +var jt2 = Q, fa = fr, oa = yr, le = jt2.rotr64_hi, de = jt2.rotr64_lo, yf = jt2.shr64_hi, wf = jt2.shr64_lo, Be = jt2.sum64, Ci = jt2.sum64_hi, Ri = jt2.sum64_lo, sa = jt2.sum64_4_hi, aa = jt2.sum64_4_lo, ua = jt2.sum64_5_hi, ha = jt2.sum64_5_lo, xf = fa.BlockHash, ca = [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 ne2() { + if (!(this instanceof ne2)) + return new ne2(); + xf.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca, this.W = new Array(160); +} +jt2.inherits(ne2, xf); +var Mf = ne2; +ne2.blockSize = 1024, ne2.outSize = 512, ne2.hmacStrength = 192, ne2.padLength = 128, ne2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o2 = xa(i2[n4 - 4], i2[n4 - 3]), h4 = Ma(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya(i2[n4 - 30], i2[n4 - 29]), w3 = wa(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa(o2, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa(o2, h4, p2, b3, m3, w3, y3, S2); + } +}, ne2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o2 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N2 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H2 = J2, z2 = Bt2, Pt2 = Aa(S2, I2), W2 = ba(S2, I2), Rt2 = la(S2, I2, N2, C2, F2), Yt3 = da(S2, I2, N2, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha(H2, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H2 = ma(n4, o2), z2 = ga(n4, o2), Pt2 = pa(n4, o2, h4, p2, b3), W2 = va(n4, o2, h4, p2, b3, m3); + var d5 = Ci(H2, z2, Pt2, W2), g3 = Ri(H2, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N2, U2 = C2, N2 = S2, C2 = I2, S2 = Ci(w3, y3, a3, c2), I2 = Ri(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o2, n4 = Ci(a3, c2, d5, g3), o2 = Ri(a3, c2, d5, g3); + } + Be(this.h, 0, n4, o2), Be(this.h, 2, h4, p2), Be(this.h, 4, b3, m3), Be(this.h, 6, w3, y3), Be(this.h, 8, S2, I2), Be(this.h, 10, N2, C2), Be(this.h, 12, F2, U2), Be(this.h, 14, J2, Bt2); +}, ne2.prototype._digest = function(t2) { + return t2 === "hex" ? jt2.toHex32(this.h, "big") : jt2.split32(this.h, "big"); +}; +function la(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ ~e2 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function da(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ ~t2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function pa(e2, t2, r3, i2, n4) { + var o2 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function va(e2, t2, r3, i2, n4, o2) { + var h4 = t2 & i2 ^ t2 & o2 ^ i2 & o2; + return h4 < 0 && (h4 += 4294967296), h4; +} +function ma(e2, t2) { + var r3 = le(e2, t2, 28), i2 = le(t2, e2, 2), n4 = le(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ga(e2, t2) { + var r3 = de(e2, t2, 28), i2 = de(t2, e2, 2), n4 = de(t2, e2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Aa(e2, t2) { + var r3 = le(e2, t2, 14), i2 = le(e2, t2, 18), n4 = le(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ba(e2, t2) { + var r3 = de(e2, t2, 14), i2 = de(e2, t2, 18), n4 = de(t2, e2, 9), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function ya(e2, t2) { + var r3 = le(e2, t2, 1), i2 = le(e2, t2, 8), n4 = yf(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function wa(e2, t2) { + var r3 = de(e2, t2, 1), i2 = de(e2, t2, 8), n4 = wf(e2, t2, 7), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function xa(e2, t2) { + var r3 = le(e2, t2, 19), i2 = le(t2, e2, 29), n4 = yf(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +function Ma(e2, t2) { + var r3 = de(e2, t2, 19), i2 = de(t2, e2, 29), n4 = wf(e2, t2, 6), o2 = r3 ^ i2 ^ n4; + return o2 < 0 && (o2 += 4294967296), o2; +} +var Oi = Q, Ef = Mf; +function we() { + if (!(this instanceof we)) + return new we(); + Ef.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; +} +Oi.inherits(we, Ef); +var Ea = we; +we.blockSize = 1024, we.outSize = 384, we.hmacStrength = 192, we.padLength = 128, we.prototype._digest = function(t2) { + return t2 === "hex" ? Oi.toHex32(this.h.slice(0, 12), "big") : Oi.split32(this.h.slice(0, 12), "big"); +}, or.sha1 = Js, or.sha224 = na, or.sha256 = Af, or.sha384 = Ea, or.sha512 = Mf; +var Sf = {}, Xe = Q, Sa = fr, Tr = Xe.rotl32, Nf = Xe.sum32, xr = Xe.sum32_3, If = Xe.sum32_4, _f = Sa.BlockHash; +function pe() { + if (!(this instanceof pe)) + return new pe(); + _f.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; +} +Xe.inherits(pe, _f), Sf.ripemd160 = pe, pe.blockSize = 512, pe.outSize = 160, pe.hmacStrength = 192, pe.padLength = 64, pe.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o2 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o2, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N2 = Nf(Tr(If(i2, Bf(I2, n4, o2, h4), t2[_a[I2] + r3], Na(I2)), Ca[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr(o2, 10), o2 = n4, n4 = N2, N2 = Nf(Tr(If(b3, Bf(79 - I2, m3, w3, y3), t2[Ba[I2] + r3], Ia(I2)), Ra[I2]), S2), b3 = S2, S2 = y3, y3 = Tr(w3, 10), w3 = m3, m3 = N2; + } + N2 = xr(this.h[1], o2, y3), this.h[1] = xr(this.h[2], h4, S2), this.h[2] = xr(this.h[3], p2, b3), this.h[3] = xr(this.h[4], i2, m3), this.h[4] = xr(this.h[0], n4, w3), this.h[0] = N2; +}, pe.prototype._digest = function(t2) { + return t2 === "hex" ? Xe.toHex32(this.h, "little") : Xe.split32(this.h, "little"); +}; +function Bf(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); +} +function Na(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; +} +function Ia(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; +} +var _a = [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], Ba = [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], Ca = [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], Ra = [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], Oa = Q, Pa = yr; +function hr2(e2, t2, r3) { + if (!(this instanceof hr2)) + return new hr2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa.toArray(t2, r3)); +} +var Da = hr2; +hr2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); +}, hr2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; +}, hr2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); +}, function(e2) { + var t2 = e2; + t2.utils = Q, t2.common = fr, t2.sha = or, t2.ripemd = Sf, t2.hmac = Da, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; +}(se); +function cr(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; +} +function Fa() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var Pi = Cf; +function Cf(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); +} +Cf.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); +}; +var fe = cr(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); } - } + return b3; } - static create(a3, b3) { - return new ZodPipeline({ - in: a3, - out: b3, - typeName: ZodFirstPartyTypeKind$1.ZodPipeline - }); + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; } + r3.zero2 = n4; + function o2(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o2, r3.encode = function(p2, b3) { + return b3 === "hex" ? o2(p2) : p2; + }; +}), Jt = cr(function(e2, t2) { + var r3 = t2; + r3.assert = Pi, r3.toArray = fe.toArray, r3.zero2 = fe.zero2, r3.toHex = fe.toHex, r3.encode = fe.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N2 = 0; N2 < y3.length; N2++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N2] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N2 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N2 === 3 && (N2 = -1), C2 === 3 && (C2 = -1); + var F2; + N2 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N2 : F2 = N2) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N2 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o2(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o2; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K2(b3, "hex", "le"); + } + r3.intFromLE = p2; +}), Ur = Jt.getNAF, Ta = Jt.getJSF, kr = Jt.assert; +function Ce(e2, t2) { + this.type = e2, this.p = new K2(t2.p, 16), this.red = t2.prime ? K2.red(t2.prime) : K2.mont(this.p), this.zero = new K2(0).toRed(this.red), this.one = new K2(1).toRed(this.red), this.two = new K2(2).toRed(this.red), this.n = t2.n && new K2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); +} +var Ze = Ce; +Ce.prototype.point = function() { + throw new Error("Not implemented"); +}, Ce.prototype.validate = function() { + throw new Error("Not implemented"); +}, Ce.prototype._fixedNafMul = function(t2, r3) { + kr(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur(r3, 1, this._bitLength), o2 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o2 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o2; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); +}, Ce.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o2 = n4.points, h4 = Ur(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o2[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o2[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o2[w3 - 1 >> 1]) : p2 = p2.add(o2[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; +}, Ce.prototype._wnafMulAdd = function(t2, r3, i2, n4, o2) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N2 = w3 - 1, C2 = w3; + if (h4[N2] !== 1 || h4[C2] !== 1) { + b3[N2] = Ur(i2[N2], h4[N2], this._bitLength), b3[C2] = Ur(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N2].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; + } + var F2 = [r3[N2], null, null, r3[C2]]; + r3[N2].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N2].add(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())) : r3[N2].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].add(r3[C2].neg())) : (F2[1] = r3[N2].toJ().mixedAdd(r3[C2]), F2[2] = r3[N2].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta(i2[N2], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N2] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N2][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N2] = F2; + } + } + var H2 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; + } + if (w3 >= 0 && Pt2++, H2 = H2.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H2 = H2.mixedAdd(S2) : H2 = H2.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o2 ? H2 : H2.toP(); +}; +function Xt(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; +} +Ce.BasePoint = Xt, Xt.prototype.eq = function() { + throw new Error("Not implemented"); +}, Xt.prototype.validate = function() { + return this.curve.validate(this); +}, Ce.prototype.decodePoint = function(t2, r3) { + t2 = Jt.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); +}, Xt.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); +}, Xt.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); +}, Xt.prototype.encode = function(t2, r3) { + return Jt.encode(this._encode(r3), t2); +}, Xt.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; +}, Xt.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; +}, Xt.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o2 = 0; o2 < r3; o2 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; +}, Xt.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o2 = 1; o2 < i2; o2++) + r3[o2] = r3[o2 - 1].add(n4); + return { wnd: t2, points: r3 }; +}, Xt.prototype._getBeta = function() { + return null; +}, Xt.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; +}; +var Di = cr(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; +}), Ua = Jt.assert; +function Zt2(e2) { + Ze.call(this, "short", e2), this.a = new K2(e2.a, 16).toRed(this.red), this.b = new K2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +Di(Zt2, Ze); +var ka = Zt2; +Zt2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K2(t2.lambda, 16); + else { + var o2 = this._getEndoRoots(this.n); + this.g.mul(o2[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o2[0] : (i2 = o2[1], Ua(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K2(p2.a, 16), b: new K2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } +}, Zt2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K2.mont(t2), i2 = new K2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o2 = new K2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o2).fromRed(), p2 = n4.redSub(o2).fromRed(); + return [h4, p2]; +}, Zt2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o2 = new K2(1), h4 = new K2(0), p2 = new K2(0), b3 = new K2(1), m3, w3, y3, S2, I2, N2, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o2)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o2, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o2, o2 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N2 = J2; + var H2 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N2.sqr()); + return z2.cmp(H2) >= 0 && (I2 = m3, N2 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N2 = N2.neg()), [{ a: y3, b: S2 }, { a: I2, b: N2 }]; +}, Zt2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o2 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o2.mul(i2.a), b3 = h4.mul(n4.a), m3 = o2.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; +}, Zt2.prototype.pointFromX = function(t2, r3) { + t2 = new K2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o2 = n4.fromRed().isOdd(); + return (r3 && !o2 || !r3 && o2) && (n4 = n4.redNeg()), this.point(t2, n4); +}, Zt2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o2 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o2).cmpn(0) === 0; +}, Zt2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o2 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o2[h4 * 2] = p2.k1, o2[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o2, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o2[y3] = null; + return w3; }; -const custom$1 = (check, params = {}, fatal) => { - if (check) - return ZodAny$1.create().superRefine((data, ctx) => { - var _a, _b; - if (!check(data)) { - const p3 = typeof params === "function" ? params(data) : params; - const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p3 === "string" ? { message: p3 } : p3; - ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); - } - }); - return ZodAny$1.create(); -}; -const late$1 = { - object: ZodObject$1.lazycreate -}; -var ZodFirstPartyTypeKind$1; -(function(ZodFirstPartyTypeKind2) { - ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; - ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; - ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; - ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; - ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; - ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; - ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; - ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; - ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; - ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; - ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; - ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; - ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; - ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; - ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; - ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; - ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; - ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; - ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; - ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; - ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; - ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; - ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; - ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; - ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; - ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; - ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; - ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; - ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; - ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; - ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; - ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; - ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; - ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; - ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; -})(ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {})); -const instanceOfType$1 = (cls, params = { - message: `Input not instance of ${cls.name}` -}) => custom$1((data) => data instanceof cls, params); -const stringType$1 = ZodString$1.create; -const numberType$1 = ZodNumber$1.create; -const nanType$1 = ZodNaN$1.create; -const bigIntType$1 = ZodBigInt$1.create; -const booleanType$1 = ZodBoolean$1.create; -const dateType$1 = ZodDate$1.create; -const symbolType$1 = ZodSymbol$1.create; -const undefinedType$1 = ZodUndefined$1.create; -const nullType$1 = ZodNull$1.create; -const anyType$1 = ZodAny$1.create; -const unknownType$1 = ZodUnknown$1.create; -const neverType$1 = ZodNever$1.create; -const voidType$1 = ZodVoid$1.create; -const arrayType$1 = ZodArray$1.create; -const objectType$1 = ZodObject$1.create; -const strictObjectType$1 = ZodObject$1.strictCreate; -const unionType$1 = ZodUnion$1.create; -const discriminatedUnionType$1 = ZodDiscriminatedUnion$1.create; -const intersectionType$1 = ZodIntersection$1.create; -const tupleType$1 = ZodTuple$1.create; -const recordType$1 = ZodRecord$1.create; -const mapType$1 = ZodMap$1.create; -const setType$1 = ZodSet$1.create; -const functionType$1 = ZodFunction$1.create; -const lazyType$1 = ZodLazy$1.create; -const literalType$1 = ZodLiteral$1.create; -const enumType$1 = ZodEnum$1.create; -const nativeEnumType$1 = ZodNativeEnum$1.create; -const promiseType$1 = ZodPromise$1.create; -const effectsType$1 = ZodEffects$1.create; -const optionalType$1 = ZodOptional$1.create; -const nullableType$1 = ZodNullable$1.create; -const preprocessType$1 = ZodEffects$1.createWithPreprocess; -const pipelineType$1 = ZodPipeline$1.create; -const ostring$1 = () => stringType$1().optional(); -const onumber$1 = () => numberType$1().optional(); -const oboolean$1 = () => booleanType$1().optional(); -const coerce$2 = { - string: (arg) => ZodString$1.create({ ...arg, coerce: true }), - number: (arg) => ZodNumber$1.create({ ...arg, coerce: true }), - boolean: (arg) => ZodBoolean$1.create({ - ...arg, - coerce: true - }), - bigint: (arg) => ZodBigInt$1.create({ ...arg, coerce: true }), - date: (arg) => ZodDate$1.create({ ...arg, coerce: true }) +function Ft(e2, t2, r3, i2) { + Ze.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); +} +Di(Ft, Ze.BasePoint), Zt2.prototype.point = function(t2, r3, i2) { + return new Ft(this, t2, r3, i2); +}, Zt2.prototype.pointFromJSON = function(t2, r3) { + return Ft.fromJSON(this, t2, r3); +}, Ft.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o2) { + return i2.point(o2.x.redMul(i2.endo.beta), o2.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } +}, Ft.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; +}, Ft.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o2(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o2)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o2)) } }, n4; +}, Ft.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Ft.prototype.isInfinity = function() { + return this.inf; +}, Ft.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); +}, Ft.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o2 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o2.redSqr().redISub(this.x.redAdd(this.x)), p2 = o2.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); +}, Ft.prototype.getX = function() { + return this.x.fromRed(); +}, Ft.prototype.getY = function() { + return this.y.fromRed(); +}, Ft.prototype.mul = function(t2) { + return t2 = new K2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); +}, Ft.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2) : this.curve._wnafMulAdd(1, n4, o2, 2); +}, Ft.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o2 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o2, true) : this.curve._wnafMulAdd(1, n4, o2, 2, true); +}, Ft.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); +}, Ft.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o2) { + return o2.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; +}, Ft.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; }; -const NEVER$1 = INVALID$1; -var z2 = /* @__PURE__ */ Object.freeze({ - __proto__: null, - defaultErrorMap: errorMap$1, - setErrorMap: setErrorMap$1, - getErrorMap: getErrorMap$1, - makeIssue: makeIssue$1, - EMPTY_PATH: EMPTY_PATH$1, - addIssueToContext: addIssueToContext$1, - ParseStatus: ParseStatus$1, - INVALID: INVALID$1, - DIRTY: DIRTY$1, - OK: OK$1, - isAborted: isAborted$1, - isDirty: isDirty$1, - isValid: isValid$1, - isAsync: isAsync$1, - get util() { - return util$1; - }, - get objectUtil() { - return objectUtil$1; - }, - ZodParsedType: ZodParsedType$1, - getParsedType: getParsedType$1, - ZodType: ZodType$1, - ZodString: ZodString$1, - ZodNumber: ZodNumber$1, - ZodBigInt: ZodBigInt$1, - ZodBoolean: ZodBoolean$1, - ZodDate: ZodDate$1, - ZodSymbol: ZodSymbol$1, - ZodUndefined: ZodUndefined$1, - ZodNull: ZodNull$1, - ZodAny: ZodAny$1, - ZodUnknown: ZodUnknown$1, - ZodNever: ZodNever$1, - ZodVoid: ZodVoid$1, - ZodArray: ZodArray$1, - ZodObject: ZodObject$1, - ZodUnion: ZodUnion$1, - ZodDiscriminatedUnion: ZodDiscriminatedUnion$1, - ZodIntersection: ZodIntersection$1, - ZodTuple: ZodTuple$1, - ZodRecord: ZodRecord$1, - ZodMap: ZodMap$1, - ZodSet: ZodSet$1, - ZodFunction: ZodFunction$1, - ZodLazy: ZodLazy$1, - ZodLiteral: ZodLiteral$1, - ZodEnum: ZodEnum$1, - ZodNativeEnum: ZodNativeEnum$1, - ZodPromise: ZodPromise$1, - ZodEffects: ZodEffects$1, - ZodTransformer: ZodEffects$1, - ZodOptional: ZodOptional$1, - ZodNullable: ZodNullable$1, - ZodDefault: ZodDefault$1, - ZodCatch: ZodCatch$1, - ZodNaN: ZodNaN$1, - BRAND: BRAND$1, - ZodBranded: ZodBranded$1, - ZodPipeline: ZodPipeline$1, - custom: custom$1, - Schema: ZodType$1, - ZodSchema: ZodType$1, - late: late$1, - get ZodFirstPartyTypeKind() { - return ZodFirstPartyTypeKind$1; - }, - coerce: coerce$2, - any: anyType$1, - array: arrayType$1, - bigint: bigIntType$1, - boolean: booleanType$1, - date: dateType$1, - discriminatedUnion: discriminatedUnionType$1, - effect: effectsType$1, - "enum": enumType$1, - "function": functionType$1, - "instanceof": instanceOfType$1, - intersection: intersectionType$1, - lazy: lazyType$1, - literal: literalType$1, - map: mapType$1, - nan: nanType$1, - nativeEnum: nativeEnumType$1, - never: neverType$1, - "null": nullType$1, - nullable: nullableType$1, - number: numberType$1, - object: objectType$1, - oboolean: oboolean$1, - onumber: onumber$1, - optional: optionalType$1, - ostring: ostring$1, - pipeline: pipelineType$1, - preprocess: preprocessType$1, - promise: promiseType$1, - record: recordType$1, - set: setType$1, - strictObject: strictObjectType$1, - string: stringType$1, - symbol: symbolType$1, - transformer: effectsType$1, - tuple: tupleType$1, - "undefined": undefinedType$1, - union: unionType$1, - unknown: unknownType$1, - "void": voidType$1, - NEVER: NEVER$1, - ZodIssueCode: ZodIssueCode$1, - quotelessJson: quotelessJson$1, - ZodError: ZodError$1 +function Tt(e2, t2, r3, i2) { + Ze.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K2(0)) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), this.z = new K2(i2, 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; +} +Di(Tt, Ze.BasePoint), Zt2.prototype.jpoint = function(t2, r3, i2) { + return new Tt(this, t2, r3, i2); +}, Tt.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); +}, Tt.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}, Tt.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o2 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o2), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N2 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N2, C2); +}, Tt.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o2 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o2.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o2.redMul(w3)), N2 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N2); +}, Tt.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o2 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N2 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N2.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N2.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o2), b3); +}, Tt.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}, Tt.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N2 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N2 = N2.redIAdd(N2); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N2).redISub(N2), r3 = C2.redMul(N2.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o2 = this.y.redSqr(), h4 = o2.redSqr(), p2 = this.x.redAdd(o2).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N2 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N2 = N2.redAdd(N2).redIAdd(N2); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N2.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N2.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); +}, Tt.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o2 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o2)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N2, C2); +}, Tt.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o2 = t2.redAdd(t2).redIAdd(t2), h4 = o2.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o2.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N2 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N2); +}, Tt.prototype.mul = function(t2, r3) { + return t2 = new K2(t2, r3), this.curve._wnafMul(this, t2); +}, Tt.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o2 = i2.redMul(t2.z); + return this.y.redMul(o2).redISub(t2.y.redMul(n4)).cmpn(0) === 0; +}, Tt.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o2 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o2), this.x.cmp(i2) === 0) + return true; + } +}, Tt.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}, Tt.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var qr = cr(function(e2, t2) { + var r3 = t2; + r3.base = Ze, r3.short = ka, r3.mont = null, r3.edwards = null; +}), Kr = cr(function(e2, t2) { + var r3 = t2, i2 = Jt.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr.short(p2) : p2.type === "edwards" ? this.curve = new qr.edwards(p2) : this.curve = new qr.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o2(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o2("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: se.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o2("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: se.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o2("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: se.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o2("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: se.sha384, gRed: false, 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"] }), o2("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: se.sha512, gRed: false, 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"] }), o2("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se.sha256, gRed: false, g: ["9"] }), o2("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: se.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o2("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: se.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); }); -const aleoAddressRegex$1 = /^aleo1[a-z0-9]{58}$/i; -const aleoViewKeyRegex$1 = /^AViewKey1[a-z0-9]{44}$/i; -const aleoPrivateKeyRegex$1 = /^APrivateKey1[a-z0-9]{47}$/i; -const aleoTransactionIdRegex$1 = /^at1[a-z0-9]{58}$/i; -const aleoFieldRegex$1 = /^\d+field$/; -const aleoU32$1 = /^\d+u32$/; -const aleoU64$1 = /^\d+u64$/; -z2.string().regex(aleoAddressRegex$1); -z2.string().regex(aleoViewKeyRegex$1); -z2.string().regex(aleoPrivateKeyRegex$1); -z2.string().regex(aleoTransactionIdRegex$1); -z2.string().regex(aleoFieldRegex$1); -z2.string().regex(aleoU32$1); -z2.string().regex(aleoU64$1); -var InputOutputType$1; -(function(InputOutputType2) { - InputOutputType2["Record"] = "record"; - InputOutputType2["OutputRecord"] = "outputRecord"; - InputOutputType2["Public"] = "public"; - InputOutputType2["Private"] = "private"; - InputOutputType2["Constant"] = "constant"; - InputOutputType2["Future"] = "future"; - InputOutputType2["ExternalRecord"] = "external_record"; -})(InputOutputType$1 || (InputOutputType$1 = {})); -var EventType$1; -(function(EventType2) { - EventType2["Deploy"] = "Deploy"; - EventType2["Execute"] = "Execute"; - EventType2["Send"] = "Send"; - EventType2["Receive"] = "Receive"; - EventType2["Join"] = "Join"; - EventType2["Split"] = "Split"; - EventType2["Shield"] = "Shield"; - EventType2["Unshield"] = "Unshield"; -})(EventType$1 || (EventType$1 = {})); -var EventStatus$1; -(function(EventStatus2) { - EventStatus2["Creating"] = "Creating"; - EventStatus2["Pending"] = "Pending"; - EventStatus2["Settled"] = "Settled"; - EventStatus2["Failed"] = "Failed"; -})(EventStatus$1 || (EventStatus$1 = {})); -var Visibility$1; -(function(Visibility2) { - Visibility2["Private"] = "Private"; - Visibility2["Public"] = "Public"; -})(Visibility$1 || (Visibility$1 = {})); -var Network$1; -(function(Network2) { - Network2["AleoTestnet"] = "AleoTestnet"; - Network2["AleoMainnet"] = "AleoMainnet"; -})(Network$1 || (Network$1 = {})); -var AssetType$1; -(function(AssetType2) { - AssetType2[AssetType2["ALEO"] = 0] = "ALEO"; -})(AssetType$1 || (AssetType$1 = {})); -z2.nativeEnum(EventType$1); -z2.nativeEnum(EventStatus$1); -z2.nativeEnum(Network$1); -z2.nativeEnum(Visibility$1); +function Re(e2) { + if (!(this instanceof Re)) + return new Re(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe.toArray(e2.pers, e2.persEnc || "hex"); + Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); +} +var Rf = Re; +Re.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o2 = 0; o2 < this.V.length; o2++) + this.K[o2] = 0, this.V[o2] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; +}, Re.prototype._hmac = function() { + return new se.hmac(this.hash, this.K); +}, Re.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); +}, Re.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe.toArray(t2, r3), i2 = fe.toArray(i2, n4), Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; +}, Re.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o2 = []; o2.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o2 = o2.concat(this.V); + var h4 = o2.slice(0, t2); + return this._update(i2), this._reseed++, fe.encode(h4, r3); +}; +var Fi = Jt.assert; +function kt2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); +} +var Ti = kt2; +kt2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { pub: r3, pubEnc: i2 }); +}, kt2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { priv: r3, privEnc: i2 }); +}, kt2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; +}, kt2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; +}, kt2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; +}, kt2.prototype._importPrivate = function(t2, r3) { + this.priv = new K2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); +}, kt2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); +}, kt2.prototype.derive = function(t2) { + return t2.validate() || Fi(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); +}, kt2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); +}, kt2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); +}, kt2.prototype.inspect = function() { + return ""; +}; +var qa = Jt.assert; +function Hr(e2, t2) { + if (e2 instanceof Hr) + return e2; + this._importDER(e2, t2) || (qa(e2.r && e2.s, "Signature without r or s"), this.r = new K2(e2.r, 16), this.s = new K2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); +} +var zr = Hr; +function Ka() { + this.place = 0; +} +function Ui(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o2 = 0, h4 = t2.place; o2 < i2; o2++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); +} +function Of(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); +} +Hr.prototype._importDER = function(t2, r3) { + t2 = Jt.toArray(t2, r3); + var i2 = new Ka(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o2 = Ui(t2, i2); + if (o2 === false) + return false; + var h4 = t2.slice(i2.place, o2 + i2.place); + if (i2.place += o2, t2[i2.place++] !== 2) + return false; + var p2 = Ui(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K2(h4), this.s = new K2(b3), this.recoveryParam = null, true; +}; +function ki(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); +} +Hr.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of(r3), i2 = Of(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki(n4, i2.length); + var o2 = n4.concat(i2), h4 = [48]; + return ki(h4, o2.length), h4 = h4.concat(o2), Jt.encode(h4, t2); +}; +var Ha = function() { + throw new Error("unsupported"); +}, Pf = Jt.assert; +function $t(e2) { + if (!(this instanceof $t)) + return new $t(e2); + typeof e2 == "string" && (Pf(Object.prototype.hasOwnProperty.call(Kr, e2), "Unknown curve " + e2), e2 = Kr[e2]), e2 instanceof Kr.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; +} +var za = $t; +$t.prototype.keyPair = function(t2) { + return new Ti(this, t2); +}, $t.prototype.keyFromPrivate = function(t2, r3) { + return Ti.fromPrivate(this, t2, r3); +}, $t.prototype.keyFromPublic = function(t2, r3) { + return Ti.fromPublic(this, t2, r3); +}, $t.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K2(2)); ; ) { + var o2 = new K2(r3.generate(i2)); + if (!(o2.cmp(n4) > 0)) + return o2.iaddn(1), this.keyFromPrivate(o2); + } +}, $t.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; +}, $t.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K2(t2, 16)); + for (var o2 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o2), p2 = t2.toArray("be", o2), b3 = new Rf({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N2 = I2.umod(this.n); + if (N2.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N2.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N2) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr({ r: N2, s: C2, recoveryParam: F2 }); + } + } + } + } + } +}, $t.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr(r3, "hex"); + var o2 = r3.r, h4 = r3.s; + if (o2.cmpn(1) < 0 || o2.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o2).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o2)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o2) === 0); +}, $t.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr(t2, i2); + var n4 = this.n, o2 = new K2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o2).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); +}, $t.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o2; + try { + o2 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; + } + if (o2.eq(r3)) + return n4; + } + throw new Error("Unable to find valid recovery factor"); +}; +var La = cr(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr, r3.curves = Kr, r3.ec = za, r3.eddsa = null; +}); +La.ec; +var Ff; +(function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; +})(Ff || (Ff = {})); +const go = { 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 } }; +function tr(e2, t2) { + const { message: r3, code: i2 } = go[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; +} +const emitter$1 = new EventEmitter$1(); +let connection$1 = void 0; +async function configureConnection$1(options) { + let disconnectSessions = false; + const thisVersion = pkg$1.version; + const prevVersion = localStorage.getItem("puzzle_sdk_version"); + if (thisVersion !== prevVersion) { + console.log( + `${pkg$1.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" + ); + localStorage.setItem("puzzle_sdk_version", thisVersion); + disconnectSessions = true; + } + connection$1 = new G({ + projectId: options.projectId ?? projectId$1, + metadata: { + name: options.dAppName, + description: options.dAppDescription, + url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", + icons: [options.dAppIconURL] + }, + modalOptions: { ...web3modal_puzzle_props$1 } + }); + if (disconnectSessions) { + localStorage.removeItem("puzzle-hasInjectedConnection"); + try { + disconnectOnVersionChange$1(connection$1, options.onDisconnect); + } catch (e2) { + console.error(e2); + } + } + connection$1.onSessionDelete(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + connection$1.onSessionExpire(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + if (typeof window !== "undefined") { + window.puzzleSdkConnection = connection$1; + } + return connection$1; +} +async function disconnectOnVersionChange$1(connection2, onDisconnect) { + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (session) { + console.log("Disconnecting session", session); + onDisconnect && onDisconnect(); + connection2.disconnect({ + topic: session.topic, + reason: tr("USER_DISCONNECTED") + }); + } +} +async function getWalletConnectModalSignClient$1() { + return new Promise((resolve) => { + if (connection$1) { + resolve(connection$1); + } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { + resolve(window.puzzleSdkConnection); + } else { + const interval = setInterval(() => { + if (connection$1) { + clearInterval(interval); + resolve(connection$1); + } + }, 200); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + }); +} +const checkForDesktopConnection$1 = async (sessionTopic) => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + try { + const res = await window.aleo.puzzleWalletClient.isConnected.query( + { sessionTopic } + ); + if (res) { + localStorage.setItem("puzzle-hasInjectedConnection", "true"); + return true; + } else { + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + } catch (e2) { + console.warn(e2); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } +}; +const hasInjectedConnection$1 = () => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + return false; + } + const puzzleHasDesktopConnection = localStorage.getItem( + "puzzle-hasInjectedConnection" + ); + return puzzleHasDesktopConnection === "true"; +}; var browser$5 = { exports: {} }; var ms; var hasRequiredMs; @@ -16589,11 +23694,11 @@ function requireMs() { return ms; hasRequiredMs = 1; var s2 = 1e3; - var m2 = s2 * 60; - var h4 = m2 * 60; - var d3 = h4 * 24; - var w3 = d3 * 7; - var y3 = d3 * 365.25; + var m3 = s2 * 60; + var h4 = m3 * 60; + var d5 = h4 * 24; + var w3 = d5 * 7; + var y3 = d5 * 365.25; ms = function(val, options) { options = options || {}; var type2 = typeof val; @@ -16617,7 +23722,7 @@ function requireMs() { if (!match) { return; } - var n3 = parseFloat(match[1]); + var n4 = parseFloat(match[1]); var type2 = (match[2] || "ms").toLowerCase(); switch (type2) { case "years": @@ -16625,53 +23730,53 @@ function requireMs() { case "yrs": case "yr": case "y": - return n3 * y3; + return n4 * y3; case "weeks": case "week": case "w": - return n3 * w3; + return n4 * w3; case "days": case "day": case "d": - return n3 * d3; + return n4 * d5; case "hours": case "hour": case "hrs": case "hr": case "h": - return n3 * h4; + return n4 * h4; case "minutes": case "minute": case "mins": case "min": case "m": - return n3 * m2; + return n4 * m3; case "seconds": case "second": case "secs": case "sec": case "s": - return n3 * s2; + return n4 * s2; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": - return n3; + return n4; default: return void 0; } } function fmtShort(ms2) { var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return Math.round(ms2 / d3) + "d"; + if (msAbs >= d5) { + return Math.round(ms2 / d5) + "d"; } if (msAbs >= h4) { return Math.round(ms2 / h4) + "h"; } - if (msAbs >= m2) { - return Math.round(ms2 / m2) + "m"; + if (msAbs >= m3) { + return Math.round(ms2 / m3) + "m"; } if (msAbs >= s2) { return Math.round(ms2 / s2) + "s"; @@ -16680,23 +23785,23 @@ function requireMs() { } function fmtLong(ms2) { var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return plural(ms2, msAbs, d3, "day"); + if (msAbs >= d5) { + return plural(ms2, msAbs, d5, "day"); } if (msAbs >= h4) { return plural(ms2, msAbs, h4, "hour"); } - if (msAbs >= m2) { - return plural(ms2, msAbs, m2, "minute"); + if (msAbs >= m3) { + return plural(ms2, msAbs, m3, "minute"); } if (msAbs >= s2) { return plural(ms2, msAbs, s2, "second"); } return ms2 + " ms"; } - function plural(ms2, msAbs, n3, name2) { - var isPlural = msAbs >= n3 * 1.5; - return Math.round(ms2 / n3) + " " + name2 + (isPlural ? "s" : ""); + function plural(ms2, msAbs, n4, name2) { + var isPlural = msAbs >= n4 * 1.5; + return Math.round(ms2 / n4) + " " + name2 + (isPlural ? "s" : ""); } return ms; } @@ -16745,12 +23850,12 @@ function setup(env2) { args.unshift("%O"); } let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => { if (match === "%%") { return "%"; } index++; - const formatter = createDebug.formatters[format]; + const formatter = createDebug.formatters[format2]; if (typeof formatter === "function") { const val = args[index]; match = formatter.call(self2, val); @@ -16996,15 +24101,15 @@ var common = setup; } } function load() { - let r2; + let r3; try { - r2 = exports2.storage.getItem("debug"); + r3 = exports2.storage.getItem("debug"); } catch (error) { } - if (!r2 && typeof process !== "undefined" && "env" in process) { - r2 = process.env.DEBUG; + if (!r3 && typeof process !== "undefined" && "env" in process) { + r3 = process.env.DEBUG; } - return r2; + return r3; } function localstorage() { try { @@ -17067,19 +24172,19 @@ function createJSONStorage(getStorage, options) { let storage; try { storage = getStorage(); - } catch (e) { + } catch (e2) { return; } const persistStorage = { getItem: (name2) => { - var _a; + var _a2; const parse = (str2) => { if (str2 === null) { return null; } - return JSON.parse(str2, options == null ? void 0 : options.reviver); + return JSON.parse(str2, void 0); }; - const str = (_a = storage.getItem(name2)) != null ? _a : null; + const str = (_a2 = storage.getItem(name2)) != null ? _a2 : null; if (str instanceof Promise) { return str.then(parse); } @@ -17087,15 +24192,15 @@ function createJSONStorage(getStorage, options) { }, setItem: (name2, newValue) => storage.setItem( name2, - JSON.stringify(newValue, options == null ? void 0 : options.replacer) + JSON.stringify(newValue, void 0) ), removeItem: (name2) => storage.removeItem(name2) }; return persistStorage; } -const toThenable = (fn2) => (input) => { +const toThenable = (fn) => (input) => { try { - const result = fn2(input); + const result = fn(input); if (result instanceof Promise) { return result; } @@ -17107,13 +24212,13 @@ const toThenable = (fn2) => (input) => { return this; } }; - } catch (e) { + } catch (e2) { return { then(_onFulfilled) { return this; }, catch(onRejected) { - return toThenable(onRejected)(e); + return toThenable(onRejected)(e2); } }; } @@ -17137,7 +24242,7 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { let storage; try { storage = options.getStorage(); - } catch (e) { + } catch (e2) { } if (!storage) { return config( @@ -17157,8 +24262,8 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { let errorInSync; const thenable = thenableSerialize({ state, version: options.version }).then( (serializedValue) => storage.setItem(options.name, serializedValue) - ).catch((e) => { - errorInSync = e; + ).catch((e2) => { + errorInSync = e2; }); if (errorInSync) { throw errorInSync; @@ -17180,12 +24285,12 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { ); let stateFromStorage; const hydrate = () => { - var _a; + var _a2; if (!storage) return; hasHydrated = false; hydrationListeners.forEach((cb) => cb(get2())); - const postRehydrationCallback = ((_a = options.onRehydrateStorage) == null ? void 0 : _a.call(options, get2())) || void 0; + const postRehydrationCallback = ((_a2 = options.onRehydrateStorage) == null ? void 0 : _a2.call(options, get2())) || void 0; return toThenable(storage.getItem.bind(storage))(options.name).then((storageValue) => { if (storageValue) { return options.deserialize(storageValue); @@ -17207,10 +24312,10 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { } } }).then((migratedState) => { - var _a2; + var _a22; stateFromStorage = options.merge( migratedState, - (_a2 = get2()) != null ? _a2 : configResult + (_a22 = get2()) != null ? _a22 : configResult ); set2(stateFromStorage, true); return setItem(); @@ -17218,8 +24323,8 @@ const oldImpl = (config, baseOptions) => (set2, get2, api) => { postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0); hasHydrated = true; finishHydrationListeners.forEach((cb) => cb(stateFromStorage)); - }).catch((e) => { - postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e); + }).catch((e2) => { + postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e2); }); }; api.persist = { @@ -17304,15 +24409,15 @@ const newImpl = (config, baseOptions) => (set2, get2, api) => { api.getInitialState = () => configResult; let stateFromStorage; const hydrate = () => { - var _a, _b; + var _a2, _b; if (!storage) return; hasHydrated = false; hydrationListeners.forEach((cb) => { - var _a2; - return cb((_a2 = get2()) != null ? _a2 : configResult); + var _a22; + return cb((_a22 = get2()) != null ? _a22 : configResult); }); - const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get2()) != null ? _a : configResult)) || void 0; + const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0; return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => { if (deserializedStorageValue) { if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) { @@ -17330,10 +24435,10 @@ const newImpl = (config, baseOptions) => (set2, get2, api) => { } } }).then((migratedState) => { - var _a2; + var _a22; stateFromStorage = options.merge( migratedState, - (_a2 = get2()) != null ? _a2 : configResult + (_a22 = get2()) != null ? _a22 : configResult ); set2(stateFromStorage, true); return setItem(); @@ -17342,8 +24447,8 @@ const newImpl = (config, baseOptions) => (set2, get2, api) => { stateFromStorage = get2(); hasHydrated = true; finishHydrationListeners.forEach((cb) => cb(stateFromStorage)); - }).catch((e) => { - postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e); + }).catch((e2) => { + postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e2); }); }; api.persist = { @@ -17444,15 +24549,15 @@ function useRequestQuery({ queryKey, async () => fetchRequest(wcParams, queryKey), queryOptions ?? { - staleTime: queryKey[0] === "getEvent" ? 7500 : 45e3, - refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 3e4, + staleTime: queryKey[0] === "getEvent" ? 7500 : 3e4, + refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 15e3, refetchIntervalInBackground: true, enabled, retry: true } ); } -function useExtensionRequestQuery({ +function useInjectedRequestQuery({ queryKey, wcParams, enabled, @@ -17463,8 +24568,8 @@ function useExtensionRequestQuery({ queryKey, async () => fetchFunction(wcParams), queryOptions ?? { - staleTime: queryKey[0] === "getEvent" ? 7500 : 45e3, - refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 3e4, + staleTime: queryKey[0] === "getEvent" ? 7500 : 3e4, + refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 15e3, refetchIntervalInBackground: true, enabled, retry: true @@ -17480,17 +24585,17 @@ function useRequest(params, fetchFunction) { const response = await fetchRequest(paramsOverride ?? params); setData(response); return response; - } catch (e) { - setError(e); + } catch (e2) { + setError(e2); setLoading(false); - throw e; + throw e2; } finally { setLoading(false); } } return { data, error, loading, request }; } -function useExtensionRequest(params, fetchFunction) { +function useInjectedRequest(params, fetchFunction) { const { data, error, loading, setData, setError, setLoading } = useAsyncAction(); async function request(paramsOverride) { try { @@ -17499,10 +24604,10 @@ function useExtensionRequest(params, fetchFunction) { const response = await fetchFunction(paramsOverride ?? params); setData(response); return response; - } catch (e) { - setError(e); + } catch (e2) { + setError(e2); setLoading(false); - throw e; + throw e2; } finally { setLoading(false); } @@ -17539,9 +24644,11 @@ const useInjectedSubscriptions = ({ } ); return () => { - subscriptions.forEach((subscription) => subscription.unsubscribe()); + subscriptions.forEach((subscription) => { + subscription.unsubscribe(); + }); }; - }, [session == null ? void 0 : session.topic, configs]); + }, [session == null ? void 0 : session.topic, ...configs.flatMap((config) => config.dependencies)]); }; var jsxRuntime = { exports: {} }; var reactJsxRuntime_production_min = {}; @@ -17559,18 +24666,18 @@ function requireReactJsxRuntime_production_min() { if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min; hasRequiredReactJsxRuntime_production_min = 1; - var f2 = React__default, k2 = Symbol.for("react.element"), l2 = Symbol.for("react.fragment"), m2 = Object.prototype.hasOwnProperty, n3 = f2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p3 = { key: true, ref: true, __self: true, __source: true }; + var f3 = React__default, k2 = Symbol.for("react.element"), l2 = Symbol.for("react.fragment"), m3 = Object.prototype.hasOwnProperty, n4 = f3.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p2 = { key: true, ref: true, __self: true, __source: true }; function q2(c2, a3, g3) { - var b3, d3 = {}, e = null, h4 = null; - void 0 !== g3 && (e = "" + g3); - void 0 !== a3.key && (e = "" + a3.key); + var b3, d5 = {}, e2 = null, h4 = null; + void 0 !== g3 && (e2 = "" + g3); + void 0 !== a3.key && (e2 = "" + a3.key); void 0 !== a3.ref && (h4 = a3.ref); for (b3 in a3) - m2.call(a3, b3) && !p3.hasOwnProperty(b3) && (d3[b3] = a3[b3]); + m3.call(a3, b3) && !p2.hasOwnProperty(b3) && (d5[b3] = a3[b3]); if (c2 && c2.defaultProps) for (b3 in a3 = c2.defaultProps, a3) - void 0 === d3[b3] && (d3[b3] = a3[b3]); - return { $$typeof: k2, type: c2, key: e, ref: h4, props: d3, _owner: n3.current }; + void 0 === d5[b3] && (d5[b3] = a3[b3]); + return { $$typeof: k2, type: c2, key: e2, ref: h4, props: d5, _owner: n4.current }; } reactJsxRuntime_production_min.Fragment = l2; reactJsxRuntime_production_min.jsx = q2; @@ -17621,28 +24728,28 @@ function requireReactJsxRuntime_development() { return null; } var ReactSharedInternals = React2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - function error(format) { + function error(format2) { { { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } - printWarning("error", format, args); + printWarning("error", format2, args); } } } - function printWarning(level, format, args) { + function printWarning(level, format2, args) { { var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ReactDebugCurrentFrame2.getStackAddendum(); if (stack !== "") { - format += "%s"; + format2 += "%s"; args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { return String(item); }); - argsWithFormat.unshift("Warning: " + format); + argsWithFormat.unshift("Warning: " + format2); Function.prototype.apply.call(console[level], console, argsWithFormat); } } @@ -17843,12 +24950,12 @@ function requireReactJsxRuntime_development() { var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; componentFrameCache = new PossiblyWeakMap(); } - function describeNativeComponentFrame(fn2, construct) { - if (!fn2 || reentry) { + function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) { return ""; } { - var frame = componentFrameCache.get(fn2); + var frame = componentFrameCache.get(fn); if (frame !== void 0) { return frame; } @@ -17879,14 +24986,14 @@ function requireReactJsxRuntime_development() { } catch (x2) { control = x2; } - Reflect.construct(fn2, [], Fake); + Reflect.construct(fn, [], Fake); } else { try { Fake.call(); } catch (x2) { control = x2; } - fn2.call(Fake.prototype); + fn.call(Fake.prototype); } } else { try { @@ -17894,7 +25001,7 @@ function requireReactJsxRuntime_development() { } catch (x2) { control = x2; } - fn2(); + fn(); } } catch (sample) { if (sample && control && typeof sample.stack === "string") { @@ -17913,12 +25020,12 @@ function requireReactJsxRuntime_development() { c2--; if (c2 < 0 || sampleLines[s2] !== controlLines[c2]) { var _frame = "\n" + sampleLines[s2].replace(" at new ", " at "); - if (fn2.displayName && _frame.includes("")) { - _frame = _frame.replace("", fn2.displayName); + if (fn.displayName && _frame.includes("")) { + _frame = _frame.replace("", fn.displayName); } { - if (typeof fn2 === "function") { - componentFrameCache.set(fn2, _frame); + if (typeof fn === "function") { + componentFrameCache.set(fn, _frame); } } return _frame; @@ -17937,18 +25044,18 @@ function requireReactJsxRuntime_development() { } Error.prepareStackTrace = previousPrepareStackTrace; } - var name2 = fn2 ? fn2.displayName || fn2.name : ""; + var name2 = fn ? fn.displayName || fn.name : ""; var syntheticFrame = name2 ? describeBuiltInComponentFrame(name2) : ""; { - if (typeof fn2 === "function") { - componentFrameCache.set(fn2, syntheticFrame); + if (typeof fn === "function") { + componentFrameCache.set(fn, syntheticFrame); } } return syntheticFrame; } - function describeFunctionComponentFrame(fn2, source, ownerFn) { + function describeFunctionComponentFrame(fn, source, ownerFn) { { - return describeNativeComponentFrame(fn2, false); + return describeNativeComponentFrame(fn, false); } } function shouldConstruct(Component) { @@ -18053,7 +25160,7 @@ function requireReactJsxRuntime_development() { try { testStringCoercion(value); return false; - } catch (e) { + } catch (e2) { return true; } } @@ -18266,11 +25373,6 @@ function requireReactJsxRuntime_development() { } function getSourceInfoErrorAddendum(source) { { - if (source !== void 0) { - var fileName = source.fileName.replace(/^.*[\\\/]/, ""); - var lineNumber = source.lineNumber; - return "\n\nCheck your code at " + fileName + ":" + lineNumber + "."; - } return ""; } } @@ -18387,6 +25489,7 @@ function requireReactJsxRuntime_development() { } } } + var didWarnAboutKeySpread = {}; function jsxWithValidation(type2, props, key, isStaticChildren, source, self2) { { var validType = isValidElementType(type2); @@ -18395,7 +25498,7 @@ function requireReactJsxRuntime_development() { if (type2 === void 0 || typeof type2 === "object" && type2 !== null && Object.keys(type2).length === 0) { info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."; } - var sourceInfo = getSourceInfoErrorAddendum(source); + var sourceInfo = getSourceInfoErrorAddendum(); if (sourceInfo) { info += sourceInfo; } else { @@ -18437,6 +25540,20 @@ function requireReactJsxRuntime_development() { } } } + { + if (hasOwnProperty.call(props, "key")) { + var componentName = getComponentNameFromType(type2); + var keys2 = Object.keys(props).filter(function(k2) { + return k2 !== "key"; + }); + var beforeExample = keys2.length > 0 ? "{key: someKey, " + keys2.join(": ..., ") + ": ...}" : "{key: someKey}"; + if (!didWarnAboutKeySpread[componentName + beforeExample]) { + var afterExample = keys2.length > 0 ? "{" + keys2.join(": ..., ") + ": ...}" : "{}"; + error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName); + didWarnAboutKeySpread[componentName + beforeExample] = true; + } + } + } if (type2 === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); } else { @@ -19182,24 +26299,24 @@ var Registry = ( }() ); var __extends = /* @__PURE__ */ function() { - var extendStatics2 = function(d3, b3) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { - d4.__proto__ = b4; - } || function(d4, b4) { - for (var p3 in b4) - if (Object.prototype.hasOwnProperty.call(b4, p3)) - d4[p3] = b4[p3]; + var extendStatics2 = function(d5, b3) { + extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d6, b4) { + d6.__proto__ = b4; + } || function(d6, b4) { + for (var p2 in b4) + if (Object.prototype.hasOwnProperty.call(b4, p2)) + d6[p2] = b4[p2]; }; - return extendStatics2(d3, b3); + return extendStatics2(d5, b3); }; - return function(d3, b3) { + return function(d5, b3) { if (typeof b3 !== "function" && b3 !== null) throw new TypeError("Class extends value " + String(b3) + " is not a constructor or null"); - extendStatics2(d3, b3); + extendStatics2(d5, b3); function __() { - this.constructor = d3; + this.constructor = d5; } - d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); + d5.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); }; }(); var ClassRegistry = ( @@ -19229,26 +26346,26 @@ var ClassRegistry = ( return ClassRegistry2; }(Registry) ); -var __read$3 = function(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +var __read$3 = function(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; }; function valuesOfObj(record) { if ("values" in Object) { @@ -19277,8 +26394,8 @@ function find(record, predicate) { return void 0; } function forEach(record, run) { - Object.entries(record).forEach(function(_a) { - var _b = __read$3(_a, 2), key = _b[0], value = _b[1]; + Object.entries(record).forEach(function(_a2) { + var _b = __read$3(_a2, 2), key = _b[0], value = _b[1]; return run(value, key); }); } @@ -19414,41 +26531,41 @@ var parsePath = function(string2) { }; var __assign$1 = function() { __assign$1 = Object.assign || function(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { + for (var s2, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2)) + t2[p2] = s2[p2]; } return t2; }; return __assign$1.apply(this, arguments); }; -var __read$2 = function(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +var __read$2 = function(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; }; -var __spreadArray$2 = function(to, from2) { - for (var i2 = 0, il = from2.length, j2 = to.length; i2 < il; i2++, j2++) - to[j2] = from2[i2]; - return to; +var __spreadArray$2 = function(to2, from2) { + for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) + to2[j2] = from2[i2]; + return to2; }; function simpleTransformation(isApplicable, annotation, transform, untransform) { return { @@ -19488,13 +26605,13 @@ var simpleRules = [ }); return baseError; }, function(v3, superJson) { - var e = new Error(v3.message); - e.name = v3.name; - e.stack = v3.stack; + var e2 = new Error(v3.message); + e2.name = v3.name; + e2.stack = v3.stack; superJson.allowedErrorProps.forEach(function(prop) { - e[prop] = v3[prop]; + e2[prop] = v3[prop]; }); - return e; + return e2; }), simpleTransformation(isRegExp, "regexp", function(v3) { return "" + v3; @@ -19684,11 +26801,11 @@ var untransformValue = function(json, type2, superJson) { return transformation.untransform(json, superJson); } }; -var getNthKey = function(value, n3) { +var getNthKey = function(value, n4) { var keys2 = value.keys(); - while (n3 > 0) { + while (n4 > 0) { keys2.next(); - n3--; + n4--; } return keys2.next().value; }; @@ -19796,31 +26913,31 @@ var setDeep = function(object, path, mapper) { } return object; }; -var __read$1 = function(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +var __read$1 = function(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; }; -var __spreadArray$1 = function(to, from2) { - for (var i2 = 0, il = from2.length, j2 = to.length; i2 < il; i2++, j2++) - to[j2] = from2[i2]; - return to; +var __spreadArray$1 = function(to2, from2) { + for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) + to2[j2] = from2[i2]; + return to2; }; function traverse(tree, walker2, origin) { if (origin === void 0) { @@ -19835,7 +26952,7 @@ function traverse(tree, walker2, origin) { }); return; } - var _a = __read$1(tree, 2), nodeValue = _a[0], children = _a[1]; + var _a2 = __read$1(tree, 2), nodeValue = _a2[0], children = _a2[1]; if (children) { forEach(children, function(child, key) { traverse(child, walker2, __spreadArray$1(__spreadArray$1([], __read$1(origin)), __read$1(parsePath(key)))); @@ -19861,7 +26978,7 @@ function applyReferentialEqualityAnnotations(plain, annotations) { }); } if (isArray$1(annotations)) { - var _a = __read$1(annotations, 2), root = _a[0], other = _a[1]; + var _a2 = __read$1(annotations, 2), root = _a2[0], other = _a2[1]; root.forEach(function(identicalPath) { plain = setDeep(plain, parsePath(identicalPath), function() { return plain; @@ -19900,7 +27017,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) { return a3.length - b3.length; }); } - var _a = __read$1(paths), representativePath = _a[0], identicalPaths = _a.slice(1); + var _a2 = __read$1(paths), representativePath = _a2[0], identicalPaths = _a2.slice(1); if (representativePath.length === 0) { rootEqualityPaths = identicalPaths.map(stringifyPath); } else { @@ -19918,7 +27035,7 @@ function generateReferentialEqualityAnnotations(identitites, dedupe) { } } var walker = function(object, identities, superJson, dedupe, path, objectsInThisPath, seenObjects) { - var _a; + var _a2; if (path === void 0) { path = []; } @@ -19957,7 +27074,7 @@ var walker = function(object, identities, superJson, dedupe, path, objectsInThis }; } var transformationResult = transformValue(object, superJson); - var transformed = (_a = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a !== void 0 ? _a : object; + var transformed = (_a2 = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a2 !== void 0 ? _a2 : object; var transformedValue = isArray$1(transformed) ? [] : {}; var innerAnnotations = {}; forEach(transformed, function(value, index) { @@ -20029,51 +27146,51 @@ function copy(target, options = {}) { } var __assign = function() { __assign = Object.assign || function(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { + for (var s2, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var p2 in s2) + if (Object.prototype.hasOwnProperty.call(s2, p2)) + t2[p2] = s2[p2]; } return t2; }; return __assign.apply(this, arguments); }; -var __read = function(o2, n3) { - var m2 = typeof Symbol === "function" && o2[Symbol.iterator]; - if (!m2) +var __read = function(o2, n4) { + var m3 = typeof Symbol === "function" && o2[Symbol.iterator]; + if (!m3) return o2; - var i2 = m2.call(o2), r2, ar2 = [], e; + var i2 = m3.call(o2), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { - e = { error }; + e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { - if (e) - throw e.error; + if (e2) + throw e2.error; } } - return ar2; + return ar3; }; -var __spreadArray = function(to, from2) { - for (var i2 = 0, il = from2.length, j2 = to.length; i2 < il; i2++, j2++) - to[j2] = from2[i2]; - return to; +var __spreadArray = function(to2, from2) { + for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) + to2[j2] = from2[i2]; + return to2; }; var SuperJSON = ( /** @class */ function() { - function SuperJSON2(_a) { - var _b = _a === void 0 ? {} : _a, _c = _b.dedupe, dedupe = _c === void 0 ? false : _c; + function SuperJSON2(_a2) { + var _b = _a2 === void 0 ? {} : _a2, _c = _b.dedupe, dedupe = _c === void 0 ? false : _c; this.classRegistry = new ClassRegistry(); this.symbolRegistry = new Registry(function(s2) { - var _a2; - return (_a2 = s2.description) !== null && _a2 !== void 0 ? _a2 : ""; + var _a3; + return (_a3 = s2.description) !== null && _a3 !== void 0 ? _a3 : ""; }); this.customTransformerRegistry = new CustomTransformerRegistry(); this.allowedErrorProps = []; @@ -20121,12 +27238,12 @@ var SuperJSON = ( this.customTransformerRegistry.register(__assign({ name: name2 }, transformer)); }; SuperJSON2.prototype.allowErrorProps = function() { - var _a; + var _a2; var props = []; - for (var _i = 0; _i < arguments.length; _i++) { - props[_i] = arguments[_i]; + for (var _i2 = 0; _i2 < arguments.length; _i2++) { + props[_i2] = arguments[_i2]; } - (_a = this.allowedErrorProps).push.apply(_a, __spreadArray([], __read(props))); + (_a2 = this.allowedErrorProps).push.apply(_a2, __spreadArray([], __read(props))); }; SuperJSON2.defaultInstance = new SuperJSON2(); SuperJSON2.serialize = SuperJSON2.defaultInstance.serialize.bind(SuperJSON2.defaultInstance); @@ -20611,7 +27728,7 @@ const DefaultRenderer = ({ }) : null, expanded ? subEntryPages.length === 1 ? /* @__PURE__ */ React.createElement(SubEntries, null, subEntries.map(handleEntry)) : /* @__PURE__ */ React.createElement(SubEntries, null, subEntryPages.map((entries, index) => /* @__PURE__ */ React.createElement("div", { key: index }, /* @__PURE__ */ React.createElement(Entry, null, /* @__PURE__ */ React.createElement(LabelButton, { - onClick: () => setExpandedPages((old) => old.includes(index) ? old.filter((d3) => d3 !== index) : [...old, index]) + onClick: () => setExpandedPages((old) => old.includes(index) ? old.filter((d5) => d5 !== index) : [...old, index]) }, /* @__PURE__ */ React.createElement(Expander, { expanded }), " [", index * pageSize, " ...", " ", index * pageSize + pageSize - 1, "]"), expandedPages.includes(index) ? /* @__PURE__ */ React.createElement(SubEntries, null, entries.map(handleEntry)) : null)))) : null) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Label, null, label, ":"), " ", /* @__PURE__ */ React.createElement(Value, null, displayValue(value)))); @@ -20642,9 +27759,9 @@ function Explorer({ }; if (Array.isArray(value)) { type2 = "array"; - subEntries = value.map((d3, i2) => makeProperty({ + subEntries = value.map((d5, i2) => makeProperty({ label: i2.toString(), - value: d3 + value: d5 })); } else if (value !== null && typeof value === "object" && isIterable(value) && typeof value[Symbol.iterator] === "function") { type2 = "Iterable"; @@ -20720,34 +27837,34 @@ function requireUseSyncExternalStoreShim_production_min() { if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min; hasRequiredUseSyncExternalStoreShim_production_min = 1; - var e = React__default; + var e2 = React__default; function h4(a3, b3) { return a3 === b3 && (0 !== a3 || 1 / a3 === 1 / b3) || a3 !== a3 && b3 !== b3; } - var k2 = "function" === typeof Object.is ? Object.is : h4, l2 = e.useState, m2 = e.useEffect, n3 = e.useLayoutEffect, p3 = e.useDebugValue; + var k2 = "function" === typeof Object.is ? Object.is : h4, l2 = e2.useState, m3 = e2.useEffect, n4 = e2.useLayoutEffect, p2 = e2.useDebugValue; function q2(a3, b3) { - var d3 = b3(), f2 = l2({ inst: { value: d3, getSnapshot: b3 } }), c2 = f2[0].inst, g3 = f2[1]; - n3(function() { - c2.value = d3; + var d5 = b3(), f3 = l2({ inst: { value: d5, getSnapshot: b3 } }), c2 = f3[0].inst, g3 = f3[1]; + n4(function() { + c2.value = d5; c2.getSnapshot = b3; - r2(c2) && g3({ inst: c2 }); - }, [a3, d3, b3]); - m2(function() { - r2(c2) && g3({ inst: c2 }); + r3(c2) && g3({ inst: c2 }); + }, [a3, d5, b3]); + m3(function() { + r3(c2) && g3({ inst: c2 }); return a3(function() { - r2(c2) && g3({ inst: c2 }); + r3(c2) && g3({ inst: c2 }); }); }, [a3]); - p3(d3); - return d3; + p2(d5); + return d5; } - function r2(a3) { + function r3(a3) { var b3 = a3.getSnapshot; a3 = a3.value; try { - var d3 = b3(); - return !k2(a3, d3); - } catch (f2) { + var d5 = b3(); + return !k2(a3, d5); + } catch (f3) { return true; } } @@ -20755,7 +27872,7 @@ function requireUseSyncExternalStoreShim_production_min() { return b3(); } var u3 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t2 : q2; - useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u3; + useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e2.useSyncExternalStore ? e2.useSyncExternalStore : u3; return useSyncExternalStoreShim_production_min; } var useSyncExternalStoreShim_development = {}; @@ -20780,35 +27897,35 @@ function requireUseSyncExternalStoreShim_development() { } var React2 = React__default; var ReactSharedInternals = React2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - function error(format) { + function error(format2) { { { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } - printWarning("error", format, args); + printWarning("error", format2, args); } } } - function printWarning(level, format, args) { + function printWarning(level, format2, args) { { var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { - format += "%s"; + format2 += "%s"; args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { return String(item); }); - argsWithFormat.unshift("Warning: " + format); + argsWithFormat.unshift("Warning: " + format2); Function.prototype.apply.call(console[level], console, argsWithFormat); } } - function is2(x2, y3) { + function is3(x2, y3) { return x2 === y3 && (x2 !== 0 || 1 / x2 === 1 / y3) || x2 !== x2 && y3 !== y3; } - var objectIs = typeof Object.is === "function" ? Object.is : is2; + var objectIs = typeof Object.is === "function" ? Object.is : is3; var useState2 = React2.useState, useEffect2 = React2.useEffect, useLayoutEffect = React2.useLayoutEffect, useDebugValue = React2.useDebugValue; var didWarnOld18Alpha = false; var didWarnUncachedGetSnapshot = false; @@ -21060,7 +28177,7 @@ function ReactQueryDevtools$1({ style, isOpen: isResolvedOpen, setIsOpen, - onDragStart: (e) => handleDragStart(panelRef.current, e), + onDragStart: (e2) => handleDragStart(panelRef.current, e2), errorTypes }))), !isResolvedOpen ? /* @__PURE__ */ React.createElement("button", _extends({ type: "button" @@ -21069,9 +28186,9 @@ function ReactQueryDevtools$1({ "aria-controls": "ReactQueryDevtoolsPanel", "aria-haspopup": "true", "aria-expanded": "false", - onClick: (e) => { + onClick: (e2) => { setIsOpen(true); - onToggleClick == null ? void 0 : onToggleClick(e); + onToggleClick == null ? void 0 : onToggleClick(e2); }, style: { background: "none", @@ -21230,7 +28347,7 @@ const ReactQueryDevtoolsPanel = /* @__PURE__ */ React.forwardRef(function ReactQ style: { marginInlineStart: ".5em" }, - onChange: (e) => onPositionChange(e.target.value) + onChange: (e2) => onPositionChange(e2.target.value) }, /* @__PURE__ */ React.createElement("option", { value: "left" }, "Left"), /* @__PURE__ */ React.createElement("option", { @@ -21250,9 +28367,9 @@ const ReactQueryDevtoolsPanel = /* @__PURE__ */ React.forwardRef(function ReactQ placeholder: "Filter", "aria-label": "Filter by queryhash", value: filter != null ? filter : "", - onChange: (e) => setFilter(e.target.value), - onKeyDown: (e) => { - if (e.key === "Escape") + onChange: (e2) => setFilter(e2.target.value), + onKeyDown: (e2) => { + if (e2.key === "Escape") setFilter(""); }, style: { @@ -21262,7 +28379,7 @@ const ReactQueryDevtoolsPanel = /* @__PURE__ */ React.forwardRef(function ReactQ }), /* @__PURE__ */ React.createElement(Select, { "aria-label": "Sort queries", value: sort, - onChange: (e) => setSort(e.target.value), + onChange: (e2) => setSort(e2.target.value), style: { flex: "1", minWidth: 75, @@ -21381,9 +28498,9 @@ const ReactQueryDevtoolsPanel = /* @__PURE__ */ React.forwardRef(function ReactQ left: 0, ...otherCloseButtonProps.style }, - onClick: (e) => { + onClick: (e2) => { setIsOpen(false); - onCloseClick == null ? void 0 : onCloseClick(e); + onCloseClick == null ? void 0 : onCloseClick(e2); } }), "Close") : null)); }); @@ -21590,8 +28707,8 @@ const ActiveQuery = ({ style: { marginInlineStart: ".5em" }, - onChange: (e) => { - const errorType = errorTypes.find((t2) => t2.name === e.target.value); + onChange: (e2) => { + const errorType = errorTypes.find((t2) => t2.name === e2.target.value); triggerError(errorType); } }, /* @__PURE__ */ React.createElement("option", { @@ -21803,7 +28920,9 @@ function useSession() { return session; } const queryClient = new QueryClient(); -const SessionContext = createContext(void 0); +const SessionContext = createContext( + void 0 +); const PuzzleWalletProvider = ({ dAppName, dAppDescription, @@ -21812,7 +28931,9 @@ const PuzzleWalletProvider = ({ children, debugQuery = false }) => { - const [session, setSession] = useState(void 0); + const [session, setSession] = useState( + void 0 + ); const _session = useSession(); useEffect(() => { setSession(_session); @@ -21858,10 +28979,10 @@ const useAccount = () => { state.setAccount, state.onDisconnect ]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getSelectedAccount" @@ -21890,8 +29011,8 @@ const useAccount = () => { return !!(data == null ? void 0 : data.address); }, onData: (data) => { - var _a, _b; - const network = ((_a = data.chain) == null ? void 0 : _a.split(":")[0]) ?? "aleo"; + var _a2, _b; + const network = ((_a2 = data.chain) == null ? void 0 : _a2.split(":")[0]) ?? "aleo"; const chainId = ((_b = data.chain) == null ? void 0 : _b.split(":")[1]) ?? "1"; setAccount({ network, @@ -21899,7 +29020,8 @@ const useAccount = () => { address: data.address, shortenedAddress: shortenAddress(data.address) }); - } + }, + dependencies: [] } ] }); @@ -21928,7 +29050,7 @@ const useAccount = () => { shortenedAddress: shortenAddress(address) }); }); - useOnSessionDelete(({ params, topic }) => { + useOnSessionDelete(() => { onDisconnect(); }); useEffect(() => { @@ -21952,18 +29074,17 @@ const useAccount = () => { loading }; }; -const useBalance = ({ address, multisig }) => { +const useBalance = ({ address, multisig } = {}) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getBalance", params: { - assetId: void 0, address } } @@ -21996,14 +29117,16 @@ const useBalance = ({ address, multisig }) => { condition: () => { return !multisig; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data) => { return !!multisig && (data == null ? void 0 : data.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig, address] } ] }); @@ -22024,7 +29147,7 @@ const useBalance = ({ address, multisig }) => { const balances = response == null ? void 0 : response.balances; return { balances, error, loading }; }; -function useConnect() { +function useConnect(showModal = true) { const session = useWalletSession(); const isConnected = !!session; const { data, error, loading, setData, setError, setLoading } = useAsyncAction(); @@ -22038,11 +29161,18 @@ function useConnect() { requiredNamespaces: { aleo: { methods: wc_aleo_methods$1, - chains: wc_aleo_chains$1, + chains: wc_required_aleo_chains$1, + events: wc_events$1 + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains$1, + methods: wc_aleo_methods$1, events: wc_events$1 } } - }); + }, showModal); setData(response); await checkForDesktopConnection$1(response.topic); const account = response.namespaces["aleo"]["accounts"][0].split(":"); @@ -22053,7 +29183,9 @@ function useConnect() { shortenedAddress: shortenAddress(account[2]) }); emitter$1.emit("session_change"); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + const choice = window.localStorage.getItem( + "WALLETCONNECT_DEEPLINK_CHOICE" + ); if (choice && JSON.parse(choice).name !== "Android") { window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); } @@ -22070,7 +29202,8 @@ function useConnect() { } const useCreateSharedState = () => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22079,7 +29212,7 @@ const useCreateSharedState = () => { } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "createSharedState", @@ -22097,7 +29230,8 @@ const useCreateSharedState = () => { }; const useDecrypt = (ciphertexts) => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22106,7 +29240,7 @@ const useDecrypt = (ciphertexts) => { } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "decrypt", @@ -22147,8 +29281,8 @@ function useDisconnect() { reason: getSdkError("USER_DISCONNECTED") }); emitter$1.emit("session_change"); - } catch (e) { - console.warn(e); + } catch (e2) { + console.warn(e2); } useWalletStore.getState().onDisconnect(); } catch (err) { @@ -22163,10 +29297,10 @@ function useDisconnect() { const useEvent = ({ id, address, multisig = false }) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getEvent", @@ -22204,14 +29338,16 @@ const useEvent = ({ id, address, multisig = false }) => { { subscriptionName: "onSelectedAccountSynced", condition: () => !!id && !multisig, - onData: () => refetch() + onData: () => refetch(), + dependencies: [id, multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data) => { return !!id && !!multisig && (data == null ? void 0 : data.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [id, multisig, address] } ] }); @@ -22244,10 +29380,10 @@ const useEvents = ({ filter, page }) => { if ((filter == null ? void 0 : filter.programId) === "") { filter.programId = void 0; } - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getEvents", @@ -22267,7 +29403,7 @@ const useEvents = ({ filter, page }) => { queryKey: [ "useEvents", account == null ? void 0 : account.address, - debouncedFilter, + JSON.stringify(debouncedFilter), page, session == null ? void 0 : session.topic ], @@ -22284,7 +29420,8 @@ const useEvents = ({ filter, page }) => { { subscriptionName: "onSelectedAccountSynced", condition: () => true, - onData: () => refetch() + onData: () => refetch(), + dependencies: [] } ] }); @@ -22313,7 +29450,8 @@ const useEvents = ({ filter, page }) => { }; const useImportSharedState = (seed) => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22322,7 +29460,7 @@ const useImportSharedState = (seed) => { } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "importSharedState", @@ -22332,8 +29470,8 @@ const useImportSharedState = (seed) => { } }, (params) => { - var _a; - return (_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient.importSharedState.mutate(params); + var _a2; + return (_a2 = window.aleo) == null ? void 0 : _a2.puzzleWalletClient.importSharedState.mutate(params); } ); const error = wc_error ? wc_error.message : wc_data && wc_data.error; @@ -22360,10 +29498,10 @@ const useRecords = ({ }) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getRecords", @@ -22386,7 +29524,7 @@ const useRecords = ({ account == null ? void 0 : account.address, address, multisig, - debouncedFilter, + JSON.stringify(debouncedFilter), page, session == null ? void 0 : session.topic ], @@ -22404,14 +29542,16 @@ const useRecords = ({ { subscriptionName: "onSelectedAccountSynced", condition: () => !multisig, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data) => { return !!multisig && (data == null ? void 0 : data.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig, address] } ] }); @@ -22436,6 +29576,7 @@ const useRecords = ({ }; const useRequestCreateEvent = (requestData) => { const session = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { if (typeof input === "string") { return input; @@ -22449,7 +29590,7 @@ const useRequestCreateEvent = (requestData) => { loading } = useRequest({ topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "requestCreateEvent", @@ -22495,8 +29636,8 @@ var util; return util2.objectValues(filtered); }; util2.objectValues = (obj) => { - return util2.objectKeys(obj).map(function(e) { - return obj[e]; + return util2.objectKeys(obj).map(function(e2) { + return obj[e2]; }); }; util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { @@ -22823,7 +29964,7 @@ const makeIssue = (params) => { path: fullPath }; let errorMessage = ""; - const maps = errorMaps.filter((m2) => !!m2).slice().reverse(); + const maps = errorMaps.filter((m3) => !!m3).slice().reverse(); for (const map of maps) { errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; } @@ -23047,11 +30188,11 @@ class ZodType2 { throw result.error; } safeParse(data, params) { - var _a; + var _a2; const ctx = { common: { issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap }, path: (params === null || params === void 0 ? void 0 : params.path) || [], @@ -23407,7 +30548,7 @@ class ZodString2 extends ZodType2 { } else if (check.kind === "url") { try { new URL(input.data); - } catch (_a) { + } catch (_a2) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext(ctx, { validation: "url", @@ -23522,7 +30663,7 @@ class ZodString2 extends ZodType2 { return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); } datetime(options) { - var _a; + var _a2; if (typeof options === "string") { return this._addCheck({ kind: "datetime", @@ -23534,7 +30675,7 @@ class ZodString2 extends ZodType2 { return this._addCheck({ kind: "datetime", precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) }); } @@ -23589,59 +30730,59 @@ class ZodString2 extends ZodType2 { }); } get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); } get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); + return !!this._def.checks.find((ch2) => ch2.kind === "email"); } get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); + return !!this._def.checks.find((ch2) => ch2.kind === "url"); } get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); } get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); } get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); } get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); } get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); } get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); } get minLength() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxLength() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } } ZodString2.create = (params) => { - var _a; + var _a2; return new ZodString2({ checks: [], typeName: ZodFirstPartyTypeKind.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, ...processCreateParams(params) }); }; @@ -23839,38 +30980,38 @@ class ZodNumber2 extends ZodType2 { } get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util.isInteger(ch2.value)); } get isFinite() { let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return Number.isFinite(min) && Number.isFinite(max); @@ -24022,31 +31163,31 @@ class ZodBigInt2 extends ZodType2 { } get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } } ZodBigInt2.create = (params) => { - var _a; + var _a2; return new ZodBigInt2({ checks: [], typeName: ZodFirstPartyTypeKind.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, ...processCreateParams(params) }); }; @@ -24157,20 +31298,20 @@ class ZodDate2 extends ZodType2 { } get minDate() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min != null ? new Date(min) : null; } get maxDate() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max != null ? new Date(max) : null; @@ -24552,8 +31693,8 @@ class ZodObject2 extends ZodType2 { unknownKeys: "strict", ...message !== void 0 ? { errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; if (issue.code === "unrecognized_keys") return { message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError @@ -25371,17 +32512,17 @@ class ZodFunction2 extends ZodType2 { }); } const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; + const fn = ctx.data; if (this._def.returns instanceof ZodPromise2) { return OK(async (...args) => { const error = new ZodError2([]); - const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => { - error.addIssue(makeArgsIssue(args, e)); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { + error.addIssue(makeArgsIssue(args, e2)); throw error; }); - const result = await fn2(...parsedArgs); - const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => { - error.addIssue(makeReturnsIssue(result, e)); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { + error.addIssue(makeReturnsIssue(result, e2)); throw error; }); return parsedReturns; @@ -25392,7 +32533,7 @@ class ZodFunction2 extends ZodType2 { if (!parsedArgs.success) { throw new ZodError2([makeArgsIssue(args, parsedArgs.error)]); } - const result = fn2(...parsedArgs.data); + const result = fn(...parsedArgs.data); const parsedReturns = this._def.returns.safeParse(result, params); if (!parsedReturns.success) { throw new ZodError2([makeReturnsIssue(result, parsedReturns.error)]); @@ -25931,11 +33072,11 @@ class ZodPipeline2 extends ZodType2 { const custom = (check, params = {}, fatal) => { if (check) return ZodAny2.create().superRefine((data, ctx) => { - var _a, _b; + var _a2, _b; if (!check(data)) { - const p3 = typeof params === "function" ? params(data) : params; - const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p3 === "string" ? { message: p3 } : p3; + const p2 = typeof params === "function" ? params(data) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); } }); @@ -26033,7 +33174,7 @@ const coerce = { date: (arg) => ZodDate2.create({ ...arg, coerce: true }) }; const NEVER = INVALID; -var z3 = /* @__PURE__ */ Object.freeze({ +var z = /* @__PURE__ */ Object.freeze({ __proto__: null, defaultErrorMap: errorMap, setErrorMap, @@ -26150,17 +33291,19 @@ var z3 = /* @__PURE__ */ Object.freeze({ const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; +const aleoTransitionIdRegex = /^au1[a-z0-9]{58}$/i; const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; const aleoFieldRegex = /^\d+field$/; const aleoU32 = /^\d+u32$/; const aleoU64 = /^\d+u64$/; -const zodAddress = z3.string().regex(aleoAddressRegex); -const zodViewKey = z3.string().regex(aleoViewKeyRegex); -const zodPrivateKey = z3.string().regex(aleoPrivateKeyRegex); -const zodTransactionId = z3.string().regex(aleoTransactionIdRegex); -const zodField = z3.string().regex(aleoFieldRegex); -const zodU32 = z3.string().regex(aleoU32); -const zodU64 = z3.string().regex(aleoU64); +const zodAddress = z.string().regex(aleoAddressRegex); +const zodViewKey = z.string().regex(aleoViewKeyRegex); +const zodPrivateKey = z.string().regex(aleoPrivateKeyRegex); +z.string().regex(aleoTransitionIdRegex); +const zodTransactionId = z.string().regex(aleoTransactionIdRegex); +const zodField = z.string().regex(aleoFieldRegex); +const zodU32 = z.string().regex(aleoU32); +const zodU64 = z.string().regex(aleoU64); var InputOutputType; (function(InputOutputType2) { InputOutputType2["Record"] = "record"; @@ -26181,6 +33324,9 @@ var EventType; EventType2["Split"] = "Split"; EventType2["Shield"] = "Shield"; EventType2["Unshield"] = "Unshield"; + EventType2["Referral"] = "Referral"; + EventType2["Points"] = "Points"; + EventType2["Raffle"] = "Raffle"; })(EventType || (EventType = {})); var EventStatus; (function(EventStatus2) { @@ -26197,18 +33343,16 @@ var Visibility; var Network; (function(Network2) { Network2["AleoTestnet"] = "AleoTestnet"; + Network2["AleoCanarynet"] = "AleoCanarynet"; Network2["AleoMainnet"] = "AleoMainnet"; })(Network || (Network = {})); -var AssetType; -(function(AssetType2) { - AssetType2[AssetType2["ALEO"] = 0] = "ALEO"; -})(AssetType || (AssetType = {})); -const zodEventType = z3.nativeEnum(EventType); -const zodEventStatus = z3.nativeEnum(EventStatus); -const zodNetwork = z3.nativeEnum(Network); -const zodVisibility = z3.nativeEnum(Visibility); -const useRequestSignature = (message, address) => { +const zodEventType = z.nativeEnum(EventType); +const zodEventStatus = z.nativeEnum(EventStatus); +const zodNetwork = z.nativeEnum(Network); +const zodVisibility = z.nativeEnum(Visibility); +const useRequestSignature = ({ message, address, method, network }) => { const session = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const { request, data: wc_data, @@ -26216,13 +33360,14 @@ const useRequestSignature = (message, address) => { loading } = useRequest({ topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "requestSignature", params: { message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method } } }); @@ -26249,7 +33394,15 @@ const wc_aleo_methods = [ "importSharedState", "requestSignature" ]; -const wc_aleo_chains = ["aleo:1"]; +const wc_required_aleo_chains = ["aleo:1"]; +const wc_optional_aleo_chains = [ + "aleo:0" + // for eventual mainnet +]; +const wc_aleo_chains = [ + ...wc_required_aleo_chains, + ...wc_optional_aleo_chains +]; const wc_events = [ "chainChanged", "accountSelected", @@ -26258,16 +33411,18 @@ const wc_events = [ ]; const projectId = "f0aaeffe71b636da453fce042d79d723"; function isAndroid() { - if (!navigator) { + if (typeof navigator === "undefined") { return false; } return /Android/i.test(navigator.userAgent); } const web3modal_puzzle_props_android = { projectId, - chains: ["aleo:3"], + chains: wc_aleo_chains, enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], mobileWallets: [ { id: "puzzle", @@ -26286,7 +33441,9 @@ const web3modal_puzzle_props_default = { projectId, chains: wc_aleo_chains, enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], mobileWallets: [ { id: "puzzle", @@ -26330,9 +33487,32 @@ const signClient_puzzleProps = { } } }; +const networkToChainId = (network, includePrefix = true) => { + let chain; + switch (network) { + case Network.AleoMainnet: + chain = "aleo:0"; + break; + case Network.AleoCanarynet: + chain = "aleo:0"; + break; + case Network.AleoTestnet: + chain = "aleo:1"; + break; + } + return includePrefix ? chain : chain.replace("aleo:", ""); +}; +const chainIdToNetwork = (chainId) => { + switch (chainId) { + case "aleo:0": + return Network.AleoCanarynet; + case "aleo:1": + return Network.AleoTestnet; + } +}; const name = "@puzzlehq/sdk-core"; const displayName = "Puzzle SDK"; -const version = "0.3.1"; +const version = "0.4.0"; const description = "Your portal to privacy"; const main = "./dist/puzzle.cjs.js"; const module = "./dist/puzzle.es.js"; @@ -26358,8 +33538,8 @@ const repository = { url: "git+https://github.com/puzzlehq/puzzle-sdk.git" }; const dependencies = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", "@walletconnect/types": "^2.11.2", "@walletconnect/utils": "^2.11.2", debug: "^4.3.4", @@ -26433,8 +33613,8 @@ async function configureConnection(options) { localStorage.removeItem("puzzle-hasInjectedConnection"); try { disconnectOnVersionChange(connection, options.onDisconnect); - } catch (e) { - console.error(e); + } catch (e2) { + console.error(e2); } } connection.onSessionDelete(() => { @@ -26486,9 +33666,10 @@ async function getWalletConnectModalSignClient() { }); } const checkForDesktopConnection = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); localStorage.setItem("puzzle-hasInjectedConnection", "false"); return false; } @@ -26503,16 +33684,16 @@ const checkForDesktopConnection = async (sessionTopic) => { localStorage.setItem("puzzle-hasInjectedConnection", "false"); return false; } - } catch (e) { - console.warn(e); + } catch (e2) { + console.warn(e2); localStorage.setItem("puzzle-hasInjectedConnection", "false"); return false; } }; const hasInjectedConnection = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { return false; } const puzzleHasDesktopConnection = localStorage.getItem( @@ -26520,15 +33701,18 @@ const hasInjectedConnection = () => { ); return puzzleHasDesktopConnection === "true"; }; -const getAccount = async () => { +const getAccount = async (network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await connection2.getSession(); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getSelectedAccount" @@ -26538,36 +33722,39 @@ const getAccount = async () => { try { const response = await window.aleo.puzzleWalletClient.getSelectedAccount.query(query); return response; - } catch (e) { - console.error("getAccount error", e); - return { error: e.message }; + } catch (e2) { + console.error("getAccount error", e2); + return { error: e2.message }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - console.error("getAccount error", e); - const error = e.message; + } catch (e2) { + console.error("getAccount error", e2); + const error = e2.message; return { error }; } }; const getBalance = async ({ - address + address, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await connection2.getSession(); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getBalance", params: { - assetId: void 0, address } } @@ -26576,25 +33763,25 @@ const getBalance = async ({ try { const response = await window.aleo.puzzleWalletClient.getBalance.query(query); return response; - } catch (e) { - const error = e.message; - console.error("getBalance error", e); + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); return { error }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - const error = e.message; - console.error("getBalance error", e); + } catch (e2) { + const error = e2.message; + console.error("getBalance error", e2); return { error }; } }; -const connect = async () => { +const connect = async (showModal = true) => { const connection2 = await getWalletConnectModalSignClient(); if (!connection2) { - throw new Error("call setConnection() first!"); + throw new Error("call configureConnection() first!"); } const existingSession = await connection2.getSession(); if (existingSession) { @@ -26606,11 +33793,18 @@ const connect = async () => { requiredNamespaces: { aleo: { methods: wc_aleo_methods, - chains: wc_aleo_chains, + chains: wc_required_aleo_chains, + events: wc_events + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains, + methods: wc_aleo_methods, events: wc_events } } - }); + }, showModal); emitter.emit("session_change"); if (newSession) { await checkForDesktopConnection(newSession.topic); @@ -26620,11 +33814,11 @@ const connect = async () => { window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); } return newSession; - } catch (e) { - console.error("connect error", e); + } catch (e2) { + console.error("connect error", e2); } }; -const requestCreateEvent = async (requestData) => { +const requestCreateEvent = async (requestData, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { @@ -26636,10 +33830,13 @@ const requestCreateEvent = async (requestData) => { } return input.plaintext; }); + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } try { const response = await connection2.request({ topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "requestCreateEvent", @@ -26650,21 +33847,24 @@ const requestCreateEvent = async (requestData) => { } }); return response; - } catch (e) { - console.error("createEvent error", e); - const error = e.message; + } catch (e2) { + console.error("createEvent error", e2); + const error = e2.message; return { error }; } }; -const createSharedState = async () => { +const createSharedState = async (network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "createSharedState", @@ -26673,34 +33873,35 @@ const createSharedState = async () => { }; if (hasInjectedConnection()) { try { - const response = await window.aleo.puzzleWalletClient.createSharedState.mutate( - query - ); + const response = await window.aleo.puzzleWalletClient.createSharedState.mutate(query); return response; - } catch (e) { - console.error("createSharedState error", e); - const error = e.message; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; return { error }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - console.error("createSharedState error", e); - const error = e.message; + } catch (e2) { + console.error("createSharedState error", e2); + const error = e2.message; return { error }; } }; -const decrypt = async (ciphertexts) => { +const decrypt = async (ciphertexts, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "decrypt", @@ -26713,18 +33914,18 @@ const decrypt = async (ciphertexts) => { try { const response = await window.aleo.puzzleWalletClient.decrypt.query(query); return response; - } catch (e) { - const error = e.message; - console.error("decrypt error", e); + } catch (e2) { + const error = e2.message; + console.error("decrypt error", e2); return { error }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - console.error("decrypt error", e); - return { error: e.message }; + } catch (e2) { + console.error("decrypt error", e2); + return { error: e2.message }; } }; const disconnect = async () => { @@ -26741,28 +33942,32 @@ const disconnect = async () => { }); localStorage.removeItem("puzzle-hasInjectedConnection"); emitter.emit("session_change"); - } catch (e) { - console.warn(e); + } catch (e2) { + console.warn(e2); } return {}; - } catch (e) { - console.error("error disconnecting", e); - const error = e.message; + } catch (e2) { + console.error("error disconnecting", e2); + const error = e2.message; return { error }; } }; const getEvent = async ({ id, - address + address, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { event: void 0, error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getEvent", @@ -26776,9 +33981,9 @@ const getEvent = async ({ try { const response = await window.aleo.puzzleWalletClient.getEvent.query(query); return response; - } catch (e) { - console.error("getEvent error", e); - const error = e.message; + } catch (e2) { + console.error("getEvent error", e2); + const error = e2.message; return { error }; } } @@ -26789,13 +33994,13 @@ const getEvent = async ({ try { const response = await fetchEvent(); return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; return { error }; } }; -const getEvents = async (filter) => { +const getEvents = async (filter, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { @@ -26804,9 +34009,15 @@ const getEvents = async (filter) => { if ((filter == null ? void 0 : filter.programId) === "") { filter.programId = void 0; } + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getEvents", @@ -26820,9 +34031,9 @@ const getEvents = async (filter) => { try { const response = await window.aleo.puzzleWalletClient.getEvents.query(query); return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; return { error }; } } @@ -26833,21 +34044,24 @@ const getEvents = async (filter) => { try { const response = await fetchPage(); return response; - } catch (e) { - console.error("getEvents error", e); - const error = e.message; + } catch (e2) { + console.error("getEvents error", e2); + const error = e2.message; return { error }; } }; -const importSharedState = async (seed) => { +const importSharedState = async (seed, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "importSharedState", @@ -26860,34 +34074,38 @@ const importSharedState = async (seed) => { try { const response = await window.aleo.puzzleWalletClient.importSharedState.mutate(query); return response; - } catch (e) { - console.error("importSharedState error", e); - const error = e.message; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; return { error }; } } try { const response = await connection2.request(query); return response; - } catch (e) { - console.error("importSharedState error", e); - const error = e.message; + } catch (e2) { + console.error("importSharedState error", e2); + const error = e2.message; return { error }; } }; const getRecords = async ({ address, filter, - page = 0 + page = 0, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getRecords", @@ -26902,9 +34120,9 @@ const getRecords = async ({ try { const response = await window.aleo.puzzleWalletClient.getRecords.query(query); return response; - } catch (e) { - console.error("getRecords error", e); - const error = e.message; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; return { error }; } } @@ -26915,38 +34133,44 @@ const getRecords = async ({ try { const response = await fetchPage(); return response; - } catch (e) { - console.error("getRecords error", e); - const error = e.message; + } catch (e2) { + console.error("getRecords error", e2); + const error = e2.message; return { error }; } }; const requestSignature = async ({ message, - address + address, + network, + method }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } try { const response = await connection2.request({ topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "requestSignature", params: { message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method } } }); return response; - } catch (e) { - console.error("signature error", e); - const error = e.message; + } catch (e2) { + console.error("signature error", e2); + const error = e2.message; return { error }; } }; @@ -26954,50 +34178,50 @@ const PAGE_SIZE = 20; const log_sdk = debug$1("wallet:sdk"); log_sdk.enabled = true; export { - zodViewKey as $, + PAGE_SIZE as $, queryClient as A, useWalletSession as B, - useWalletStore as C, - AssetType as D, + EventType as C, + aleoAddressRegex as D, EventStatus as E, - EventType as F, - aleoAddressRegex as G, - aleoFieldRegex as H, - aleoPrivateKeyRegex as I, - aleoTransactionIdRegex as J, - aleoU32 as K, - aleoU64 as L, - aleoViewKeyRegex as M, + aleoFieldRegex as F, + aleoPrivateKeyRegex as G, + aleoTransactionIdRegex as H, + aleoU32 as I, + aleoU64 as J, + aleoViewKeyRegex as K, + zodAddress as L, + zodEventStatus as M, Network as N, - zodAddress as O, + zodEventType as O, PuzzleWalletProvider as P, - zodEventStatus as Q, - R$4 as R, - zodEventType as S, - T$1 as T, - zodField as U, + zodField as Q, + R$1 as R, + zodNetwork as S, + T$2 as T, + zodPrivateKey as U, Visibility as V, - zodNetwork as W, - zodPrivateKey as X, - zodTransactionId as Y, - zodU32 as Z, - zodU64 as _, - a$3 as a, - zodVisibility as a0, - PAGE_SIZE as a1, - getAccount as a2, - getBalance as a3, - connect as a4, - requestCreateEvent as a5, - createSharedState as a6, - decrypt as a7, - disconnect as a8, - getEvent as a9, - getEvents as aa, - importSharedState as ab, - getRecords as ac, - requestSignature as ad, - wc_aleo_methods as ae, + zodTransactionId as W, + zodU32 as X, + zodU64 as Y, + zodViewKey as Z, + zodVisibility as _, + shortenAddress as a, + getAccount as a0, + getBalance as a1, + connect as a2, + requestCreateEvent as a3, + createSharedState as a4, + decrypt as a5, + disconnect as a6, + getEvent as a7, + getEvents as a8, + importSharedState as a9, + getRecords as aa, + requestSignature as ab, + wc_aleo_methods as ac, + wc_required_aleo_chains as ad, + wc_optional_aleo_chains as ae, wc_aleo_chains as af, wc_events as ag, projectId as ah, @@ -27005,36 +34229,38 @@ export { web3modal_puzzle_props_default as aj, web3modal_puzzle_props as ak, signClient_puzzleProps as al, - log_sdk as am, - checkForDesktopConnection as an, - hasInjectedConnection as ao, - emitter as ap, - connection as aq, - configureConnection as ar, - getWalletConnectModalSignClient as as, - shortenAddress as b, - useBalance as c, - useConnect as d, - useCreateSharedState as e, - useDecrypt as f, - useDisconnect as g, - useEvent as h, - useEvents as i, + networkToChainId as am, + chainIdToNetwork as an, + log_sdk as ao, + checkForDesktopConnection as ap, + hasInjectedConnection as aq, + emitter as ar, + connection as as, + configureConnection as at, + getWalletConnectModalSignClient as au, + useBalance as b, + useConnect as c, + useCreateSharedState as d, + useDecrypt as e, + useDisconnect as f, + useEvent as g, + useEvents as h, + i$1 as i, useImportSharedState as j, getFormattedRecordPlaintext as k, useRecords as l, useRequestCreateEvent as m, - ne as n, - oe$1 as o, - p$3 as p, + ne$3 as n, + oe$2 as o, + p$2 as p, useRequestSignature as q, useOnSessionDelete as r, - se as s, - te$2 as t, + se$3 as s, + te$1 as t, useAccount as u, useOnSessionEvent as v, useOnSessionExpire as w, useOnSessionUpdate as x, - y$3 as y, + y$4 as y, useSession as z }; diff --git a/packages/react/dist/puzzle.cjs.js b/packages/react/dist/puzzle.cjs.js index 9a0e6d02..547f2415 100644 --- a/packages/react/dist/puzzle.cjs.js +++ b/packages/react/dist/puzzle.cjs.js @@ -1,10 +1,6 @@ "use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); -const index = require("./index-DbX1yfTB.cjs"); -Object.defineProperty(exports, "AssetType", { - enumerable: true, - get: () => index.AssetType -}); +const index = require("./index-BHOVivr9.cjs"); Object.defineProperty(exports, "EventStatus", { enumerable: true, get: () => index.EventStatus @@ -30,6 +26,7 @@ exports.aleoTransactionIdRegex = index.aleoTransactionIdRegex; exports.aleoU32 = index.aleoU32; exports.aleoU64 = index.aleoU64; exports.aleoViewKeyRegex = index.aleoViewKeyRegex; +exports.chainIdToNetwork = index.chainIdToNetwork; exports.checkForDesktopConnection = index.checkForDesktopConnection; exports.configureConnection = index.configureConnection; exports.connect = index.connect; @@ -51,6 +48,7 @@ exports.getWalletConnectModalSignClient = index.getWalletConnectModalSignClient; exports.hasInjectedConnection = index.hasInjectedConnection; exports.importSharedState = index.importSharedState; exports.log_sdk = index.log_sdk; +exports.networkToChainId = index.networkToChainId; exports.projectId = index.projectId; exports.queryClient = index.queryClient; exports.requestCreateEvent = index.requestCreateEvent; @@ -75,10 +73,11 @@ exports.useRequestCreateEvent = index.useRequestCreateEvent; exports.useRequestSignature = index.useRequestSignature; exports.useSession = index.useSession; exports.useWalletSession = index.useWalletSession; -exports.useWalletStore = index.useWalletStore; exports.wc_aleo_chains = index.wc_aleo_chains; exports.wc_aleo_methods = index.wc_aleo_methods; exports.wc_events = index.wc_events; +exports.wc_optional_aleo_chains = index.wc_optional_aleo_chains; +exports.wc_required_aleo_chains = index.wc_required_aleo_chains; exports.web3modal_puzzle_props = index.web3modal_puzzle_props; exports.web3modal_puzzle_props_android = index.web3modal_puzzle_props_android; exports.web3modal_puzzle_props_default = index.web3modal_puzzle_props_default; diff --git a/packages/react/dist/puzzle.es.js b/packages/react/dist/puzzle.es.js index 3131a400..dbad31e0 100644 --- a/packages/react/dist/puzzle.es.js +++ b/packages/react/dist/puzzle.es.js @@ -1,51 +1,52 @@ -import { D, E, F, N, a1, P, V, G, H, I, J, K, L, M, an, ar, a4, aq, a6, a7, a8, ap, a2, a3, a9, aa, k, ac, as, ao, ab, am, ah, A, a5, ad, b, al, u, c, d, e, f, g, h, i, j, r, v, w, x, l, m, q, z, B, C, af, ae, ag, ak, ai, aj, O, Q, S, U, W, X, Y, Z, _, $, a0 } from "./index-BqFuGgVn.js"; +import { E, C, N, $, P, V, D, F, G, H, I, J, K, an, ap, at, a2, as, a4, a5, a6, ar, a0, a1, a7, a8, k, aa, au, aq, a9, ao, am, ah, A, a3, ab, a, al, u, b, c, d, e, f, g, h, j, r, v, w, x, l, m, q, z, B, af, ac, ag, ae, ad, ak, ai, aj, L, M, O, Q, S, U, W, X, Y, Z, _ } from "./index-j7s7E1c2.js"; export { - D as AssetType, E as EventStatus, - F as EventType, + C as EventType, N as Network, - a1 as PAGE_SIZE, + $ as PAGE_SIZE, P as PuzzleWalletProvider, V as Visibility, - G as aleoAddressRegex, - H as aleoFieldRegex, - I as aleoPrivateKeyRegex, - J as aleoTransactionIdRegex, - K as aleoU32, - L as aleoU64, - M as aleoViewKeyRegex, - an as checkForDesktopConnection, - ar as configureConnection, - a4 as connect, - aq as connection, - a6 as createSharedState, - a7 as decrypt, - a8 as disconnect, - ap as emitter, - a2 as getAccount, - a3 as getBalance, - a9 as getEvent, - aa as getEvents, + D as aleoAddressRegex, + F as aleoFieldRegex, + G as aleoPrivateKeyRegex, + H as aleoTransactionIdRegex, + I as aleoU32, + J as aleoU64, + K as aleoViewKeyRegex, + an as chainIdToNetwork, + ap as checkForDesktopConnection, + at as configureConnection, + a2 as connect, + as as connection, + a4 as createSharedState, + a5 as decrypt, + a6 as disconnect, + ar as emitter, + a0 as getAccount, + a1 as getBalance, + a7 as getEvent, + a8 as getEvents, k as getFormattedRecordPlaintext, - ac as getRecords, - as as getWalletConnectModalSignClient, - ao as hasInjectedConnection, - ab as importSharedState, - am as log_sdk, + aa as getRecords, + au as getWalletConnectModalSignClient, + aq as hasInjectedConnection, + a9 as importSharedState, + ao as log_sdk, + am as networkToChainId, ah as projectId, A as queryClient, - a5 as requestCreateEvent, - ad as requestSignature, - b as shortenAddress, + a3 as requestCreateEvent, + ab as requestSignature, + a as shortenAddress, al as signClient_puzzleProps, u as useAccount, - c as useBalance, - d as useConnect, - e as useCreateSharedState, - f as useDecrypt, - g as useDisconnect, - h as useEvent, - i as useEvents, + b as useBalance, + c as useConnect, + d as useCreateSharedState, + e as useDecrypt, + f as useDisconnect, + g as useEvent, + h as useEvents, j as useImportSharedState, r as useOnSessionDelete, v as useOnSessionEvent, @@ -56,22 +57,23 @@ export { q as useRequestSignature, z as useSession, B as useWalletSession, - C as useWalletStore, af as wc_aleo_chains, - ae as wc_aleo_methods, + ac as wc_aleo_methods, ag as wc_events, + ae as wc_optional_aleo_chains, + ad as wc_required_aleo_chains, ak as web3modal_puzzle_props, ai as web3modal_puzzle_props_android, aj as web3modal_puzzle_props_default, - O as zodAddress, - Q as zodEventStatus, - S as zodEventType, - U as zodField, - W as zodNetwork, - X as zodPrivateKey, - Y as zodTransactionId, - Z as zodU32, - _ as zodU64, - $ as zodViewKey, - a0 as zodVisibility + L as zodAddress, + M as zodEventStatus, + O as zodEventType, + Q as zodField, + S as zodNetwork, + U as zodPrivateKey, + W as zodTransactionId, + X as zodU32, + Y as zodU64, + Z as zodViewKey, + _ as zodVisibility }; diff --git a/packages/react/dist/puzzle.umd.js b/packages/react/dist/puzzle.umd.js index 191f8f43..5c77616b 100644 --- a/packages/react/dist/puzzle.umd.js +++ b/packages/react/dist/puzzle.umd.js @@ -1,27 +1,27 @@ (function(global2, factory) { - typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("zustand"), require("@tanstack/react-query"), require("events"), require("@walletconnect/utils"), require("use-debounce"), require("@walletconnect/modal-sign-html"), require("debug")) : typeof define === "function" && define.amd ? define(["exports", "react", "zustand", "@tanstack/react-query", "events", "@walletconnect/utils", "use-debounce", "@walletconnect/modal-sign-html", "debug"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@puzzlehq/sdk-react"] = global2["@puzzlehq/sdk-react"] || {}, global2.React, global2.zustand, global2.reactQuery, global2.EventEmitter, global2.utils, global2.useDebounce, global2.modalSignHtml, global2.debug)); -})(this, function(exports2, React, zustand, reactQuery, EventEmitter$2, utils$3, useDebounce, modalSignHtml, debug$1) { + typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("zustand"), require("@tanstack/react-query"), require("events"), require("@walletconnect/utils"), require("use-debounce"), require("@puzzlehq/walletconnect-modal-sign-html"), require("debug")) : typeof define === "function" && define.amd ? define(["exports", "react", "zustand", "@tanstack/react-query", "events", "@walletconnect/utils", "use-debounce", "@puzzlehq/walletconnect-modal-sign-html", "debug"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@puzzlehq/sdk-react"] = global2["@puzzlehq/sdk-react"] || {}, global2.React, global2.zustand, global2.reactQuery, global2.EventEmitter, global2.utils, global2.useDebounce, global2.modalSignHtml, global2.debug)); +})(this, function(exports2, React, zustand, reactQuery, EventEmitter$2, utils$3, useDebounce, walletconnectModalSignHtml, debug$1) { "use strict"; function _interopNamespaceDefault(e2) { - const n3 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } }); + const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } }); if (e2) { for (const k2 in e2) { if (k2 !== "default") { - const d3 = Object.getOwnPropertyDescriptor(e2, k2); - Object.defineProperty(n3, k2, d3.get ? d3 : { + const d2 = Object.getOwnPropertyDescriptor(e2, k2); + Object.defineProperty(n2, k2, d2.get ? d2 : { enumerable: true, get: () => e2[k2] }); } } } - n3.default = e2; - return Object.freeze(n3); + n2.default = e2; + return Object.freeze(n2); } const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React); const t$4 = Symbol(); - const s$4 = Object.getPrototypeOf, c$2$1 = /* @__PURE__ */ new WeakMap(), l$2$1 = (e2) => e2 && (c$2$1.has(e2) ? c$2$1.get(e2) : s$4(e2) === Object.prototype || s$4(e2) === Array.prototype), y$4 = (e2) => l$2$1(e2) && e2[t$4] || null, h$4 = (e2, t2 = true) => { - c$2$1.set(e2, t2); + const s$1$1 = Object.getPrototypeOf, c$4 = /* @__PURE__ */ new WeakMap(), l$2$1 = (e2) => e2 && (c$4.has(e2) ? c$4.get(e2) : s$1$1(e2) === Object.prototype || s$1$1(e2) === Array.prototype), y$5 = (e2) => l$2$1(e2) && e2[t$4] || null, h$3 = (e2, t2 = true) => { + c$4.set(e2, t2); }; var define_import_meta_env_default$1 = { BASE_URL: "/", MODE: "production", DEV: false, PROD: true, SSR: false }; const isObject = (x2) => typeof x2 === "object" && x2 !== null; @@ -42,7 +42,7 @@ return cache[1]; } const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); - h$4(snap, true); + h$3(snap, true); snapCache.set(target, [version2, snap]); Reflect.ownKeys(target).forEach((key) => { if (Object.getOwnPropertyDescriptor(snap, key)) { @@ -57,7 +57,7 @@ configurable: true }; if (refSet.has(value)) { - h$4(value, false); + h$3(value, false); } else if (value instanceof Promise) { delete desc.value; desc.get = () => handlePromise(value); @@ -121,11 +121,11 @@ } }; const removePropListener = (prop) => { - var _a; + var _a2; const entry = propProxyStates.get(prop); if (entry) { propProxyStates.delete(prop); - (_a = entry[1]) == null ? void 0 : _a.call(entry); + (_a2 = entry[1]) == null ? void 0 : _a2.call(entry); } }; const addListener2 = (listener) => { @@ -171,7 +171,7 @@ } removePropListener(prop); if (isObject(value)) { - value = y$4(value) || value; + value = y$5(value) || value; } let nextValue = value; if (value instanceof Promise) { @@ -251,10 +251,6 @@ let isListenerActive = false; const listener = (op) => { ops.push(op); - if (notifyInSync) { - callback(ops.splice(0)); - return; - } if (!promise) { promise = Promise.resolve().then(() => { promise = void 0; @@ -279,388 +275,240 @@ const [target, ensureVersion, createSnapshot] = proxyState; return createSnapshot(target, ensureVersion(), handlePromise); } - const o$1$1 = proxy({ - history: ["ConnectWallet"], - view: "ConnectWallet", - data: void 0 - }), T$1$1 = { - state: o$1$1, - subscribe(e2) { - return subscribe(o$1$1, () => e2(o$1$1)); - }, - push(e2, t2) { - e2 !== o$1$1.view && (o$1$1.view = e2, t2 && (o$1$1.data = t2), o$1$1.history.push(e2)); - }, - reset(e2) { - o$1$1.view = e2, o$1$1.history = [e2]; - }, - replace(e2) { - o$1$1.history.length > 1 && (o$1$1.history[o$1$1.history.length - 1] = e2, o$1$1.view = e2); - }, - goBack() { - if (o$1$1.history.length > 1) { - o$1$1.history.pop(); - const [e2] = o$1$1.history.slice(-1); - o$1$1.view = e2; - } - }, - setData(e2) { - o$1$1.data = e2; - } - }, a$3 = { - WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", - WCM_VERSION: "WCM_VERSION", - RECOMMENDED_WALLET_AMOUNT: 9, - isMobile() { - return typeof window < "u" ? Boolean( - window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test( - navigator.userAgent - ) - ) : false; - }, - isAndroid() { - return a$3.isMobile() && navigator.userAgent.toLowerCase().includes("android"); - }, - isIos() { - const e2 = navigator.userAgent.toLowerCase(); - return a$3.isMobile() && (e2.includes("iphone") || e2.includes("ipad")); - }, - isHttpUrl(e2) { - return e2.startsWith("http://") || e2.startsWith("https://"); - }, - isArray(e2) { - return Array.isArray(e2) && e2.length > 0; - }, - formatNativeUrl(e2, t2, s2) { - if (a$3.isHttpUrl(e2)) - return this.formatUniversalUrl(e2, t2, s2); - let n3 = e2; - n3.includes("://") || (n3 = e2.replaceAll("/", "").replaceAll(":", ""), n3 = `${n3}://`), n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - formatUniversalUrl(e2, t2, s2) { - if (!a$3.isHttpUrl(e2)) - return this.formatNativeUrl(e2, t2, s2); - let n3 = e2; - n3.endsWith("/") || (n3 = `${n3}/`), this.setWalletConnectDeepLink(n3, s2); - const i2 = encodeURIComponent(t2); - return `${n3}wc?uri=${i2}`; - }, - async wait(e2) { - return new Promise((t2) => { - setTimeout(t2, e2); - }); - }, - openHref(e2, t2) { - window.open(e2, t2, "noreferrer noopener"); - }, - setWalletConnectDeepLink(e2, t2) { - try { - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: e2, name: t2 }) - ); - } catch { - console.info("Unable to set WalletConnect deep link"); - } - }, - setWalletConnectAndroidDeepLink(e2) { - try { - const [t2] = e2.split("?"); - localStorage.setItem( - a$3.WALLETCONNECT_DEEPLINK_CHOICE, - JSON.stringify({ href: t2, name: "Android" }) - ); - } catch { - console.info("Unable to set WalletConnect android deep link"); - } - }, - removeWalletConnectDeepLink() { - try { - localStorage.removeItem(a$3.WALLETCONNECT_DEEPLINK_CHOICE); - } catch { - console.info("Unable to remove WalletConnect deep link"); - } - }, - setModalVersionInStorage() { - try { - typeof localStorage < "u" && localStorage.setItem(a$3.WCM_VERSION, "2.6.2"); - } catch { - console.info("Unable to set Web3Modal version in storage"); - } - }, - getWalletRouterData() { - var e2; - const t2 = (e2 = T$1$1.state.data) == null ? void 0 : e2.Wallet; - if (!t2) - throw new Error('Missing "Wallet" view data'); - return t2; + const o$1$1 = proxy({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), T$2 = { state: o$1$1, subscribe(e2) { + return subscribe(o$1$1, () => e2(o$1$1)); + }, push(e2, t2) { + e2 !== o$1$1.view && (o$1$1.view = e2, t2 && (o$1$1.data = t2), o$1$1.history.push(e2)); + }, reset(e2) { + o$1$1.view = e2, o$1$1.history = [e2]; + }, replace(e2) { + o$1$1.history.length > 1 && (o$1$1.history[o$1$1.history.length - 1] = e2, o$1$1.view = e2); + }, goBack() { + if (o$1$1.history.length > 1) { + o$1$1.history.pop(); + const [e2] = o$1$1.history.slice(-1); + o$1$1.view = e2; + } + }, setData(e2) { + o$1$1.data = e2; + } }, i$1$1 = { WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", WCM_VERSION: "WCM_VERSION", RECOMMENDED_WALLET_AMOUNT: 9, isMobile() { + return typeof window < "u" ? Boolean(window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)) : false; + }, isAndroid() { + return i$1$1.isMobile() && navigator.userAgent.toLowerCase().includes("android"); + }, isIos() { + const e2 = navigator.userAgent.toLowerCase(); + return i$1$1.isMobile() && (e2.includes("iphone") || e2.includes("ipad")); + }, isHttpUrl(e2) { + return e2.startsWith("http://") || e2.startsWith("https://"); + }, isArray(e2) { + return Array.isArray(e2) && e2.length > 0; + }, formatNativeUrl(e2, t2, s22) { + if (i$1$1.isHttpUrl(e2)) + return this.formatUniversalUrl(e2, t2, s22); + let n4 = e2; + n4.includes("://") || (n4 = e2.replaceAll("/", "").replaceAll(":", ""), n4 = `${n4}://`), n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s22); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; + }, formatUniversalUrl(e2, t2, s22) { + if (!i$1$1.isHttpUrl(e2)) + return this.formatNativeUrl(e2, t2, s22); + let n4 = e2; + n4.endsWith("/") || (n4 = `${n4}/`), this.setWalletConnectDeepLink(n4, s22); + const r3 = encodeURIComponent(t2); + return `${n4}wc?uri=${r3}`; + }, async wait(e2) { + return new Promise((t2) => { + setTimeout(t2, e2); + }); + }, openHref(e2, t2) { + window.open(e2, t2, "noreferrer noopener"); + }, setWalletConnectDeepLink(e2, t2) { + try { + localStorage.setItem(i$1$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: e2, name: t2 })); + } catch { + console.info("Unable to set WalletConnect deep link"); } - }, _$3 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), r$1$1 = proxy({ - enabled: _$3, - userSessionId: "", - events: [], - connectedWalletId: void 0 - }), R$4 = { - state: r$1$1, - subscribe(e2) { - return subscribe(r$1$1.events, () => e2(snapshot(r$1$1.events[r$1$1.events.length - 1]))); - }, - initialize() { - r$1$1.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (r$1$1.userSessionId = crypto.randomUUID()); - }, - setConnectedWalletId(e2) { - r$1$1.connectedWalletId = e2; - }, - click(e2) { - if (r$1$1.enabled) { - const t2 = { - type: "CLICK", - name: e2.name, - userSessionId: r$1$1.userSessionId, - timestamp: Date.now(), - data: e2 - }; - r$1$1.events.push(t2); - } - }, - track(e2) { - if (r$1$1.enabled) { - const t2 = { - type: "TRACK", - name: e2.name, - userSessionId: r$1$1.userSessionId, - timestamp: Date.now(), - data: e2 - }; - r$1$1.events.push(t2); - } - }, - view(e2) { - if (r$1$1.enabled) { - const t2 = { - type: "VIEW", - name: e2.name, - userSessionId: r$1$1.userSessionId, - timestamp: Date.now(), - data: e2 - }; - r$1$1.events.push(t2); - } - } - }, c$1$1 = proxy({ - chains: void 0, - walletConnectUri: void 0, - isAuth: false, - isCustomDesktop: false, - isCustomMobile: false, - isDataLoaded: false, - isUiLoaded: false - }), p$3 = { - state: c$1$1, - subscribe(e2) { - return subscribe(c$1$1, () => e2(c$1$1)); - }, - setChains(e2) { - c$1$1.chains = e2; - }, - setWalletConnectUri(e2) { - c$1$1.walletConnectUri = e2; - }, - setIsCustomDesktop(e2) { - c$1$1.isCustomDesktop = e2; - }, - setIsCustomMobile(e2) { - c$1$1.isCustomMobile = e2; - }, - setIsDataLoaded(e2) { - c$1$1.isDataLoaded = e2; - }, - setIsUiLoaded(e2) { - c$1$1.isUiLoaded = e2; - }, - setIsAuth(e2) { - c$1$1.isAuth = e2; - } - }, W$2 = proxy({ - projectId: "", - mobileWallets: void 0, - desktopWallets: void 0, - walletImages: void 0, - chains: void 0, - enableAuthMode: false, - enableExplorer: true, - explorerExcludedWalletIds: void 0, - explorerRecommendedWalletIds: void 0, - termsOfServiceUrl: void 0, - privacyPolicyUrl: void 0 - }), y$3 = { - state: W$2, - subscribe(e2) { - return subscribe(W$2, () => e2(W$2)); - }, - setConfig(e2) { - var t2, s2; - R$4.initialize(), p$3.setChains(e2.chains), p$3.setIsAuth(Boolean(e2.enableAuthMode)), p$3.setIsCustomMobile( - Boolean((t2 = e2.mobileWallets) == null ? void 0 : t2.length) - ), p$3.setIsCustomDesktop( - Boolean((s2 = e2.desktopWallets) == null ? void 0 : s2.length) - ), a$3.setModalVersionInStorage(), Object.assign(W$2, e2); - } - }; - var V$2 = Object.defineProperty, D$4 = Object.getOwnPropertySymbols, H$2 = Object.prototype.hasOwnProperty, B$2 = Object.prototype.propertyIsEnumerable, M$1 = (e2, t2, s2) => t2 in e2 ? V$2(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, K$1 = (e2, t2) => { - for (var s2 in t2 || (t2 = {})) - H$2.call(t2, s2) && M$1(e2, s2, t2[s2]); - if (D$4) - for (var s2 of D$4(t2)) - B$2.call(t2, s2) && M$1(e2, s2, t2[s2]); - return e2; - }; - const L$2 = "https://explorer-api.walletconnect.com", E$2 = "wcm", O$3 = "js-2.6.2"; - async function w$5(e2, t2) { - const s2 = K$1({ sdkType: E$2, sdkVersion: O$3 }, t2), n3 = new URL(e2, L$2); - return n3.searchParams.append("projectId", y$3.state.projectId), Object.entries(s2).forEach(([i2, l2]) => { - l2 && n3.searchParams.append(i2, String(l2)); - }), (await fetch(n3)).json(); - } - const m$2 = { - async getDesktopListings(e2) { - return w$5("/w3m/v1/getDesktopListings", e2); - }, - async getMobileListings(e2) { - return w$5("/w3m/v1/getMobileListings", e2); - }, - async getInjectedListings(e2) { - return w$5("/w3m/v1/getInjectedListings", e2); - }, - async getAllListings(e2) { - return w$5("/w3m/v1/getAllListings", e2); - }, - getWalletImageUrl(e2) { - return `${L$2}/w3m/v1/getWalletImage/${e2}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; - }, - getAssetImageUrl(e2) { - return `${L$2}/w3m/v1/getAssetImage/${e2}?projectId=${y$3.state.projectId}&sdkType=${E$2}&sdkVersion=${O$3}`; + }, setWalletConnectAndroidDeepLink(e2) { + try { + const [t2] = e2.split("?"); + localStorage.setItem(i$1$1.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href: t2, name: "Android" })); + } catch { + console.info("Unable to set WalletConnect android deep link"); } - }; - var z$3 = Object.defineProperty, j$3 = Object.getOwnPropertySymbols, J$2 = Object.prototype.hasOwnProperty, q$2 = Object.prototype.propertyIsEnumerable, k$2 = (e2, t2, s2) => t2 in e2 ? z$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, F$3 = (e2, t2) => { - for (var s2 in t2 || (t2 = {})) - J$2.call(t2, s2) && k$2(e2, s2, t2[s2]); - if (j$3) - for (var s2 of j$3(t2)) - q$2.call(t2, s2) && k$2(e2, s2, t2[s2]); - return e2; - }; - const N$3 = a$3.isMobile(), d$2 = proxy({ - wallets: { listings: [], total: 0, page: 1 }, - search: { listings: [], total: 0, page: 1 }, - recomendedWallets: [] - }), te$2 = { - state: d$2, - async getRecomendedWallets() { - const { explorerRecommendedWalletIds: e2, explorerExcludedWalletIds: t2 } = y$3.state; - if (e2 === "NONE" || t2 === "ALL" && !e2) - return d$2.recomendedWallets; - if (a$3.isArray(e2)) { - const s2 = { recommendedIds: e2.join(",") }, { listings: n3 } = await m$2.getAllListings(s2), i2 = Object.values(n3); - i2.sort && i2.sort((l2, v3) => { - const b3 = e2.indexOf(l2.id), f2 = e2.indexOf(v3.id); - return b3 - f2; - }), d$2.recomendedWallets = i2; - } else { - const { chains: s2, isAuth: n3 } = p$3.state, i2 = s2 == null ? void 0 : s2.join(","), l2 = a$3.isArray(t2), v3 = { - page: 1, - sdks: n3 ? "auth_v1" : void 0, - entries: a$3.RECOMMENDED_WALLET_AMOUNT, - chains: i2, - version: 2, - excludedIds: l2 ? t2.join(",") : void 0 - }, { listings: b3 } = N$3 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); - d$2.recomendedWallets = Object.values(b3); - } - return d$2.recomendedWallets; - }, - async getWallets(e2) { - const t2 = F$3({}, e2), { explorerRecommendedWalletIds: s2, explorerExcludedWalletIds: n3 } = y$3.state, { recomendedWallets: i2 } = d$2; - if (n3 === "ALL") - return d$2.wallets; - i2.length ? t2.excludedIds = i2.map((x2) => x2.id).join(",") : a$3.isArray(s2) && (t2.excludedIds = s2.join(",")), a$3.isArray(n3) && (t2.excludedIds = [t2.excludedIds, n3].filter(Boolean).join(",")), p$3.state.isAuth && (t2.sdks = "auth_v1"); - const { page: l2, search: v3 } = e2, { listings: b3, total: f2 } = N$3 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; - return d$2[U2] = { listings: [...d$2[U2].listings, ...A2], total: f2, page: l2 ?? 1 }, { listings: A2, total: f2 }; - }, - getWalletImageUrl(e2) { - return m$2.getWalletImageUrl(e2); - }, - getAssetImageUrl(e2) { - return m$2.getAssetImageUrl(e2); - }, - resetSearch() { - d$2.search = { listings: [], total: 0, page: 1 }; + }, removeWalletConnectDeepLink() { + try { + localStorage.removeItem(i$1$1.WALLETCONNECT_DEEPLINK_CHOICE); + } catch { + console.info("Unable to remove WalletConnect deep link"); } - }, I$1 = proxy({ open: false }), se$1 = { - state: I$1, - subscribe(e2) { - return subscribe(I$1, () => e2(I$1)); - }, - async open(e2) { - return new Promise((t2) => { - const { isUiLoaded: s2, isDataLoaded: n3 } = p$3.state; - if (a$3.removeWalletConnectDeepLink(), p$3.setWalletConnectUri(e2 == null ? void 0 : e2.uri), p$3.setChains(e2 == null ? void 0 : e2.chains), T$1$1.reset("ConnectWallet"), s2 && n3) - I$1.open = true, t2(); - else { - const i2 = setInterval(() => { - const l2 = p$3.state; - l2.isUiLoaded && l2.isDataLoaded && (clearInterval(i2), I$1.open = true, t2()); - }, 200); - } - }); - }, - close() { - I$1.open = false; + }, setModalVersionInStorage() { + try { + typeof localStorage < "u" && localStorage.setItem(i$1$1.WCM_VERSION, "0.0.6"); + } catch { + console.info("Unable to set Web3Modal version in storage"); } + }, getWalletRouterData() { + var e2; + const t2 = (e2 = T$2.state.data) == null ? void 0 : e2.Wallet; + if (!t2) + throw new Error('Missing "Wallet" view data'); + return t2; + } }, _$2 = typeof location < "u" && (location.hostname.includes("localhost") || location.protocol.includes("https")), a$2 = proxy({ enabled: _$2, userSessionId: "", events: [], connectedWalletId: void 0 }), R$1 = { state: a$2, subscribe(e2) { + return subscribe(a$2.events, () => e2(snapshot(a$2.events[a$2.events.length - 1]))); + }, initialize() { + a$2.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && (a$2.userSessionId = crypto.randomUUID()); + }, setConnectedWalletId(e2) { + a$2.connectedWalletId = e2; + }, click(e2) { + if (a$2.enabled) { + const t2 = { type: "CLICK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } + }, track(e2) { + if (a$2.enabled) { + const t2 = { type: "TRACK", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } + }, view(e2) { + if (a$2.enabled) { + const t2 = { type: "VIEW", name: e2.name, userSessionId: a$2.userSessionId, timestamp: Date.now(), data: e2 }; + a$2.events.push(t2); + } + } }, c$3 = proxy({ chains: void 0, walletConnectUri: void 0, isAuth: false, isCustomDesktop: false, isCustomMobile: false, isDataLoaded: false, isUiLoaded: false }), p$2 = { state: c$3, subscribe(e2) { + return subscribe(c$3, () => e2(c$3)); + }, setChains(e2) { + c$3.chains = e2; + }, setWalletConnectUri(e2) { + c$3.walletConnectUri = e2; + }, setIsCustomDesktop(e2) { + c$3.isCustomDesktop = e2; + }, setIsCustomMobile(e2) { + c$3.isCustomMobile = e2; + }, setIsDataLoaded(e2) { + c$3.isDataLoaded = e2; + }, setIsUiLoaded(e2) { + c$3.isUiLoaded = e2; + }, setIsAuth(e2) { + c$3.isAuth = e2; + } }, W = proxy({ projectId: "", mobileWallets: void 0, desktopWallets: void 0, walletImages: void 0, chains: void 0, enableAuthMode: false, enableExplorer: true, explorerExcludedWalletIds: void 0, explorerRecommendedWalletIds: void 0, termsOfServiceUrl: void 0, privacyPolicyUrl: void 0 }), y$4 = { state: W, subscribe(e2) { + return subscribe(W, () => e2(W)); + }, setConfig(e2) { + var t2, s22; + R$1.initialize(), p$2.setChains(e2.chains), p$2.setIsAuth(Boolean(e2.enableAuthMode)), p$2.setIsCustomMobile(Boolean((t2 = e2.mobileWallets) == null ? void 0 : t2.length)), p$2.setIsCustomDesktop(Boolean((s22 = e2.desktopWallets) == null ? void 0 : s22.length)), i$1$1.setModalVersionInStorage(), Object.assign(W, e2); + } }; + var V$3 = Object.defineProperty, D$2 = Object.getOwnPropertySymbols, H = Object.prototype.hasOwnProperty, B$1$1 = Object.prototype.propertyIsEnumerable, M$1 = (e2, t2, s22) => t2 in e2 ? V$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: s22 }) : e2[t2] = s22, K$4 = (e2, t2) => { + for (var s22 in t2 || (t2 = {})) + H.call(t2, s22) && M$1(e2, s22, t2[s22]); + if (D$2) + for (var s22 of D$2(t2)) + B$1$1.call(t2, s22) && M$1(e2, s22, t2[s22]); + return e2; + }; + const L$5 = "https://explorer-api.walletconnect.com", E$3 = "wcm", O$3 = "js-0.0.6"; + async function w$4(e2, t2) { + const s22 = K$4({ sdkType: E$3, sdkVersion: O$3 }, t2), n4 = new URL(e2, L$5); + return n4.searchParams.append("projectId", y$4.state.projectId), Object.entries(s22).forEach(([r3, l2]) => { + l2 && n4.searchParams.append(r3, String(l2)); + }), (await fetch(n4)).json(); + } + const m$2 = { async getDesktopListings(e2) { + return w$4("/w3m/v1/getDesktopListings", e2); + }, async getMobileListings(e2) { + return w$4("/w3m/v1/getMobileListings", e2); + }, async getInjectedListings(e2) { + return w$4("/w3m/v1/getInjectedListings", e2); + }, async getAllListings(e2) { + return w$4("/w3m/v1/getAllListings", e2); + }, getWalletImageUrl(e2) { + return `${L$5}/w3m/v1/getWalletImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; + }, getAssetImageUrl(e2) { + return `${L$5}/w3m/v1/getAssetImage/${e2}?projectId=${y$4.state.projectId}&sdkType=${E$3}&sdkVersion=${O$3}`; + } }; + var z$4 = Object.defineProperty, j$4 = Object.getOwnPropertySymbols, J$1 = Object.prototype.hasOwnProperty, q$3 = Object.prototype.propertyIsEnumerable, k$4 = (e2, t2, s22) => t2 in e2 ? z$4(e2, t2, { enumerable: true, configurable: true, writable: true, value: s22 }) : e2[t2] = s22, F$2 = (e2, t2) => { + for (var s22 in t2 || (t2 = {})) + J$1.call(t2, s22) && k$4(e2, s22, t2[s22]); + if (j$4) + for (var s22 of j$4(t2)) + q$3.call(t2, s22) && k$4(e2, s22, t2[s22]); + return e2; }; - var G$2 = Object.defineProperty, $$2 = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$2 = Object.prototype.propertyIsEnumerable, S$2$1 = (e2, t2, s2) => t2 in e2 ? G$2(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, Y$1 = (e2, t2) => { - for (var s2 in t2 || (t2 = {})) - Q$3.call(t2, s2) && S$2$1(e2, s2, t2[s2]); - if ($$2) - for (var s2 of $$2(t2)) - X$2.call(t2, s2) && S$2$1(e2, s2, t2[s2]); + const N$2 = i$1$1.isMobile(), d$4 = proxy({ wallets: { listings: [], total: 0, page: 1 }, search: { listings: [], total: 0, page: 1 }, recomendedWallets: [] }), te$1 = { state: d$4, async getRecomendedWallets() { + const { explorerRecommendedWalletIds: e2, explorerExcludedWalletIds: t2 } = y$4.state; + if (e2 === "NONE" || t2 === "ALL" && !e2) + return d$4.recomendedWallets; + if (i$1$1.isArray(e2)) { + const s22 = { recommendedIds: e2.join(",") }, { listings: n4 } = await m$2.getAllListings(s22), r3 = Object.values(n4); + n4 && r3.sort && r3.sort((l2, v3) => { + const b3 = e2.indexOf(l2.id), f3 = e2.indexOf(v3.id); + return b3 - f3; + }), d$4.recomendedWallets = r3; + } else { + const { chains: s22, isAuth: n4 } = p$2.state, r3 = s22 == null ? void 0 : s22.join(","), l2 = i$1$1.isArray(t2), v3 = { page: 1, sdks: n4 ? "auth_v1" : void 0, entries: i$1$1.RECOMMENDED_WALLET_AMOUNT, chains: r3, version: 2, excludedIds: l2 ? t2.join(",") : void 0 }, { listings: b3 } = N$2 ? await m$2.getMobileListings(v3) : await m$2.getDesktopListings(v3); + d$4.recomendedWallets = Object.values(b3); + } + return d$4.recomendedWallets; + }, async getWallets(e2) { + const t2 = F$2({}, e2), { explorerRecommendedWalletIds: s22, explorerExcludedWalletIds: n4 } = y$4.state, { recomendedWallets: r3 } = d$4; + if (n4 === "ALL") + return d$4.wallets; + r3.length ? t2.excludedIds = r3.map((x2) => x2.id).join(",") : i$1$1.isArray(s22) && (t2.excludedIds = s22.join(",")), i$1$1.isArray(n4) && (t2.excludedIds = [t2.excludedIds, n4].filter(Boolean).join(",")), p$2.state.isAuth && (t2.sdks = "auth_v1"); + const { page: l2, search: v3 } = e2, { listings: b3, total: f3 } = N$2 ? await m$2.getMobileListings(t2) : await m$2.getDesktopListings(t2), A2 = Object.values(b3), U2 = v3 ? "search" : "wallets"; + return d$4[U2] = { listings: [...d$4[U2].listings, ...A2], total: f3, page: l2 ?? 1 }, { listings: A2, total: f3 }; + }, getWalletImageUrl(e2) { + return m$2.getWalletImageUrl(e2); + }, getAssetImageUrl(e2) { + return m$2.getAssetImageUrl(e2); + }, resetSearch() { + d$4.search = { listings: [], total: 0, page: 1 }; + } }, I$3 = proxy({ open: false }), se$3 = { state: I$3, subscribe(e2) { + return subscribe(I$3, () => e2(I$3)); + }, async open(e2) { + return new Promise((t2) => { + const { isUiLoaded: s22, isDataLoaded: n4 } = p$2.state; + if (i$1$1.removeWalletConnectDeepLink(), p$2.setWalletConnectUri(e2 == null ? void 0 : e2.uri), p$2.setChains(e2 == null ? void 0 : e2.chains), T$2.reset("ConnectWallet"), s22 && n4) + I$3.open = true, t2(); + else { + const r3 = setInterval(() => { + const l2 = p$2.state; + l2.isUiLoaded && l2.isDataLoaded && (clearInterval(r3), I$3.open = true, t2()); + }, 200); + } + }); + }, close() { + I$3.open = false; + } }; + var G$1 = Object.defineProperty, $$1 = Object.getOwnPropertySymbols, Q$3 = Object.prototype.hasOwnProperty, X$1 = Object.prototype.propertyIsEnumerable, S$4 = (e2, t2, s22) => t2 in e2 ? G$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: s22 }) : e2[t2] = s22, Y$1 = (e2, t2) => { + for (var s22 in t2 || (t2 = {})) + Q$3.call(t2, s22) && S$4(e2, s22, t2[s22]); + if ($$1) + for (var s22 of $$1(t2)) + X$1.call(t2, s22) && S$4(e2, s22, t2[s22]); return e2; }; - function Z$2() { + function Z$1$1() { return typeof matchMedia < "u" && matchMedia("(prefers-color-scheme: dark)").matches; } - const C$1 = proxy({ themeMode: Z$2() ? "dark" : "light" }), ne$1 = { - state: C$1, - subscribe(e2) { - return subscribe(C$1, () => e2(C$1)); - }, - setThemeConfig(e2) { - const { themeMode: t2, themeVariables: s2 } = e2; - t2 && (C$1.themeMode = t2), s2 && (C$1.themeVariables = Y$1({}, s2)); - } - }, g$5 = proxy({ open: false, message: "", variant: "success" }), oe$1 = { - state: g$5, - subscribe(e2) { - return subscribe(g$5, () => e2(g$5)); - }, - openToast(e2, t2) { - g$5.open = true, g$5.message = e2, g$5.variant = t2; - }, - closeToast() { - g$5.open = false; - } - }; - let d$1$1 = class d { + const C$3 = proxy({ themeMode: Z$1$1() ? "dark" : "light" }), ne$3 = { state: C$3, subscribe(e2) { + return subscribe(C$3, () => e2(C$3)); + }, setThemeConfig(e2) { + const { themeMode: t2, themeVariables: s22 } = e2; + t2 && (C$3.themeMode = t2), s22 && (C$3.themeVariables = Y$1({}, s22)); + } }, g$3 = proxy({ open: false, message: "", variant: "success" }), oe$2 = { state: g$3, subscribe(e2) { + return subscribe(g$3, () => e2(g$3)); + }, openToast(e2, t2) { + g$3.open = true, g$3.message = e2, g$3.variant = t2; + }, closeToast() { + g$3.open = false; + } }; + let d$3 = class d { constructor(e2) { - this.openModal = se$1.open, this.closeModal = se$1.close, this.subscribeModal = se$1.subscribe, this.setTheme = ne$1.setThemeConfig, ne$1.setThemeConfig(e2), y$3.setConfig(e2), this.initUi(); + this.openModal = se$3.open, this.closeModal = se$3.close, this.subscribeModal = se$3.subscribe, this.setTheme = ne$3.setThemeConfig, ne$3.setThemeConfig(e2), y$4.setConfig(e2), this.initUi(); } async initUi() { if (typeof window < "u") { - await Promise.resolve().then(() => indexB2etef5O); + await Promise.resolve().then(() => indexF3LbIFb5); const e2 = document.createElement("wcm-modal"); - document.body.insertAdjacentElement("beforeend", e2), p$3.setIsUiLoaded(true); + document.body.insertAdjacentElement("beforeend", e2), p$2.setIsUiLoaded(true); } } }; @@ -668,40 +516,40 @@ function getDefaultExportFromCjs(x2) { return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; } - function getAugmentedNamespace(n3) { - if (n3.__esModule) - return n3; - var f2 = n3.default; - if (typeof f2 == "function") { + function getAugmentedNamespace(n4) { + if (n4.__esModule) + return n4; + var f3 = n4.default; + if (typeof f3 == "function") { var a3 = function a4() { if (this instanceof a4) { - return Reflect.construct(f2, arguments, this.constructor); + return Reflect.construct(f3, arguments, this.constructor); } - return f2.apply(this, arguments); + return f3.apply(this, arguments); }; - a3.prototype = f2.prototype; + a3.prototype = f3.prototype; } else a3 = {}; Object.defineProperty(a3, "__esModule", { value: true }); - Object.keys(n3).forEach(function(k2) { - var d3 = Object.getOwnPropertyDescriptor(n3, k2); - Object.defineProperty(a3, k2, d3.get ? d3 : { + Object.keys(n4).forEach(function(k2) { + var d5 = Object.getOwnPropertyDescriptor(n4, k2); + Object.defineProperty(a3, k2, d5.get ? d5 : { enumerable: true, get: function() { - return n3[k2]; + return n4[k2]; } }); }); return a3; } var events = { exports: {} }; - var R$3 = typeof Reflect === "object" ? Reflect : null; - var ReflectApply = R$3 && typeof R$3.apply === "function" ? R$3.apply : function ReflectApply2(target, receiver, args) { + var R$2 = typeof Reflect === "object" ? Reflect : null; + var ReflectApply = R$2 && typeof R$2.apply === "function" ? R$2.apply : function ReflectApply2(target, receiver, args) { return Function.prototype.apply.call(target, receiver, args); }; var ReflectOwnKeys; - if (R$3 && typeof R$3.ownKeys === "function") { - ReflectOwnKeys = R$3.ownKeys; + if (R$2 && typeof R$2.ownKeys === "function") { + ReflectOwnKeys = R$2.ownKeys; } else if (Object.getOwnPropertySymbols) { ReflectOwnKeys = function ReflectOwnKeys2(target) { return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)); @@ -752,11 +600,11 @@ } this._maxListeners = this._maxListeners || void 0; }; - EventEmitter.prototype.setMaxListeners = function setMaxListeners(n3) { - if (typeof n3 !== "number" || n3 < 0 || NumberIsNaN(n3)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n3 + "."); + EventEmitter.prototype.setMaxListeners = function setMaxListeners(n4) { + if (typeof n4 !== "number" || n4 < 0 || NumberIsNaN(n4)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n4 + "."); } - this._maxListeners = n3; + this._maxListeners = n4; return this; }; function _getMaxListeners(that) { @@ -802,7 +650,7 @@ return true; }; function _addListener(target, type2, listener, prepend) { - var m2; + var m3; var events2; var existing; checkListener(listener); @@ -832,8 +680,8 @@ } else { existing.push(listener); } - m2 = _getMaxListeners(target); - if (m2 > 0 && existing.length > m2 && !existing.warned) { + m3 = _getMaxListeners(target); + if (m3 > 0 && existing.length > m3 && !existing.warned) { existing.warned = true; var w3 = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type2) + " listeners added. Use emitter.setMaxListeners() to increase limit"); w3.name = "MaxListenersExceededWarning"; @@ -1000,9 +848,9 @@ EventEmitter.prototype.eventNames = function eventNames() { return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; }; - function arrayClone(arr, n3) { - var copy2 = new Array(n3); - for (var i2 = 0; i2 < n3; ++i2) + function arrayClone(arr, n4) { + var copy2 = new Array(n4); + for (var i2 = 0; i2 < n4; ++i2) copy2[i2] = arr[i2]; return copy2; } @@ -1331,7 +1179,7 @@ }); } return Promise.all([...batches.values()].map((batch) => cb(batch))).then( - (r2) => r2.flat() + (r3) => r3.flat() ); }; const storage = { @@ -1359,7 +1207,7 @@ })), commonOptions ).then( - (r2) => r2.map((item) => ({ + (r3) => r3.map((item) => ({ key: joinKeys(batch.base, item.key), value: destr(item.value) })) @@ -1406,7 +1254,7 @@ async setItems(items, commonOptions) { await runBatch(items, commonOptions, async (batch) => { if (batch.driver.setItems) { - await asyncCall( + return asyncCall( batch.driver.setItems, batch.items.map((item) => ({ key: item.relativeKey, @@ -1512,11 +1360,11 @@ mount.relativeBase, opts ); - const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p3) => key.startsWith(p3))); + const keys2 = rawKeys.map((key) => mount.mountpoint + normalizeKey(key)).filter((key) => !maskedMounts.some((p2) => key.startsWith(p2))); allKeys.push(...keys2); maskedMounts = [ mount.mountpoint, - ...maskedMounts.filter((p3) => !p3.startsWith(mount.mountpoint)) + ...maskedMounts.filter((p2) => !p2.startsWith(mount.mountpoint)) ]; } return base3 ? allKeys.filter((key) => key.startsWith(base3) && !key.endsWith("$")) : allKeys.filter((key) => !key.endsWith("$")); @@ -1525,14 +1373,14 @@ async clear(base3, opts = {}) { base3 = normalizeBaseKey(base3); await Promise.all( - getMounts(base3, false).map(async (m2) => { - if (m2.driver.clear) { - return asyncCall(m2.driver.clear, m2.relativeBase, opts); + getMounts(base3, false).map(async (m3) => { + if (m3.driver.clear) { + return asyncCall(m3.driver.clear, m3.relativeBase, opts); } - if (m2.driver.removeItem) { - const keys2 = await m2.driver.getKeys(m2.relativeBase || "", opts); + if (m3.driver.removeItem) { + const keys2 = await m3.driver.getKeys(m3.relativeBase || "", opts); return Promise.all( - keys2.map((key) => m2.driver.removeItem(key, opts)) + keys2.map((key) => m3.driver.removeItem(key, opts)) ); } }) @@ -1594,18 +1442,18 @@ }, getMount(key = "") { key = normalizeKey(key) + ":"; - const m2 = getMount(key); + const m3 = getMount(key); return { - driver: m2.driver, - base: m2.base + driver: m3.driver, + base: m3.base }; }, getMounts(base3 = "", opts = {}) { base3 = normalizeKey(base3); const mounts = getMounts(base3, opts.parents); - return mounts.map((m2) => ({ - driver: m2.driver, - base: m2.mountpoint + return mounts.map((m3) => ({ + driver: m3.driver, + base: m3.mountpoint })); } }; @@ -1642,7 +1490,7 @@ function get(key, customStore = defaultGetStore()) { return customStore("readonly", (store) => promisifyRequest(store.get(key))); } - function set(key, value, customStore = defaultGetStore()) { + function set$1(key, value, customStore = defaultGetStore()) { return customStore("readwrite", (store) => { store.put(value, key); return promisifyRequest(store.transaction); @@ -1695,7 +1543,7 @@ } try { return JSONParse(value); - } catch (_a) { + } catch (_a2) { return value; } } @@ -1703,27 +1551,27 @@ return typeof value === "string" ? value : JSONStringify(value) || ""; } const x$1 = "idb-keyval"; - var z$2 = (i2 = {}) => { - const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e2 = (s2) => t2 + s2; - let n3; - return i2.dbName && i2.storeName && (n3 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s2) { - return !(typeof await get(e2(s2), n3) > "u"); - }, async getItem(s2) { - return await get(e2(s2), n3) ?? null; - }, setItem(s2, a3) { - return set(e2(s2), a3, n3); - }, removeItem(s2) { - return del(e2(s2), n3); + var z$3 = (i2 = {}) => { + const t2 = i2.base && i2.base.length > 0 ? `${i2.base}:` : "", e2 = (s22) => t2 + s22; + let n4; + return i2.dbName && i2.storeName && (n4 = createStore(i2.dbName, i2.storeName)), { name: x$1, options: i2, async hasItem(s22) { + return !(typeof await get(e2(s22), n4) > "u"); + }, async getItem(s22) { + return await get(e2(s22), n4) ?? null; + }, setItem(s22, a3) { + return set$1(e2(s22), a3, n4); + }, removeItem(s22) { + return del(e2(s22), n4); }, getKeys() { - return keys(n3); + return keys(n4); }, clear() { - return clear(n3); + return clear(n4); } }; }; - const D$3 = "WALLET_CONNECT_V2_INDEXED_DB", E$1 = "keyvaluestorage"; - let _$2 = class _ { + const D$1$1 = "WALLET_CONNECT_V2_INDEXED_DB", E$2 = "keyvaluestorage"; + let _$1$1 = class _ { constructor() { - this.indexedDb = createStorage({ driver: z$2({ dbName: D$3, storeName: E$1 }) }); + this.indexedDb = createStorage({ driver: z$3({ dbName: D$1$1, storeName: E$2 }) }); } async getKeys() { return this.indexedDb.getKeys(); @@ -1743,41 +1591,41 @@ await this.indexedDb.removeItem(t2); } }; - var l$1$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c$3 = { exports: {} }; + var l$1$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, c$2 = { exports: {} }; (function() { let i2; function t2() { } i2 = t2, i2.prototype.getItem = function(e2) { return this.hasOwnProperty(e2) ? String(this[e2]) : null; - }, i2.prototype.setItem = function(e2, n3) { - this[e2] = String(n3); + }, i2.prototype.setItem = function(e2, n4) { + this[e2] = String(n4); }, i2.prototype.removeItem = function(e2) { delete this[e2]; }, i2.prototype.clear = function() { const e2 = this; - Object.keys(e2).forEach(function(n3) { - e2[n3] = void 0, delete e2[n3]; + Object.keys(e2).forEach(function(n4) { + e2[n4] = void 0, delete e2[n4]; }); }, i2.prototype.key = function(e2) { return e2 = e2 || 0, Object.keys(this)[e2]; }, i2.prototype.__defineGetter__("length", function() { return Object.keys(this).length; - }), typeof l$1$1 < "u" && l$1$1.localStorage ? c$3.exports = l$1$1.localStorage : typeof window < "u" && window.localStorage ? c$3.exports = window.localStorage : c$3.exports = new t2(); + }), typeof l$1$1 < "u" && l$1$1.localStorage ? c$2.exports = l$1$1.localStorage : typeof window < "u" && window.localStorage ? c$2.exports = window.localStorage : c$2.exports = new t2(); })(); - function k$1(i2) { + function k$3(i2) { var t2; return [i2[0], safeJsonParse((t2 = i2[1]) != null ? t2 : "")]; } - let K$2 = class K { + let K$3 = class K { constructor() { - this.localStorage = c$3.exports; + this.localStorage = c$2.exports; } async getKeys() { return Object.keys(this.localStorage); } async getEntries() { - return Object.entries(this.localStorage).map(k$1); + return Object.entries(this.localStorage).map(k$3); } async getItem(t2) { const e2 = this.localStorage.getItem(t2); @@ -1791,9 +1639,9 @@ this.localStorage.removeItem(t2); } }; - const N$2 = "wc_storage_version", y$2 = 1, O$2 = async (i2, t2, e2) => { - const n3 = N$2, s2 = await t2.getItem(n3); - if (s2 && s2 >= y$2) { + const N$1$1 = "wc_storage_version", y$3 = 1, O$2 = async (i2, t2, e2) => { + const n4 = N$1$1, s22 = await t2.getItem(n4); + if (s22 && s22 >= y$3) { e2(t2); return; } @@ -1802,32 +1650,32 @@ e2(t2); return; } - const m2 = []; + const m3 = []; for (; a3.length; ) { - const r2 = a3.shift(); - if (!r2) + const r3 = a3.shift(); + if (!r3) continue; - const o22 = r2.toLowerCase(); + const o22 = r3.toLowerCase(); if (o22.includes("wc@") || o22.includes("walletconnect") || o22.includes("wc_") || o22.includes("wallet_connect")) { - const f2 = await i2.getItem(r2); - await t2.setItem(r2, f2), m2.push(r2); + const f3 = await i2.getItem(r3); + await t2.setItem(r3, f3), m3.push(r3); } } - await t2.setItem(n3, y$2), e2(t2), j$2(i2, m2); - }, j$2 = async (i2, t2) => { + await t2.setItem(n4, y$3), e2(t2), j$3(i2, m3); + }, j$3 = async (i2, t2) => { t2.length && t2.forEach(async (e2) => { await i2.removeItem(e2); }); }; - let h$3 = class h { + let h$2$1 = class h { constructor() { this.initialized = false, this.setInitialized = (e2) => { this.storage = e2, this.initialized = true; }; - const t2 = new K$2(); + const t2 = new K$3(); this.storage = t2; try { - const e2 = new _$2(); + const e2 = new _$1$1(); O$2(t2, e2, this.setInitialized); } catch { this.initialized = true; @@ -1856,7 +1704,7 @@ }); } }; - var cjs$5 = {}; + var cjs$4 = {}; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. @@ -1871,56 +1719,56 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ - var extendStatics = function(d3, b3) { - extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { - d4.__proto__ = b4; - } || function(d4, b4) { - for (var p3 in b4) - if (b4.hasOwnProperty(p3)) - d4[p3] = b4[p3]; + var extendStatics = function(d5, b3) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d6, b4) { + d6.__proto__ = b4; + } || function(d6, b4) { + for (var p2 in b4) + if (b4.hasOwnProperty(p2)) + d6[p2] = b4[p2]; }; - return extendStatics(d3, b3); + return extendStatics(d5, b3); }; - function __extends$1(d3, b3) { - extendStatics(d3, b3); + function __extends$1(d5, b3) { + extendStatics(d5, b3); function __() { - this.constructor = d3; + this.constructor = d5; } - d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); + d5.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); } var __assign$2 = function() { __assign$2 = Object.assign || function __assign2(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { - s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var s22, i2 = 1, n4 = arguments.length; i2 < n4; i2++) { + s22 = arguments[i2]; + for (var p2 in s22) + if (Object.prototype.hasOwnProperty.call(s22, p2)) + t2[p2] = s22[p2]; } return t2; }; return __assign$2.apply(this, arguments); }; - function __rest(s2, e2) { + function __rest(s22, e2) { var t2 = {}; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3) && e2.indexOf(p3) < 0) - t2[p3] = s2[p3]; - if (s2 != null && typeof Object.getOwnPropertySymbols === "function") - for (var i2 = 0, p3 = Object.getOwnPropertySymbols(s2); i2 < p3.length; i2++) { - if (e2.indexOf(p3[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p3[i2])) - t2[p3[i2]] = s2[p3[i2]]; + for (var p2 in s22) + if (Object.prototype.hasOwnProperty.call(s22, p2) && e2.indexOf(p2) < 0) + t2[p2] = s22[p2]; + if (s22 != null && typeof Object.getOwnPropertySymbols === "function") + for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s22); i2 < p2.length; i2++) { + if (e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s22, p2[i2])) + t2[p2[i2]] = s22[p2[i2]]; } return t2; } function __decorate(decorators, target, key, desc) { - var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3; + var c2 = arguments.length, r3 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d5; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r2 = Reflect.decorate(decorators, target, key, desc); + r3 = Reflect.decorate(decorators, target, key, desc); else for (var i2 = decorators.length - 1; i2 >= 0; i2--) - if (d3 = decorators[i2]) - r2 = (c2 < 3 ? d3(r2) : c2 > 3 ? d3(target, key, r2) : d3(target, key)) || r2; - return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2; + if (d5 = decorators[i2]) + r3 = (c2 < 3 ? d5(r3) : c2 > 3 ? d5(target, key, r3) : d5(target, key)) || r3; + return c2 > 3 && r3 && Object.defineProperty(target, key, r3), r3; } function __param(paramIndex, decorator) { return function(target, key) { @@ -1963,21 +1811,21 @@ if (t2[0] & 1) throw t2[1]; return t2[1]; - }, trys: [], ops: [] }, f2, y3, t2, g3; + }, trys: [], ops: [] }, f3, y3, t2, g3; return g3 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() { return this; }), g3; - function verb(n3) { + function verb(n4) { return function(v3) { - return step([n3, v3]); + return step([n4, v3]); }; } function step(op) { - if (f2) + if (f3) throw new TypeError("Generator is already executing."); while (_3) try { - if (f2 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) + if (f3 = 1, y3 && (t2 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t2 = y3["return"]) && t2.call(y3), 0) : y3.next) && !(t2 = t2.call(y3, op[1])).done) return t2; if (y3 = 0, t2) op = [op[0] & 2, t2.value]; @@ -2027,27 +1875,27 @@ op = [6, e2]; y3 = 0; } finally { - f2 = t2 = 0; + f3 = t2 = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } - function __createBinding(o22, m2, k2, k22) { + function __createBinding(o22, m3, k2, k22) { if (k22 === void 0) k22 = k2; - o22[k22] = m2[k2]; + o22[k22] = m3[k2]; } - function __exportStar(m2, exports22) { - for (var p3 in m2) - if (p3 !== "default" && !exports22.hasOwnProperty(p3)) - exports22[p3] = m2[p3]; + function __exportStar(m3, exports22) { + for (var p2 in m3) + if (p2 !== "default" && !exports22.hasOwnProperty(p2)) + exports22[p2] = m3[p2]; } function __values(o22) { - var s2 = typeof Symbol === "function" && Symbol.iterator, m2 = s2 && o22[s2], i2 = 0; - if (m2) - return m2.call(o22); + var s22 = typeof Symbol === "function" && Symbol.iterator, m3 = s22 && o22[s22], i2 = 0; + if (m3) + return m3.call(o22); if (o22 && typeof o22.length === "number") return { next: function() { @@ -2056,41 +1904,41 @@ return { value: o22 && o22[i2++], done: !o22 }; } }; - throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined."); + throw new TypeError(s22 ? "Object is not iterable." : "Symbol.iterator is not defined."); } - function __read$4(o22, n3) { - var m2 = typeof Symbol === "function" && o22[Symbol.iterator]; - if (!m2) + function __read$4(o22, n4) { + var m3 = typeof Symbol === "function" && o22[Symbol.iterator]; + if (!m3) return o22; - var i2 = m2.call(o22), r2, ar2 = [], e2; + var i2 = m3.call(o22), r3, ar3 = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n4 === void 0 || n4-- > 0) && !(r3 = i2.next()).done) + ar3.push(r3.value); } catch (error) { e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { if (e2) throw e2.error; } } - return ar2; + return ar3; } function __spread() { - for (var ar2 = [], i2 = 0; i2 < arguments.length; i2++) - ar2 = ar2.concat(__read$4(arguments[i2])); - return ar2; + for (var ar3 = [], i2 = 0; i2 < arguments.length; i2++) + ar3 = ar3.concat(__read$4(arguments[i2])); + return ar3; } function __spreadArrays() { - for (var s2 = 0, i2 = 0, il = arguments.length; i2 < il; i2++) - s2 += arguments[i2].length; - for (var r2 = Array(s2), k2 = 0, i2 = 0; i2 < il; i2++) + for (var s22 = 0, i2 = 0, il = arguments.length; i2 < il; i2++) + s22 += arguments[i2].length; + for (var r3 = Array(s22), k2 = 0, i2 = 0; i2 < il; i2++) for (var a3 = arguments[i2], j2 = 0, jl = a3.length; j2 < jl; j2++, k2++) - r2[k2] = a3[j2]; - return r2; + r3[k2] = a3[j2]; + return r3; } function __await(v3) { return this instanceof __await ? (this.v = v3, this) : new __await(v3); @@ -2102,23 +1950,23 @@ return i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { return this; }, i2; - function verb(n3) { - if (g3[n3]) - i2[n3] = function(v3) { + function verb(n4) { + if (g3[n4]) + i2[n4] = function(v3) { return new Promise(function(a3, b3) { - q2.push([n3, v3, a3, b3]) > 1 || resume(n3, v3); + q2.push([n4, v3, a3, b3]) > 1 || resume(n4, v3); }); }; } - function resume(n3, v3) { + function resume(n4, v3) { try { - step(g3[n3](v3)); + step(g3[n4](v3)); } catch (e2) { settle(q2[0][3], e2); } } - function step(r2) { - r2.value instanceof __await ? Promise.resolve(r2.value.v).then(fulfill, reject) : settle(q2[0][2], r2); + function step(r3) { + r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q2[0][2], r3); } function fulfill(value) { resume("next", value); @@ -2126,41 +1974,41 @@ function reject(value) { resume("throw", value); } - function settle(f2, v3) { - if (f2(v3), q2.shift(), q2.length) + function settle(f3, v3) { + if (f3(v3), q2.shift(), q2.length) resume(q2[0][0], q2[0][1]); } } function __asyncDelegator(o22) { - var i2, p3; + var i2, p2; return i2 = {}, verb("next"), verb("throw", function(e2) { throw e2; }), verb("return"), i2[Symbol.iterator] = function() { return this; }, i2; - function verb(n3, f2) { - i2[n3] = o22[n3] ? function(v3) { - return (p3 = !p3) ? { value: __await(o22[n3](v3)), done: n3 === "return" } : f2 ? f2(v3) : v3; - } : f2; + function verb(n4, f3) { + i2[n4] = o22[n4] ? function(v3) { + return (p2 = !p2) ? { value: __await(o22[n4](v3)), done: n4 === "return" } : f3 ? f3(v3) : v3; + } : f3; } } function __asyncValues(o22) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m2 = o22[Symbol.asyncIterator], i2; - return m2 ? m2.call(o22) : (o22 = typeof __values === "function" ? __values(o22) : o22[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { + var m3 = o22[Symbol.asyncIterator], i2; + return m3 ? m3.call(o22) : (o22 = typeof __values === "function" ? __values(o22) : o22[Symbol.iterator](), i2 = {}, verb("next"), verb("throw"), verb("return"), i2[Symbol.asyncIterator] = function() { return this; }, i2); - function verb(n3) { - i2[n3] = o22[n3] && function(v3) { + function verb(n4) { + i2[n4] = o22[n4] && function(v3) { return new Promise(function(resolve, reject) { - v3 = o22[n3](v3), settle(resolve, reject, v3.done, v3.value); + v3 = o22[n4](v3), settle(resolve, reject, v3.done, v3.value); }); }; } - function settle(resolve, reject, d3, v3) { + function settle(resolve, reject, d5, v3) { Promise.resolve(v3).then(function(v4) { - resolve({ value: v4, done: d3 }); + resolve({ value: v4, done: d5 }); }, reject); } } @@ -2230,8 +2078,8 @@ }, Symbol.toStringTag, { value: "Module" })); const require$$0$2 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6); var heartbeat$2 = {}; - var cjs$4 = {}; - var utils$1$1 = {}; + var cjs$3 = {}; + var utils$2 = {}; var delay = {}; var hasRequiredDelay; function requireDelay() { @@ -2251,7 +2099,7 @@ return delay; } var convert = {}; - var constants$2 = {}; + var constants$1 = {}; var misc = {}; var hasRequiredMisc; function requireMisc() { @@ -2301,18 +2149,18 @@ })(time$1); return time$1; } - var hasRequiredConstants$2; - function requireConstants$2() { - if (hasRequiredConstants$2) - return constants$2; - hasRequiredConstants$2 = 1; + var hasRequiredConstants$1; + function requireConstants$1() { + if (hasRequiredConstants$1) + return constants$1; + hasRequiredConstants$1 = 1; (function(exports22) { Object.defineProperty(exports22, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireMisc(), exports22); tslib_1.__exportStar(requireTime(), exports22); - })(constants$2); - return constants$2; + })(constants$1); + return constants$1; } var hasRequiredConvert; function requireConvert() { @@ -2321,7 +2169,7 @@ hasRequiredConvert = 1; Object.defineProperty(convert, "__esModule", { value: true }); convert.fromMiliseconds = convert.toMiliseconds = void 0; - const constants_1 = requireConstants$2(); + const constants_1 = requireConstants$1(); function toMiliseconds(seconds) { return seconds * constants_1.ONE_THOUSAND; } @@ -2332,18 +2180,18 @@ convert.fromMiliseconds = fromMiliseconds; return convert; } - var hasRequiredUtils$1; - function requireUtils$1() { - if (hasRequiredUtils$1) - return utils$1$1; - hasRequiredUtils$1 = 1; + var hasRequiredUtils; + function requireUtils() { + if (hasRequiredUtils) + return utils$2; + hasRequiredUtils = 1; (function(exports22) { Object.defineProperty(exports22, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireDelay(), exports22); tslib_1.__exportStar(requireConvert(), exports22); - })(utils$1$1); - return utils$1$1; + })(utils$2); + return utils$2; } var watch$1 = {}; var hasRequiredWatch$1; @@ -2417,18 +2265,18 @@ (function(exports22) { Object.defineProperty(exports22, "__esModule", { value: true }); const tslib_1 = require$$0$2; - tslib_1.__exportStar(requireUtils$1(), exports22); + tslib_1.__exportStar(requireUtils(), exports22); tslib_1.__exportStar(requireWatch$1(), exports22); tslib_1.__exportStar(requireTypes$1(), exports22); - tslib_1.__exportStar(requireConstants$2(), exports22); - })(cjs$4); + tslib_1.__exportStar(requireConstants$1(), exports22); + })(cjs$3); var types$1 = {}; var heartbeat$1 = {}; - let IEvents$1 = class IEvents { - }; + class IEvents { + } const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, - IEvents: IEvents$1 + IEvents }, Symbol.toStringTag, { value: "Module" })); const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(esm); var hasRequiredHeartbeat$2; @@ -2459,7 +2307,7 @@ })(types$1); return types$1; } - var constants$1 = {}; + var constants = {}; var heartbeat = {}; var hasRequiredHeartbeat$1; function requireHeartbeat$1() { @@ -2468,24 +2316,24 @@ hasRequiredHeartbeat$1 = 1; Object.defineProperty(heartbeat, "__esModule", { value: true }); heartbeat.HEARTBEAT_EVENTS = heartbeat.HEARTBEAT_INTERVAL = void 0; - const time_1 = cjs$4; + const time_1 = cjs$3; heartbeat.HEARTBEAT_INTERVAL = time_1.FIVE_SECONDS; heartbeat.HEARTBEAT_EVENTS = { pulse: "heartbeat_pulse" }; return heartbeat; } - var hasRequiredConstants$1; - function requireConstants$1() { - if (hasRequiredConstants$1) - return constants$1; - hasRequiredConstants$1 = 1; + var hasRequiredConstants; + function requireConstants() { + if (hasRequiredConstants) + return constants; + hasRequiredConstants = 1; (function(exports22) { Object.defineProperty(exports22, "__esModule", { value: true }); const tslib_1 = require$$0$2; tslib_1.__exportStar(requireHeartbeat$1(), exports22); - })(constants$1); - return constants$1; + })(constants); + return constants; } var hasRequiredHeartbeat; function requireHeartbeat() { @@ -2496,9 +2344,9 @@ heartbeat$2.HeartBeat = void 0; const tslib_1 = require$$0$2; const events_1 = eventsExports; - const time_1 = cjs$4; + const time_1 = cjs$3; const types_1 = requireTypes(); - const constants_1 = requireConstants$1(); + const constants_1 = requireConstants(); class HeartBeat extends types_1.IHeartBeat { constructor(opts) { super(opts); @@ -2550,595 +2398,676 @@ const tslib_1 = require$$0$2; tslib_1.__exportStar(requireHeartbeat(), exports22); tslib_1.__exportStar(requireTypes(), exports22); - tslib_1.__exportStar(requireConstants$1(), exports22); - })(cjs$5); - var cjs$3 = {}; - var quickFormatUnescaped; - var hasRequiredQuickFormatUnescaped; - function requireQuickFormatUnescaped() { - if (hasRequiredQuickFormatUnescaped) - return quickFormatUnescaped; - hasRequiredQuickFormatUnescaped = 1; - function tryStringify(o22) { - try { - return JSON.stringify(o22); - } catch (e2) { - return '"[Circular]"'; - } - } - quickFormatUnescaped = format; - function format(f2, args, opts) { - var ss2 = opts && opts.stringify || tryStringify; - var offset = 1; - if (typeof f2 === "object" && f2 !== null) { - var len = args.length + offset; - if (len === 1) - return f2; - var objects = new Array(len); - objects[0] = ss2(f2); - for (var index = 1; index < len; index++) { - objects[index] = ss2(args[index]); - } - return objects.join(" "); - } - if (typeof f2 !== "string") { - return f2; - } - var argLen = args.length; - if (argLen === 0) - return f2; - var str = ""; - var a3 = 1 - offset; - var lastPos = -1; - var flen = f2 && f2.length || 0; - for (var i2 = 0; i2 < flen; ) { - if (f2.charCodeAt(i2) === 37 && i2 + 1 < flen) { - lastPos = lastPos > -1 ? lastPos : 0; - switch (f2.charCodeAt(i2 + 1)) { - case 100: - case 102: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Number(args[a3]); - lastPos = i2 + 2; - i2++; + tslib_1.__exportStar(requireConstants(), exports22); + })(cjs$4); + function tryStringify(o22) { + try { + return JSON.stringify(o22); + } catch (e2) { + return '"[Circular]"'; + } + } + var quickFormatUnescaped = format$1; + function format$1(f3, args, opts) { + var ss4 = opts && opts.stringify || tryStringify; + var offset = 1; + if (typeof f3 === "object" && f3 !== null) { + var len = args.length + offset; + if (len === 1) + return f3; + var objects = new Array(len); + objects[0] = ss4(f3); + for (var index = 1; index < len; index++) { + objects[index] = ss4(args[index]); + } + return objects.join(" "); + } + if (typeof f3 !== "string") { + return f3; + } + var argLen = args.length; + if (argLen === 0) + return f3; + var str = ""; + var a3 = 1 - offset; + var lastPos = -1; + var flen = f3 && f3.length || 0; + for (var i2 = 0; i2 < flen; ) { + if (f3.charCodeAt(i2) === 37 && i2 + 1 < flen) { + lastPos = lastPos > -1 ? lastPos : 0; + switch (f3.charCodeAt(i2 + 1)) { + case 100: + case 102: + if (a3 >= argLen) break; - case 105: - if (a3 >= argLen) - break; - if (args[a3] == null) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += Math.floor(Number(args[a3])); - lastPos = i2 + 2; - i2++; + if (args[a3] == null) break; - case 79: - case 111: - case 106: - if (a3 >= argLen) - break; - if (args[a3] === void 0) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - var type2 = typeof args[a3]; - if (type2 === "string") { - str += "'" + args[a3] + "'"; - lastPos = i2 + 2; - i2++; - break; - } - if (type2 === "function") { - str += args[a3].name || ""; - lastPos = i2 + 2; - i2++; - break; - } - str += ss2(args[a3]); - lastPos = i2 + 2; - i2++; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Number(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 105: + if (a3 >= argLen) break; - case 115: - if (a3 >= argLen) - break; - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += String(args[a3]); + if (args[a3] == null) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += Math.floor(Number(args[a3])); + lastPos = i2 + 2; + i2++; + break; + case 79: + case 111: + case 106: + if (a3 >= argLen) + break; + if (args[a3] === void 0) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + var type2 = typeof args[a3]; + if (type2 === "string") { + str += "'" + args[a3] + "'"; lastPos = i2 + 2; i2++; break; - case 37: - if (lastPos < i2) - str += f2.slice(lastPos, i2); - str += "%"; + } + if (type2 === "function") { + str += args[a3].name || ""; lastPos = i2 + 2; i2++; - a3--; break; - } - ++a3; + } + str += ss4(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 115: + if (a3 >= argLen) + break; + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += String(args[a3]); + lastPos = i2 + 2; + i2++; + break; + case 37: + if (lastPos < i2) + str += f3.slice(lastPos, i2); + str += "%"; + lastPos = i2 + 2; + i2++; + a3--; + break; } - ++i2; + ++a3; } - if (lastPos === -1) - return f2; - else if (lastPos < flen) { - str += f2.slice(lastPos); - } - return str; + ++i2; } - return quickFormatUnescaped; - } - var browser$4; - var hasRequiredBrowser; - function requireBrowser() { - if (hasRequiredBrowser) - return browser$4; - hasRequiredBrowser = 1; - const format = requireQuickFormatUnescaped(); - browser$4 = pino; - const _console = pfGlobalThisOrFallback().console || {}; - const stdSerializers = { - mapHttpRequest: mock, - mapHttpResponse: mock, - wrapRequestSerializer: passthrough, - wrapResponseSerializer: passthrough, - wrapErrorSerializer: passthrough, - req: mock, - res: mock, - err: asErrValue - }; - function shouldSerialize(serialize, serializers) { - if (Array.isArray(serialize)) { - const hasToFilter = serialize.filter(function(k2) { - return k2 !== "!stdSerializers.err"; - }); - return hasToFilter; - } else if (serialize === true) { - return Object.keys(serializers); - } - return false; + if (lastPos === -1) + return f3; + else if (lastPos < flen) { + str += f3.slice(lastPos); } - function pino(opts) { - opts = opts || {}; - opts.browser = opts.browser || {}; - const transmit2 = opts.browser.transmit; - if (transmit2 && typeof transmit2.send !== "function") { - throw Error("pino: transmit option must have a send function"); - } - const proto = opts.browser.write || _console; - if (opts.browser.write) - opts.browser.asObject = true; - const serializers = opts.serializers || {}; - const serialize = shouldSerialize(opts.browser.serialize, serializers); - let stdErrSerialize = opts.browser.serialize; - if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) - stdErrSerialize = false; - const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; - if (typeof proto === "function") { - proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; - } - if (opts.enabled === false) - opts.level = "silent"; - const level = opts.level || "info"; - const logger = Object.create(proto); - if (!logger.log) - logger.log = noop2; - Object.defineProperty(logger, "levelVal", { - get: getLevelVal - }); - Object.defineProperty(logger, "level", { - get: getLevel, - set: setLevel + return str; + } + const format = quickFormatUnescaped; + var browser$4 = pino; + const _console = pfGlobalThisOrFallback().console || {}; + const stdSerializers = { + mapHttpRequest: mock, + mapHttpResponse: mock, + wrapRequestSerializer: passthrough, + wrapResponseSerializer: passthrough, + wrapErrorSerializer: passthrough, + req: mock, + res: mock, + err: asErrValue + }; + function shouldSerialize(serialize, serializers) { + if (Array.isArray(serialize)) { + const hasToFilter = serialize.filter(function(k2) { + return k2 !== "!stdSerializers.err"; }); - const setOpts = { - transmit: transmit2, - serialize, - asObject: opts.browser.asObject, - levels, - timestamp: getTimeFunction(opts) - }; - logger.levels = pino.levels; - logger.level = level; - logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop2; - logger.serializers = serializers; - logger._serialize = serialize; - logger._stdErrSerialize = stdErrSerialize; - logger.child = child; - if (transmit2) - logger._logEvent = createLogEventShape(); - function getLevelVal() { - return this.level === "silent" ? Infinity : this.levels.values[this.level]; - } - function getLevel() { - return this._level; - } - function setLevel(level2) { - if (level2 !== "silent" && !this.levels.values[level2]) { - throw Error("unknown level " + level2); - } - this._level = level2; - set2(setOpts, logger, "error", "log"); - set2(setOpts, logger, "fatal", "error"); - set2(setOpts, logger, "warn", "error"); - set2(setOpts, logger, "info", "log"); - set2(setOpts, logger, "debug", "log"); - set2(setOpts, logger, "trace", "log"); - } - function child(bindings, childOptions) { - if (!bindings) { - throw new Error("missing bindings for child Pino"); - } - childOptions = childOptions || {}; - if (serialize && bindings.serializers) { - childOptions.serializers = bindings.serializers; - } - const childOptionsSerializers = childOptions.serializers; - if (serialize && childOptionsSerializers) { - var childSerializers = Object.assign({}, serializers, childOptionsSerializers); - var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; - delete bindings.serializers; - applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); - } - function Child(parent) { - this._childLevel = (parent._childLevel | 0) + 1; - this.error = bind(parent, bindings, "error"); - this.fatal = bind(parent, bindings, "fatal"); - this.warn = bind(parent, bindings, "warn"); - this.info = bind(parent, bindings, "info"); - this.debug = bind(parent, bindings, "debug"); - this.trace = bind(parent, bindings, "trace"); - if (childSerializers) { - this.serializers = childSerializers; - this._serialize = childSerialize; - } - if (transmit2) { - this._logEvent = createLogEventShape( - [].concat(parent._logEvent.bindings, bindings) - ); - } - } - Child.prototype = this; - return new Child(this); - } - return logger; + return hasToFilter; + } else if (serialize === true) { + return Object.keys(serializers); } - pino.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" - } + return false; + } + function pino(opts) { + opts = opts || {}; + opts.browser = opts.browser || {}; + const transmit2 = opts.browser.transmit; + if (transmit2 && typeof transmit2.send !== "function") { + throw Error("pino: transmit option must have a send function"); + } + const proto = opts.browser.write || _console; + if (opts.browser.write) + opts.browser.asObject = true; + const serializers = opts.serializers || {}; + const serialize = shouldSerialize(opts.browser.serialize, serializers); + let stdErrSerialize = opts.browser.serialize; + if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) + stdErrSerialize = false; + const levels = ["error", "fatal", "warn", "info", "debug", "trace"]; + if (typeof proto === "function") { + proto.error = proto.fatal = proto.warn = proto.info = proto.debug = proto.trace = proto; + } + if (opts.enabled === false) + opts.level = "silent"; + const level = opts.level || "info"; + const logger = Object.create(proto); + if (!logger.log) + logger.log = noop$2; + Object.defineProperty(logger, "levelVal", { + get: getLevelVal + }); + Object.defineProperty(logger, "level", { + get: getLevel, + set: setLevel + }); + const setOpts = { + transmit: transmit2, + serialize, + asObject: opts.browser.asObject, + levels, + timestamp: getTimeFunction(opts) }; - pino.stdSerializers = stdSerializers; - pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); - function set2(opts, logger, level, fallback) { - const proto = Object.getPrototypeOf(logger); - logger[level] = logger.levelVal > logger.levels.values[level] ? noop2 : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop2; - wrap2(opts, logger, level); - } - function wrap2(opts, logger, level) { - if (!opts.transmit && logger[level] === noop2) - return; - logger[level] = /* @__PURE__ */ function(write) { - return function LOG() { - const ts2 = opts.timestamp(); - const args = new Array(arguments.length); - const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; - for (var i2 = 0; i2 < args.length; i2++) - args[i2] = arguments[i2]; - if (opts.serialize && !opts.asObject) { - applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); - } - if (opts.asObject) - write.call(proto, asObject(this, level, args, ts2)); - else - write.apply(proto, args); - if (opts.transmit) { - const transmitLevel = opts.transmit.level || logger.level; - const transmitValue = pino.levels.values[transmitLevel]; - const methodValue = pino.levels.values[level]; - if (methodValue < transmitValue) - return; - transmit(this, { - ts: ts2, - methodLevel: level, - methodValue, - transmitLevel, - transmitValue: pino.levels.values[opts.transmit.level || logger.level], - send: opts.transmit.send, - val: logger.levelVal - }, args); - } - }; - }(logger[level]); - } - function asObject(logger, level, args, ts2) { - if (logger._serialize) - applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); - const argsCloned = args.slice(); - let msg = argsCloned[0]; - const o22 = {}; - if (ts2) { - o22.time = ts2; - } - o22.level = pino.levels.values[level]; - let lvl = (logger._childLevel | 0) + 1; - if (lvl < 1) - lvl = 1; - if (msg !== null && typeof msg === "object") { - while (lvl-- && typeof argsCloned[0] === "object") { - Object.assign(o22, argsCloned.shift()); - } - msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; - } else if (typeof msg === "string") - msg = format(argsCloned.shift(), argsCloned); - if (msg !== void 0) - o22.msg = msg; - return o22; - } - function applySerializers(args, serialize, serializers, stdErrSerialize) { - for (const i2 in args) { - if (stdErrSerialize && args[i2] instanceof Error) { - args[i2] = pino.stdSerializers.err(args[i2]); - } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { - for (const k2 in args[i2]) { - if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { - args[i2][k2] = serializers[k2](args[i2][k2]); - } - } + logger.levels = pino.levels; + logger.level = level; + logger.setMaxListeners = logger.getMaxListeners = logger.emit = logger.addListener = logger.on = logger.prependListener = logger.once = logger.prependOnceListener = logger.removeListener = logger.removeAllListeners = logger.listeners = logger.listenerCount = logger.eventNames = logger.write = logger.flush = noop$2; + logger.serializers = serializers; + logger._serialize = serialize; + logger._stdErrSerialize = stdErrSerialize; + logger.child = child; + if (transmit2) + logger._logEvent = createLogEventShape(); + function getLevelVal() { + return this.level === "silent" ? Infinity : this.levels.values[this.level]; + } + function getLevel() { + return this._level; + } + function setLevel(level2) { + if (level2 !== "silent" && !this.levels.values[level2]) { + throw Error("unknown level " + level2); + } + this._level = level2; + set(setOpts, logger, "error", "log"); + set(setOpts, logger, "fatal", "error"); + set(setOpts, logger, "warn", "error"); + set(setOpts, logger, "info", "log"); + set(setOpts, logger, "debug", "log"); + set(setOpts, logger, "trace", "log"); + } + function child(bindings, childOptions) { + if (!bindings) { + throw new Error("missing bindings for child Pino"); + } + childOptions = childOptions || {}; + if (serialize && bindings.serializers) { + childOptions.serializers = bindings.serializers; + } + const childOptionsSerializers = childOptions.serializers; + if (serialize && childOptionsSerializers) { + var childSerializers = Object.assign({}, serializers, childOptionsSerializers); + var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize; + delete bindings.serializers; + applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize); + } + function Child(parent) { + this._childLevel = (parent._childLevel | 0) + 1; + this.error = bind(parent, bindings, "error"); + this.fatal = bind(parent, bindings, "fatal"); + this.warn = bind(parent, bindings, "warn"); + this.info = bind(parent, bindings, "info"); + this.debug = bind(parent, bindings, "debug"); + this.trace = bind(parent, bindings, "trace"); + if (childSerializers) { + this.serializers = childSerializers; + this._serialize = childSerialize; + } + if (transmit2) { + this._logEvent = createLogEventShape( + [].concat(parent._logEvent.bindings, bindings) + ); } } + Child.prototype = this; + return new Child(this); } - function bind(parent, bindings, level) { - return function() { - const args = new Array(1 + arguments.length); - args[0] = bindings; - for (var i2 = 1; i2 < args.length; i2++) { - args[i2] = arguments[i2 - 1]; + return logger; + } + pino.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" + } + }; + pino.stdSerializers = stdSerializers; + pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime }); + function set(opts, logger, level, fallback) { + const proto = Object.getPrototypeOf(logger); + logger[level] = logger.levelVal > logger.levels.values[level] ? noop$2 : proto[level] ? proto[level] : _console[level] || _console[fallback] || noop$2; + wrap$1(opts, logger, level); + } + function wrap$1(opts, logger, level) { + if (!opts.transmit && logger[level] === noop$2) + return; + logger[level] = /* @__PURE__ */ function(write) { + return function LOG() { + const ts3 = opts.timestamp(); + const args = new Array(arguments.length); + const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this; + for (var i2 = 0; i2 < args.length; i2++) + args[i2] = arguments[i2]; + if (opts.serialize && !opts.asObject) { + applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize); + } + if (opts.asObject) + write.call(proto, asObject(this, level, args, ts3)); + else + write.apply(proto, args); + if (opts.transmit) { + const transmitLevel = opts.transmit.level || logger.level; + const transmitValue = pino.levels.values[transmitLevel]; + const methodValue = pino.levels.values[level]; + if (methodValue < transmitValue) + return; + transmit(this, { + ts: ts3, + methodLevel: level, + methodValue, + transmitLevel, + transmitValue: pino.levels.values[opts.transmit.level || logger.level], + send: opts.transmit.send, + val: logger.levelVal + }, args); } - return parent[level].apply(this, args); - }; - } - function transmit(logger, opts, args) { - const send = opts.send; - const ts2 = opts.ts; - const methodLevel = opts.methodLevel; - const methodValue = opts.methodValue; - const val = opts.val; - const bindings = logger._logEvent.bindings; - applySerializers( - args, - logger._serialize || Object.keys(logger.serializers), - logger.serializers, - logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize - ); - logger._logEvent.ts = ts2; - logger._logEvent.messages = args.filter(function(arg) { - return bindings.indexOf(arg) === -1; - }); - logger._logEvent.level.label = methodLevel; - logger._logEvent.level.value = methodValue; - send(methodLevel, logger._logEvent, val); - logger._logEvent = createLogEventShape(bindings); - } - function createLogEventShape(bindings) { - return { - ts: 0, - messages: [], - bindings: bindings || [], - level: { label: "", value: 0 } - }; - } - function asErrValue(err) { - const obj = { - type: err.constructor.name, - msg: err.message, - stack: err.stack }; - for (const key in err) { - if (obj[key] === void 0) { - obj[key] = err[key]; + }(logger[level]); + } + function asObject(logger, level, args, ts3) { + if (logger._serialize) + applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize); + const argsCloned = args.slice(); + let msg = argsCloned[0]; + const o22 = {}; + if (ts3) { + o22.time = ts3; + } + o22.level = pino.levels.values[level]; + let lvl = (logger._childLevel | 0) + 1; + if (lvl < 1) + lvl = 1; + if (msg !== null && typeof msg === "object") { + while (lvl-- && typeof argsCloned[0] === "object") { + Object.assign(o22, argsCloned.shift()); + } + msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0; + } else if (typeof msg === "string") + msg = format(argsCloned.shift(), argsCloned); + if (msg !== void 0) + o22.msg = msg; + return o22; + } + function applySerializers(args, serialize, serializers, stdErrSerialize) { + for (const i2 in args) { + if (stdErrSerialize && args[i2] instanceof Error) { + args[i2] = pino.stdSerializers.err(args[i2]); + } else if (typeof args[i2] === "object" && !Array.isArray(args[i2])) { + for (const k2 in args[i2]) { + if (serialize && serialize.indexOf(k2) > -1 && k2 in serializers) { + args[i2][k2] = serializers[k2](args[i2][k2]); + } } } - return obj; } - function getTimeFunction(opts) { - if (typeof opts.timestamp === "function") { - return opts.timestamp; + } + function bind(parent, bindings, level) { + return function() { + const args = new Array(1 + arguments.length); + args[0] = bindings; + for (var i2 = 1; i2 < args.length; i2++) { + args[i2] = arguments[i2 - 1]; } - if (opts.timestamp === false) { - return nullTime; + return parent[level].apply(this, args); + }; + } + function transmit(logger, opts, args) { + const send = opts.send; + const ts3 = opts.ts; + const methodLevel = opts.methodLevel; + const methodValue = opts.methodValue; + const val = opts.val; + const bindings = logger._logEvent.bindings; + applySerializers( + args, + logger._serialize || Object.keys(logger.serializers), + logger.serializers, + logger._stdErrSerialize === void 0 ? true : logger._stdErrSerialize + ); + logger._logEvent.ts = ts3; + logger._logEvent.messages = args.filter(function(arg) { + return bindings.indexOf(arg) === -1; + }); + logger._logEvent.level.label = methodLevel; + logger._logEvent.level.value = methodValue; + send(methodLevel, logger._logEvent, val); + logger._logEvent = createLogEventShape(bindings); + } + function createLogEventShape(bindings) { + return { + ts: 0, + messages: [], + bindings: bindings || [], + level: { label: "", value: 0 } + }; + } + function asErrValue(err) { + const obj = { + type: err.constructor.name, + msg: err.message, + stack: err.stack + }; + for (const key in err) { + if (obj[key] === void 0) { + obj[key] = err[key]; } - return epochTime; - } - function mock() { - return {}; } - function passthrough(a3) { - return a3; + return obj; + } + function getTimeFunction(opts) { + if (typeof opts.timestamp === "function") { + return opts.timestamp; } - function noop2() { + if (opts.timestamp === false) { + return nullTime; } - function nullTime() { - return false; + return epochTime; + } + function mock() { + return {}; + } + function passthrough(a3) { + return a3; + } + function noop$2() { + } + function nullTime() { + return false; + } + function epochTime() { + return Date.now(); + } + function unixTime() { + return Math.round(Date.now() / 1e3); + } + function isoTime() { + return new Date(Date.now()).toISOString(); + } + function pfGlobalThisOrFallback() { + function defd(o22) { + return typeof o22 !== "undefined" && o22; } - function epochTime() { - return Date.now(); + try { + if (typeof globalThis !== "undefined") + return globalThis; + Object.defineProperty(Object.prototype, "globalThis", { + get: function() { + delete Object.prototype.globalThis; + return this.globalThis = this; + }, + configurable: true + }); + return globalThis; + } catch (e2) { + return defd(self) || defd(window) || defd(this) || {}; } - function unixTime() { - return Math.round(Date.now() / 1e3); + } + const nt$1 = /* @__PURE__ */ getDefaultExportFromCjs(browser$4); + const c$1$1 = { level: "info" }, n$3$1 = "custom_context", l$4 = 1e3 * 1024; + let O$1 = class O { + constructor(e2) { + this.nodeValue = e2, this.sizeInBytes = new TextEncoder().encode(this.nodeValue).length, this.next = null; } - function isoTime() { - return new Date(Date.now()).toISOString(); + get value() { + return this.nodeValue; } - function pfGlobalThisOrFallback() { - function defd(o22) { - return typeof o22 !== "undefined" && o22; - } - try { - if (typeof globalThis !== "undefined") - return globalThis; - Object.defineProperty(Object.prototype, "globalThis", { - get: function() { - delete Object.prototype.globalThis; - return this.globalThis = this; - }, - configurable: true - }); - return globalThis; - } catch (e2) { - return defd(self) || defd(window) || defd(this) || {}; - } + get size() { + return this.sizeInBytes; } - return browser$4; - } - var constants = {}; - var hasRequiredConstants; - function requireConstants() { - if (hasRequiredConstants) - return constants; - hasRequiredConstants = 1; - Object.defineProperty(constants, "__esModule", { value: true }); - constants.PINO_CUSTOM_CONTEXT_KEY = constants.PINO_LOGGER_DEFAULTS = void 0; - constants.PINO_LOGGER_DEFAULTS = { - level: "info" - }; - constants.PINO_CUSTOM_CONTEXT_KEY = "custom_context"; - return constants; - } - var utils$2 = {}; - var hasRequiredUtils; - function requireUtils() { - if (hasRequiredUtils) - return utils$2; - hasRequiredUtils = 1; - Object.defineProperty(utils$2, "__esModule", { value: true }); - utils$2.generateChildLogger = utils$2.formatChildLoggerContext = utils$2.getLoggerContext = utils$2.setBrowserLoggerContext = utils$2.getBrowserLoggerContext = utils$2.getDefaultLoggerOptions = void 0; - const constants_1 = requireConstants(); - function getDefaultLoggerOptions(opts) { - return Object.assign(Object.assign({}, opts), { level: (opts === null || opts === void 0 ? void 0 : opts.level) || constants_1.PINO_LOGGER_DEFAULTS.level }); - } - utils$2.getDefaultLoggerOptions = getDefaultLoggerOptions; - function getBrowserLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - return logger[customContextKey] || ""; - } - utils$2.getBrowserLoggerContext = getBrowserLoggerContext; - function setBrowserLoggerContext(logger, context, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - logger[customContextKey] = context; - return logger; - } - utils$2.setBrowserLoggerContext = setBrowserLoggerContext; - function getLoggerContext(logger, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - let context = ""; - if (typeof logger.bindings === "undefined") { - context = getBrowserLoggerContext(logger, customContextKey); - } else { - context = logger.bindings().context || ""; - } - return context; + }; + let d$2 = class d2 { + constructor(e2) { + this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e2, this.sizeInBytes = 0; + } + append(e2) { + const t2 = new O$1(e2); + if (t2.size > this.maxSizeInBytes) + throw new Error(`[LinkedList] Value too big to insert into list: ${e2} with size ${t2.size}`); + for (; this.size + t2.size > this.maxSizeInBytes; ) + this.shift(); + this.head ? (this.tail && (this.tail.next = t2), this.tail = t2) : (this.head = t2, this.tail = t2), this.lengthInNodes++, this.sizeInBytes += t2.size; + } + shift() { + if (!this.head) + return; + const e2 = this.head; + this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e2.size; } - utils$2.getLoggerContext = getLoggerContext; - function formatChildLoggerContext(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const parentContext = getLoggerContext(logger, customContextKey); - const context = parentContext.trim() ? `${parentContext}/${childContext}` : childContext; - return context; + toArray() { + const e2 = []; + let t2 = this.head; + for (; t2 !== null; ) + e2.push(t2.value), t2 = t2.next; + return e2; } - utils$2.formatChildLoggerContext = formatChildLoggerContext; - function generateChildLogger(logger, childContext, customContextKey = constants_1.PINO_CUSTOM_CONTEXT_KEY) { - const context = formatChildLoggerContext(logger, childContext, customContextKey); - const child = logger.child({ context }); - return setBrowserLoggerContext(child, context, customContextKey); + get length() { + return this.lengthInNodes; } - utils$2.generateChildLogger = generateChildLogger; - return utils$2; + get size() { + return this.sizeInBytes; + } + toOrderedArray() { + return Array.from(this); + } + [Symbol.iterator]() { + let e2 = this.head; + return { next: () => { + if (!e2) + return { done: true, value: null }; + const t2 = e2.value; + return e2 = e2.next, { done: false, value: t2 }; + } }; + } + }; + let L$4 = class L { + constructor(e2, t2 = l$4) { + this.level = e2 ?? "error", this.levelValue = browser$4.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = t2, this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); + } + forwardToConsole(e2, t2) { + t2 === browser$4.levels.values.error ? console.error(e2) : t2 === browser$4.levels.values.warn ? console.warn(e2) : t2 === browser$4.levels.values.debug ? console.debug(e2) : t2 === browser$4.levels.values.trace ? console.trace(e2) : console.log(e2); + } + appendToLogs(e2) { + this.logs.append(safeJsonStringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: e2 })); + const t2 = typeof e2 == "string" ? JSON.parse(e2).level : e2.level; + t2 >= this.levelValue && this.forwardToConsole(e2, t2); + } + getLogs() { + return this.logs; + } + clearLogs() { + this.logs = new d$2(this.MAX_LOG_SIZE_IN_BYTES); + } + getLogArray() { + return Array.from(this.logs); + } + logsToBlob(e2) { + const t2 = this.getLogArray(); + return t2.push(safeJsonStringify({ extraMetadata: e2 })), new Blob(t2, { type: "application/json" }); + } + }; + let m$1 = class m { + constructor(e2, t2 = l$4) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } + downloadLogsBlobInBrowser(e2) { + const t2 = URL.createObjectURL(this.logsToBlob(e2)), o22 = document.createElement("a"); + o22.href = t2, o22.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(o22), o22.click(), document.body.removeChild(o22), URL.revokeObjectURL(t2); + } + }; + let B$2 = class B { + constructor(e2, t2 = l$4) { + this.baseChunkLogger = new L$4(e2, t2); + } + write(e2) { + this.baseChunkLogger.appendToLogs(e2); + } + getLogs() { + return this.baseChunkLogger.getLogs(); + } + clearLogs() { + this.baseChunkLogger.clearLogs(); + } + getLogArray() { + return this.baseChunkLogger.getLogArray(); + } + logsToBlob(e2) { + return this.baseChunkLogger.logsToBlob(e2); + } + }; + var x$2 = Object.defineProperty, S$3 = Object.defineProperties, _2 = Object.getOwnPropertyDescriptors, p$1 = Object.getOwnPropertySymbols, T$1 = Object.prototype.hasOwnProperty, z$2 = Object.prototype.propertyIsEnumerable, f$3 = (r3, e2, t2) => e2 in r3 ? x$2(r3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : r3[e2] = t2, i$4 = (r3, e2) => { + for (var t2 in e2 || (e2 = {})) + T$1.call(e2, t2) && f$3(r3, t2, e2[t2]); + if (p$1) + for (var t2 of p$1(e2)) + z$2.call(e2, t2) && f$3(r3, t2, e2[t2]); + return r3; + }, g$2 = (r3, e2) => S$3(r3, _2(e2)); + function k$2(r3) { + return g$2(i$4({}, r3), { level: (r3 == null ? void 0 : r3.level) || c$1$1.level }); + } + function v$2(r3, e2 = n$3$1) { + return r3[e2] || ""; + } + function b$2(r3, e2, t2 = n$3$1) { + return r3[t2] = e2, r3; + } + function y$2(r3, e2 = n$3$1) { + let t2 = ""; + return typeof r3.bindings > "u" ? t2 = v$2(r3, e2) : t2 = r3.bindings().context || "", t2; + } + function w$3(r3, e2, t2 = n$3$1) { + const o22 = y$2(r3, t2); + return o22.trim() ? `${o22}/${e2}` : e2; + } + function E$1(r3, e2, t2 = n$3$1) { + const o22 = w$3(r3, e2, t2), a3 = r3.child({ context: o22 }); + return b$2(a3, o22, t2); + } + function C$2(r3) { + var e2, t2; + const o22 = new m$1((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i$4({}, r3.opts), { level: "trace", browser: g$2(i$4({}, (t2 = r3.opts) == null ? void 0 : t2.browser), { write: (a3) => o22.write(a3) }) })), chunkLoggerController: o22 }; + } + function I$2(r3) { + var e2; + const t2 = new B$2((e2 = r3.opts) == null ? void 0 : e2.level, r3.maxSizeInBytes); + return { logger: nt$1(g$2(i$4({}, r3.opts), { level: "trace" }), t2), chunkLoggerController: t2 }; } - (function(exports22) { - Object.defineProperty(exports22, "__esModule", { value: true }); - exports22.pino = void 0; - const tslib_1 = require$$0$2; - const pino_1 = tslib_1.__importDefault(requireBrowser()); - Object.defineProperty(exports22, "pino", { enumerable: true, get: function() { - return pino_1.default; - } }); - tslib_1.__exportStar(requireConstants(), exports22); - tslib_1.__exportStar(requireUtils(), exports22); - })(cjs$3); - let n$1$1 = class n extends IEvents$1 { - constructor(s2) { - super(), this.opts = s2, this.protocol = "wc", this.version = 2; + function A$2(r3) { + return typeof r3.loggerOverride < "u" && typeof r3.loggerOverride != "string" ? { logger: r3.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? C$2(r3) : I$2(r3); + } + let n$2$1 = class n extends IEvents { + constructor(s22) { + super(), this.opts = s22, this.protocol = "wc", this.version = 2; } }; - let h$2$1 = class h2 extends IEvents$1 { - constructor(s2, t2) { - super(), this.core = s2, this.logger = t2, this.records = /* @__PURE__ */ new Map(); + let h$1$1 = class h2 extends IEvents { + constructor(s22, t2) { + super(), this.core = s22, this.logger = t2, this.records = /* @__PURE__ */ new Map(); } }; - let a$2 = class a { - constructor(s2, t2) { - this.logger = s2, this.core = t2; + let a$1$1 = class a { + constructor(s22, t2) { + this.logger = s22, this.core = t2; } }; - let u$1$1 = class u extends IEvents$1 { - constructor(s2, t2) { - super(), this.relayer = s2, this.logger = t2; + let u$1$1 = class u extends IEvents { + constructor(s22, t2) { + super(), this.relayer = s22, this.logger = t2; } }; - let g$4 = class g extends IEvents$1 { - constructor(s2) { + let g$1 = class g extends IEvents { + constructor(s22) { super(); } }; - let p$2 = class p { - constructor(s2, t2, o22, M2) { - this.core = s2, this.logger = t2, this.name = o22; + let p$3 = class p { + constructor(s22, t2, o22, M2) { + this.core = s22, this.logger = t2, this.name = o22; } }; - class d2 extends IEvents$1 { - constructor(s2, t2) { - super(), this.relayer = s2, this.logger = t2; + let d$1$1 = class d3 extends IEvents { + constructor(s22, t2) { + super(), this.relayer = s22, this.logger = t2; } - } - let E$3 = class E extends IEvents$1 { - constructor(s2, t2) { - super(), this.core = s2, this.logger = t2; + }; + let E$4 = class E extends IEvents { + constructor(s22, t2) { + super(), this.core = s22, this.logger = t2; } }; let y$1 = class y { - constructor(s2, t2) { - this.projectId = s2, this.logger = t2; + constructor(s22, t2) { + this.projectId = s22, this.logger = t2; } }; - let v$1$1 = class v { - constructor(s2, t2) { - this.projectId = s2, this.logger = t2; + let v$1 = class v { + constructor(s22, t2) { + this.projectId = s22, this.logger = t2; } }; - let b$1 = class b { - constructor(s2) { - this.opts = s2, this.protocol = "wc", this.version = 2; + let b$1$1 = class b { + constructor(s22) { + this.opts = s22, this.protocol = "wc", this.version = 2; } }; - let w$4 = class w { - constructor(s2) { - this.client = s2; + let w$2 = class w { + constructor(s22) { + this.client = s22; } }; var ed25519 = {}; @@ -3257,9 +3186,9 @@ (function(exports22) { Object.defineProperty(exports22, "__esModule", { value: true }); function imulShim(a3, b3) { - var ah = a3 >>> 16 & 65535, al = a3 & 65535; + var ah2 = a3 >>> 16 & 65535, al = a3 & 65535; var bh = b3 >>> 16 & 65535, bl = b3 & 65535; - return al * bl + (ah * bl + al * bh << 16 >>> 0) | 0; + return al * bl + (ah2 * bl + al * bh << 16 >>> 0) | 0; } exports22.mul = Math.imul || imulShim; function add(a3, b3) { @@ -3270,21 +3199,21 @@ return a3 - b3 | 0; } exports22.sub = sub; - function rotl(x2, n3) { - return x2 << n3 | x2 >>> 32 - n3; + function rotl(x2, n4) { + return x2 << n4 | x2 >>> 32 - n4; } exports22.rotl = rotl; - function rotr(x2, n3) { - return x2 << 32 - n3 | x2 >>> n3; + function rotr(x2, n4) { + return x2 << 32 - n4 | x2 >>> n4; } exports22.rotr = rotr; - function isIntegerShim(n3) { - return typeof n3 === "number" && isFinite(n3) && Math.floor(n3) === n3; + function isIntegerShim(n4) { + return typeof n4 === "number" && isFinite(n4) && Math.floor(n4) === n4; } exports22.isInteger = Number.isInteger || isIntegerShim; exports22.MAX_SAFE_INTEGER = 9007199254740991; - exports22.isSafeInteger = function(n3) { - return exports22.isInteger(n3) && (n3 >= -exports22.MAX_SAFE_INTEGER && n3 <= exports22.MAX_SAFE_INTEGER); + exports22.isSafeInteger = function(n4) { + return exports22.isInteger(n4) && (n4 >= -exports22.MAX_SAFE_INTEGER && n4 <= exports22.MAX_SAFE_INTEGER); }; })(int); Object.defineProperty(binary, "__esModule", { value: true }); @@ -3818,7 +3747,7 @@ }() ); exports22.SHA512 = SHA512; - var K2 = new Int32Array([ + var K3 = new Int32Array([ 1116352408, 3609767458, 1899447441, @@ -3980,16 +3909,16 @@ 1816402316, 1246189591 ]); - function hashBlocks(wh, wl, hh, hl, m2, pos, len) { - var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; + function hashBlocks(wh, wl, hh2, hl, m3, pos, len) { + var ah0 = hh2[0], ah1 = hh2[1], ah2 = hh2[2], ah3 = hh2[3], ah4 = hh2[4], ah5 = hh2[5], ah6 = hh2[6], ah7 = hh2[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7]; var h4, l2; - var th, tl; - var a3, b3, c2, d3; + var th2, tl; + var a3, b3, c2, d5; while (len >= 128) { for (var i2 = 0; i2 < 16; i2++) { var j2 = 8 * i2 + pos; - wh[i2] = binary_12.readUint32BE(m2, j2); - wl[i2] = binary_12.readUint32BE(m2, j2 + 4); + wh[i2] = binary_12.readUint32BE(m3, j2); + wl[i2] = binary_12.readUint32BE(m3, j2 + 4); } for (var i2 = 0; i2 < 80; i2++) { var bh0 = ah0; @@ -4013,75 +3942,75 @@ a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32)); l2 = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32)); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = ah4 & ah5 ^ ~ah4 & ah6; l2 = al4 & al5 ^ ~al4 & al6; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - h4 = K2[i2 * 2]; - l2 = K2[i2 * 2 + 1]; + d5 += h4 >>> 16; + h4 = K3[i2 * 2]; + l2 = K3[i2 * 2 + 1]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = wh[i2 % 16]; l2 = wl[i2 % 16]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - th = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + th2 = c2 & 65535 | d5 << 16; tl = a3 & 65535 | b3 << 16; - h4 = th; + h4 = th2; l2 = tl; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32)); l2 = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32)); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; h4 = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2; l2 = al0 & al1 ^ al0 & al2 ^ al1 & al2; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh7 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + bh7 = c2 & 65535 | d5 << 16; bl7 = a3 & 65535 | b3 << 16; h4 = bh3; l2 = bl3; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = th; + d5 = h4 >>> 16; + h4 = th2; l2 = tl; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - bh3 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + bh3 = c2 & 65535 | d5 << 16; bl3 = a3 & 65535 | b3 << 16; ah1 = bh0; ah2 = bh1; @@ -4106,33 +4035,33 @@ a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; + d5 = h4 >>> 16; h4 = wh[(j2 + 9) % 16]; l2 = wl[(j2 + 9) % 16]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 1) % 16]; + d5 += h4 >>> 16; + th2 = wh[(j2 + 1) % 16]; tl = wl[(j2 + 1) % 16]; - h4 = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7; - l2 = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7); + h4 = (th2 >>> 1 | tl << 32 - 1) ^ (th2 >>> 8 | tl << 32 - 8) ^ th2 >>> 7; + l2 = (tl >>> 1 | th2 << 32 - 1) ^ (tl >>> 8 | th2 << 32 - 8) ^ (tl >>> 7 | th2 << 32 - 7); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; - th = wh[(j2 + 14) % 16]; + d5 += h4 >>> 16; + th2 = wh[(j2 + 14) % 16]; tl = wl[(j2 + 14) % 16]; - h4 = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6; - l2 = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6); + h4 = (th2 >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th2 << 32 - (61 - 32)) ^ th2 >>> 6; + l2 = (tl >>> 19 | th2 << 32 - 19) ^ (th2 >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th2 << 32 - 6); a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - wh[j2] = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + wh[j2] = c2 & 65535 | d5 << 16; wl[j2] = a3 & 65535 | b3 << 16; } } @@ -4142,136 +4071,136 @@ a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[0]; + d5 = h4 >>> 16; + h4 = hh2[0]; l2 = hl[0]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[0] = ah0 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[0] = ah0 = c2 & 65535 | d5 << 16; hl[0] = al0 = a3 & 65535 | b3 << 16; h4 = ah1; l2 = al1; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[1]; + d5 = h4 >>> 16; + h4 = hh2[1]; l2 = hl[1]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[1] = ah1 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[1] = ah1 = c2 & 65535 | d5 << 16; hl[1] = al1 = a3 & 65535 | b3 << 16; h4 = ah2; l2 = al2; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[2]; + d5 = h4 >>> 16; + h4 = hh2[2]; l2 = hl[2]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[2] = ah2 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[2] = ah2 = c2 & 65535 | d5 << 16; hl[2] = al2 = a3 & 65535 | b3 << 16; h4 = ah3; l2 = al3; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[3]; + d5 = h4 >>> 16; + h4 = hh2[3]; l2 = hl[3]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[3] = ah3 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[3] = ah3 = c2 & 65535 | d5 << 16; hl[3] = al3 = a3 & 65535 | b3 << 16; h4 = ah4; l2 = al4; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[4]; + d5 = h4 >>> 16; + h4 = hh2[4]; l2 = hl[4]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[4] = ah4 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[4] = ah4 = c2 & 65535 | d5 << 16; hl[4] = al4 = a3 & 65535 | b3 << 16; h4 = ah5; l2 = al5; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[5]; + d5 = h4 >>> 16; + h4 = hh2[5]; l2 = hl[5]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[5] = ah5 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[5] = ah5 = c2 & 65535 | d5 << 16; hl[5] = al5 = a3 & 65535 | b3 << 16; h4 = ah6; l2 = al6; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[6]; + d5 = h4 >>> 16; + h4 = hh2[6]; l2 = hl[6]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[6] = ah6 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[6] = ah6 = c2 & 65535 | d5 << 16; hl[6] = al6 = a3 & 65535 | b3 << 16; h4 = ah7; l2 = al7; a3 = l2 & 65535; b3 = l2 >>> 16; c2 = h4 & 65535; - d3 = h4 >>> 16; - h4 = hh[7]; + d5 = h4 >>> 16; + h4 = hh2[7]; l2 = hl[7]; a3 += l2 & 65535; b3 += l2 >>> 16; c2 += h4 & 65535; - d3 += h4 >>> 16; + d5 += h4 >>> 16; b3 += a3 >>> 16; c2 += b3 >>> 16; - d3 += c2 >>> 16; - hh[7] = ah7 = c2 & 65535 | d3 << 16; + d5 += c2 >>> 16; + hh2[7] = ah7 = c2 & 65535 | d5 << 16; hl[7] = al7 = a3 & 65535 | b3 << 16; pos += 128; len -= 128; @@ -4297,20 +4226,20 @@ exports22.PUBLIC_KEY_LENGTH = 32; exports22.SECRET_KEY_LENGTH = 64; exports22.SEED_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); + function gf2(init) { + const r3 = new Float64Array(16); if (init) { for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; + r3[i2] = init[i2]; } } - return r2; + return r3; } const _9 = new Uint8Array(32); _9[0] = 9; - const gf0 = gf(); - const gf1 = gf([1]); - const D2 = gf([ + const gf0 = gf2(); + const gf1 = gf2([1]); + const D2 = gf2([ 30883, 4953, 19914, @@ -4328,7 +4257,7 @@ 27886, 20995 ]); - const D22 = gf([ + const D22 = gf2([ 61785, 9906, 39828, @@ -4346,7 +4275,7 @@ 55772, 9222 ]); - const X2 = gf([ + const X2 = gf2([ 54554, 36645, 11616, @@ -4364,7 +4293,7 @@ 14035, 8553 ]); - const Y2 = gf([ + const Y2 = gf2([ 26200, 26214, 26214, @@ -4382,7 +4311,7 @@ 26214, 26214 ]); - const I2 = gf([ + const I2 = gf2([ 41136, 18958, 6951, @@ -4400,9 +4329,9 @@ 9344, 11139 ]); - function set25519(r2, a3) { + function set25519(r3, a3) { for (let i2 = 0; i2 < 16; i2++) { - r2[i2] = a3[i2] | 0; + r3[i2] = a3[i2] | 0; } } function car25519(o22) { @@ -4414,33 +4343,33 @@ } o22[0] += c2 - 1 + 37 * (c2 - 1); } - function sel25519(p3, q2, b3) { + function sel25519(p2, q2, b3) { const c2 = ~(b3 - 1); for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; q2[i2] ^= t2; } } - function pack25519(o22, n3) { - const m2 = gf(); - const t2 = gf(); + function pack25519(o22, n4) { + const m3 = gf2(); + const t2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; + t2[i2] = n4[i2]; } car25519(t2); car25519(t2); car25519(t2); for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; + m3[0] = t2[0] - 65517; for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); } for (let i2 = 0; i2 < 16; i2++) { o22[2 * i2] = t2[i2] & 255; @@ -4448,27 +4377,27 @@ } } function verify32(x2, y3) { - let d3 = 0; + let d5 = 0; for (let i2 = 0; i2 < 32; i2++) { - d3 |= x2[i2] ^ y3[i2]; + d5 |= x2[i2] ^ y3[i2]; } - return (1 & d3 - 1 >>> 8) - 1; + return (1 & d5 - 1 >>> 8) - 1; } function neq25519(a3, b3) { const c2 = new Uint8Array(32); - const d3 = new Uint8Array(32); + const d5 = new Uint8Array(32); pack25519(c2, a3); - pack25519(d3, b3); - return verify32(c2, d3); + pack25519(d5, b3); + return verify32(c2, d5); } function par25519(a3) { - const d3 = new Uint8Array(32); - pack25519(d3, a3); - return d3[0] & 1; + const d5 = new Uint8Array(32); + pack25519(d5, a3); + return d5[0] & 1; } - function unpack25519(o22, n3) { + function unpack25519(o22, n4) { for (let i2 = 0; i2 < 16; i2++) { - o22[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); + o22[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); } o22[15] &= 32767; } @@ -4483,9 +4412,9 @@ } } function mul(o22, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; v3 = a3[0]; - t0 += v3 * b0; + t0 += v3 * b02; t1 += v3 * b1; t2 += v3 * b22; t3 += v3 * b32; @@ -4502,7 +4431,7 @@ t14 += v3 * b14; t15 += v3 * b15; v3 = a3[1]; - t1 += v3 * b0; + t1 += v3 * b02; t2 += v3 * b1; t3 += v3 * b22; t4 += v3 * b32; @@ -4519,7 +4448,7 @@ t15 += v3 * b14; t16 += v3 * b15; v3 = a3[2]; - t2 += v3 * b0; + t2 += v3 * b02; t3 += v3 * b1; t4 += v3 * b22; t5 += v3 * b32; @@ -4536,7 +4465,7 @@ t16 += v3 * b14; t17 += v3 * b15; v3 = a3[3]; - t3 += v3 * b0; + t3 += v3 * b02; t4 += v3 * b1; t5 += v3 * b22; t6 += v3 * b32; @@ -4553,7 +4482,7 @@ t17 += v3 * b14; t18 += v3 * b15; v3 = a3[4]; - t4 += v3 * b0; + t4 += v3 * b02; t5 += v3 * b1; t6 += v3 * b22; t7 += v3 * b32; @@ -4570,7 +4499,7 @@ t18 += v3 * b14; t19 += v3 * b15; v3 = a3[5]; - t5 += v3 * b0; + t5 += v3 * b02; t6 += v3 * b1; t7 += v3 * b22; t8 += v3 * b32; @@ -4587,7 +4516,7 @@ t19 += v3 * b14; t20 += v3 * b15; v3 = a3[6]; - t6 += v3 * b0; + t6 += v3 * b02; t7 += v3 * b1; t8 += v3 * b22; t9 += v3 * b32; @@ -4604,7 +4533,7 @@ t20 += v3 * b14; t21 += v3 * b15; v3 = a3[7]; - t7 += v3 * b0; + t7 += v3 * b02; t8 += v3 * b1; t9 += v3 * b22; t10 += v3 * b32; @@ -4621,7 +4550,7 @@ t21 += v3 * b14; t22 += v3 * b15; v3 = a3[8]; - t8 += v3 * b0; + t8 += v3 * b02; t9 += v3 * b1; t10 += v3 * b22; t11 += v3 * b32; @@ -4638,7 +4567,7 @@ t22 += v3 * b14; t23 += v3 * b15; v3 = a3[9]; - t9 += v3 * b0; + t9 += v3 * b02; t10 += v3 * b1; t11 += v3 * b22; t12 += v3 * b32; @@ -4655,7 +4584,7 @@ t23 += v3 * b14; t24 += v3 * b15; v3 = a3[10]; - t10 += v3 * b0; + t10 += v3 * b02; t11 += v3 * b1; t12 += v3 * b22; t13 += v3 * b32; @@ -4672,7 +4601,7 @@ t24 += v3 * b14; t25 += v3 * b15; v3 = a3[11]; - t11 += v3 * b0; + t11 += v3 * b02; t12 += v3 * b1; t13 += v3 * b22; t14 += v3 * b32; @@ -4689,7 +4618,7 @@ t25 += v3 * b14; t26 += v3 * b15; v3 = a3[12]; - t12 += v3 * b0; + t12 += v3 * b02; t13 += v3 * b1; t14 += v3 * b22; t15 += v3 * b32; @@ -4706,7 +4635,7 @@ t26 += v3 * b14; t27 += v3 * b15; v3 = a3[13]; - t13 += v3 * b0; + t13 += v3 * b02; t14 += v3 * b1; t15 += v3 * b22; t16 += v3 * b32; @@ -4723,7 +4652,7 @@ t27 += v3 * b14; t28 += v3 * b15; v3 = a3[14]; - t14 += v3 * b0; + t14 += v3 * b02; t15 += v3 * b1; t16 += v3 * b22; t17 += v3 * b32; @@ -4740,7 +4669,7 @@ t28 += v3 * b14; t29 += v3 * b15; v3 = a3[15]; - t15 += v3 * b0; + t15 += v3 * b02; t16 += v3 * b1; t17 += v3 * b22; t18 += v3 * b32; @@ -4892,7 +4821,7 @@ mul(o22, a3, a3); } function inv25519(o22, i2) { - const c2 = gf(); + const c2 = gf2(); let a3; for (a3 = 0; a3 < 16; a3++) { c2[a3] = i2[a3]; @@ -4908,7 +4837,7 @@ } } function pow2523(o22, i2) { - const c2 = gf(); + const c2 = gf2(); let a3; for (a3 = 0; a3 < 16; a3++) { c2[a3] = i2[a3]; @@ -4923,73 +4852,73 @@ o22[a3] = c2[a3]; } } - function edadd(p3, q2) { - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e2 = gf(), f2 = gf(), g3 = gf(), h4 = gf(), t2 = gf(); - sub(a3, p3[1], p3[0]); + function edadd(p2, q2) { + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(), g3 = gf2(), h4 = gf2(), t2 = gf2(); + sub(a3, p2[1], p2[0]); sub(t2, q2[1], q2[0]); mul(a3, a3, t2); - add(b3, p3[0], p3[1]); + add(b3, p2[0], p2[1]); add(t2, q2[0], q2[1]); mul(b3, b3, t2); - mul(c2, p3[3], q2[3]); + mul(c2, p2[3], q2[3]); mul(c2, c2, D22); - mul(d3, p3[2], q2[2]); - add(d3, d3, d3); + mul(d5, p2[2], q2[2]); + add(d5, d5, d5); sub(e2, b3, a3); - sub(f2, d3, c2); - add(g3, d3, c2); + sub(f3, d5, c2); + add(g3, d5, c2); add(h4, b3, a3); - mul(p3[0], e2, f2); - mul(p3[1], h4, g3); - mul(p3[2], g3, f2); - mul(p3[3], e2, h4); + mul(p2[0], e2, f3); + mul(p2[1], h4, g3); + mul(p2[2], g3, f3); + mul(p2[3], e2, h4); } - function cswap(p3, q2, b3) { + function cswap(p2, q2, b3) { for (let i2 = 0; i2 < 4; i2++) { - sel25519(p3[i2], q2[i2], b3); - } - } - function pack(r2, p3) { - const tx = gf(), ty = gf(), zi = gf(); - inv25519(zi, p3[2]); - mul(tx, p3[0], zi); - mul(ty, p3[1], zi); - pack25519(r2, ty); - r2[31] ^= par25519(tx) << 7; - } - function scalarmult(p3, q2, s2) { - set25519(p3[0], gf0); - set25519(p3[1], gf1); - set25519(p3[2], gf1); - set25519(p3[3], gf0); + sel25519(p2[i2], q2[i2], b3); + } + } + function pack(r3, p2) { + const tx = gf2(), ty = gf2(), zi2 = gf2(); + inv25519(zi2, p2[2]); + mul(tx, p2[0], zi2); + mul(ty, p2[1], zi2); + pack25519(r3, ty); + r3[31] ^= par25519(tx) << 7; + } + function scalarmult(p2, q2, s22) { + set25519(p2[0], gf0); + set25519(p2[1], gf1); + set25519(p2[2], gf1); + set25519(p2[3], gf0); for (let i2 = 255; i2 >= 0; --i2) { - const b3 = s2[i2 / 8 | 0] >> (i2 & 7) & 1; - cswap(p3, q2, b3); - edadd(q2, p3); - edadd(p3, p3); - cswap(p3, q2, b3); + const b3 = s22[i2 / 8 | 0] >> (i2 & 7) & 1; + cswap(p2, q2, b3); + edadd(q2, p2); + edadd(p2, p2); + cswap(p2, q2, b3); } } - function scalarbase(p3, s2) { - const q2 = [gf(), gf(), gf(), gf()]; + function scalarbase(p2, s22) { + const q2 = [gf2(), gf2(), gf2(), gf2()]; set25519(q2[0], X2); set25519(q2[1], Y2); set25519(q2[2], gf1); mul(q2[3], X2, Y2); - scalarmult(p3, q2, s2); + scalarmult(p2, q2, s22); } function generateKeyPairFromSeed(seed) { if (seed.length !== exports22.SEED_LENGTH) { throw new Error(`ed25519: seed must be ${exports22.SEED_LENGTH} bytes`); } - const d3 = (0, sha512_1.hash)(seed); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; + const d5 = (0, sha512_1.hash)(seed); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; const publicKey = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - scalarbase(p3, d3); - pack(publicKey, p3); + const p2 = [gf2(), gf2(), gf2(), gf2()]; + scalarbase(p2, d5); + pack(publicKey, p2); const secretKey = new Uint8Array(64); secretKey.set(seed); secretKey.set(publicKey, 32); @@ -5013,7 +4942,7 @@ return new Uint8Array(secretKey.subarray(32)); } exports22.extractPublicKeyFromSecretKey = extractPublicKeyFromSecretKey; - const L22 = new Float64Array([ + const L4 = new Float64Array([ 237, 211, 245, @@ -5047,7 +4976,7 @@ 0, 16 ]); - function modL(r2, x2) { + function modL(r3, x2) { let carry; let i2; let j2; @@ -5055,7 +4984,7 @@ for (i2 = 63; i2 >= 32; --i2) { carry = 0; for (j2 = i2 - 32, k2 = i2 - 12; j2 < k2; ++j2) { - x2[j2] += carry - 16 * x2[i2] * L22[j2 - (i2 - 32)]; + x2[j2] += carry - 16 * x2[i2] * L4[j2 - (i2 - 32)]; carry = Math.floor((x2[j2] + 128) / 256); x2[j2] -= carry * 256; } @@ -5064,45 +4993,45 @@ } carry = 0; for (j2 = 0; j2 < 32; j2++) { - x2[j2] += carry - (x2[31] >> 4) * L22[j2]; + x2[j2] += carry - (x2[31] >> 4) * L4[j2]; carry = x2[j2] >> 8; x2[j2] &= 255; } for (j2 = 0; j2 < 32; j2++) { - x2[j2] -= carry * L22[j2]; + x2[j2] -= carry * L4[j2]; } for (i2 = 0; i2 < 32; i2++) { x2[i2 + 1] += x2[i2] >> 8; - r2[i2] = x2[i2] & 255; + r3[i2] = x2[i2] & 255; } } - function reduce(r2) { + function reduce(r3) { const x2 = new Float64Array(64); for (let i2 = 0; i2 < 64; i2++) { - x2[i2] = r2[i2]; + x2[i2] = r3[i2]; } for (let i2 = 0; i2 < 64; i2++) { - r2[i2] = 0; + r3[i2] = 0; } - modL(r2, x2); + modL(r3, x2); } function sign(secretKey, message) { const x2 = new Float64Array(64); - const p3 = [gf(), gf(), gf(), gf()]; - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; const signature = new Uint8Array(64); - signature.set(d3.subarray(32), 32); + signature.set(d5.subarray(32), 32); const hs2 = new sha512_1.SHA512(); hs2.update(signature.subarray(32)); hs2.update(message); - const r2 = hs2.digest(); + const r3 = hs2.digest(); hs2.clean(); - reduce(r2); - scalarbase(p3, r2); - pack(signature, p3); + reduce(r3); + scalarbase(p2, r3); + pack(signature, p2); hs2.reset(); hs2.update(signature.subarray(0, 32)); hs2.update(secretKey.subarray(32)); @@ -5110,25 +5039,25 @@ const h4 = hs2.digest(); reduce(h4); for (let i2 = 0; i2 < 32; i2++) { - x2[i2] = r2[i2]; + x2[i2] = r3[i2]; } for (let i2 = 0; i2 < 32; i2++) { for (let j2 = 0; j2 < 32; j2++) { - x2[i2 + j2] += h4[i2] * d3[j2]; + x2[i2 + j2] += h4[i2] * d5[j2]; } } modL(signature.subarray(32), x2); return signature; } exports22.sign = sign; - function unpackneg(r2, p3) { - const t2 = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf(); - set25519(r2[2], gf1); - unpack25519(r2[1], p3); - square(num, r2[1]); + function unpackneg(r3, p2) { + const t2 = gf2(), chk = gf2(), num = gf2(), den = gf2(), den2 = gf2(), den4 = gf2(), den6 = gf2(); + set25519(r3[2], gf1); + unpack25519(r3[1], p2); + square(num, r3[1]); mul(den, num, D2); - sub(num, num, r2[2]); - add(den, r2[2], den); + sub(num, num, r3[2]); + add(den, r3[2], den); square(den2, den); square(den4, den2); mul(den6, den4, den2); @@ -5138,27 +5067,27 @@ mul(t2, t2, num); mul(t2, t2, den); mul(t2, t2, den); - mul(r2[0], t2, den); - square(chk, r2[0]); + mul(r3[0], t2, den); + square(chk, r3[0]); mul(chk, chk, den); if (neq25519(chk, num)) { - mul(r2[0], r2[0], I2); + mul(r3[0], r3[0], I2); } - square(chk, r2[0]); + square(chk, r3[0]); mul(chk, chk, den); if (neq25519(chk, num)) { return -1; } - if (par25519(r2[0]) === p3[31] >> 7) { - sub(r2[0], gf0, r2[0]); + if (par25519(r3[0]) === p2[31] >> 7) { + sub(r3[0], gf0, r3[0]); } - mul(r2[3], r2[0], r2[1]); + mul(r3[3], r3[0], r3[1]); return 0; } function verify(publicKey, message, signature) { const t2 = new Uint8Array(32); - const p3 = [gf(), gf(), gf(), gf()]; - const q2 = [gf(), gf(), gf(), gf()]; + const p2 = [gf2(), gf2(), gf2(), gf2()]; + const q2 = [gf2(), gf2(), gf2(), gf2()]; if (signature.length !== exports22.SIGNATURE_LENGTH) { throw new Error(`ed25519: signature must be ${exports22.SIGNATURE_LENGTH} bytes`); } @@ -5171,10 +5100,10 @@ hs2.update(message); const h4 = hs2.digest(); reduce(h4); - scalarmult(p3, q2, h4); + scalarmult(p2, q2, h4); scalarbase(q2, signature.subarray(32)); - edadd(p3, q2); - pack(t2, p3); + edadd(p2, q2); + pack(t2, p2); if (verify32(signature, t2)) { return false; } @@ -5182,29 +5111,29 @@ } exports22.verify = verify; function convertPublicKeyToX25519(publicKey) { - let q2 = [gf(), gf(), gf(), gf()]; + let q2 = [gf2(), gf2(), gf2(), gf2()]; if (unpackneg(q2, publicKey)) { throw new Error("Ed25519: invalid public key"); } - let a3 = gf(); - let b3 = gf(); + let a3 = gf2(); + let b3 = gf2(); let y3 = q2[1]; add(a3, gf1, y3); sub(b3, gf1, y3); inv25519(b3, b3); mul(a3, a3, b3); - let z3 = new Uint8Array(32); - pack25519(z3, a3); - return z3; + let z2 = new Uint8Array(32); + pack25519(z2, a3); + return z2; } exports22.convertPublicKeyToX25519 = convertPublicKeyToX25519; function convertSecretKeyToX25519(secretKey) { - const d3 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); - d3[0] &= 248; - d3[31] &= 127; - d3[31] |= 64; - const o22 = new Uint8Array(d3.subarray(0, 32)); - (0, wipe_12.wipe)(d3); + const d5 = (0, sha512_1.hash)(secretKey.subarray(0, 32)); + d5[0] &= 248; + d5[31] &= 127; + d5[31] |= 64; + const o22 = new Uint8Array(d5.subarray(0, 32)); + (0, wipe_12.wipe)(d5); return o22; } exports22.convertSecretKeyToX25519 = convertSecretKeyToX25519; @@ -5426,7 +5355,7 @@ } } or(decoder) { - return or$2(this, decoder); + return or$3(this, decoder); } } class ComposedDecoder { @@ -5434,7 +5363,7 @@ this.decoders = decoders; } or(decoder) { - return or$2(this, decoder); + return or$3(this, decoder); } decode(input) { const prefix = input[0]; @@ -5446,7 +5375,7 @@ } } } - const or$2 = (left, right) => new ComposedDecoder({ + const or$3 = (left, right) => new ComposedDecoder({ ...left.decoders || { [left.prefix]: left }, ...right.decoders || { [right.prefix]: right } }); @@ -5726,18 +5655,18 @@ base64urlpad }, Symbol.toStringTag, { value: "Module" })); const alphabet = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"); - const alphabetBytesToChars = alphabet.reduce((p3, c2, i2) => { - p3[i2] = c2; - return p3; + const alphabetBytesToChars = alphabet.reduce((p2, c2, i2) => { + p2[i2] = c2; + return p2; }, []); - const alphabetCharsToBytes = alphabet.reduce((p3, c2, i2) => { - p3[c2.codePointAt(0)] = i2; - return p3; + const alphabetCharsToBytes = alphabet.reduce((p2, c2, i2) => { + p2[c2.codePointAt(0)] = i2; + return p2; }, []); function encode(data2) { - return data2.reduce((p3, c2) => { - p3 += alphabetBytesToChars[c2]; - return p3; + return data2.reduce((p2, c2) => { + p2 += alphabetBytesToChars[c2]; + return p2; }, ""); } function decode$1(str) { @@ -5861,7 +5790,7 @@ function generateKeyPair(seed = random.randomBytes(KEY_PAIR_SEED_LENGTH)) { return ed25519.generateKeyPairFromSeed(seed); } - async function signJWT(sub, aud, ttl, keyPair, iat = cjs$4.fromMiliseconds(Date.now())) { + async function signJWT(sub, aud, ttl, keyPair, iat = cjs$3.fromMiliseconds(Date.now())) { const header = { alg: JWT_IRIDIUM_ALG, typ: JWT_IRIDIUM_TYP }; const iss = encodeIss(keyPair.publicKey); const exp = iat + ttl; @@ -5870,1266 +5799,2064 @@ const signature = ed25519.sign(keyPair.secretKey, data2); return encodeJWT({ header, payload, signature }); } - var chacha20poly1305 = {}; - var chacha = {}; - Object.defineProperty(chacha, "__esModule", { value: true }); - var binary_1 = binary; - var wipe_1$2 = wipe$1; - var ROUNDS = 20; - function core(out, input, key) { - var j0 = 1634760805; - var j1 = 857760878; - var j2 = 2036477234; - var j3 = 1797285236; - var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; - var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; - var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; - var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; - var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; - var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; - var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; - var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; - var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; - var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; - var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; - var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; - var x0 = j0; - var x1 = j1; - var x2 = j2; - var x3 = j3; - var x4 = j4; - var x5 = j5; - var x6 = j6; - var x7 = j7; - var x8 = j8; - var x9 = j9; - var x10 = j10; - var x11 = j11; - var x12 = j12; - var x13 = j13; - var x14 = j14; - var x15 = j15; - for (var i2 = 0; i2 < ROUNDS; i2 += 2) { - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 16 | x12 << 16; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 12 | x4 << 12; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 16 | x13 << 16; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 12 | x5 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 16 | x14 << 16; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 12 | x6 << 12; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 16 | x15 << 16; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 12 | x7 << 12; - x2 = x2 + x6 | 0; - x14 ^= x2; - x14 = x14 >>> 32 - 8 | x14 << 8; - x10 = x10 + x14 | 0; - x6 ^= x10; - x6 = x6 >>> 32 - 7 | x6 << 7; - x3 = x3 + x7 | 0; - x15 ^= x3; - x15 = x15 >>> 32 - 8 | x15 << 8; - x11 = x11 + x15 | 0; - x7 ^= x11; - x7 = x7 >>> 32 - 7 | x7 << 7; - x1 = x1 + x5 | 0; - x13 ^= x1; - x13 = x13 >>> 32 - 8 | x13 << 8; - x9 = x9 + x13 | 0; - x5 ^= x9; - x5 = x5 >>> 32 - 7 | x5 << 7; - x0 = x0 + x4 | 0; - x12 ^= x0; - x12 = x12 >>> 32 - 8 | x12 << 8; - x8 = x8 + x12 | 0; - x4 ^= x8; - x4 = x4 >>> 32 - 7 | x4 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 16 | x15 << 16; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 12 | x5 << 12; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 16 | x12 << 16; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 12 | x6 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 16 | x13 << 16; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 12 | x7 << 12; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 16 | x14 << 16; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 12 | x4 << 12; - x2 = x2 + x7 | 0; - x13 ^= x2; - x13 = x13 >>> 32 - 8 | x13 << 8; - x8 = x8 + x13 | 0; - x7 ^= x8; - x7 = x7 >>> 32 - 7 | x7 << 7; - x3 = x3 + x4 | 0; - x14 ^= x3; - x14 = x14 >>> 32 - 8 | x14 << 8; - x9 = x9 + x14 | 0; - x4 ^= x9; - x4 = x4 >>> 32 - 7 | x4 << 7; - x1 = x1 + x6 | 0; - x12 ^= x1; - x12 = x12 >>> 32 - 8 | x12 << 8; - x11 = x11 + x12 | 0; - x6 ^= x11; - x6 = x6 >>> 32 - 7 | x6 << 7; - x0 = x0 + x5 | 0; - x15 ^= x0; - x15 = x15 >>> 32 - 8 | x15 << 8; - x10 = x10 + x15 | 0; - x5 ^= x10; - x5 = x5 >>> 32 - 7 | x5 << 7; - } - binary_1.writeUint32LE(x0 + j0 | 0, out, 0); - binary_1.writeUint32LE(x1 + j1 | 0, out, 4); - binary_1.writeUint32LE(x2 + j2 | 0, out, 8); - binary_1.writeUint32LE(x3 + j3 | 0, out, 12); - binary_1.writeUint32LE(x4 + j4 | 0, out, 16); - binary_1.writeUint32LE(x5 + j5 | 0, out, 20); - binary_1.writeUint32LE(x6 + j6 | 0, out, 24); - binary_1.writeUint32LE(x7 + j7 | 0, out, 28); - binary_1.writeUint32LE(x8 + j8 | 0, out, 32); - binary_1.writeUint32LE(x9 + j9 | 0, out, 36); - binary_1.writeUint32LE(x10 + j10 | 0, out, 40); - binary_1.writeUint32LE(x11 + j11 | 0, out, 44); - binary_1.writeUint32LE(x12 + j12 | 0, out, 48); - binary_1.writeUint32LE(x13 + j13 | 0, out, 52); - binary_1.writeUint32LE(x14 + j14 | 0, out, 56); - binary_1.writeUint32LE(x15 + j15 | 0, out, 60); - } - function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - if (key.length !== 32) { - throw new Error("ChaCha: key size must be 32 bytes"); - } - if (dst.length < src2.length) { - throw new Error("ChaCha: destination is shorter than source"); - } - var nc; - var counterLength; - if (nonceInplaceCounterLength === 0) { - if (nonce.length !== 8 && nonce.length !== 12) { - throw new Error("ChaCha nonce must be 8 or 12 bytes"); - } - nc = new Uint8Array(16); - counterLength = nc.length - nonce.length; - nc.set(nonce, counterLength); - } else { - if (nonce.length !== 16) { - throw new Error("ChaCha nonce with counter must be 16 bytes"); + var __spreadArray$3 = function(to2, from2, pack) { + for (var i2 = 0, l2 = from2.length, ar3; i2 < l2; i2++) { + if (ar3 || !(i2 in from2)) { + if (!ar3) + ar3 = Array.prototype.slice.call(from2, 0, i2); + ar3[i2] = from2[i2]; } - nc = nonce; - counterLength = nonceInplaceCounterLength; } - var block = new Uint8Array(64); - for (var i2 = 0; i2 < src2.length; i2 += 64) { - core(block, nc, key); - for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { - dst[j2] = src2[j2] ^ block[j2 - i2]; + return to2.concat(ar3 || Array.prototype.slice.call(from2)); + }; + var BrowserInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BrowserInfo2(name2, version2, os2) { + this.name = name2; + this.version = version2; + this.os = os2; + this.type = "browser"; } - incrementCounter(nc, 0, counterLength); + return BrowserInfo2; + }() + ); + var NodeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function NodeInfo2(version2) { + this.version = version2; + this.type = "node"; + this.name = "node"; + this.os = process.platform; + } + return NodeInfo2; + }() + ); + var SearchBotDeviceInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function SearchBotDeviceInfo2(name2, version2, os2, bot) { + this.name = name2; + this.version = version2; + this.os = os2; + this.bot = bot; + this.type = "bot-device"; + } + return SearchBotDeviceInfo2; + }() + ); + var BotInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function BotInfo2() { + this.type = "bot"; + this.bot = true; + this.name = "bot"; + this.version = null; + this.os = null; + } + return BotInfo2; + }() + ); + var ReactNativeInfo = ( + /** @class */ + /* @__PURE__ */ function() { + function ReactNativeInfo2() { + this.type = "react-native"; + this.name = "react-native"; + this.version = null; + this.os = null; + } + return ReactNativeInfo2; + }() + ); + var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; + var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; + var REQUIRED_VERSION_PARTS = 3; + var userAgentRules = [ + ["aol", /AOLShield\/([0-9\._]+)/], + ["edge", /Edge\/([0-9\._]+)/], + ["edge-ios", /EdgiOS\/([0-9\._]+)/], + ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], + ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], + ["samsung", /SamsungBrowser\/([0-9\.]+)/], + ["silk", /\bSilk\/([0-9._-]+)\b/], + ["miui", /MiuiBrowser\/([0-9\.]+)$/], + ["beaker", /BeakerBrowser\/([0-9\.]+)/], + ["edge-chromium", /EdgA?\/([0-9\.]+)/], + [ + "chromium-webview", + /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ + ], + ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], + ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], + ["fxios", /FxiOS\/([0-9\.]+)/], + ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], + ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], + ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], + ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], + ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], + ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], + ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ["ie", /MSIE\s(7\.0)/], + ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], + ["android", /Android\s([0-9\.]+)/], + ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ["safari", /Version\/([0-9\._]+).*Safari/], + ["facebook", /FB[AS]V\/([0-9\.]+)/], + ["instagram", /Instagram\s([0-9\.]+)/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ["curl", /^curl\/([0-9\.]+)$/], + ["searchbot", SEARCHBOX_UA_REGEX] + ]; + var operatingSystemRules = [ + ["iOS", /iP(hone|od|ad)/], + ["Android OS", /Android/], + ["BlackBerry OS", /BlackBerry|BB10/], + ["Windows Mobile", /IEMobile/], + ["Amazon OS", /Kindle/], + ["Windows 3.11", /Win16/], + ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], + ["Windows 98", /(Windows 98)|(Win98)/], + ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], + ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], + ["Windows Server 2003", /(Windows NT 5.2)/], + ["Windows Vista", /(Windows NT 6.0)/], + ["Windows 7", /(Windows NT 6.1)/], + ["Windows 8", /(Windows NT 6.2)/], + ["Windows 8.1", /(Windows NT 6.3)/], + ["Windows 10", /(Windows NT 10.0)/], + ["Windows ME", /Windows ME/], + ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], + ["Open BSD", /OpenBSD/], + ["Sun OS", /SunOS/], + ["Chrome OS", /CrOS/], + ["Linux", /(Linux)|(X11)/], + ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], + ["QNX", /QNX/], + ["BeOS", /BeOS/], + ["OS/2", /OS\/2/] + ]; + function detect(userAgent) { + if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { + return new ReactNativeInfo(); } - wipe_1$2.wipe(block); - if (nonceInplaceCounterLength === 0) { - wipe_1$2.wipe(nc); + if (typeof navigator !== "undefined") { + return parseUserAgent(navigator.userAgent); } - return dst; + return getNodeVersion(); } - chacha.streamXOR = streamXOR; - function stream(key, nonce, dst, nonceInplaceCounterLength) { - if (nonceInplaceCounterLength === void 0) { - nonceInplaceCounterLength = 0; - } - wipe_1$2.wipe(dst); - return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); + function matchUserAgent(ua2) { + return ua2 !== "" && userAgentRules.reduce(function(matched, _a2) { + var browser2 = _a2[0], regex2 = _a2[1]; + if (matched) { + return matched; + } + var uaMatch = regex2.exec(ua2); + return !!uaMatch && [browser2, uaMatch]; + }, false); } - chacha.stream = stream; - function incrementCounter(counter, pos, len) { - var carry = 1; - while (len--) { - carry = carry + (counter[pos] & 255) | 0; - counter[pos] = carry & 255; - carry >>>= 8; - pos++; + function parseUserAgent(ua2) { + var matchedRule = matchUserAgent(ua2); + if (!matchedRule) { + return null; } - if (carry > 0) { - throw new Error("ChaCha: counter overflow"); + var name2 = matchedRule[0], match = matchedRule[1]; + if (name2 === "searchbot") { + return new BotInfo(); + } + var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); + if (versionParts) { + if (versionParts.length < REQUIRED_VERSION_PARTS) { + versionParts = __spreadArray$3(__spreadArray$3([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length)); + } + } else { + versionParts = []; + } + var version2 = versionParts.join("."); + var os2 = detectOS(ua2); + var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua2); + if (searchBotMatch && searchBotMatch[1]) { + return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); } + return new BrowserInfo(name2, version2, os2); } - var poly1305 = {}; - var constantTime = {}; - Object.defineProperty(constantTime, "__esModule", { value: true }); - function select(subject, resultIfOne, resultIfZero) { - return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; + function detectOS(ua2) { + for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { + var _a2 = operatingSystemRules[ii], os2 = _a2[0], regex2 = _a2[1]; + var match = regex2.exec(ua2); + if (match) { + return os2; + } + } + return null; } - constantTime.select = select; - function lessOrEqual(a3, b3) { - return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; + function getNodeVersion() { + var isNode = typeof process !== "undefined" && process.version; + return isNode ? new NodeInfo(process.version.slice(1)) : null; } - constantTime.lessOrEqual = lessOrEqual; - function compare(a3, b3) { - if (a3.length !== b3.length) { - return 0; + function createVersionParts(count) { + var output = []; + for (var ii = 0; ii < count; ii++) { + output.push("0"); } - var result = 0; - for (var i2 = 0; i2 < a3.length; i2++) { - result |= a3[i2] ^ b3[i2]; + return output; + } + var cjs$2 = {}; + Object.defineProperty(cjs$2, "__esModule", { value: true }); + cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; + function getFromWindow(name2) { + let res = void 0; + if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { + res = window[name2]; } - return 1 & result - 1 >>> 8; + return res; } - constantTime.compare = compare; - function equal(a3, b3) { - if (a3.length === 0 || b3.length === 0) { - return false; + cjs$2.getFromWindow = getFromWindow; + function getFromWindowOrThrow(name2) { + const res = getFromWindow(name2); + if (!res) { + throw new Error(`${name2} is not defined in Window`); } - return compare(a3, b3) !== 0; + return res; } - constantTime.equal = equal; - (function(exports22) { - Object.defineProperty(exports22, "__esModule", { value: true }); - var constant_time_12 = constantTime; - var wipe_12 = wipe$1; - exports22.DIGEST_LENGTH = 16; - var Poly1305 = ( - /** @class */ - function() { - function Poly13052(key) { - this.digestLength = exports22.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 = false; - var t0 = key[0] | key[1] << 8; - this._r[0] = t0 & 8191; - var t1 = key[2] | key[3] << 8; - this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; - var t2 = key[4] | key[5] << 8; - this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; - var t3 = key[6] | key[7] << 8; - this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; - var t4 = key[8] | key[9] << 8; - this._r[4] = (t3 >>> 4 | t4 << 12) & 255; - this._r[5] = t4 >>> 1 & 8190; - var t5 = key[10] | key[11] << 8; - this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; - var t6 = key[12] | key[13] << 8; - this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; - var t7 = key[14] | key[15] << 8; - this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; - this._r[9] = t7 >>> 5 & 127; - this._pad[0] = key[16] | key[17] << 8; - this._pad[1] = key[18] | key[19] << 8; - this._pad[2] = key[20] | key[21] << 8; - this._pad[3] = key[22] | key[23] << 8; - this._pad[4] = key[24] | key[25] << 8; - this._pad[5] = key[26] | key[27] << 8; - this._pad[6] = key[28] | key[29] << 8; - this._pad[7] = key[30] | key[31] << 8; + cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; + function getDocumentOrThrow() { + return getFromWindowOrThrow("document"); + } + cjs$2.getDocumentOrThrow = getDocumentOrThrow; + function getDocument() { + return getFromWindow("document"); + } + var getDocument_1 = cjs$2.getDocument = getDocument; + function getNavigatorOrThrow() { + return getFromWindowOrThrow("navigator"); + } + cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; + function getNavigator() { + return getFromWindow("navigator"); + } + var getNavigator_1 = cjs$2.getNavigator = getNavigator; + function getLocationOrThrow() { + return getFromWindowOrThrow("location"); + } + cjs$2.getLocationOrThrow = getLocationOrThrow; + function getLocation() { + return getFromWindow("location"); + } + var getLocation_1 = cjs$2.getLocation = getLocation; + function getCryptoOrThrow() { + return getFromWindowOrThrow("crypto"); + } + cjs$2.getCryptoOrThrow = getCryptoOrThrow; + function getCrypto() { + return getFromWindow("crypto"); + } + cjs$2.getCrypto = getCrypto; + function getLocalStorageOrThrow() { + return getFromWindowOrThrow("localStorage"); + } + cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; + function getLocalStorage() { + return getFromWindow("localStorage"); + } + cjs$2.getLocalStorage = getLocalStorage; + var cjs$1 = {}; + Object.defineProperty(cjs$1, "__esModule", { value: true }); + var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; + const window_getters_1 = cjs$2; + function getWindowMetadata() { + let doc; + let loc; + try { + doc = window_getters_1.getDocumentOrThrow(); + loc = window_getters_1.getLocationOrThrow(); + } catch (e2) { + return null; + } + function getIcons() { + const links = doc.getElementsByTagName("link"); + const icons2 = []; + for (let i2 = 0; i2 < links.length; i2++) { + const link = links[i2]; + const rel = link.getAttribute("rel"); + if (rel) { + if (rel.toLowerCase().indexOf("icon") > -1) { + const href = link.getAttribute("href"); + if (href) { + if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { + let absoluteHref = loc.protocol + "//" + loc.host; + if (href.indexOf("/") === 0) { + absoluteHref += href; + } else { + const path = loc.pathname.split("/"); + path.pop(); + const finalPath = path.join("/"); + absoluteHref += finalPath + "/" + href; + } + icons2.push(absoluteHref); + } else if (href.indexOf("//") === 0) { + const absoluteUrl = loc.protocol + href; + icons2.push(absoluteUrl); + } else { + icons2.push(href); + } + } + } } - Poly13052.prototype._blocks = function(m2, mpos, bytes) { - var hibit = this._fin ? 0 : 1 << 11; - var h0 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; - var r0 = this._r[0], r1 = this._r[1], r2 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; - while (bytes >= 16) { - var t0 = m2[mpos + 0] | m2[mpos + 1] << 8; - h0 += t0 & 8191; - var t1 = m2[mpos + 2] | m2[mpos + 3] << 8; - h1 += (t0 >>> 13 | t1 << 3) & 8191; - var t2 = m2[mpos + 4] | m2[mpos + 5] << 8; - h22 += (t1 >>> 10 | t2 << 6) & 8191; - var t3 = m2[mpos + 6] | m2[mpos + 7] << 8; - h32 += (t2 >>> 7 | t3 << 9) & 8191; - var t4 = m2[mpos + 8] | m2[mpos + 9] << 8; - h4 += (t3 >>> 4 | t4 << 12) & 8191; - h5 += t4 >>> 1 & 8191; - var t5 = m2[mpos + 10] | m2[mpos + 11] << 8; - h6 += (t4 >>> 14 | t5 << 2) & 8191; - var t6 = m2[mpos + 12] | m2[mpos + 13] << 8; - h7 += (t5 >>> 11 | t6 << 5) & 8191; - var t7 = m2[mpos + 14] | m2[mpos + 15] << 8; - h8 += (t6 >>> 8 | t7 << 8) & 8191; - h9 += t7 >>> 5 | hibit; - var c2 = 0; - var d0 = c2; - d0 += h0 * r0; - d0 += h1 * (5 * r9); - d0 += h22 * (5 * r8); - d0 += h32 * (5 * r7); - d0 += h4 * (5 * r6); - c2 = d0 >>> 13; - d0 &= 8191; - d0 += h5 * (5 * r5); - d0 += h6 * (5 * r4); - d0 += h7 * (5 * r3); - d0 += h8 * (5 * r2); - d0 += h9 * (5 * r1); - c2 += d0 >>> 13; - d0 &= 8191; - var d1 = c2; - d1 += h0 * r1; - d1 += h1 * r0; - d1 += h22 * (5 * r9); - d1 += h32 * (5 * r8); - d1 += h4 * (5 * r7); - c2 = d1 >>> 13; - d1 &= 8191; - d1 += h5 * (5 * r6); - d1 += h6 * (5 * r5); - d1 += h7 * (5 * r4); - d1 += h8 * (5 * r3); - d1 += h9 * (5 * r2); - c2 += d1 >>> 13; - d1 &= 8191; - var d22 = c2; - d22 += h0 * r2; - d22 += h1 * r1; - d22 += h22 * r0; - d22 += h32 * (5 * r9); - d22 += h4 * (5 * r8); - c2 = d22 >>> 13; - d22 &= 8191; - d22 += h5 * (5 * r7); - d22 += h6 * (5 * r6); - d22 += h7 * (5 * r5); - d22 += h8 * (5 * r4); - d22 += h9 * (5 * r3); - c2 += d22 >>> 13; - d22 &= 8191; - var d3 = c2; - d3 += h0 * r3; - d3 += h1 * r2; - d3 += h22 * r1; - d3 += h32 * r0; - d3 += h4 * (5 * r9); - c2 = d3 >>> 13; - d3 &= 8191; - d3 += h5 * (5 * r8); - d3 += h6 * (5 * r7); - d3 += h7 * (5 * r6); - d3 += h8 * (5 * r5); - d3 += h9 * (5 * r4); - c2 += d3 >>> 13; - d3 &= 8191; - var d4 = c2; - d4 += h0 * r4; - d4 += h1 * r3; - d4 += h22 * r2; - d4 += h32 * r1; - d4 += h4 * r0; - c2 = d4 >>> 13; - d4 &= 8191; - d4 += h5 * (5 * r9); - d4 += h6 * (5 * r8); - d4 += h7 * (5 * r7); - d4 += h8 * (5 * r6); - d4 += h9 * (5 * r5); - c2 += d4 >>> 13; - d4 &= 8191; - var d5 = c2; - d5 += h0 * r5; - d5 += h1 * r4; - d5 += h22 * r3; - d5 += h32 * r2; - d5 += h4 * r1; - c2 = d5 >>> 13; - d5 &= 8191; - d5 += h5 * r0; - d5 += h6 * (5 * r9); - d5 += h7 * (5 * r8); - d5 += h8 * (5 * r7); - d5 += h9 * (5 * r6); - c2 += d5 >>> 13; - d5 &= 8191; - var d6 = c2; - d6 += h0 * r6; - d6 += h1 * r5; - d6 += h22 * r4; - d6 += h32 * r3; - d6 += h4 * r2; - c2 = d6 >>> 13; - d6 &= 8191; - d6 += h5 * r1; - d6 += h6 * r0; - d6 += h7 * (5 * r9); - d6 += h8 * (5 * r8); - d6 += h9 * (5 * r7); - c2 += d6 >>> 13; - d6 &= 8191; - var d7 = c2; - d7 += h0 * r7; - d7 += h1 * r6; - d7 += h22 * r5; - d7 += h32 * r4; - d7 += h4 * r3; - c2 = d7 >>> 13; - d7 &= 8191; - d7 += h5 * r2; - d7 += h6 * r1; - d7 += h7 * r0; - d7 += h8 * (5 * r9); - d7 += h9 * (5 * r8); - c2 += d7 >>> 13; - d7 &= 8191; - var d8 = c2; - d8 += h0 * r8; - d8 += h1 * r7; - d8 += h22 * r6; - d8 += h32 * r5; - d8 += h4 * r4; - c2 = d8 >>> 13; - d8 &= 8191; - d8 += h5 * r3; - d8 += h6 * r2; - d8 += h7 * r1; - d8 += h8 * r0; - d8 += h9 * (5 * r9); - c2 += d8 >>> 13; - d8 &= 8191; - var d9 = c2; - d9 += h0 * r9; - d9 += h1 * r8; - d9 += h22 * r7; - d9 += h32 * r6; - d9 += h4 * r5; - c2 = d9 >>> 13; - d9 &= 8191; - d9 += h5 * r4; - d9 += h6 * r3; - d9 += h7 * r2; - d9 += h8 * r1; - d9 += h9 * r0; - c2 += d9 >>> 13; - d9 &= 8191; - c2 = (c2 << 2) + c2 | 0; - c2 = c2 + d0 | 0; - d0 = c2 & 8191; - c2 = c2 >>> 13; - d1 += c2; - h0 = d0; - h1 = d1; - h22 = d22; - h32 = d3; - h4 = d4; - h5 = d5; - h6 = d6; - h7 = d7; - h8 = d8; - h9 = d9; - mpos += 16; - bytes -= 16; + } + return icons2; + } + function getWindowMetadataOfAny(...args) { + const metaTags = doc.getElementsByTagName("meta"); + for (let i2 = 0; i2 < metaTags.length; i2++) { + const tag = metaTags[i2]; + const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { + if (attr) { + return args.includes(attr); } - this._h[0] = h0; - this._h[1] = h1; - this._h[2] = h22; - this._h[3] = h32; - this._h[4] = h4; - this._h[5] = h5; - this._h[6] = h6; - this._h[7] = h7; - this._h[8] = h8; - this._h[9] = h9; - }; - Poly13052.prototype.finish = function(mac, macpos) { - if (macpos === void 0) { - macpos = 0; + return false; + }); + if (attributes.length && attributes) { + const content = tag.getAttribute("content"); + if (content) { + return content; } - var g3 = new Uint16Array(10); - var c2; - var mask; - var f2; - var i2; - if (this._leftover) { - i2 = this._leftover; - this._buffer[i2++] = 1; - for (; i2 < 16; i2++) { - this._buffer[i2] = 0; + } + } + return ""; + } + function getName() { + let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); + if (!name3) { + name3 = doc.title; + } + return name3; + } + function getDescription() { + const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); + return description3; + } + const name2 = getName(); + const description2 = getDescription(); + const url = loc.origin; + const icons = getIcons(); + const meta = { + description: description2, + url, + icons, + name: name2 + }; + return meta; + } + getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; + var queryString = {}; + var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); + var token = "%[a-f0-9]{2}"; + var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); + var multiMatcher = new RegExp("(" + token + ")+", "gi"); + function decodeComponents(components, split) { + try { + return [decodeURIComponent(components.join(""))]; + } catch (err) { + } + if (components.length === 1) { + return components; + } + split = split || 1; + var left = components.slice(0, split); + var right = components.slice(split); + return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); + } + function decode(input) { + try { + return decodeURIComponent(input); + } catch (err) { + var tokens = input.match(singleMatcher) || []; + for (var i2 = 1; i2 < tokens.length; i2++) { + input = decodeComponents(tokens, i2).join(""); + tokens = input.match(singleMatcher) || []; + } + return input; + } + } + function customDecodeURIComponent(input) { + var replaceMap = { + "%FE%FF": "��", + "%FF%FE": "��" + }; + var match = multiMatcher.exec(input); + while (match) { + try { + replaceMap[match[0]] = decodeURIComponent(match[0]); + } catch (err) { + var result = decode(match[0]); + if (result !== match[0]) { + replaceMap[match[0]] = result; + } + } + match = multiMatcher.exec(input); + } + replaceMap["%C2"] = "�"; + var entries = Object.keys(replaceMap); + for (var i2 = 0; i2 < entries.length; i2++) { + var key = entries[i2]; + input = input.replace(new RegExp(key, "g"), replaceMap[key]); + } + return input; + } + var decodeUriComponent = function(encodedURI) { + if (typeof encodedURI !== "string") { + throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + } + try { + encodedURI = encodedURI.replace(/\+/g, " "); + return decodeURIComponent(encodedURI); + } catch (err) { + return customDecodeURIComponent(encodedURI); + } + }; + var splitOnFirst = (string2, separator) => { + if (!(typeof string2 === "string" && typeof separator === "string")) { + throw new TypeError("Expected the arguments to be of type `string`"); + } + if (separator === "") { + return [string2]; + } + const separatorIndex = string2.indexOf(separator); + if (separatorIndex === -1) { + return [string2]; + } + return [ + string2.slice(0, separatorIndex), + string2.slice(separatorIndex + separator.length) + ]; + }; + var filterObj = function(obj, predicate) { + var ret = {}; + var keys2 = Object.keys(obj); + var isArr = Array.isArray(predicate); + for (var i2 = 0; i2 < keys2.length; i2++) { + var key = keys2[i2]; + var val = obj[key]; + if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { + ret[key] = val; + } + } + return ret; + }; + (function(exports22) { + const strictUriEncode$1 = strictUriEncode; + const decodeComponent = decodeUriComponent; + const splitOnFirst$1 = splitOnFirst; + const filterObject = filterObj; + const isNullOrUndefined = (value) => value === null || value === void 0; + const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); + function encoderForArrayFormat(options) { + switch (options.arrayFormat) { + case "index": + return (key) => (result, value) => { + const index = result.length; + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; } - this._fin = 1; - this._blocks(this._buffer, 0, 16); - } - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - for (i2 = 2; i2 < 10; i2++) { - this._h[i2] += c2; - c2 = this._h[i2] >>> 13; - this._h[i2] &= 8191; - } - this._h[0] += c2 * 5; - c2 = this._h[0] >>> 13; - this._h[0] &= 8191; - this._h[1] += c2; - c2 = this._h[1] >>> 13; - this._h[1] &= 8191; - this._h[2] += c2; - g3[0] = this._h[0] + 5; - c2 = g3[0] >>> 13; - g3[0] &= 8191; - for (i2 = 1; i2 < 10; i2++) { - g3[i2] = this._h[i2] + c2; - c2 = g3[i2] >>> 13; - g3[i2] &= 8191; - } - g3[9] -= 1 << 13; - mask = (c2 ^ 1) - 1; - for (i2 = 0; i2 < 10; i2++) { - g3[i2] &= mask; - } - mask = ~mask; - for (i2 = 0; i2 < 10; i2++) { - this._h[i2] = this._h[i2] & mask | g3[i2]; - } - 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; - f2 = this._h[0] + this._pad[0]; - this._h[0] = f2 & 65535; - for (i2 = 1; i2 < 8; i2++) { - f2 = (this._h[i2] + this._pad[i2] | 0) + (f2 >>> 16) | 0; - this._h[i2] = f2 & 65535; - } - mac[macpos + 0] = this._h[0] >>> 0; - mac[macpos + 1] = this._h[0] >>> 8; - mac[macpos + 2] = this._h[1] >>> 0; - mac[macpos + 3] = this._h[1] >>> 8; - mac[macpos + 4] = this._h[2] >>> 0; - mac[macpos + 5] = this._h[2] >>> 8; - mac[macpos + 6] = this._h[3] >>> 0; - mac[macpos + 7] = this._h[3] >>> 8; - mac[macpos + 8] = this._h[4] >>> 0; - mac[macpos + 9] = this._h[4] >>> 8; - mac[macpos + 10] = this._h[5] >>> 0; - mac[macpos + 11] = this._h[5] >>> 8; - mac[macpos + 12] = this._h[6] >>> 0; - mac[macpos + 13] = this._h[6] >>> 8; - mac[macpos + 14] = this._h[7] >>> 0; - mac[macpos + 15] = this._h[7] >>> 8; - this._finished = true; - return this; - }; - Poly13052.prototype.update = function(m2) { - var mpos = 0; - var bytes = m2.length; - var want; - if (this._leftover) { - want = 16 - this._leftover; - if (want > bytes) { - want = bytes; + if (value === null) { + return [...result, [encode2(key, options), "[", index, "]"].join("")]; } - for (var i2 = 0; i2 < want; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; + return [ + ...result, + [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") + ]; + }; + case "bracket": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; } - bytes -= want; - mpos += want; - this._leftover += want; - if (this._leftover < 16) { - return this; + if (value === null) { + return [...result, [encode2(key, options), "[]"].join("")]; } - this._blocks(this._buffer, 0, 16); - this._leftover = 0; - } - if (bytes >= 16) { - want = bytes - bytes % 16; - this._blocks(m2, mpos, want); - mpos += want; - bytes -= want; - } - if (bytes) { - for (var i2 = 0; i2 < bytes; i2++) { - this._buffer[this._leftover + i2] = m2[mpos + i2]; + return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; + }; + case "colon-list-separator": + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; } - this._leftover += bytes; - } - return this; - }; - Poly13052.prototype.digest = function() { - if (this._finished) { - throw new Error("Poly1305 was finished"); - } - var mac = new Uint8Array(16); - this.finish(mac); - return mac; - }; - Poly13052.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._r); - wipe_12.wipe(this._h); - wipe_12.wipe(this._pad); - this._leftover = 0; - this._fin = 0; - this._finished = true; - return this; - }; - return Poly13052; - }() - ); - exports22.Poly1305 = Poly1305; - function oneTimeAuth(key, data2) { - var h4 = new Poly1305(key); - h4.update(data2); - var digest = h4.digest(); - h4.clean(); - return digest; - } - exports22.oneTimeAuth = oneTimeAuth; - function equal2(a3, b3) { - if (a3.length !== exports22.DIGEST_LENGTH || b3.length !== exports22.DIGEST_LENGTH) { - return false; - } - return constant_time_12.equal(a3, b3); - } - exports22.equal = equal2; - })(poly1305); - (function(exports22) { - Object.defineProperty(exports22, "__esModule", { value: true }); - var chacha_1 = chacha; - var poly1305_1 = poly1305; - var wipe_12 = wipe$1; - var binary_12 = binary; - var constant_time_12 = constantTime; - exports22.KEY_LENGTH = 32; - exports22.NONCE_LENGTH = 12; - exports22.TAG_LENGTH = 16; - var ZEROS = new Uint8Array(16); - var ChaCha20Poly1305 = ( - /** @class */ - function() { - function ChaCha20Poly13052(key) { - this.nonceLength = exports22.NONCE_LENGTH; - this.tagLength = exports22.TAG_LENGTH; - if (key.length !== exports22.KEY_LENGTH) { - throw new Error("ChaCha20Poly1305 needs 32-byte key"); - } - this._key = new Uint8Array(key); - } - ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var resultLength = plaintext.length + this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); + if (value === null) { + return [...result, [encode2(key, options), ":list="].join("")]; } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, plaintext, result, 4); - this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { - if (nonce.length > 16) { - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - } - if (sealed.length < this.tagLength) { - return null; - } - var counter = new Uint8Array(16); - counter.set(nonce, counter.length - nonce.length); - var authKey = new Uint8Array(32); - chacha_1.stream(this._key, counter, authKey, 4); - var calculatedTag = new Uint8Array(this.tagLength); - this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); - if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { - return null; - } - var resultLength = sealed.length - this.tagLength; - var result; - if (dst) { - if (dst.length !== resultLength) { - throw new Error("ChaCha20Poly1305: incorrect destination length"); + return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; + }; + case "comma": + case "separator": + case "bracket-separator": { + const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; } - result = dst; - } else { - result = new Uint8Array(resultLength); - } - chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); - wipe_12.wipe(counter); - return result; - }; - ChaCha20Poly13052.prototype.clean = function() { - wipe_12.wipe(this._key); - return this; - }; - ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { - var h4 = new poly1305_1.Poly1305(authKey); - if (associatedData) { - h4.update(associatedData); - if (associatedData.length % 16 > 0) { - h4.update(ZEROS.subarray(associatedData.length % 16)); + value = value === null ? "" : value; + if (result.length === 0) { + return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; } - } - h4.update(ciphertext); - if (ciphertext.length % 16 > 0) { - h4.update(ZEROS.subarray(ciphertext.length % 16)); - } - var length = new Uint8Array(8); - if (associatedData) { - binary_12.writeUint64LE(associatedData.length, length); - } - h4.update(length); - binary_12.writeUint64LE(ciphertext.length, length); - h4.update(length); - var tag = h4.digest(); - for (var i2 = 0; i2 < tag.length; i2++) { - tagOut[i2] = tag[i2]; - } - h4.clean(); - wipe_12.wipe(tag); - wipe_12.wipe(length); - }; - return ChaCha20Poly13052; - }() - ); - exports22.ChaCha20Poly1305 = ChaCha20Poly1305; - })(chacha20poly1305); - var hkdf = {}; - var hmac$1 = {}; - var hash = {}; - Object.defineProperty(hash, "__esModule", { value: true }); - function isSerializableHash(h4) { - return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; - } - hash.isSerializableHash = isSerializableHash; - Object.defineProperty(hmac$1, "__esModule", { value: true }); - var hash_1 = hash; - var constant_time_1 = constantTime; - var wipe_1$1 = wipe$1; - var HMAC = ( - /** @class */ - function() { - function HMAC2(hash2, key) { - this._finished = false; - this._inner = new hash2(); - this._outer = new hash2(); - this.blockSize = this._outer.blockSize; - this.digestLength = this._outer.digestLength; - var pad = new Uint8Array(this.blockSize); - if (key.length > this.blockSize) { - this._inner.update(key).finish(pad).clean(); - } else { - pad.set(key); - } - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54; - } - this._inner.update(pad); - for (var i2 = 0; i2 < pad.length; i2++) { - pad[i2] ^= 54 ^ 92; - } - this._outer.update(pad); - if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { - this._innerKeyedState = this._inner.saveState(); - this._outerKeyedState = this._outer.saveState(); + return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; + }; } - wipe_1$1.wipe(pad); + default: + return (key) => (result, value) => { + if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { + return result; + } + if (value === null) { + return [...result, encode2(key, options)]; + } + return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; + }; } - HMAC2.prototype.reset = function() { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); - } - this._inner.restoreState(this._innerKeyedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.clean = function() { - if (hash_1.isSerializableHash(this._inner)) { - this._inner.cleanSavedState(this._innerKeyedState); - } - if (hash_1.isSerializableHash(this._outer)) { - this._outer.cleanSavedState(this._outerKeyedState); - } - this._inner.clean(); - this._outer.clean(); - }; - HMAC2.prototype.update = function(data2) { - this._inner.update(data2); - return this; - }; - HMAC2.prototype.finish = function(out) { - if (this._finished) { - this._outer.finish(out); - return this; - } - this._inner.finish(out); - this._outer.update(out.subarray(0, this.digestLength)).finish(out); - this._finished = true; - return this; - }; - HMAC2.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - HMAC2.prototype.saveState = function() { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't saveState() because hash doesn't implement it"); - } - return this._inner.saveState(); - }; - HMAC2.prototype.restoreState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { - throw new Error("hmac: can't restoreState() because hash doesn't implement it"); - } - this._inner.restoreState(savedState); - this._outer.restoreState(this._outerKeyedState); - this._finished = false; - return this; - }; - HMAC2.prototype.cleanSavedState = function(savedState) { - if (!hash_1.isSerializableHash(this._inner)) { - throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); + } + function parserForArrayFormat(options) { + let result; + switch (options.arrayFormat) { + case "index": + return (key, value, accumulator) => { + result = /\[(\d*)\]$/.exec(key); + key = key.replace(/\[\d*\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = {}; + } + accumulator[key][result[1]] = value; + }; + case "bracket": + return (key, value, accumulator) => { + result = /(\[\])$/.exec(key); + key = key.replace(/\[\]$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "colon-list-separator": + return (key, value, accumulator) => { + result = /(:list)$/.exec(key); + key = key.replace(/:list$/, ""); + if (!result) { + accumulator[key] = value; + return; + } + if (accumulator[key] === void 0) { + accumulator[key] = [value]; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + case "comma": + case "separator": + return (key, value, accumulator) => { + const isArray2 = typeof value === "string" && value.includes(options.arrayFormatSeparator); + const isEncodedArray = typeof value === "string" && !isArray2 && decode2(value, options).includes(options.arrayFormatSeparator); + value = isEncodedArray ? decode2(value, options) : value; + const newValue = isArray2 || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); + accumulator[key] = newValue; + }; + case "bracket-separator": + return (key, value, accumulator) => { + const isArray2 = /(\[\])$/.test(key); + key = key.replace(/\[\]$/, ""); + if (!isArray2) { + accumulator[key] = value ? decode2(value, options) : value; + return; + } + const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); + if (accumulator[key] === void 0) { + accumulator[key] = arrayValue; + return; + } + accumulator[key] = [].concat(accumulator[key], arrayValue); + }; + default: + return (key, value, accumulator) => { + if (accumulator[key] === void 0) { + accumulator[key] = value; + return; + } + accumulator[key] = [].concat(accumulator[key], value); + }; + } + } + function validateArrayFormatSeparator(value) { + if (typeof value !== "string" || value.length !== 1) { + throw new TypeError("arrayFormatSeparator must be single character string"); + } + } + function encode2(value, options) { + if (options.encode) { + return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); + } + return value; + } + function decode2(value, options) { + if (options.decode) { + return decodeComponent(value); + } + return value; + } + function keysSorter(input) { + if (Array.isArray(input)) { + return input.sort(); + } + if (typeof input === "object") { + return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); + } + return input; + } + function removeHash(input) { + const hashStart = input.indexOf("#"); + if (hashStart !== -1) { + input = input.slice(0, hashStart); + } + return input; + } + function getHash(url) { + let hash2 = ""; + const hashStart = url.indexOf("#"); + if (hashStart !== -1) { + hash2 = url.slice(hashStart); + } + return hash2; + } + function extract(input) { + input = removeHash(input); + const queryStart = input.indexOf("?"); + if (queryStart === -1) { + return ""; + } + return input.slice(queryStart + 1); + } + function parseValue(value, options) { + if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { + value = Number(value); + } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { + value = value.toLowerCase() === "true"; + } + return value; + } + function parse(query, options) { + options = Object.assign({ + decode: true, + sort: true, + arrayFormat: "none", + arrayFormatSeparator: ",", + parseNumbers: false, + parseBooleans: false + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const formatter = parserForArrayFormat(options); + const ret = /* @__PURE__ */ Object.create(null); + if (typeof query !== "string") { + return ret; + } + query = query.trim().replace(/^[?#&]/, ""); + if (!query) { + return ret; + } + for (const param of query.split("&")) { + if (param === "") { + continue; } - this._inner.cleanSavedState(savedState); - }; - return HMAC2; - }() - ); - hmac$1.HMAC = HMAC; - function hmac(hash2, key, data2) { - var h4 = new HMAC(hash2, key); - h4.update(data2); - var digest = h4.digest(); - h4.clean(); - return digest; - } - hmac$1.hmac = hmac; - hmac$1.equal = constant_time_1.equal; - Object.defineProperty(hkdf, "__esModule", { value: true }); - var hmac_1 = hmac$1; - var wipe_1 = wipe$1; - var HKDF = ( - /** @class */ - function() { - function HKDF2(hash2, key, salt, info) { - if (salt === void 0) { - salt = new Uint8Array(0); + let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); + value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); + formatter(decode2(key, options), value, ret); + } + for (const key of Object.keys(ret)) { + const value = ret[key]; + if (typeof value === "object" && value !== null) { + for (const k2 of Object.keys(value)) { + value[k2] = parseValue(value[k2], options); + } + } else { + ret[key] = parseValue(value, options); } - this._counter = new Uint8Array(1); - this._hash = hash2; - this._info = info; - var okm = hmac_1.hmac(this._hash, salt, key); - this._hmac = new hmac_1.HMAC(hash2, okm); - this._buffer = new Uint8Array(this._hmac.digestLength); - this._bufpos = this._buffer.length; } - HKDF2.prototype._fillBuffer = function() { - this._counter[0]++; - var ctr = this._counter[0]; - if (ctr === 0) { - throw new Error("hkdf: cannot expand more"); + if (options.sort === false) { + return ret; + } + return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { + const value = ret[key]; + if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { + result[key] = keysSorter(value); + } else { + result[key] = value; } - this._hmac.reset(); - if (ctr > 1) { - this._hmac.update(this._buffer); + return result; + }, /* @__PURE__ */ Object.create(null)); + } + exports22.extract = extract; + exports22.parse = parse; + exports22.stringify = (object, options) => { + if (!object) { + return ""; + } + options = Object.assign({ + encode: true, + strict: true, + arrayFormat: "none", + arrayFormatSeparator: "," + }, options); + validateArrayFormatSeparator(options.arrayFormatSeparator); + const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; + const formatter = encoderForArrayFormat(options); + const objectCopy = {}; + for (const key of Object.keys(object)) { + if (!shouldFilter(key)) { + objectCopy[key] = object[key]; } - if (this._info) { - this._hmac.update(this._info); + } + const keys2 = Object.keys(objectCopy); + if (options.sort !== false) { + keys2.sort(options.sort); + } + return keys2.map((key) => { + const value = object[key]; + if (value === void 0) { + return ""; } - this._hmac.update(this._counter); - this._hmac.finish(this._buffer); - this._bufpos = 0; - }; - HKDF2.prototype.expand = function(length) { - var out = new Uint8Array(length); - for (var i2 = 0; i2 < out.length; i2++) { - if (this._bufpos === this._buffer.length) { - this._fillBuffer(); - } - out[i2] = this._buffer[this._bufpos++]; - } - return out; - }; - HKDF2.prototype.clean = function() { - this._hmac.clean(); - wipe_1.wipe(this._buffer); - wipe_1.wipe(this._counter); - this._bufpos = 0; - }; - return HKDF2; - }() - ); - var HKDF_1 = hkdf.HKDF = HKDF; - var sha256 = {}; - (function(exports22) { - Object.defineProperty(exports22, "__esModule", { value: true }); - var binary_12 = binary; - var wipe_12 = wipe$1; - exports22.DIGEST_LENGTH = 32; - exports22.BLOCK_SIZE = 64; - var SHA256 = ( - /** @class */ - function() { - function SHA2562() { - this.digestLength = exports22.DIGEST_LENGTH; - this.blockSize = exports22.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 = false; - this.reset(); + if (value === null) { + return encode2(key, options); } - SHA2562.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; - }; - SHA2562.prototype.reset = function() { - this._initState(); - this._bufferLength = 0; - this._bytesHashed = 0; - this._finished = false; - return this; - }; - SHA2562.prototype.clean = function() { - wipe_12.wipe(this._buffer); - wipe_12.wipe(this._temp); - this.reset(); - }; - SHA2562.prototype.update = function(data2, dataLength) { - if (dataLength === void 0) { - dataLength = data2.length; - } - if (this._finished) { - throw new Error("SHA256: can't update because hash was finished."); - } - var dataPos = 0; - this._bytesHashed += dataLength; - if (this._bufferLength > 0) { - while (this._bufferLength < this.blockSize && dataLength > 0) { - this._buffer[this._bufferLength++] = data2[dataPos++]; - dataLength--; - } - if (this._bufferLength === this.blockSize) { - hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); - this._bufferLength = 0; - } - } - if (dataLength >= this.blockSize) { - dataPos = hashBlocks(this._temp, this._state, data2, dataPos, dataLength); - dataLength %= this.blockSize; - } - while (dataLength > 0) { - this._buffer[this._bufferLength++] = data2[dataPos++]; - dataLength--; - } - return this; - }; - SHA2562.prototype.finish = function(out) { - if (!this._finished) { - var bytesHashed = this._bytesHashed; - var left = this._bufferLength; - var bitLenHi = bytesHashed / 536870912 | 0; - var bitLenLo = bytesHashed << 3; - var padLength = bytesHashed % 64 < 56 ? 64 : 128; - this._buffer[left] = 128; - for (var i2 = left + 1; i2 < padLength - 8; i2++) { - this._buffer[i2] = 0; - } - binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); - binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); - hashBlocks(this._temp, this._state, this._buffer, 0, padLength); - this._finished = true; - } - for (var i2 = 0; i2 < this.digestLength / 4; i2++) { - binary_12.writeUint32BE(this._state[i2], out, i2 * 4); - } - return this; - }; - SHA2562.prototype.digest = function() { - var out = new Uint8Array(this.digestLength); - this.finish(out); - return out; - }; - SHA2562.prototype.saveState = function() { - if (this._finished) { - throw new Error("SHA256: cannot save finished state"); - } - return { - state: new Int32Array(this._state), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed - }; - }; - SHA2562.prototype.restoreState = function(savedState) { - this._state.set(savedState.state); - this._bufferLength = savedState.bufferLength; - if (savedState.buffer) { - this._buffer.set(savedState.buffer); - } - this._bytesHashed = savedState.bytesHashed; - this._finished = false; - return this; - }; - SHA2562.prototype.cleanSavedState = function(savedState) { - wipe_12.wipe(savedState.state); - if (savedState.buffer) { - wipe_12.wipe(savedState.buffer); + if (Array.isArray(value)) { + if (value.length === 0 && options.arrayFormat === "bracket-separator") { + return encode2(key, options) + "[]"; } - savedState.bufferLength = 0; - savedState.bytesHashed = 0; - }; - return SHA2562; - }() - ); - exports22.SHA256 = SHA256; - var K2 = 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 hashBlocks(w3, v3, p3, pos, len) { - while (len >= 64) { - var a3 = v3[0]; - var b3 = v3[1]; - var c2 = v3[2]; - var d3 = v3[3]; - var e2 = v3[4]; - var f2 = v3[5]; - var g3 = v3[6]; - var h4 = v3[7]; - for (var i2 = 0; i2 < 16; i2++) { - var j2 = pos + i2 * 4; - w3[i2] = binary_12.readUint32BE(p3, j2); - } - for (var i2 = 16; i2 < 64; i2++) { - var u3 = w3[i2 - 2]; - var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; - u3 = w3[i2 - 15]; - var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; - w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); - } - for (var i2 = 0; i2 < 64; i2++) { - var t1 = (((e2 >>> 6 | e2 << 32 - 6) ^ (e2 >>> 11 | e2 << 32 - 11) ^ (e2 >>> 25 | e2 << 32 - 25)) + (e2 & f2 ^ ~e2 & g3) | 0) + (h4 + (K2[i2] + w3[i2] | 0) | 0) | 0; - var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; - h4 = g3; - g3 = f2; - f2 = e2; - e2 = d3 + t1 | 0; - d3 = c2; - c2 = b3; - b3 = a3; - a3 = t1 + t2 | 0; + return value.reduce(formatter(key), []).join("&"); } - v3[0] += a3; - v3[1] += b3; - v3[2] += c2; - v3[3] += d3; - v3[4] += e2; - v3[5] += f2; - v3[6] += g3; - v3[7] += h4; - pos += 64; - len -= 64; - } - return pos; - } - function hash2(data2) { - var h4 = new SHA256(); - h4.update(data2); - var digest = h4.digest(); - h4.clean(); - return digest; - } - exports22.hash = hash2; - })(sha256); - var x25519 = {}; - (function(exports22) { - Object.defineProperty(exports22, "__esModule", { value: true }); - exports22.sharedKey = exports22.generateKeyPair = exports22.generateKeyPairFromSeed = exports22.scalarMultBase = exports22.scalarMult = exports22.SHARED_KEY_LENGTH = exports22.SECRET_KEY_LENGTH = exports22.PUBLIC_KEY_LENGTH = void 0; - const random_1 = random; - const wipe_12 = wipe$1; - exports22.PUBLIC_KEY_LENGTH = 32; - exports22.SECRET_KEY_LENGTH = 32; - exports22.SHARED_KEY_LENGTH = 32; - function gf(init) { - const r2 = new Float64Array(16); - if (init) { - for (let i2 = 0; i2 < init.length; i2++) { - r2[i2] = init[i2]; - } - } - return r2; - } - const _9 = new Uint8Array(32); - _9[0] = 9; - const _121665 = gf([56129, 1]); - function car25519(o22) { - let c2 = 1; - for (let i2 = 0; i2 < 16; i2++) { - let v3 = o22[i2] + c2 + 65535; - c2 = Math.floor(v3 / 65536); - o22[i2] = v3 - c2 * 65536; + return encode2(key, options) + "=" + encode2(value, options); + }).filter((x2) => x2.length > 0).join("&"); + }; + exports22.parseUrl = (url, options) => { + options = Object.assign({ + decode: true + }, options); + const [url_, hash2] = splitOnFirst$1(url, "#"); + return Object.assign( + { + url: url_.split("?")[0] || "", + query: parse(extract(url), options) + }, + options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} + ); + }; + exports22.stringifyUrl = (object, options) => { + options = Object.assign({ + encode: true, + strict: true, + [encodeFragmentIdentifier]: true + }, options); + const url = removeHash(object.url).split("?")[0] || ""; + const queryFromUrl = exports22.extract(object.url); + const parsedQueryFromUrl = exports22.parse(queryFromUrl, { sort: false }); + const query = Object.assign(parsedQueryFromUrl, object.query); + let queryString2 = exports22.stringify(query, options); + if (queryString2) { + queryString2 = `?${queryString2}`; } - o22[0] += c2 - 1 + 37 * (c2 - 1); - } - function sel25519(p3, q2, b3) { - const c2 = ~(b3 - 1); - for (let i2 = 0; i2 < 16; i2++) { - const t2 = c2 & (p3[i2] ^ q2[i2]); - p3[i2] ^= t2; - q2[i2] ^= t2; + let hash2 = getHash(object.url); + if (object.fragmentIdentifier) { + hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; } + return `${url}${queryString2}${hash2}`; + }; + exports22.pick = (input, filter, options) => { + options = Object.assign({ + parseFragmentIdentifier: true, + [encodeFragmentIdentifier]: false + }, options); + const { url, query, fragmentIdentifier } = exports22.parseUrl(input, options); + return exports22.stringifyUrl({ + url, + query: filterObject(query, filter), + fragmentIdentifier + }, options); + }; + exports22.exclude = (input, filter, options) => { + const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); + return exports22.pick(input, exclusionFilter, options); + }; + })(queryString); + var chacha20poly1305 = {}; + var chacha = {}; + Object.defineProperty(chacha, "__esModule", { value: true }); + var binary_1 = binary; + var wipe_1$2 = wipe$1; + var ROUNDS = 20; + function core(out, input, key) { + var j02 = 1634760805; + var j1 = 857760878; + var j2 = 2036477234; + var j3 = 1797285236; + var j4 = key[3] << 24 | key[2] << 16 | key[1] << 8 | key[0]; + var j5 = key[7] << 24 | key[6] << 16 | key[5] << 8 | key[4]; + var j6 = key[11] << 24 | key[10] << 16 | key[9] << 8 | key[8]; + var j7 = key[15] << 24 | key[14] << 16 | key[13] << 8 | key[12]; + var j8 = key[19] << 24 | key[18] << 16 | key[17] << 8 | key[16]; + var j9 = key[23] << 24 | key[22] << 16 | key[21] << 8 | key[20]; + var j10 = key[27] << 24 | key[26] << 16 | key[25] << 8 | key[24]; + var j11 = key[31] << 24 | key[30] << 16 | key[29] << 8 | key[28]; + var j12 = input[3] << 24 | input[2] << 16 | input[1] << 8 | input[0]; + var j13 = input[7] << 24 | input[6] << 16 | input[5] << 8 | input[4]; + var j14 = input[11] << 24 | input[10] << 16 | input[9] << 8 | input[8]; + var j15 = input[15] << 24 | input[14] << 16 | input[13] << 8 | input[12]; + var x02 = j02; + var x1 = j1; + var x2 = j2; + var x3 = j3; + var x4 = j4; + var x5 = j5; + var x6 = j6; + var x7 = j7; + var x8 = j8; + var x9 = j9; + var x10 = j10; + var x11 = j11; + var x12 = j12; + var x13 = j13; + var x14 = j14; + var x15 = j15; + for (var i2 = 0; i2 < ROUNDS; i2 += 2) { + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 16 | x12 << 16; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 12 | x4 << 12; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 16 | x13 << 16; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 12 | x5 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 16 | x14 << 16; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 12 | x6 << 12; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 16 | x15 << 16; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 12 | x7 << 12; + x2 = x2 + x6 | 0; + x14 ^= x2; + x14 = x14 >>> 32 - 8 | x14 << 8; + x10 = x10 + x14 | 0; + x6 ^= x10; + x6 = x6 >>> 32 - 7 | x6 << 7; + x3 = x3 + x7 | 0; + x15 ^= x3; + x15 = x15 >>> 32 - 8 | x15 << 8; + x11 = x11 + x15 | 0; + x7 ^= x11; + x7 = x7 >>> 32 - 7 | x7 << 7; + x1 = x1 + x5 | 0; + x13 ^= x1; + x13 = x13 >>> 32 - 8 | x13 << 8; + x9 = x9 + x13 | 0; + x5 ^= x9; + x5 = x5 >>> 32 - 7 | x5 << 7; + x02 = x02 + x4 | 0; + x12 ^= x02; + x12 = x12 >>> 32 - 8 | x12 << 8; + x8 = x8 + x12 | 0; + x4 ^= x8; + x4 = x4 >>> 32 - 7 | x4 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 16 | x15 << 16; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 12 | x5 << 12; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 16 | x12 << 16; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 12 | x6 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 16 | x13 << 16; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 12 | x7 << 12; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 16 | x14 << 16; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 12 | x4 << 12; + x2 = x2 + x7 | 0; + x13 ^= x2; + x13 = x13 >>> 32 - 8 | x13 << 8; + x8 = x8 + x13 | 0; + x7 ^= x8; + x7 = x7 >>> 32 - 7 | x7 << 7; + x3 = x3 + x4 | 0; + x14 ^= x3; + x14 = x14 >>> 32 - 8 | x14 << 8; + x9 = x9 + x14 | 0; + x4 ^= x9; + x4 = x4 >>> 32 - 7 | x4 << 7; + x1 = x1 + x6 | 0; + x12 ^= x1; + x12 = x12 >>> 32 - 8 | x12 << 8; + x11 = x11 + x12 | 0; + x6 ^= x11; + x6 = x6 >>> 32 - 7 | x6 << 7; + x02 = x02 + x5 | 0; + x15 ^= x02; + x15 = x15 >>> 32 - 8 | x15 << 8; + x10 = x10 + x15 | 0; + x5 ^= x10; + x5 = x5 >>> 32 - 7 | x5 << 7; } - function pack25519(o22, n3) { - const m2 = gf(); - const t2 = gf(); - for (let i2 = 0; i2 < 16; i2++) { - t2[i2] = n3[i2]; - } - car25519(t2); - car25519(t2); - car25519(t2); - for (let j2 = 0; j2 < 2; j2++) { - m2[0] = t2[0] - 65517; - for (let i2 = 1; i2 < 15; i2++) { - m2[i2] = t2[i2] - 65535 - (m2[i2 - 1] >> 16 & 1); - m2[i2 - 1] &= 65535; - } - m2[15] = t2[15] - 32767 - (m2[14] >> 16 & 1); - const b3 = m2[15] >> 16 & 1; - m2[14] &= 65535; - sel25519(t2, m2, 1 - b3); - } - for (let i2 = 0; i2 < 16; i2++) { - o22[2 * i2] = t2[i2] & 255; - o22[2 * i2 + 1] = t2[i2] >> 8; - } + binary_1.writeUint32LE(x02 + j02 | 0, out, 0); + binary_1.writeUint32LE(x1 + j1 | 0, out, 4); + binary_1.writeUint32LE(x2 + j2 | 0, out, 8); + binary_1.writeUint32LE(x3 + j3 | 0, out, 12); + binary_1.writeUint32LE(x4 + j4 | 0, out, 16); + binary_1.writeUint32LE(x5 + j5 | 0, out, 20); + binary_1.writeUint32LE(x6 + j6 | 0, out, 24); + binary_1.writeUint32LE(x7 + j7 | 0, out, 28); + binary_1.writeUint32LE(x8 + j8 | 0, out, 32); + binary_1.writeUint32LE(x9 + j9 | 0, out, 36); + binary_1.writeUint32LE(x10 + j10 | 0, out, 40); + binary_1.writeUint32LE(x11 + j11 | 0, out, 44); + binary_1.writeUint32LE(x12 + j12 | 0, out, 48); + binary_1.writeUint32LE(x13 + j13 | 0, out, 52); + binary_1.writeUint32LE(x14 + j14 | 0, out, 56); + binary_1.writeUint32LE(x15 + j15 | 0, out, 60); + } + function streamXOR(key, nonce, src2, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; } - function unpack25519(o22, n3) { - for (let i2 = 0; i2 < 16; i2++) { - o22[i2] = n3[2 * i2] + (n3[2 * i2 + 1] << 8); - } - o22[15] &= 32767; + if (key.length !== 32) { + throw new Error("ChaCha: key size must be 32 bytes"); } - function add(o22, a3, b3) { - for (let i2 = 0; i2 < 16; i2++) { - o22[i2] = a3[i2] + b3[i2]; - } + if (dst.length < src2.length) { + throw new Error("ChaCha: destination is shorter than source"); } - function sub(o22, a3, b3) { + var nc; + var counterLength; + if (nonceInplaceCounterLength === 0) { + if (nonce.length !== 8 && nonce.length !== 12) { + throw new Error("ChaCha nonce must be 8 or 12 bytes"); + } + nc = new Uint8Array(16); + counterLength = nc.length - nonce.length; + nc.set(nonce, counterLength); + } else { + if (nonce.length !== 16) { + throw new Error("ChaCha nonce with counter must be 16 bytes"); + } + nc = nonce; + counterLength = nonceInplaceCounterLength; + } + var block = new Uint8Array(64); + for (var i2 = 0; i2 < src2.length; i2 += 64) { + core(block, nc, key); + for (var j2 = i2; j2 < i2 + 64 && j2 < src2.length; j2++) { + dst[j2] = src2[j2] ^ block[j2 - i2]; + } + incrementCounter(nc, 0, counterLength); + } + wipe_1$2.wipe(block); + if (nonceInplaceCounterLength === 0) { + wipe_1$2.wipe(nc); + } + return dst; + } + chacha.streamXOR = streamXOR; + function stream(key, nonce, dst, nonceInplaceCounterLength) { + if (nonceInplaceCounterLength === void 0) { + nonceInplaceCounterLength = 0; + } + wipe_1$2.wipe(dst); + return streamXOR(key, nonce, dst, dst, nonceInplaceCounterLength); + } + chacha.stream = stream; + function incrementCounter(counter, pos, len) { + var carry = 1; + while (len--) { + carry = carry + (counter[pos] & 255) | 0; + counter[pos] = carry & 255; + carry >>>= 8; + pos++; + } + if (carry > 0) { + throw new Error("ChaCha: counter overflow"); + } + } + var poly1305 = {}; + var constantTime = {}; + Object.defineProperty(constantTime, "__esModule", { value: true }); + function select(subject, resultIfOne, resultIfZero) { + return ~(subject - 1) & resultIfOne | subject - 1 & resultIfZero; + } + constantTime.select = select; + function lessOrEqual(a3, b3) { + return (a3 | 0) - (b3 | 0) - 1 >>> 31 & 1; + } + constantTime.lessOrEqual = lessOrEqual; + function compare(a3, b3) { + if (a3.length !== b3.length) { + return 0; + } + var result = 0; + for (var i2 = 0; i2 < a3.length; i2++) { + result |= a3[i2] ^ b3[i2]; + } + return 1 & result - 1 >>> 8; + } + constantTime.compare = compare; + function equal(a3, b3) { + if (a3.length === 0 || b3.length === 0) { + return false; + } + return compare(a3, b3) !== 0; + } + constantTime.equal = equal; + (function(exports22) { + Object.defineProperty(exports22, "__esModule", { value: true }); + var constant_time_12 = constantTime; + var wipe_12 = wipe$1; + exports22.DIGEST_LENGTH = 16; + var Poly1305 = ( + /** @class */ + function() { + function Poly13052(key) { + this.digestLength = exports22.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 = false; + var t0 = key[0] | key[1] << 8; + this._r[0] = t0 & 8191; + var t1 = key[2] | key[3] << 8; + this._r[1] = (t0 >>> 13 | t1 << 3) & 8191; + var t2 = key[4] | key[5] << 8; + this._r[2] = (t1 >>> 10 | t2 << 6) & 7939; + var t3 = key[6] | key[7] << 8; + this._r[3] = (t2 >>> 7 | t3 << 9) & 8191; + var t4 = key[8] | key[9] << 8; + this._r[4] = (t3 >>> 4 | t4 << 12) & 255; + this._r[5] = t4 >>> 1 & 8190; + var t5 = key[10] | key[11] << 8; + this._r[6] = (t4 >>> 14 | t5 << 2) & 8191; + var t6 = key[12] | key[13] << 8; + this._r[7] = (t5 >>> 11 | t6 << 5) & 8065; + var t7 = key[14] | key[15] << 8; + this._r[8] = (t6 >>> 8 | t7 << 8) & 8191; + this._r[9] = t7 >>> 5 & 127; + this._pad[0] = key[16] | key[17] << 8; + this._pad[1] = key[18] | key[19] << 8; + this._pad[2] = key[20] | key[21] << 8; + this._pad[3] = key[22] | key[23] << 8; + this._pad[4] = key[24] | key[25] << 8; + this._pad[5] = key[26] | key[27] << 8; + this._pad[6] = key[28] | key[29] << 8; + this._pad[7] = key[30] | key[31] << 8; + } + Poly13052.prototype._blocks = function(m3, mpos, bytes) { + var hibit = this._fin ? 0 : 1 << 11; + var h02 = this._h[0], h1 = this._h[1], h22 = this._h[2], h32 = this._h[3], h4 = this._h[4], h5 = this._h[5], h6 = this._h[6], h7 = this._h[7], h8 = this._h[8], h9 = this._h[9]; + var r0 = this._r[0], r1 = this._r[1], r22 = this._r[2], r3 = this._r[3], r4 = this._r[4], r5 = this._r[5], r6 = this._r[6], r7 = this._r[7], r8 = this._r[8], r9 = this._r[9]; + while (bytes >= 16) { + var t0 = m3[mpos + 0] | m3[mpos + 1] << 8; + h02 += t0 & 8191; + var t1 = m3[mpos + 2] | m3[mpos + 3] << 8; + h1 += (t0 >>> 13 | t1 << 3) & 8191; + var t2 = m3[mpos + 4] | m3[mpos + 5] << 8; + h22 += (t1 >>> 10 | t2 << 6) & 8191; + var t3 = m3[mpos + 6] | m3[mpos + 7] << 8; + h32 += (t2 >>> 7 | t3 << 9) & 8191; + var t4 = m3[mpos + 8] | m3[mpos + 9] << 8; + h4 += (t3 >>> 4 | t4 << 12) & 8191; + h5 += t4 >>> 1 & 8191; + var t5 = m3[mpos + 10] | m3[mpos + 11] << 8; + h6 += (t4 >>> 14 | t5 << 2) & 8191; + var t6 = m3[mpos + 12] | m3[mpos + 13] << 8; + h7 += (t5 >>> 11 | t6 << 5) & 8191; + var t7 = m3[mpos + 14] | m3[mpos + 15] << 8; + h8 += (t6 >>> 8 | t7 << 8) & 8191; + h9 += t7 >>> 5 | hibit; + var c2 = 0; + var d02 = c2; + d02 += h02 * r0; + d02 += h1 * (5 * r9); + d02 += h22 * (5 * r8); + d02 += h32 * (5 * r7); + d02 += h4 * (5 * r6); + c2 = d02 >>> 13; + d02 &= 8191; + d02 += h5 * (5 * r5); + d02 += h6 * (5 * r4); + d02 += h7 * (5 * r3); + d02 += h8 * (5 * r22); + d02 += h9 * (5 * r1); + c2 += d02 >>> 13; + d02 &= 8191; + var d1 = c2; + d1 += h02 * r1; + d1 += h1 * r0; + d1 += h22 * (5 * r9); + d1 += h32 * (5 * r8); + d1 += h4 * (5 * r7); + c2 = d1 >>> 13; + d1 &= 8191; + d1 += h5 * (5 * r6); + d1 += h6 * (5 * r5); + d1 += h7 * (5 * r4); + d1 += h8 * (5 * r3); + d1 += h9 * (5 * r22); + c2 += d1 >>> 13; + d1 &= 8191; + var d22 = c2; + d22 += h02 * r22; + d22 += h1 * r1; + d22 += h22 * r0; + d22 += h32 * (5 * r9); + d22 += h4 * (5 * r8); + c2 = d22 >>> 13; + d22 &= 8191; + d22 += h5 * (5 * r7); + d22 += h6 * (5 * r6); + d22 += h7 * (5 * r5); + d22 += h8 * (5 * r4); + d22 += h9 * (5 * r3); + c2 += d22 >>> 13; + d22 &= 8191; + var d32 = c2; + d32 += h02 * r3; + d32 += h1 * r22; + d32 += h22 * r1; + d32 += h32 * r0; + d32 += h4 * (5 * r9); + c2 = d32 >>> 13; + d32 &= 8191; + d32 += h5 * (5 * r8); + d32 += h6 * (5 * r7); + d32 += h7 * (5 * r6); + d32 += h8 * (5 * r5); + d32 += h9 * (5 * r4); + c2 += d32 >>> 13; + d32 &= 8191; + var d42 = c2; + d42 += h02 * r4; + d42 += h1 * r3; + d42 += h22 * r22; + d42 += h32 * r1; + d42 += h4 * r0; + c2 = d42 >>> 13; + d42 &= 8191; + d42 += h5 * (5 * r9); + d42 += h6 * (5 * r8); + d42 += h7 * (5 * r7); + d42 += h8 * (5 * r6); + d42 += h9 * (5 * r5); + c2 += d42 >>> 13; + d42 &= 8191; + var d5 = c2; + d5 += h02 * r5; + d5 += h1 * r4; + d5 += h22 * r3; + d5 += h32 * r22; + d5 += h4 * r1; + c2 = d5 >>> 13; + d5 &= 8191; + d5 += h5 * r0; + d5 += h6 * (5 * r9); + d5 += h7 * (5 * r8); + d5 += h8 * (5 * r7); + d5 += h9 * (5 * r6); + c2 += d5 >>> 13; + d5 &= 8191; + var d6 = c2; + d6 += h02 * r6; + d6 += h1 * r5; + d6 += h22 * r4; + d6 += h32 * r3; + d6 += h4 * r22; + c2 = d6 >>> 13; + d6 &= 8191; + d6 += h5 * r1; + d6 += h6 * r0; + d6 += h7 * (5 * r9); + d6 += h8 * (5 * r8); + d6 += h9 * (5 * r7); + c2 += d6 >>> 13; + d6 &= 8191; + var d7 = c2; + d7 += h02 * r7; + d7 += h1 * r6; + d7 += h22 * r5; + d7 += h32 * r4; + d7 += h4 * r3; + c2 = d7 >>> 13; + d7 &= 8191; + d7 += h5 * r22; + d7 += h6 * r1; + d7 += h7 * r0; + d7 += h8 * (5 * r9); + d7 += h9 * (5 * r8); + c2 += d7 >>> 13; + d7 &= 8191; + var d8 = c2; + d8 += h02 * r8; + d8 += h1 * r7; + d8 += h22 * r6; + d8 += h32 * r5; + d8 += h4 * r4; + c2 = d8 >>> 13; + d8 &= 8191; + d8 += h5 * r3; + d8 += h6 * r22; + d8 += h7 * r1; + d8 += h8 * r0; + d8 += h9 * (5 * r9); + c2 += d8 >>> 13; + d8 &= 8191; + var d9 = c2; + d9 += h02 * r9; + d9 += h1 * r8; + d9 += h22 * r7; + d9 += h32 * r6; + d9 += h4 * r5; + c2 = d9 >>> 13; + d9 &= 8191; + d9 += h5 * r4; + d9 += h6 * r3; + d9 += h7 * r22; + d9 += h8 * r1; + d9 += h9 * r0; + c2 += d9 >>> 13; + d9 &= 8191; + c2 = (c2 << 2) + c2 | 0; + c2 = c2 + d02 | 0; + d02 = c2 & 8191; + c2 = c2 >>> 13; + d1 += c2; + h02 = d02; + h1 = d1; + h22 = d22; + h32 = d32; + h4 = d42; + h5 = d5; + h6 = d6; + h7 = d7; + h8 = d8; + h9 = d9; + mpos += 16; + bytes -= 16; + } + this._h[0] = h02; + this._h[1] = h1; + this._h[2] = h22; + this._h[3] = h32; + this._h[4] = h4; + this._h[5] = h5; + this._h[6] = h6; + this._h[7] = h7; + this._h[8] = h8; + this._h[9] = h9; + }; + Poly13052.prototype.finish = function(mac, macpos) { + if (macpos === void 0) { + macpos = 0; + } + var g3 = new Uint16Array(10); + var c2; + var mask; + var f3; + var i2; + if (this._leftover) { + i2 = this._leftover; + this._buffer[i2++] = 1; + for (; i2 < 16; i2++) { + this._buffer[i2] = 0; + } + this._fin = 1; + this._blocks(this._buffer, 0, 16); + } + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + for (i2 = 2; i2 < 10; i2++) { + this._h[i2] += c2; + c2 = this._h[i2] >>> 13; + this._h[i2] &= 8191; + } + this._h[0] += c2 * 5; + c2 = this._h[0] >>> 13; + this._h[0] &= 8191; + this._h[1] += c2; + c2 = this._h[1] >>> 13; + this._h[1] &= 8191; + this._h[2] += c2; + g3[0] = this._h[0] + 5; + c2 = g3[0] >>> 13; + g3[0] &= 8191; + for (i2 = 1; i2 < 10; i2++) { + g3[i2] = this._h[i2] + c2; + c2 = g3[i2] >>> 13; + g3[i2] &= 8191; + } + g3[9] -= 1 << 13; + mask = (c2 ^ 1) - 1; + for (i2 = 0; i2 < 10; i2++) { + g3[i2] &= mask; + } + mask = ~mask; + for (i2 = 0; i2 < 10; i2++) { + this._h[i2] = this._h[i2] & mask | g3[i2]; + } + 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; + f3 = this._h[0] + this._pad[0]; + this._h[0] = f3 & 65535; + for (i2 = 1; i2 < 8; i2++) { + f3 = (this._h[i2] + this._pad[i2] | 0) + (f3 >>> 16) | 0; + this._h[i2] = f3 & 65535; + } + mac[macpos + 0] = this._h[0] >>> 0; + mac[macpos + 1] = this._h[0] >>> 8; + mac[macpos + 2] = this._h[1] >>> 0; + mac[macpos + 3] = this._h[1] >>> 8; + mac[macpos + 4] = this._h[2] >>> 0; + mac[macpos + 5] = this._h[2] >>> 8; + mac[macpos + 6] = this._h[3] >>> 0; + mac[macpos + 7] = this._h[3] >>> 8; + mac[macpos + 8] = this._h[4] >>> 0; + mac[macpos + 9] = this._h[4] >>> 8; + mac[macpos + 10] = this._h[5] >>> 0; + mac[macpos + 11] = this._h[5] >>> 8; + mac[macpos + 12] = this._h[6] >>> 0; + mac[macpos + 13] = this._h[6] >>> 8; + mac[macpos + 14] = this._h[7] >>> 0; + mac[macpos + 15] = this._h[7] >>> 8; + this._finished = true; + return this; + }; + Poly13052.prototype.update = function(m3) { + var mpos = 0; + var bytes = m3.length; + var want; + if (this._leftover) { + want = 16 - this._leftover; + if (want > bytes) { + want = bytes; + } + for (var i2 = 0; i2 < want; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + bytes -= want; + mpos += want; + this._leftover += want; + if (this._leftover < 16) { + return this; + } + this._blocks(this._buffer, 0, 16); + this._leftover = 0; + } + if (bytes >= 16) { + want = bytes - bytes % 16; + this._blocks(m3, mpos, want); + mpos += want; + bytes -= want; + } + if (bytes) { + for (var i2 = 0; i2 < bytes; i2++) { + this._buffer[this._leftover + i2] = m3[mpos + i2]; + } + this._leftover += bytes; + } + return this; + }; + Poly13052.prototype.digest = function() { + if (this._finished) { + throw new Error("Poly1305 was finished"); + } + var mac = new Uint8Array(16); + this.finish(mac); + return mac; + }; + Poly13052.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._r); + wipe_12.wipe(this._h); + wipe_12.wipe(this._pad); + this._leftover = 0; + this._fin = 0; + this._finished = true; + return this; + }; + return Poly13052; + }() + ); + exports22.Poly1305 = Poly1305; + function oneTimeAuth(key, data2) { + var h4 = new Poly1305(key); + h4.update(data2); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports22.oneTimeAuth = oneTimeAuth; + function equal2(a3, b3) { + if (a3.length !== exports22.DIGEST_LENGTH || b3.length !== exports22.DIGEST_LENGTH) { + return false; + } + return constant_time_12.equal(a3, b3); + } + exports22.equal = equal2; + })(poly1305); + (function(exports22) { + Object.defineProperty(exports22, "__esModule", { value: true }); + var chacha_1 = chacha; + var poly1305_1 = poly1305; + var wipe_12 = wipe$1; + var binary_12 = binary; + var constant_time_12 = constantTime; + exports22.KEY_LENGTH = 32; + exports22.NONCE_LENGTH = 12; + exports22.TAG_LENGTH = 16; + var ZEROS = new Uint8Array(16); + var ChaCha20Poly1305 = ( + /** @class */ + function() { + function ChaCha20Poly13052(key) { + this.nonceLength = exports22.NONCE_LENGTH; + this.tagLength = exports22.TAG_LENGTH; + if (key.length !== exports22.KEY_LENGTH) { + throw new Error("ChaCha20Poly1305 needs 32-byte key"); + } + this._key = new Uint8Array(key); + } + ChaCha20Poly13052.prototype.seal = function(nonce, plaintext, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var resultLength = plaintext.length + this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, plaintext, result, 4); + this._authenticate(result.subarray(result.length - this.tagLength, result.length), authKey, result.subarray(0, result.length - this.tagLength), associatedData); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.open = function(nonce, sealed, associatedData, dst) { + if (nonce.length > 16) { + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + } + if (sealed.length < this.tagLength) { + return null; + } + var counter = new Uint8Array(16); + counter.set(nonce, counter.length - nonce.length); + var authKey = new Uint8Array(32); + chacha_1.stream(this._key, counter, authKey, 4); + var calculatedTag = new Uint8Array(this.tagLength); + this._authenticate(calculatedTag, authKey, sealed.subarray(0, sealed.length - this.tagLength), associatedData); + if (!constant_time_12.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) { + return null; + } + var resultLength = sealed.length - this.tagLength; + var result; + if (dst) { + if (dst.length !== resultLength) { + throw new Error("ChaCha20Poly1305: incorrect destination length"); + } + result = dst; + } else { + result = new Uint8Array(resultLength); + } + chacha_1.streamXOR(this._key, counter, sealed.subarray(0, sealed.length - this.tagLength), result, 4); + wipe_12.wipe(counter); + return result; + }; + ChaCha20Poly13052.prototype.clean = function() { + wipe_12.wipe(this._key); + return this; + }; + ChaCha20Poly13052.prototype._authenticate = function(tagOut, authKey, ciphertext, associatedData) { + var h4 = new poly1305_1.Poly1305(authKey); + if (associatedData) { + h4.update(associatedData); + if (associatedData.length % 16 > 0) { + h4.update(ZEROS.subarray(associatedData.length % 16)); + } + } + h4.update(ciphertext); + if (ciphertext.length % 16 > 0) { + h4.update(ZEROS.subarray(ciphertext.length % 16)); + } + var length = new Uint8Array(8); + if (associatedData) { + binary_12.writeUint64LE(associatedData.length, length); + } + h4.update(length); + binary_12.writeUint64LE(ciphertext.length, length); + h4.update(length); + var tag = h4.digest(); + for (var i2 = 0; i2 < tag.length; i2++) { + tagOut[i2] = tag[i2]; + } + h4.clean(); + wipe_12.wipe(tag); + wipe_12.wipe(length); + }; + return ChaCha20Poly13052; + }() + ); + exports22.ChaCha20Poly1305 = ChaCha20Poly1305; + })(chacha20poly1305); + var hkdf = {}; + var hmac$1 = {}; + var hash = {}; + Object.defineProperty(hash, "__esModule", { value: true }); + function isSerializableHash(h4) { + return typeof h4.saveState !== "undefined" && typeof h4.restoreState !== "undefined" && typeof h4.cleanSavedState !== "undefined"; + } + hash.isSerializableHash = isSerializableHash; + Object.defineProperty(hmac$1, "__esModule", { value: true }); + var hash_1 = hash; + var constant_time_1 = constantTime; + var wipe_1$1 = wipe$1; + var HMAC = ( + /** @class */ + function() { + function HMAC2(hash2, key) { + this._finished = false; + this._inner = new hash2(); + this._outer = new hash2(); + this.blockSize = this._outer.blockSize; + this.digestLength = this._outer.digestLength; + var pad = new Uint8Array(this.blockSize); + if (key.length > this.blockSize) { + this._inner.update(key).finish(pad).clean(); + } else { + pad.set(key); + } + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54; + } + this._inner.update(pad); + for (var i2 = 0; i2 < pad.length; i2++) { + pad[i2] ^= 54 ^ 92; + } + this._outer.update(pad); + if (hash_1.isSerializableHash(this._inner) && hash_1.isSerializableHash(this._outer)) { + this._innerKeyedState = this._inner.saveState(); + this._outerKeyedState = this._outer.saveState(); + } + wipe_1$1.wipe(pad); + } + HMAC2.prototype.reset = function() { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); + } + this._inner.restoreState(this._innerKeyedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.clean = function() { + if (hash_1.isSerializableHash(this._inner)) { + this._inner.cleanSavedState(this._innerKeyedState); + } + if (hash_1.isSerializableHash(this._outer)) { + this._outer.cleanSavedState(this._outerKeyedState); + } + this._inner.clean(); + this._outer.clean(); + }; + HMAC2.prototype.update = function(data2) { + this._inner.update(data2); + return this; + }; + HMAC2.prototype.finish = function(out) { + if (this._finished) { + this._outer.finish(out); + return this; + } + this._inner.finish(out); + this._outer.update(out.subarray(0, this.digestLength)).finish(out); + this._finished = true; + return this; + }; + HMAC2.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + HMAC2.prototype.saveState = function() { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't saveState() because hash doesn't implement it"); + } + return this._inner.saveState(); + }; + HMAC2.prototype.restoreState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner) || !hash_1.isSerializableHash(this._outer)) { + throw new Error("hmac: can't restoreState() because hash doesn't implement it"); + } + this._inner.restoreState(savedState); + this._outer.restoreState(this._outerKeyedState); + this._finished = false; + return this; + }; + HMAC2.prototype.cleanSavedState = function(savedState) { + if (!hash_1.isSerializableHash(this._inner)) { + throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); + } + this._inner.cleanSavedState(savedState); + }; + return HMAC2; + }() + ); + hmac$1.HMAC = HMAC; + function hmac(hash2, key, data2) { + var h4 = new HMAC(hash2, key); + h4.update(data2); + var digest = h4.digest(); + h4.clean(); + return digest; + } + hmac$1.hmac = hmac; + hmac$1.equal = constant_time_1.equal; + Object.defineProperty(hkdf, "__esModule", { value: true }); + var hmac_1 = hmac$1; + var wipe_1 = wipe$1; + var HKDF = ( + /** @class */ + function() { + function HKDF2(hash2, key, salt, info) { + if (salt === void 0) { + salt = new Uint8Array(0); + } + this._counter = new Uint8Array(1); + this._hash = hash2; + this._info = info; + var okm = hmac_1.hmac(this._hash, salt, key); + this._hmac = new hmac_1.HMAC(hash2, okm); + this._buffer = new Uint8Array(this._hmac.digestLength); + this._bufpos = this._buffer.length; + } + HKDF2.prototype._fillBuffer = function() { + this._counter[0]++; + var ctr = this._counter[0]; + if (ctr === 0) { + throw new Error("hkdf: cannot expand more"); + } + this._hmac.reset(); + if (ctr > 1) { + this._hmac.update(this._buffer); + } + if (this._info) { + this._hmac.update(this._info); + } + this._hmac.update(this._counter); + this._hmac.finish(this._buffer); + this._bufpos = 0; + }; + HKDF2.prototype.expand = function(length) { + var out = new Uint8Array(length); + for (var i2 = 0; i2 < out.length; i2++) { + if (this._bufpos === this._buffer.length) { + this._fillBuffer(); + } + out[i2] = this._buffer[this._bufpos++]; + } + return out; + }; + HKDF2.prototype.clean = function() { + this._hmac.clean(); + wipe_1.wipe(this._buffer); + wipe_1.wipe(this._counter); + this._bufpos = 0; + }; + return HKDF2; + }() + ); + var HKDF_1 = hkdf.HKDF = HKDF; + var sha256 = {}; + (function(exports22) { + Object.defineProperty(exports22, "__esModule", { value: true }); + var binary_12 = binary; + var wipe_12 = wipe$1; + exports22.DIGEST_LENGTH = 32; + exports22.BLOCK_SIZE = 64; + var SHA256 = ( + /** @class */ + function() { + function SHA2562() { + this.digestLength = exports22.DIGEST_LENGTH; + this.blockSize = exports22.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 = false; + this.reset(); + } + SHA2562.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; + }; + SHA2562.prototype.reset = function() { + this._initState(); + this._bufferLength = 0; + this._bytesHashed = 0; + this._finished = false; + return this; + }; + SHA2562.prototype.clean = function() { + wipe_12.wipe(this._buffer); + wipe_12.wipe(this._temp); + this.reset(); + }; + SHA2562.prototype.update = function(data2, dataLength) { + if (dataLength === void 0) { + dataLength = data2.length; + } + if (this._finished) { + throw new Error("SHA256: can't update because hash was finished."); + } + var dataPos = 0; + this._bytesHashed += dataLength; + if (this._bufferLength > 0) { + while (this._bufferLength < this.blockSize && dataLength > 0) { + this._buffer[this._bufferLength++] = data2[dataPos++]; + dataLength--; + } + if (this._bufferLength === this.blockSize) { + hashBlocks(this._temp, this._state, this._buffer, 0, this.blockSize); + this._bufferLength = 0; + } + } + if (dataLength >= this.blockSize) { + dataPos = hashBlocks(this._temp, this._state, data2, dataPos, dataLength); + dataLength %= this.blockSize; + } + while (dataLength > 0) { + this._buffer[this._bufferLength++] = data2[dataPos++]; + dataLength--; + } + return this; + }; + SHA2562.prototype.finish = function(out) { + if (!this._finished) { + var bytesHashed = this._bytesHashed; + var left = this._bufferLength; + var bitLenHi = bytesHashed / 536870912 | 0; + var bitLenLo = bytesHashed << 3; + var padLength = bytesHashed % 64 < 56 ? 64 : 128; + this._buffer[left] = 128; + for (var i2 = left + 1; i2 < padLength - 8; i2++) { + this._buffer[i2] = 0; + } + binary_12.writeUint32BE(bitLenHi, this._buffer, padLength - 8); + binary_12.writeUint32BE(bitLenLo, this._buffer, padLength - 4); + hashBlocks(this._temp, this._state, this._buffer, 0, padLength); + this._finished = true; + } + for (var i2 = 0; i2 < this.digestLength / 4; i2++) { + binary_12.writeUint32BE(this._state[i2], out, i2 * 4); + } + return this; + }; + SHA2562.prototype.digest = function() { + var out = new Uint8Array(this.digestLength); + this.finish(out); + return out; + }; + SHA2562.prototype.saveState = function() { + if (this._finished) { + throw new Error("SHA256: cannot save finished state"); + } + return { + state: new Int32Array(this._state), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }; + SHA2562.prototype.restoreState = function(savedState) { + this._state.set(savedState.state); + this._bufferLength = savedState.bufferLength; + if (savedState.buffer) { + this._buffer.set(savedState.buffer); + } + this._bytesHashed = savedState.bytesHashed; + this._finished = false; + return this; + }; + SHA2562.prototype.cleanSavedState = function(savedState) { + wipe_12.wipe(savedState.state); + if (savedState.buffer) { + wipe_12.wipe(savedState.buffer); + } + savedState.bufferLength = 0; + savedState.bytesHashed = 0; + }; + return SHA2562; + }() + ); + exports22.SHA256 = SHA256; + var K3 = 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 hashBlocks(w3, v3, p2, pos, len) { + while (len >= 64) { + var a3 = v3[0]; + var b3 = v3[1]; + var c2 = v3[2]; + var d5 = v3[3]; + var e2 = v3[4]; + var f3 = v3[5]; + var g3 = v3[6]; + var h4 = v3[7]; + for (var i2 = 0; i2 < 16; i2++) { + var j2 = pos + i2 * 4; + w3[i2] = binary_12.readUint32BE(p2, j2); + } + for (var i2 = 16; i2 < 64; i2++) { + var u3 = w3[i2 - 2]; + var t1 = (u3 >>> 17 | u3 << 32 - 17) ^ (u3 >>> 19 | u3 << 32 - 19) ^ u3 >>> 10; + u3 = w3[i2 - 15]; + var t2 = (u3 >>> 7 | u3 << 32 - 7) ^ (u3 >>> 18 | u3 << 32 - 18) ^ u3 >>> 3; + w3[i2] = (t1 + w3[i2 - 7] | 0) + (t2 + w3[i2 - 16] | 0); + } + for (var i2 = 0; i2 < 64; i2++) { + var t1 = (((e2 >>> 6 | e2 << 32 - 6) ^ (e2 >>> 11 | e2 << 32 - 11) ^ (e2 >>> 25 | e2 << 32 - 25)) + (e2 & f3 ^ ~e2 & g3) | 0) + (h4 + (K3[i2] + w3[i2] | 0) | 0) | 0; + var t2 = ((a3 >>> 2 | a3 << 32 - 2) ^ (a3 >>> 13 | a3 << 32 - 13) ^ (a3 >>> 22 | a3 << 32 - 22)) + (a3 & b3 ^ a3 & c2 ^ b3 & c2) | 0; + h4 = g3; + g3 = f3; + f3 = e2; + e2 = d5 + t1 | 0; + d5 = c2; + c2 = b3; + b3 = a3; + a3 = t1 + t2 | 0; + } + v3[0] += a3; + v3[1] += b3; + v3[2] += c2; + v3[3] += d5; + v3[4] += e2; + v3[5] += f3; + v3[6] += g3; + v3[7] += h4; + pos += 64; + len -= 64; + } + return pos; + } + function hash2(data2) { + var h4 = new SHA256(); + h4.update(data2); + var digest = h4.digest(); + h4.clean(); + return digest; + } + exports22.hash = hash2; + })(sha256); + var x25519 = {}; + (function(exports22) { + Object.defineProperty(exports22, "__esModule", { value: true }); + exports22.sharedKey = exports22.generateKeyPair = exports22.generateKeyPairFromSeed = exports22.scalarMultBase = exports22.scalarMult = exports22.SHARED_KEY_LENGTH = exports22.SECRET_KEY_LENGTH = exports22.PUBLIC_KEY_LENGTH = void 0; + const random_1 = random; + const wipe_12 = wipe$1; + exports22.PUBLIC_KEY_LENGTH = 32; + exports22.SECRET_KEY_LENGTH = 32; + exports22.SHARED_KEY_LENGTH = 32; + function gf2(init) { + const r3 = new Float64Array(16); + if (init) { + for (let i2 = 0; i2 < init.length; i2++) { + r3[i2] = init[i2]; + } + } + return r3; + } + const _9 = new Uint8Array(32); + _9[0] = 9; + const _121665 = gf2([56129, 1]); + function car25519(o22) { + let c2 = 1; + for (let i2 = 0; i2 < 16; i2++) { + let v3 = o22[i2] + c2 + 65535; + c2 = Math.floor(v3 / 65536); + o22[i2] = v3 - c2 * 65536; + } + o22[0] += c2 - 1 + 37 * (c2 - 1); + } + function sel25519(p2, q2, b3) { + const c2 = ~(b3 - 1); + for (let i2 = 0; i2 < 16; i2++) { + const t2 = c2 & (p2[i2] ^ q2[i2]); + p2[i2] ^= t2; + q2[i2] ^= t2; + } + } + function pack25519(o22, n4) { + const m3 = gf2(); + const t2 = gf2(); + for (let i2 = 0; i2 < 16; i2++) { + t2[i2] = n4[i2]; + } + car25519(t2); + car25519(t2); + car25519(t2); + for (let j2 = 0; j2 < 2; j2++) { + m3[0] = t2[0] - 65517; + for (let i2 = 1; i2 < 15; i2++) { + m3[i2] = t2[i2] - 65535 - (m3[i2 - 1] >> 16 & 1); + m3[i2 - 1] &= 65535; + } + m3[15] = t2[15] - 32767 - (m3[14] >> 16 & 1); + const b3 = m3[15] >> 16 & 1; + m3[14] &= 65535; + sel25519(t2, m3, 1 - b3); + } + for (let i2 = 0; i2 < 16; i2++) { + o22[2 * i2] = t2[i2] & 255; + o22[2 * i2 + 1] = t2[i2] >> 8; + } + } + function unpack25519(o22, n4) { + for (let i2 = 0; i2 < 16; i2++) { + o22[i2] = n4[2 * i2] + (n4[2 * i2 + 1] << 8); + } + o22[15] &= 32767; + } + function add(o22, a3, b3) { + for (let i2 = 0; i2 < 16; i2++) { + o22[i2] = a3[i2] + b3[i2]; + } + } + function sub(o22, a3, b3) { for (let i2 = 0; i2 < 16; i2++) { o22[i2] = a3[i2] - b3[i2]; } } function mul(o22, a3, b3) { - let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; + let v3, c2, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b02 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15]; v3 = a3[0]; - t0 += v3 * b0; + t0 += v3 * b02; t1 += v3 * b1; t2 += v3 * b22; t3 += v3 * b32; @@ -7146,7 +7873,7 @@ t14 += v3 * b14; t15 += v3 * b15; v3 = a3[1]; - t1 += v3 * b0; + t1 += v3 * b02; t2 += v3 * b1; t3 += v3 * b22; t4 += v3 * b32; @@ -7163,7 +7890,7 @@ t15 += v3 * b14; t16 += v3 * b15; v3 = a3[2]; - t2 += v3 * b0; + t2 += v3 * b02; t3 += v3 * b1; t4 += v3 * b22; t5 += v3 * b32; @@ -7180,7 +7907,7 @@ t16 += v3 * b14; t17 += v3 * b15; v3 = a3[3]; - t3 += v3 * b0; + t3 += v3 * b02; t4 += v3 * b1; t5 += v3 * b22; t6 += v3 * b32; @@ -7197,7 +7924,7 @@ t17 += v3 * b14; t18 += v3 * b15; v3 = a3[4]; - t4 += v3 * b0; + t4 += v3 * b02; t5 += v3 * b1; t6 += v3 * b22; t7 += v3 * b32; @@ -7214,7 +7941,7 @@ t18 += v3 * b14; t19 += v3 * b15; v3 = a3[5]; - t5 += v3 * b0; + t5 += v3 * b02; t6 += v3 * b1; t7 += v3 * b22; t8 += v3 * b32; @@ -7231,7 +7958,7 @@ t19 += v3 * b14; t20 += v3 * b15; v3 = a3[6]; - t6 += v3 * b0; + t6 += v3 * b02; t7 += v3 * b1; t8 += v3 * b22; t9 += v3 * b32; @@ -7248,7 +7975,7 @@ t20 += v3 * b14; t21 += v3 * b15; v3 = a3[7]; - t7 += v3 * b0; + t7 += v3 * b02; t8 += v3 * b1; t9 += v3 * b22; t10 += v3 * b32; @@ -7265,7 +7992,7 @@ t21 += v3 * b14; t22 += v3 * b15; v3 = a3[8]; - t8 += v3 * b0; + t8 += v3 * b02; t9 += v3 * b1; t10 += v3 * b22; t11 += v3 * b32; @@ -7282,7 +8009,7 @@ t22 += v3 * b14; t23 += v3 * b15; v3 = a3[9]; - t9 += v3 * b0; + t9 += v3 * b02; t10 += v3 * b1; t11 += v3 * b22; t12 += v3 * b32; @@ -7299,7 +8026,7 @@ t23 += v3 * b14; t24 += v3 * b15; v3 = a3[10]; - t10 += v3 * b0; + t10 += v3 * b02; t11 += v3 * b1; t12 += v3 * b22; t13 += v3 * b32; @@ -7316,7 +8043,7 @@ t24 += v3 * b14; t25 += v3 * b15; v3 = a3[11]; - t11 += v3 * b0; + t11 += v3 * b02; t12 += v3 * b1; t13 += v3 * b22; t14 += v3 * b32; @@ -7333,7 +8060,7 @@ t25 += v3 * b14; t26 += v3 * b15; v3 = a3[12]; - t12 += v3 * b0; + t12 += v3 * b02; t13 += v3 * b1; t14 += v3 * b22; t15 += v3 * b32; @@ -7350,7 +8077,7 @@ t26 += v3 * b14; t27 += v3 * b15; v3 = a3[13]; - t13 += v3 * b0; + t13 += v3 * b02; t14 += v3 * b1; t15 += v3 * b22; t16 += v3 * b32; @@ -7367,7 +8094,7 @@ t27 += v3 * b14; t28 += v3 * b15; v3 = a3[14]; - t14 += v3 * b0; + t14 += v3 * b02; t15 += v3 * b1; t16 += v3 * b22; t17 += v3 * b32; @@ -7384,7 +8111,7 @@ t28 += v3 * b14; t29 += v3 * b15; v3 = a3[15]; - t15 += v3 * b0; + t15 += v3 * b02; t16 += v3 * b1; t17 += v3 * b22; t18 += v3 * b32; @@ -7536,7 +8263,7 @@ mul(o22, a3, a3); } function inv25519(o22, inp) { - const c2 = gf(); + const c2 = gf2(); for (let i2 = 0; i2 < 16; i2++) { c2[i2] = inp[i2]; } @@ -7550,50 +8277,50 @@ o22[i2] = c2[i2]; } } - function scalarMult(n3, p3) { - const z3 = new Uint8Array(32); + function scalarMult(n4, p2) { + const z2 = new Uint8Array(32); const x2 = new Float64Array(80); - const a3 = gf(), b3 = gf(), c2 = gf(), d3 = gf(), e2 = gf(), f2 = gf(); + const a3 = gf2(), b3 = gf2(), c2 = gf2(), d5 = gf2(), e2 = gf2(), f3 = gf2(); for (let i2 = 0; i2 < 31; i2++) { - z3[i2] = n3[i2]; + z2[i2] = n4[i2]; } - z3[31] = n3[31] & 127 | 64; - z3[0] &= 248; - unpack25519(x2, p3); + z2[31] = n4[31] & 127 | 64; + z2[0] &= 248; + unpack25519(x2, p2); for (let i2 = 0; i2 < 16; i2++) { b3[i2] = x2[i2]; } - a3[0] = d3[0] = 1; + a3[0] = d5[0] = 1; for (let i2 = 254; i2 >= 0; --i2) { - const r2 = z3[i2 >>> 3] >>> (i2 & 7) & 1; - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); + const r3 = z2[i2 >>> 3] >>> (i2 & 7) & 1; + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); add(e2, a3, c2); sub(a3, a3, c2); - add(c2, b3, d3); - sub(b3, b3, d3); - square(d3, e2); - square(f2, a3); + add(c2, b3, d5); + sub(b3, b3, d5); + square(d5, e2); + square(f3, a3); mul(a3, c2, a3); mul(c2, b3, e2); add(e2, a3, c2); sub(a3, a3, c2); square(b3, a3); - sub(c2, d3, f2); + sub(c2, d5, f3); mul(a3, c2, _121665); - add(a3, a3, d3); + add(a3, a3, d5); mul(c2, c2, a3); - mul(a3, d3, f2); - mul(d3, b3, x2); + mul(a3, d5, f3); + mul(d5, b3, x2); square(b3, e2); - sel25519(a3, b3, r2); - sel25519(c2, d3, r2); + sel25519(a3, b3, r3); + sel25519(c2, d5, r3); } for (let i2 = 0; i2 < 16; i2++) { x2[i2 + 16] = a3[i2]; x2[i2 + 32] = c2[i2]; x2[i2 + 48] = b3[i2]; - x2[i2 + 64] = d3[i2]; + x2[i2 + 64] = d5[i2]; } const x32 = x2.subarray(32); const x16 = x2.subarray(16); @@ -7604,8 +8331,8 @@ return q2; } exports22.scalarMult = scalarMult; - function scalarMultBase(n3) { - return scalarMult(n3, _9); + function scalarMultBase(n4) { + return scalarMult(n4, _9); } exports22.scalarMultBase = scalarMultBase; function generateKeyPairFromSeed(seed) { @@ -7640,1194 +8367,3978 @@ for (let i2 = 0; i2 < result.length; i2++) { zeros |= result[i2]; } - if (zeros === 0) { - throw new Error("X25519: invalid shared key"); - } - } - return result; - } - exports22.sharedKey = sharedKey; - })(x25519); - var __spreadArray$3 = function(to2, from2, pack) { - if (pack || arguments.length === 2) - for (var i2 = 0, l2 = from2.length, ar2; i2 < l2; i2++) { - if (ar2 || !(i2 in from2)) { - if (!ar2) - ar2 = Array.prototype.slice.call(from2, 0, i2); - ar2[i2] = from2[i2]; - } - } - return to2.concat(ar2 || Array.prototype.slice.call(from2)); - }; - var BrowserInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BrowserInfo2(name2, version2, os2) { - this.name = name2; - this.version = version2; - this.os = os2; - this.type = "browser"; - } - return BrowserInfo2; - }() - ); - var NodeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function NodeInfo2(version2) { - this.version = version2; - this.type = "node"; - this.name = "node"; - this.os = process.platform; - } - return NodeInfo2; - }() - ); - var SearchBotDeviceInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function SearchBotDeviceInfo2(name2, version2, os2, bot) { - this.name = name2; - this.version = version2; - this.os = os2; - this.bot = bot; - this.type = "bot-device"; - } - return SearchBotDeviceInfo2; - }() - ); - var BotInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function BotInfo2() { - this.type = "bot"; - this.bot = true; - this.name = "bot"; - this.version = null; - this.os = null; - } - return BotInfo2; - }() - ); - var ReactNativeInfo = ( - /** @class */ - /* @__PURE__ */ function() { - function ReactNativeInfo2() { - this.type = "react-native"; - this.name = "react-native"; - this.version = null; - this.os = null; - } - return ReactNativeInfo2; - }() - ); - var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; - var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; - var REQUIRED_VERSION_PARTS = 3; - var userAgentRules = [ - ["aol", /AOLShield\/([0-9\._]+)/], - ["edge", /Edge\/([0-9\._]+)/], - ["edge-ios", /EdgiOS\/([0-9\._]+)/], - ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], - ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], - ["samsung", /SamsungBrowser\/([0-9\.]+)/], - ["silk", /\bSilk\/([0-9._-]+)\b/], - ["miui", /MiuiBrowser\/([0-9\.]+)$/], - ["beaker", /BeakerBrowser\/([0-9\.]+)/], - ["edge-chromium", /EdgA?\/([0-9\.]+)/], - [ - "chromium-webview", - /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ - ], - ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], - ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], - ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], - ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], - ["fxios", /FxiOS\/([0-9\.]+)/], - ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], - ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], - ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], - ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], - ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], - ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], - ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], - ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], - ["ie", /MSIE\s(7\.0)/], - ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], - ["android", /Android\s([0-9\.]+)/], - ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], - ["safari", /Version\/([0-9\._]+).*Safari/], - ["facebook", /FB[AS]V\/([0-9\.]+)/], - ["instagram", /Instagram\s([0-9\.]+)/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], - ["curl", /^curl\/([0-9\.]+)$/], - ["searchbot", SEARCHBOX_UA_REGEX] - ]; - var operatingSystemRules = [ - ["iOS", /iP(hone|od|ad)/], - ["Android OS", /Android/], - ["BlackBerry OS", /BlackBerry|BB10/], - ["Windows Mobile", /IEMobile/], - ["Amazon OS", /Kindle/], - ["Windows 3.11", /Win16/], - ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], - ["Windows 98", /(Windows 98)|(Win98)/], - ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], - ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], - ["Windows Server 2003", /(Windows NT 5.2)/], - ["Windows Vista", /(Windows NT 6.0)/], - ["Windows 7", /(Windows NT 6.1)/], - ["Windows 8", /(Windows NT 6.2)/], - ["Windows 8.1", /(Windows NT 6.3)/], - ["Windows 10", /(Windows NT 10.0)/], - ["Windows ME", /Windows ME/], - ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], - ["Open BSD", /OpenBSD/], - ["Sun OS", /SunOS/], - ["Chrome OS", /CrOS/], - ["Linux", /(Linux)|(X11)/], - ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], - ["QNX", /QNX/], - ["BeOS", /BeOS/], - ["OS/2", /OS\/2/] - ]; - function detect(userAgent) { - if (!!userAgent) { - return parseUserAgent(userAgent); - } - if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { - return new ReactNativeInfo(); - } - if (typeof navigator !== "undefined") { - return parseUserAgent(navigator.userAgent); - } - return getNodeVersion(); - } - function matchUserAgent(ua) { - return ua !== "" && userAgentRules.reduce(function(matched, _a) { - var browser2 = _a[0], regex2 = _a[1]; - if (matched) { - return matched; - } - var uaMatch = regex2.exec(ua); - return !!uaMatch && [browser2, uaMatch]; - }, false); - } - function parseUserAgent(ua) { - var matchedRule = matchUserAgent(ua); - if (!matchedRule) { - return null; - } - var name2 = matchedRule[0], match = matchedRule[1]; - if (name2 === "searchbot") { - return new BotInfo(); - } - var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); - if (versionParts) { - if (versionParts.length < REQUIRED_VERSION_PARTS) { - versionParts = __spreadArray$3(__spreadArray$3([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); - } - } else { - versionParts = []; - } - var version2 = versionParts.join("."); - var os2 = detectOS(ua); - var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua); - if (searchBotMatch && searchBotMatch[1]) { - return new SearchBotDeviceInfo(name2, version2, os2, searchBotMatch[1]); - } - return new BrowserInfo(name2, version2, os2); - } - function detectOS(ua) { - for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) { - var _a = operatingSystemRules[ii], os2 = _a[0], regex2 = _a[1]; - var match = regex2.exec(ua); - if (match) { - return os2; + if (zeros === 0) { + throw new Error("X25519: invalid shared key"); + } } + return result; } - return null; + exports22.sharedKey = sharedKey; + })(x25519); + const C$1 = { 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" } }; + const Ir$1 = ":"; + function dn(e2) { + const [t2, r3] = e2.split(Ir$1); + return { namespace: t2, reference: r3 }; + } + function _r$1(e2, t2) { + return e2.includes(":") ? [e2] : t2.chains || []; + } + var Qo = Object.defineProperty, bn = Object.getOwnPropertySymbols, Jo$1 = Object.prototype.hasOwnProperty, Go$1 = Object.prototype.propertyIsEnumerable, yn = (e2, t2, r3) => t2 in e2 ? Qo(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, wn = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Jo$1.call(t2, r3) && yn(e2, r3, t2[r3]); + if (bn) + for (var r3 of bn(t2)) + Go$1.call(t2, r3) && yn(e2, r3, t2[r3]); + return e2; + }; + const xn = "ReactNative", qt$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, En = "js"; + function pi() { + return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; } - function getNodeVersion() { - var isNode = typeof process !== "undefined" && process.version; - return isNode ? new NodeInfo(process.version.slice(1)) : null; + function er$1() { + return !getDocument_1() && !!getNavigator_1() && navigator.product === xn; } - function createVersionParts(count) { - var output = []; - for (var ii = 0; ii < count; ii++) { - output.push("0"); - } - return output; + function pr$1() { + return !pi() && !!getNavigator_1() && !!getDocument_1(); } - var cjs$2 = {}; - Object.defineProperty(cjs$2, "__esModule", { value: true }); - cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; - function getFromWindow(name2) { - let res = void 0; - if (typeof window !== "undefined" && typeof window[name2] !== "undefined") { - res = window[name2]; + function We$2() { + return er$1() ? qt$1.reactNative : pi() ? qt$1.node : pr$1() ? qt$1.browser : qt$1.unknown; + } + function Wo$1() { + var e2; + try { + return er$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e2 = global.Application) == null ? void 0 : e2.applicationId : void 0; + } catch { + return; } - return res; } - cjs$2.getFromWindow = getFromWindow; - function getFromWindowOrThrow(name2) { - const res = getFromWindow(name2); - if (!res) { - throw new Error(`${name2} is not defined in Window`); + function Sn(e2, t2) { + let r3 = queryString.parse(e2); + return r3 = wn(wn({}, r3), t2), e2 = queryString.stringify(r3), e2; + } + function Xo$1() { + return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; + } + function Nn() { + if (We$2() === qt$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { + const { OS: r3, Version: i2 } = global.Platform; + return [r3, i2].join("-"); } - return res; + const e2 = detect(); + if (e2 === null) + return "unknown"; + const t2 = e2.os ? e2.os.replace(" ", "").toLowerCase() : "unknown"; + return e2.type === "browser" ? [t2, e2.name, e2.version].join("-") : [t2, e2.version].join("-"); } - cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; - function getDocumentOrThrow() { - return getFromWindowOrThrow("document"); + function In() { + var e2; + const t2 = We$2(); + return t2 === qt$1.browser ? [t2, ((e2 = getLocation_1()) == null ? void 0 : e2.host) || "unknown"].join(":") : t2; } - cjs$2.getDocumentOrThrow = getDocumentOrThrow; - function getDocument() { - return getFromWindow("document"); + function _n(e2, t2, r3) { + const i2 = Nn(), n4 = In(); + return [[e2, t2].join("-"), [En, r3].join("-"), i2, n4].join("/"); } - var getDocument_1 = cjs$2.getDocument = getDocument; - function getNavigatorOrThrow() { - return getFromWindowOrThrow("navigator"); + function $o({ protocol: e2, version: t2, relayUrl: r3, sdkVersion: i2, auth: n4, projectId: o22, useOnCloseEvent: h4, bundleId: p2 }) { + const b3 = r3.split("?"), m3 = _n(e2, t2, i2), w3 = { auth: n4, ua: m3, projectId: o22, useOnCloseEvent: h4 || void 0, origin: p2 || void 0 }, y3 = Sn(b3[1] || "", w3); + return b3[0] + "?" + y3; } - cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; - function getNavigator() { - return getFromWindow("navigator"); + function _e$1(e2, t2) { + return e2.filter((r3) => t2.includes(r3)).length === e2.length; } - var getNavigator_1 = cjs$2.getNavigator = getNavigator; - function getLocationOrThrow() { - return getFromWindowOrThrow("location"); + function i0(e2) { + return Object.fromEntries(e2.entries()); } - cjs$2.getLocationOrThrow = getLocationOrThrow; - function getLocation() { - return getFromWindow("location"); + function n0(e2) { + return new Map(Object.entries(e2)); } - var getLocation_1 = cjs$2.getLocation = getLocation; - function getCryptoOrThrow() { - return getFromWindowOrThrow("crypto"); + function a0(e2 = cjs$3.FIVE_MINUTES, t2) { + const r3 = cjs$3.toMiliseconds(e2 || cjs$3.FIVE_MINUTES); + let i2, n4, o22; + return { resolve: (h4) => { + o22 && i2 && (clearTimeout(o22), i2(h4)); + }, reject: (h4) => { + o22 && n4 && (clearTimeout(o22), n4(h4)); + }, done: () => new Promise((h4, p2) => { + o22 = setTimeout(() => { + p2(new Error(t2)); + }, r3), i2 = h4, n4 = p2; + }) }; } - cjs$2.getCryptoOrThrow = getCryptoOrThrow; - function getCrypto() { - return getFromWindow("crypto"); + function u0(e2, t2, r3) { + return new Promise(async (i2, n4) => { + const o22 = setTimeout(() => n4(new Error(r3)), t2); + try { + const h4 = await e2; + i2(h4); + } catch (h4) { + n4(h4); + } + clearTimeout(o22); + }); } - cjs$2.getCrypto = getCrypto; - function getLocalStorageOrThrow() { - return getFromWindowOrThrow("localStorage"); + function vi(e2, t2) { + if (typeof t2 == "string" && t2.startsWith(`${e2}:`)) + return t2; + if (e2.toLowerCase() === "topic") { + if (typeof t2 != "string") + throw new Error('Value must be "string" for expirer target type: topic'); + return `topic:${t2}`; + } else if (e2.toLowerCase() === "id") { + if (typeof t2 != "number") + throw new Error('Value must be "number" for expirer target type: id'); + return `id:${t2}`; + } + throw new Error(`Unknown expirer target type: ${e2}`); } - cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; - function getLocalStorage() { - return getFromWindow("localStorage"); + function h0(e2) { + return vi("topic", e2); } - cjs$2.getLocalStorage = getLocalStorage; - var cjs$1 = {}; - Object.defineProperty(cjs$1, "__esModule", { value: true }); - var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; - const window_getters_1 = cjs$2; - function getWindowMetadata() { - let doc; - let loc; + function c0(e2) { + return vi("id", e2); + } + function l0(e2) { + const [t2, r3] = e2.split(":"), i2 = { id: void 0, topic: void 0 }; + if (t2 === "topic" && typeof r3 == "string") + i2.topic = r3; + else if (t2 === "id" && Number.isInteger(Number(r3))) + i2.id = Number(r3); + else + throw new Error(`Invalid target, expected id:number or topic:string, got ${t2}:${r3}`); + return i2; + } + function d0(e2, t2) { + return cjs$3.fromMiliseconds(Date.now() + cjs$3.toMiliseconds(e2)); + } + function p0(e2) { + return Date.now() >= cjs$3.toMiliseconds(e2); + } + function v0(e2, t2) { + return `${e2}${t2 ? `:${t2}` : ""}`; + } + function ge$1(e2 = [], t2 = []) { + return [.../* @__PURE__ */ new Set([...e2, ...t2])]; + } + async function m0({ id: e2, topic: t2, wcDeepLink: r3 }) { try { - doc = window_getters_1.getDocumentOrThrow(); - loc = window_getters_1.getLocationOrThrow(); - } catch (e2) { - return null; + if (!r3) + return; + const i2 = typeof r3 == "string" ? JSON.parse(r3) : r3; + let n4 = i2 == null ? void 0 : i2.href; + if (typeof n4 != "string") + return; + n4.endsWith("/") && (n4 = n4.slice(0, -1)); + const o22 = `${n4}/wc?requestId=${e2}&sessionTopic=${t2}`, h4 = We$2(); + h4 === qt$1.browser ? o22.startsWith("https://") || o22.startsWith("http://") ? window.open(o22, "_blank", "noreferrer noopener") : window.open(o22, "_self", "noreferrer noopener") : h4 === qt$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(o22); + } catch (i2) { + console.error(i2); } - function getIcons() { - const links = doc.getElementsByTagName("link"); - const icons2 = []; - for (let i2 = 0; i2 < links.length; i2++) { - const link = links[i2]; - const rel = link.getAttribute("rel"); - if (rel) { - if (rel.toLowerCase().indexOf("icon") > -1) { - const href = link.getAttribute("href"); - if (href) { - if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { - let absoluteHref = loc.protocol + "//" + loc.host; - if (href.indexOf("/") === 0) { - absoluteHref += href; - } else { - const path = loc.pathname.split("/"); - path.pop(); - const finalPath = path.join("/"); - absoluteHref += finalPath + "/" + href; - } - icons2.push(absoluteHref); - } else if (href.indexOf("//") === 0) { - const absoluteUrl = loc.protocol + href; - icons2.push(absoluteUrl); - } else { - icons2.push(href); - } - } - } - } - } - return icons2; + } + async function g0(e2, t2) { + try { + return await e2.getItem(t2) || (pr$1() ? localStorage.getItem(t2) : void 0); + } catch (r3) { + console.error(r3); } - function getWindowMetadataOfAny(...args) { - const metaTags = doc.getElementsByTagName("meta"); - for (let i2 = 0; i2 < metaTags.length; i2++) { - const tag = metaTags[i2]; - const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { - if (attr) { - return args.includes(attr); - } - return false; - }); - if (attributes.length && attributes) { - const content = tag.getAttribute("content"); - if (content) { - return content; - } + } + var On$1 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; + function A0$1(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); + }; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; + } + var Pn$1 = { exports: {} }; + /** + * [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 + */ + (function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o22 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On$1 : o22 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N22 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s22(u3, E2, u3).update(B2)[_3](); + }; + }, H22 = function(u3, E2, _3) { + return function(B2, R2) { + return new s22(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s22(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H22(u3, E2, "hex"); + return _3.create = function(B2) { + return new s22(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H22, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s22(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s22(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s22.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N22[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N22[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N22[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N22[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N22[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; } + return this; + }, s22.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s22.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s22.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s22.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s22.prototype.toString = s22.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s22.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s22.prototype.buffer = s22.prototype.arrayBuffer, s22.prototype.digest = s22.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s22.call(this, u3, E2, _3); } - return ""; + v3.prototype = new s22(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s22.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z22, Fe2, $2, tt2, Te2, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le2, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne2, Ie2; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z22 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z22 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z22 >>> 31), _3 = D2 ^ (Z22 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te2 = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne2 = u3[42] << 2 | u3[43] >>> 30, Ie2 = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le2 = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te2 & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le2, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te2 ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le2 & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le2 ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne2, u3[45] = Me2 ^ ~Se2 & Ie2, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne2 & St2, u3[47] = Se2 ^ ~Ie2 & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te2, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne2 ^ ~St2 & Ve2, u3[49] = Ie2 ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); + })(Pn$1); + var b0 = Pn$1.exports; + const y0$1 = "logger/5.7.0"; + let Dn$1 = false, Fn$1 = false; + const Cr$2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; + let Tn$1 = Cr$2.default, gi$1 = null; + function w0$1() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; } - function getName() { - let name3 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); - if (!name3) { - name3 = doc.title; - } - return name3; + return null; + } + const Un$1 = w0$1(); + var Ai$1; + (function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; + })(Ai$1 || (Ai$1 = {})); + var re$2; + (function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; + })(re$2 || (re$2 = {})); + const kn$1 = "0123456789abcdef"; + let L$3 = class L22 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); } - function getDescription() { - const description3 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); - return description3; + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr$2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn$1 > Cr$2[i2]) && console.log.apply(console, r3); } - const name2 = getName(); - const description2 = getDescription(); - const url = loc.origin; - const icons = getIcons(); - const meta = { - description: description2, - url, - icons, - name: name2 - }; - return meta; - } - getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; - var queryString = {}; - var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x2) => `%${x2.charCodeAt(0).toString(16).toUpperCase()}`); - var token = "%[a-f0-9]{2}"; - var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi"); - var multiMatcher = new RegExp("(" + token + ")+", "gi"); - function decodeComponents(components, split) { - try { - return [decodeURIComponent(components.join(""))]; - } catch (err) { + debug(...t2) { + this._log(L22.levels.DEBUG, t2); } - if (components.length === 1) { - return components; + info(...t2) { + this._log(L22.levels.INFO, t2); } - split = split || 1; - var left = components.slice(0, split); - var right = components.slice(split); - return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); - } - function decode(input) { - try { - return decodeURIComponent(input); - } catch (err) { - var tokens = input.match(singleMatcher) || []; - for (var i2 = 1; i2 < tokens.length; i2++) { - input = decodeComponents(tokens, i2).join(""); - tokens = input.match(singleMatcher) || []; - } - return input; + warn(...t2) { + this._log(L22.levels.WARNING, t2); } - } - function customDecodeURIComponent(input) { - var replaceMap = { - "%FE%FF": "��", - "%FF%FE": "��" - }; - var match = multiMatcher.exec(input); - while (match) { - try { - replaceMap[match[0]] = decodeURIComponent(match[0]); - } catch (err) { - var result = decode(match[0]); - if (result !== match[0]) { - replaceMap[match[0]] = result; + makeError(t2, r3, i2) { + if (Fn$1) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L22.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn$1[m3[y3] >> 4], w3 += kn$1[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o22 = t2; + let h4 = ""; + switch (r3) { + case re$2.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; + } + break; } + case re$2.CALL_EXCEPTION: + case re$2.INSUFFICIENT_FUNDS: + case re$2.MISSING_NEW: + case re$2.NONCE_EXPIRED: + case re$2.REPLACEMENT_UNDERPRICED: + case re$2.TRANSACTION_REPLACED: + case re$2.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; } - match = multiMatcher.exec(input); + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o22, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; } - replaceMap["%C2"] = "�"; - var entries = Object.keys(replaceMap); - for (var i2 = 0; i2 < entries.length; i2++) { - var key = entries[i2]; - input = input.replace(new RegExp(key, "g"), replaceMap[key]); + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); } - return input; - } - var decodeUriComponent = function(encodedURI) { - if (typeof encodedURI !== "string") { - throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L22.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); } - try { - encodedURI = encodedURI.replace(/\+/g, " "); - return decodeURIComponent(encodedURI); - } catch (err) { - return customDecodeURIComponent(encodedURI); + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); } - }; - var splitOnFirst = (string2, separator) => { - if (!(typeof string2 === "string" && typeof separator === "string")) { - throw new TypeError("Expected the arguments to be of type `string`"); + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); } - if (separator === "") { - return [string2]; + checkNormalize(t2) { + Un$1 && this.throwError("platform missing String.prototype.normalize", L22.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un$1 }); } - const separatorIndex = string2.indexOf(separator); - if (separatorIndex === -1) { - return [string2]; + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L22.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L22.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); } - return [ - string2.slice(0, separatorIndex), - string2.slice(separatorIndex + separator.length) - ]; - }; - var filterObj = function(obj, predicate) { - var ret = {}; - var keys2 = Object.keys(obj); - var isArr = Array.isArray(predicate); - for (var i2 = 0; i2 < keys2.length; i2++) { - var key = keys2[i2]; - var val = obj[key]; - if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { - ret[key] = val; + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L22.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L22.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); + } + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L22.errors.MISSING_NEW, { name: r3.name }); + } + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L22.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L22.errors.MISSING_NEW, { name: r3.name }); + } + static globalLogger() { + return gi$1 || (gi$1 = new L22(y0$1)), gi$1; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L22.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn$1) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L22.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } + Fn$1 = !!t2, Dn$1 = !!r3; } - return ret; - }; - (function(exports22) { - const strictUriEncode$1 = strictUriEncode; - const decodeComponent = decodeUriComponent; - const splitOnFirst$1 = splitOnFirst; - const filterObject = filterObj; - const isNullOrUndefined = (value) => value === null || value === void 0; - const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); - function encoderForArrayFormat(options) { - switch (options.arrayFormat) { - case "index": - return (key) => (result, value) => { - const index = result.length; - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[", index, "]"].join("")]; - } - return [ - ...result, - [encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("") - ]; - }; - case "bracket": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), "[]"].join("")]; - } - return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")]; - }; - case "colon-list-separator": - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, [encode2(key, options), ":list="].join("")]; - } - return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")]; - }; - case "comma": - case "separator": - case "bracket-separator": { - const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - value = value === null ? "" : value; - if (result.length === 0) { - return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")]; - } - return [[result, encode2(value, options)].join(options.arrayFormatSeparator)]; - }; - } - default: - return (key) => (result, value) => { - if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { - return result; - } - if (value === null) { - return [...result, encode2(key, options)]; - } - return [...result, [encode2(key, options), "=", encode2(value, options)].join("")]; - }; + static setLogLevel(t2) { + const r3 = Cr$2[t2.toLowerCase()]; + if (r3 == null) { + L22.globalLogger().warn("invalid log level - " + t2); + return; } + Tn$1 = r3; } - function parserForArrayFormat(options) { - let result; - switch (options.arrayFormat) { - case "index": - return (key, value, accumulator) => { - result = /\[(\d*)\]$/.exec(key); - key = key.replace(/\[\d*\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = {}; - } - accumulator[key][result[1]] = value; - }; - case "bracket": - return (key, value, accumulator) => { - result = /(\[\])$/.exec(key); - key = key.replace(/\[\]$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "colon-list-separator": - return (key, value, accumulator) => { - result = /(:list)$/.exec(key); - key = key.replace(/:list$/, ""); - if (!result) { - accumulator[key] = value; - return; - } - if (accumulator[key] === void 0) { - accumulator[key] = [value]; - return; - } - accumulator[key] = [].concat(accumulator[key], value); - }; - case "comma": - case "separator": - return (key, value, accumulator) => { - const isArray2 = typeof value === "string" && value.includes(options.arrayFormatSeparator); - const isEncodedArray = typeof value === "string" && !isArray2 && decode2(value, options).includes(options.arrayFormatSeparator); - value = isEncodedArray ? decode2(value, options) : value; - const newValue = isArray2 || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options); - accumulator[key] = newValue; - }; - case "bracket-separator": - return (key, value, accumulator) => { - const isArray2 = /(\[\])$/.test(key); - key = key.replace(/\[\]$/, ""); - if (!isArray2) { - accumulator[key] = value ? decode2(value, options) : value; - return; - } - const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)); - if (accumulator[key] === void 0) { - accumulator[key] = arrayValue; - return; - } - accumulator[key] = [].concat(accumulator[key], arrayValue); - }; - default: - return (key, value, accumulator) => { - if (accumulator[key] === void 0) { - accumulator[key] = value; - return; + static from(t2) { + return new L22(t2); + } + }; + L$3.errors = re$2, L$3.levels = Ai$1; + const x0$1 = "bytes/5.7.0", Dt$2 = new L$3(x0$1); + function qn$1(e2) { + return !!e2.toHexString; + } + function rr$2(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr$2(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; + } + function M0(e2) { + return Qt$1(e2) && !(e2.length % 2) || ir$2(e2); + } + function Kn$1(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; + } + function ir$2(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn$1(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn$1(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; + } + function Ot$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr$2(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2) && (e2 = e2.toHexString()), Qt$1(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr$2(new Uint8Array(i2)); + } + return ir$2(e2) ? rr$2(new Uint8Array(e2)) : Dt$2.throwArgumentError("invalid arrayify value", "value", e2); + } + function E0(e2) { + const t2 = e2.map((n4) => Ot$2(n4)), r3 = t2.reduce((n4, o22) => n4 + o22.length, 0), i2 = new Uint8Array(r3); + return t2.reduce((n4, o22) => (i2.set(o22, n4), n4 + o22.length), 0), rr$2(i2); + } + function S0(e2, t2) { + e2 = Ot$2(e2), e2.length > t2 && Dt$2.throwArgumentError("value out of range", "value", arguments[0]); + const r3 = new Uint8Array(t2); + return r3.set(e2, t2 - e2.length), rr$2(r3); + } + function Qt$1(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2 && e2.length !== 2 + 2 * t2); + } + const bi$1 = "0123456789abcdef"; + function Kt$2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$2.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi$1[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn$1(e2)) + return e2.toHexString(); + if (Qt$1(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt$2.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir$2(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi$1[(n4 & 240) >> 4] + bi$1[n4 & 15]; + } + return r3; + } + return Dt$2.throwArgumentError("invalid hexlify value", "value", e2); + } + function N0(e2) { + if (typeof e2 != "string") + e2 = Kt$2(e2); + else if (!Qt$1(e2) || e2.length % 2) + return null; + return (e2.length - 2) / 2; + } + function Hn(e2, t2, r3) { + return typeof e2 != "string" ? e2 = Kt$2(e2) : (!Qt$1(e2) || e2.length % 2) && Dt$2.throwArgumentError("invalid hexData", "value", e2), t2 = 2 + 2 * t2, r3 != null ? "0x" + e2.substring(t2, 2 + 2 * r3) : "0x" + e2.substring(t2); + } + function oe$1(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt$2(e2) : Qt$1(e2) || Dt$2.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt$2.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; + } + function zn(e2) { + const t2 = { r: "0x", s: "0x", _vs: "0x", recoveryParam: 0, v: 0, yParityAndS: "0x", compact: "0x" }; + if (M0(e2)) { + let r3 = Ot$2(e2); + r3.length === 64 ? (t2.v = 27 + (r3[32] >> 7), r3[32] &= 127, t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64))) : r3.length === 65 ? (t2.r = Kt$2(r3.slice(0, 32)), t2.s = Kt$2(r3.slice(32, 64)), t2.v = r3[64]) : Dt$2.throwArgumentError("invalid signature string", "signature", e2), t2.v < 27 && (t2.v === 0 || t2.v === 1 ? t2.v += 27 : Dt$2.throwArgumentError("signature invalid v byte", "signature", e2)), t2.recoveryParam = 1 - t2.v % 2, t2.recoveryParam && (r3[32] |= 128), t2._vs = Kt$2(r3.slice(32, 64)); + } else { + if (t2.r = e2.r, t2.s = e2.s, t2.v = e2.v, t2.recoveryParam = e2.recoveryParam, t2._vs = e2._vs, t2._vs != null) { + const n4 = S0(Ot$2(t2._vs), 32); + t2._vs = Kt$2(n4); + const o22 = n4[0] >= 128 ? 1 : 0; + t2.recoveryParam == null ? t2.recoveryParam = o22 : t2.recoveryParam !== o22 && Dt$2.throwArgumentError("signature recoveryParam mismatch _vs", "signature", e2), n4[0] &= 127; + const h4 = Kt$2(n4); + t2.s == null ? t2.s = h4 : t2.s !== h4 && Dt$2.throwArgumentError("signature v mismatch _vs", "signature", e2); + } + if (t2.recoveryParam == null) + t2.v == null ? Dt$2.throwArgumentError("signature missing v and recoveryParam", "signature", e2) : t2.v === 0 || t2.v === 1 ? t2.recoveryParam = t2.v : t2.recoveryParam = 1 - t2.v % 2; + else if (t2.v == null) + t2.v = 27 + t2.recoveryParam; + else { + const n4 = t2.v === 0 || t2.v === 1 ? t2.v : 1 - t2.v % 2; + t2.recoveryParam !== n4 && Dt$2.throwArgumentError("signature recoveryParam mismatch v", "signature", e2); + } + t2.r == null || !Qt$1(t2.r) ? Dt$2.throwArgumentError("signature missing or invalid r", "signature", e2) : t2.r = oe$1(t2.r, 32), t2.s == null || !Qt$1(t2.s) ? Dt$2.throwArgumentError("signature missing or invalid s", "signature", e2) : t2.s = oe$1(t2.s, 32); + const r3 = Ot$2(t2.s); + r3[0] >= 128 && Dt$2.throwArgumentError("signature s out of range", "signature", e2), t2.recoveryParam && (r3[0] |= 128); + const i2 = Kt$2(r3); + t2._vs && (Qt$1(t2._vs) || Dt$2.throwArgumentError("signature invalid _vs", "signature", e2), t2._vs = oe$1(t2._vs, 32)), t2._vs == null ? t2._vs = i2 : t2._vs !== i2 && Dt$2.throwArgumentError("signature _vs mismatch v and s", "signature", e2); + } + return t2.yParityAndS = t2._vs, t2.compact = t2.r + t2.yParityAndS.substring(2), t2; + } + function yi(e2) { + return "0x" + b0.keccak_256(Ot$2(e2)); + } + var Ln$1 = { exports: {} }, I0$1 = {}, _0$1 = Object.freeze({ __proto__: null, default: I0$1 }), B0$1 = A0$1(_0$1); + (function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; + } + function o22(A2, f3, a3) { + if (o22.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o22 : r3.BN = o22, o22.BN = o22, o22.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0$1.Buffer; + } catch { + } + o22.isBN = function(f3) { + return f3 instanceof o22 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o22.wordSize && Array.isArray(f3.words); + }, o22.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o22.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o22.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o22.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o22.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o22.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + } + this._strip(); + }; + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o22.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s22 = 0, v3 = c2; v3 < l2; v3 += d5) + s22 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s22 < 67108864 ? this.words[0] += s22 : this._iaddn(s22); + if (M2 !== 0) { + var k2 = 1; + for (s22 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s22 < 67108864 ? this.words[0] += s22 : this._iaddn(s22); + } + this._strip(); + }, o22.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o22.prototype._move = function(f3) { + w3(f3, this); + }, o22.prototype.clone = function() { + var f3 = new o22(null); + return this.copy(f3), f3; + }, o22.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o22.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o22.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o22.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o22.prototype.inspect = y3; + } + else + o22.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N22 = [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]; + o22.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s22 = I2[f3], v3 = N22[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s22 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o22.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o22.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o22.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o22.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o22.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o22.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o22.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o22.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o22.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o22.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o22.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o22.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; + } + return f3; + }, o22.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o22.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o22.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o22.prototype.isNeg = function() { + return this.negative !== 0; + }, o22.prototype.neg = function() { + return this.clone().ineg(); + }, o22.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o22.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o22.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o22.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o22.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o22.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o22.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o22.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o22.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o22.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o22.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o22.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o22.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o22.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o22.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o22.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o22.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o22.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o22.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o22.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s22 = 1; s22 < c2; s22++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s22, f3.length - 1), E2 = Math.max(0, s22 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s22 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s22] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s22] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s22, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z22 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te2 = d5[6] | 0, et2 = Te2 & 8191, rt2 = Te2 >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le2 = g3[3] | 0, vt2 = Le2 & 8191, mt2 = Le2 >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s22 = Math.imul(u3, ht2), s22 = s22 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s22 = Math.imul(B2, ht2), s22 = s22 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s22 = s22 + Math.imul(u3, lt2) | 0, s22 = s22 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s22 = Math.imul(P2, ht2), s22 = s22 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s22 = s22 + Math.imul(B2, lt2) | 0, s22 = s22 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s22 = s22 + Math.imul(u3, pt2) | 0, s22 = s22 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s22 = Math.imul(D2, ht2), s22 = s22 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s22 = s22 + Math.imul(P2, lt2) | 0, s22 = s22 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s22 = s22 + Math.imul(B2, pt2) | 0, s22 = s22 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s22 = s22 + Math.imul(u3, mt2) | 0, s22 = s22 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Ne2 >>> 26) | 0, Ne2 &= 67108863, l2 = Math.imul(X2, ut2), s22 = Math.imul(X2, ht2), s22 = s22 + Math.imul(Z22, ut2) | 0, v3 = Math.imul(Z22, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s22 = s22 + Math.imul(D2, lt2) | 0, s22 = s22 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s22 = s22 + Math.imul(P2, pt2) | 0, s22 = s22 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s22 = s22 + Math.imul(B2, mt2) | 0, s22 = s22 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s22 = s22 + Math.imul(u3, At2) | 0, s22 = s22 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Ie2 >>> 26) | 0, Ie2 &= 67108863, l2 = Math.imul($2, ut2), s22 = Math.imul($2, ht2), s22 = s22 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s22 = s22 + Math.imul(X2, lt2) | 0, s22 = s22 + Math.imul(Z22, ct2) | 0, v3 = v3 + Math.imul(Z22, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s22 = s22 + Math.imul(D2, pt2) | 0, s22 = s22 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s22 = s22 + Math.imul(P2, mt2) | 0, s22 = s22 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s22 = s22 + Math.imul(B2, At2) | 0, s22 = s22 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s22 = s22 + Math.imul(u3, yt2) | 0, s22 = s22 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s22 = Math.imul(et2, ht2), s22 = s22 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s22 = s22 + Math.imul($2, lt2) | 0, s22 = s22 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s22 = s22 + Math.imul(X2, pt2) | 0, s22 = s22 + Math.imul(Z22, dt2) | 0, v3 = v3 + Math.imul(Z22, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s22 = s22 + Math.imul(D2, mt2) | 0, s22 = s22 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s22 = s22 + Math.imul(P2, At2) | 0, s22 = s22 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s22 = s22 + Math.imul(B2, yt2) | 0, s22 = s22 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s22 = s22 + Math.imul(u3, xt2) | 0, s22 = s22 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s22 = Math.imul(it2, ht2), s22 = s22 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s22 = s22 + Math.imul(et2, lt2) | 0, s22 = s22 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s22 = s22 + Math.imul($2, pt2) | 0, s22 = s22 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s22 = s22 + Math.imul(X2, mt2) | 0, s22 = s22 + Math.imul(Z22, vt2) | 0, v3 = v3 + Math.imul(Z22, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s22 = s22 + Math.imul(D2, At2) | 0, s22 = s22 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s22 = s22 + Math.imul(P2, yt2) | 0, s22 = s22 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s22 = s22 + Math.imul(B2, xt2) | 0, s22 = s22 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s22 = s22 + Math.imul(u3, Et2) | 0, s22 = s22 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s22 = Math.imul(ft2, ht2), s22 = s22 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s22 = s22 + Math.imul(it2, lt2) | 0, s22 = s22 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s22 = s22 + Math.imul(et2, pt2) | 0, s22 = s22 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s22 = s22 + Math.imul($2, mt2) | 0, s22 = s22 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s22 = s22 + Math.imul(X2, At2) | 0, s22 = s22 + Math.imul(Z22, gt2) | 0, v3 = v3 + Math.imul(Z22, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s22 = s22 + Math.imul(D2, yt2) | 0, s22 = s22 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s22 = s22 + Math.imul(P2, xt2) | 0, s22 = s22 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s22 = s22 + Math.imul(B2, Et2) | 0, s22 = s22 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s22 = s22 + Math.imul(u3, Nt2) | 0, s22 = s22 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s22 = Math.imul(st2, ht2), s22 = s22 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s22 = s22 + Math.imul(ft2, lt2) | 0, s22 = s22 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s22 = s22 + Math.imul(it2, pt2) | 0, s22 = s22 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s22 = s22 + Math.imul(et2, mt2) | 0, s22 = s22 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s22 = s22 + Math.imul($2, At2) | 0, s22 = s22 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s22 = s22 + Math.imul(X2, yt2) | 0, s22 = s22 + Math.imul(Z22, bt2) | 0, v3 = v3 + Math.imul(Z22, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s22 = s22 + Math.imul(D2, xt2) | 0, s22 = s22 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s22 = s22 + Math.imul(P2, Et2) | 0, s22 = s22 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s22 = s22 + Math.imul(B2, Nt2) | 0, s22 = s22 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s22 = s22 + Math.imul(u3, _t2) | 0, s22 = s22 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s22 = Math.imul(st2, lt2), s22 = s22 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s22 = s22 + Math.imul(ft2, pt2) | 0, s22 = s22 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s22 = s22 + Math.imul(it2, mt2) | 0, s22 = s22 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s22 = s22 + Math.imul(et2, At2) | 0, s22 = s22 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s22 = s22 + Math.imul($2, yt2) | 0, s22 = s22 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s22 = s22 + Math.imul(X2, xt2) | 0, s22 = s22 + Math.imul(Z22, wt2) | 0, v3 = v3 + Math.imul(Z22, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s22 = s22 + Math.imul(D2, Et2) | 0, s22 = s22 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s22 = s22 + Math.imul(P2, Nt2) | 0, s22 = s22 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s22 = s22 + Math.imul(B2, _t2) | 0, s22 = s22 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s22 = Math.imul(st2, pt2), s22 = s22 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s22 = s22 + Math.imul(ft2, mt2) | 0, s22 = s22 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s22 = s22 + Math.imul(it2, At2) | 0, s22 = s22 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s22 = s22 + Math.imul(et2, yt2) | 0, s22 = s22 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s22 = s22 + Math.imul($2, xt2) | 0, s22 = s22 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s22 = s22 + Math.imul(X2, Et2) | 0, s22 = s22 + Math.imul(Z22, Mt2) | 0, v3 = v3 + Math.imul(Z22, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s22 = s22 + Math.imul(D2, Nt2) | 0, s22 = s22 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s22 = s22 + Math.imul(P2, _t2) | 0, s22 = s22 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s22 = Math.imul(st2, mt2), s22 = s22 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s22 = s22 + Math.imul(ft2, At2) | 0, s22 = s22 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s22 = s22 + Math.imul(it2, yt2) | 0, s22 = s22 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s22 = s22 + Math.imul(et2, xt2) | 0, s22 = s22 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s22 = s22 + Math.imul($2, Et2) | 0, s22 = s22 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s22 = s22 + Math.imul(X2, Nt2) | 0, s22 = s22 + Math.imul(Z22, St2) | 0, v3 = v3 + Math.imul(Z22, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s22 = s22 + Math.imul(D2, _t2) | 0, s22 = s22 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s22 = Math.imul(st2, At2), s22 = s22 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s22 = s22 + Math.imul(ft2, yt2) | 0, s22 = s22 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s22 = s22 + Math.imul(it2, xt2) | 0, s22 = s22 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s22 = s22 + Math.imul(et2, Et2) | 0, s22 = s22 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s22 = s22 + Math.imul($2, Nt2) | 0, s22 = s22 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s22 = s22 + Math.imul(X2, _t2) | 0, s22 = s22 + Math.imul(Z22, It2) | 0, v3 = v3 + Math.imul(Z22, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s22 = Math.imul(st2, yt2), s22 = s22 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s22 = s22 + Math.imul(ft2, xt2) | 0, s22 = s22 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s22 = s22 + Math.imul(it2, Et2) | 0, s22 = s22 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s22 = s22 + Math.imul(et2, Nt2) | 0, s22 = s22 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s22 = s22 + Math.imul($2, _t2) | 0, s22 = s22 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s22 = Math.imul(st2, xt2), s22 = s22 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s22 = s22 + Math.imul(ft2, Et2) | 0, s22 = s22 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s22 = s22 + Math.imul(it2, Nt2) | 0, s22 = s22 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s22 = s22 + Math.imul(et2, _t2) | 0, s22 = s22 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s22 = Math.imul(st2, Et2), s22 = s22 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s22 = s22 + Math.imul(ft2, Nt2) | 0, s22 = s22 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s22 = s22 + Math.imul(it2, _t2) | 0, s22 = s22 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s22 = Math.imul(st2, Nt2), s22 = s22 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s22 = s22 + Math.imul(ft2, _t2) | 0, s22 = s22 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s22 = Math.imul(st2, _t2), s22 = s22 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + return M2 = (v3 + (s22 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne2, x2[4] = Ie2, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s22 = Math.max(0, g3 - A2.length + 1); s22 <= l2; s22++) { + var v3 = g3 - s22, k2 = A2.words[v3] | 0, u3 = f3.words[s22] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o22.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o22.prototype.mul = function(f3) { + var a3 = new o22(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o22.prototype.mulf = function(f3) { + var a3 = new o22(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o22.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o22.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o22.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o22.prototype.sqr = function() { + return this.mul(this); + }, o22.prototype.isqr = function() { + return this.imul(this.clone()); + }, o22.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o22(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o22.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o22.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o22.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s22 = 0; s22 < x2; s22++) + l2.words[s22] = this.words[s22]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s22 = 0; s22 < this.length; s22++) + this.words[s22] = this.words[s22 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s22 = this.length - 1; s22 >= 0 && (v3 !== 0 || s22 >= d5); s22--) { + var k2 = this.words[s22] | 0; + this.words[s22] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o22.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o22.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o22.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o22.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o22.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o22.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o22.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o22.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o22.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o22.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o22.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o22.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o22.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o22.prototype.iabs = function() { + return this.negative = 0, this; + }, o22.prototype.abs = function() { + return this.clone().iabs(); + }, o22.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o22.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s22; + if (a3 !== "mod") { + s22 = new o22(null), s22.length = l2 + 1, s22.words = new Array(s22.length); + for (var v3 = 0; v3 < s22.length; v3++) + s22.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s22 && (s22.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s22 && (s22.words[u3] = E2); + } + return s22 && s22._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s22 || null, mod: d5 }; + }, o22.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o22(0), mod: new o22(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o22(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o22(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o22(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o22.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o22.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o22.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o22.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o22.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o22.prototype.modn = function(f3) { + return this.modrn(f3); + }, o22.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o22.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o22.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o22(1), g3 = new o22(0), x2 = new o22(0), M2 = new o22(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s22 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s22), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s22), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o22.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o22(1), g3 = new o22(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s22 = 0, v3 = 1; !(c2.words[0] & v3) && s22 < 26; ++s22, v3 <<= 1) + ; + if (s22 > 0) + for (c2.iushrn(s22); s22-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o22.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o22.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o22.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o22.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o22.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o22.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o22.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o22.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o22.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o22.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; + } + } + return a3; + }, o22.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o22.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o22.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o22.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o22.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o22.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o22.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o22.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o22.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o22.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o22.red = function(f3) { + return new Y2(f3); + }, o22.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o22.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o22.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o22.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o22.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o22.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o22.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o22.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o22.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o22.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o22.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o22.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o22.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o22.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o22.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o22.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o22.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H22 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o22(f3, 16), this.n = this.p.bitLength(), this.k = new o22(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o22(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o22._prime = function(f3) { + if (H22[f3]) + return H22[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H22[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o22._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o22(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o22(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s22 = this.m.bitLength(); + for (s22 = new o22(2 * s22 * s22).toRed(this); this.pow(s22, l2).cmp(M2) !== 0; ) + s22.redIAdd(M2); + for (var v3 = this.pow(s22, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o22(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o22(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o22(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s22 = a3.bitLength() % 26; + for (s22 === 0 && (s22 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s22 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; } - accumulator[key] = [].concat(accumulator[key], value); - }; - } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s22 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o22.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o22(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o22(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On$1); + })(Ln$1); + var K$2 = Ln$1.exports; + const jn$1 = "bignumber/5.7.0"; + var Rr$2 = K$2.BN; + const Ae$1 = new L$3(jn$1), wi$1 = {}, Qn$1 = 9007199254740991; + function C0$1(e2) { + return e2 != null && (V$2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt$1(e2) || typeof e2 == "bigint" || ir$2(e2)); + } + let Jn$1 = false; + let V$2 = class V3 { + constructor(t2, r3) { + t2 !== wi$1 && Ae$1.throwError("cannot call constructor directly; use BigNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); } - function validateArrayFormatSeparator(value) { - if (typeof value !== "string" || value.length !== 1) { - throw new TypeError("arrayFormatSeparator must be single character string"); - } + fromTwos(t2) { + return Lt$2(j$2(this).fromTwos(t2)); } - function encode2(value, options) { - if (options.encode) { - return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value); - } - return value; + toTwos(t2) { + return Lt$2(j$2(this).toTwos(t2)); } - function decode2(value, options) { - if (options.decode) { - return decodeComponent(value); - } - return value; + abs() { + return this._hex[0] === "-" ? V3.from(this._hex.substring(1)) : this; } - function keysSorter(input) { - if (Array.isArray(input)) { - return input.sort(); - } - if (typeof input === "object") { - return keysSorter(Object.keys(input)).sort((a3, b3) => Number(a3) - Number(b3)).map((key) => input[key]); - } - return input; + add(t2) { + return Lt$2(j$2(this).add(j$2(t2))); } - function removeHash(input) { - const hashStart = input.indexOf("#"); - if (hashStart !== -1) { - input = input.slice(0, hashStart); - } - return input; + sub(t2) { + return Lt$2(j$2(this).sub(j$2(t2))); } - function getHash(url) { - let hash2 = ""; - const hashStart = url.indexOf("#"); - if (hashStart !== -1) { - hash2 = url.slice(hashStart); - } - return hash2; + div(t2) { + return V3.from(t2).isZero() && Wt$3("division-by-zero", "div"), Lt$2(j$2(this).div(j$2(t2))); } - function extract(input) { - input = removeHash(input); - const queryStart = input.indexOf("?"); - if (queryStart === -1) { - return ""; - } - return input.slice(queryStart + 1); + mul(t2) { + return Lt$2(j$2(this).mul(j$2(t2))); } - function parseValue(value, options) { - if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { - value = Number(value); - } else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { - value = value.toLowerCase() === "true"; - } - return value; + mod(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("division-by-zero", "mod"), Lt$2(j$2(this).umod(r3)); } - function parse(query, options) { - options = Object.assign({ - decode: true, - sort: true, - arrayFormat: "none", - arrayFormatSeparator: ",", - parseNumbers: false, - parseBooleans: false - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const formatter = parserForArrayFormat(options); - const ret = /* @__PURE__ */ Object.create(null); - if (typeof query !== "string") { - return ret; - } - query = query.trim().replace(/^[?#&]/, ""); - if (!query) { - return ret; - } - for (const param of query.split("&")) { - if (param === "") { - continue; - } - let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "="); - value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options); - formatter(decode2(key, options), value, ret); - } - for (const key of Object.keys(ret)) { - const value = ret[key]; - if (typeof value === "object" && value !== null) { - for (const k2 of Object.keys(value)) { - value[k2] = parseValue(value[k2], options); - } - } else { - ret[key] = parseValue(value, options); - } + pow(t2) { + const r3 = j$2(t2); + return r3.isNeg() && Wt$3("negative-power", "pow"), Lt$2(j$2(this).pow(r3)); + } + and(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "and"), Lt$2(j$2(this).and(r3)); + } + or(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "or"), Lt$2(j$2(this).or(r3)); + } + xor(t2) { + const r3 = j$2(t2); + return (this.isNegative() || r3.isNeg()) && Wt$3("unbound-bitwise-result", "xor"), Lt$2(j$2(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "mask"), Lt$2(j$2(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shl"), Lt$2(j$2(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt$3("negative-width", "shr"), Lt$2(j$2(this).shrn(t2)); + } + eq(t2) { + return j$2(this).eq(j$2(t2)); + } + lt(t2) { + return j$2(this).lt(j$2(t2)); + } + lte(t2) { + return j$2(this).lte(j$2(t2)); + } + gt(t2) { + return j$2(this).gt(j$2(t2)); + } + gte(t2) { + return j$2(this).gte(j$2(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j$2(this).isZero(); + } + toNumber() { + try { + return j$2(this).toNumber(); + } catch { + Wt$3("overflow", "toNumber", this.toString()); } - if (options.sort === false) { - return ret; + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { } - return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { - const value = ret[key]; - if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { - result[key] = keysSorter(value); + return Ae$1.throwError("this platform does not support BigInt", L$3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn$1 || (Jn$1 = true, Ae$1.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae$1.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L$3.errors.UNEXPECTED_ARGUMENT, {}) : Ae$1.throwError("BigNumber.toString does not accept parameters", L$3.errors.UNEXPECTED_ARGUMENT, {})), j$2(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V3) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V3(wi$1, vr$1(t2)) : t2.match(/^-?[0-9]+$/) ? new V3(wi$1, vr$1(new Rr$2(t2))) : Ae$1.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt$3("underflow", "BigNumber.from", t2), (t2 >= Qn$1 || t2 <= -Qn$1) && Wt$3("overflow", "BigNumber.from", t2), V3.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V3.from(r3.toString()); + if (ir$2(r3)) + return V3.from(Kt$2(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V3.from(i2); } else { - result[key] = value; + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt$1(i2) || i2[0] === "-" && Qt$1(i2.substring(1)))) + return V3.from(i2); } - return result; - }, /* @__PURE__ */ Object.create(null)); + return Ae$1.throwArgumentError("invalid BigNumber value", "value", t2); } - exports22.extract = extract; - exports22.parse = parse; - exports22.stringify = (object, options) => { - if (!object) { - return ""; - } - options = Object.assign({ - encode: true, - strict: true, - arrayFormat: "none", - arrayFormatSeparator: "," - }, options); - validateArrayFormatSeparator(options.arrayFormatSeparator); - const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; - const formatter = encoderForArrayFormat(options); - const objectCopy = {}; - for (const key of Object.keys(object)) { - if (!shouldFilter(key)) { - objectCopy[key] = object[key]; - } - } - const keys2 = Object.keys(objectCopy); - if (options.sort !== false) { - keys2.sort(options.sort); + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } + }; + function vr$1(e2) { + if (typeof e2 != "string") + return vr$1(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae$1.throwArgumentError("invalid hex", "value", e2), e2 = vr$1(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; + } + function Lt$2(e2) { + return V$2.from(vr$1(e2)); + } + function j$2(e2) { + const t2 = V$2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr$2("-" + t2.substring(3), 16) : new Rr$2(t2.substring(2), 16); + } + function Wt$3(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae$1.throwError(e2, L$3.errors.NUMERIC_FAULT, i2); + } + function R0(e2) { + return new Rr$2(e2, 36).toString(16); + } + const Ht$3 = new L$3(jn$1), mr$2 = {}, Gn$1 = V$2.from(0), Yn$1 = V$2.from(-1); + function Vn$1(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht$3.throwError(e2, L$3.errors.NUMERIC_FAULT, n4); + } + let gr$2 = "0"; + for (; gr$2.length < 256; ) + gr$2 += gr$2; + function xi$1(e2) { + if (typeof e2 != "number") + try { + e2 = V$2.from(e2).toNumber(); + } catch { } - return keys2.map((key) => { - const value = object[key]; - if (value === void 0) { - return ""; - } - if (value === null) { - return encode2(key, options); - } - if (Array.isArray(value)) { - if (value.length === 0 && options.arrayFormat === "bracket-separator") { - return encode2(key, options) + "[]"; - } - return value.reduce(formatter(key), []).join("&"); - } - return encode2(key, options) + "=" + encode2(value, options); - }).filter((x2) => x2.length > 0).join("&"); - }; - exports22.parseUrl = (url, options) => { - options = Object.assign({ - decode: true - }, options); - const [url_, hash2] = splitOnFirst$1(url, "#"); - return Object.assign( - { - url: url_.split("?")[0] || "", - query: parse(extract(url), options) - }, - options && options.parseFragmentIdentifier && hash2 ? { fragmentIdentifier: decode2(hash2, options) } : {} - ); + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr$2.substring(0, e2) : Ht$3.throwArgumentError("invalid decimal size", "decimals", e2); + } + function Mi$1(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + e2 = V$2.from(e2); + const i2 = e2.lt(Gn$1); + i2 && (e2 = e2.mul(Yn$1)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o22 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o22 : e2 = o22 + "." + n4, i2 && (e2 = "-" + e2), e2; + } + function be$2(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi$1(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht$3.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht$3.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht$3.throwArgumentError("too many decimal points", "value", e2); + let o22 = n4[0], h4 = n4[1]; + for (o22 || (o22 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn$1("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V$2.from(o22), b3 = V$2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn$1)), m3; + } + let dr$2 = class dr3 { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi$1(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr3) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o22 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o22 || Ht$3.throwArgumentError("invalid fixed format", "format", t2), r3 = o22[1] !== "u", i2 = parseInt(o22[2]), n4 = parseInt(o22[3]); + } + } else if (t2) { + const o22 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht$3.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o22("signed", "boolean", r3), i2 = o22("width", "number", i2), n4 = o22("decimals", "number", n4); + } + return i2 % 8 && Ht$3.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht$3.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr3(mr$2, r3, i2, n4); + } + }; + let Ut$2 = class Ut2 { + constructor(t2, r3, i2, n4) { + t2 !== mr$2 && Ht$3.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L$3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht$3.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut2.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut2.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut2.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be$2(this._value, this.format.decimals), i2 = be$2(t2._value, t2.format.decimals); + return Ut2.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut2.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn$1.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut2.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn$1.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht$3.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut2.from("1" + gr$2.substring(0, t2), this.format), n4 = O0$1.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); + } + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht$3.throwArgumentError("invalid byte width", "width", t2); + const r3 = V$2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe$1(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut2.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0$1(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut2.fromString(Mi$1(t2, r3), dr$2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3), n4 = be$2(t2, i2.decimals); + !i2.signed && n4.lt(Gn$1) && Vn$1("unsigned value cannot be negative", "overflow", "value", t2); + let o22 = null; + i2.signed ? o22 = n4.toTwos(i2.width).toHexString() : (o22 = n4.toHexString(), o22 = oe$1(o22, i2.width / 8)); + const h4 = Mi$1(n4, i2.decimals); + return new Ut2(mr$2, o22, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr$2.from(r3); + if (Ot$2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V$2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o22 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi$1(n4, i2.decimals); + return new Ut2(mr$2, o22, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut2.fromString(t2, r3); + if (ir$2(t2)) + return Ut2.fromBytes(t2, r3); + try { + return Ut2.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L$3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht$3.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } + }; + const Wn$1 = Ut$2.from(1), O0$1 = Ut$2.from("0.5"), P0 = "strings/5.7.0", Xn = new L$3(P0); + var Or$2; + (function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; + })(Or$2 || (Or$2 = {})); + var nr$2; + (function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; + })(nr$2 || (nr$2 = {})); + function Ei(e2, t2 = Or$2.current) { + t2 != Or$2.current && (Xn.checkNormalize(), e2 = e2.normalize(t2)); + let r3 = []; + for (let i2 = 0; i2 < e2.length; i2++) { + const n4 = e2.charCodeAt(i2); + if (n4 < 128) + r3.push(n4); + else if (n4 < 2048) + r3.push(n4 >> 6 | 192), r3.push(n4 & 63 | 128); + else if ((n4 & 64512) == 55296) { + i2++; + const o22 = e2.charCodeAt(i2); + if (i2 >= e2.length || (o22 & 64512) !== 56320) + throw new Error("invalid utf-8 string"); + const h4 = 65536 + ((n4 & 1023) << 10) + (o22 & 1023); + r3.push(h4 >> 18 | 240), r3.push(h4 >> 12 & 63 | 128), r3.push(h4 >> 6 & 63 | 128), r3.push(h4 & 63 | 128); + } else + r3.push(n4 >> 12 | 224), r3.push(n4 >> 6 & 63 | 128), r3.push(n4 & 63 | 128); + } + return Ot$2(r3); + } + function T0$1(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; + } + function Si$1(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; + }); + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o22 = n4.split(":"); + r3 += parseInt(o22[0], 16), i2[r3] = t2(o22[1]); + }), i2; + } + function $n$1(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); + } + $n$1("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si$1("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si$1("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si$1("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0$1), $n$1("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); + function U0$1(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot$2(t2); + } + function ef$1(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o22, h4) { + i2.call(o22, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); + }); }; - exports22.stringifyUrl = (object, options) => { - options = Object.assign({ - encode: true, - strict: true, - [encodeFragmentIdentifier]: true - }, options); - const url = removeHash(object.url).split("?")[0] || ""; - const queryFromUrl = exports22.extract(object.url); - const parsedQueryFromUrl = exports22.parse(queryFromUrl, { sort: false }); - const query = Object.assign(parsedQueryFromUrl, object.query); - let queryString2 = exports22.stringify(query, options); - if (queryString2) { - queryString2 = `?${queryString2}`; - } - let hash2 = getHash(object.url); - if (object.fragmentIdentifier) { - hash2 = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; + return n4(e2, t2), r3; + } + function k0$1(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; + } + return t2; + } + function q0$1(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o22 = [0, 1]; + for (let H22 = 1; H22 < i2; H22++) + o22.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N22 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H22 = 0; H22 < y3; H22++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H22 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H22 < o22[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o22[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o22[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N22; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H22) => { + switch (H22 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H22 - 1; } - return `${url}${queryString2}${hash2}`; - }; - exports22.pick = (input, filter, options) => { - options = Object.assign({ - parseFragmentIdentifier: true, - [encodeFragmentIdentifier]: false - }, options); - const { url, query, fragmentIdentifier } = exports22.parseUrl(input, options); - return exports22.stringifyUrl({ - url, - query: filterObject(query, filter), - fragmentIdentifier - }, options); - }; - exports22.exclude = (input, filter, options) => { - const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); - return exports22.pick(input, exclusionFilter, options); - }; - })(queryString); - const RELAY_JSONRPC = { - waku: { - publish: "waku_publish", - batchPublish: "waku_batchPublish", - subscribe: "waku_subscribe", - batchSubscribe: "waku_batchSubscribe", - subscription: "waku_subscription", - unsubscribe: "waku_unsubscribe", - batchUnsubscribe: "waku_batchUnsubscribe" - }, - irn: { - publish: "irn_publish", - batchPublish: "irn_batchPublish", - subscribe: "irn_subscribe", - batchSubscribe: "irn_batchSubscribe", - subscription: "irn_subscription", - unsubscribe: "irn_unsubscribe", - batchUnsubscribe: "irn_batchUnsubscribe" - }, - iridium: { - publish: "iridium_publish", - batchPublish: "iridium_batchPublish", - subscribe: "iridium_subscribe", - batchSubscribe: "iridium_batchSubscribe", - subscription: "iridium_subscription", - unsubscribe: "iridium_unsubscribe", - batchUnsubscribe: "iridium_batchUnsubscribe" + }); + } + function K0$1(e2) { + let t2 = 0; + return () => e2[t2++]; + } + function H0$1(e2) { + return K0$1(q0$1(e2)); + } + function z0$1(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; + } + function L0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; + } + function rf$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; + } + function j0$1(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0$1(t2()); + return r3; + } + function Pr$2(e2, t2) { + let r3 = rf$1(e2(), e2), i2 = e2(), n4 = rf$1(i2, e2), o22 = L0$1(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o22[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; + } + function Q0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0$1(r3, e2)); + } + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0$1(r3, e2)); + } + return k0$1(ef$1(t2)); + } + function J0$1(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); } - }; - function L$1$1(e2, n3) { - return e2.includes(":") ? [e2] : n3.chains || []; + return t2; } - const J$1 = "base10", p$1 = "base16", F$2 = "base64pad", H$1 = "utf8", Q$2 = 0, _$1$1 = 1, Dn = 0, Te$1 = 1, Z$1$1 = 12, X$1 = 32; - function kn() { - const e2 = x25519.generateKeyPair(); - return { privateKey: toString(e2.secretKey, p$1), publicKey: toString(e2.publicKey, p$1) }; + function nf$1(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0$1(e2, r3).forEach((o22, h4) => i2[h4].push(o22)); + return i2; + } + function G0$1(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0$1(t2), o22 = nf$1(n4.length, 1 + e2, t2); + return ef$1(o22.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; + }); + })); + } + function Y0$1(e2, t2) { + let r3 = 1 + t2(); + return nf$1(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); + } + function V0$1(e2) { + let t2 = Pr$2(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr$2(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o22 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o22, fe0f: h4, save: p2, check: b3 }; + } + } + function W0$1() { + return H0$1(U0$1("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); + } + const Dr$2 = W0$1(); + new Set(Pr$2(Dr$2)), new Set(Pr$2(Dr$2)), Q0$1(Dr$2), V0$1(Dr$2); + const X0$1 = new Uint8Array(32); + X0$1.fill(0); + const Z0 = `Ethereum Signed Message: +`; + function ff(e2) { + return typeof e2 == "string" && (e2 = Ei(e2)), yi(E0([Ei(Z0), Ei(String(e2.length)), e2])); + } + const ts$2 = "address/5.7.0", Ar$1 = new L$3(ts$2); + function of(e2) { + Qt$1(e2, 20) || Ar$1.throwArgumentError("invalid address", "address", e2), e2 = e2.toLowerCase(); + const t2 = e2.substring(2).split(""), r3 = new Uint8Array(40); + for (let n4 = 0; n4 < 40; n4++) + r3[n4] = t2[n4].charCodeAt(0); + const i2 = Ot$2(yi(r3)); + for (let n4 = 0; n4 < 40; n4 += 2) + i2[n4 >> 1] >> 4 >= 8 && (t2[n4] = t2[n4].toUpperCase()), (i2[n4 >> 1] & 15) >= 8 && (t2[n4 + 1] = t2[n4 + 1].toUpperCase()); + return "0x" + t2.join(""); + } + const es$2 = 9007199254740991; + function rs$2(e2) { + return Math.log10 ? Math.log10(e2) : Math.log(e2) / Math.LN10; + } + const Ni = {}; + for (let e2 = 0; e2 < 10; e2++) + Ni[String(e2)] = String(e2); + for (let e2 = 0; e2 < 26; e2++) + Ni[String.fromCharCode(65 + e2)] = String(10 + e2); + const sf = Math.floor(rs$2(es$2)); + function is$2(e2) { + e2 = e2.toUpperCase(), e2 = e2.substring(4) + e2.substring(0, 2) + "00"; + let t2 = e2.split("").map((i2) => Ni[i2]).join(""); + for (; t2.length >= sf; ) { + let i2 = t2.substring(0, sf); + t2 = parseInt(i2, 10) % 97 + t2.substring(i2.length); + } + let r3 = String(98 - parseInt(t2, 10) % 97); + for (; r3.length < 2; ) + r3 = "0" + r3; + return r3; + } + function ns$1(e2) { + let t2 = null; + if (typeof e2 != "string" && Ar$1.throwArgumentError("invalid address", "address", e2), e2.match(/^(0x)?[0-9a-fA-F]{40}$/)) + e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), t2 = of(e2), e2.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && t2 !== e2 && Ar$1.throwArgumentError("bad address checksum", "address", e2); + else if (e2.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + for (e2.substring(2, 4) !== is$2(e2) && Ar$1.throwArgumentError("bad icap checksum", "address", e2), t2 = R0(e2.substring(4)); t2.length < 40; ) + t2 = "0" + t2; + t2 = of("0x" + t2); + } else + Ar$1.throwArgumentError("invalid address", "address", e2); + return t2; } - function Vn() { - const e2 = random.randomBytes(X$1); - return toString(e2, p$1); + function br$1(e2, t2, r3) { + Object.defineProperty(e2, t2, { enumerable: true, value: r3, writable: false }); + } + const os$2 = new Uint8Array(32); + os$2.fill(0), V$2.from(-1); + const ss$3 = V$2.from(0), as$2 = V$2.from(1); + V$2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe$1(as$2.toHexString(), 32), oe$1(ss$3.toHexString(), 32); + var se$2 = {}, Q$2 = {}, yr$2 = af$1; + function af$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); + } + af$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); + }; + var Ii$1 = { exports: {} }; + typeof Object.create == "function" ? Ii$1.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); + } : Ii$1.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; + } + }; + var us$2 = yr$2, hs$2 = Ii$1.exports; + Q$2.inherits = hs$2; + function cs$2(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; } - function Mn(e2, n3) { - const t2 = x25519.sharedKey(fromString(e2, p$1), fromString(n3, p$1), true), r2 = new HKDF_1(sha256.SHA256, t2).expand(X$1); - return toString(r2, p$1); + function ls$2(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o22 = e2.charCodeAt(n4); + o22 < 128 ? r3[i2++] = o22 : o22 < 2048 ? (r3[i2++] = o22 >> 6 | 192, r3[i2++] = o22 & 63 | 128) : cs$2(e2, n4) ? (o22 = 65536 + ((o22 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o22 >> 18 | 240, r3[i2++] = o22 >> 12 & 63 | 128, r3[i2++] = o22 >> 6 & 63 | 128, r3[i2++] = o22 & 63 | 128) : (r3[i2++] = o22 >> 12 | 224, r3[i2++] = o22 >> 6 & 63 | 128, r3[i2++] = o22 & 63 | 128); + } + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; + } + Q$2.toArray = ls$2; + function ds$2(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf$1(e2[r3].toString(16)); + return t2; } - function Kn(e2) { - const n3 = sha256.hash(fromString(e2, p$1)); - return toString(n3, p$1); + Q$2.toHex = ds$2; + function uf$1(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; } - function Ln(e2) { - const n3 = sha256.hash(fromString(e2, H$1)); - return toString(n3, p$1); + Q$2.htonl = uf$1; + function ps$2(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf$1(n4)), r3 += cf$1(n4.toString(16)); + } + return r3; } - function Pe$1(e2) { - return fromString(`${e2}`, J$1); + Q$2.toHex32 = ps$2; + function hf$1(e2) { + return e2.length === 1 ? "0" + e2 : e2; } - function j$1(e2) { - return Number(toString(e2, J$1)); + Q$2.zero2 = hf$1; + function cf$1(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; } - function xn(e2) { - const n3 = Pe$1(typeof e2.type < "u" ? e2.type : Q$2); - if (j$1(n3) === _$1$1 && typeof e2.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - const t2 = typeof e2.senderPublicKey < "u" ? fromString(e2.senderPublicKey, p$1) : void 0, r2 = typeof e2.iv < "u" ? fromString(e2.iv, p$1) : random.randomBytes(Z$1$1), o22 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, p$1)).seal(r2, fromString(e2.message, H$1)); - return Re$1({ type: n3, sealed: o22, iv: r2, senderPublicKey: t2 }); + Q$2.zero8 = cf$1; + function vs$2(e2, t2, r3, i2) { + var n4 = r3 - t2; + us$2(n4 % 4 === 0); + for (var o22 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o22.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o22[h4] = b3 >>> 0; + } + return o22; } - function Fn(e2) { - const n3 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, p$1)), { sealed: t2, iv: r2 } = ee$1(e2.encoded), o22 = n3.open(r2, t2); - if (o22 === null) - throw new Error("Failed to decrypt"); - return toString(o22, H$1); + Q$2.join32 = vs$2; + function ms$3(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o22 = e2[i2]; + t2 === "big" ? (r3[n4] = o22 >>> 24, r3[n4 + 1] = o22 >>> 16 & 255, r3[n4 + 2] = o22 >>> 8 & 255, r3[n4 + 3] = o22 & 255) : (r3[n4 + 3] = o22 >>> 24, r3[n4 + 2] = o22 >>> 16 & 255, r3[n4 + 1] = o22 >>> 8 & 255, r3[n4] = o22 & 255); + } + return r3; + } + Q$2.split32 = ms$3; + function gs$2(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; + } + Q$2.rotr32 = gs$2; + function As$2(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; + } + Q$2.rotl32 = As$2; + function bs$2(e2, t2) { + return e2 + t2 >>> 0; + } + Q$2.sum32 = bs$2; + function ys$2(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; + } + Q$2.sum32_3 = ys$2; + function ws$2(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; + } + Q$2.sum32_4 = ws$2; + function xs$2(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; + } + Q$2.sum32_5 = xs$2; + function Ms$2(e2, t2, r3, i2) { + var n4 = e2[t2], o22 = e2[t2 + 1], h4 = i2 + o22 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; + } + Q$2.sum64 = Ms$2; + function Es$2(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o22 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o22 >>> 0; + } + Q$2.sum64_hi = Es$2; + function Ss$2(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; + } + Q$2.sum64_lo = Ss$2; + function Ns$2(e2, t2, r3, i2, n4, o22, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o22 >>> 0, b3 += m3 < o22 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; + } + Q$2.sum64_4_hi = Ns$2; + function Is$2(e2, t2, r3, i2, n4, o22, h4, p2) { + var b3 = t2 + i2 + o22 + p2; + return b3 >>> 0; + } + Q$2.sum64_4_lo = Is$2; + function _s$2(e2, t2, r3, i2, n4, o22, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o22 >>> 0, w3 += y3 < o22 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; + } + Q$2.sum64_5_hi = _s$2; + function Bs$2(e2, t2, r3, i2, n4, o22, h4, p2, b3, m3) { + var w3 = t2 + i2 + o22 + p2 + m3; + return w3 >>> 0; + } + Q$2.sum64_5_lo = Bs$2; + function Cs$2(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; + } + Q$2.rotr64_hi = Cs$2; + function Rs$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; + } + Q$2.rotr64_lo = Rs$2; + function Os$2(e2, t2, r3) { + return e2 >>> r3; + } + Q$2.shr64_hi = Os$2; + function Ps$2(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; + } + Q$2.shr64_lo = Ps$2; + var fr$1 = {}, lf$1 = Q$2, Ds$2 = yr$2; + function Fr$2() { + 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; + } + fr$1.BlockHash = Fr$2, Fr$2.prototype.update = function(t2, r3) { + if (t2 = lf$1.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf$1.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; + }, Fr$2.prototype.digest = function(t2) { + return this.update(this._pad()), Ds$2(this.pending === null), this._digest(t2); + }, Fr$2.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o22 = 1; o22 < i2; o22++) + n4[o22] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o22++] = 0; + n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = t2 >>> 24 & 255, n4[o22++] = t2 >>> 16 & 255, n4[o22++] = t2 >>> 8 & 255, n4[o22++] = t2 & 255; + } else + for (n4[o22++] = t2 & 255, n4[o22++] = t2 >>> 8 & 255, n4[o22++] = t2 >>> 16 & 255, n4[o22++] = t2 >>> 24 & 255, n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o22++] = 0; + return n4; + }; + var or$2 = {}, ae$1 = {}, Fs$2 = Q$2, ue$1 = Fs$2.rotr32; + function Ts$2(e2, t2, r3, i2) { + if (e2 === 0) + return df$1(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf$1(t2, r3, i2); + if (e2 === 2) + return pf$1(t2, r3, i2); + } + ae$1.ft_1 = Ts$2; + function df$1(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; + } + ae$1.ch32 = df$1; + function pf$1(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; + } + ae$1.maj32 = pf$1; + function vf$1(e2, t2, r3) { + return e2 ^ t2 ^ r3; + } + ae$1.p32 = vf$1; + function Us$2(e2) { + return ue$1(e2, 2) ^ ue$1(e2, 13) ^ ue$1(e2, 22); + } + ae$1.s0_256 = Us$2; + function ks$2(e2) { + return ue$1(e2, 6) ^ ue$1(e2, 11) ^ ue$1(e2, 25); + } + ae$1.s1_256 = ks$2; + function qs$2(e2) { + return ue$1(e2, 7) ^ ue$1(e2, 18) ^ e2 >>> 3; + } + ae$1.g0_256 = qs$2; + function Ks$2(e2) { + return ue$1(e2, 17) ^ ue$1(e2, 19) ^ e2 >>> 10; + } + ae$1.g1_256 = Ks$2; + var sr$2 = Q$2, Hs$2 = fr$1, zs$2 = ae$1, _i$1 = sr$2.rotl32, wr$1 = sr$2.sum32, Ls$2 = sr$2.sum32_5, js$2 = zs$2.ft_1, mf$1 = Hs$2.BlockHash, Qs$2 = [1518500249, 1859775393, 2400959708, 3395469782]; + function he$1() { + if (!(this instanceof he$1)) + return new he$1(); + mf$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); + } + sr$2.inherits(he$1, mf$1); + var Js$2 = he$1; + he$1.blockSize = 512, he$1.outSize = 160, he$1.hmacStrength = 80, he$1.padLength = 64, he$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i$1(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o22 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls$2(_i$1(o22, 5), js$2(w3, h4, p2, b3), m3, i2[n4], Qs$2[w3]); + m3 = b3, b3 = p2, p2 = _i$1(h4, 30), h4 = o22, o22 = y3; + } + this.h[0] = wr$1(this.h[0], o22), this.h[1] = wr$1(this.h[1], h4), this.h[2] = wr$1(this.h[2], p2), this.h[3] = wr$1(this.h[3], b3), this.h[4] = wr$1(this.h[4], m3); + }, he$1.prototype._digest = function(t2) { + return t2 === "hex" ? sr$2.toHex32(this.h, "big") : sr$2.split32(this.h, "big"); + }; + var ar$2 = Q$2, Gs$2 = fr$1, ur$2 = ae$1, Ys$2 = yr$2, ie$3 = ar$2.sum32, Vs$2 = ar$2.sum32_4, Ws$2 = ar$2.sum32_5, Xs$2 = ur$2.ch32, Zs$2 = ur$2.maj32, $s$2 = ur$2.s0_256, ta$1 = ur$2.s1_256, ea$1 = ur$2.g0_256, ra$1 = ur$2.g1_256, gf$1 = Gs$2.BlockHash, ia$1 = [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 ce$1() { + if (!(this instanceof ce$1)) + return new ce$1(); + gf$1.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia$1, this.W = new Array(64); + } + ar$2.inherits(ce$1, gf$1); + var Af$1 = ce$1; + ce$1.blockSize = 512, ce$1.outSize = 256, ce$1.hmacStrength = 192, ce$1.padLength = 64, ce$1.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs$2(ra$1(i2[n4 - 2]), i2[n4 - 7], ea$1(i2[n4 - 15]), i2[n4 - 16]); + var o22 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys$2(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws$2(S2, ta$1(m3), Xs$2(m3, w3, y3), this.k[n4], i2[n4]), N22 = ie$3($s$2(o22), Zs$2(o22, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie$3(b3, I2), b3 = p2, p2 = h4, h4 = o22, o22 = ie$3(I2, N22); + } + this.h[0] = ie$3(this.h[0], o22), this.h[1] = ie$3(this.h[1], h4), this.h[2] = ie$3(this.h[2], p2), this.h[3] = ie$3(this.h[3], b3), this.h[4] = ie$3(this.h[4], m3), this.h[5] = ie$3(this.h[5], w3), this.h[6] = ie$3(this.h[6], y3), this.h[7] = ie$3(this.h[7], S2); + }, ce$1.prototype._digest = function(t2) { + return t2 === "hex" ? ar$2.toHex32(this.h, "big") : ar$2.split32(this.h, "big"); + }; + var Bi$1 = Q$2, bf$1 = Af$1; + function ye$2() { + if (!(this instanceof ye$2)) + return new ye$2(); + bf$1.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; + } + Bi$1.inherits(ye$2, bf$1); + var na$1 = ye$2; + ye$2.blockSize = 512, ye$2.outSize = 224, ye$2.hmacStrength = 192, ye$2.padLength = 64, ye$2.prototype._digest = function(t2) { + return t2 === "hex" ? Bi$1.toHex32(this.h.slice(0, 7), "big") : Bi$1.split32(this.h.slice(0, 7), "big"); + }; + var jt$2 = Q$2, fa$1 = fr$1, oa$1 = yr$2, le$1 = jt$2.rotr64_hi, de$2 = jt$2.rotr64_lo, yf$1 = jt$2.shr64_hi, wf$1 = jt$2.shr64_lo, Be$3 = jt$2.sum64, Ci$1 = jt$2.sum64_hi, Ri$1 = jt$2.sum64_lo, sa$1 = jt$2.sum64_4_hi, aa$1 = jt$2.sum64_4_lo, ua$1 = jt$2.sum64_5_hi, ha$1 = jt$2.sum64_5_lo, xf$1 = fa$1.BlockHash, ca$1 = [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 ne$2() { + if (!(this instanceof ne$2)) + return new ne$2(); + xf$1.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca$1, this.W = new Array(160); + } + jt$2.inherits(ne$2, xf$1); + var Mf$1 = ne$2; + ne$2.blockSize = 1024, ne$2.outSize = 512, ne$2.hmacStrength = 192, ne$2.padLength = 128, ne$2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o22 = xa$1(i2[n4 - 4], i2[n4 - 3]), h4 = Ma$1(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya$1(i2[n4 - 30], i2[n4 - 29]), w3 = wa$1(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa$1(o22, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa$1(o22, h4, p2, b3, m3, w3, y3, S2); + } + }, ne$2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o22 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N22 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa$1(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H22 = J2, z2 = Bt2, Pt2 = Aa$1(S2, I2), W2 = ba$1(S2, I2), Rt2 = la$1(S2, I2, N22, C2, F2), Yt3 = da$1(S2, I2, N22, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua$1(H22, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha$1(H22, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H22 = ma$1(n4, o22), z2 = ga$1(n4, o22), Pt2 = pa$1(n4, o22, h4, p2, b3), W2 = va$1(n4, o22, h4, p2, b3, m3); + var d5 = Ci$1(H22, z2, Pt2, W2), g3 = Ri$1(H22, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N22, U2 = C2, N22 = S2, C2 = I2, S2 = Ci$1(w3, y3, a3, c2), I2 = Ri$1(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o22, n4 = Ci$1(a3, c2, d5, g3), o22 = Ri$1(a3, c2, d5, g3); + } + Be$3(this.h, 0, n4, o22), Be$3(this.h, 2, h4, p2), Be$3(this.h, 4, b3, m3), Be$3(this.h, 6, w3, y3), Be$3(this.h, 8, S2, I2), Be$3(this.h, 10, N22, C2), Be$3(this.h, 12, F2, U2), Be$3(this.h, 14, J2, Bt2); + }, ne$2.prototype._digest = function(t2) { + return t2 === "hex" ? jt$2.toHex32(this.h, "big") : jt$2.split32(this.h, "big"); + }; + function la$1(e2, t2, r3, i2, n4) { + var o22 = e2 & r3 ^ ~e2 & n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function da$1(e2, t2, r3, i2, n4, o22) { + var h4 = t2 & i2 ^ ~t2 & o22; + return h4 < 0 && (h4 += 4294967296), h4; + } + function pa$1(e2, t2, r3, i2, n4) { + var o22 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function va$1(e2, t2, r3, i2, n4, o22) { + var h4 = t2 & i2 ^ t2 & o22 ^ i2 & o22; + return h4 < 0 && (h4 += 4294967296), h4; + } + function ma$1(e2, t2) { + var r3 = le$1(e2, t2, 28), i2 = le$1(t2, e2, 2), n4 = le$1(t2, e2, 7), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function ga$1(e2, t2) { + var r3 = de$2(e2, t2, 28), i2 = de$2(t2, e2, 2), n4 = de$2(t2, e2, 7), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function Aa$1(e2, t2) { + var r3 = le$1(e2, t2, 14), i2 = le$1(e2, t2, 18), n4 = le$1(t2, e2, 9), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function ba$1(e2, t2) { + var r3 = de$2(e2, t2, 14), i2 = de$2(e2, t2, 18), n4 = de$2(t2, e2, 9), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function ya$1(e2, t2) { + var r3 = le$1(e2, t2, 1), i2 = le$1(e2, t2, 8), n4 = yf$1(e2, t2, 7), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function wa$1(e2, t2) { + var r3 = de$2(e2, t2, 1), i2 = de$2(e2, t2, 8), n4 = wf$1(e2, t2, 7), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function xa$1(e2, t2) { + var r3 = le$1(e2, t2, 19), i2 = le$1(t2, e2, 29), n4 = yf$1(e2, t2, 6), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function Ma$1(e2, t2) { + var r3 = de$2(e2, t2, 19), i2 = de$2(t2, e2, 29), n4 = wf$1(e2, t2, 6), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + var Oi$1 = Q$2, Ef$1 = Mf$1; + function we$1() { + if (!(this instanceof we$1)) + return new we$1(); + Ef$1.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; + } + Oi$1.inherits(we$1, Ef$1); + var Ea$1 = we$1; + we$1.blockSize = 1024, we$1.outSize = 384, we$1.hmacStrength = 192, we$1.padLength = 128, we$1.prototype._digest = function(t2) { + return t2 === "hex" ? Oi$1.toHex32(this.h.slice(0, 12), "big") : Oi$1.split32(this.h.slice(0, 12), "big"); + }, or$2.sha1 = Js$2, or$2.sha224 = na$1, or$2.sha256 = Af$1, or$2.sha384 = Ea$1, or$2.sha512 = Mf$1; + var Sf$1 = {}, Xe$3 = Q$2, Sa$1 = fr$1, Tr$2 = Xe$3.rotl32, Nf$1 = Xe$3.sum32, xr$2 = Xe$3.sum32_3, If$1 = Xe$3.sum32_4, _f$1 = Sa$1.BlockHash; + function pe$2() { + if (!(this instanceof pe$2)) + return new pe$2(); + _f$1.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; + } + Xe$3.inherits(pe$2, _f$1), Sf$1.ripemd160 = pe$2, pe$2.blockSize = 512, pe$2.outSize = 160, pe$2.hmacStrength = 192, pe$2.padLength = 64, pe$2.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o22 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o22, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N22 = Nf$1(Tr$2(If$1(i2, Bf$1(I2, n4, o22, h4), t2[_a$1[I2] + r3], Na$1(I2)), Ca$1[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr$2(o22, 10), o22 = n4, n4 = N22, N22 = Nf$1(Tr$2(If$1(b3, Bf$1(79 - I2, m3, w3, y3), t2[Ba$1[I2] + r3], Ia$1(I2)), Ra$1[I2]), S2), b3 = S2, S2 = y3, y3 = Tr$2(w3, 10), w3 = m3, m3 = N22; + } + N22 = xr$2(this.h[1], o22, y3), this.h[1] = xr$2(this.h[2], h4, S2), this.h[2] = xr$2(this.h[3], p2, b3), this.h[3] = xr$2(this.h[4], i2, m3), this.h[4] = xr$2(this.h[0], n4, w3), this.h[0] = N22; + }, pe$2.prototype._digest = function(t2) { + return t2 === "hex" ? Xe$3.toHex32(this.h, "little") : Xe$3.split32(this.h, "little"); + }; + function Bf$1(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); + } + function Na$1(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; + } + function Ia$1(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; + } + var _a$1 = [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], Ba$1 = [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], Ca$1 = [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], Ra$1 = [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], Oa$1 = Q$2, Pa$1 = yr$2; + function hr$2(e2, t2, r3) { + if (!(this instanceof hr$2)) + return new hr$2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa$1.toArray(t2, r3)); + } + var Da$1 = hr$2; + hr$2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa$1(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); + }, hr$2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; + }, hr$2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); + }, function(e2) { + var t2 = e2; + t2.utils = Q$2, t2.common = fr$1, t2.sha = or$2, t2.ripemd = Sf$1, t2.hmac = Da$1, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; + }(se$2); + function cr$2(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa$1(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; + } + function Fa$1() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); + } + var Pi$1 = Cf$1; + function Cf$1(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); + } + Cf$1.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); + }; + var fe$2 = cr$2(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); + } + return b3; + } + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; + } + r3.zero2 = n4; + function o22(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o22, r3.encode = function(p2, b3) { + return b3 === "hex" ? o22(p2) : p2; + }; + }), Jt$3 = cr$2(function(e2, t2) { + var r3 = t2; + r3.assert = Pi$1, r3.toArray = fe$2.toArray, r3.zero2 = fe$2.zero2, r3.toHex = fe$2.toHex, r3.encode = fe$2.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N22 = 0; N22 < y3.length; N22++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N22] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N22 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N22 === 3 && (N22 = -1), C2 === 3 && (C2 = -1); + var F2; + N22 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N22 : F2 = N22) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N22 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o22(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o22; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K$2(b3, "hex", "le"); + } + r3.intFromLE = p2; + }), Ur$2 = Jt$3.getNAF, Ta$1 = Jt$3.getJSF, kr$2 = Jt$3.assert; + function Ce$1(e2, t2) { + this.type = e2, this.p = new K$2(t2.p, 16), this.red = t2.prime ? K$2.red(t2.prime) : K$2.mont(this.p), this.zero = new K$2(0).toRed(this.red), this.one = new K$2(1).toRed(this.red), this.two = new K$2(2).toRed(this.red), this.n = t2.n && new K$2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); + } + var Ze$2 = Ce$1; + Ce$1.prototype.point = function() { + throw new Error("Not implemented"); + }, Ce$1.prototype.validate = function() { + throw new Error("Not implemented"); + }, Ce$1.prototype._fixedNafMul = function(t2, r3) { + kr$2(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur$2(r3, 1, this._bitLength), o22 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o22 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o22; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); + }, Ce$1.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o22 = n4.points, h4 = Ur$2(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr$2(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o22[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o22[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o22[w3 - 1 >> 1]) : p2 = p2.add(o22[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; + }, Ce$1.prototype._wnafMulAdd = function(t2, r3, i2, n4, o22) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N22 = w3 - 1, C2 = w3; + if (h4[N22] !== 1 || h4[C2] !== 1) { + b3[N22] = Ur$2(i2[N22], h4[N22], this._bitLength), b3[C2] = Ur$2(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N22].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; + } + var F2 = [r3[N22], null, null, r3[C2]]; + r3[N22].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N22].add(r3[C2]), F2[2] = r3[N22].toJ().mixedAdd(r3[C2].neg())) : r3[N22].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N22].toJ().mixedAdd(r3[C2]), F2[2] = r3[N22].add(r3[C2].neg())) : (F2[1] = r3[N22].toJ().mixedAdd(r3[C2]), F2[2] = r3[N22].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta$1(i2[N22], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N22] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N22][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N22] = F2; + } + } + var H22 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; + } + if (w3 >= 0 && Pt2++, H22 = H22.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H22 = H22.mixedAdd(S2) : H22 = H22.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o22 ? H22 : H22.toP(); + }; + function Xt$3(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; + } + Ce$1.BasePoint = Xt$3, Xt$3.prototype.eq = function() { + throw new Error("Not implemented"); + }, Xt$3.prototype.validate = function() { + return this.curve.validate(this); + }, Ce$1.prototype.decodePoint = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr$2(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr$2(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); + }, Xt$3.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); + }, Xt$3.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); + }, Xt$3.prototype.encode = function(t2, r3) { + return Jt$3.encode(this._encode(r3), t2); + }, Xt$3.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; + }, Xt$3.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; + }, Xt$3.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o22 = 0; o22 < r3; o22 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; + }, Xt$3.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o22 = 1; o22 < i2; o22++) + r3[o22] = r3[o22 - 1].add(n4); + return { wnd: t2, points: r3 }; + }, Xt$3.prototype._getBeta = function() { + return null; + }, Xt$3.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; + }; + var Di$1 = cr$2(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; + }), Ua$1 = Jt$3.assert; + function Zt$2(e2) { + Ze$2.call(this, "short", e2), this.a = new K$2(e2.a, 16).toRed(this.red), this.b = new K$2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); + } + Di$1(Zt$2, Ze$2); + var ka$1 = Zt$2; + Zt$2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K$2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K$2(t2.lambda, 16); + else { + var o22 = this._getEndoRoots(this.n); + this.g.mul(o22[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o22[0] : (i2 = o22[1], Ua$1(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K$2(p2.a, 16), b: new K$2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } + }, Zt$2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K$2.mont(t2), i2 = new K$2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o22 = new K$2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o22).fromRed(), p2 = n4.redSub(o22).fromRed(); + return [h4, p2]; + }, Zt$2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o22 = new K$2(1), h4 = new K$2(0), p2 = new K$2(0), b3 = new K$2(1), m3, w3, y3, S2, I2, N22, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o22)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o22, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o22, o22 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N22 = J2; + var H22 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N22.sqr()); + return z2.cmp(H22) >= 0 && (I2 = m3, N22 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N22 = N22.neg()), [{ a: y3, b: S2 }, { a: I2, b: N22 }]; + }, Zt$2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o22 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o22.mul(i2.a), b3 = h4.mul(n4.a), m3 = o22.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; + }, Zt$2.prototype.pointFromX = function(t2, r3) { + t2 = new K$2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o22 = n4.fromRed().isOdd(); + return (r3 && !o22 || !r3 && o22) && (n4 = n4.redNeg()), this.point(t2, n4); + }, Zt$2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o22 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o22).cmpn(0) === 0; + }, Zt$2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o22 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o22[h4 * 2] = p2.k1, o22[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o22, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o22[y3] = null; + return w3; + }; + function Ft$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); + } + Di$1(Ft$2, Ze$2.BasePoint), Zt$2.prototype.point = function(t2, r3, i2) { + return new Ft$2(this, t2, r3, i2); + }, Zt$2.prototype.pointFromJSON = function(t2, r3) { + return Ft$2.fromJSON(this, t2, r3); + }, Ft$2.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o22) { + return i2.point(o22.x.redMul(i2.endo.beta), o22.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } + }, Ft$2.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; + }, Ft$2.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o22(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o22)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o22)) } }, n4; + }, Ft$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, Ft$2.prototype.isInfinity = function() { + return this.inf; + }, Ft$2.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); + }, Ft$2.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o22 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o22.redSqr().redISub(this.x.redAdd(this.x)), p2 = o22.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); + }, Ft$2.prototype.getX = function() { + return this.x.fromRed(); + }, Ft$2.prototype.getY = function() { + return this.y.fromRed(); + }, Ft$2.prototype.mul = function(t2) { + return t2 = new K$2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); + }, Ft$2.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o22 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o22) : this.curve._wnafMulAdd(1, n4, o22, 2); + }, Ft$2.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o22 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o22, true) : this.curve._wnafMulAdd(1, n4, o22, 2, true); + }, Ft$2.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); + }, Ft$2.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o22) { + return o22.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; + }, Ft$2.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; + }; + function Tt$2(e2, t2, r3, i2) { + Ze$2.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K$2(0)) : (this.x = new K$2(t2, 16), this.y = new K$2(r3, 16), this.z = new K$2(i2, 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; + } + Di$1(Tt$2, Ze$2.BasePoint), Zt$2.prototype.jpoint = function(t2, r3, i2) { + return new Tt$2(this, t2, r3, i2); + }, Tt$2.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); + }, Tt$2.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }, Tt$2.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o22 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o22), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N22 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N22, C2); + }, Tt$2.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o22 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o22.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o22.redMul(w3)), N22 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N22); + }, Tt$2.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o22 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N22 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N22.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N22.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o22), b3); + }, Tt$2.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); + }, Tt$2.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o22 = this.y.redSqr(), h4 = o22.redSqr(), p2 = this.x.redAdd(o22).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N22 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N22 = N22.redIAdd(N22); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N22).redISub(N22), r3 = C2.redMul(N22.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); + }, Tt$2.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o22 = this.y.redSqr(), h4 = o22.redSqr(), p2 = this.x.redAdd(o22).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N22 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N22 = N22.redAdd(N22).redIAdd(N22); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N22.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N22.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); + }, Tt$2.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o22 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o22)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N22 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N22, C2); + }, Tt$2.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o22 = t2.redAdd(t2).redIAdd(t2), h4 = o22.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o22.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N22 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N22); + }, Tt$2.prototype.mul = function(t2, r3) { + return t2 = new K$2(t2, r3), this.curve._wnafMul(this, t2); + }, Tt$2.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o22 = i2.redMul(t2.z); + return this.y.redMul(o22).redISub(t2.y.redMul(n4)).cmpn(0) === 0; + }, Tt$2.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o22 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o22), this.x.cmp(i2) === 0) + return true; + } + }, Tt$2.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, Tt$2.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; + }; + var qr$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.base = Ze$2, r3.short = ka$1, r3.mont = null, r3.edwards = null; + }), Kr$1 = cr$2(function(e2, t2) { + var r3 = t2, i2 = Jt$3.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr$1.short(p2) : p2.type === "edwards" ? this.curve = new qr$1.edwards(p2) : this.curve = new qr$1.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o22(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o22("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: se$2.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o22("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: se$2.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o22("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: se$2.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o22("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: se$2.sha384, gRed: false, 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"] }), o22("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: se$2.sha512, gRed: false, 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"] }), o22("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se$2.sha256, gRed: false, g: ["9"] }), o22("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: se$2.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o22("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: se$2.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); + }); + function Re$2(e2) { + if (!(this instanceof Re$2)) + return new Re$2(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe$2.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe$2.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe$2.toArray(e2.pers, e2.persEnc || "hex"); + Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); + } + var Rf$1 = Re$2; + Re$2.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o22 = 0; o22 < this.V.length; o22++) + this.K[o22] = 0, this.V[o22] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; + }, Re$2.prototype._hmac = function() { + return new se$2.hmac(this.hash, this.K); + }, Re$2.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); + }, Re$2.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe$2.toArray(t2, r3), i2 = fe$2.toArray(i2, n4), Pi$1(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; + }, Re$2.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe$2.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o22 = []; o22.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o22 = o22.concat(this.V); + var h4 = o22.slice(0, t2); + return this._update(i2), this._reseed++, fe$2.encode(h4, r3); + }; + var Fi$1 = Jt$3.assert; + function kt$2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); + } + var Ti$1 = kt$2; + kt$2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { pub: r3, pubEnc: i2 }); + }, kt$2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt$2 ? r3 : new kt$2(t2, { priv: r3, privEnc: i2 }); + }, kt$2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; + }, kt$2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; + }, kt$2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; + }, kt$2.prototype._importPrivate = function(t2, r3) { + this.priv = new K$2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); + }, kt$2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi$1(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi$1(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); + }, kt$2.prototype.derive = function(t2) { + return t2.validate() || Fi$1(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); + }, kt$2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); + }, kt$2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); + }, kt$2.prototype.inspect = function() { + return ""; + }; + var qa$1 = Jt$3.assert; + function Hr$1(e2, t2) { + if (e2 instanceof Hr$1) + return e2; + this._importDER(e2, t2) || (qa$1(e2.r && e2.s, "Signature without r or s"), this.r = new K$2(e2.r, 16), this.s = new K$2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); + } + var zr$2 = Hr$1; + function Ka$1() { + this.place = 0; + } + function Ui$1(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o22 = 0, h4 = t2.place; o22 < i2; o22++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); + } + function Of$1(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); + } + Hr$1.prototype._importDER = function(t2, r3) { + t2 = Jt$3.toArray(t2, r3); + var i2 = new Ka$1(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui$1(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o22 = Ui$1(t2, i2); + if (o22 === false) + return false; + var h4 = t2.slice(i2.place, o22 + i2.place); + if (i2.place += o22, t2[i2.place++] !== 2) + return false; + var p2 = Ui$1(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K$2(h4), this.s = new K$2(b3), this.recoveryParam = null, true; + }; + function ki$1(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); + } + Hr$1.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of$1(r3), i2 = Of$1(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki$1(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki$1(n4, i2.length); + var o22 = n4.concat(i2), h4 = [48]; + return ki$1(h4, o22.length), h4 = h4.concat(o22), Jt$3.encode(h4, t2); + }; + var Ha$1 = function() { + throw new Error("unsupported"); + }, Pf$1 = Jt$3.assert; + function $t$2(e2) { + if (!(this instanceof $t$2)) + return new $t$2(e2); + typeof e2 == "string" && (Pf$1(Object.prototype.hasOwnProperty.call(Kr$1, e2), "Unknown curve " + e2), e2 = Kr$1[e2]), e2 instanceof Kr$1.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; + } + var za$1 = $t$2; + $t$2.prototype.keyPair = function(t2) { + return new Ti$1(this, t2); + }, $t$2.prototype.keyFromPrivate = function(t2, r3) { + return Ti$1.fromPrivate(this, t2, r3); + }, $t$2.prototype.keyFromPublic = function(t2, r3) { + return Ti$1.fromPublic(this, t2, r3); + }, $t$2.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf$1({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha$1(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K$2(2)); ; ) { + var o22 = new K$2(r3.generate(i2)); + if (!(o22.cmp(n4) > 0)) + return o22.iaddn(1), this.keyFromPrivate(o22); + } + }, $t$2.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; + }, $t$2.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K$2(t2, 16)); + for (var o22 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o22), p2 = t2.toArray("be", o22), b3 = new Rf$1({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K$2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K$2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N22 = I2.umod(this.n); + if (N22.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N22.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N22) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr$2({ r: N22, s: C2, recoveryParam: F2 }); + } + } + } + } + } + }, $t$2.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K$2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr$2(r3, "hex"); + var o22 = r3.r, h4 = r3.s; + if (o22.cmpn(1) < 0 || o22.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o22).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o22)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o22) === 0); + }, $t$2.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf$1((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr$2(t2, i2); + var n4 = this.n, o22 = new K$2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o22).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); + }, $t$2.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr$2(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o22; + try { + o22 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; + } + if (o22.eq(r3)) + return n4; + } + throw new Error("Unable to find valid recovery factor"); + }; + var La$1 = cr$2(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt$3, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr$1, r3.curves = Kr$1, r3.ec = za$1, r3.eddsa = null; + }), ja = La$1.ec; + const Qa = "signing-key/5.7.0", qi = new L$3(Qa); + let Ki = null; + function ve$1() { + return Ki || (Ki = new ja("secp256k1")), Ki; } - function Re$1(e2) { - if (j$1(e2.type) === _$1$1) { - if (typeof e2.senderPublicKey > "u") - throw new Error("Missing sender public key for type 1 envelope"); - return toString(concat([e2.type, e2.senderPublicKey, e2.iv, e2.sealed]), F$2); + class Ja { + constructor(t2) { + br$1(this, "curve", "secp256k1"), br$1(this, "privateKey", Kt$2(t2)), N0(this.privateKey) !== 32 && qi.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); + const r3 = ve$1().keyFromPrivate(Ot$2(this.privateKey)); + br$1(this, "publicKey", "0x" + r3.getPublic(false, "hex")), br$1(this, "compressedPublicKey", "0x" + r3.getPublic(true, "hex")), br$1(this, "_isSigningKey", true); + } + _addPoint(t2) { + const r3 = ve$1().keyFromPublic(Ot$2(this.publicKey)), i2 = ve$1().keyFromPublic(Ot$2(t2)); + return "0x" + r3.pub.add(i2.pub).encodeCompressed("hex"); } - return toString(concat([e2.type, e2.iv, e2.sealed]), F$2); + signDigest(t2) { + const r3 = ve$1().keyFromPrivate(Ot$2(this.privateKey)), i2 = Ot$2(t2); + i2.length !== 32 && qi.throwArgumentError("bad digest length", "digest", t2); + const n4 = r3.sign(i2, { canonical: true }); + return zn({ recoveryParam: n4.recoveryParam, r: oe$1("0x" + n4.r.toString(16), 32), s: oe$1("0x" + n4.s.toString(16), 32) }); + } + computeSharedSecret(t2) { + const r3 = ve$1().keyFromPrivate(Ot$2(this.privateKey)), i2 = ve$1().keyFromPublic(Ot$2(Df(t2))); + return oe$1("0x" + r3.derive(i2.getPublic()).toString(16), 32); + } + static isSigningKey(t2) { + return !!(t2 && t2._isSigningKey); + } + } + function Ga(e2, t2) { + const r3 = zn(t2), i2 = { r: Ot$2(r3.r), s: Ot$2(r3.s) }; + return "0x" + ve$1().recoverPubKey(Ot$2(e2), i2, r3.recoveryParam).encode("hex", false); } - function ee$1(e2) { - const n3 = fromString(e2, F$2), t2 = n3.slice(Dn, Te$1), r2 = Te$1; - if (j$1(t2) === _$1$1) { - const d3 = r2 + X$1, l2 = d3 + Z$1$1, c2 = n3.slice(r2, d3), u3 = n3.slice(d3, l2), a3 = n3.slice(l2); - return { type: t2, sealed: a3, iv: u3, senderPublicKey: c2 }; + function Df(e2, t2) { + const r3 = Ot$2(e2); + if (r3.length === 32) { + const i2 = new Ja(r3); + return i2.publicKey; + } else { + if (r3.length === 33) + return "0x" + ve$1().keyFromPublic(r3).getPublic(false, "hex"); + if (r3.length === 65) + return Kt$2(r3); + } + return qi.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); + } + var Ff$1; + (function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; + })(Ff$1 || (Ff$1 = {})); + function Va(e2) { + const t2 = Df(e2); + return ns$1(Hn(yi(Hn(t2, 1)), 12)); + } + function Wa(e2, t2) { + return Va(Ga(Ot$2(e2), t2)); + } + const Xa = "https://rpc.walletconnect.com/v1"; + async function Tf(e2, t2, r3, i2, n4, o22) { + switch (r3.t) { + case "eip191": + return Uf(e2, t2, r3.s); + case "eip1271": + return await kf(e2, t2, r3.s, i2, n4, o22); + default: + throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r3.t}`); } - const o22 = r2 + Z$1$1, s2 = n3.slice(r2, o22), i2 = n3.slice(o22); - return { type: t2, sealed: i2, iv: s2 }; } - function Hn(e2, n3) { - const t2 = ee$1(e2); - return Ae$1({ type: j$1(t2.type), senderPublicKey: typeof t2.senderPublicKey < "u" ? toString(t2.senderPublicKey, p$1) : void 0, receiverPublicKey: n3 == null ? void 0 : n3.receiverPublicKey }); + function Uf(e2, t2, r3) { + return Wa(ff(t2), r3).toLowerCase() === e2.toLowerCase(); } - function Ae$1(e2) { - const n3 = (e2 == null ? void 0 : e2.type) || Q$2; - if (n3 === _$1$1) { - if (typeof (e2 == null ? void 0 : e2.senderPublicKey) > "u") - throw new Error("missing sender public key"); - if (typeof (e2 == null ? void 0 : e2.receiverPublicKey) > "u") - throw new Error("missing receiver public key"); + async function kf(e2, t2, r3, i2, n4, o22) { + try { + const h4 = "0x1626ba7e", p2 = "0000000000000000000000000000000000000000000000000000000000000040", b3 = "0000000000000000000000000000000000000000000000000000000000000041", m3 = r3.substring(2), w3 = ff(t2).substring(2), y3 = h4 + w3 + p2 + b3 + m3, S2 = await fetch(`${o22 || Xa}/?chainId=${i2}&projectId=${n4}`, { method: "POST", body: JSON.stringify({ id: Za(), jsonrpc: "2.0", method: "eth_call", params: [{ to: e2, data: y3 }, "latest"] }) }), { result: I2 } = await S2.json(); + return I2 ? I2.slice(0, h4.length).toLowerCase() === h4.toLowerCase() : false; + } catch (h4) { + return console.error("isValidEip1271Signature: ", h4), false; } - return { type: n3, senderPublicKey: e2 == null ? void 0 : e2.senderPublicKey, receiverPublicKey: e2 == null ? void 0 : e2.receiverPublicKey }; } - function qn(e2) { - return e2.type === _$1$1 && typeof e2.senderPublicKey == "string" && typeof e2.receiverPublicKey == "string"; - } - var Bn = Object.defineProperty, Ue$1 = Object.getOwnPropertySymbols, Gn = Object.prototype.hasOwnProperty, Wn = Object.prototype.propertyIsEnumerable, _e$1 = (e2, n3, t2) => n3 in e2 ? Bn(e2, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e2[n3] = t2, $e$1 = (e2, n3) => { - for (var t2 in n3 || (n3 = {})) - Gn.call(n3, t2) && _e$1(e2, t2, n3[t2]); - if (Ue$1) - for (var t2 of Ue$1(n3)) - Wn.call(n3, t2) && _e$1(e2, t2, n3[t2]); - return e2; - }; - const Ce$1 = "ReactNative", m$1 = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, De$1 = "js"; - function te$1() { - return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; + function Za() { + return Date.now() + Math.floor(Math.random() * 1e3); } - function $$1() { - return !getDocument_1() && !!getNavigator_1() && navigator.product === Ce$1; + var $a = Object.defineProperty, tu = Object.defineProperties, eu = Object.getOwnPropertyDescriptors, qf = Object.getOwnPropertySymbols, ru = Object.prototype.hasOwnProperty, iu = Object.prototype.propertyIsEnumerable, Kf = (e2, t2, r3) => t2 in e2 ? $a(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, Hi$1 = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + ru.call(t2, r3) && Kf(e2, r3, t2[r3]); + if (qf) + for (var r3 of qf(t2)) + iu.call(t2, r3) && Kf(e2, r3, t2[r3]); + return e2; + }, Hf = (e2, t2) => tu(e2, eu(t2)); + const nu = "did:pkh:", Lr$1 = (e2) => e2 == null ? void 0 : e2.split(":"), zi = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return e2.includes(nu) ? t2[3] : t2[1]; + }, fu = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2[2] + ":" + t2[3]; + }, Li = (e2) => { + const t2 = e2 && Lr$1(e2); + if (t2) + return t2.pop(); + }; + async function ou(e2) { + const { cacao: t2, projectId: r3 } = e2, { s: i2, p: n4 } = t2, o22 = zf(n4, n4.iss), h4 = Li(n4.iss); + return await Tf(h4, o22, i2, zi(n4.iss), r3); + } + const zf = (e2, t2) => { + const r3 = `${e2.domain} wants you to sign in with your Ethereum account:`, i2 = Li(t2); + if (!e2.aud && !e2.uri) + throw new Error("Either `aud` or `uri` is required to construct the message"); + let n4 = e2.statement || void 0; + const o22 = `URI: ${e2.aud || e2.uri}`, h4 = `Version: ${e2.version}`, p2 = `Chain ID: ${zi(t2)}`, b3 = `Nonce: ${e2.nonce}`, m3 = `Issued At: ${e2.iat}`, w3 = e2.resources ? `Resources:${e2.resources.map((S2) => ` +- ${S2}`).join("")}` : void 0, y3 = Qr(e2.resources); + if (y3) { + const S2 = Oe$1(y3); + n4 = Ji$1(n4, S2); + } + return [r3, i2, "", n4, "", o22, h4, p2, b3, m3, w3].filter((S2) => S2 != null).join(` +`); + }; + function Jf(e2) { + return Buffer.from(JSON.stringify(e2)).toString("base64"); + } + function Gf(e2) { + return JSON.parse(Buffer.from(e2, "base64").toString("utf-8")); + } + function me$1(e2) { + if (!e2) + throw new Error("No recap provided, value is undefined"); + if (!e2.att) + throw new Error("No `att` property found"); + const t2 = Object.keys(e2.att); + if (!(t2 != null && t2.length)) + throw new Error("No resources found in `att` property"); + t2.forEach((r3) => { + const i2 = e2.att[r3]; + if (Array.isArray(i2)) + throw new Error(`Resource must be an object: ${r3}`); + if (typeof i2 != "object") + throw new Error(`Resource must be an object: ${r3}`); + if (!Object.keys(i2).length) + throw new Error(`Resource object is empty: ${r3}`); + Object.keys(i2).forEach((n4) => { + const o22 = i2[n4]; + if (!Array.isArray(o22)) + throw new Error(`Ability limits ${n4} must be an array of objects, found: ${o22}`); + if (!o22.length) + throw new Error(`Value of ${n4} is empty array, must be an array with objects`); + o22.forEach((h4) => { + if (typeof h4 != "object") + throw new Error(`Ability limits (${n4}) must be an array of objects, found: ${h4}`); + }); + }); + }); } - function D$2() { - return !te$1() && !!getNavigator_1() && !!getDocument_1(); + function Yf(e2, t2, r3, i2 = {}) { + return r3 == null ? void 0 : r3.sort((n4, o22) => n4.localeCompare(o22)), { att: { [e2]: ji(t2, r3, i2) } }; } - function R$2() { - return $$1() ? m$1.reactNative : te$1() ? m$1.node : D$2() ? m$1.browser : m$1.unknown; + function ji(e2, t2, r3 = {}) { + t2 = t2 == null ? void 0 : t2.sort((n4, o22) => n4.localeCompare(o22)); + const i2 = t2.map((n4) => ({ [`${e2}/${n4}`]: [r3] })); + return Object.assign({}, ...i2); } - function Jn() { - var e2; - try { - return $$1() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (e2 = global.Application) == null ? void 0 : e2.applicationId : void 0; - } catch { - return; - } + function jr(e2) { + return me$1(e2), `urn:recap:${Jf(e2).replace(/=/g, "")}`; } - function ke$1(e2, n3) { - let t2 = queryString.parse(e2); - return t2 = $e$1($e$1({}, t2), n3), e2 = queryString.stringify(t2), e2; + function Oe$1(e2) { + const t2 = Gf(e2.replace("urn:recap:", "")); + return me$1(t2), t2; } - function Qn() { - return getWindowMetadata_1() || { name: "", description: "", url: "", icons: [""] }; + function cu(e2, t2, r3) { + const i2 = Yf(e2, t2, r3); + return jr(i2); } - function Ve$1() { - if (R$2() === m$1.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { - const { OS: t2, Version: r2 } = global.Platform; - return [t2, r2].join("-"); - } - const e2 = detect(); - if (e2 === null) - return "unknown"; - const n3 = e2.os ? e2.os.replace(" ", "").toLowerCase() : "unknown"; - return e2.type === "browser" ? [n3, e2.name, e2.version].join("-") : [n3, e2.version].join("-"); + function Qi$1(e2) { + return e2 && e2.includes("urn:recap:"); } - function Me$1() { - var e2; - const n3 = R$2(); - return n3 === m$1.browser ? [n3, ((e2 = getLocation_1()) == null ? void 0 : e2.host) || "unknown"].join(":") : n3; + function lu(e2, t2) { + const r3 = Oe$1(e2), i2 = Oe$1(t2), n4 = Wf(r3, i2); + return jr(n4); } - function Ke$1(e2, n3, t2) { - const r2 = Ve$1(), o22 = Me$1(); - return [[e2, n3].join("-"), [De$1, t2].join("-"), r2, o22].join("/"); + function Wf(e2, t2) { + me$1(e2), me$1(t2); + const r3 = Object.keys(e2.att).concat(Object.keys(t2.att)).sort((n4, o22) => n4.localeCompare(o22)), i2 = { att: {} }; + return r3.forEach((n4) => { + var o22, h4; + Object.keys(((o22 = e2.att) == null ? void 0 : o22[n4]) || {}).concat(Object.keys(((h4 = t2.att) == null ? void 0 : h4[n4]) || {})).sort((p2, b3) => p2.localeCompare(b3)).forEach((p2) => { + var b3, m3; + i2.att[n4] = Hf(Hi$1({}, i2.att[n4]), { [p2]: ((b3 = e2.att[n4]) == null ? void 0 : b3[p2]) || ((m3 = t2.att[n4]) == null ? void 0 : m3[p2]) }); + }); + }), i2; } - function Xn({ protocol: e2, version: n3, relayUrl: t2, sdkVersion: r2, auth: o22, projectId: s2, useOnCloseEvent: i2, bundleId: d3 }) { - const l2 = t2.split("?"), c2 = Ke$1(e2, n3, r2), u3 = { auth: o22, ua: c2, projectId: s2, useOnCloseEvent: i2 || void 0, origin: d3 || void 0 }, a3 = ke$1(l2[1] || "", u3); - return l2[0] + "?" + a3; + function Ji$1(e2 = "", t2) { + me$1(t2); + const r3 = "I further authorize the stated URI to perform the following actions on my behalf: "; + if (e2.includes(r3)) + return e2; + const i2 = []; + let n4 = 0; + Object.keys(t2.att).forEach((p2) => { + const b3 = Object.keys(t2.att[p2]).map((y3) => ({ ability: y3.split("/")[0], action: y3.split("/")[1] })); + b3.sort((y3, S2) => y3.action.localeCompare(S2.action)); + const m3 = {}; + b3.forEach((y3) => { + m3[y3.ability] || (m3[y3.ability] = []), m3[y3.ability].push(y3.action); + }); + const w3 = Object.keys(m3).map((y3) => (n4++, `(${n4}) '${y3}': '${m3[y3].join("', '")}' for '${p2}'.`)); + i2.push(w3.join(", ").replace(".,", ".")); + }); + const o22 = i2.join(" "), h4 = `${r3}${o22}`; + return `${e2 ? e2 + " " : ""}${h4}`; } - function O$1(e2, n3) { - return e2.filter((t2) => n3.includes(t2)).length === e2.length; + function du(e2) { + var t2; + const r3 = Oe$1(e2); + me$1(r3); + const i2 = (t2 = r3.att) == null ? void 0 : t2.eip155; + return i2 ? Object.keys(i2).map((n4) => n4.split("/")[1]) : []; + } + function pu(e2) { + const t2 = Oe$1(e2); + me$1(t2); + const r3 = []; + return Object.values(t2.att).forEach((i2) => { + Object.values(i2).forEach((n4) => { + var o22; + (o22 = n4 == null ? void 0 : n4[0]) != null && o22.chains && r3.push(n4[0].chains); + }); + }), [...new Set(r3.flat())]; } - function rt$1(e2) { - return Object.fromEntries(e2.entries()); + function Qr(e2) { + if (!e2) + return; + const t2 = e2 == null ? void 0 : e2[e2.length - 1]; + return Qi$1(t2) ? t2 : void 0; } - function ot$1(e2) { - return new Map(Object.entries(e2)); + const Gi = "base10", zt$1 = "base16", Jr = "base64pad", Gr = "utf8", Yi$1 = 0, lr$1 = 1, vu = 0, Zf = 1, Vi = 12, Wi$1 = 32; + function mu() { + const e2 = x25519.generateKeyPair(); + return { privateKey: toString(e2.secretKey, zt$1), publicKey: toString(e2.publicKey, zt$1) }; } - function at$1(e2 = cjs$4.FIVE_MINUTES, n3) { - const t2 = cjs$4.toMiliseconds(e2 || cjs$4.FIVE_MINUTES); - let r2, o22, s2; - return { resolve: (i2) => { - s2 && r2 && (clearTimeout(s2), r2(i2)); - }, reject: (i2) => { - s2 && o22 && (clearTimeout(s2), o22(i2)); - }, done: () => new Promise((i2, d3) => { - s2 = setTimeout(() => { - d3(new Error(n3)); - }, t2), r2 = i2, o22 = d3; - }) }; + function gu() { + const e2 = random.randomBytes(Wi$1); + return toString(e2, zt$1); } - function ut$1(e2, n3, t2) { - return new Promise(async (r2, o22) => { - const s2 = setTimeout(() => o22(new Error(t2)), n3); - try { - const i2 = await e2; - r2(i2); - } catch (i2) { - o22(i2); - } - clearTimeout(s2); - }); + function Au(e2, t2) { + const r3 = x25519.sharedKey(fromString(e2, zt$1), fromString(t2, zt$1), true), i2 = new HKDF_1(sha256.SHA256, r3).expand(Wi$1); + return toString(i2, zt$1); } - function re$1(e2, n3) { - if (typeof n3 == "string" && n3.startsWith(`${e2}:`)) - return n3; - if (e2.toLowerCase() === "topic") { - if (typeof n3 != "string") - throw new Error('Value must be "string" for expirer target type: topic'); - return `topic:${n3}`; - } else if (e2.toLowerCase() === "id") { - if (typeof n3 != "number") - throw new Error('Value must be "number" for expirer target type: id'); - return `id:${n3}`; - } - throw new Error(`Unknown expirer target type: ${e2}`); + function bu(e2) { + const t2 = sha256.hash(fromString(e2, zt$1)); + return toString(t2, zt$1); } - function lt$1(e2) { - return re$1("topic", e2); + function yu(e2) { + const t2 = sha256.hash(fromString(e2, Gr)); + return toString(t2, zt$1); } - function dt$1(e2) { - return re$1("id", e2); + function $f(e2) { + return fromString(`${e2}`, Gi); } - function ft$1(e2) { - const [n3, t2] = e2.split(":"), r2 = { id: void 0, topic: void 0 }; - if (n3 === "topic" && typeof t2 == "string") - r2.topic = t2; - else if (n3 === "id" && Number.isInteger(Number(t2))) - r2.id = Number(t2); - else - throw new Error(`Invalid target, expected id:number or topic:string, got ${n3}:${t2}`); - return r2; + function Mr(e2) { + return Number(toString(e2, Gi)); } - function pt$1(e2, n3) { - return cjs$4.fromMiliseconds((n3 || Date.now()) + cjs$4.toMiliseconds(e2)); + function wu(e2) { + const t2 = $f(typeof e2.type < "u" ? e2.type : Yi$1); + if (Mr(t2) === lr$1 && typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + const r3 = typeof e2.senderPublicKey < "u" ? fromString(e2.senderPublicKey, zt$1) : void 0, i2 = typeof e2.iv < "u" ? fromString(e2.iv, zt$1) : random.randomBytes(Vi), n4 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)).seal(i2, fromString(e2.message, Gr)); + return to$1({ type: t2, sealed: n4, iv: i2, senderPublicKey: r3 }); } - function mt$1(e2) { - return Date.now() >= cjs$4.toMiliseconds(e2); + function xu(e2) { + const t2 = new chacha20poly1305.ChaCha20Poly1305(fromString(e2.symKey, zt$1)), { sealed: r3, iv: i2 } = Xi$1(e2.encoded), n4 = t2.open(i2, r3); + if (n4 === null) + throw new Error("Failed to decrypt"); + return toString(n4, Gr); } - function yt$1(e2, n3) { - return `${e2}${n3 ? `:${n3}` : ""}`; + function to$1(e2) { + if (Mr(e2.type) === lr$1) { + if (typeof e2.senderPublicKey > "u") + throw new Error("Missing sender public key for type 1 envelope"); + return toString(concat([e2.type, e2.senderPublicKey, e2.iv, e2.sealed]), Jr); + } + return toString(concat([e2.type, e2.iv, e2.sealed]), Jr); } - async function gt$1({ id: e2, topic: n3, wcDeepLink: t2 }) { - try { - if (!t2) - return; - const r2 = typeof t2 == "string" ? JSON.parse(t2) : t2; - let o22 = r2 == null ? void 0 : r2.href; - if (typeof o22 != "string") - return; - o22.endsWith("/") && (o22 = o22.slice(0, -1)); - const s2 = `${o22}/wc?requestId=${e2}&sessionTopic=${n3}`, i2 = R$2(); - i2 === m$1.browser ? s2.startsWith("https://") ? window.open(s2, "_blank", "noreferrer noopener") : window.open(s2, "_self", "noreferrer noopener") : i2 === m$1.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(s2); - } catch (r2) { - console.error(r2); + function Xi$1(e2) { + const t2 = fromString(e2, Jr), r3 = t2.slice(vu, Zf), i2 = Zf; + if (Mr(r3) === lr$1) { + const p2 = i2 + Wi$1, b3 = p2 + Vi, m3 = t2.slice(i2, p2), w3 = t2.slice(p2, b3), y3 = t2.slice(b3); + return { type: r3, sealed: y3, iv: w3, senderPublicKey: m3 }; } + const n4 = i2 + Vi, o22 = t2.slice(i2, n4), h4 = t2.slice(n4); + return { type: r3, sealed: h4, iv: o22 }; } - async function ht$1(e2, n3) { - try { - return await e2.getItem(n3) || (D$2() ? localStorage.getItem(n3) : void 0); - } catch (t2) { - console.error(t2); + function Mu(e2, t2) { + const r3 = Xi$1(e2); + return eo$1({ type: Mr(r3.type), senderPublicKey: typeof r3.senderPublicKey < "u" ? toString(r3.senderPublicKey, zt$1) : void 0, receiverPublicKey: t2 == null ? void 0 : t2.receiverPublicKey }); + } + function eo$1(e2) { + const t2 = (e2 == null ? void 0 : e2.type) || Yi$1; + if (t2 === lr$1) { + if (typeof (e2 == null ? void 0 : e2.senderPublicKey) > "u") + throw new Error("missing sender public key"); + if (typeof (e2 == null ? void 0 : e2.receiverPublicKey) > "u") + throw new Error("missing receiver public key"); } + return { type: t2, senderPublicKey: e2 == null ? void 0 : e2.senderPublicKey, receiverPublicKey: e2 == null ? void 0 : e2.receiverPublicKey }; + } + function Eu(e2) { + return e2.type === lr$1 && typeof e2.senderPublicKey == "string" && typeof e2.receiverPublicKey == "string"; } - const He$1 = "irn"; - function vt$1(e2) { - return (e2 == null ? void 0 : e2.relay) || { protocol: He$1 }; + const ro$1 = "irn"; + function Su(e2) { + return (e2 == null ? void 0 : e2.relay) || { protocol: ro$1 }; } - function Et$1(e2) { - const n3 = RELAY_JSONRPC[e2]; - if (typeof n3 > "u") + function Nu(e2) { + const t2 = C$1[e2]; + if (typeof t2 > "u") throw new Error(`Relay Protocol not supported: ${e2}`); - return n3; - } - var bt$1 = Object.defineProperty, Nt$1 = Object.defineProperties, Ot$1 = Object.getOwnPropertyDescriptors, qe$1 = Object.getOwnPropertySymbols, St$1 = Object.prototype.hasOwnProperty, wt$1 = Object.prototype.propertyIsEnumerable, Be$1 = (e2, n3, t2) => n3 in e2 ? bt$1(e2, n3, { enumerable: true, configurable: true, writable: true, value: t2 }) : e2[n3] = t2, It$1 = (e2, n3) => { - for (var t2 in n3 || (n3 = {})) - St$1.call(n3, t2) && Be$1(e2, t2, n3[t2]); - if (qe$1) - for (var t2 of qe$1(n3)) - wt$1.call(n3, t2) && Be$1(e2, t2, n3[t2]); + return t2; + } + var Iu = Object.defineProperty, _u = Object.defineProperties, Bu = Object.getOwnPropertyDescriptors, io = Object.getOwnPropertySymbols, Cu = Object.prototype.hasOwnProperty, Ru = Object.prototype.propertyIsEnumerable, no$1 = (e2, t2, r3) => t2 in e2 ? Iu(e2, t2, { enumerable: true, configurable: true, writable: true, value: r3 }) : e2[t2] = r3, fo$1 = (e2, t2) => { + for (var r3 in t2 || (t2 = {})) + Cu.call(t2, r3) && no$1(e2, r3, t2[r3]); + if (io) + for (var r3 of io(t2)) + Ru.call(t2, r3) && no$1(e2, r3, t2[r3]); return e2; - }, Tt$1 = (e2, n3) => Nt$1(e2, Ot$1(n3)); - function Ge$1(e2, n3 = "-") { - const t2 = {}, r2 = "relay" + n3; - return Object.keys(e2).forEach((o22) => { - if (o22.startsWith(r2)) { - const s2 = o22.replace(r2, ""), i2 = e2[o22]; - t2[s2] = i2; + }, Ou = (e2, t2) => _u(e2, Bu(t2)); + function oo$1(e2, t2 = "-") { + const r3 = {}, i2 = "relay" + t2; + return Object.keys(e2).forEach((n4) => { + if (n4.startsWith(i2)) { + const o22 = n4.replace(i2, ""), h4 = e2[n4]; + r3[o22] = h4; } - }), t2; + }), r3; } - function Pt$1(e2) { + function Pu(e2) { e2 = e2.includes("wc://") ? e2.replace("wc://", "") : e2, e2 = e2.includes("wc:") ? e2.replace("wc:", "") : e2; - const n3 = e2.indexOf(":"), t2 = e2.indexOf("?") !== -1 ? e2.indexOf("?") : void 0, r2 = e2.substring(0, n3), o22 = e2.substring(n3 + 1, t2).split("@"), s2 = typeof t2 < "u" ? e2.substring(t2) : "", i2 = queryString.parse(s2); - return { protocol: r2, topic: We$1(o22[0]), version: parseInt(o22[1], 10), symKey: i2.symKey, relay: Ge$1(i2), expiryTimestamp: i2.expiryTimestamp ? parseInt(i2.expiryTimestamp, 10) : void 0 }; + const t2 = e2.indexOf(":"), r3 = e2.indexOf("?") !== -1 ? e2.indexOf("?") : void 0, i2 = e2.substring(0, t2), n4 = e2.substring(t2 + 1, r3).split("@"), o22 = typeof r3 < "u" ? e2.substring(r3) : "", h4 = queryString.parse(o22), p2 = typeof h4.methods == "string" ? h4.methods.split(",") : void 0; + return { protocol: i2, topic: so(n4[0]), version: parseInt(n4[1], 10), symKey: h4.symKey, relay: oo$1(h4), methods: p2, expiryTimestamp: h4.expiryTimestamp ? parseInt(h4.expiryTimestamp, 10) : void 0 }; } - function We$1(e2) { + function so(e2) { return e2.startsWith("//") ? e2.substring(2) : e2; } - function ze$1(e2, n3 = "-") { - const t2 = "relay", r2 = {}; - return Object.keys(e2).forEach((o22) => { - const s2 = t2 + n3 + o22; - e2[o22] && (r2[s2] = e2[o22]); - }), r2; - } - function Rt$1(e2) { - return `${e2.protocol}:${e2.topic}@${e2.version}?` + queryString.stringify(Tt$1(It$1({ symKey: e2.symKey }, ze$1(e2.relay)), { expiryTimestamp: e2.expiryTimestamp })); - } - function A$1$1(e2) { - const n3 = []; - return e2.forEach((t2) => { - const [r2, o22] = t2.split(":"); - n3.push(`${r2}:${o22}`); - }), n3; - } - function Qe$1(e2) { - const n3 = []; - return Object.values(e2).forEach((t2) => { - n3.push(...A$1$1(t2.accounts)); - }), n3; - } - function Ze$1(e2, n3) { + function ao$1(e2, t2 = "-") { + const r3 = "relay", i2 = {}; + return Object.keys(e2).forEach((n4) => { + const o22 = r3 + t2 + n4; + e2[n4] && (i2[o22] = e2[n4]); + }), i2; + } + function Du(e2) { + return `${e2.protocol}:${e2.topic}@${e2.version}?` + queryString.stringify(fo$1(Ou(fo$1({ symKey: e2.symKey }, ao$1(e2.relay)), { expiryTimestamp: e2.expiryTimestamp }), e2.methods ? { methods: e2.methods.join(",") } : {})); + } + function $e$1(e2) { const t2 = []; - return Object.values(e2).forEach((r2) => { - A$1$1(r2.accounts).includes(n3) && t2.push(...r2.methods); + return e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2.push(`${i2}:${n4}`); }), t2; } - function Xe$1(e2, n3) { + function co$1(e2) { const t2 = []; - return Object.values(e2).forEach((r2) => { - A$1$1(r2.accounts).includes(n3) && t2.push(...r2.events); + return Object.values(e2).forEach((r3) => { + t2.push(...$e$1(r3.accounts)); + }), t2; + } + function lo(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.methods); + }), r3; + } + function po$1(e2, t2) { + const r3 = []; + return Object.values(e2).forEach((i2) => { + $e$1(i2.accounts).includes(t2) && r3.push(...i2.events); + }), r3; + } + function mo(e2) { + const t2 = {}; + return e2 == null ? void 0 : e2.forEach((r3) => { + const [i2, n4] = r3.split(":"); + t2[i2] || (t2[i2] = { accounts: [], chains: [], events: [] }), t2[i2].accounts.push(r3), t2[i2].chains.push(`${i2}:${n4}`); }), t2; } - const nn = { 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 } }, tn = { 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 N$1(e2, n3) { - const { message: t2, code: r2 } = tn[e2]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; + function ju(e2, t2) { + t2 = t2.map((i2) => i2.replace("did:pkh:", "")); + const r3 = mo(t2); + for (const [i2, n4] of Object.entries(r3)) + n4.methods ? n4.methods = ge$1(n4.methods, e2) : n4.methods = e2, n4.events = ["chainChanged", "accountsChanged"]; + return r3; + } + const go$1 = { 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 } }, Ao$1 = { 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 xe$1(e2, t2) { + const { message: r3, code: i2 } = Ao$1[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; } - function U$2(e2, n3) { - const { message: t2, code: r2 } = nn[e2]; - return { message: n3 ? `${t2} ${n3}` : t2, code: r2 }; + function tr$2(e2, t2) { + const { message: r3, code: i2 } = go$1[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; } - function k$3(e2, n3) { - return Array.isArray(e2) ? typeof n3 < "u" && e2.length ? e2.every(n3) : true : false; + function Er(e2, t2) { + return Array.isArray(e2) ? true : false; } - function B$1$1(e2) { + function Yr(e2) { return Object.getPrototypeOf(e2) === Object.prototype && Object.keys(e2).length; } - function w$3(e2) { + function Pe$1(e2) { return typeof e2 > "u"; } - function g$3(e2, n3) { - return n3 && w$3(e2) ? true : typeof e2 == "string" && !!e2.trim().length; + function Gt$1(e2, t2) { + return t2 && Pe$1(e2) ? true : typeof e2 == "string" && !!e2.trim().length; } - function G$1(e2, n3) { - return n3 && w$3(e2) ? true : typeof e2 == "number" && !isNaN(e2); + function Vr(e2, t2) { + return typeof e2 == "number" && !isNaN(e2); } - function Mt$1(e2, n3) { - const { requiredNamespaces: t2 } = n3, r2 = Object.keys(e2.namespaces), o22 = Object.keys(t2); - let s2 = true; - return O$1(o22, r2) ? (r2.forEach((i2) => { - const { accounts: d3, methods: l2, events: c2 } = e2.namespaces[i2], u3 = A$1$1(d3), a3 = t2[i2]; - (!O$1(L$1$1(i2, a3), u3) || !O$1(a3.methods, l2) || !O$1(a3.events, c2)) && (s2 = false); - }), s2) : false; + function Qu(e2, t2) { + const { requiredNamespaces: r3 } = t2, i2 = Object.keys(e2.namespaces), n4 = Object.keys(r3); + let o22 = true; + return _e$1(n4, i2) ? (i2.forEach((h4) => { + const { accounts: p2, methods: b3, events: m3 } = e2.namespaces[h4], w3 = $e$1(p2), y3 = r3[h4]; + (!_e$1(_r$1(h4, y3), w3) || !_e$1(y3.methods, b3) || !_e$1(y3.events, m3)) && (o22 = false); + }), o22) : false; } - function V$1(e2) { - return g$3(e2, false) && e2.includes(":") ? e2.split(":").length === 2 : false; + function Sr$1(e2) { + return Gt$1(e2, false) && e2.includes(":") ? e2.split(":").length === 2 : false; } - function rn(e2) { - if (g$3(e2, false) && e2.includes(":")) { - const n3 = e2.split(":"); - if (n3.length === 3) { - const t2 = n3[0] + ":" + n3[1]; - return !!n3[2] && V$1(t2); + function bo(e2) { + if (Gt$1(e2, false) && e2.includes(":")) { + const t2 = e2.split(":"); + if (t2.length === 3) { + const r3 = t2[0] + ":" + t2[1]; + return !!t2[2] && Sr$1(r3); } } return false; } - function Kt$1(e2) { - if (g$3(e2, false)) + function Ju(e2) { + if (Gt$1(e2, false)) try { return typeof new URL(e2) < "u"; } catch { @@ -8835,227 +12346,227 @@ } return false; } - function Lt$1(e2) { - var n3; - return (n3 = e2 == null ? void 0 : e2.proposer) == null ? void 0 : n3.publicKey; + function Gu(e2) { + var t2; + return (t2 = e2 == null ? void 0 : e2.proposer) == null ? void 0 : t2.publicKey; } - function xt$1(e2) { + function Yu(e2) { return e2 == null ? void 0 : e2.topic; } - function Ft$1(e2, n3) { - let t2 = null; - return g$3(e2 == null ? void 0 : e2.publicKey, false) || (t2 = N$1("MISSING_OR_INVALID", `${n3} controller public key should be a string`)), t2; - } - function ie$1(e2) { - let n3 = true; - return k$3(e2) ? e2.length && (n3 = e2.every((t2) => g$3(t2, false))) : n3 = false, n3; - } - function on(e2, n3, t2) { - let r2 = null; - return k$3(n3) && n3.length ? n3.forEach((o22) => { - r2 || V$1(o22) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, chain ${o22} should be a string and conform to "namespace:chainId" format`)); - }) : V$1(e2) || (r2 = U$2("UNSUPPORTED_CHAINS", `${t2}, 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"] }`)), r2; - } - function sn(e2, n3, t2) { - let r2 = null; - return Object.entries(e2).forEach(([o22, s2]) => { - if (r2) - return; - const i2 = on(o22, L$1$1(o22, s2), `${n3} ${t2}`); - i2 && (r2 = i2); - }), r2; - } - function cn(e2, n3) { - let t2 = null; - return k$3(e2) ? e2.forEach((r2) => { - t2 || rn(r2) || (t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, account ${r2} should be a string and conform to "namespace:chainId:address" format`)); - }) : t2 = U$2("UNSUPPORTED_ACCOUNTS", `${n3}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), t2; + function Vu(e2, t2) { + let r3 = null; + return Gt$1(e2 == null ? void 0 : e2.publicKey, false) || (r3 = xe$1("MISSING_OR_INVALID", `${t2} controller public key should be a string`)), r3; } - function an(e2, n3) { - let t2 = null; - return Object.values(e2).forEach((r2) => { - if (t2) - return; - const o22 = cn(r2 == null ? void 0 : r2.accounts, `${n3} namespace`); - o22 && (t2 = o22); - }), t2; + function tn(e2) { + let t2 = true; + return Er(e2) ? e2.length && (t2 = e2.every((r3) => Gt$1(r3, false))) : t2 = false, t2; } - function un(e2, n3) { - let t2 = null; - return ie$1(e2 == null ? void 0 : e2.methods) ? ie$1(e2 == null ? void 0 : e2.events) || (t2 = U$2("UNSUPPORTED_EVENTS", `${n3}, events should be an array of strings or empty array for no events`)) : t2 = U$2("UNSUPPORTED_METHODS", `${n3}, methods should be an array of strings or empty array for no methods`), t2; + function yo(e2, t2, r3) { + let i2 = null; + return Er(t2) && t2.length ? t2.forEach((n4) => { + i2 || Sr$1(n4) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, chain ${n4} should be a string and conform to "namespace:chainId" format`)); + }) : Sr$1(e2) || (i2 = tr$2("UNSUPPORTED_CHAINS", `${r3}, 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"] }`)), i2; } - function ce$2(e2, n3) { - let t2 = null; - return Object.values(e2).forEach((r2) => { - if (t2) + function wo$1(e2, t2, r3) { + let i2 = null; + return Object.entries(e2).forEach(([n4, o22]) => { + if (i2) return; - const o22 = un(r2, `${n3}, namespace`); - o22 && (t2 = o22); - }), t2; - } - function Ht$1(e2, n3, t2) { - let r2 = null; - if (e2 && B$1$1(e2)) { - const o22 = ce$2(e2, n3); - o22 && (r2 = o22); - const s2 = sn(e2, n3, t2); - s2 && (r2 = s2); + const h4 = yo(n4, _r$1(n4, o22), `${t2} ${r3}`); + h4 && (i2 = h4); + }), i2; + } + function xo$1(e2, t2) { + let r3 = null; + return Er(e2) ? e2.forEach((i2) => { + r3 || bo(i2) || (r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, account ${i2} should be a string and conform to "namespace:chainId:address" format`)); + }) : r3 = tr$2("UNSUPPORTED_ACCOUNTS", `${t2}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), r3; + } + function Mo$1(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = xo$1(i2 == null ? void 0 : i2.accounts, `${t2} namespace`); + n4 && (r3 = n4); + }), r3; + } + function Eo$1(e2, t2) { + let r3 = null; + return tn(e2 == null ? void 0 : e2.methods) ? tn(e2 == null ? void 0 : e2.events) || (r3 = tr$2("UNSUPPORTED_EVENTS", `${t2}, events should be an array of strings or empty array for no events`)) : r3 = tr$2("UNSUPPORTED_METHODS", `${t2}, methods should be an array of strings or empty array for no methods`), r3; + } + function en(e2, t2) { + let r3 = null; + return Object.values(e2).forEach((i2) => { + if (r3) + return; + const n4 = Eo$1(i2, `${t2}, namespace`); + n4 && (r3 = n4); + }), r3; + } + function Wu(e2, t2, r3) { + let i2 = null; + if (e2 && Yr(e2)) { + const n4 = en(e2, t2); + n4 && (i2 = n4); + const o22 = wo$1(e2, t2, r3); + o22 && (i2 = o22); } else - r2 = N$1("MISSING_OR_INVALID", `${n3}, ${t2} should be an object with data`); - return r2; - } - function ln(e2, n3) { - let t2 = null; - if (e2 && B$1$1(e2)) { - const r2 = ce$2(e2, n3); - r2 && (t2 = r2); - const o22 = an(e2, n3); - o22 && (t2 = o22); + i2 = xe$1("MISSING_OR_INVALID", `${t2}, ${r3} should be an object with data`); + return i2; + } + function So(e2, t2) { + let r3 = null; + if (e2 && Yr(e2)) { + const i2 = en(e2, t2); + i2 && (r3 = i2); + const n4 = Mo$1(e2, t2); + n4 && (r3 = n4); } else - t2 = N$1("MISSING_OR_INVALID", `${n3}, namespaces should be an object with data`); - return t2; + r3 = xe$1("MISSING_OR_INVALID", `${t2}, namespaces should be an object with data`); + return r3; } - function dn(e2) { - return g$3(e2.protocol, true); + function No$1(e2) { + return Gt$1(e2.protocol, true); } - function qt$1(e2, n3) { - let t2 = false; - return n3 && !e2 ? t2 = true : e2 && k$3(e2) && e2.length && e2.forEach((r2) => { - t2 = dn(r2); - }), t2; + function Xu(e2, t2) { + let r3 = false; + return !e2 ? r3 = true : e2 && Er(e2) && e2.length && e2.forEach((i2) => { + r3 = No$1(i2); + }), r3; } - function Bt$1(e2) { + function Zu(e2) { return typeof e2 == "number"; } - function Gt$1(e2) { + function $u(e2) { return typeof e2 < "u" && typeof e2 !== null; } - function Wt$1(e2) { - return !(!e2 || typeof e2 != "object" || !e2.code || !G$1(e2.code, false) || !e2.message || !g$3(e2.message, false)); + function th(e2) { + return !(!e2 || typeof e2 != "object" || !e2.code || !Vr(e2.code) || !e2.message || !Gt$1(e2.message, false)); } - function zt$1(e2) { - return !(w$3(e2) || !g$3(e2.method, false)); + function eh(e2) { + return !(Pe$1(e2) || !Gt$1(e2.method, false)); } - function Yt$1(e2) { - return !(w$3(e2) || w$3(e2.result) && w$3(e2.error) || !G$1(e2.id, false) || !g$3(e2.jsonrpc, false)); + function rh(e2) { + return !(Pe$1(e2) || Pe$1(e2.result) && Pe$1(e2.error) || !Vr(e2.id) || !Gt$1(e2.jsonrpc, false)); } - function Jt$1(e2) { - return !(w$3(e2) || !g$3(e2.name, false)); + function ih(e2) { + return !(Pe$1(e2) || !Gt$1(e2.name, false)); } - function Qt$1(e2, n3) { - return !(!V$1(n3) || !Qe$1(e2).includes(n3)); + function nh(e2, t2) { + return !(!Sr$1(t2) || !co$1(e2).includes(t2)); } - function Zt$1(e2, n3, t2) { - return g$3(t2, false) ? Ze$1(e2, n3).includes(t2) : false; + function fh(e2, t2, r3) { + return Gt$1(r3, false) ? lo(e2, t2).includes(r3) : false; } - function Xt$1(e2, n3, t2) { - return g$3(t2, false) ? Xe$1(e2, n3).includes(t2) : false; + function oh(e2, t2, r3) { + return Gt$1(r3, false) ? po$1(e2, t2).includes(r3) : false; } - function fn(e2, n3, t2) { - let r2 = null; - const o22 = er$1(e2), s2 = nr$1(n3), i2 = Object.keys(o22), d3 = Object.keys(s2), l2 = pn(Object.keys(e2)), c2 = pn(Object.keys(n3)), u3 = l2.filter((a3) => !c2.includes(a3)); - return u3.length && (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces keys don't satisfy requiredNamespaces. - Required: ${u3.toString()} - Received: ${Object.keys(n3).toString()}`)), O$1(i2, d3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces chains don't satisfy required namespaces. - Required: ${i2.toString()} - Approved: ${d3.toString()}`)), Object.keys(n3).forEach((a3) => { - if (!a3.includes(":") || r2) + function Io(e2, t2, r3) { + let i2 = null; + const n4 = sh(e2), o22 = ah(t2), h4 = Object.keys(n4), p2 = Object.keys(o22), b3 = _o(Object.keys(e2)), m3 = _o(Object.keys(t2)), w3 = b3.filter((y3) => !m3.includes(y3)); + return w3.length && (i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r3} namespaces keys don't satisfy requiredNamespaces. + Required: ${w3.toString()} + Received: ${Object.keys(t2).toString()}`)), _e$1(h4, p2) || (i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r3} namespaces chains don't satisfy required namespaces. + Required: ${h4.toString()} + Approved: ${p2.toString()}`)), Object.keys(t2).forEach((y3) => { + if (!y3.includes(":") || i2) return; - const b3 = A$1$1(n3[a3].accounts); - b3.includes(a3) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces accounts don't satisfy namespace accounts for ${a3} - Required: ${a3} - Approved: ${b3.toString()}`)); - }), i2.forEach((a3) => { - r2 || (O$1(o22[a3].methods, s2[a3].methods) ? O$1(o22[a3].events, s2[a3].events) || (r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces events don't satisfy namespace events for ${a3}`)) : r2 = N$1("NON_CONFORMING_NAMESPACES", `${t2} namespaces methods don't satisfy namespace methods for ${a3}`)); - }), r2; - } - function er$1(e2) { - const n3 = {}; - return Object.keys(e2).forEach((t2) => { - var r2; - t2.includes(":") ? n3[t2] = e2[t2] : (r2 = e2[t2].chains) == null || r2.forEach((o22) => { - n3[o22] = { methods: e2[t2].methods, events: e2[t2].events }; + const S2 = $e$1(t2[y3].accounts); + S2.includes(y3) || (i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r3} namespaces accounts don't satisfy namespace accounts for ${y3} + Required: ${y3} + Approved: ${S2.toString()}`)); + }), h4.forEach((y3) => { + i2 || (_e$1(n4[y3].methods, o22[y3].methods) ? _e$1(n4[y3].events, o22[y3].events) || (i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r3} namespaces events don't satisfy namespace events for ${y3}`)) : i2 = xe$1("NON_CONFORMING_NAMESPACES", `${r3} namespaces methods don't satisfy namespace methods for ${y3}`)); + }), i2; + } + function sh(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + var i2; + r3.includes(":") ? t2[r3] = e2[r3] : (i2 = e2[r3].chains) == null || i2.forEach((n4) => { + t2[n4] = { methods: e2[r3].methods, events: e2[r3].events }; }); - }), n3; + }), t2; } - function pn(e2) { - return [...new Set(e2.map((n3) => n3.includes(":") ? n3.split(":")[0] : n3))]; + function _o(e2) { + return [...new Set(e2.map((t2) => t2.includes(":") ? t2.split(":")[0] : t2))]; } - function nr$1(e2) { - const n3 = {}; - return Object.keys(e2).forEach((t2) => { - if (t2.includes(":")) - n3[t2] = e2[t2]; + function ah(e2) { + const t2 = {}; + return Object.keys(e2).forEach((r3) => { + if (r3.includes(":")) + t2[r3] = e2[r3]; else { - const r2 = A$1$1(e2[t2].accounts); - r2 == null ? void 0 : r2.forEach((o22) => { - n3[o22] = { accounts: e2[t2].accounts.filter((s2) => s2.includes(`${o22}:`)), methods: e2[t2].methods, events: e2[t2].events }; + const i2 = $e$1(e2[r3].accounts); + i2 == null ? void 0 : i2.forEach((n4) => { + t2[n4] = { accounts: e2[r3].accounts.filter((o22) => o22.includes(`${n4}:`)), methods: e2[r3].methods, events: e2[r3].events }; }); } - }), n3; + }), t2; } - function tr$1(e2, n3) { - return G$1(e2, false) && e2 <= n3.max && e2 >= n3.min; + function uh(e2, t2) { + return Vr(e2) && e2 <= t2.max && e2 >= t2.min; } - function rr$1() { - const e2 = R$2(); - return new Promise((n3) => { + function hh() { + const e2 = We$2(); + return new Promise((t2) => { switch (e2) { - case m$1.browser: - n3(mn()); + case qt$1.browser: + t2(Bo()); break; - case m$1.reactNative: - n3(yn()); + case qt$1.reactNative: + t2(Co$1()); break; - case m$1.node: - n3(gn()); + case qt$1.node: + t2(Ro$1()); break; default: - n3(true); + t2(true); } }); } - function mn() { - return D$2() && (navigator == null ? void 0 : navigator.onLine); + function Bo() { + return pr$1() && (navigator == null ? void 0 : navigator.onLine); } - async function yn() { - if ($$1() && typeof global < "u" && global != null && global.NetInfo) { + async function Co$1() { + if (er$1() && typeof global < "u" && global != null && global.NetInfo) { const e2 = await (global == null ? void 0 : global.NetInfo.fetch()); return e2 == null ? void 0 : e2.isConnected; } return true; } - function gn() { + function Ro$1() { return true; } - function or$1(e2) { - switch (R$2()) { - case m$1.browser: - hn(e2); + function ch(e2) { + switch (We$2()) { + case qt$1.browser: + Oo(e2); break; - case m$1.reactNative: - vn(e2); + case qt$1.reactNative: + Po$1(e2); break; } } - function hn(e2) { - !$$1() && D$2() && (window.addEventListener("online", () => e2(true)), window.addEventListener("offline", () => e2(false))); + function Oo(e2) { + !er$1() && pr$1() && (window.addEventListener("online", () => e2(true)), window.addEventListener("offline", () => e2(false))); } - function vn(e2) { - $$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((n3) => e2(n3 == null ? void 0 : n3.isConnected))); + function Po$1(e2) { + er$1() && typeof global < "u" && global != null && global.NetInfo && (global == null ? void 0 : global.NetInfo.addEventListener((t2) => e2(t2 == null ? void 0 : t2.isConnected))); } - const ae$1 = {}; - let sr$1 = class sr { - static get(n3) { - return ae$1[n3]; + const rn = {}; + class lh { + static get(t2) { + return rn[t2]; } - static set(n3, t2) { - ae$1[n3] = t2; + static set(t2, r3) { + rn[t2] = r3; } - static delete(n3) { - delete ae$1[n3]; + static delete(t2) { + delete rn[t2]; } - }; + } const PARSE_ERROR = "PARSE_ERROR"; const INVALID_REQUEST = "INVALID_REQUEST"; const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; @@ -9170,7 +12681,7 @@ return { id, jsonrpc: "2.0", - error: formatErrorMessage(error, data2) + error: formatErrorMessage(error) }; } function formatErrorMessage(error, data2) { @@ -9180,26 +12691,23 @@ if (typeof error === "string") { error = Object.assign(Object.assign({}, getError(SERVER_ERROR)), { message: error }); } - if (typeof data2 !== "undefined") { - error.data = data2; - } if (isReservedErrorCode(error.code)) { error = getErrorByCode(error.code); } return error; } - class IEvents2 { - } - class IBaseJsonRpcProvider extends IEvents2 { + let e$6 = class e { + }; + let n$1$1 = class n2 extends e$6 { constructor() { super(); } - } - class IJsonRpcProvider extends IBaseJsonRpcProvider { - constructor(connection2) { + }; + let r$1$1 = class r extends n$1$1 { + constructor(c2) { super(); } - } + }; const WS_REGEX = "^wss?:"; function getUrlProtocol(url) { const matches = url.match(new RegExp(/^\w+:/, "gi")); @@ -9234,7 +12742,7 @@ function isJsonRpcError(payload) { return "error" in payload; } - class JsonRpcProvider extends IJsonRpcProvider { + class JsonRpcProvider extends r$1$1 { constructor(connection2) { super(connection2); this.events = new eventsExports.EventEmitter(); @@ -9335,13 +12843,13 @@ this.hasRegisteredEventListeners = true; } } - const w$2 = () => 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 : (() => { + const w$1 = () => 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 : (() => { try { return require("ws"); } catch (e2) { } - })(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a$1$1 = (c2) => c2.split("?")[0], h$1$1 = 10, S$1$1 = w$2(); - let f$1 = class f { + })(), b2 = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", a2 = (c2) => c2.split("?")[0], h3 = 10, S$2$1 = w$1(); + let f$2 = class f { constructor(e2) { if (this.url = e2, this.events = new eventsExports.EventEmitter(), this.registering = false, !isWsUrl(e2)) throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); @@ -9374,8 +12882,8 @@ t2(new Error("Connection already closed")); return; } - this.socket.onclose = (n3) => { - this.onClose(n3), e2(); + this.socket.onclose = (n4) => { + this.onClose(n4), e2(); }, this.socket.close(); }); } @@ -9392,23 +12900,23 @@ throw new Error(`Provided URL is not compatible with WebSocket connection: ${e2}`); if (this.registering) { const t2 = this.events.getMaxListeners(); - return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n3, o22) => { - this.events.once("register_error", (s2) => { - this.resetMaxListeners(), o22(s2); + return (this.events.listenerCount("register_error") >= t2 || this.events.listenerCount("open") >= t2) && this.events.setMaxListeners(t2 + 1), new Promise((n4, o22) => { + this.events.once("register_error", (s22) => { + this.resetMaxListeners(), o22(s22); }), this.events.once("open", () => { if (this.resetMaxListeners(), typeof this.socket > "u") return o22(new Error("WebSocket connection is missing or invalid")); - n3(this.socket); + n4(this.socket); }); }); } - return this.url = e2, this.registering = true, new Promise((t2, n3) => { - const o22 = new URLSearchParams(e2).get("origin"), s2 = cjs.isReactNative() ? { headers: { origin: o22 } } : { rejectUnauthorized: !isLocalhostUrl(e2) }, i2 = new S$1$1(e2, [], s2); - b2() ? i2.onerror = (r2) => { - const l2 = r2; - n3(this.emitError(l2.error)); - } : i2.on("error", (r2) => { - n3(this.emitError(r2)); + return this.url = e2, this.registering = true, new Promise((t2, n4) => { + const o22 = new URLSearchParams(e2).get("origin"), s22 = cjs.isReactNative() ? { headers: { origin: o22 } } : { rejectUnauthorized: !isLocalhostUrl(e2) }, i2 = new S$2$1(e2, [], s22); + b2() ? i2.onerror = (r3) => { + const l2 = r3; + n4(this.emitError(l2.error)); + } : i2.on("error", (r3) => { + n4(this.emitError(r3)); }), i2.onopen = () => { this.onOpen(i2), t2(i2); }; @@ -9427,17 +12935,17 @@ this.events.emit("payload", t2); } onError(e2, t2) { - const n3 = this.parseError(t2), o22 = n3.message || n3.toString(), s2 = formatJsonRpcError(e2, o22); - this.events.emit("payload", s2); + const n4 = this.parseError(t2), o22 = n4.message || n4.toString(), s22 = formatJsonRpcError(e2, o22); + this.events.emit("payload", s22); } parseError(e2, t2 = this.url) { - return parseConnectionError(e2, a$1$1(t2), "WS"); + return parseConnectionError(e2, a2(t2), "WS"); } resetMaxListeners() { - this.events.getMaxListeners() > h$1$1 && this.events.setMaxListeners(h$1$1); + this.events.getMaxListeners() > h3 && this.events.setMaxListeners(h3); } emitError(e2) { - const t2 = this.parseError(new Error((e2 == null ? void 0 : e2.message) || `WebSocket connection failed for host: ${a$1$1(this.url)}`)); + const t2 = this.parseError(new Error((e2 == null ? void 0 : e2.message) || `WebSocket connection failed for host: ${a2(this.url)}`)); return this.events.emit("register_error", t2), t2; } }; @@ -9496,9 +13004,9 @@ } return false; } - function baseTimes(n3, iteratee) { - var index = -1, result = Array(n3); - while (++index < n3) { + function baseTimes(n4, iteratee) { + var index = -1, result = Array(n4); + while (++index < n4) { result[index] = iteratee(index); } return result; @@ -9734,7 +13242,7 @@ function arrayLikeKeys(value, inherited) { var isArr = isArray2(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray2(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. + if (hasOwnProperty.call(value, key) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. @@ -10092,33 +13600,33 @@ module22.exports = isEqual; })(lodash_isequal, lodash_isequal.exports); var lodash_isequalExports = lodash_isequal.exports; - const Gi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); - function unfetch_module(e2, n3) { - return n3 = n3 || {}, new Promise(function(t2, r2) { - var s2 = new XMLHttpRequest(), o22 = [], u3 = [], i2 = {}, a3 = function() { - return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() { - return Promise.resolve(s2.responseText); + const Yi = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports); + function unfetch_module(e2, n4) { + return n4 = n4 || {}, new Promise(function(t2, r3) { + var s22 = new XMLHttpRequest(), o22 = [], u3 = [], i2 = {}, a3 = function() { + return { ok: 2 == (s22.status / 100 | 0), statusText: s22.statusText, status: s22.status, url: s22.responseURL, text: function() { + return Promise.resolve(s22.responseText); }, json: function() { - return Promise.resolve(s2.responseText).then(JSON.parse); + return Promise.resolve(s22.responseText).then(JSON.parse); }, blob: function() { - return Promise.resolve(new Blob([s2.response])); + return Promise.resolve(new Blob([s22.response])); }, clone: a3, headers: { keys: function() { return o22; }, entries: function() { return u3; - }, get: function(e22) { - return i2[e22.toLowerCase()]; - }, has: function(e22) { - return e22.toLowerCase() in i2; + }, get: function(e3) { + return i2[e3.toLowerCase()]; + }, has: function(e3) { + return e3.toLowerCase() in i2; } } }; }; - for (var l2 in s2.open(n3.method || "get", e2, true), s2.onload = function() { - s2.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e22, n4, t3) { - o22.push(n4 = n4.toLowerCase()), u3.push([n4, t3]), i2[n4] = i2[n4] ? i2[n4] + "," + t3 : t3; + for (var l2 in s22.open(n4.method || "get", e2, true), s22.onload = function() { + s22.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(e3, n5, t3) { + o22.push(n5 = n5.toLowerCase()), u3.push([n5, t3]), i2[n5] = i2[n5] ? i2[n5] + "," + t3 : t3; }), t2(a3()); - }, s2.onerror = r2, s2.withCredentials = "include" == n3.credentials, n3.headers) - s2.setRequestHeader(l2, n3.headers[l2]); - s2.send(n3.body || null); + }, s22.onerror = r3, s22.withCredentials = "include" == n4.credentials, n4.headers) + s22.setRequestHeader(l2, n4.headers[l2]); + s22.send(n4.body || null); }); } const unfetch_module$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ @@ -10127,86 +13635,86 @@ }, Symbol.toStringTag, { value: "Module" })); const require$$0 = /* @__PURE__ */ getAugmentedNamespace(unfetch_module$1); var browser$2 = fetch || (self.fetch = require$$0.default || require$$0); - const Yi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); - function Hi(n3, e2) { - if (n3.length >= 255) + const Hi = /* @__PURE__ */ getDefaultExportFromCjs(browser$2); + function Ji(n4, e2) { + if (n4.length >= 255) throw new TypeError("Alphabet too long"); for (var t2 = new Uint8Array(256), i2 = 0; i2 < t2.length; i2++) t2[i2] = 255; - for (var s2 = 0; s2 < n3.length; s2++) { - var r2 = n3.charAt(s2), o22 = r2.charCodeAt(0); + for (var s22 = 0; s22 < n4.length; s22++) { + var r3 = n4.charAt(s22), o22 = r3.charCodeAt(0); if (t2[o22] !== 255) - throw new TypeError(r2 + " is ambiguous"); - t2[o22] = s2; + throw new TypeError(r3 + " is ambiguous"); + t2[o22] = s22; } - var a3 = n3.length, h4 = n3.charAt(0), l2 = Math.log(a3) / Math.log(256), d3 = Math.log(256) / Math.log(a3); - function p3(u3) { + var a3 = n4.length, h4 = n4.charAt(0), l2 = Math.log(a3) / Math.log(256), d5 = Math.log(256) / Math.log(a3); + function g3(u3) { if (u3 instanceof Uint8Array || (ArrayBuffer.isView(u3) ? u3 = new Uint8Array(u3.buffer, u3.byteOffset, u3.byteLength) : Array.isArray(u3) && (u3 = Uint8Array.from(u3))), !(u3 instanceof Uint8Array)) throw new TypeError("Expected Uint8Array"); if (u3.length === 0) return ""; - for (var m2 = 0, z3 = 0, I2 = 0, _3 = u3.length; I2 !== _3 && u3[I2] === 0; ) - I2++, m2++; - for (var T2 = (_3 - I2) * d3 + 1 >>> 0, f2 = new Uint8Array(T2); I2 !== _3; ) { - for (var S2 = u3[I2], A2 = 0, C2 = T2 - 1; (S2 !== 0 || A2 < z3) && C2 !== -1; C2--, A2++) - S2 += 256 * f2[C2] >>> 0, f2[C2] = S2 % a3 >>> 0, S2 = S2 / a3 >>> 0; - if (S2 !== 0) + for (var p2 = 0, _3 = 0, D2 = 0, P2 = u3.length; D2 !== P2 && u3[D2] === 0; ) + D2++, p2++; + for (var x2 = (P2 - D2) * d5 + 1 >>> 0, E2 = new Uint8Array(x2); D2 !== P2; ) { + for (var O3 = u3[D2], N22 = 0, R2 = x2 - 1; (O3 !== 0 || N22 < _3) && R2 !== -1; R2--, N22++) + O3 += 256 * E2[R2] >>> 0, E2[R2] = O3 % a3 >>> 0, O3 = O3 / a3 >>> 0; + if (O3 !== 0) throw new Error("Non-zero carry"); - z3 = A2, I2++; + _3 = N22, D2++; } - for (var x2 = T2 - z3; x2 !== T2 && f2[x2] === 0; ) - x2++; - for (var j2 = h4.repeat(m2); x2 < T2; ++x2) - j2 += n3.charAt(f2[x2]); + for (var A2 = x2 - _3; A2 !== x2 && E2[A2] === 0; ) + A2++; + for (var j2 = h4.repeat(p2); A2 < x2; ++A2) + j2 += n4.charAt(E2[A2]); return j2; } - function y3(u3) { + function m3(u3) { if (typeof u3 != "string") throw new TypeError("Expected String"); if (u3.length === 0) return new Uint8Array(); - var m2 = 0; - if (u3[m2] !== " ") { - for (var z3 = 0, I2 = 0; u3[m2] === h4; ) - z3++, m2++; - for (var _3 = (u3.length - m2) * l2 + 1 >>> 0, T2 = new Uint8Array(_3); u3[m2]; ) { - var f2 = t2[u3.charCodeAt(m2)]; - if (f2 === 255) + var p2 = 0; + if (u3[p2] !== " ") { + for (var _3 = 0, D2 = 0; u3[p2] === h4; ) + _3++, p2++; + for (var P2 = (u3.length - p2) * l2 + 1 >>> 0, x2 = new Uint8Array(P2); u3[p2]; ) { + var E2 = t2[u3.charCodeAt(p2)]; + if (E2 === 255) return; - for (var S2 = 0, A2 = _3 - 1; (f2 !== 0 || S2 < I2) && A2 !== -1; A2--, S2++) - f2 += a3 * T2[A2] >>> 0, T2[A2] = f2 % 256 >>> 0, f2 = f2 / 256 >>> 0; - if (f2 !== 0) + for (var O3 = 0, N22 = P2 - 1; (E2 !== 0 || O3 < D2) && N22 !== -1; N22--, O3++) + E2 += a3 * x2[N22] >>> 0, x2[N22] = E2 % 256 >>> 0, E2 = E2 / 256 >>> 0; + if (E2 !== 0) throw new Error("Non-zero carry"); - I2 = S2, m2++; + D2 = O3, p2++; } - if (u3[m2] !== " ") { - for (var C2 = _3 - I2; C2 !== _3 && T2[C2] === 0; ) - C2++; - for (var x2 = new Uint8Array(z3 + (_3 - C2)), j2 = z3; C2 !== _3; ) - x2[j2++] = T2[C2++]; - return x2; + if (u3[p2] !== " ") { + for (var R2 = P2 - D2; R2 !== P2 && x2[R2] === 0; ) + R2++; + for (var A2 = new Uint8Array(_3 + (P2 - R2)), j2 = _3; R2 !== P2; ) + A2[j2++] = x2[R2++]; + return A2; } } } - function M2(u3) { - var m2 = y3(u3); - if (m2) - return m2; + function L4(u3) { + var p2 = m3(u3); + if (p2) + return p2; throw new Error(`Non-${e2} character`); } - return { encode: p3, decodeUnsafe: y3, decode: M2 }; + return { encode: g3, decodeUnsafe: m3, decode: L4 }; } - var Ji = Hi, Xi = Ji; - const Ne = (n3) => { - if (n3 instanceof Uint8Array && n3.constructor.name === "Uint8Array") - return n3; - if (n3 instanceof ArrayBuffer) - return new Uint8Array(n3); - if (ArrayBuffer.isView(n3)) - return new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength); + var Xi = Ji, Wi = Xi; + const Ue$1 = (n4) => { + if (n4 instanceof Uint8Array && n4.constructor.name === "Uint8Array") + return n4; + if (n4 instanceof ArrayBuffer) + return new Uint8Array(n4); + if (ArrayBuffer.isView(n4)) + return new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength); throw new Error("Unknown type, must be binary type"); - }, Wi = (n3) => new TextEncoder().encode(n3), Qi = (n3) => new TextDecoder().decode(n3); - class Zi { + }, Qi = (n4) => new TextEncoder().encode(n4), Zi = (n4) => new TextDecoder().decode(n4); + let es$1 = class es { constructor(e2, t2, i2) { this.name = e2, this.prefix = t2, this.baseEncode = i2; } @@ -10215,8 +13723,8 @@ return `${this.prefix}${this.baseEncode(e2)}`; throw Error("Unknown type, must be binary type"); } - } - class es { + }; + let ts$1 = class ts { constructor(e2, t2, i2) { if (this.name = e2, this.prefix = t2, t2.codePointAt(0) === void 0) throw new Error("Invalid prefix character"); @@ -10231,15 +13739,15 @@ throw Error("Can only multibase decode strings"); } or(e2) { - return Ue$2(this, e2); + return $e$2(this, e2); } - } - class ts { + }; + let is$1 = class is { constructor(e2) { this.decoders = e2; } or(e2) { - return Ue$2(this, e2); + return $e$2(this, e2); } decode(e2) { const t2 = e2[0], i2 = this.decoders[t2]; @@ -10247,11 +13755,11 @@ return i2.decode(e2); throw RangeError(`Unable to decode multibase string ${JSON.stringify(e2)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); } - } - const Ue$2 = (n3, e2) => new ts({ ...n3.decoders || { [n3.prefix]: n3 }, ...e2.decoders || { [e2.prefix]: e2 } }); - class is { - constructor(e2, t2, i2, s2) { - this.name = e2, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s2, this.encoder = new Zi(e2, t2, i2), this.decoder = new es(e2, t2, s2); + }; + const $e$2 = (n4, e2) => new is$1({ ...n4.decoders || { [n4.prefix]: n4 }, ...e2.decoders || { [e2.prefix]: e2 } }); + let ss$2 = class ss { + constructor(e2, t2, i2, s22) { + this.name = e2, this.prefix = t2, this.baseEncode = i2, this.baseDecode = s22, this.encoder = new es$1(e2, t2, i2), this.decoder = new ts$1(e2, t2, s22); } encode(e2) { return this.encoder.encode(e2); @@ -10259,258 +13767,258 @@ decode(e2) { return this.decoder.decode(e2); } - } - const W$1 = ({ name: n3, prefix: e2, encode: t2, decode: i2 }) => new is(n3, e2, t2, i2), B$3 = ({ prefix: n3, name: e2, alphabet: t2 }) => { - const { encode: i2, decode: s2 } = Xi(t2, e2); - return W$1({ prefix: n3, name: e2, encode: i2, decode: (r2) => Ne(s2(r2)) }); - }, ss = (n3, e2, t2, i2) => { - const s2 = {}; - for (let d3 = 0; d3 < e2.length; ++d3) - s2[e2[d3]] = d3; - let r2 = n3.length; - for (; n3[r2 - 1] === "="; ) - --r2; - const o22 = new Uint8Array(r2 * t2 / 8 | 0); + }; + const Q$1 = ({ name: n4, prefix: e2, encode: t2, decode: i2 }) => new ss$2(n4, e2, t2, i2), K$1 = ({ prefix: n4, name: e2, alphabet: t2 }) => { + const { encode: i2, decode: s22 } = Wi(t2, e2); + return Q$1({ prefix: n4, name: e2, encode: i2, decode: (r3) => Ue$1(s22(r3)) }); + }, rs$1 = (n4, e2, t2, i2) => { + const s22 = {}; + for (let d5 = 0; d5 < e2.length; ++d5) + s22[e2[d5]] = d5; + let r3 = n4.length; + for (; n4[r3 - 1] === "="; ) + --r3; + const o22 = new Uint8Array(r3 * t2 / 8 | 0); let a3 = 0, h4 = 0, l2 = 0; - for (let d3 = 0; d3 < r2; ++d3) { - const p3 = s2[n3[d3]]; - if (p3 === void 0) + for (let d5 = 0; d5 < r3; ++d5) { + const g3 = s22[n4[d5]]; + if (g3 === void 0) throw new SyntaxError(`Non-${i2} character`); - h4 = h4 << t2 | p3, a3 += t2, a3 >= 8 && (a3 -= 8, o22[l2++] = 255 & h4 >> a3); + h4 = h4 << t2 | g3, a3 += t2, a3 >= 8 && (a3 -= 8, o22[l2++] = 255 & h4 >> a3); } if (a3 >= t2 || 255 & h4 << 8 - a3) throw new SyntaxError("Unexpected end of data"); return o22; - }, rs = (n3, e2, t2) => { - const i2 = e2[e2.length - 1] === "=", s2 = (1 << t2) - 1; - let r2 = "", o22 = 0, a3 = 0; - for (let h4 = 0; h4 < n3.length; ++h4) - for (a3 = a3 << 8 | n3[h4], o22 += 8; o22 > t2; ) - o22 -= t2, r2 += e2[s2 & a3 >> o22]; - if (o22 && (r2 += e2[s2 & a3 << t2 - o22]), i2) - for (; r2.length * t2 & 7; ) - r2 += "="; - return r2; - }, g$2 = ({ name: n3, prefix: e2, bitsPerChar: t2, alphabet: i2 }) => W$1({ prefix: e2, name: n3, encode(s2) { - return rs(s2, i2, t2); - }, decode(s2) { - return ss(s2, i2, t2, n3); - } }), ns = W$1({ prefix: "\0", name: "identity", encode: (n3) => Qi(n3), decode: (n3) => Wi(n3) }); - var os = Object.freeze({ __proto__: null, identity: ns }); - const as$1 = g$2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); - var hs$1 = Object.freeze({ __proto__: null, base2: as$1 }); - const cs$1 = g$2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); - var us$1 = Object.freeze({ __proto__: null, base8: cs$1 }); - const ls$1 = B$3({ prefix: "9", name: "base10", alphabet: "0123456789" }); - var ds$1 = Object.freeze({ __proto__: null, base10: ls$1 }); - const gs$1 = g$2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), ps$1 = g$2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); - var Ds = Object.freeze({ __proto__: null, base16: gs$1, base16upper: ps$1 }); - const ys = g$2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), ms$1 = g$2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), bs = g$2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), fs = g$2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), Es = g$2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), ws = g$2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), vs = g$2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Is = g$2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), Cs = g$2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); - var Rs = Object.freeze({ __proto__: null, base32: ys, base32upper: ms$1, base32pad: bs, base32padupper: fs, base32hex: Es, base32hexupper: ws, base32hexpad: vs, base32hexpadupper: Is, base32z: Cs }); - const _s = B$3({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ts = B$3({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); - var Ss = Object.freeze({ __proto__: null, base36: _s, base36upper: Ts }); - const Ps = B$3({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), xs = B$3({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); - var Os = Object.freeze({ __proto__: null, base58btc: Ps, base58flickr: xs }); - const As = g$2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), zs = g$2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ns = g$2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us = g$2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); - var Ls = Object.freeze({ __proto__: null, base64: As, base64pad: zs, base64url: Ns, base64urlpad: Us }); - const Le$1 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), $s = Le$1.reduce((n3, e2, t2) => (n3[t2] = e2, n3), []), Fs = Le$1.reduce((n3, e2, t2) => (n3[e2.codePointAt(0)] = t2, n3), []); - function Ms(n3) { - return n3.reduce((e2, t2) => (e2 += $s[t2], e2), ""); - } - function ks(n3) { + }, ns = (n4, e2, t2) => { + const i2 = e2[e2.length - 1] === "=", s22 = (1 << t2) - 1; + let r3 = "", o22 = 0, a3 = 0; + for (let h4 = 0; h4 < n4.length; ++h4) + for (a3 = a3 << 8 | n4[h4], o22 += 8; o22 > t2; ) + o22 -= t2, r3 += e2[s22 & a3 >> o22]; + if (o22 && (r3 += e2[s22 & a3 << t2 - o22]), i2) + for (; r3.length * t2 & 7; ) + r3 += "="; + return r3; + }, y2 = ({ name: n4, prefix: e2, bitsPerChar: t2, alphabet: i2 }) => Q$1({ prefix: e2, name: n4, encode(s22) { + return ns(s22, i2, t2); + }, decode(s22) { + return rs$1(s22, i2, t2, n4); + } }), os$1 = Q$1({ prefix: "\0", name: "identity", encode: (n4) => Zi(n4), decode: (n4) => Qi(n4) }); + var as$1 = Object.freeze({ __proto__: null, identity: os$1 }); + const hs$1 = y2({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); + var cs$1 = Object.freeze({ __proto__: null, base2: hs$1 }); + const ls$1 = y2({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); + var us$1 = Object.freeze({ __proto__: null, base8: ls$1 }); + const ds$1 = K$1({ prefix: "9", name: "base10", alphabet: "0123456789" }); + var gs$1 = Object.freeze({ __proto__: null, base10: ds$1 }); + const ps$1 = y2({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), Ds$1 = y2({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); + var ys$1 = Object.freeze({ __proto__: null, base16: ps$1, base16upper: Ds$1 }); + const ms$2 = y2({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), bs$1 = y2({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), fs = y2({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), Es$1 = y2({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), ws$1 = y2({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), vs$1 = y2({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), Is$1 = y2({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Cs$1 = y2({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), _s$1 = y2({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); + var Rs$1 = Object.freeze({ __proto__: null, base32: ms$2, base32upper: bs$1, base32pad: fs, base32padupper: Es$1, base32hex: ws$1, base32hexupper: vs$1, base32hexpad: Is$1, base32hexpadupper: Cs$1, base32z: _s$1 }); + const Ts$1 = K$1({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Ss$1 = K$1({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); + var Ps$1 = Object.freeze({ __proto__: null, base36: Ts$1, base36upper: Ss$1 }); + const xs$1 = K$1({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), Os$1 = K$1({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); + var As$1 = Object.freeze({ __proto__: null, base58btc: xs$1, base58flickr: Os$1 }); + const zs$1 = y2({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), Ns$1 = y2({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), Ls$1 = y2({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), Us$1 = y2({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); + var $s$1 = Object.freeze({ __proto__: null, base64: zs$1, base64pad: Ns$1, base64url: Ls$1, base64urlpad: Us$1 }); + const Fe$1 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), Fs$1 = Fe$1.reduce((n4, e2, t2) => (n4[t2] = e2, n4), []), ks$1 = Fe$1.reduce((n4, e2, t2) => (n4[e2.codePointAt(0)] = t2, n4), []); + function Bs$1(n4) { + return n4.reduce((e2, t2) => (e2 += Fs$1[t2], e2), ""); + } + function Ms$1(n4) { const e2 = []; - for (const t2 of n3) { - const i2 = Fs[t2.codePointAt(0)]; + for (const t2 of n4) { + const i2 = ks$1[t2.codePointAt(0)]; if (i2 === void 0) throw new Error(`Non-base256emoji character: ${t2}`); e2.push(i2); } return new Uint8Array(e2); } - const Ks = W$1({ prefix: "🚀", name: "base256emoji", encode: Ms, decode: ks }); - var Bs = Object.freeze({ __proto__: null, base256emoji: Ks }), Vs = Fe$1, $e$2 = 128, qs = 127, js = ~qs, Gs = Math.pow(2, 31); - function Fe$1(n3, e2, t2) { + const Ks$1 = Q$1({ prefix: "🚀", name: "base256emoji", encode: Bs$1, decode: Ms$1 }); + var Vs$1 = Object.freeze({ __proto__: null, base256emoji: Ks$1 }), qs$1 = Be$2, ke$1 = 128, js$1 = 127, Gs$1 = ~js$1, Ys$1 = Math.pow(2, 31); + function Be$2(n4, e2, t2) { e2 = e2 || [], t2 = t2 || 0; - for (var i2 = t2; n3 >= Gs; ) - e2[t2++] = n3 & 255 | $e$2, n3 /= 128; - for (; n3 & js; ) - e2[t2++] = n3 & 255 | $e$2, n3 >>>= 7; - return e2[t2] = n3 | 0, Fe$1.bytes = t2 - i2 + 1, e2; - } - var Ys = he$1, Hs = 128, Me$2 = 127; - function he$1(n3, i2) { - var t2 = 0, i2 = i2 || 0, s2 = 0, r2 = i2, o22, a3 = n3.length; + for (var i2 = t2; n4 >= Ys$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 /= 128; + for (; n4 & Gs$1; ) + e2[t2++] = n4 & 255 | ke$1, n4 >>>= 7; + return e2[t2] = n4 | 0, Be$2.bytes = t2 - i2 + 1, e2; + } + var Hs$1 = de$1, Js$1 = 128, Me$1 = 127; + function de$1(n4, i2) { + var t2 = 0, i2 = i2 || 0, s22 = 0, r3 = i2, o22, a3 = n4.length; do { - if (r2 >= a3) - throw he$1.bytes = 0, new RangeError("Could not decode varint"); - o22 = n3[r2++], t2 += s2 < 28 ? (o22 & Me$2) << s2 : (o22 & Me$2) * Math.pow(2, s2), s2 += 7; - } while (o22 >= Hs); - return he$1.bytes = r2 - i2, t2; - } - var Js = Math.pow(2, 7), Xs = Math.pow(2, 14), Ws = Math.pow(2, 21), Qs = Math.pow(2, 28), Zs = Math.pow(2, 35), er$2 = Math.pow(2, 42), tr$2 = Math.pow(2, 49), ir$1 = Math.pow(2, 56), sr2 = Math.pow(2, 63), rr$2 = function(n3) { - return n3 < Js ? 1 : n3 < Xs ? 2 : n3 < Ws ? 3 : n3 < Qs ? 4 : n3 < Zs ? 5 : n3 < er$2 ? 6 : n3 < tr$2 ? 7 : n3 < ir$1 ? 8 : n3 < sr2 ? 9 : 10; - }, nr$2 = { encode: Vs, decode: Ys, encodingLength: rr$2 }, ke$2 = nr$2; - const Ke$2 = (n3, e2, t2 = 0) => (ke$2.encode(n3, e2, t2), e2), Be$2 = (n3) => ke$2.encodingLength(n3), ce$1 = (n3, e2) => { - const t2 = e2.byteLength, i2 = Be$2(n3), s2 = i2 + Be$2(t2), r2 = new Uint8Array(s2 + t2); - return Ke$2(n3, r2, 0), Ke$2(t2, r2, i2), r2.set(e2, s2), new or$3(n3, t2, e2, r2); + if (r3 >= a3) + throw de$1.bytes = 0, new RangeError("Could not decode varint"); + o22 = n4[r3++], t2 += s22 < 28 ? (o22 & Me$1) << s22 : (o22 & Me$1) * Math.pow(2, s22), s22 += 7; + } while (o22 >= Js$1); + return de$1.bytes = r3 - i2, t2; + } + var Xs$1 = Math.pow(2, 7), Ws$1 = Math.pow(2, 14), Qs$1 = Math.pow(2, 21), Zs$1 = Math.pow(2, 28), er$2 = Math.pow(2, 35), tr$1 = Math.pow(2, 42), ir$1 = Math.pow(2, 49), sr$1 = Math.pow(2, 56), rr$1 = Math.pow(2, 63), nr$1 = function(n4) { + return n4 < Xs$1 ? 1 : n4 < Ws$1 ? 2 : n4 < Qs$1 ? 3 : n4 < Zs$1 ? 4 : n4 < er$2 ? 5 : n4 < tr$1 ? 6 : n4 < ir$1 ? 7 : n4 < sr$1 ? 8 : n4 < rr$1 ? 9 : 10; + }, or$1 = { encode: qs$1, decode: Hs$1, encodingLength: nr$1 }, Ke$1 = or$1; + const Ve$1 = (n4, e2, t2 = 0) => (Ke$1.encode(n4, e2, t2), e2), qe$1 = (n4) => Ke$1.encodingLength(n4), ge$2 = (n4, e2) => { + const t2 = e2.byteLength, i2 = qe$1(n4), s22 = i2 + qe$1(t2), r3 = new Uint8Array(s22 + t2); + return Ve$1(n4, r3, 0), Ve$1(t2, r3, i2), r3.set(e2, s22), new ar$1(n4, t2, e2, r3); }; - let or$3 = class or { - constructor(e2, t2, i2, s2) { - this.code = e2, this.size = t2, this.digest = i2, this.bytes = s2; + let ar$1 = class ar { + constructor(e2, t2, i2, s22) { + this.code = e2, this.size = t2, this.digest = i2, this.bytes = s22; } }; - const Ve$2 = ({ name: n3, code: e2, encode: t2 }) => new ar$1(n3, e2, t2); - let ar$1 = class ar { + const je$1 = ({ name: n4, code: e2, encode: t2 }) => new hr$1(n4, e2, t2); + let hr$1 = class hr { constructor(e2, t2, i2) { this.name = e2, this.code = t2, this.encode = i2; } digest(e2) { if (e2 instanceof Uint8Array) { const t2 = this.encode(e2); - return t2 instanceof Uint8Array ? ce$1(this.code, t2) : t2.then((i2) => ce$1(this.code, i2)); + return t2 instanceof Uint8Array ? ge$2(this.code, t2) : t2.then((i2) => ge$2(this.code, i2)); } else throw Error("Unknown type, must be binary type"); } }; - const qe$2 = (n3) => async (e2) => new Uint8Array(await crypto.subtle.digest(n3, e2)), hr$1 = Ve$2({ name: "sha2-256", code: 18, encode: qe$2("SHA-256") }), cr$1 = Ve$2({ name: "sha2-512", code: 19, encode: qe$2("SHA-512") }); - var ur = Object.freeze({ __proto__: null, sha256: hr$1, sha512: cr$1 }); - const je$1 = 0, lr$1 = "identity", Ge$2 = Ne, dr$1 = (n3) => ce$1(je$1, Ge$2(n3)), gr = { code: je$1, name: lr$1, encode: Ge$2, digest: dr$1 }; - var pr = Object.freeze({ __proto__: null, identity: gr }); + const Ge$1 = (n4) => async (e2) => new Uint8Array(await crypto.subtle.digest(n4, e2)), cr$1 = je$1({ name: "sha2-256", code: 18, encode: Ge$1("SHA-256") }), lr = je$1({ name: "sha2-512", code: 19, encode: Ge$1("SHA-512") }); + var ur$1 = Object.freeze({ __proto__: null, sha256: cr$1, sha512: lr }); + const Ye$1 = 0, dr$1 = "identity", He$1 = Ue$1, gr$1 = (n4) => ge$2(Ye$1, He$1(n4)), pr = { code: Ye$1, name: dr$1, encode: He$1, digest: gr$1 }; + var Dr$1 = Object.freeze({ __proto__: null, identity: pr }); new TextEncoder(), new TextDecoder(); - const Ye$1 = { ...os, ...hs$1, ...us$1, ...ds$1, ...Ds, ...Rs, ...Ss, ...Os, ...Ls, ...Bs }; - ({ ...ur, ...pr }); - function He$2(n3) { - return globalThis.Buffer != null ? new Uint8Array(n3.buffer, n3.byteOffset, n3.byteLength) : n3; + const Je$1 = { ...as$1, ...cs$1, ...us$1, ...gs$1, ...ys$1, ...Rs$1, ...Ps$1, ...As$1, ...$s$1, ...Vs$1 }; + ({ ...ur$1, ...Dr$1 }); + function Xe$2(n4) { + return globalThis.Buffer != null ? new Uint8Array(n4.buffer, n4.byteOffset, n4.byteLength) : n4; } - function Dr(n3 = 0) { - return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? He$2(globalThis.Buffer.allocUnsafe(n3)) : new Uint8Array(n3); + function yr$1(n4 = 0) { + return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? Xe$2(globalThis.Buffer.allocUnsafe(n4)) : new Uint8Array(n4); } - function Je(n3, e2, t2, i2) { - return { name: n3, prefix: e2, encoder: { name: n3, prefix: e2, encode: t2 }, decoder: { decode: i2 } }; + function We$1(n4, e2, t2, i2) { + return { name: n4, prefix: e2, encoder: { name: n4, prefix: e2, encode: t2 }, decoder: { decode: i2 } }; } - const Xe = Je("utf8", "u", (n3) => "u" + new TextDecoder("utf8").decode(n3), (n3) => new TextEncoder().encode(n3.substring(1))), ue$1 = Je("ascii", "a", (n3) => { + const Qe$1 = We$1("utf8", "u", (n4) => "u" + new TextDecoder("utf8").decode(n4), (n4) => new TextEncoder().encode(n4.substring(1))), pe$1 = We$1("ascii", "a", (n4) => { let e2 = "a"; - for (let t2 = 0; t2 < n3.length; t2++) - e2 += String.fromCharCode(n3[t2]); + for (let t2 = 0; t2 < n4.length; t2++) + e2 += String.fromCharCode(n4[t2]); return e2; - }, (n3) => { - n3 = n3.substring(1); - const e2 = Dr(n3.length); - for (let t2 = 0; t2 < n3.length; t2++) - e2[t2] = n3.charCodeAt(t2); + }, (n4) => { + n4 = n4.substring(1); + const e2 = yr$1(n4.length); + for (let t2 = 0; t2 < n4.length; t2++) + e2[t2] = n4.charCodeAt(t2); return e2; - }), yr = { utf8: Xe, "utf-8": Xe, hex: Ye$1.base16, latin1: ue$1, ascii: ue$1, binary: ue$1, ...Ye$1 }; - function mr$1(n3, e2 = "utf8") { - const t2 = yr[e2]; + }), mr$1 = { utf8: Qe$1, "utf-8": Qe$1, hex: Je$1.base16, latin1: pe$1, ascii: pe$1, binary: pe$1, ...Je$1 }; + function br(n4, e2 = "utf8") { + const t2 = mr$1[e2]; if (!t2) throw new Error(`Unsupported encoding "${e2}"`); - return (e2 === "utf8" || e2 === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? He$2(globalThis.Buffer.from(n3, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n3}`); + return (e2 === "utf8" || e2 === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null ? Xe$2(globalThis.Buffer.from(n4, "utf-8")) : t2.decoder.decode(`${t2.prefix}${n4}`); } - const le$1 = "wc", We$2 = 2, Q$1 = "core", O = `${le$1}@2:${Q$1}:`, Qe$2 = { name: Q$1, logger: "error" }, Ze = { database: ":memory:" }, et$1 = "crypto", de$1 = "client_ed25519_seed", tt$1 = cjs$4.ONE_DAY, it$1 = "keychain", st$1 = "0.3", rt$2 = "messages", nt$1 = "0.3", ot$2 = cjs$4.SIX_HOURS, at$2 = "publisher", ht$2 = "irn", ct$1 = "error", ge$1 = "wss://relay.walletconnect.com", pe$1 = "wss://relay.walletconnect.org", ut$2 = "relayer", D$1$1 = { 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" }, lt$2 = "_subscription", P$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, dt$2 = cjs$4.ONE_SECOND, gt$2 = "2.11.2", pt$2 = 1e4, Dt$1 = "0.3", yt$2 = "WALLETCONNECT_CLIENT_ID", w$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, mt$2 = "subscription", bt$2 = "0.3", ft$2 = cjs$4.FIVE_SECONDS * 1e3, Et$2 = "pairing", wt$2 = "0.3", $$3 = { wc_pairingDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 0 } } }, V$3 = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, R$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, vt$2 = "history", It$2 = "0.3", Ct$1 = "expirer", v2 = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Rt$2 = "0.3", Z = "verify-api", F$1 = "https://verify.walletconnect.com", ee$2 = "https://verify.walletconnect.org", _t$1 = [F$1, ee$2], Tt$2 = "echo", St$2 = "https://echo.walletconnect.com"; - let Pt$2 = class Pt { + const De$1 = "wc", Ze$1 = 2, Z = "core", z$1$1 = `${De$1}@2:${Z}:`, et$1 = { name: Z, logger: "error" }, tt$1 = { database: ":memory:" }, it$1 = "crypto", ye$1 = "client_ed25519_seed", st$1 = cjs$3.ONE_DAY, rt$1 = "keychain", nt$2 = "0.3", ot$1 = "messages", at$1 = "0.3", ht$1 = cjs$3.SIX_HOURS, ct$1 = "publisher", lt$1 = "irn", ut$1 = "error", me$2 = "wss://relay.walletconnect.com", be$1 = "wss://relay.walletconnect.org", dt$1 = "relayer", v2 = { 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" }, gt = "_subscription", f$1 = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, pt$1 = cjs$3.ONE_SECOND, Dt$1 = "2.12.2", yt$1 = 1e4, mt = "0.3", bt$1 = "WALLETCONNECT_CLIENT_ID", S$1$1 = { created: "subscription_created", deleted: "subscription_deleted", expired: "subscription_expired", disabled: "subscription_disabled", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, ft = "subscription", Et$1 = "0.3", wt = cjs$3.FIVE_SECONDS * 1e3, vt = "pairing", It$1 = "0.3", F$1 = { wc_pairingDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1e3 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1001 } }, wc_pairingPing: { req: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1002 }, res: { ttl: cjs$3.THIRTY_SECONDS, prompt: false, tag: 1003 } }, unregistered_method: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 0 } } }, V$1 = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, I$1 = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, Ct = "history", _t$1 = "0.3", Rt$1 = "expirer", C$4 = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, Tt$1 = "0.3", ee$1 = "verify-api", k$1 = "https://verify.walletconnect.com", te = "https://verify.walletconnect.org", St$1 = [k$1, te], Pt$1 = "echo", xt = "https://echo.walletconnect.com"; + let Ot$1 = class Ot { constructor(e2, t2) { - this.core = e2, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = it$1, this.version = st$1, this.initialized = false, this.storagePrefix = O, this.init = async () => { + this.core = e2, this.logger = t2, this.keychain = /* @__PURE__ */ new Map(), this.name = rt$1, this.version = nt$2, this.initialized = false, this.storagePrefix = z$1$1, this.init = async () => { if (!this.initialized) { const i2 = await this.getKeyChain(); typeof i2 < "u" && (this.keychain = i2), this.initialized = true; } - }, this.has = (i2) => (this.isInitialized(), this.keychain.has(i2)), this.set = async (i2, s2) => { - this.isInitialized(), this.keychain.set(i2, s2), await this.persist(); + }, this.has = (i2) => (this.isInitialized(), this.keychain.has(i2)), this.set = async (i2, s22) => { + this.isInitialized(), this.keychain.set(i2, s22), await this.persist(); }, this.get = (i2) => { this.isInitialized(); - const s2 = this.keychain.get(i2); - if (typeof s2 > "u") { - const { message: r2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${i2}`); - throw new Error(r2); + const s22 = this.keychain.get(i2); + if (typeof s22 > "u") { + const { message: r3 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${i2}`); + throw new Error(r3); } - return s2; + return s22; }, this.del = async (i2) => { this.isInitialized(), this.keychain.delete(i2), await this.persist(); - }, this.core = e2, this.logger = cjs$3.generateChildLogger(t2, this.name); + }, this.core = e2, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } async setKeyChain(e2) { - await this.core.storage.setItem(this.storageKey, rt$1(e2)); + await this.core.storage.setItem(this.storageKey, i0(e2)); } async getKeyChain() { const e2 = await this.core.storage.getItem(this.storageKey); - return typeof e2 < "u" ? ot$1(e2) : void 0; + return typeof e2 < "u" ? n0(e2) : void 0; } async persist() { await this.setKeyChain(this.keychain); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } }; - let xt$2 = class xt { + let At$1 = class At { constructor(e2, t2, i2) { - this.core = e2, this.logger = t2, this.name = et$1, this.initialized = false, this.init = async () => { + this.core = e2, this.logger = t2, this.name = it$1, this.initialized = false, this.init = async () => { this.initialized || (await this.keychain.init(), this.initialized = true); - }, this.hasKeys = (s2) => (this.isInitialized(), this.keychain.has(s2)), this.getClientId = async () => { + }, this.hasKeys = (s22) => (this.isInitialized(), this.keychain.has(s22)), this.getClientId = async () => { this.isInitialized(); - const s2 = await this.getClientSeed(), r2 = generateKeyPair(s2); - return encodeIss(r2.publicKey); + const s22 = await this.getClientSeed(), r3 = generateKeyPair(s22); + return encodeIss(r3.publicKey); }, this.generateKeyPair = () => { this.isInitialized(); - const s2 = kn(); - return this.setPrivateKey(s2.publicKey, s2.privateKey); - }, this.signJWT = async (s2) => { + const s22 = mu(); + return this.setPrivateKey(s22.publicKey, s22.privateKey); + }, this.signJWT = async (s22) => { this.isInitialized(); - const r2 = await this.getClientSeed(), o22 = generateKeyPair(r2), a3 = Vn(), h4 = tt$1; - return await signJWT(a3, s2, h4, o22); - }, this.generateSharedKey = (s2, r2, o22) => { + const r3 = await this.getClientSeed(), o22 = generateKeyPair(r3), a3 = gu(), h4 = st$1; + return await signJWT(a3, s22, h4, o22); + }, this.generateSharedKey = (s22, r3, o22) => { this.isInitialized(); - const a3 = this.getPrivateKey(s2), h4 = Mn(a3, r2); + const a3 = this.getPrivateKey(s22), h4 = Au(a3, r3); return this.setSymKey(h4, o22); - }, this.setSymKey = async (s2, r2) => { + }, this.setSymKey = async (s22, r3) => { this.isInitialized(); - const o22 = r2 || Kn(s2); - return await this.keychain.set(o22, s2), o22; - }, this.deleteKeyPair = async (s2) => { - this.isInitialized(), await this.keychain.del(s2); - }, this.deleteSymKey = async (s2) => { - this.isInitialized(), await this.keychain.del(s2); - }, this.encode = async (s2, r2, o22) => { + const o22 = r3 || bu(s22); + return await this.keychain.set(o22, s22), o22; + }, this.deleteKeyPair = async (s22) => { + this.isInitialized(), await this.keychain.del(s22); + }, this.deleteSymKey = async (s22) => { + this.isInitialized(), await this.keychain.del(s22); + }, this.encode = async (s22, r3, o22) => { this.isInitialized(); - const a3 = Ae$1(o22), h4 = safeJsonStringify(r2); - if (qn(a3)) { - const y3 = a3.senderPublicKey, M2 = a3.receiverPublicKey; - s2 = await this.generateSharedKey(y3, M2); - } - const l2 = this.getSymKey(s2), { type: d3, senderPublicKey: p3 } = a3; - return xn({ type: d3, symKey: l2, message: h4, senderPublicKey: p3 }); - }, this.decode = async (s2, r2, o22) => { + const a3 = eo$1(o22), h4 = safeJsonStringify(r3); + if (Eu(a3)) { + const m3 = a3.senderPublicKey, L4 = a3.receiverPublicKey; + s22 = await this.generateSharedKey(m3, L4); + } + const l2 = this.getSymKey(s22), { type: d5, senderPublicKey: g3 } = a3; + return wu({ type: d5, symKey: l2, message: h4, senderPublicKey: g3 }); + }, this.decode = async (s22, r3, o22) => { this.isInitialized(); - const a3 = Hn(r2, o22); - if (qn(a3)) { + const a3 = Mu(r3, o22); + if (Eu(a3)) { const h4 = a3.receiverPublicKey, l2 = a3.senderPublicKey; - s2 = await this.generateSharedKey(h4, l2); + s22 = await this.generateSharedKey(h4, l2); } try { - const h4 = this.getSymKey(s2), l2 = Fn({ symKey: h4, encoded: r2 }); + const h4 = this.getSymKey(s22), l2 = xu({ symKey: h4, encoded: r3 }); return safeJsonParse(l2); } catch (h4) { - this.logger.error(`Failed to decode message from topic: '${s2}', clientId: '${await this.getClientId()}'`), this.logger.error(h4); + this.logger.error(`Failed to decode message from topic: '${s22}', clientId: '${await this.getClientId()}'`), this.logger.error(h4); } - }, this.getPayloadType = (s2) => { - const r2 = ee$1(s2); - return j$1(r2.type); - }, this.getPayloadSenderPublicKey = (s2) => { - const r2 = ee$1(s2); - return r2.senderPublicKey ? toString(r2.senderPublicKey, p$1) : void 0; - }, this.core = e2, this.logger = cjs$3.generateChildLogger(t2, this.name), this.keychain = i2 || new Pt$2(this.core, this.logger); + }, this.getPayloadType = (s22) => { + const r3 = Xi$1(s22); + return Mr(r3.type); + }, this.getPayloadSenderPublicKey = (s22) => { + const r3 = Xi$1(s22); + return r3.senderPublicKey ? toString(r3.senderPublicKey, zt$1) : void 0; + }, this.core = e2, this.logger = E$1(t2, this.name), this.keychain = i2 || new Ot$1(this.core, this.logger); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } async setPrivateKey(e2, t2) { return await this.keychain.set(e2, t2), e2; @@ -10521,25 +14029,25 @@ async getClientSeed() { let e2 = ""; try { - e2 = this.keychain.get(de$1); + e2 = this.keychain.get(ye$1); } catch { - e2 = Vn(), await this.keychain.set(de$1, e2); + e2 = gu(), await this.keychain.set(ye$1, e2); } - return mr$1(e2, "base16"); + return br(e2, "base16"); } getSymKey(e2) { return this.keychain.get(e2); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } }; - let Ot$2 = class Ot extends a$2 { + let zt$2 = class zt extends a$1$1 { constructor(e2, t2) { - super(e2, t2), this.logger = e2, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = rt$2, this.version = nt$1, this.initialized = false, this.storagePrefix = O, this.init = async () => { + super(e2, t2), this.logger = e2, this.core = t2, this.messages = /* @__PURE__ */ new Map(), this.name = ot$1, this.version = at$1, this.initialized = false, this.storagePrefix = z$1$1, this.init = async () => { if (!this.initialized) { this.logger.trace("Initialized"); try { @@ -10551,106 +14059,105 @@ this.initialized = true; } } - }, this.set = async (i2, s2) => { + }, this.set = async (i2, s22) => { this.isInitialized(); - const r2 = Ln(s2); + const r3 = yu(s22); let o22 = this.messages.get(i2); - return typeof o22 > "u" && (o22 = {}), typeof o22[r2] < "u" || (o22[r2] = s2, this.messages.set(i2, o22), await this.persist()), r2; + return typeof o22 > "u" && (o22 = {}), typeof o22[r3] < "u" || (o22[r3] = s22, this.messages.set(i2, o22), await this.persist()), r3; }, this.get = (i2) => { this.isInitialized(); - let s2 = this.messages.get(i2); - return typeof s2 > "u" && (s2 = {}), s2; - }, this.has = (i2, s2) => { + let s22 = this.messages.get(i2); + return typeof s22 > "u" && (s22 = {}), s22; + }, this.has = (i2, s22) => { this.isInitialized(); - const r2 = this.get(i2), o22 = Ln(s2); - return typeof r2[o22] < "u"; + const r3 = this.get(i2), o22 = yu(s22); + return typeof r3[o22] < "u"; }, this.del = async (i2) => { this.isInitialized(), this.messages.delete(i2), await this.persist(); - }, this.logger = cjs$3.generateChildLogger(e2, this.name), this.core = t2; + }, this.logger = E$1(e2, this.name), this.core = t2; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; } async setRelayerMessages(e2) { - await this.core.storage.setItem(this.storageKey, rt$1(e2)); + await this.core.storage.setItem(this.storageKey, i0(e2)); } async getRelayerMessages() { const e2 = await this.core.storage.getItem(this.storageKey); - return typeof e2 < "u" ? ot$1(e2) : void 0; + return typeof e2 < "u" ? n0(e2) : void 0; } async persist() { await this.setRelayerMessages(this.messages); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } }; - class vr extends u$1$1 { + class Ir extends u$1$1 { constructor(e2, t2) { - super(e2, t2), this.relayer = e2, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = at$2, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$4.toMiliseconds(cjs$4.TEN_SECONDS * 2), this.needsTransportRestart = false, this.publish = async (i2, s2, r2) => { + super(e2, t2), this.relayer = e2, this.logger = t2, this.events = new eventsExports.EventEmitter(), this.name = ct$1, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.failedPublishTimeout = cjs$3.toMiliseconds(cjs$3.ONE_SECOND), this.needsTransportRestart = false, this.publish = async (i2, s22, r3) => { var o22; - this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); + this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s22, opts: r3 } }); + const a3 = (r3 == null ? void 0 : r3.ttl) || ht$1, h4 = Su(r3), l2 = (r3 == null ? void 0 : r3.prompt) || false, d5 = (r3 == null ? void 0 : r3.tag) || 0, g3 = (r3 == null ? void 0 : r3.id) || getBigIntRpcId().toString(), m3 = { topic: i2, message: s22, opts: { ttl: a3, relay: h4, prompt: l2, tag: d5, id: g3 } }, L4 = `Failed to publish payload, please try again. id:${g3} tag:${d5}`, u3 = Date.now(); + let p2, _3 = 1; try { - const a3 = (r2 == null ? void 0 : r2.ttl) || ot$2, h4 = vt$1(r2), l2 = (r2 == null ? void 0 : r2.prompt) || false, d3 = (r2 == null ? void 0 : r2.tag) || 0, p3 = (r2 == null ? void 0 : r2.id) || getBigIntRpcId().toString(), y3 = { topic: i2, message: s2, opts: { ttl: a3, relay: h4, prompt: l2, tag: d3, id: p3 } }, M2 = setTimeout(() => this.queue.set(p3, y3), this.publishTimeout); - try { - await await ut$1(this.rpcPublish(i2, s2, a3, h4, l2, d3, p3), this.publishTimeout, `Failed to publish payload, please try again. id:${p3} tag:${d3}`), this.removeRequestFromQueue(p3), this.relayer.events.emit(D$1$1.publish, y3); - } catch (u3) { - if (this.logger.debug("Publishing Payload stalled"), this.needsTransportRestart = true, (o22 = r2 == null ? void 0 : r2.internal) != null && o22.throwOnFailedPublish) - throw this.removeRequestFromQueue(p3), u3; - return; - } finally { - clearTimeout(M2); - } - this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: i2, message: s2, opts: r2 } }); - } catch (a3) { - throw this.logger.debug("Failed to Publish Payload"), this.logger.error(a3), a3; - } - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.relayer = e2, this.logger = cjs$3.generateChildLogger(t2, this.name), this.registerEventListeners(); + for (; p2 === void 0; ) { + if (Date.now() - u3 > this.publishTimeout) + throw new Error(L4); + this.logger.trace({ id: g3, attempts: _3 }, `publisher.publish - attempt ${_3}`), p2 = await await u0(this.rpcPublish(i2, s22, a3, h4, l2, d5, g3).catch((D2) => this.logger.warn(D2)), this.publishTimeout, L4), _3++, p2 || await new Promise((D2) => setTimeout(D2, this.failedPublishTimeout)); + } + this.relayer.events.emit(v2.publish, m3), this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { id: g3, topic: i2, message: s22, opts: r3 } }); + } catch (D2) { + if (this.logger.debug("Failed to Publish Payload"), this.logger.error(D2), (o22 = r3 == null ? void 0 : r3.internal) != null && o22.throwOnFailedPublish) + throw D2; + this.queue.set(g3, m3); + } + }, this.on = (i2, s22) => { + this.events.on(i2, s22); + }, this.once = (i2, s22) => { + this.events.once(i2, s22); + }, this.off = (i2, s22) => { + this.events.off(i2, s22); + }, this.removeListener = (i2, s22) => { + this.events.removeListener(i2, s22); + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.registerEventListeners(); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } - rpcPublish(e2, t2, i2, s2, r2, o22, a3) { - var h4, l2, d3, p3; - const y3 = { method: Et$1(s2.protocol).publish, params: { topic: e2, message: t2, ttl: i2, prompt: r2, tag: o22 }, id: a3 }; - return w$3((h4 = y3.params) == null ? void 0 : h4.prompt) && ((l2 = y3.params) == null || delete l2.prompt), w$3((d3 = y3.params) == null ? void 0 : d3.tag) && ((p3 = y3.params) == null || delete p3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: y3 }), this.relayer.request(y3); + rpcPublish(e2, t2, i2, s22, r3, o22, a3) { + var h4, l2, d5, g3; + const m3 = { method: Nu(s22.protocol).publish, params: { topic: e2, message: t2, ttl: i2, prompt: r3, tag: o22 }, id: a3 }; + return Pe$1((h4 = m3.params) == null ? void 0 : h4.prompt) && ((l2 = m3.params) == null || delete l2.prompt), Pe$1((d5 = m3.params) == null ? void 0 : d5.tag) && ((g3 = m3.params) == null || delete g3.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: m3 }), this.relayer.request(m3); } removeRequestFromQueue(e2) { this.queue.delete(e2); } checkQueue() { this.queue.forEach(async (e2) => { - const { topic: t2, message: i2, opts: s2 } = e2; - await this.publish(t2, i2, s2); + const { topic: t2, message: i2, opts: s22 } = e2; + await this.publish(t2, i2, s22); }); } registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { if (this.needsTransportRestart) { - this.needsTransportRestart = false, this.relayer.events.emit(D$1$1.connection_stalled); + this.needsTransportRestart = false, this.relayer.events.emit(v2.connection_stalled); return; } this.checkQueue(); - }), this.relayer.on(D$1$1.message_ack, (e2) => { + }), this.relayer.on(v2.message_ack, (e2) => { this.removeRequestFromQueue(e2.id.toString()); }); } } - class Ir { + let Cr$1 = class Cr { constructor() { this.map = /* @__PURE__ */ new Map(), this.set = (e2, t2) => { const i2 = this.get(e2); @@ -10665,12 +14172,12 @@ const i2 = this.get(e2); if (!this.exists(e2, t2)) return; - const s2 = i2.filter((r2) => r2 !== t2); - if (!s2.length) { + const s22 = i2.filter((r3) => r3 !== t2); + if (!s22.length) { this.map.delete(e2); return; } - this.map.set(e2, s2); + this.map.set(e2, s22); }, this.clear = () => { this.map.clear(); }; @@ -10678,56 +14185,60 @@ get topics() { return Array.from(this.map.keys()); } - } - var Cr = Object.defineProperty, Rr = Object.defineProperties, _r = Object.getOwnPropertyDescriptors, At$1 = Object.getOwnPropertySymbols, Tr = Object.prototype.hasOwnProperty, Sr = Object.prototype.propertyIsEnumerable, zt$2 = (n3, e2, t2) => e2 in n3 ? Cr(n3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e2] = t2, q$1 = (n3, e2) => { + }; + var _r = Object.defineProperty, Rr$1 = Object.defineProperties, Tr$1 = Object.getOwnPropertyDescriptors, Nt$1 = Object.getOwnPropertySymbols, Sr = Object.prototype.hasOwnProperty, Pr$1 = Object.prototype.propertyIsEnumerable, Lt$1 = (n4, e2, t2) => e2 in n4 ? _r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, q$2 = (n4, e2) => { for (var t2 in e2 || (e2 = {})) - Tr.call(e2, t2) && zt$2(n3, t2, e2[t2]); - if (At$1) - for (var t2 of At$1(e2)) - Sr.call(e2, t2) && zt$2(n3, t2, e2[t2]); - return n3; - }, De$2 = (n3, e2) => Rr(n3, _r(e2)); - let Nt$2 = class Nt extends d2 { + Sr.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + if (Nt$1) + for (var t2 of Nt$1(e2)) + Pr$1.call(e2, t2) && Lt$1(n4, t2, e2[t2]); + return n4; + }, fe$1 = (n4, e2) => Rr$1(n4, Tr$1(e2)); + let Ut$1 = class Ut2 extends d$1$1 { constructor(e2, t2) { - super(e2, t2), this.relayer = e2, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Ir(), this.events = new eventsExports.EventEmitter(), this.name = mt$2, this.version = bt$2, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = O, this.subscribeTimeout = 1e4, this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { + super(e2, t2), this.relayer = e2, this.logger = t2, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Cr$1(), this.events = new eventsExports.EventEmitter(), this.name = ft, this.version = Et$1, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = false, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = z$1$1, this.subscribeTimeout = cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), this.restartInProgress = false, this.batchSubscribeTopicsLimit = 500, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), this.registerEventListeners(), this.clientId = await this.relayer.core.crypto.getClientId()); - }, this.subscribe = async (i2, s2) => { - await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }); + }, this.subscribe = async (i2, s22) => { + await this.restartToComplete(), this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s22 } }); try { - const r2 = vt$1(s2), o22 = { topic: i2, relay: r2 }; + const r3 = Su(s22), o22 = { topic: i2, relay: r3 }; this.pending.set(i2, o22); - const a3 = await this.rpcSubscribe(i2, r2); - return this.onSubscribe(a3, o22), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s2 } }), a3; - } catch (r2) { - throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r2), r2; + const a3 = await this.rpcSubscribe(i2, r3); + return typeof a3 == "string" && (this.onSubscribe(a3, o22), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: i2, opts: s22 } })), a3; + } catch (r3) { + throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(r3), r3; } - }, this.unsubscribe = async (i2, s2) => { - await this.restartToComplete(), this.isInitialized(), typeof (s2 == null ? void 0 : s2.id) < "u" ? await this.unsubscribeById(i2, s2.id, s2) : await this.unsubscribeByTopic(i2, s2); + }, this.unsubscribe = async (i2, s22) => { + await this.restartToComplete(), this.isInitialized(), typeof (s22 == null ? void 0 : s22.id) < "u" ? await this.unsubscribeById(i2, s22.id, s22) : await this.unsubscribeByTopic(i2, s22); }, this.isSubscribed = async (i2) => { if (this.topics.includes(i2)) return true; - const s2 = `${this.pendingSubscriptionWatchLabel}_${i2}`; - return await new Promise((r2, o22) => { - const a3 = new cjs$4.Watch(); - a3.start(s2); + const s22 = `${this.pendingSubscriptionWatchLabel}_${i2}`; + return await new Promise((r3, o22) => { + const a3 = new cjs$3.Watch(); + a3.start(s22); const h4 = setInterval(() => { - !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s2), r2(true)), a3.elapsed(s2) >= ft$2 && (clearInterval(h4), a3.stop(s2), o22(new Error("Subscription resolution timeout"))); + !this.pending.has(i2) && this.topics.includes(i2) && (clearInterval(h4), a3.stop(s22), r3(true)), a3.elapsed(s22) >= wt && (clearInterval(h4), a3.stop(s22), o22(new Error("Subscription resolution timeout"))); }, this.pollingInterval); }).catch(() => false); - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); + }, this.on = (i2, s22) => { + this.events.on(i2, s22); + }, this.once = (i2, s22) => { + this.events.once(i2, s22); + }, this.off = (i2, s22) => { + this.events.off(i2, s22); + }, this.removeListener = (i2, s22) => { + this.events.removeListener(i2, s22); + }, this.start = async () => { + await this.onConnect(); + }, this.stop = async () => { + await this.onDisconnect(); }, this.restart = async () => { this.restartInProgress = true, await this.restore(), await this.reset(), this.restartInProgress = false; - }, this.relayer = e2, this.logger = cjs$3.generateChildLogger(t2, this.name), this.clientId = ""; + }, this.relayer = e2, this.logger = E$1(t2, this.name), this.clientId = ""; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.relayer.core.customStoragePrefix + "//" + this.name; @@ -10760,50 +14271,50 @@ } async unsubscribeByTopic(e2, t2) { const i2 = this.topicMap.get(e2); - await Promise.all(i2.map(async (s2) => await this.unsubscribeById(e2, s2, t2))); + await Promise.all(i2.map(async (s22) => await this.unsubscribeById(e2, s22, t2))); } async unsubscribeById(e2, t2, i2) { this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); try { - const s2 = vt$1(i2); - await this.rpcUnsubscribe(e2, t2, s2); - const r2 = U$2("USER_DISCONNECTED", `${this.name}, ${e2}`); - await this.onUnsubscribe(e2, t2, r2), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); - } catch (s2) { - throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s2), s2; + const s22 = Su(i2); + await this.rpcUnsubscribe(e2, t2, s22); + const r3 = tr$2("USER_DISCONNECTED", `${this.name}, ${e2}`); + await this.onUnsubscribe(e2, t2, r3), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e2, id: t2, opts: i2 } }); + } catch (s22) { + throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(s22), s22; } } async rpcSubscribe(e2, t2) { - const i2 = { method: Et$1(t2.protocol).subscribe, params: { topic: e2 } }; + const i2 = { method: Nu(t2.protocol).subscribe, params: { topic: e2 } }; this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); try { - await await ut$1(this.relayer.request(i2), this.subscribeTimeout); + return await await u0(this.relayer.request(i2).catch((s22) => this.logger.warn(s22)), this.subscribeTimeout) ? yu(e2 + this.clientId) : null; } catch { - this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(D$1$1.connection_stalled); + this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(v2.connection_stalled); } - return Ln(e2 + this.clientId); + return null; } async rpcBatchSubscribe(e2) { if (!e2.length) return; - const t2 = e2[0].relay, i2 = { method: Et$1(t2.protocol).batchSubscribe, params: { topics: e2.map((s2) => s2.topic) } }; + const t2 = e2[0].relay, i2 = { method: Nu(t2.protocol).batchSubscribe, params: { topics: e2.map((s22) => s22.topic) } }; this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i2 }); try { - return await await ut$1(this.relayer.request(i2), this.subscribeTimeout); + return await await u0(this.relayer.request(i2).catch((s22) => this.logger.warn(s22)), this.subscribeTimeout); } catch { - this.logger.debug("Outgoing Relay Payload stalled"), this.relayer.events.emit(D$1$1.connection_stalled); + this.relayer.events.emit(v2.connection_stalled); } } rpcUnsubscribe(e2, t2, i2) { - const s2 = { method: Et$1(i2.protocol).unsubscribe, params: { topic: e2, id: t2 } }; - return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s2 }), this.relayer.request(s2); + const s22 = { method: Nu(i2.protocol).unsubscribe, params: { topic: e2, id: t2 } }; + return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s22 }), this.relayer.request(s22); } onSubscribe(e2, t2) { - this.setSubscription(e2, De$2(q$1({}, t2), { id: e2 })), this.pending.delete(t2.topic); + this.setSubscription(e2, fe$1(q$2({}, t2), { id: e2 })), this.pending.delete(t2.topic); } onBatchSubscribe(e2) { e2.length && e2.forEach((t2) => { - this.setSubscription(t2.id, q$1({}, t2)), this.pending.delete(t2.topic); + this.setSubscription(t2.id, q$2({}, t2)), this.pending.delete(t2.topic); }); } async onUnsubscribe(e2, t2, i2) { @@ -10816,16 +14327,16 @@ return await this.relayer.core.storage.getItem(this.storageKey); } setSubscription(e2, t2) { - this.subscriptions.has(e2) || (this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e2, subscription: t2 }), this.addSubscription(e2, t2)); + this.logger.debug("Setting subscription"), this.logger.trace({ type: "method", method: "setSubscription", id: e2, subscription: t2 }), this.addSubscription(e2, t2); } addSubscription(e2, t2) { - this.subscriptions.set(e2, q$1({}, t2)), this.topicMap.set(t2.topic, e2), this.events.emit(w$1.created, t2); + this.subscriptions.set(e2, q$2({}, t2)), this.topicMap.set(t2.topic, e2), this.events.emit(S$1$1.created, t2); } getSubscription(e2) { this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e2 }); const t2 = this.subscriptions.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); + const { message: i2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw new Error(i2); } return t2; @@ -10833,10 +14344,10 @@ deleteSubscription(e2, t2) { this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e2, reason: t2 }); const i2 = this.getSubscription(e2); - this.subscriptions.delete(e2), this.topicMap.delete(i2.topic, e2), this.events.emit(w$1.deleted, De$2(q$1({}, i2), { reason: t2 })); + this.subscriptions.delete(e2), this.topicMap.delete(i2.topic, e2), this.events.emit(S$1$1.deleted, fe$1(q$2({}, i2), { reason: t2 })); } async persist() { - await this.setRelayerSubscriptions(this.values), this.events.emit(w$1.sync); + await this.setRelayerSubscriptions(this.values), this.events.emit(S$1$1.sync); } async reset() { if (this.cached.length) { @@ -10846,7 +14357,7 @@ await this.batchSubscribe(i2); } } - this.events.emit(w$1.resubscribed); + this.events.emit(S$1$1.resubscribed); } async restore() { try { @@ -10854,7 +14365,7 @@ if (typeof e2 > "u" || !e2.length) return; if (this.subscriptions.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe$1("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`), new Error(t2); } this.cached = e2, this.logger.debug(`Successfully Restored subscriptions for ${this.name}`), this.logger.trace({ type: "method", method: "restore", subscriptions: this.values }); @@ -10866,16 +14377,16 @@ if (!e2.length) return; const t2 = await this.rpcBatchSubscribe(e2); - k$3(t2) && this.onBatchSubscribe(t2.map((i2, s2) => De$2(q$1({}, e2[s2]), { id: i2 }))); + Er(t2) && this.onBatchSubscribe(t2.map((i2, s22) => fe$1(q$2({}, e2[s22]), { id: i2 }))); } async onConnect() { - this.restartInProgress || (await this.restart(), this.onEnable()); + await this.restart(), this.onEnable(); } onDisconnect() { this.onDisable(); } async checkPending() { - if (!this.initialized || this.relayer.transportExplicitlyClosed) + if (!this.initialized || !this.relayer.connected) return; const e2 = []; this.pending.forEach((t2) => { @@ -10883,23 +14394,19 @@ }), await this.batchSubscribe(e2); } registerEventListeners() { - this.relayer.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, async () => { + this.relayer.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, async () => { await this.checkPending(); - }), this.relayer.on(D$1$1.connect, async () => { - await this.onConnect(); - }), this.relayer.on(D$1$1.disconnect, () => { - this.onDisconnect(); - }), this.events.on(w$1.created, async (e2) => { - const t2 = w$1.created; + }), this.events.on(S$1$1.created, async (e2) => { + const t2 = S$1$1.created; this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); - }), this.events.on(w$1.deleted, async (e2) => { - const t2 = w$1.deleted; + }), this.events.on(S$1$1.deleted, async (e2) => { + const t2 = S$1$1.deleted; this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), await this.persist(); }); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } @@ -10911,59 +14418,81 @@ }); } }; - var Pr = Object.defineProperty, Ut$1 = Object.getOwnPropertySymbols, xr = Object.prototype.hasOwnProperty, Or = Object.prototype.propertyIsEnumerable, Lt$2 = (n3, e2, t2) => e2 in n3 ? Pr(n3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e2] = t2, Ar = (n3, e2) => { + var xr$1 = Object.defineProperty, $t$1 = Object.getOwnPropertySymbols, Or$1 = Object.prototype.hasOwnProperty, Ar = Object.prototype.propertyIsEnumerable, Ft$1 = (n4, e2, t2) => e2 in n4 ? xr$1(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, zr$1 = (n4, e2) => { for (var t2 in e2 || (e2 = {})) - xr.call(e2, t2) && Lt$2(n3, t2, e2[t2]); - if (Ut$1) - for (var t2 of Ut$1(e2)) - Or.call(e2, t2) && Lt$2(n3, t2, e2[t2]); - return n3; + Or$1.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + if ($t$1) + for (var t2 of $t$1(e2)) + Ar.call(e2, t2) && Ft$1(n4, t2, e2[t2]); + return n4; }; - let $t$1 = class $t extends g$4 { + let kt$1 = class kt extends g$1 { constructor(e2) { - super(e2), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = ut$2, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.request = async (t2) => { + super(e2), this.protocol = "wc", this.version = 2, this.events = new eventsExports.EventEmitter(), this.name = dt$1, this.transportExplicitlyClosed = false, this.initialized = false, this.connectionAttemptInProgress = false, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "socket stalled", "interrupted"], this.hasExperiencedNetworkDisruption = false, this.requestsInFlight = /* @__PURE__ */ new Map(), this.heartBeatTimeout = cjs$3.toMiliseconds(cjs$3.THIRTY_SECONDS + cjs$3.ONE_SECOND), this.request = async (t2) => { + var i2, s22; this.logger.debug("Publishing Request Payload"); - const i2 = t2.id; + const r3 = t2.id || getBigIntRpcId().toString(); + await this.toEstablishConnection(); try { - await this.toEstablishConnection(); - const s2 = this.provider.request(t2); - return this.requestsInFlight.set(i2, { promise: s2, request: t2 }), await s2; - } catch (s2) { - throw this.logger.debug("Failed to Publish Request"), this.logger.error(s2), s2; + const o22 = this.provider.request(t2); + this.requestsInFlight.set(r3, { promise: o22, request: t2 }), this.logger.trace({ id: r3, method: t2.method, topic: (i2 = t2.params) == null ? void 0 : i2.topic }, "relayer.request - attempt to publish..."); + const a3 = await new Promise(async (h4, l2) => { + const d5 = () => { + l2(new Error(`relayer.request - publish interrupted, id: ${r3}`)); + }; + this.provider.on(f$1.disconnect, d5); + const g3 = await o22; + this.provider.off(f$1.disconnect, d5), h4(g3); + }); + return this.logger.trace({ id: r3, method: t2.method, topic: (s22 = t2.params) == null ? void 0 : s22.topic }, "relayer.request - published"), a3; + } catch (o22) { + throw this.logger.debug(`Failed to Publish Request: ${r3}`), o22; } finally { - this.requestsInFlight.delete(i2); + this.requestsInFlight.delete(r3); } + }, this.resetPingTimeout = () => { + if (pi()) + try { + clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => { + var t2, i2, s22; + (s22 = (i2 = (t2 = this.provider) == null ? void 0 : t2.connection) == null ? void 0 : i2.socket) == null || s22.terminate(); + }, this.heartBeatTimeout); + } catch (t2) { + this.logger.warn(t2); + } }, this.onPayloadHandler = (t2) => { - this.onProviderPayload(t2); + this.onProviderPayload(t2), this.resetPingTimeout(); }, this.onConnectHandler = () => { - this.events.emit(D$1$1.connect); + this.startPingTimeout(), this.events.emit(v2.connect); }, this.onDisconnectHandler = () => { this.onProviderDisconnect(); }, this.onProviderErrorHandler = (t2) => { - this.logger.error(t2), this.events.emit(D$1$1.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); + this.logger.error(t2), this.events.emit(v2.error, t2), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); }, this.registerProviderListeners = () => { - this.provider.on(P$1.payload, this.onPayloadHandler), this.provider.on(P$1.connect, this.onConnectHandler), this.provider.on(P$1.disconnect, this.onDisconnectHandler), this.provider.on(P$1.error, this.onProviderErrorHandler); - }, this.core = e2.core, this.logger = typeof e2.logger < "u" && typeof e2.logger != "string" ? cjs$3.generateChildLogger(e2.logger, this.name) : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: e2.logger || ct$1 })), this.messages = new Ot$2(this.logger, e2.core), this.subscriber = new Nt$2(this, this.logger), this.publisher = new vr(this, this.logger), this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || ge$1, this.projectId = e2.projectId, this.bundleId = Jn(), this.provider = {}; + this.provider.on(f$1.payload, this.onPayloadHandler), this.provider.on(f$1.connect, this.onConnectHandler), this.provider.on(f$1.disconnect, this.onDisconnectHandler), this.provider.on(f$1.error, this.onProviderErrorHandler); + }, this.core = e2.core, this.logger = typeof e2.logger < "u" && typeof e2.logger != "string" ? E$1(e2.logger, this.name) : nt$1(k$2({ level: e2.logger || ut$1 })), this.messages = new zt$2(this.logger, e2.core), this.subscriber = new Ut$1(this, this.logger), this.publisher = new Ir(this, this.logger), this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me$2, this.projectId = e2.projectId, this.bundleId = Wo$1(), this.provider = {}; } async init() { this.logger.trace("Initialized"), this.registerEventListeners(), await this.createProvider(), await Promise.all([this.messages.init(), this.subscriber.init()]); try { await this.transportOpen(); } catch { - this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$1}...`), await this.restartTransport(pe$1); + this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${be$1}...`), await this.restartTransport(be$1); } this.initialized = true, setTimeout(async () => { - this.subscriber.topics.length === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); - }, pt$2); + this.subscriber.topics.length === 0 && this.subscriber.pending.size === 0 && (this.logger.info("No topics subscribed to after init, closing transport"), await this.transportClose(), this.transportExplicitlyClosed = false); + }, yt$1); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get connected() { - return this.provider.connection.connected; + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 1; } get connecting() { - return this.provider.connection.connecting; + var e2, t2, i2; + return ((i2 = (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) == null ? void 0 : t2.socket) == null ? void 0 : i2.readyState) === 0; } async publish(e2, t2, i2) { this.isInitialized(), await this.publisher.publish(e2, t2, i2), await this.recordMessageEvent({ topic: e2, message: t2, publishedAt: Date.now() }); @@ -10971,18 +14500,15 @@ async subscribe(e2, t2) { var i2; this.isInitialized(); - let s2 = ((i2 = this.subscriber.topicMap.get(e2)) == null ? void 0 : i2[0]) || ""; - if (s2) - return s2; - let r2; + let s22 = ((i2 = this.subscriber.topicMap.get(e2)) == null ? void 0 : i2[0]) || "", r3; const o22 = (a3) => { - a3.topic === e2 && (this.subscriber.off(w$1.created, o22), r2()); + a3.topic === e2 && (this.subscriber.off(S$1$1.created, o22), r3()); }; return await Promise.all([new Promise((a3) => { - r2 = a3, this.subscriber.on(w$1.created, o22); + r3 = a3, this.subscriber.on(S$1$1.created, o22); }), new Promise(async (a3) => { - s2 = await this.subscriber.subscribe(e2, t2), a3(); - })]), s2; + s22 = await this.subscriber.subscribe(e2, t2) || s22, a3(); + })]), s22; } async unsubscribe(e2, t2) { this.isInitialized(), await this.subscriber.unsubscribe(e2, t2); @@ -10999,55 +14525,63 @@ removeListener(e2, t2) { this.events.removeListener(e2, t2); } + async transportDisconnect() { + if (!this.hasExperiencedNetworkDisruption && this.connected && this.requestsInFlight.size > 0) + try { + await Promise.all(Array.from(this.requestsInFlight.values()).map((e2) => e2.promise)); + } catch (e2) { + this.logger.warn(e2); + } + this.hasExperiencedNetworkDisruption || this.connected ? await u0(this.provider.disconnect(), 2e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.onProviderDisconnect(); + } async transportClose() { - this.requestsInFlight.size > 0 && (this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."), this.requestsInFlight.forEach(async (e2) => { - await e2.promise; - })), this.transportExplicitlyClosed = true, this.hasExperiencedNetworkDisruption && this.connected ? await ut$1(this.provider.disconnect(), 1e3, "provider.disconnect()").catch(() => this.onProviderDisconnect()) : this.connected && await this.provider.disconnect(); + this.transportExplicitlyClosed = true, await this.transportDisconnect(); } async transportOpen(e2) { - if (this.transportExplicitlyClosed = false, await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress) { - e2 && e2 !== this.relayUrl && (this.relayUrl = e2, await this.transportClose(), await this.createProvider()), this.connectionAttemptInProgress = true; - try { - await Promise.all([new Promise((t2) => { - if (!this.initialized) - return t2(); - this.subscriber.once(w$1.resubscribed, () => { - t2(); - }); - }), new Promise(async (t2, i2) => { - try { - await ut$1(this.provider.connect(), 1e4, `Socket stalled when trying to connect to ${this.relayUrl}`); - } catch (s2) { - i2(s2); - return; - } - t2(); - })]); - } catch (t2) { - this.logger.error(t2); - const i2 = t2; - if (!this.isConnectionStalled(i2.message)) - throw t2; - this.provider.events.emit(P$1.disconnect); - } finally { - this.connectionAttemptInProgress = false, this.hasExperiencedNetworkDisruption = false; - } + await this.confirmOnlineStateOrThrow(), e2 && e2 !== this.relayUrl && (this.relayUrl = e2, await this.transportDisconnect(), await this.createProvider()), this.connectionAttemptInProgress = true, this.transportExplicitlyClosed = false; + try { + await new Promise(async (t2, i2) => { + const s22 = () => { + this.provider.off(f$1.disconnect, s22), i2(new Error("Connection interrupted while trying to subscribe")); + }; + this.provider.on(f$1.disconnect, s22), await u0(this.provider.connect(), cjs$3.toMiliseconds(cjs$3.ONE_MINUTE), `Socket stalled when trying to connect to ${this.relayUrl}`).catch((r3) => { + i2(r3); + }), await this.subscriber.start(), this.hasExperiencedNetworkDisruption = false, t2(); + }); + } catch (t2) { + this.logger.error(t2); + const i2 = t2; + if (!this.isConnectionStalled(i2.message)) + throw t2; + } finally { + this.connectionAttemptInProgress = false; } } async restartTransport(e2) { - await this.confirmOnlineStateOrThrow(), !this.connectionAttemptInProgress && (this.relayUrl = e2 || this.relayUrl, await this.transportClose(), await this.createProvider(), await this.transportOpen()); + this.connectionAttemptInProgress || (this.relayUrl = e2 || this.relayUrl, await this.confirmOnlineStateOrThrow(), await this.transportClose(), await this.createProvider(), await this.transportOpen()); } async confirmOnlineStateOrThrow() { - if (!await rr$1()) + if (!await hh()) throw new Error("No internet connection detected. Please restart your network and try again."); } + startPingTimeout() { + var e2, t2, i2, s22, r3; + if (pi()) + try { + (t2 = (e2 = this.provider) == null ? void 0 : e2.connection) != null && t2.socket && ((r3 = (s22 = (i2 = this.provider) == null ? void 0 : i2.connection) == null ? void 0 : s22.socket) == null || r3.once("ping", () => { + this.resetPingTimeout(); + })), this.resetPingTimeout(); + } catch (o22) { + this.logger.warn(o22); + } + } isConnectionStalled(e2) { return this.staleConnectionErrors.some((t2) => e2.includes(t2)); } async createProvider() { this.provider.connection && this.unregisterProviderListeners(); const e2 = await this.core.crypto.signJWT(this.relayUrl); - this.provider = new JsonRpcProvider(new f$1(Xn({ sdkVersion: gt$2, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e2, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); + this.provider = new JsonRpcProvider(new f$2($o({ sdkVersion: Dt$1, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e2, useOnCloseEvent: true, bundleId: this.bundleId }))), this.registerProviderListeners(); } async recordMessageEvent(e2) { const { topic: t2, message: i2 } = e2; @@ -11059,89 +14593,79 @@ return this.logger.debug(`Ignoring invalid/empty message: ${i2}`), true; if (!await this.subscriber.isSubscribed(t2)) return this.logger.debug(`Ignoring message for non-subscribed topic ${t2}`), true; - const s2 = this.messages.has(t2, i2); - return s2 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s2; + const s22 = this.messages.has(t2, i2); + return s22 && this.logger.debug(`Ignoring duplicate message: ${i2}`), s22; } async onProviderPayload(e2) { if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e2 }), isJsonRpcRequest(e2)) { - if (!e2.method.endsWith(lt$2)) + if (!e2.method.endsWith(gt)) return; - const t2 = e2.params, { topic: i2, message: s2, publishedAt: r2 } = t2.data, o22 = { topic: i2, message: s2, publishedAt: r2 }; - this.logger.debug("Emitting Relayer Payload"), this.logger.trace(Ar({ type: "event", event: t2.id }, o22)), this.events.emit(t2.id, o22), await this.acknowledgePayload(e2), await this.onMessageEvent(o22); + const t2 = e2.params, { topic: i2, message: s22, publishedAt: r3 } = t2.data, o22 = { topic: i2, message: s22, publishedAt: r3 }; + this.logger.debug("Emitting Relayer Payload"), this.logger.trace(zr$1({ type: "event", event: t2.id }, o22)), this.events.emit(t2.id, o22), await this.acknowledgePayload(e2), await this.onMessageEvent(o22); } else - isJsonRpcResponse(e2) && this.events.emit(D$1$1.message_ack, e2); + isJsonRpcResponse(e2) && this.events.emit(v2.message_ack, e2); } async onMessageEvent(e2) { - await this.shouldIgnoreMessageEvent(e2) || (this.events.emit(D$1$1.message, e2), await this.recordMessageEvent(e2)); + await this.shouldIgnoreMessageEvent(e2) || (this.events.emit(v2.message, e2), await this.recordMessageEvent(e2)); } async acknowledgePayload(e2) { const t2 = formatJsonRpcResult(e2.id, true); await this.provider.connection.send(t2); } unregisterProviderListeners() { - this.provider.off(P$1.payload, this.onPayloadHandler), this.provider.off(P$1.connect, this.onConnectHandler), this.provider.off(P$1.disconnect, this.onDisconnectHandler), this.provider.off(P$1.error, this.onProviderErrorHandler); + this.provider.off(f$1.payload, this.onPayloadHandler), this.provider.off(f$1.connect, this.onConnectHandler), this.provider.off(f$1.disconnect, this.onDisconnectHandler), this.provider.off(f$1.error, this.onProviderErrorHandler); } async registerEventListeners() { - this.events.on(D$1$1.connection_stalled, () => { - this.restartTransport().catch((t2) => this.logger.error(t2)); + let e2 = await hh(); + ch(async (t2) => { + e2 !== t2 && (e2 = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportDisconnect(), this.transportExplicitlyClosed = false)); }); - let e2 = await rr$1(); - or$1(async (t2) => { - this.initialized && e2 !== t2 && (e2 = t2, t2 ? await this.restartTransport().catch((i2) => this.logger.error(i2)) : (this.hasExperiencedNetworkDisruption = true, await this.transportClose().catch((i2) => this.logger.error(i2)))); - }); - } - onProviderDisconnect() { - this.events.emit(D$1$1.disconnect), this.attemptToReconnect(); } - attemptToReconnect() { - this.transportExplicitlyClosed || (this.logger.info("attemptToReconnect called. Connecting..."), setTimeout(async () => { - await this.restartTransport().catch((e2) => this.logger.error(e2)); - }, cjs$4.toMiliseconds(dt$2))); + async onProviderDisconnect() { + await this.subscriber.stop(), this.events.emit(v2.disconnect), this.connectionAttemptInProgress = false, !this.transportExplicitlyClosed && setTimeout(async () => { + await this.transportOpen().catch((e2) => this.logger.error(e2)); + }, cjs$3.toMiliseconds(pt$1)); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } async toEstablishConnection() { - if (await this.confirmOnlineStateOrThrow(), !this.connected) { - if (this.connectionAttemptInProgress) - return await new Promise((e2) => { - const t2 = setInterval(() => { - this.connected && (clearInterval(t2), e2()); - }, this.connectionStatusPollingInterval); - }); - await this.restartTransport(); - } + await this.confirmOnlineStateOrThrow(), !this.connected && (this.connectionAttemptInProgress && await new Promise((e2) => { + const t2 = setInterval(() => { + this.connected && (clearInterval(t2), e2()); + }, this.connectionStatusPollingInterval); + }), await this.transportOpen()); } }; - var zr = Object.defineProperty, Ft$2 = Object.getOwnPropertySymbols, Nr = Object.prototype.hasOwnProperty, Ur = Object.prototype.propertyIsEnumerable, Mt$2 = (n3, e2, t2) => e2 in n3 ? zr(n3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e2] = t2, kt$1 = (n3, e2) => { + var Nr = Object.defineProperty, Bt$1 = Object.getOwnPropertySymbols, Lr = Object.prototype.hasOwnProperty, Ur$1 = Object.prototype.propertyIsEnumerable, Mt$1 = (n4, e2, t2) => e2 in n4 ? Nr(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Kt$1 = (n4, e2) => { for (var t2 in e2 || (e2 = {})) - Nr.call(e2, t2) && Mt$2(n3, t2, e2[t2]); - if (Ft$2) - for (var t2 of Ft$2(e2)) - Ur.call(e2, t2) && Mt$2(n3, t2, e2[t2]); - return n3; - }; - let Kt$2 = class Kt extends p$2 { - constructor(e2, t2, i2, s2 = O, r2 = void 0) { - super(e2, t2, i2, s2), this.core = e2, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = Dt$1, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { + Lr.call(e2, t2) && Mt$1(n4, t2, e2[t2]); + if (Bt$1) + for (var t2 of Bt$1(e2)) + Ur$1.call(e2, t2) && Mt$1(n4, t2, e2[t2]); + return n4; + }; + class Vt extends p$3 { + constructor(e2, t2, i2, s22 = z$1$1, r3 = void 0) { + super(e2, t2, i2, s22), this.core = e2, this.logger = t2, this.name = i2, this.map = /* @__PURE__ */ new Map(), this.version = mt, this.cached = [], this.initialized = false, this.storagePrefix = z$1$1, this.recentlyDeleted = [], this.recentlyDeletedLimit = 200, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((o22) => { - this.getKey && o22 !== null && !w$3(o22) ? this.map.set(this.getKey(o22), o22) : Lt$1(o22) ? this.map.set(o22.id, o22) : xt$1(o22) && this.map.set(o22.topic, o22); + this.getKey && o22 !== null && !Pe$1(o22) ? this.map.set(this.getKey(o22), o22) : Gu(o22) ? this.map.set(o22.id, o22) : Yu(o22) && this.map.set(o22.topic, o22); }), this.cached = [], this.initialized = true); }, this.set = async (o22, a3) => { this.isInitialized(), this.map.has(o22) ? await this.update(o22, a3) : (this.logger.debug("Setting value"), this.logger.trace({ type: "method", method: "set", key: o22, value: a3 }), this.map.set(o22, a3), await this.persist()); - }, this.get = (o22) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o22 }), this.getData(o22)), this.getAll = (o22) => (this.isInitialized(), o22 ? this.values.filter((a3) => Object.keys(o22).every((h4) => Gi(a3[h4], o22[h4]))) : this.values), this.update = async (o22, a3) => { + }, this.get = (o22) => (this.isInitialized(), this.logger.debug("Getting value"), this.logger.trace({ type: "method", method: "get", key: o22 }), this.getData(o22)), this.getAll = (o22) => (this.isInitialized(), o22 ? this.values.filter((a3) => Object.keys(o22).every((h4) => Yi(a3[h4], o22[h4]))) : this.values), this.update = async (o22, a3) => { this.isInitialized(), this.logger.debug("Updating value"), this.logger.trace({ type: "method", method: "update", key: o22, update: a3 }); - const h4 = kt$1(kt$1({}, this.getData(o22)), a3); + const h4 = Kt$1(Kt$1({}, this.getData(o22)), a3); this.map.set(o22, h4), await this.persist(); }, this.delete = async (o22, a3) => { - this.isInitialized(), this.map.has(o22) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o22, reason: a3 }), this.map.delete(o22), await this.persist()); - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.storagePrefix = s2, this.getKey = r2; + this.isInitialized(), this.map.has(o22) && (this.logger.debug("Deleting value"), this.logger.trace({ type: "method", method: "delete", key: o22, reason: a3 }), this.map.delete(o22), this.addToRecentlyDeleted(o22), await this.persist()); + }, this.logger = E$1(t2, this.name), this.storagePrefix = s22, this.getKey = r3; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11155,6 +14679,9 @@ get values() { return Array.from(this.map.values()); } + addToRecentlyDeleted(e2) { + this.recentlyDeleted.push(e2), this.recentlyDeleted.length >= this.recentlyDeletedLimit && this.recentlyDeleted.splice(0, this.recentlyDeletedLimit / 2); + } async setDataStore(e2) { await this.core.storage.setItem(this.storageKey, e2); } @@ -11164,7 +14691,11 @@ getData(e2) { const t2 = this.map.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); + if (this.recentlyDeleted.includes(e2)) { + const { message: s22 } = xe$1("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e2}`); + throw this.logger.error(s22), new Error(s22); + } + const { message: i2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw this.logger.error(i2), new Error(i2); } return t2; @@ -11178,7 +14709,7 @@ if (typeof e2 > "u" || !e2.length) return; if (this.map.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe$1("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } this.cached = e2, this.logger.debug(`Successfully Restored value for ${this.name}`), this.logger.trace({ type: "method", method: "restore", value: this.values }); @@ -11188,229 +14719,229 @@ } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } - }; - let Bt$2 = class Bt { + } + class qt { constructor(e2, t2) { - this.core = e2, this.logger = t2, this.name = Et$2, this.version = wt$2, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = O, this.ignoredPayloadTypes = [_$1$1], this.registeredMethods = [], this.init = async () => { + this.core = e2, this.logger = t2, this.name = vt, this.version = It$1, this.events = new EventEmitter$1(), this.initialized = false, this.storagePrefix = z$1$1, this.ignoredPayloadTypes = [lr$1], this.registeredMethods = [], this.init = async () => { this.initialized || (await this.pairings.init(), await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.initialized = true, this.logger.trace("Initialized")); }, this.register = ({ methods: i2 }) => { this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...i2])]; - }, this.create = async () => { + }, this.create = async (i2) => { this.isInitialized(); - const i2 = Vn(), s2 = await this.core.crypto.setSymKey(i2), r2 = pt$1(cjs$4.FIVE_MINUTES), o22 = { protocol: ht$2 }, a3 = { topic: s2, expiry: r2, relay: o22, active: false }, h4 = Rt$1({ protocol: this.core.protocol, version: this.core.version, topic: s2, symKey: i2, relay: o22, expiryTimestamp: r2 }); - return await this.pairings.set(s2, a3), await this.core.relayer.subscribe(s2), this.core.expirer.set(s2, r2), { topic: s2, uri: h4 }; + const s22 = gu(), r3 = await this.core.crypto.setSymKey(s22), o22 = d0(cjs$3.FIVE_MINUTES), a3 = { protocol: lt$1 }, h4 = { topic: r3, expiry: o22, relay: a3, active: false }, l2 = Du({ protocol: this.core.protocol, version: this.core.version, topic: r3, symKey: s22, relay: a3, expiryTimestamp: o22, methods: i2 == null ? void 0 : i2.methods }); + return await this.pairings.set(r3, h4), await this.core.relayer.subscribe(r3), this.core.expirer.set(r3, o22), { topic: r3, uri: l2 }; }, this.pair = async (i2) => { this.isInitialized(), this.isValidPair(i2); - const { topic: s2, symKey: r2, relay: o22, expiryTimestamp: a3 } = Pt$1(i2.uri); - let h4; - if (this.pairings.keys.includes(s2) && (h4 = this.pairings.get(s2), h4.active)) - throw new Error(`Pairing already exists: ${s2}. Please try again with a new connection URI.`); - const l2 = a3 || pt$1(cjs$4.FIVE_MINUTES), d3 = { topic: s2, relay: o22, expiry: l2, active: false }; - return await this.pairings.set(s2, d3), this.core.expirer.set(s2, l2), i2.activatePairing && await this.activate({ topic: s2 }), this.events.emit(V$3.create, d3), this.core.crypto.keychain.has(s2) || (await this.core.crypto.setSymKey(r2, s2), await this.core.relayer.subscribe(s2, { relay: o22 })), d3; + const { topic: s22, symKey: r3, relay: o22, expiryTimestamp: a3, methods: h4 } = Pu(i2.uri); + let l2; + if (this.pairings.keys.includes(s22) && (l2 = this.pairings.get(s22), l2.active)) + throw new Error(`Pairing already exists: ${s22}. Please try again with a new connection URI.`); + const d5 = a3 || d0(cjs$3.FIVE_MINUTES), g3 = { topic: s22, relay: o22, expiry: d5, active: false, methods: h4 }; + return await this.pairings.set(s22, g3), this.core.expirer.set(s22, d5), i2.activatePairing && await this.activate({ topic: s22 }), this.events.emit(V$1.create, g3), this.core.crypto.keychain.has(s22) || await this.core.crypto.setSymKey(r3, s22), await this.core.relayer.subscribe(s22, { relay: o22 }), g3; }, this.activate = async ({ topic: i2 }) => { this.isInitialized(); - const s2 = pt$1(cjs$4.THIRTY_DAYS); - await this.pairings.update(i2, { active: true, expiry: s2 }), this.core.expirer.set(i2, s2); + const s22 = d0(cjs$3.THIRTY_DAYS); + await this.pairings.update(i2, { active: true, expiry: s22 }), this.core.expirer.set(i2, s22); }, this.ping = async (i2) => { this.isInitialized(), await this.isValidPing(i2); - const { topic: s2 } = i2; - if (this.pairings.keys.includes(s2)) { - const r2 = await this.sendRequest(s2, "wc_pairingPing", {}), { done: o22, resolve: a3, reject: h4 } = at$1(); - this.events.once(yt$1("pairing_ping", r2), ({ error: l2 }) => { + const { topic: s22 } = i2; + if (this.pairings.keys.includes(s22)) { + const r3 = await this.sendRequest(s22, "wc_pairingPing", {}), { done: o22, resolve: a3, reject: h4 } = a0(); + this.events.once(v0("pairing_ping", r3), ({ error: l2 }) => { l2 ? h4(l2) : a3(); }), await o22(); } - }, this.updateExpiry = async ({ topic: i2, expiry: s2 }) => { - this.isInitialized(), await this.pairings.update(i2, { expiry: s2 }); - }, this.updateMetadata = async ({ topic: i2, metadata: s2 }) => { - this.isInitialized(), await this.pairings.update(i2, { peerMetadata: s2 }); + }, this.updateExpiry = async ({ topic: i2, expiry: s22 }) => { + this.isInitialized(), await this.pairings.update(i2, { expiry: s22 }); + }, this.updateMetadata = async ({ topic: i2, metadata: s22 }) => { + this.isInitialized(), await this.pairings.update(i2, { peerMetadata: s22 }); }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (i2) => { this.isInitialized(), await this.isValidDisconnect(i2); - const { topic: s2 } = i2; - this.pairings.keys.includes(s2) && (await this.sendRequest(s2, "wc_pairingDelete", U$2("USER_DISCONNECTED")), await this.deletePairing(s2)); - }, this.sendRequest = async (i2, s2, r2) => { - const o22 = formatJsonRpcRequest(s2, r2), a3 = await this.core.crypto.encode(i2, o22), h4 = $$3[s2].req; + const { topic: s22 } = i2; + this.pairings.keys.includes(s22) && (await this.sendRequest(s22, "wc_pairingDelete", tr$2("USER_DISCONNECTED")), await this.deletePairing(s22)); + }, this.sendRequest = async (i2, s22, r3) => { + const o22 = formatJsonRpcRequest(s22, r3), a3 = await this.core.crypto.encode(i2, o22), h4 = F$1[s22].req; return this.core.history.set(i2, o22), this.core.relayer.publish(i2, a3, h4), o22.id; - }, this.sendResult = async (i2, s2, r2) => { - const o22 = formatJsonRpcResult(i2, r2), a3 = await this.core.crypto.encode(s2, o22), h4 = await this.core.history.get(s2, i2), l2 = $$3[h4.request.method].res; - await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o22); - }, this.sendError = async (i2, s2, r2) => { - const o22 = formatJsonRpcError(i2, r2), a3 = await this.core.crypto.encode(s2, o22), h4 = await this.core.history.get(s2, i2), l2 = $$3[h4.request.method] ? $$3[h4.request.method].res : $$3.unregistered_method.res; - await this.core.relayer.publish(s2, a3, l2), await this.core.history.resolve(o22); - }, this.deletePairing = async (i2, s2) => { - await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, U$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s2 ? Promise.resolve() : this.core.expirer.del(i2)]); + }, this.sendResult = async (i2, s22, r3) => { + const o22 = formatJsonRpcResult(i2, r3), a3 = await this.core.crypto.encode(s22, o22), h4 = await this.core.history.get(s22, i2), l2 = F$1[h4.request.method].res; + await this.core.relayer.publish(s22, a3, l2), await this.core.history.resolve(o22); + }, this.sendError = async (i2, s22, r3) => { + const o22 = formatJsonRpcError(i2, r3), a3 = await this.core.crypto.encode(s22, o22), h4 = await this.core.history.get(s22, i2), l2 = F$1[h4.request.method] ? F$1[h4.request.method].res : F$1.unregistered_method.res; + await this.core.relayer.publish(s22, a3, l2), await this.core.history.resolve(o22); + }, this.deletePairing = async (i2, s22) => { + await this.core.relayer.unsubscribe(i2), await Promise.all([this.pairings.delete(i2, tr$2("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(i2), s22 ? Promise.resolve() : this.core.expirer.del(i2)]); }, this.cleanup = async () => { - const i2 = this.pairings.getAll().filter((s2) => mt$1(s2.expiry)); - await Promise.all(i2.map((s2) => this.deletePairing(s2.topic))); + const i2 = this.pairings.getAll().filter((s22) => p0(s22.expiry)); + await Promise.all(i2.map((s22) => this.deletePairing(s22.topic))); }, this.onRelayEventRequest = (i2) => { - const { topic: s2, payload: r2 } = i2; - switch (r2.method) { + const { topic: s22, payload: r3 } = i2; + switch (r3.method) { case "wc_pairingPing": - return this.onPairingPingRequest(s2, r2); + return this.onPairingPingRequest(s22, r3); case "wc_pairingDelete": - return this.onPairingDeleteRequest(s2, r2); + return this.onPairingDeleteRequest(s22, r3); default: - return this.onUnknownRpcMethodRequest(s2, r2); + return this.onUnknownRpcMethodRequest(s22, r3); } }, this.onRelayEventResponse = async (i2) => { - const { topic: s2, payload: r2 } = i2, o22 = (await this.core.history.get(s2, r2.id)).request.method; + const { topic: s22, payload: r3 } = i2, o22 = (await this.core.history.get(s22, r3.id)).request.method; switch (o22) { case "wc_pairingPing": - return this.onPairingPingResponse(s2, r2); + return this.onPairingPingResponse(s22, r3); default: return this.onUnknownRpcMethodResponse(o22); } - }, this.onPairingPingRequest = async (i2, s2) => { - const { id: r2 } = s2; + }, this.onPairingPingRequest = async (i2, s22) => { + const { id: r3 } = s22; try { - this.isValidPing({ topic: i2 }), await this.sendResult(r2, i2, true), this.events.emit(V$3.ping, { id: r2, topic: i2 }); + this.isValidPing({ topic: i2 }), await this.sendResult(r3, i2, true), this.events.emit(V$1.ping, { id: r3, topic: i2 }); } catch (o22) { - await this.sendError(r2, i2, o22), this.logger.error(o22); + await this.sendError(r3, i2, o22), this.logger.error(o22); } - }, this.onPairingPingResponse = (i2, s2) => { - const { id: r2 } = s2; + }, this.onPairingPingResponse = (i2, s22) => { + const { id: r3 } = s22; setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("pairing_ping", r2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("pairing_ping", r2), { error: s2.error }); + isJsonRpcResult(s22) ? this.events.emit(v0("pairing_ping", r3), {}) : isJsonRpcError(s22) && this.events.emit(v0("pairing_ping", r3), { error: s22.error }); }, 500); - }, this.onPairingDeleteRequest = async (i2, s2) => { - const { id: r2 } = s2; + }, this.onPairingDeleteRequest = async (i2, s22) => { + const { id: r3 } = s22; try { - this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V$3.delete, { id: r2, topic: i2 }); + this.isValidDisconnect({ topic: i2 }), await this.deletePairing(i2), this.events.emit(V$1.delete, { id: r3, topic: i2 }); } catch (o22) { - await this.sendError(r2, i2, o22), this.logger.error(o22); + await this.sendError(r3, i2, o22), this.logger.error(o22); } - }, this.onUnknownRpcMethodRequest = async (i2, s2) => { - const { id: r2, method: o22 } = s2; + }, this.onUnknownRpcMethodRequest = async (i2, s22) => { + const { id: r3, method: o22 } = s22; try { if (this.registeredMethods.includes(o22)) return; - const a3 = U$2("WC_METHOD_UNSUPPORTED", o22); - await this.sendError(r2, i2, a3), this.logger.error(a3); + const a3 = tr$2("WC_METHOD_UNSUPPORTED", o22); + await this.sendError(r3, i2, a3), this.logger.error(a3); } catch (a3) { - await this.sendError(r2, i2, a3), this.logger.error(a3); + await this.sendError(r3, i2, a3), this.logger.error(a3); } }, this.onUnknownRpcMethodResponse = (i2) => { - this.registeredMethods.includes(i2) || this.logger.error(U$2("WC_METHOD_UNSUPPORTED", i2)); + this.registeredMethods.includes(i2) || this.logger.error(tr$2("WC_METHOD_UNSUPPORTED", i2)); }, this.isValidPair = (i2) => { - var s2; - if (!Gt$1(i2)) { - const { message: o22 } = N$1("MISSING_OR_INVALID", `pair() params: ${i2}`); + var s22; + if (!$u(i2)) { + const { message: o22 } = xe$1("MISSING_OR_INVALID", `pair() params: ${i2}`); throw new Error(o22); } - if (!Kt$1(i2.uri)) { - const { message: o22 } = N$1("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); + if (!Ju(i2.uri)) { + const { message: o22 } = xe$1("MISSING_OR_INVALID", `pair() uri: ${i2.uri}`); throw new Error(o22); } - const r2 = Pt$1(i2.uri); - if (!((s2 = r2 == null ? void 0 : r2.relay) != null && s2.protocol)) { - const { message: o22 } = N$1("MISSING_OR_INVALID", "pair() uri#relay-protocol"); + const r3 = Pu(i2.uri); + if (!((s22 = r3 == null ? void 0 : r3.relay) != null && s22.protocol)) { + const { message: o22 } = xe$1("MISSING_OR_INVALID", "pair() uri#relay-protocol"); throw new Error(o22); } - if (!(r2 != null && r2.symKey)) { - const { message: o22 } = N$1("MISSING_OR_INVALID", "pair() uri#symKey"); + if (!(r3 != null && r3.symKey)) { + const { message: o22 } = xe$1("MISSING_OR_INVALID", "pair() uri#symKey"); throw new Error(o22); } - if (r2 != null && r2.expiryTimestamp && cjs$4.toMiliseconds(r2 == null ? void 0 : r2.expiryTimestamp) < Date.now()) { - const { message: o22 } = N$1("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); + if (r3 != null && r3.expiryTimestamp && cjs$3.toMiliseconds(r3 == null ? void 0 : r3.expiryTimestamp) < Date.now()) { + const { message: o22 } = xe$1("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); throw new Error(o22); } }, this.isValidPing = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `ping() params: ${i2}`); - throw new Error(r2); + if (!$u(i2)) { + const { message: r3 } = xe$1("MISSING_OR_INVALID", `ping() params: ${i2}`); + throw new Error(r3); } - const { topic: s2 } = i2; - await this.isValidPairingTopic(s2); + const { topic: s22 } = i2; + await this.isValidPairingTopic(s22); }, this.isValidDisconnect = async (i2) => { - if (!Gt$1(i2)) { - const { message: r2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${i2}`); - throw new Error(r2); + if (!$u(i2)) { + const { message: r3 } = xe$1("MISSING_OR_INVALID", `disconnect() params: ${i2}`); + throw new Error(r3); } - const { topic: s2 } = i2; - await this.isValidPairingTopic(s2); + const { topic: s22 } = i2; + await this.isValidPairingTopic(s22); }, this.isValidPairingTopic = async (i2) => { - if (!g$3(i2, false)) { - const { message: s2 } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); - throw new Error(s2); + if (!Gt$1(i2, false)) { + const { message: s22 } = xe$1("MISSING_OR_INVALID", `pairing topic should be a string: ${i2}`); + throw new Error(s22); } if (!this.pairings.keys.includes(i2)) { - const { message: s2 } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); - throw new Error(s2); + const { message: s22 } = xe$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${i2}`); + throw new Error(s22); } - if (mt$1(this.pairings.get(i2).expiry)) { + if (p0(this.pairings.get(i2).expiry)) { await this.deletePairing(i2); - const { message: s2 } = N$1("EXPIRED", `pairing topic: ${i2}`); - throw new Error(s2); + const { message: s22 } = xe$1("EXPIRED", `pairing topic: ${i2}`); + throw new Error(s22); } - }, this.core = e2, this.logger = cjs$3.generateChildLogger(t2, this.name), this.pairings = new Kt$2(this.core, this.logger, this.name, this.storagePrefix); + }, this.core = e2, this.logger = E$1(t2, this.name), this.pairings = new Vt(this.core, this.logger, this.name, this.storagePrefix); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } registerRelayerEvents() { - this.core.relayer.on(D$1$1.message, async (e2) => { + this.core.relayer.on(v2.message, async (e2) => { const { topic: t2, message: i2 } = e2; if (!this.pairings.keys.includes(t2) || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i2))) return; - const s2 = await this.core.crypto.decode(t2, i2); + const s22 = await this.core.crypto.decode(t2, i2); try { - isJsonRpcRequest(s2) ? (this.core.history.set(t2, s2), this.onRelayEventRequest({ topic: t2, payload: s2 })) : isJsonRpcResponse(s2) && (await this.core.history.resolve(s2), await this.onRelayEventResponse({ topic: t2, payload: s2 }), this.core.history.delete(t2, s2.id)); - } catch (r2) { - this.logger.error(r2); + isJsonRpcRequest(s22) ? (this.core.history.set(t2, s22), this.onRelayEventRequest({ topic: t2, payload: s22 })) : isJsonRpcResponse(s22) && (await this.core.history.resolve(s22), await this.onRelayEventResponse({ topic: t2, payload: s22 }), this.core.history.delete(t2, s22.id)); + } catch (r3) { + this.logger.error(r3); } }); } registerExpirerEvents() { - this.core.expirer.on(v2.expired, async (e2) => { - const { topic: t2 } = ft$1(e2.target); - t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V$3.expire, { topic: t2 })); + this.core.expirer.on(C$4.expired, async (e2) => { + const { topic: t2 } = l0(e2.target); + t2 && this.pairings.keys.includes(t2) && (await this.deletePairing(t2, true), this.events.emit(V$1.expire, { topic: t2 })); }); } - }; - let Vt$1 = class Vt extends h$2$1 { + } + let jt$1 = class jt extends h$1$1 { constructor(e2, t2) { - super(e2, t2), this.core = e2, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = vt$2, this.version = It$2, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { + super(e2, t2), this.core = e2, this.logger = t2, this.records = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct, this.version = _t$1, this.cached = [], this.initialized = false, this.storagePrefix = z$1$1, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.records.set(i2.id, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); - }, this.set = (i2, s2, r2) => { - if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s2, chainId: r2 }), this.records.has(s2.id)) + }, this.set = (i2, s22, r3) => { + if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: i2, request: s22, chainId: r3 }), this.records.has(s22.id)) return; - const o22 = { id: s2.id, topic: i2, request: { method: s2.method, params: s2.params || null }, chainId: r2, expiry: pt$1(cjs$4.THIRTY_DAYS) }; - this.records.set(o22.id, o22), this.events.emit(R$1.created, o22); + const o22 = { id: s22.id, topic: i2, request: { method: s22.method, params: s22.params || null }, chainId: r3, expiry: d0(cjs$3.THIRTY_DAYS) }; + this.records.set(o22.id, o22), this.persist(), this.events.emit(I$1.created, o22); }, this.resolve = async (i2) => { if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: i2 }), !this.records.has(i2.id)) return; - const s2 = await this.getRecord(i2.id); - typeof s2.response > "u" && (s2.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s2.id, s2), this.events.emit(R$1.updated, s2)); - }, this.get = async (i2, s2) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s2 }), await this.getRecord(s2)), this.delete = (i2, s2) => { - this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s2 }), this.values.forEach((r2) => { - if (r2.topic === i2) { - if (typeof s2 < "u" && r2.id !== s2) + const s22 = await this.getRecord(i2.id); + typeof s22.response > "u" && (s22.response = isJsonRpcError(i2) ? { error: i2.error } : { result: i2.result }, this.records.set(s22.id, s22), this.persist(), this.events.emit(I$1.updated, s22)); + }, this.get = async (i2, s22) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: i2, id: s22 }), await this.getRecord(s22)), this.delete = (i2, s22) => { + this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: s22 }), this.values.forEach((r3) => { + if (r3.topic === i2) { + if (typeof s22 < "u" && r3.id !== s22) return; - this.records.delete(r2.id), this.events.emit(R$1.deleted, r2); - } - }); - }, this.exists = async (i2, s2) => (this.isInitialized(), this.records.has(s2) ? (await this.getRecord(s2)).topic === i2 : false), this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); + this.records.delete(r3.id), this.events.emit(I$1.deleted, r3); + } + }), this.persist(); + }, this.exists = async (i2, s22) => (this.isInitialized(), this.records.has(s22) ? (await this.getRecord(s22)).topic === i2 : false), this.on = (i2, s22) => { + this.events.on(i2, s22); + }, this.once = (i2, s22) => { + this.events.once(i2, s22); + }, this.off = (i2, s22) => { + this.events.off(i2, s22); + }, this.removeListener = (i2, s22) => { + this.events.removeListener(i2, s22); + }, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11443,13 +14974,13 @@ this.isInitialized(); const t2 = this.records.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); + const { message: i2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); throw new Error(i2); } return t2; } async persist() { - await this.setJsonRpcRecords(this.values), this.events.emit(R$1.sync); + await this.setJsonRpcRecords(this.values), this.events.emit(I$1.sync); } async restore() { try { @@ -11457,7 +14988,7 @@ if (typeof e2 > "u" || !e2.length) return; if (this.records.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe$1("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } this.cached = e2, this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", records: this.values }); @@ -11466,71 +14997,73 @@ } } registerEventListeners() { - this.events.on(R$1.created, (e2) => { - const t2 = R$1.created; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }), this.persist(); - }), this.events.on(R$1.updated, (e2) => { - const t2 = R$1.updated; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }), this.persist(); - }), this.events.on(R$1.deleted, (e2) => { - const t2 = R$1.deleted; - this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }), this.persist(); - }), this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => { + this.events.on(I$1.created, (e2) => { + const t2 = I$1.created; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.updated, (e2) => { + const t2 = I$1.updated; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.events.on(I$1.deleted, (e2) => { + const t2 = I$1.deleted; + this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, record: e2 }); + }), this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => { this.cleanup(); }); } cleanup() { try { - this.records.forEach((e2) => { - cjs$4.toMiliseconds(e2.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${e2.id}`), this.delete(e2.topic, e2.id)); - }); + this.isInitialized(); + let e2 = false; + this.records.forEach((t2) => { + cjs$3.toMiliseconds(t2.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${t2.id}`), this.records.delete(t2.id), this.events.emit(I$1.deleted, t2, false), e2 = true); + }), e2 && this.persist(); } catch (e2) { this.logger.warn(e2); } } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } }; - let qt$2 = class qt extends E$3 { + let Gt$2 = class Gt extends E$4 { constructor(e2, t2) { - super(e2, t2), this.core = e2, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Ct$1, this.version = Rt$2, this.cached = [], this.initialized = false, this.storagePrefix = O, this.init = async () => { + super(e2, t2), this.core = e2, this.logger = t2, this.expirations = /* @__PURE__ */ new Map(), this.events = new eventsExports.EventEmitter(), this.name = Rt$1, this.version = Tt$1, this.cached = [], this.initialized = false, this.storagePrefix = z$1$1, this.init = async () => { this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((i2) => this.expirations.set(i2.target, i2)), this.cached = [], this.registerEventListeners(), this.initialized = true); }, this.has = (i2) => { try { - const s2 = this.formatTarget(i2); - return typeof this.getExpiration(s2) < "u"; + const s22 = this.formatTarget(i2); + return typeof this.getExpiration(s22) < "u"; } catch { return false; } - }, this.set = (i2, s2) => { + }, this.set = (i2, s22) => { this.isInitialized(); - const r2 = this.formatTarget(i2), o22 = { target: r2, expiry: s2 }; - this.expirations.set(r2, o22), this.checkExpiry(r2, o22), this.events.emit(v2.created, { target: r2, expiration: o22 }); + const r3 = this.formatTarget(i2), o22 = { target: r3, expiry: s22 }; + this.expirations.set(r3, o22), this.checkExpiry(r3, o22), this.events.emit(C$4.created, { target: r3, expiration: o22 }); }, this.get = (i2) => { this.isInitialized(); - const s2 = this.formatTarget(i2); - return this.getExpiration(s2); + const s22 = this.formatTarget(i2); + return this.getExpiration(s22); }, this.del = (i2) => { if (this.isInitialized(), this.has(i2)) { - const s2 = this.formatTarget(i2), r2 = this.getExpiration(s2); - this.expirations.delete(s2), this.events.emit(v2.deleted, { target: s2, expiration: r2 }); - } - }, this.on = (i2, s2) => { - this.events.on(i2, s2); - }, this.once = (i2, s2) => { - this.events.once(i2, s2); - }, this.off = (i2, s2) => { - this.events.off(i2, s2); - }, this.removeListener = (i2, s2) => { - this.events.removeListener(i2, s2); - }, this.logger = cjs$3.generateChildLogger(t2, this.name); + const s22 = this.formatTarget(i2), r3 = this.getExpiration(s22); + this.expirations.delete(s22), this.events.emit(C$4.deleted, { target: s22, expiration: r3 }); + } + }, this.on = (i2, s22) => { + this.events.on(i2, s22); + }, this.once = (i2, s22) => { + this.events.once(i2, s22); + }, this.off = (i2, s22) => { + this.events.off(i2, s22); + }, this.removeListener = (i2, s22) => { + this.events.removeListener(i2, s22); + }, this.logger = E$1(t2, this.name); } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } get storageKey() { return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; @@ -11546,10 +15079,10 @@ } formatTarget(e2) { if (typeof e2 == "string") - return lt$1(e2); + return h0(e2); if (typeof e2 == "number") - return dt$1(e2); - const { message: t2 } = N$1("UNKNOWN_TYPE", `Target type: ${typeof e2}`); + return c0(e2); + const { message: t2 } = xe$1("UNKNOWN_TYPE", `Target type: ${typeof e2}`); throw new Error(t2); } async setExpirations(e2) { @@ -11559,7 +15092,7 @@ return await this.core.storage.getItem(this.storageKey); } async persist() { - await this.setExpirations(this.values), this.events.emit(v2.sync); + await this.setExpirations(this.values), this.events.emit(C$4.sync); } async restore() { try { @@ -11567,7 +15100,7 @@ if (typeof e2 > "u" || !e2.length) return; if (this.expirations.size) { - const { message: t2 } = N$1("RESTORE_WILL_OVERRIDE", this.name); + const { message: t2 } = xe$1("RESTORE_WILL_OVERRIDE", this.name); throw this.logger.error(t2), new Error(t2); } this.cached = e2, this.logger.debug(`Successfully Restored expirations for ${this.name}`), this.logger.trace({ type: "method", method: "restore", expirations: this.values }); @@ -11578,58 +15111,58 @@ getExpiration(e2) { const t2 = this.expirations.get(e2); if (!t2) { - const { message: i2 } = N$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); - throw this.logger.error(i2), new Error(i2); + const { message: i2 } = xe$1("NO_MATCHING_KEY", `${this.name}: ${e2}`); + throw this.logger.warn(i2), new Error(i2); } return t2; } checkExpiry(e2, t2) { const { expiry: i2 } = t2; - cjs$4.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e2, t2); + cjs$3.toMiliseconds(i2) - Date.now() <= 0 && this.expire(e2, t2); } expire(e2, t2) { - this.expirations.delete(e2), this.events.emit(v2.expired, { target: e2, expiration: t2 }); + this.expirations.delete(e2), this.events.emit(C$4.expired, { target: e2, expiration: t2 }); } checkExpirations() { this.core.relayer.connected && this.expirations.forEach((e2, t2) => this.checkExpiry(t2, e2)); } registerEventListeners() { - this.core.heartbeat.on(cjs$5.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(v2.created, (e2) => { - const t2 = v2.created; + this.core.heartbeat.on(cjs$4.HEARTBEAT_EVENTS.pulse, () => this.checkExpirations()), this.events.on(C$4.created, (e2) => { + const t2 = C$4.created; this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); - }), this.events.on(v2.expired, (e2) => { - const t2 = v2.expired; + }), this.events.on(C$4.expired, (e2) => { + const t2 = C$4.expired; this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); - }), this.events.on(v2.deleted, (e2) => { - const t2 = v2.deleted; + }), this.events.on(C$4.deleted, (e2) => { + const t2 = C$4.deleted; this.logger.info(`Emitting ${t2}`), this.logger.debug({ type: "event", event: t2, data: e2 }), this.persist(); }); } isInitialized() { if (!this.initialized) { - const { message: e2 } = N$1("NOT_INITIALIZED", this.name); + const { message: e2 } = xe$1("NOT_INITIALIZED", this.name); throw new Error(e2); } } }; - let jt$1 = class jt extends y$1 { + let Yt$1 = class Yt extends y$1 { constructor(e2, t2) { - super(e2, t2), this.projectId = e2, this.logger = t2, this.name = Z, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { - if (this.verifyDisabled || $$1() || !D$2()) + super(e2, t2), this.projectId = e2, this.logger = t2, this.name = ee$1, this.initialized = false, this.queue = [], this.verifyDisabled = false, this.init = async (i2) => { + if (this.verifyDisabled || er$1() || !pr$1()) return; - const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - this.verifyUrl !== s2 && this.removeIframe(), this.verifyUrl = s2; + const s22 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); + this.verifyUrl !== s22 && this.removeIframe(), this.verifyUrl = s22; try { await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2); + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3); } if (!this.initialized) { - this.removeIframe(), this.verifyUrl = ee$2; + this.removeIframe(), this.verifyUrl = te; try { await this.createIframe(); - } catch (r2) { - this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r2), this.verifyDisabled = true; + } catch (r3) { + this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`), this.logger.info(r3), this.verifyDisabled = true; } } }, this.register = async (i2) => { @@ -11637,92 +15170,103 @@ }, this.resolve = async (i2) => { if (this.isDevEnv) return ""; - const s2 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); - let r2; + const s22 = this.getVerifyUrl(i2 == null ? void 0 : i2.verifyUrl); + let r3; try { - r2 = await this.fetchAttestation(i2.attestationId, s2); + r3 = await this.fetchAttestation(i2.attestationId, s22); } catch (o22) { - this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s2}`), this.logger.info(o22), r2 = await this.fetchAttestation(i2.attestationId, ee$2); + this.logger.info(`failed to resolve attestation: ${i2.attestationId} from url: ${s22}`), this.logger.info(o22), r3 = await this.fetchAttestation(i2.attestationId, te); } - return r2; - }, this.fetchAttestation = async (i2, s2) => { - this.logger.info(`resolving attestation: ${i2} from url: ${s2}`); - const r2 = this.startAbortTimer(cjs$4.ONE_SECOND * 2), o22 = await fetch(`${s2}/attestation/${i2}`, { signal: this.abortController.signal }); - return clearTimeout(r2), o22.status === 200 ? await o22.json() : void 0; + return r3; + }, this.fetchAttestation = async (i2, s22) => { + this.logger.info(`resolving attestation: ${i2} from url: ${s22}`); + const r3 = this.startAbortTimer(cjs$3.ONE_SECOND * 2), o22 = await fetch(`${s22}/attestation/${i2}`, { signal: this.abortController.signal }); + return clearTimeout(r3), o22.status === 200 ? await o22.json() : void 0; }, this.addToQueue = (i2) => { this.queue.push(i2); }, this.processQueue = () => { this.queue.length !== 0 && (this.queue.forEach((i2) => this.sendPost(i2)), this.queue = []); }, this.sendPost = (i2) => { - var s2; + var s22; try { if (!this.iframe) return; - (s2 = this.iframe.contentWindow) == null || s2.postMessage(i2, "*"), this.logger.info(`postMessage sent: ${i2} ${this.verifyUrl}`); + (s22 = this.iframe.contentWindow) == null || s22.postMessage(i2, "*"), this.logger.info(`postMessage sent: ${i2} ${this.verifyUrl}`); } catch { } }, this.createIframe = async () => { let i2; - const s2 = (r2) => { - r2.data === "verify_ready" && (this.initialized = true, this.processQueue(), window.removeEventListener("message", s2), i2()); + const s22 = (r3) => { + r3.data === "verify_ready" && (this.onInit(), window.removeEventListener("message", s22), i2()); }; - await Promise.race([new Promise((r2) => { - if (document.getElementById(Z)) - return r2(); - window.addEventListener("message", s2); - const o22 = document.createElement("iframe"); - o22.id = Z, o22.src = `${this.verifyUrl}/${this.projectId}`, o22.style.display = "none", document.body.append(o22), this.iframe = o22, i2 = r2; - }), new Promise((r2, o22) => setTimeout(() => { - window.removeEventListener("message", s2), o22("verify iframe load timeout"); - }, cjs$4.toMiliseconds(cjs$4.FIVE_SECONDS)))]); + await Promise.race([new Promise((r3) => { + const o22 = document.getElementById(ee$1); + if (o22) + return this.iframe = o22, this.onInit(), r3(); + window.addEventListener("message", s22); + const a3 = document.createElement("iframe"); + a3.id = ee$1, a3.src = `${this.verifyUrl}/${this.projectId}`, a3.style.display = "none", document.body.append(a3), this.iframe = a3, i2 = r3; + }), new Promise((r3, o22) => setTimeout(() => { + window.removeEventListener("message", s22), o22("verify iframe load timeout"); + }, cjs$3.toMiliseconds(cjs$3.FIVE_SECONDS)))]); + }, this.onInit = () => { + this.initialized = true, this.processQueue(); }, this.removeIframe = () => { this.iframe && (this.iframe.remove(), this.iframe = void 0, this.initialized = false); }, this.getVerifyUrl = (i2) => { - let s2 = i2 || F$1; - return _t$1.includes(s2) || (this.logger.info(`verify url: ${s2}, not included in trusted list, assigning default: ${F$1}`), s2 = F$1), s2; - }, this.logger = cjs$3.generateChildLogger(t2, this.name), this.verifyUrl = F$1, this.abortController = new AbortController(), this.isDevEnv = te$1() && process.env.IS_VITEST; + let s22 = i2 || k$1; + return St$1.includes(s22) || (this.logger.info(`verify url: ${s22}, not included in trusted list, assigning default: ${k$1}`), s22 = k$1), s22; + }, this.logger = E$1(t2, this.name), this.verifyUrl = k$1, this.abortController = new AbortController(), this.isDevEnv = pi() && process.env.IS_VITEST; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } startAbortTimer(e2) { - return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$4.toMiliseconds(e2)); + return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), cjs$3.toMiliseconds(e2)); } }; - let Gt$2 = class Gt extends v$1$1 { + let Ht$2 = class Ht extends v$1 { constructor(e2, t2) { - super(e2, t2), this.projectId = e2, this.logger = t2, this.context = Tt$2, this.registerDeviceToken = async (i2) => { - const { clientId: s2, token: r2, notificationType: o22, enableEncrypted: a3 = false } = i2, h4 = `${St$2}/${this.projectId}/clients`; - await Yi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s2, type: o22, token: r2, always_raw: a3 }) }); - }, this.logger = cjs$3.generateChildLogger(t2, this.context); + super(e2, t2), this.projectId = e2, this.logger = t2, this.context = Pt$1, this.registerDeviceToken = async (i2) => { + const { clientId: s22, token: r3, notificationType: o22, enableEncrypted: a3 = false } = i2, h4 = `${xt}/${this.projectId}/clients`; + await Hi(h4, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: s22, type: o22, token: r3, always_raw: a3 }) }); + }, this.logger = E$1(t2, this.context); } }; - var Lr = Object.defineProperty, Yt$2 = Object.getOwnPropertySymbols, $r = Object.prototype.hasOwnProperty, Fr = Object.prototype.propertyIsEnumerable, Ht$2 = (n3, e2, t2) => e2 in n3 ? Lr(n3, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n3[e2] = t2, Jt$2 = (n3, e2) => { + var $r = Object.defineProperty, Jt$2 = Object.getOwnPropertySymbols, Fr$1 = Object.prototype.hasOwnProperty, kr$1 = Object.prototype.propertyIsEnumerable, Xt$2 = (n4, e2, t2) => e2 in n4 ? $r(n4, e2, { enumerable: true, configurable: true, writable: true, value: t2 }) : n4[e2] = t2, Wt$2 = (n4, e2) => { for (var t2 in e2 || (e2 = {})) - $r.call(e2, t2) && Ht$2(n3, t2, e2[t2]); - if (Yt$2) - for (var t2 of Yt$2(e2)) - Fr.call(e2, t2) && Ht$2(n3, t2, e2[t2]); - return n3; + Fr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + if (Jt$2) + for (var t2 of Jt$2(e2)) + kr$1.call(e2, t2) && Xt$2(n4, t2, e2[t2]); + return n4; }; - let te$3 = class te2 extends n$1$1 { + let ie$2 = class ie3 extends n$2$1 { constructor(e2) { - super(e2), this.protocol = le$1, this.version = We$2, this.name = Q$1, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (i2, s2) => this.events.on(i2, s2), this.once = (i2, s2) => this.events.once(i2, s2), this.off = (i2, s2) => this.events.off(i2, s2), this.removeListener = (i2, s2) => this.events.removeListener(i2, s2), this.projectId = e2 == null ? void 0 : e2.projectId, this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || ge$1, this.customStoragePrefix = e2 != null && e2.customStoragePrefix ? `:${e2.customStoragePrefix}` : ""; - const t2 = typeof (e2 == null ? void 0 : e2.logger) < "u" && typeof (e2 == null ? void 0 : e2.logger) != "string" ? e2.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (e2 == null ? void 0 : e2.logger) || Qe$2.logger })); - this.logger = cjs$3.generateChildLogger(t2, this.name), this.heartbeat = new cjs$5.HeartBeat(), this.crypto = new xt$2(this, this.logger, e2 == null ? void 0 : e2.keychain), this.history = new Vt$1(this, this.logger), this.expirer = new qt$2(this, this.logger), this.storage = e2 != null && e2.storage ? e2.storage : new h$3(Jt$2(Jt$2({}, Ze), e2 == null ? void 0 : e2.storageOptions)), this.relayer = new $t$1({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new Bt$2(this, this.logger), this.verify = new jt$1(this.projectId || "", this.logger), this.echoClient = new Gt$2(this.projectId || "", this.logger); + var t2; + super(e2), this.protocol = De$1, this.version = Ze$1, this.name = Z, this.events = new eventsExports.EventEmitter(), this.initialized = false, this.on = (o22, a3) => this.events.on(o22, a3), this.once = (o22, a3) => this.events.once(o22, a3), this.off = (o22, a3) => this.events.off(o22, a3), this.removeListener = (o22, a3) => this.events.removeListener(o22, a3), this.projectId = e2 == null ? void 0 : e2.projectId, this.relayUrl = (e2 == null ? void 0 : e2.relayUrl) || me$2, this.customStoragePrefix = e2 != null && e2.customStoragePrefix ? `:${e2.customStoragePrefix}` : ""; + const i2 = k$2({ level: typeof (e2 == null ? void 0 : e2.logger) == "string" && e2.logger ? e2.logger : et$1.logger }), { logger: s22, chunkLoggerController: r3 } = A$2({ opts: i2, maxSizeInBytes: e2 == null ? void 0 : e2.maxLogBlobSizeInBytes, loggerOverride: e2 == null ? void 0 : e2.logger }); + this.logChunkController = r3, (t2 = this.logChunkController) != null && t2.downloadLogsBlobInBrowser && (window.downloadLogsBlobInBrowser = async () => { + var o22, a3; + (o22 = this.logChunkController) != null && o22.downloadLogsBlobInBrowser && ((a3 = this.logChunkController) == null || a3.downloadLogsBlobInBrowser({ clientId: await this.crypto.getClientId() })); + }), this.logger = E$1(s22, this.name), this.heartbeat = new cjs$4.HeartBeat(), this.crypto = new At$1(this, this.logger, e2 == null ? void 0 : e2.keychain), this.history = new jt$1(this, this.logger), this.expirer = new Gt$2(this, this.logger), this.storage = e2 != null && e2.storage ? e2.storage : new h$2$1(Wt$2(Wt$2({}, tt$1), e2 == null ? void 0 : e2.storageOptions)), this.relayer = new kt$1({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new qt(this, this.logger), this.verify = new Yt$1(this.projectId || "", this.logger), this.echoClient = new Ht$2(this.projectId || "", this.logger); } static async init(e2) { - const t2 = new te2(e2); + const t2 = new ie3(e2); await t2.initialize(); const i2 = await t2.crypto.getClientId(); - return await t2.storage.setItem(yt$2, i2), t2; + return await t2.storage.setItem(bt$1, i2), t2; } get context() { - return cjs$3.getLoggerContext(this.logger); + return y$2(this.logger); } async start() { this.initialized || await this.initialize(); } + async getLogsBlob() { + var e2; + return (e2 = this.logChunkController) == null ? void 0 : e2.logsToBlob({ clientId: await this.crypto.getClientId() }); + } async initialize() { this.logger.trace("Initialized"); try { @@ -11732,1128 +15276,1167 @@ } } }; - const Mr = te$3; - const J = "wc", F$4 = 2, X = "client", G$3 = `${J}@${F$4}:${X}:`, M$2 = { name: X, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, H$3 = "WALLETCONNECT_DEEPLINK_CHOICE", oe$2 = "proposal", ae$2 = "Proposal expired", ce$3 = "session", L = cjs$4.SEVEN_DAYS, le$2 = "engine", R$5 = { wc_sessionPropose: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$4.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$4.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$4.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1114 }, res: { ttl: cjs$4.THIRTY_SECONDS, prompt: false, tag: 1115 } } }, U$1 = { min: cjs$4.FIVE_MINUTES, max: cjs$4.SEVEN_DAYS }, I$2 = { idle: "IDLE", active: "ACTIVE" }, pe = "request", he$2 = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"]; - var as = Object.defineProperty, cs = Object.defineProperties, ls = Object.getOwnPropertyDescriptors, de$2 = Object.getOwnPropertySymbols, ps = Object.prototype.hasOwnProperty, hs = Object.prototype.propertyIsEnumerable, ue$2 = (w3, r2, e2) => r2 in w3 ? as(w3, r2, { enumerable: true, configurable: true, writable: true, value: e2 }) : w3[r2] = e2, g$1 = (w3, r2) => { - for (var e2 in r2 || (r2 = {})) - ps.call(r2, e2) && ue$2(w3, e2, r2[e2]); - if (de$2) - for (var e2 of de$2(r2)) - hs.call(r2, e2) && ue$2(w3, e2, r2[e2]); - return w3; - }, D$5 = (w3, r2) => cs(w3, ls(r2)); - class ds extends w$4 { - constructor(r2) { - super(r2), this.name = le$2, this.events = new EventEmitter$1(), this.initialized = false, this.ignoredPayloadTypes = [_$1$1], this.requestQueue = { state: I$2.idle, queue: [] }, this.sessionRequestQueue = { state: I$2.idle, queue: [] }, this.requestQueueDelay = cjs$4.ONE_SECOND, this.init = async () => { - this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(R$5) }), this.initialized = true, setTimeout(() => { + const Br = ie$2; + const Se$1 = "wc", Ee$1 = 2, _e$2 = "client", se$1 = `${Se$1}@${Ee$1}:${_e$2}:`, ie$1 = { name: _e$2, logger: "error", controller: false, relayUrl: "wss://relay.walletconnect.com" }, Re$1 = "WALLETCONNECT_DEEPLINK_CHOICE", Ke$2 = "proposal", Ue$2 = "Proposal expired", Ge$2 = "session", L$2 = cjs$3.SEVEN_DAYS, ke$2 = "engine", q$1 = { wc_sessionPropose: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1100 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1101 } }, wc_sessionSettle: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1102 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1104 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1105 } }, wc_sessionExtend: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1106 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1107 } }, wc_sessionRequest: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1108 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1109 } }, wc_sessionEvent: { req: { ttl: cjs$3.FIVE_MINUTES, prompt: true, tag: 1110 }, res: { ttl: cjs$3.FIVE_MINUTES, prompt: false, tag: 1111 } }, wc_sessionDelete: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1112 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1113 } }, wc_sessionPing: { req: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1114 }, res: { ttl: cjs$3.ONE_DAY, prompt: false, tag: 1115 } }, wc_sessionAuthenticate: { req: { ttl: cjs$3.ONE_HOUR, prompt: true, tag: 1116 }, res: { ttl: cjs$3.ONE_HOUR, prompt: false, tag: 1117 } } }, re$1 = { min: cjs$3.FIVE_MINUTES, max: cjs$3.SEVEN_DAYS }, A$1 = { idle: "IDLE", active: "ACTIVE" }, Fe$2 = "request", je$2 = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest"], Qe$2 = "wc", ze$1 = "auth", He$2 = "authKeys", Ye$2 = "pairingTopics", Xe$1 = "requests", X$2 = `${Qe$2}@${1.5}:${ze$1}:`, J$2 = `${X$2}:PUB_KEY`; + var Ht$1 = Object.defineProperty, Yt2 = Object.defineProperties, Xt$1 = Object.getOwnPropertyDescriptors, Je = Object.getOwnPropertySymbols, Jt$1 = Object.prototype.hasOwnProperty, Bt$2 = Object.prototype.propertyIsEnumerable, Be$1 = (S2, n4, t2) => n4 in S2 ? Ht$1(S2, n4, { enumerable: true, configurable: true, writable: true, value: t2 }) : S2[n4] = t2, m2 = (S2, n4) => { + for (var t2 in n4 || (n4 = {})) + Jt$1.call(n4, t2) && Be$1(S2, t2, n4[t2]); + if (Je) + for (var t2 of Je(n4)) + Bt$2.call(n4, t2) && Be$1(S2, t2, n4[t2]); + return S2; + }, F = (S2, n4) => Yt2(S2, Xt$1(n4)); + let Wt$1 = class Wt extends w$2 { + constructor(n4) { + super(n4), this.name = ke$2, this.events = new EventEmitter$1(), this.initialized = false, this.requestQueue = { state: A$1.idle, queue: [] }, this.sessionRequestQueue = { state: A$1.idle, queue: [] }, this.requestQueueDelay = cjs$3.ONE_SECOND, this.expectedPairingMethodMap = /* @__PURE__ */ new Map(), this.recentlyDeletedMap = /* @__PURE__ */ new Map(), this.recentlyDeletedLimit = 200, this.init = async () => { + this.initialized || (await this.cleanup(), this.registerRelayerEvents(), this.registerExpirerEvents(), this.registerPairingEvents(), this.client.core.pairing.register({ methods: Object.keys(q$1) }), this.initialized = true, setTimeout(() => { this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay))); - }, this.connect = async (e2) => { + }, cjs$3.toMiliseconds(this.requestQueueDelay))); + }, this.connect = async (t2) => { + await this.isInitialized(); + const e2 = F(m2({}, t2), { requiredNamespaces: t2.requiredNamespaces || {}, optionalNamespaces: t2.optionalNamespaces || {} }); + await this.isValidConnect(e2); + const { pairingTopic: s22, requiredNamespaces: i2, optionalNamespaces: r3, sessionProperties: o22, relays: a3 } = e2; + let c2 = s22, d5, p2 = false; + try { + c2 && (p2 = this.client.core.pairing.pairings.get(c2).active); + } catch (f3) { + throw this.client.logger.error(`connect() -> pairing.get(${c2}) failed`), f3; + } + if (!c2 || !p2) { + const { topic: f3, uri: v3 } = await this.client.core.pairing.create(); + c2 = f3, d5 = v3; + } + if (!c2) { + const { message: f3 } = xe$1("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); + throw new Error(f3); + } + const g3 = await this.client.core.crypto.generateKeyPair(), h4 = q$1.wc_sessionPropose.req.ttl || cjs$3.FIVE_MINUTES, y3 = d0(h4), w3 = m2({ requiredNamespaces: i2, optionalNamespaces: r3, relays: a3 ?? [{ protocol: lt$1 }], proposer: { publicKey: g3, metadata: this.client.metadata }, expiryTimestamp: y3 }, o22 && { sessionProperties: o22 }), { reject: I2, resolve: D2, done: E2 } = a0(h4, Ue$2); + this.events.once(v0("session_connect"), async ({ error: f3, session: v3 }) => { + if (f3) + I2(f3); + else if (v3) { + v3.self.publicKey = g3; + const j2 = F(m2({}, v3), { requiredNamespaces: w3.requiredNamespaces, optionalNamespaces: w3.optionalNamespaces }); + await this.client.session.set(v3.topic, j2), await this.setExpiry(v3.topic, v3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: v3.peer.metadata }), D2(j2); + } + }); + const P2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: w3, throwOnFailedPublish: true }); + return await this.setProposal(P2, m2({ id: P2 }, w3)), { uri: d5, approval: E2 }; + }, this.pair = async (t2) => { await this.isInitialized(); - const s2 = D$5(g$1({}, e2), { requiredNamespaces: e2.requiredNamespaces || {}, optionalNamespaces: e2.optionalNamespaces || {} }); - await this.isValidConnect(s2); - const { pairingTopic: t2, requiredNamespaces: i2, optionalNamespaces: n3, sessionProperties: o22, relays: a3 } = s2; - let c2 = t2, p3, d3 = false; - if (c2 && (d3 = this.client.core.pairing.pairings.get(c2).active), !c2 || !d3) { - const { topic: T2, uri: _3 } = await this.client.core.pairing.create(); - c2 = T2, p3 = _3; - } - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = R$5.wc_sessionPropose.req.ttl || cjs$4.FIVE_MINUTES, m2 = pt$1(N2), f2 = g$1({ requiredNamespaces: i2, optionalNamespaces: n3, relays: a3 ?? [{ protocol: ht$2 }], proposer: { publicKey: h4, metadata: this.client.metadata }, expiryTimestamp: m2 }, o22 && { sessionProperties: o22 }), { reject: k2, resolve: O2, done: we2 } = at$1(N2, ae$2); - if (this.events.once(yt$1("session_connect"), async ({ error: T2, session: _3 }) => { - if (T2) - k2(T2); - else if (_3) { - _3.self.publicKey = h4; - const B2 = D$5(g$1({}, _3), { requiredNamespaces: f2.requiredNamespaces, optionalNamespaces: f2.optionalNamespaces }); - await this.client.session.set(_3.topic, B2), await this.setExpiry(_3.topic, _3.expiry), c2 && await this.client.core.pairing.updateMetadata({ topic: c2, metadata: _3.peer.metadata }), O2(B2); - } - }), !c2) { - const { message: T2 } = N$1("NO_MATCHING_KEY", `connect() pairing topic: ${c2}`); - throw new Error(T2); - } - const W2 = await this.sendRequest({ topic: c2, method: "wc_sessionPropose", params: f2, throwOnFailedPublish: true }); - return await this.setProposal(W2, g$1({ id: W2 }, f2)), { uri: p3, approval: we2 }; - }, this.pair = async (e2) => (await this.isInitialized(), await this.client.core.pairing.pair(e2)), this.approve = async (e2) => { - await this.isInitialized(), await this.isValidApprove(e2); - const { id: s2, relayProtocol: t2, namespaces: i2, sessionProperties: n3 } = e2, o22 = this.client.proposal.get(s2); - let { pairingTopic: a3, proposer: c2, requiredNamespaces: p3, optionalNamespaces: d3 } = o22; - a3 = a3 || ""; - const h4 = await this.client.core.crypto.generateKeyPair(), N2 = c2.publicKey, m2 = await this.client.core.crypto.generateSharedKey(h4, N2); - a3 && s2 && (await this.client.core.pairing.updateMetadata({ topic: a3, metadata: c2.metadata }), await this.sendResult({ id: s2, topic: a3, result: { relay: { protocol: t2 ?? "irn" }, responderPublicKey: h4 } }), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: a3 })); - const f2 = g$1({ relay: { protocol: t2 ?? "irn" }, namespaces: i2, pairingTopic: a3, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: pt$1(L) }, n3 && { sessionProperties: n3 }); - await this.client.core.relayer.subscribe(m2); - const k2 = D$5(g$1({}, f2), { topic: m2, requiredNamespaces: p3, optionalNamespaces: d3, pairingTopic: a3, acknowledged: false, self: f2.controller, peer: { publicKey: c2.publicKey, metadata: c2.metadata }, controller: h4 }); - await this.client.session.set(m2, k2); try { - await this.sendRequest({ topic: m2, method: "wc_sessionSettle", params: f2, throwOnFailedPublish: true }); - } catch (O2) { - throw this.client.logger.error(O2), this.client.session.delete(m2, U$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(m2), O2; + return await this.client.core.pairing.pair(t2); + } catch (e2) { + throw this.client.logger.error("pair() failed"), e2; } - return await this.setExpiry(m2, pt$1(L)), { topic: m2, acknowledged: () => new Promise((O2) => setTimeout(() => O2(this.client.session.get(m2)), 500)) }; - }, this.reject = async (e2) => { - await this.isInitialized(), await this.isValidReject(e2); - const { id: s2, reason: t2 } = e2, { pairingTopic: i2 } = this.client.proposal.get(s2); - i2 && (await this.sendError(s2, i2, t2), await this.client.proposal.delete(s2, U$2("USER_DISCONNECTED"))); - }, this.update = async (e2) => { - await this.isInitialized(), await this.isValidUpdate(e2); - const { topic: s2, namespaces: t2 } = e2, i2 = await this.sendRequest({ topic: s2, method: "wc_sessionUpdate", params: { namespaces: t2 } }), { done: n3, resolve: o22, reject: a3 } = at$1(); - return this.events.once(yt$1("session_update", i2), ({ error: c2 }) => { - c2 ? a3(c2) : o22(); - }), await this.client.session.update(s2, { namespaces: t2 }), { acknowledged: n3 }; - }, this.extend = async (e2) => { - await this.isInitialized(), await this.isValidExtend(e2); - const { topic: s2 } = e2, t2 = await this.sendRequest({ topic: s2, method: "wc_sessionExtend", params: {} }), { done: i2, resolve: n3, reject: o22 } = at$1(); - return this.events.once(yt$1("session_extend", t2), ({ error: a3 }) => { - a3 ? o22(a3) : n3(); - }), await this.setExpiry(s2, pt$1(L)), { acknowledged: i2 }; - }, this.request = async (e2) => { - await this.isInitialized(), await this.isValidRequest(e2); - const { chainId: s2, request: t2, topic: i2, expiry: n3 = R$5.wc_sessionRequest.req.ttl } = e2, o22 = payloadId(), { done: a3, resolve: c2, reject: p3 } = at$1(n3, "Request expired. Please try again."); - return this.events.once(yt$1("session_request", o22), ({ error: d3, result: h4 }) => { - d3 ? p3(d3) : c2(h4); - }), await Promise.all([new Promise(async (d3) => { - await this.sendRequest({ clientRpcId: o22, topic: i2, method: "wc_sessionRequest", params: { request: D$5(g$1({}, t2), { expiryTimestamp: pt$1(n3) }), chainId: s2 }, expiry: n3, throwOnFailedPublish: true }).catch((h4) => p3(h4)), this.client.events.emit("session_request_sent", { topic: i2, request: t2, chainId: s2, id: o22 }), d3(); - }), new Promise(async (d3) => { - const h4 = await ht$1(this.client.core.storage, H$3); - gt$1({ id: o22, topic: i2, wcDeepLink: h4 }), d3(); - }), a3()]).then((d3) => d3[2]); - }, this.respond = async (e2) => { - await this.isInitialized(), await this.isValidRespond(e2); - const { topic: s2, response: t2 } = e2, { id: i2 } = t2; - isJsonRpcResult(t2) ? await this.sendResult({ id: i2, topic: s2, result: t2.result, throwOnFailedPublish: true }) : isJsonRpcError(t2) && await this.sendError(i2, s2, t2.error), this.cleanupAfterResponse(e2); - }, this.ping = async (e2) => { - await this.isInitialized(), await this.isValidPing(e2); - const { topic: s2 } = e2; - if (this.client.session.keys.includes(s2)) { - const t2 = await this.sendRequest({ topic: s2, method: "wc_sessionPing", params: {} }), { done: i2, resolve: n3, reject: o22 } = at$1(); - this.events.once(yt$1("session_ping", t2), ({ error: a3 }) => { - a3 ? o22(a3) : n3(); - }), await i2(); + }, this.approve = async (t2) => { + await this.isInitialized(); + try { + await this.isValidApprove(t2); + } catch (E2) { + throw this.client.logger.error("approve() -> isValidApprove() failed"), E2; + } + const { id: e2, relayProtocol: s22, namespaces: i2, sessionProperties: r3, sessionConfig: o22 } = t2; + let a3; + try { + a3 = this.client.proposal.get(e2); + } catch (E2) { + throw this.client.logger.error(`approve() -> proposal.get(${e2}) failed`), E2; + } + let { pairingTopic: c2, proposer: d5, requiredNamespaces: p2, optionalNamespaces: g3 } = a3; + c2 = c2 || ""; + const h4 = await this.client.core.crypto.generateKeyPair(), y3 = d5.publicKey, w3 = await this.client.core.crypto.generateSharedKey(h4, y3), I2 = m2(m2({ relay: { protocol: s22 ?? "irn" }, namespaces: i2, pairingTopic: c2, controller: { publicKey: h4, metadata: this.client.metadata }, expiry: d0(L$2) }, r3 && { sessionProperties: r3 }), o22 && { sessionConfig: o22 }); + await this.client.core.relayer.subscribe(w3); + const D2 = F(m2({}, I2), { topic: w3, requiredNamespaces: p2, optionalNamespaces: g3, pairingTopic: c2, acknowledged: false, self: I2.controller, peer: { publicKey: d5.publicKey, metadata: d5.metadata }, controller: h4 }); + await this.client.session.set(w3, D2); + try { + await this.sendResult({ id: e2, topic: c2, result: { relay: { protocol: s22 ?? "irn" }, responderPublicKey: h4 }, throwOnFailedPublish: true }), await this.sendRequest({ topic: w3, method: "wc_sessionSettle", params: I2, throwOnFailedPublish: true }); + } catch (E2) { + throw this.client.logger.error(E2), this.client.session.delete(w3, tr$2("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(w3), E2; + } + return await this.client.core.pairing.updateMetadata({ topic: c2, metadata: d5.metadata }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: c2 }), await this.setExpiry(w3, d0(L$2)), { topic: w3, acknowledged: () => new Promise((E2) => setTimeout(() => E2(this.client.session.get(w3)), 500)) }; + }, this.reject = async (t2) => { + await this.isInitialized(); + try { + await this.isValidReject(t2); + } catch (r3) { + throw this.client.logger.error("reject() -> isValidReject() failed"), r3; + } + const { id: e2, reason: s22 } = t2; + let i2; + try { + i2 = this.client.proposal.get(e2).pairingTopic; + } catch (r3) { + throw this.client.logger.error(`reject() -> proposal.get(${e2}) failed`), r3; + } + i2 && (await this.sendError({ id: e2, topic: i2, error: s22 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED"))); + }, this.update = async (t2) => { + await this.isInitialized(); + try { + await this.isValidUpdate(t2); + } catch (p2) { + throw this.client.logger.error("update() -> isValidUpdate() failed"), p2; + } + const { topic: e2, namespaces: s22 } = t2, { done: i2, resolve: r3, reject: o22 } = a0(), a3 = payloadId(), c2 = getBigIntRpcId().toString(), d5 = this.client.session.get(e2).namespaces; + return this.events.once(v0("session_update", a3), ({ error: p2 }) => { + p2 ? o22(p2) : r3(); + }), await this.client.session.update(e2, { namespaces: s22 }), this.sendRequest({ topic: e2, method: "wc_sessionUpdate", params: { namespaces: s22 }, throwOnFailedPublish: true, clientRpcId: a3, relayRpcId: c2 }).catch((p2) => { + this.client.logger.error(p2), this.client.session.update(e2, { namespaces: d5 }), o22(p2); + }), { acknowledged: i2 }; + }, this.extend = async (t2) => { + await this.isInitialized(); + try { + await this.isValidExtend(t2); + } catch (a3) { + throw this.client.logger.error("extend() -> isValidExtend() failed"), a3; + } + const { topic: e2 } = t2, s22 = payloadId(), { done: i2, resolve: r3, reject: o22 } = a0(); + return this.events.once(v0("session_extend", s22), ({ error: a3 }) => { + a3 ? o22(a3) : r3(); + }), await this.setExpiry(e2, d0(L$2)), this.sendRequest({ topic: e2, method: "wc_sessionExtend", params: {}, clientRpcId: s22, throwOnFailedPublish: true }).catch((a3) => { + o22(a3); + }), { acknowledged: i2 }; + }, this.request = async (t2) => { + await this.isInitialized(); + try { + await this.isValidRequest(t2); + } catch (h4) { + throw this.client.logger.error("request() -> isValidRequest() failed"), h4; + } + const { chainId: e2, request: s22, topic: i2, expiry: r3 = q$1.wc_sessionRequest.req.ttl } = t2, o22 = this.client.session.get(i2), a3 = payloadId(), c2 = getBigIntRpcId().toString(), { done: d5, resolve: p2, reject: g3 } = a0(r3, "Request expired. Please try again."); + return this.events.once(v0("session_request", a3), ({ error: h4, result: y3 }) => { + h4 ? g3(h4) : p2(y3); + }), await Promise.all([new Promise(async (h4) => { + await this.sendRequest({ clientRpcId: a3, relayRpcId: c2, topic: i2, method: "wc_sessionRequest", params: { request: F(m2({}, s22), { expiryTimestamp: d0(r3) }), chainId: e2 }, expiry: r3, throwOnFailedPublish: true }).catch((y3) => g3(y3)), this.client.events.emit("session_request_sent", { topic: i2, request: s22, chainId: e2, id: a3 }), h4(); + }), new Promise(async (h4) => { + var y3; + if (!((y3 = o22.sessionConfig) != null && y3.disableDeepLink)) { + const w3 = await g0(this.client.core.storage, Re$1); + m0({ id: a3, topic: i2, wcDeepLink: w3 }); + } + h4(); + }), d5()]).then((h4) => h4[2]); + }, this.respond = async (t2) => { + await this.isInitialized(), await this.isValidRespond(t2); + const { topic: e2, response: s22 } = t2, { id: i2 } = s22; + isJsonRpcResult(s22) ? await this.sendResult({ id: i2, topic: e2, result: s22.result, throwOnFailedPublish: true }) : isJsonRpcError(s22) && await this.sendError({ id: i2, topic: e2, error: s22.error }), this.cleanupAfterResponse(t2); + }, this.ping = async (t2) => { + await this.isInitialized(); + try { + await this.isValidPing(t2); + } catch (s22) { + throw this.client.logger.error("ping() -> isValidPing() failed"), s22; + } + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) { + const s22 = payloadId(), i2 = getBigIntRpcId().toString(), { done: r3, resolve: o22, reject: a3 } = a0(); + this.events.once(v0("session_ping", s22), ({ error: c2 }) => { + c2 ? a3(c2) : o22(); + }), await Promise.all([this.sendRequest({ topic: e2, method: "wc_sessionPing", params: {}, throwOnFailedPublish: true, clientRpcId: s22, relayRpcId: i2 }), r3()]); } else - this.client.core.pairing.pairings.keys.includes(s2) && await this.client.core.pairing.ping({ topic: s2 }); - }, this.emit = async (e2) => { - await this.isInitialized(), await this.isValidEmit(e2); - const { topic: s2, event: t2, chainId: i2 } = e2; - await this.sendRequest({ topic: s2, method: "wc_sessionEvent", params: { event: t2, chainId: i2 } }); - }, this.disconnect = async (e2) => { - await this.isInitialized(), await this.isValidDisconnect(e2); - const { topic: s2 } = e2; - if (this.client.session.keys.includes(s2)) - await this.sendRequest({ topic: s2, method: "wc_sessionDelete", params: U$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: s2, emitEvent: false }); - else if (this.client.core.pairing.pairings.keys.includes(s2)) - await this.client.core.pairing.disconnect({ topic: s2 }); + this.client.core.pairing.pairings.keys.includes(e2) && await this.client.core.pairing.ping({ topic: e2 }); + }, this.emit = async (t2) => { + await this.isInitialized(), await this.isValidEmit(t2); + const { topic: e2, event: s22, chainId: i2 } = t2, r3 = getBigIntRpcId().toString(); + await this.sendRequest({ topic: e2, method: "wc_sessionEvent", params: { event: s22, chainId: i2 }, throwOnFailedPublish: true, relayRpcId: r3 }); + }, this.disconnect = async (t2) => { + await this.isInitialized(), await this.isValidDisconnect(t2); + const { topic: e2 } = t2; + if (this.client.session.keys.includes(e2)) + await this.sendRequest({ topic: e2, method: "wc_sessionDelete", params: tr$2("USER_DISCONNECTED"), throwOnFailedPublish: true }), await this.deleteSession({ topic: e2, emitEvent: false }); + else if (this.client.core.pairing.pairings.keys.includes(e2)) + await this.client.core.pairing.disconnect({ topic: e2 }); else { - const { message: t2 } = N$1("MISMATCHED_TOPIC", `Session or pairing topic not found: ${s2}`); - throw new Error(t2); + const { message: s22 } = xe$1("MISMATCHED_TOPIC", `Session or pairing topic not found: ${e2}`); + throw new Error(s22); + } + }, this.find = (t2) => (this.isInitialized(), this.client.session.getAll().filter((e2) => Qu(e2, t2))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (t2) => { + this.isInitialized(), this.isValidAuthenticate(t2); + const { chains: e2, statement: s22 = "", uri: i2, domain: r3, nonce: o22, type: a3, exp: c2, nbf: d5, methods: p2 = [] } = t2, g3 = [...t2.resources || []], { topic: h4, uri: y3 } = await this.client.core.pairing.create({ methods: ["wc_sessionAuthenticate"] }); + this.client.logger.info({ message: "Generated new pairing", pairing: { topic: h4, uri: y3 } }); + const w3 = await this.client.core.crypto.generateKeyPair(), I2 = bu(w3); + if (await Promise.all([this.client.auth.authKeys.set(J$2, { responseTopic: I2, publicKey: w3 }), this.client.auth.pairingTopics.set(I2, { topic: I2, pairingTopic: h4 })]), await this.client.core.relayer.subscribe(I2), this.client.logger.info(`sending request to new pairing topic: ${h4}`), p2.length > 0) { + const { namespace: O3 } = dn(e2[0]); + let _3 = cu(O3, "request", p2); + Qr(g3) && (_3 = lu(_3, g3.pop())), g3.push(_3); + } + const D2 = d0(q$1.wc_sessionPropose.req.ttl), E2 = { authPayload: { type: a3 ?? "caip122", chains: e2, statement: s22, aud: i2, domain: r3, version: "1", nonce: o22, iat: (/* @__PURE__ */ new Date()).toISOString(), exp: c2, nbf: d5, resources: g3 }, requester: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, P2 = { eip155: { chains: e2, methods: [.../* @__PURE__ */ new Set(["personal_sign", ...p2])], events: ["chainChanged", "accountsChanged"] } }, f3 = { requiredNamespaces: {}, optionalNamespaces: P2, relays: [{ protocol: "irn" }], proposer: { publicKey: w3, metadata: this.client.metadata }, expiryTimestamp: D2 }, { done: v3, resolve: j2, reject: oe2 } = a0(q$1.wc_sessionAuthenticate.req.ttl, "Request expired"), B2 = async ({ error: O3, session: _3 }) => { + if (this.events.off(v0("session_request", M2), ae2), O3) + oe2(O3); + else if (_3) { + _3.self.publicKey = w3, await this.client.session.set(_3.topic, _3), await this.setExpiry(_3.topic, _3.expiry), h4 && await this.client.core.pairing.updateMetadata({ topic: h4, metadata: _3.peer.metadata }); + const Q2 = this.client.session.get(_3.topic); + j2({ session: Q2 }); + } + }, ae2 = async (O3) => { + if (O3.error) { + const z2 = tr$2("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate"); + return O3.error.code === z2.code ? void 0 : (this.events.off(v0("session_connect"), B2), oe2(O3.error.message)); + } + this.events.off(v0("session_connect"), B2); + const { cacaos: _3, responder: Q2 } = O3.result, le2 = [], Ie2 = []; + for (const z2 of _3) { + await ou({ cacao: z2, projectId: this.client.core.projectId }) || (this.client.logger.error(z2, "Signature verification failed"), oe2(tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"))); + const { p: he2 } = z2, pe2 = Qr(he2.resources), fe2 = [fu(he2.iss)], Ze2 = Li(he2.iss); + if (pe2) { + const de2 = du(pe2), et2 = pu(pe2); + le2.push(...de2), fe2.push(...et2); + } + for (const de2 of fe2) + Ie2.push(`${de2}:${Ze2}`); + } + const W2 = await this.client.core.crypto.generateSharedKey(w3, Q2.publicKey); + let Z22; + le2.length > 0 && (Z22 = { topic: W2, acknowledged: true, self: { publicKey: w3, metadata: this.client.metadata }, peer: Q2, controller: Q2.publicKey, expiry: d0(L$2), requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: h4, namespaces: ju([...new Set(le2)], [...new Set(Ie2)]) }, await this.client.core.relayer.subscribe(W2), await this.client.session.set(W2, Z22), Z22 = this.client.session.get(W2)), j2({ auths: _3, session: Z22 }); + }, M2 = payloadId(), ce2 = payloadId(); + this.events.once(v0("session_connect"), B2), this.events.once(v0("session_request", M2), ae2); + try { + await Promise.all([this.sendRequest({ topic: h4, method: "wc_sessionAuthenticate", params: E2, expiry: t2.expiry, throwOnFailedPublish: true, clientRpcId: M2 }), this.sendRequest({ topic: h4, method: "wc_sessionPropose", params: f3, expiry: q$1.wc_sessionPropose.req.ttl, throwOnFailedPublish: true, clientRpcId: ce2 })]); + } catch (O3) { + throw this.events.off(v0("session_connect"), B2), this.events.off(v0("session_request", M2), ae2), O3; } - }, this.find = (e2) => (this.isInitialized(), this.client.session.getAll().filter((s2) => Mt$1(s2, e2))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.cleanupDuplicatePairings = async (e2) => { - if (e2.pairingTopic) + return await this.setProposal(ce2, m2({ id: ce2 }, f3)), await this.client.auth.requests.set(M2, { authPayload: E2.authPayload, requester: E2.requester, expiryTimestamp: D2, id: M2, pairingTopic: h4, verifyContext: {} }), { uri: y3, response: v3 }; + }, this.approveSessionAuthenticate = async (t2) => { + this.isInitialized(); + const { id: e2, auths: s22 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o22 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o22 }, d5 = [], p2 = []; + for (const y3 of s22) { + if (!await ou({ cacao: y3, projectId: this.client.core.projectId })) { + const P2 = tr$2("SESSION_SETTLEMENT_FAILED", "Signature verification failed"); + throw await this.sendError({ id: e2, topic: a3, error: P2, encodeOpts: c2 }), new Error(P2.message); + } + const { p: w3 } = y3, I2 = Qr(w3.resources), D2 = [fu(w3.iss)], E2 = Li(w3.iss); + if (I2) { + const P2 = du(I2), f3 = pu(I2); + d5.push(...P2), D2.push(...f3); + } + for (const P2 of D2) + p2.push(`${P2}:${E2}`); + } + const g3 = await this.client.core.crypto.generateSharedKey(o22, r3); + let h4; + return (d5 == null ? void 0 : d5.length) > 0 && (h4 = { topic: g3, acknowledged: true, self: { publicKey: o22, metadata: this.client.metadata }, peer: { publicKey: r3, metadata: i2.requester.metadata }, controller: r3, expiry: d0(L$2), authentication: s22, requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: "", namespaces: ju([...new Set(d5)], [...new Set(p2)]) }, await this.client.core.relayer.subscribe(g3), await this.client.session.set(g3, h4)), await this.sendResult({ topic: a3, id: e2, result: { cacaos: s22, responder: { publicKey: o22, metadata: this.client.metadata } }, encodeOpts: c2, throwOnFailedPublish: true }), await this.client.auth.requests.delete(e2, { message: "fullfilled", code: 0 }), await this.client.core.pairing.activate({ topic: i2.pairingTopic }), { session: h4 }; + }, this.rejectSessionAuthenticate = async (t2) => { + await this.isInitialized(); + const { id: e2, reason: s22 } = t2, i2 = this.getPendingAuthRequest(e2); + if (!i2) + throw new Error(`Could not find pending auth request with id ${e2}`); + const r3 = i2.requester.publicKey, o22 = await this.client.core.crypto.generateKeyPair(), a3 = bu(r3), c2 = { type: lr$1, receiverPublicKey: r3, senderPublicKey: o22 }; + await this.sendError({ id: e2, topic: a3, error: s22, encodeOpts: c2 }), await this.client.auth.requests.delete(e2, { message: "rejected", code: 0 }), await this.client.proposal.delete(e2, tr$2("USER_DISCONNECTED")); + }, this.formatAuthMessage = (t2) => { + this.isInitialized(); + const { request: e2, iss: s22 } = t2; + return zf(e2, s22); + }, this.cleanupDuplicatePairings = async (t2) => { + if (t2.pairingTopic) try { - const s2 = this.client.core.pairing.pairings.get(e2.pairingTopic), t2 = this.client.core.pairing.pairings.getAll().filter((i2) => { - var n3, o22; - return ((n3 = i2.peerMetadata) == null ? void 0 : n3.url) && ((o22 = i2.peerMetadata) == null ? void 0 : o22.url) === e2.peer.metadata.url && i2.topic && i2.topic !== s2.topic; + const e2 = this.client.core.pairing.pairings.get(t2.pairingTopic), s22 = this.client.core.pairing.pairings.getAll().filter((i2) => { + var r3, o22; + return ((r3 = i2.peerMetadata) == null ? void 0 : r3.url) && ((o22 = i2.peerMetadata) == null ? void 0 : o22.url) === t2.peer.metadata.url && i2.topic && i2.topic !== e2.topic; }); - if (t2.length === 0) + if (s22.length === 0) return; - this.client.logger.info(`Cleaning up ${t2.length} duplicate pairing(s)`), await Promise.all(t2.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); - } catch (s2) { - this.client.logger.error(s2); - } - }, this.deleteSession = async (e2) => { - const { topic: s2, expirerHasDeleted: t2 = false, emitEvent: i2 = true, id: n3 = 0 } = e2, { self: o22 } = this.client.session.get(s2); - await this.client.core.relayer.unsubscribe(s2), await this.client.session.delete(s2, U$2("USER_DISCONNECTED")), this.client.core.crypto.keychain.has(o22.publicKey) && await this.client.core.crypto.deleteKeyPair(o22.publicKey), this.client.core.crypto.keychain.has(s2) && await this.client.core.crypto.deleteSymKey(s2), t2 || this.client.core.expirer.del(s2), this.client.core.storage.removeItem(H$3).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { - a3.topic === s2 && this.deletePendingSessionRequest(a3.id, U$2("USER_DISCONNECTED")); - }), i2 && this.client.events.emit("session_delete", { id: n3, topic: s2 }); - }, this.deleteProposal = async (e2, s2) => { - await Promise.all([this.client.proposal.delete(e2, U$2("USER_DISCONNECTED")), s2 ? Promise.resolve() : this.client.core.expirer.del(e2)]); - }, this.deletePendingSessionRequest = async (e2, s2, t2 = false) => { - await Promise.all([this.client.pendingRequest.delete(e2, s2), t2 ? Promise.resolve() : this.client.core.expirer.del(e2)]), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== e2), t2 && (this.sessionRequestQueue.state = I$2.idle, this.client.events.emit("session_request_expire", { id: e2 })); - }, this.setExpiry = async (e2, s2) => { - this.client.session.keys.includes(e2) && await this.client.session.update(e2, { expiry: s2 }), this.client.core.expirer.set(e2, s2); - }, this.setProposal = async (e2, s2) => { - await this.client.proposal.set(e2, s2), this.client.core.expirer.set(e2, pt$1(R$5.wc_sessionPropose.req.ttl)); - }, this.setPendingSessionRequest = async (e2) => { - const { id: s2, topic: t2, params: i2, verifyContext: n3 } = e2, o22 = i2.request.expiryTimestamp || pt$1(R$5.wc_sessionRequest.req.ttl); - await this.client.pendingRequest.set(s2, { id: s2, topic: t2, params: i2, verifyContext: n3 }), o22 && this.client.core.expirer.set(s2, o22); - }, this.sendRequest = async (e2) => { - const { topic: s2, method: t2, params: i2, expiry: n3, relayRpcId: o22, clientRpcId: a3, throwOnFailedPublish: c2 } = e2, p3 = formatJsonRpcRequest(t2, i2, a3); - if (D$2() && he$2.includes(t2)) { - const N2 = Ln(JSON.stringify(p3)); - this.client.core.verify.register({ attestationId: N2 }); - } - const d3 = await this.client.core.crypto.encode(s2, p3), h4 = R$5[t2].req; - return n3 && (h4.ttl = n3), o22 && (h4.id = o22), this.client.core.history.set(s2, p3), c2 ? (h4.internal = D$5(g$1({}, h4.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s2, d3, h4)) : this.client.core.relayer.publish(s2, d3, h4).catch((N2) => this.client.logger.error(N2)), p3.id; - }, this.sendResult = async (e2) => { - const { id: s2, topic: t2, result: i2, throwOnFailedPublish: n3 } = e2, o22 = formatJsonRpcResult(s2, i2), a3 = await this.client.core.crypto.encode(t2, o22), c2 = await this.client.core.history.get(t2, s2), p3 = R$5[c2.request.method].res; - n3 ? (p3.internal = D$5(g$1({}, p3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(t2, a3, p3)) : this.client.core.relayer.publish(t2, a3, p3).catch((d3) => this.client.logger.error(d3)), await this.client.core.history.resolve(o22); - }, this.sendError = async (e2, s2, t2) => { - const i2 = formatJsonRpcError(e2, t2), n3 = await this.client.core.crypto.encode(s2, i2), o22 = await this.client.core.history.get(s2, e2), a3 = R$5[o22.request.method].res; - this.client.core.relayer.publish(s2, n3, a3), await this.client.core.history.resolve(i2); + this.client.logger.info(`Cleaning up ${s22.length} duplicate pairing(s)`), await Promise.all(s22.map((i2) => this.client.core.pairing.disconnect({ topic: i2.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); + } catch (e2) { + this.client.logger.error(e2); + } + }, this.deleteSession = async (t2) => { + const { topic: e2, expirerHasDeleted: s22 = false, emitEvent: i2 = true, id: r3 = 0 } = t2, { self: o22 } = this.client.session.get(e2); + await this.client.core.relayer.unsubscribe(e2), await this.client.session.delete(e2, tr$2("USER_DISCONNECTED")), this.addToRecentlyDeleted(e2, "session"), this.client.core.crypto.keychain.has(o22.publicKey) && await this.client.core.crypto.deleteKeyPair(o22.publicKey), this.client.core.crypto.keychain.has(e2) && await this.client.core.crypto.deleteSymKey(e2), s22 || this.client.core.expirer.del(e2), this.client.core.storage.removeItem(Re$1).catch((a3) => this.client.logger.warn(a3)), this.getPendingSessionRequests().forEach((a3) => { + a3.topic === e2 && this.deletePendingSessionRequest(a3.id, tr$2("USER_DISCONNECTED")); + }), i2 && this.client.events.emit("session_delete", { id: r3, topic: e2 }); + }, this.deleteProposal = async (t2, e2) => { + await Promise.all([this.client.proposal.delete(t2, tr$2("USER_DISCONNECTED")), e2 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "proposal"); + }, this.deletePendingSessionRequest = async (t2, e2, s22 = false) => { + await Promise.all([this.client.pendingRequest.delete(t2, e2), s22 ? Promise.resolve() : this.client.core.expirer.del(t2)]), this.addToRecentlyDeleted(t2, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((i2) => i2.id !== t2), s22 && (this.sessionRequestQueue.state = A$1.idle, this.client.events.emit("session_request_expire", { id: t2 })); + }, this.setExpiry = async (t2, e2) => { + this.client.session.keys.includes(t2) && await this.client.session.update(t2, { expiry: e2 }), this.client.core.expirer.set(t2, e2); + }, this.setProposal = async (t2, e2) => { + await this.client.proposal.set(t2, e2), this.client.core.expirer.set(t2, d0(q$1.wc_sessionPropose.req.ttl)); + }, this.setPendingSessionRequest = async (t2) => { + const { id: e2, topic: s22, params: i2, verifyContext: r3 } = t2, o22 = i2.request.expiryTimestamp || d0(q$1.wc_sessionRequest.req.ttl); + await this.client.pendingRequest.set(e2, { id: e2, topic: s22, params: i2, verifyContext: r3 }), o22 && this.client.core.expirer.set(e2, o22); + }, this.sendRequest = async (t2) => { + const { topic: e2, method: s22, params: i2, expiry: r3, relayRpcId: o22, clientRpcId: a3, throwOnFailedPublish: c2 } = t2, d5 = formatJsonRpcRequest(s22, i2, a3); + if (pr$1() && je$2.includes(s22)) { + const h4 = yu(JSON.stringify(d5)); + this.client.core.verify.register({ attestationId: h4 }); + } + let p2; + try { + p2 = await this.client.core.crypto.encode(e2, d5); + } catch (h4) { + throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e2} failed`), h4; + } + const g3 = q$1[s22].req; + return r3 && (g3.ttl = r3), o22 && (g3.id = o22), this.client.core.history.set(e2, d5), c2 ? (g3.internal = F(m2({}, g3.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(e2, p2, g3)) : this.client.core.relayer.publish(e2, p2, g3).catch((h4) => this.client.logger.error(h4)), d5.id; + }, this.sendResult = async (t2) => { + const { id: e2, topic: s22, result: i2, throwOnFailedPublish: r3, encodeOpts: o22 } = t2, a3 = formatJsonRpcResult(e2, i2); + let c2; + try { + c2 = await this.client.core.crypto.encode(s22, a3, o22); + } catch (g3) { + throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s22} failed`), g3; + } + let d5; + try { + d5 = await this.client.core.history.get(s22, e2); + } catch (g3) { + throw this.client.logger.error(`sendResult() -> history.get(${s22}, ${e2}) failed`), g3; + } + const p2 = q$1[d5.request.method].res; + r3 ? (p2.internal = F(m2({}, p2.internal), { throwOnFailedPublish: true }), await this.client.core.relayer.publish(s22, c2, p2)) : this.client.core.relayer.publish(s22, c2, p2).catch((g3) => this.client.logger.error(g3)), await this.client.core.history.resolve(a3); + }, this.sendError = async (t2) => { + const { id: e2, topic: s22, error: i2, encodeOpts: r3 } = t2, o22 = formatJsonRpcError(e2, i2); + let a3; + try { + a3 = await this.client.core.crypto.encode(s22, o22, r3); + } catch (p2) { + throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s22} failed`), p2; + } + let c2; + try { + c2 = await this.client.core.history.get(s22, e2); + } catch (p2) { + throw this.client.logger.error(`sendError() -> history.get(${s22}, ${e2}) failed`), p2; + } + const d5 = q$1[c2.request.method].res; + this.client.core.relayer.publish(s22, a3, d5), await this.client.core.history.resolve(o22); }, this.cleanup = async () => { - const e2 = [], s2 = []; - this.client.session.getAll().forEach((t2) => { + const t2 = [], e2 = []; + this.client.session.getAll().forEach((s22) => { let i2 = false; - mt$1(t2.expiry) && (i2 = true), this.client.core.crypto.keychain.has(t2.topic) || (i2 = true), i2 && e2.push(t2.topic); - }), this.client.proposal.getAll().forEach((t2) => { - mt$1(t2.expiryTimestamp) && s2.push(t2.id); - }), await Promise.all([...e2.map((t2) => this.deleteSession({ topic: t2 })), ...s2.map((t2) => this.deleteProposal(t2))]); - }, this.onRelayEventRequest = async (e2) => { - this.requestQueue.queue.push(e2), await this.processRequestsQueue(); + p0(s22.expiry) && (i2 = true), this.client.core.crypto.keychain.has(s22.topic) || (i2 = true), i2 && t2.push(s22.topic); + }), this.client.proposal.getAll().forEach((s22) => { + p0(s22.expiryTimestamp) && e2.push(s22.id); + }), await Promise.all([...t2.map((s22) => this.deleteSession({ topic: s22 })), ...e2.map((s22) => this.deleteProposal(s22))]); + }, this.onRelayEventRequest = async (t2) => { + this.requestQueue.queue.push(t2), await this.processRequestsQueue(); }, this.processRequestsQueue = async () => { - if (this.requestQueue.state === I$2.active) { + if (this.requestQueue.state === A$1.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 = I$2.active; - const e2 = this.requestQueue.queue.shift(); - if (e2) + this.requestQueue.state = A$1.active; + const t2 = this.requestQueue.queue.shift(); + if (t2) try { - this.processRequest(e2), await new Promise((s2) => setTimeout(s2, 300)); - } catch (s2) { - this.client.logger.warn(s2); + this.processRequest(t2), await new Promise((e2) => setTimeout(e2, 300)); + } catch (e2) { + this.client.logger.warn(e2); } } - this.requestQueue.state = I$2.idle; - }, this.processRequest = (e2) => { - const { topic: s2, payload: t2 } = e2, i2 = t2.method; - switch (i2) { - case "wc_sessionPropose": - return this.onSessionProposeRequest(s2, t2); - case "wc_sessionSettle": - return this.onSessionSettleRequest(s2, t2); - case "wc_sessionUpdate": - return this.onSessionUpdateRequest(s2, t2); - case "wc_sessionExtend": - return this.onSessionExtendRequest(s2, t2); - case "wc_sessionPing": - return this.onSessionPingRequest(s2, t2); - case "wc_sessionDelete": - return this.onSessionDeleteRequest(s2, t2); - case "wc_sessionRequest": - return this.onSessionRequest(s2, t2); - case "wc_sessionEvent": - return this.onSessionEventRequest(s2, t2); - default: - return this.client.logger.info(`Unsupported request method ${i2}`); - } - }, this.onRelayEventResponse = async (e2) => { - const { topic: s2, payload: t2 } = e2, i2 = (await this.client.core.history.get(s2, t2.id)).request.method; + this.requestQueue.state = A$1.idle; + }, this.processRequest = (t2) => { + const { topic: e2, payload: s22 } = t2, i2 = s22.method; + if (!this.shouldIgnorePairingRequest({ topic: e2, requestMethod: i2 })) + switch (i2) { + case "wc_sessionPropose": + return this.onSessionProposeRequest(e2, s22); + case "wc_sessionSettle": + return this.onSessionSettleRequest(e2, s22); + case "wc_sessionUpdate": + return this.onSessionUpdateRequest(e2, s22); + case "wc_sessionExtend": + return this.onSessionExtendRequest(e2, s22); + case "wc_sessionPing": + return this.onSessionPingRequest(e2, s22); + case "wc_sessionDelete": + return this.onSessionDeleteRequest(e2, s22); + case "wc_sessionRequest": + return this.onSessionRequest(e2, s22); + case "wc_sessionEvent": + return this.onSessionEventRequest(e2, s22); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateRequest(e2, s22); + default: + return this.client.logger.info(`Unsupported request method ${i2}`); + } + }, this.onRelayEventResponse = async (t2) => { + const { topic: e2, payload: s22 } = t2, i2 = (await this.client.core.history.get(e2, s22.id)).request.method; switch (i2) { case "wc_sessionPropose": - return this.onSessionProposeResponse(s2, t2); + return this.onSessionProposeResponse(e2, s22); case "wc_sessionSettle": - return this.onSessionSettleResponse(s2, t2); + return this.onSessionSettleResponse(e2, s22); case "wc_sessionUpdate": - return this.onSessionUpdateResponse(s2, t2); + return this.onSessionUpdateResponse(e2, s22); case "wc_sessionExtend": - return this.onSessionExtendResponse(s2, t2); + return this.onSessionExtendResponse(e2, s22); case "wc_sessionPing": - return this.onSessionPingResponse(s2, t2); + return this.onSessionPingResponse(e2, s22); case "wc_sessionRequest": - return this.onSessionRequestResponse(s2, t2); + return this.onSessionRequestResponse(e2, s22); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateResponse(e2, s22); default: return this.client.logger.info(`Unsupported response method ${i2}`); } - }, this.onRelayEventUnknownPayload = (e2) => { - const { topic: s2 } = e2, { message: t2 } = N$1("MISSING_OR_INVALID", `Decoded payload on topic ${s2} is not identifiable as a JSON-RPC request or a response.`); - throw new Error(t2); - }, this.onSessionProposeRequest = async (e2, s2) => { - const { params: t2, id: i2 } = s2; + }, this.onRelayEventUnknownPayload = (t2) => { + const { topic: e2 } = t2, { message: s22 } = xe$1("MISSING_OR_INVALID", `Decoded payload on topic ${e2} is not identifiable as a JSON-RPC request or a response.`); + throw new Error(s22); + }, this.shouldIgnorePairingRequest = (t2) => { + const { topic: e2, requestMethod: s22 } = t2, i2 = this.expectedPairingMethodMap.get(e2); + return !i2 || i2.includes(s22) ? false : !!(i2.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0); + }, this.onSessionProposeRequest = async (t2, e2) => { + const { params: s22, id: i2 } = e2; try { - this.isValidConnect(g$1({}, s2.params)); - const n3 = t2.expiryTimestamp || pt$1(R$5.wc_sessionPropose.req.ttl), o22 = g$1({ id: i2, pairingTopic: e2, expiryTimestamp: n3 }, t2); + this.isValidConnect(m2({}, e2.params)); + const r3 = s22.expiryTimestamp || d0(q$1.wc_sessionPropose.req.ttl), o22 = m2({ id: i2, pairingTopic: t2, expiryTimestamp: r3 }, s22); await this.setProposal(i2, o22); - const a3 = Ln(JSON.stringify(s2)), c2 = await this.getVerifyContext(a3, o22.proposer.metadata); + const a3 = yu(JSON.stringify(e2)), c2 = await this.getVerifyContext(a3, o22.proposer.metadata); this.client.events.emit("session_proposal", { id: i2, params: o22, verifyContext: c2 }); - } catch (n3) { - await this.sendError(i2, e2, n3), this.client.logger.error(n3); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); } - }, this.onSessionProposeResponse = async (e2, s2) => { - const { id: t2 } = s2; - if (isJsonRpcResult(s2)) { - const { result: i2 } = s2; + }, this.onSessionProposeResponse = async (t2, e2) => { + const { id: s22 } = e2; + if (isJsonRpcResult(e2)) { + const { result: i2 } = e2; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: i2 }); - const n3 = this.client.proposal.get(t2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: n3 }); - const o22 = n3.proposer.publicKey; + const r3 = this.client.proposal.get(s22); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: r3 }); + const o22 = r3.proposer.publicKey; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: o22 }); const a3 = i2.responderPublicKey; this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: a3 }); const c2 = await this.client.core.crypto.generateSharedKey(o22, a3); this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: c2 }); - const p3 = await this.client.core.relayer.subscribe(c2); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: p3 }), await this.client.core.pairing.activate({ topic: e2 }); - } else - isJsonRpcError(s2) && (await this.client.proposal.delete(t2, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_connect"), { error: s2.error })); - }, this.onSessionSettleRequest = async (e2, s2) => { - const { id: t2, params: i2 } = s2; + const d5 = await this.client.core.relayer.subscribe(c2); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: d5 }), await this.client.core.pairing.activate({ topic: t2 }); + } else if (isJsonRpcError(e2)) { + await this.client.proposal.delete(s22, tr$2("USER_DISCONNECTED")); + const i2 = v0("session_connect"); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners, 954`); + this.events.emit(v0("session_connect"), { error: e2.error }); + } + }, this.onSessionSettleRequest = async (t2, e2) => { + const { id: s22, params: i2 } = e2; try { this.isValidSessionSettleRequest(i2); - const { relay: n3, controller: o22, expiry: a3, namespaces: c2, sessionProperties: p3, pairingTopic: d3 } = s2.params, h4 = g$1({ topic: e2, relay: n3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: d3, requiredNamespaces: {}, optionalNamespaces: {}, controller: o22.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o22.publicKey, metadata: o22.metadata } }, p3 && { sessionProperties: p3 }); - await this.sendResult({ id: s2.id, topic: e2, result: true }), this.events.emit(yt$1("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); - } catch (n3) { - await this.sendError(t2, e2, n3), this.client.logger.error(n3); - } - }, this.onSessionSettleResponse = async (e2, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? (await this.client.session.update(e2, { acknowledged: true }), this.events.emit(yt$1("session_approve", t2), {})) : isJsonRpcError(s2) && (await this.client.session.delete(e2, U$2("USER_DISCONNECTED")), this.events.emit(yt$1("session_approve", t2), { error: s2.error })); - }, this.onSessionUpdateRequest = async (e2, s2) => { - const { params: t2, id: i2 } = s2; + const { relay: r3, controller: o22, expiry: a3, namespaces: c2, sessionProperties: d5, pairingTopic: p2, sessionConfig: g3 } = e2.params, h4 = m2(m2({ topic: t2, relay: r3, expiry: a3, namespaces: c2, acknowledged: true, pairingTopic: p2, requiredNamespaces: {}, optionalNamespaces: {}, controller: o22.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: o22.publicKey, metadata: o22.metadata } }, d5 && { sessionProperties: d5 }), g3 && { sessionConfig: g3 }); + await this.sendResult({ id: e2.id, topic: t2, result: true, throwOnFailedPublish: true }); + const y3 = v0("session_connect"); + if (this.events.listenerCount(y3) === 0) + throw new Error(`emitting ${y3} without any listeners 997`); + this.events.emit(v0("session_connect"), { session: h4 }), this.cleanupDuplicatePairings(h4); + } catch (r3) { + await this.sendError({ id: s22, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionSettleResponse = async (t2, e2) => { + const { id: s22 } = e2; + isJsonRpcResult(e2) ? (await this.client.session.update(t2, { acknowledged: true }), this.events.emit(v0("session_approve", s22), {})) : isJsonRpcError(e2) && (await this.client.session.delete(t2, tr$2("USER_DISCONNECTED")), this.events.emit(v0("session_approve", s22), { error: e2.error })); + }, this.onSessionUpdateRequest = async (t2, e2) => { + const { params: s22, id: i2 } = e2; try { - const n3 = `${e2}_session_update`, o22 = sr$1.get(n3); + const r3 = `${t2}_session_update`, o22 = lh.get(r3); if (o22 && this.isRequestOutOfSync(o22, i2)) { - this.client.logger.info(`Discarding out of sync request - ${i2}`); + this.client.logger.info(`Discarding out of sync request - ${i2}`), this.sendError({ id: i2, topic: t2, error: tr$2("INVALID_UPDATE_REQUEST") }); return; } - this.isValidUpdate(g$1({ topic: e2 }, t2)), await this.client.session.update(e2, { namespaces: t2.namespaces }), await this.sendResult({ id: i2, topic: e2, result: true }), this.client.events.emit("session_update", { id: i2, topic: e2, params: t2 }), sr$1.set(n3, i2); - } catch (n3) { - await this.sendError(i2, e2, n3), this.client.logger.error(n3); - } - }, this.isRequestOutOfSync = (e2, s2) => parseInt(s2.toString().slice(0, -3)) <= parseInt(e2.toString().slice(0, -3)), this.onSessionUpdateResponse = (e2, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_update", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_update", t2), { error: s2.error }); - }, this.onSessionExtendRequest = async (e2, s2) => { - const { id: t2 } = s2; + this.isValidUpdate(m2({ topic: t2 }, s22)); + try { + lh.set(r3, i2), await this.client.session.update(t2, { namespaces: s22.namespaces }), await this.sendResult({ id: i2, topic: t2, result: true, throwOnFailedPublish: true }); + } catch (a3) { + throw lh.delete(r3), a3; + } + this.client.events.emit("session_update", { id: i2, topic: t2, params: s22 }); + } catch (r3) { + await this.sendError({ id: i2, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.isRequestOutOfSync = (t2, e2) => parseInt(e2.toString().slice(0, -3)) <= parseInt(t2.toString().slice(0, -3)), this.onSessionUpdateResponse = (t2, e2) => { + const { id: s22 } = e2, i2 = v0("session_update", s22); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_update", s22), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_update", s22), { error: e2.error }); + }, this.onSessionExtendRequest = async (t2, e2) => { + const { id: s22 } = e2; try { - this.isValidExtend({ topic: e2 }), await this.setExpiry(e2, pt$1(L)), await this.sendResult({ id: t2, topic: e2, result: true }), this.client.events.emit("session_extend", { id: t2, topic: e2 }); + this.isValidExtend({ topic: t2 }), await this.setExpiry(t2, d0(L$2)), await this.sendResult({ id: s22, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_extend", { id: s22, topic: t2 }); } catch (i2) { - await this.sendError(t2, e2, i2), this.client.logger.error(i2); - } - }, this.onSessionExtendResponse = (e2, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_extend", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_extend", t2), { error: s2.error }); - }, this.onSessionPingRequest = async (e2, s2) => { - const { id: t2 } = s2; + await this.sendError({ id: s22, topic: t2, error: i2 }), this.client.logger.error(i2); + } + }, this.onSessionExtendResponse = (t2, e2) => { + const { id: s22 } = e2, i2 = v0("session_extend", s22); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_extend", s22), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_extend", s22), { error: e2.error }); + }, this.onSessionPingRequest = async (t2, e2) => { + const { id: s22 } = e2; try { - this.isValidPing({ topic: e2 }), await this.sendResult({ id: t2, topic: e2, result: true }), this.client.events.emit("session_ping", { id: t2, topic: e2 }); + this.isValidPing({ topic: t2 }), await this.sendResult({ id: s22, topic: t2, result: true, throwOnFailedPublish: true }), this.client.events.emit("session_ping", { id: s22, topic: t2 }); } catch (i2) { - await this.sendError(t2, e2, i2), this.client.logger.error(i2); + await this.sendError({ id: s22, topic: t2, error: i2 }), this.client.logger.error(i2); } - }, this.onSessionPingResponse = (e2, s2) => { - const { id: t2 } = s2; + }, this.onSessionPingResponse = (t2, e2) => { + const { id: s22 } = e2, i2 = v0("session_ping", s22); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); setTimeout(() => { - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_ping", t2), {}) : isJsonRpcError(s2) && this.events.emit(yt$1("session_ping", t2), { error: s2.error }); + isJsonRpcResult(e2) ? this.events.emit(v0("session_ping", s22), {}) : isJsonRpcError(e2) && this.events.emit(v0("session_ping", s22), { error: e2.error }); }, 500); - }, this.onSessionDeleteRequest = async (e2, s2) => { - const { id: t2 } = s2; + }, this.onSessionDeleteRequest = async (t2, e2) => { + const { id: s22 } = e2; try { - this.isValidDisconnect({ topic: e2, reason: s2.params }), await Promise.all([new Promise((i2) => { - this.client.core.relayer.once(D$1$1.publish, async () => { - i2(await this.deleteSession({ topic: e2, id: t2 })); + this.isValidDisconnect({ topic: t2, reason: e2.params }), await Promise.all([new Promise((i2) => { + this.client.core.relayer.once(v2.publish, async () => { + i2(await this.deleteSession({ topic: t2, id: s22 })); }); - }), this.sendResult({ id: t2, topic: e2, result: true }), this.cleanupPendingSentRequestsForTopic({ topic: e2, error: U$2("USER_DISCONNECTED") })]); + }), this.sendResult({ id: s22, topic: t2, result: true, throwOnFailedPublish: true }), this.cleanupPendingSentRequestsForTopic({ topic: t2, error: tr$2("USER_DISCONNECTED") })]); } catch (i2) { this.client.logger.error(i2); } - }, this.onSessionRequest = async (e2, s2) => { - const { id: t2, params: i2 } = s2; + }, this.onSessionRequest = async (t2, e2) => { + const { id: s22, params: i2 } = e2; try { - this.isValidRequest(g$1({ topic: e2 }, i2)); - const n3 = Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, t2))), o22 = this.client.session.get(e2), a3 = await this.getVerifyContext(n3, o22.peer.metadata), c2 = { id: t2, topic: e2, params: i2, verifyContext: a3 }; + await this.isValidRequest(m2({ topic: t2 }, i2)); + const r3 = yu(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest", i2, s22))), o22 = this.client.session.get(t2), a3 = await this.getVerifyContext(r3, o22.peer.metadata), c2 = { id: s22, topic: t2, params: i2, verifyContext: a3 }; await this.setPendingSessionRequest(c2), this.addSessionRequestToSessionRequestQueue(c2), this.processSessionRequestQueue(); - } catch (n3) { - await this.sendError(t2, e2, n3), this.client.logger.error(n3); - } - }, this.onSessionRequestResponse = (e2, s2) => { - const { id: t2 } = s2; - isJsonRpcResult(s2) ? this.events.emit(yt$1("session_request", t2), { result: s2.result }) : isJsonRpcError(s2) && this.events.emit(yt$1("session_request", t2), { error: s2.error }); - }, this.onSessionEventRequest = async (e2, s2) => { - const { id: t2, params: i2 } = s2; + } catch (r3) { + await this.sendError({ id: s22, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionRequestResponse = (t2, e2) => { + const { id: s22 } = e2, i2 = v0("session_request", s22); + if (this.events.listenerCount(i2) === 0) + throw new Error(`emitting ${i2} without any listeners`); + isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s22), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s22), { error: e2.error }); + }, this.onSessionEventRequest = async (t2, e2) => { + const { id: s22, params: i2 } = e2; try { - const n3 = `${e2}_session_event_${i2.event.name}`, o22 = sr$1.get(n3); - if (o22 && this.isRequestOutOfSync(o22, t2)) { - this.client.logger.info(`Discarding out of sync request - ${t2}`); + const r3 = `${t2}_session_event_${i2.event.name}`, o22 = lh.get(r3); + if (o22 && this.isRequestOutOfSync(o22, s22)) { + this.client.logger.info(`Discarding out of sync request - ${s22}`); return; } - this.isValidEmit(g$1({ topic: e2 }, i2)), this.client.events.emit("session_event", { id: t2, topic: e2, params: i2 }), sr$1.set(n3, t2); - } catch (n3) { - await this.sendError(t2, e2, n3), this.client.logger.error(n3); - } - }, this.addSessionRequestToSessionRequestQueue = (e2) => { - this.sessionRequestQueue.queue.push(e2); - }, this.cleanupAfterResponse = (e2) => { - this.deletePendingSessionRequest(e2.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { - this.sessionRequestQueue.state = I$2.idle, this.processSessionRequestQueue(); - }, cjs$4.toMiliseconds(this.requestQueueDelay)); - }, this.cleanupPendingSentRequestsForTopic = ({ topic: e2, error: s2 }) => { - const t2 = this.client.core.history.pending; - t2.length > 0 && t2.filter((i2) => i2.topic === e2 && i2.request.method === "wc_sessionRequest").forEach((i2) => { - this.events.emit(yt$1("session_request", i2.request.id), { error: s2 }); + this.isValidEmit(m2({ topic: t2 }, i2)), this.client.events.emit("session_event", { id: s22, topic: t2, params: i2 }), lh.set(r3, s22); + } catch (r3) { + await this.sendError({ id: s22, topic: t2, error: r3 }), this.client.logger.error(r3); + } + }, this.onSessionAuthenticateResponse = (t2, e2) => { + const { id: s22 } = e2; + this.client.logger.trace({ type: "method", method: "onSessionAuthenticateResponse", topic: t2, payload: e2 }), isJsonRpcResult(e2) ? this.events.emit(v0("session_request", s22), { result: e2.result }) : isJsonRpcError(e2) && this.events.emit(v0("session_request", s22), { error: e2.error }); + }, this.onSessionAuthenticateRequest = async (t2, e2) => { + const { requester: s22, authPayload: i2, expiryTimestamp: r3 } = e2.params, o22 = yu(JSON.stringify(e2)), a3 = await this.getVerifyContext(o22, this.client.metadata), c2 = { requester: s22, pairingTopic: t2, id: e2.id, authPayload: i2, verifyContext: a3, expiryTimestamp: r3 }; + await this.client.auth.requests.set(e2.id, c2), this.client.events.emit("session_authenticate", { topic: t2, params: e2.params, id: e2.id }); + }, this.addSessionRequestToSessionRequestQueue = (t2) => { + this.sessionRequestQueue.queue.push(t2); + }, this.cleanupAfterResponse = (t2) => { + this.deletePendingSessionRequest(t2.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { + this.sessionRequestQueue.state = A$1.idle, this.processSessionRequestQueue(); + }, cjs$3.toMiliseconds(this.requestQueueDelay)); + }, this.cleanupPendingSentRequestsForTopic = ({ topic: t2, error: e2 }) => { + const s22 = this.client.core.history.pending; + s22.length > 0 && s22.filter((i2) => i2.topic === t2 && i2.request.method === "wc_sessionRequest").forEach((i2) => { + const r3 = i2.request.id, o22 = v0("session_request", r3); + if (this.events.listenerCount(o22) === 0) + throw new Error(`emitting ${o22} without any listeners`); + this.events.emit(v0("session_request", i2.request.id), { error: e2 }); }); }, this.processSessionRequestQueue = () => { - if (this.sessionRequestQueue.state === I$2.active) { + if (this.sessionRequestQueue.state === A$1.active) { this.client.logger.info("session request queue is already active."); return; } - const e2 = this.sessionRequestQueue.queue[0]; - if (!e2) { + const t2 = this.sessionRequestQueue.queue[0]; + if (!t2) { this.client.logger.info("session request queue is empty."); return; } try { - this.sessionRequestQueue.state = I$2.active, this.client.events.emit("session_request", e2); - } catch (s2) { - this.client.logger.error(s2); + this.sessionRequestQueue.state = A$1.active, this.client.events.emit("session_request", t2); + } catch (e2) { + this.client.logger.error(e2); } - }, this.onPairingCreated = (e2) => { - if (e2.active) + }, this.onPairingCreated = (t2) => { + if (t2.methods && this.expectedPairingMethodMap.set(t2.topic, t2.methods), t2.active) return; - const s2 = this.client.proposal.getAll().find((t2) => t2.pairingTopic === e2.topic); - s2 && this.onSessionProposeRequest(e2.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: s2.requiredNamespaces, optionalNamespaces: s2.optionalNamespaces, relays: s2.relays, proposer: s2.proposer, sessionProperties: s2.sessionProperties }, s2.id)); - }, this.isValidConnect = async (e2) => { - if (!Gt$1(e2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(e2)}`); + const e2 = this.client.proposal.getAll().find((s22) => s22.pairingTopic === t2.topic); + e2 && this.onSessionProposeRequest(t2.topic, formatJsonRpcRequest("wc_sessionPropose", { requiredNamespaces: e2.requiredNamespaces, optionalNamespaces: e2.optionalNamespaces, relays: e2.relays, proposer: e2.proposer, sessionProperties: e2.sessionProperties }, e2.id)); + }, this.isValidConnect = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe$1("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(t2)}`); throw new Error(a3); } - const { pairingTopic: s2, requiredNamespaces: t2, optionalNamespaces: i2, sessionProperties: n3, relays: o22 } = e2; - if (w$3(s2) || await this.isValidPairingTopic(s2), !qt$1(o22, true)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `connect() relays: ${o22}`); + const { pairingTopic: e2, requiredNamespaces: s22, optionalNamespaces: i2, sessionProperties: r3, relays: o22 } = t2; + if (Pe$1(e2) || await this.isValidPairingTopic(e2), !Xu(o22)) { + const { message: a3 } = xe$1("MISSING_OR_INVALID", `connect() relays: ${o22}`); throw new Error(a3); } - !w$3(t2) && B$1$1(t2) !== 0 && this.validateNamespaces(t2, "requiredNamespaces"), !w$3(i2) && B$1$1(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.validateNamespaces = (e2, s2) => { - const t2 = Ht$1(e2, "connect()", s2); - if (t2) - throw new Error(t2.message); - }, this.isValidApprove = async (e2) => { - if (!Gt$1(e2)) - throw new Error(N$1("MISSING_OR_INVALID", `approve() params: ${e2}`).message); - const { id: s2, namespaces: t2, relayProtocol: i2, sessionProperties: n3 } = e2; - await this.isValidProposalId(s2); - const o22 = this.client.proposal.get(s2), a3 = ln(t2, "approve()"); + !Pe$1(s22) && Yr(s22) !== 0 && this.validateNamespaces(s22, "requiredNamespaces"), !Pe$1(i2) && Yr(i2) !== 0 && this.validateNamespaces(i2, "optionalNamespaces"), Pe$1(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.validateNamespaces = (t2, e2) => { + const s22 = Wu(t2, "connect()", e2); + if (s22) + throw new Error(s22.message); + }, this.isValidApprove = async (t2) => { + if (!$u(t2)) + throw new Error(xe$1("MISSING_OR_INVALID", `approve() params: ${t2}`).message); + const { id: e2, namespaces: s22, relayProtocol: i2, sessionProperties: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2); + const o22 = this.client.proposal.get(e2), a3 = So(s22, "approve()"); if (a3) throw new Error(a3.message); - const c2 = fn(o22.requiredNamespaces, t2, "approve()"); + const c2 = Io(o22.requiredNamespaces, s22, "approve()"); if (c2) throw new Error(c2.message); - if (!g$3(i2, true)) { - const { message: p3 } = N$1("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); - throw new Error(p3); - } - w$3(n3) || this.validateSessionProps(n3, "sessionProperties"); - }, this.isValidReject = async (e2) => { - if (!Gt$1(e2)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() params: ${e2}`); + if (!Gt$1(i2, true)) { + const { message: d5 } = xe$1("MISSING_OR_INVALID", `approve() relayProtocol: ${i2}`); + throw new Error(d5); + } + Pe$1(r3) || this.validateSessionProps(r3, "sessionProperties"); + }, this.isValidReject = async (t2) => { + if (!$u(t2)) { + const { message: i2 } = xe$1("MISSING_OR_INVALID", `reject() params: ${t2}`); throw new Error(i2); } - const { id: s2, reason: t2 } = e2; - if (await this.isValidProposalId(s2), !Wt$1(t2)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(t2)}`); + const { id: e2, reason: s22 } = t2; + if (this.checkRecentlyDeleted(e2), await this.isValidProposalId(e2), !th(s22)) { + const { message: i2 } = xe$1("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(s22)}`); throw new Error(i2); } - }, this.isValidSessionSettleRequest = (e2) => { - if (!Gt$1(e2)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${e2}`); + }, this.isValidSessionSettleRequest = (t2) => { + if (!$u(t2)) { + const { message: c2 } = xe$1("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${t2}`); throw new Error(c2); } - const { relay: s2, controller: t2, namespaces: i2, expiry: n3 } = e2; - if (!dn(s2)) { - const { message: c2 } = N$1("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); + const { relay: e2, controller: s22, namespaces: i2, expiry: r3 } = t2; + if (!No$1(e2)) { + const { message: c2 } = xe$1("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); throw new Error(c2); } - const o22 = Ft$1(t2, "onSessionSettleRequest()"); + const o22 = Vu(s22, "onSessionSettleRequest()"); if (o22) throw new Error(o22.message); - const a3 = ln(i2, "onSessionSettleRequest()"); + const a3 = So(i2, "onSessionSettleRequest()"); if (a3) throw new Error(a3.message); - if (mt$1(n3)) { - const { message: c2 } = N$1("EXPIRED", "onSessionSettleRequest()"); + if (p0(r3)) { + const { message: c2 } = xe$1("EXPIRED", "onSessionSettleRequest()"); throw new Error(c2); } - }, this.isValidUpdate = async (e2) => { - if (!Gt$1(e2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `update() params: ${e2}`); + }, this.isValidUpdate = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe$1("MISSING_OR_INVALID", `update() params: ${t2}`); throw new Error(a3); } - const { topic: s2, namespaces: t2 } = e2; - await this.isValidSessionTopic(s2); - const i2 = this.client.session.get(s2), n3 = ln(t2, "update()"); - if (n3) - throw new Error(n3.message); - const o22 = fn(i2.requiredNamespaces, t2, "update()"); + const { topic: e2, namespaces: s22 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const i2 = this.client.session.get(e2), r3 = So(s22, "update()"); + if (r3) + throw new Error(r3.message); + const o22 = Io(i2.requiredNamespaces, s22, "update()"); if (o22) throw new Error(o22.message); - }, this.isValidExtend = async (e2) => { - if (!Gt$1(e2)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `extend() params: ${e2}`); - throw new Error(t2); - } - const { topic: s2 } = e2; - await this.isValidSessionTopic(s2); - }, this.isValidRequest = async (e2) => { - if (!Gt$1(e2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() params: ${e2}`); + }, this.isValidExtend = async (t2) => { + if (!$u(t2)) { + const { message: s22 } = xe$1("MISSING_OR_INVALID", `extend() params: ${t2}`); + throw new Error(s22); + } + const { topic: e2 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + }, this.isValidRequest = async (t2) => { + if (!$u(t2)) { + const { message: a3 } = xe$1("MISSING_OR_INVALID", `request() params: ${t2}`); throw new Error(a3); } - const { topic: s2, request: t2, chainId: i2, expiry: n3 } = e2; - await this.isValidSessionTopic(s2); - const { namespaces: o22 } = this.client.session.get(s2); - if (!Qt$1(o22, i2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() chainId: ${i2}`); + const { topic: e2, request: s22, chainId: i2, expiry: r3 } = t2; + this.checkRecentlyDeleted(e2), await this.isValidSessionTopic(e2); + const { namespaces: o22 } = this.client.session.get(e2); + if (!nh(o22, i2)) { + const { message: a3 } = xe$1("MISSING_OR_INVALID", `request() chainId: ${i2}`); throw new Error(a3); } - if (!zt$1(t2)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() ${JSON.stringify(t2)}`); + if (!eh(s22)) { + const { message: a3 } = xe$1("MISSING_OR_INVALID", `request() ${JSON.stringify(s22)}`); throw new Error(a3); } - if (!Zt$1(o22, i2, t2.method)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() method: ${t2.method}`); + if (!fh(o22, i2, s22.method)) { + const { message: a3 } = xe$1("MISSING_OR_INVALID", `request() method: ${s22.method}`); throw new Error(a3); } - if (n3 && !tr$1(n3, U$1)) { - const { message: a3 } = N$1("MISSING_OR_INVALID", `request() expiry: ${n3}. Expiry must be a number (in seconds) between ${U$1.min} and ${U$1.max}`); + if (r3 && !uh(r3, re$1)) { + const { message: a3 } = xe$1("MISSING_OR_INVALID", `request() expiry: ${r3}. Expiry must be a number (in seconds) between ${re$1.min} and ${re$1.max}`); throw new Error(a3); } - }, this.isValidRespond = async (e2) => { - var s2; - if (!Gt$1(e2)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() params: ${e2}`); - throw new Error(n3); + }, this.isValidRespond = async (t2) => { + var e2; + if (!$u(t2)) { + const { message: r3 } = xe$1("MISSING_OR_INVALID", `respond() params: ${t2}`); + throw new Error(r3); } - const { topic: t2, response: i2 } = e2; + const { topic: s22, response: i2 } = t2; try { - await this.isValidSessionTopic(t2); - } catch (n3) { - throw (s2 = e2 == null ? void 0 : e2.response) != null && s2.id && this.cleanupAfterResponse(e2), n3; - } - if (!Yt$1(i2)) { - const { message: n3 } = N$1("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); - throw new Error(n3); - } - }, this.isValidPing = async (e2) => { - if (!Gt$1(e2)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `ping() params: ${e2}`); - throw new Error(t2); - } - const { topic: s2 } = e2; - await this.isValidSessionOrPairingTopic(s2); - }, this.isValidEmit = async (e2) => { - if (!Gt$1(e2)) { - const { message: o22 } = N$1("MISSING_OR_INVALID", `emit() params: ${e2}`); + await this.isValidSessionTopic(s22); + } catch (r3) { + throw (e2 = t2 == null ? void 0 : t2.response) != null && e2.id && this.cleanupAfterResponse(t2), r3; + } + if (!rh(i2)) { + const { message: r3 } = xe$1("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(i2)}`); + throw new Error(r3); + } + }, this.isValidPing = async (t2) => { + if (!$u(t2)) { + const { message: s22 } = xe$1("MISSING_OR_INVALID", `ping() params: ${t2}`); + throw new Error(s22); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidEmit = async (t2) => { + if (!$u(t2)) { + const { message: o22 } = xe$1("MISSING_OR_INVALID", `emit() params: ${t2}`); throw new Error(o22); } - const { topic: s2, event: t2, chainId: i2 } = e2; - await this.isValidSessionTopic(s2); - const { namespaces: n3 } = this.client.session.get(s2); - if (!Qt$1(n3, i2)) { - const { message: o22 } = N$1("MISSING_OR_INVALID", `emit() chainId: ${i2}`); + const { topic: e2, event: s22, chainId: i2 } = t2; + await this.isValidSessionTopic(e2); + const { namespaces: r3 } = this.client.session.get(e2); + if (!nh(r3, i2)) { + const { message: o22 } = xe$1("MISSING_OR_INVALID", `emit() chainId: ${i2}`); throw new Error(o22); } - if (!Jt$1(t2)) { - const { message: o22 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); + if (!ih(s22)) { + const { message: o22 } = xe$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s22)}`); throw new Error(o22); } - if (!Xt$1(n3, i2, t2.name)) { - const { message: o22 } = N$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(t2)}`); + if (!oh(r3, i2, s22.name)) { + const { message: o22 } = xe$1("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(s22)}`); throw new Error(o22); } - }, this.isValidDisconnect = async (e2) => { - if (!Gt$1(e2)) { - const { message: t2 } = N$1("MISSING_OR_INVALID", `disconnect() params: ${e2}`); - throw new Error(t2); - } - const { topic: s2 } = e2; - await this.isValidSessionOrPairingTopic(s2); - }, this.getVerifyContext = async (e2, s2) => { - const t2 = { verified: { verifyUrl: s2.verifyUrl || F$1, validation: "UNKNOWN", origin: s2.url || "" } }; + }, this.isValidDisconnect = async (t2) => { + if (!$u(t2)) { + const { message: s22 } = xe$1("MISSING_OR_INVALID", `disconnect() params: ${t2}`); + throw new Error(s22); + } + const { topic: e2 } = t2; + await this.isValidSessionOrPairingTopic(e2); + }, this.isValidAuthenticate = (t2) => { + const { chains: e2, uri: s22, domain: i2, nonce: r3 } = t2; + if (!Array.isArray(e2) || e2.length === 0) + throw new Error("chains is required and must be a non-empty array"); + if (!Gt$1(s22, false)) + throw new Error("uri is required parameter"); + if (!Gt$1(i2, false)) + throw new Error("domain is required parameter"); + if (!Gt$1(r3, false)) + throw new Error("nonce is required parameter"); + if ([...new Set(e2.map((a3) => dn(a3).namespace))].length > 1) + throw new Error("Multi-namespace requests are not supported. Please request single namespace only."); + const { namespace: o22 } = dn(e2[0]); + if (o22 !== "eip155") + throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains."); + }, this.getVerifyContext = async (t2, e2) => { + const s22 = { verified: { verifyUrl: e2.verifyUrl || k$1, validation: "UNKNOWN", origin: e2.url || "" } }; try { - const i2 = await this.client.core.verify.resolve({ attestationId: e2, verifyUrl: s2.verifyUrl }); - i2 && (t2.verified.origin = i2.origin, t2.verified.isScam = i2.isScam, t2.verified.validation = i2.origin === new URL(s2.url).origin ? "VALID" : "INVALID"); + const i2 = await this.client.core.verify.resolve({ attestationId: t2, verifyUrl: e2.verifyUrl }); + i2 && (s22.verified.origin = i2.origin, s22.verified.isScam = i2.isScam, s22.verified.validation = i2.origin === new URL(e2.url).origin ? "VALID" : "INVALID"); } catch (i2) { this.client.logger.info(i2); } - return this.client.logger.info(`Verify context: ${JSON.stringify(t2)}`), t2; - }, this.validateSessionProps = (e2, s2) => { - Object.values(e2).forEach((t2) => { - if (!g$3(t2, false)) { - const { message: i2 } = N$1("MISSING_OR_INVALID", `${s2} must be in Record format. Received: ${JSON.stringify(t2)}`); + return this.client.logger.info(`Verify context: ${JSON.stringify(s22)}`), s22; + }, this.validateSessionProps = (t2, e2) => { + Object.values(t2).forEach((s22) => { + if (!Gt$1(s22, false)) { + const { message: i2 } = xe$1("MISSING_OR_INVALID", `${e2} must be in Record format. Received: ${JSON.stringify(s22)}`); throw new Error(i2); } }); + }, this.getPendingAuthRequest = (t2) => { + const e2 = this.client.auth.requests.get(t2); + return typeof e2 == "object" ? e2 : void 0; + }, this.addToRecentlyDeleted = (t2, e2) => { + if (this.recentlyDeletedMap.set(t2, e2), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) { + let s22 = 0; + const i2 = this.recentlyDeletedLimit / 2; + for (const r3 of this.recentlyDeletedMap.keys()) { + if (s22++ >= i2) + break; + this.recentlyDeletedMap.delete(r3); + } + } + }, this.checkRecentlyDeleted = (t2) => { + const e2 = this.recentlyDeletedMap.get(t2); + if (e2) { + const { message: s22 } = xe$1("MISSING_OR_INVALID", `Record was recently deleted - ${e2}: ${t2}`); + throw new Error(s22); + } }; } async isInitialized() { if (!this.initialized) { - const { message: r2 } = N$1("NOT_INITIALIZED", this.name); - throw new Error(r2); + const { message: n4 } = xe$1("NOT_INITIALIZED", this.name); + throw new Error(n4); } await this.client.core.relayer.confirmOnlineStateOrThrow(); } registerRelayerEvents() { - this.client.core.relayer.on(D$1$1.message, async (r2) => { - const { topic: e2, message: s2 } = r2; - if (this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s2))) - return; - const t2 = await this.client.core.crypto.decode(e2, s2); + this.client.core.relayer.on(v2.message, async (n4) => { + const { topic: t2, message: e2 } = n4, { publicKey: s22 } = this.client.auth.authKeys.keys.includes(J$2) ? this.client.auth.authKeys.get(J$2) : { responseTopic: void 0, publicKey: void 0 }, i2 = await this.client.core.crypto.decode(t2, e2, { receiverPublicKey: s22 }); try { - isJsonRpcRequest(t2) ? (this.client.core.history.set(e2, t2), this.onRelayEventRequest({ topic: e2, payload: t2 })) : isJsonRpcResponse(t2) ? (await this.client.core.history.resolve(t2), await this.onRelayEventResponse({ topic: e2, payload: t2 }), this.client.core.history.delete(e2, t2.id)) : this.onRelayEventUnknownPayload({ topic: e2, payload: t2 }); - } catch (i2) { - this.client.logger.error(i2); + isJsonRpcRequest(i2) ? (this.client.core.history.set(t2, i2), this.onRelayEventRequest({ topic: t2, payload: i2 })) : isJsonRpcResponse(i2) ? (await this.client.core.history.resolve(i2), await this.onRelayEventResponse({ topic: t2, payload: i2 }), this.client.core.history.delete(t2, i2.id)) : this.onRelayEventUnknownPayload({ topic: t2, payload: i2 }); + } catch (r3) { + this.client.logger.error(r3); } }); } registerExpirerEvents() { - this.client.core.expirer.on(v2.expired, async (r2) => { - const { topic: e2, id: s2 } = ft$1(r2.target); - if (s2 && this.client.pendingRequest.keys.includes(s2)) - return await this.deletePendingSessionRequest(s2, N$1("EXPIRED"), true); - e2 ? this.client.session.keys.includes(e2) && (await this.deleteSession({ topic: e2, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: e2 })) : s2 && (await this.deleteProposal(s2, true), this.client.events.emit("proposal_expire", { id: s2 })); + this.client.core.expirer.on(C$4.expired, async (n4) => { + const { topic: t2, id: e2 } = l0(n4.target); + if (e2 && this.client.pendingRequest.keys.includes(e2)) + return await this.deletePendingSessionRequest(e2, xe$1("EXPIRED"), true); + t2 ? this.client.session.keys.includes(t2) && (await this.deleteSession({ topic: t2, expirerHasDeleted: true }), this.client.events.emit("session_expire", { topic: t2 })) : e2 && (await this.deleteProposal(e2, true), this.client.events.emit("proposal_expire", { id: e2 })); }); } registerPairingEvents() { - this.client.core.pairing.events.on(V$3.create, (r2) => this.onPairingCreated(r2)); + this.client.core.pairing.events.on(V$1.create, (n4) => this.onPairingCreated(n4)), this.client.core.pairing.events.on(V$1.delete, (n4) => { + this.addToRecentlyDeleted(n4.topic, "pairing"); + }); } - isValidPairingTopic(r2) { - if (!g$3(r2, false)) { - const { message: e2 } = N$1("MISSING_OR_INVALID", `pairing topic should be a string: ${r2}`); - throw new Error(e2); + isValidPairingTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `pairing topic should be a string: ${n4}`); + throw new Error(t2); } - if (!this.client.core.pairing.pairings.keys.includes(r2)) { - const { message: e2 } = N$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${r2}`); - throw new Error(e2); + if (!this.client.core.pairing.pairings.keys.includes(n4)) { + const { message: t2 } = xe$1("NO_MATCHING_KEY", `pairing topic doesn't exist: ${n4}`); + throw new Error(t2); } - if (mt$1(this.client.core.pairing.pairings.get(r2).expiry)) { - const { message: e2 } = N$1("EXPIRED", `pairing topic: ${r2}`); - throw new Error(e2); + if (p0(this.client.core.pairing.pairings.get(n4).expiry)) { + const { message: t2 } = xe$1("EXPIRED", `pairing topic: ${n4}`); + throw new Error(t2); } } - async isValidSessionTopic(r2) { - if (!g$3(r2, false)) { - const { message: e2 } = N$1("MISSING_OR_INVALID", `session topic should be a string: ${r2}`); - throw new Error(e2); + async isValidSessionTopic(n4) { + if (!Gt$1(n4, false)) { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `session topic should be a string: ${n4}`); + throw new Error(t2); } - if (!this.client.session.keys.includes(r2)) { - const { message: e2 } = N$1("NO_MATCHING_KEY", `session topic doesn't exist: ${r2}`); - throw new Error(e2); + if (this.checkRecentlyDeleted(n4), !this.client.session.keys.includes(n4)) { + const { message: t2 } = xe$1("NO_MATCHING_KEY", `session topic doesn't exist: ${n4}`); + throw new Error(t2); } - if (mt$1(this.client.session.get(r2).expiry)) { - await this.deleteSession({ topic: r2 }); - const { message: e2 } = N$1("EXPIRED", `session topic: ${r2}`); - throw new Error(e2); + if (p0(this.client.session.get(n4).expiry)) { + await this.deleteSession({ topic: n4 }); + const { message: t2 } = xe$1("EXPIRED", `session topic: ${n4}`); + throw new Error(t2); } - if (!this.client.core.crypto.keychain.has(r2)) { - const { message: e2 } = N$1("MISSING_OR_INVALID", `session topic does not exist in keychain: ${r2}`); - throw await this.deleteSession({ topic: r2 }), new Error(e2); + if (!this.client.core.crypto.keychain.has(n4)) { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `session topic does not exist in keychain: ${n4}`); + throw await this.deleteSession({ topic: n4 }), new Error(t2); } } - async isValidSessionOrPairingTopic(r2) { - if (this.client.session.keys.includes(r2)) - await this.isValidSessionTopic(r2); - else if (this.client.core.pairing.pairings.keys.includes(r2)) - this.isValidPairingTopic(r2); - else if (g$3(r2, false)) { - const { message: e2 } = N$1("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${r2}`); - throw new Error(e2); + async isValidSessionOrPairingTopic(n4) { + if (this.checkRecentlyDeleted(n4), this.client.session.keys.includes(n4)) + await this.isValidSessionTopic(n4); + else if (this.client.core.pairing.pairings.keys.includes(n4)) + this.isValidPairingTopic(n4); + else if (Gt$1(n4, false)) { + const { message: t2 } = xe$1("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${n4}`); + throw new Error(t2); } else { - const { message: e2 } = N$1("MISSING_OR_INVALID", `session or pairing topic should be a string: ${r2}`); - throw new Error(e2); + const { message: t2 } = xe$1("MISSING_OR_INVALID", `session or pairing topic should be a string: ${n4}`); + throw new Error(t2); } } - async isValidProposalId(r2) { - if (!Bt$1(r2)) { - const { message: e2 } = N$1("MISSING_OR_INVALID", `proposal id should be a number: ${r2}`); - throw new Error(e2); + async isValidProposalId(n4) { + if (!Zu(n4)) { + const { message: t2 } = xe$1("MISSING_OR_INVALID", `proposal id should be a number: ${n4}`); + throw new Error(t2); } - if (!this.client.proposal.keys.includes(r2)) { - const { message: e2 } = N$1("NO_MATCHING_KEY", `proposal id doesn't exist: ${r2}`); - throw new Error(e2); + if (!this.client.proposal.keys.includes(n4)) { + const { message: t2 } = xe$1("NO_MATCHING_KEY", `proposal id doesn't exist: ${n4}`); + throw new Error(t2); } - if (mt$1(this.client.proposal.get(r2).expiryTimestamp)) { - await this.deleteProposal(r2); - const { message: e2 } = N$1("EXPIRED", `proposal id: ${r2}`); - throw new Error(e2); + if (p0(this.client.proposal.get(n4).expiryTimestamp)) { + await this.deleteProposal(n4); + const { message: t2 } = xe$1("EXPIRED", `proposal id: ${n4}`); + throw new Error(t2); } } + }; + let Zt$1 = class Zt extends Vt { + constructor(n4, t2) { + super(n4, t2, Ke$2, se$1), this.core = n4, this.logger = t2; + } + }; + let We$3 = class We extends Vt { + constructor(n4, t2) { + super(n4, t2, Ge$2, se$1), this.core = n4, this.logger = t2; + } + }; + class es2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Fe$2, se$1, (e2) => e2.id), this.core = n4, this.logger = t2; + } } - class us extends Kt$2 { - constructor(r2, e2) { - super(r2, e2, oe$2, G$3), this.core = r2, this.logger = e2; + class ts2 extends Vt { + constructor(n4, t2) { + super(n4, t2, He$2, X$2, () => J$2), this.core = n4, this.logger = t2; } } - class ge extends Kt$2 { - constructor(r2, e2) { - super(r2, e2, ce$3, G$3), this.core = r2, this.logger = e2; + let ss$1 = class ss2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Ye$2, X$2), this.core = n4, this.logger = t2; + } + }; + class is2 extends Vt { + constructor(n4, t2) { + super(n4, t2, Xe$1, X$2, (e2) => e2.id), this.core = n4, this.logger = t2; } } - class gs extends Kt$2 { - constructor(r2, e2) { - super(r2, e2, pe, G$3, (s2) => s2.id), this.core = r2, this.logger = e2; + class rs { + constructor(n4, t2) { + this.core = n4, this.logger = t2, this.authKeys = new ts2(this.core, this.logger), this.pairingTopics = new ss$1(this.core, this.logger), this.requests = new is2(this.core, this.logger); + } + async init() { + await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init(); } } - let Q$4 = class Q2 extends b$1 { - constructor(r2) { - super(r2), this.protocol = J, this.version = F$4, this.name = M$2.name, this.events = new eventsExports.EventEmitter(), this.on = (s2, t2) => this.events.on(s2, t2), this.once = (s2, t2) => this.events.once(s2, t2), this.off = (s2, t2) => this.events.off(s2, t2), this.removeListener = (s2, t2) => this.events.removeListener(s2, t2), this.removeAllListeners = (s2) => this.events.removeAllListeners(s2), this.connect = async (s2) => { - try { - return await this.engine.connect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.pair = async (s2) => { - try { - return await this.engine.pair(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; - } - }, this.approve = async (s2) => { + let ne$1 = class ne3 extends b$1$1 { + constructor(n4) { + super(n4), this.protocol = Se$1, this.version = Ee$1, this.name = ie$1.name, this.events = new eventsExports.EventEmitter(), this.on = (e2, s22) => this.events.on(e2, s22), this.once = (e2, s22) => this.events.once(e2, s22), this.off = (e2, s22) => this.events.off(e2, s22), this.removeListener = (e2, s22) => this.events.removeListener(e2, s22), this.removeAllListeners = (e2) => this.events.removeAllListeners(e2), this.connect = async (e2) => { try { - return await this.engine.approve(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.connect(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.reject = async (s2) => { + }, this.pair = async (e2) => { try { - return await this.engine.reject(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.pair(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.update = async (s2) => { + }, this.approve = async (e2) => { try { - return await this.engine.update(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.approve(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.extend = async (s2) => { + }, this.reject = async (e2) => { try { - return await this.engine.extend(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.reject(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.request = async (s2) => { + }, this.update = async (e2) => { try { - return await this.engine.request(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.update(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.respond = async (s2) => { + }, this.extend = async (e2) => { try { - return await this.engine.respond(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.extend(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.ping = async (s2) => { + }, this.request = async (e2) => { try { - return await this.engine.ping(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.request(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.emit = async (s2) => { + }, this.respond = async (e2) => { try { - return await this.engine.emit(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.respond(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.disconnect = async (s2) => { + }, this.ping = async (e2) => { try { - return await this.engine.disconnect(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.ping(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.find = (s2) => { + }, this.emit = async (e2) => { try { - return this.engine.find(s2); - } catch (t2) { - throw this.logger.error(t2.message), t2; + return await this.engine.emit(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, this.getPendingSessionRequests = () => { + }, this.disconnect = async (e2) => { try { - return this.engine.getPendingSessionRequests(); - } catch (s2) { - throw this.logger.error(s2.message), s2; - } - }, this.name = (r2 == null ? void 0 : r2.name) || M$2.name, this.metadata = (r2 == null ? void 0 : r2.metadata) || Qn(); - const e2 = typeof (r2 == null ? void 0 : r2.logger) < "u" && typeof (r2 == null ? void 0 : r2.logger) != "string" ? r2.logger : cjs$3.pino(cjs$3.getDefaultLoggerOptions({ level: (r2 == null ? void 0 : r2.logger) || M$2.logger })); - this.core = (r2 == null ? void 0 : r2.core) || new Mr(r2), this.logger = cjs$3.generateChildLogger(e2, this.name), this.session = new ge(this.core, this.logger), this.proposal = new us(this.core, this.logger), this.pendingRequest = new gs(this.core, this.logger), this.engine = new ds(this); - } - static async init(r2) { - const e2 = new Q2(r2); - return await e2.initialize(), e2; - } - get context() { - return cjs$3.getLoggerContext(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.engine.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); - } catch (r2) { - throw this.logger.info("SignClient Initialization Failure"), this.logger.error(r2.message), r2; - } - } - }; - var P$2 = Object.defineProperty, x$2 = Object.defineProperties, N$4 = Object.getOwnPropertyDescriptors, j$4 = Object.getOwnPropertySymbols, U$3 = Object.prototype.hasOwnProperty, T$2 = Object.prototype.propertyIsEnumerable, W = (e2, t2, s2) => t2 in e2 ? P$2(e2, t2, { enumerable: true, configurable: true, writable: true, value: s2 }) : e2[t2] = s2, q$3 = (e2, t2) => { - for (var s2 in t2 || (t2 = {})) - U$3.call(t2, s2) && W(e2, s2, t2[s2]); - if (j$4) - for (var s2 of j$4(t2)) - T$2.call(t2, s2) && W(e2, s2, t2[s2]); - return e2; - }, A$2 = (e2, t2) => x$2(e2, N$4(t2)), S$3 = (e2, t2, s2) => { - if (!t2.has(e2)) - throw TypeError("Cannot " + s2); - }, a2 = (e2, t2, s2) => (S$3(e2, t2, "read from private field"), s2 ? s2.call(e2) : t2.get(e2)), l$4 = (e2, t2, s2) => { - if (t2.has(e2)) - throw TypeError("Cannot add the same private member more than once"); - t2 instanceof WeakSet ? t2.add(e2) : t2.set(e2, s2); - }, y2 = (e2, t2, s2, d3) => (S$3(e2, t2, "write to private field"), d3 ? d3.call(e2, s2) : t2.set(e2, s2), s2), o = (e2, t2, s2) => (S$3(e2, t2, "access private method"), s2), h3, p2, w2, i$4, u2$1, _2, n2, r$3, m$3, g2; - let z$1$1 = class z { - constructor(t2) { - l$4(this, u2$1), l$4(this, n2), l$4(this, m$3), l$4(this, h3, void 0), l$4(this, p2, void 0), l$4(this, w2, void 0), l$4(this, i$4, void 0), y2(this, h3, t2), y2(this, p2, o(this, u2$1, _2).call(this)), o(this, n2, r$3).call(this); - } - async connect(t2) { - const { requiredNamespaces: s2, optionalNamespaces: d3 } = t2; - return new Promise(async (C2, b3) => { - await o(this, n2, r$3).call(this); - const E2 = a2(this, p2).subscribeModal((c2) => { - c2.open || (E2(), b3(new Error("Modal closed"))); - }), { uri: O2, approval: I2 } = await a2(this, i$4).connect(t2); - if (O2) { - const c2 = /* @__PURE__ */ new Set(); - s2 && Object.values(s2).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), d3 && Object.values(d3).forEach(({ chains: f2 }) => { - f2 && f2.forEach((v3) => c2.add(v3)); - }), await a2(this, p2).openModal({ uri: O2, chains: Array.from(c2) }); + return await this.engine.disconnect(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } + }, this.find = (e2) => { try { - const c2 = await I2(); - C2(c2); - } catch (c2) { - b3(c2); - } finally { - E2(), a2(this, p2).closeModal(); + return this.engine.find(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }); - } - async disconnect(t2) { - await o(this, n2, r$3).call(this), await a2(this, i$4).disconnect(t2); - } - async request(t2) { - return await o(this, n2, r$3).call(this), await a2(this, i$4).request(t2); - } - async getSessions() { - return await o(this, n2, r$3).call(this), a2(this, i$4).session.getAll(); - } - async getSession() { - return await o(this, n2, r$3).call(this), a2(this, i$4).session.getAll().at(-1); - } - async onSessionEvent(t2) { - await o(this, n2, r$3).call(this), a2(this, i$4).on("session_event", t2); - } - async offSessionEvent(t2) { - await o(this, n2, r$3).call(this), a2(this, i$4).off("session_event", t2); - } - async onSessionUpdate(t2) { - await o(this, n2, r$3).call(this), a2(this, i$4).on("session_update", t2); - } - async offSessionUpdate(t2) { - await o(this, n2, r$3).call(this), a2(this, i$4).off("session_update", t2); - } - async onSessionDelete(t2) { - await o(this, n2, r$3).call(this), a2(this, i$4).on("session_delete", t2); - } - async offSessionDelete(t2) { - await o(this, n2, r$3).call(this), a2(this, i$4).off("session_delete", t2); - } - async onSessionExpire(t2) { - await o(this, n2, r$3).call(this), a2(this, i$4).on("session_expire", t2); - } - async offSessionExpire(t2) { - await o(this, n2, r$3).call(this), a2(this, i$4).off("session_expire", t2); - } - }; - h3 = /* @__PURE__ */ new WeakMap(), p2 = /* @__PURE__ */ new WeakMap(), w2 = /* @__PURE__ */ new WeakMap(), i$4 = /* @__PURE__ */ new WeakMap(), u2$1 = /* @__PURE__ */ new WeakSet(), _2 = function() { - const { modalOptions: e2, projectId: t2 } = a2(this, h3); - return new d$1$1(A$2(q$3({}, e2), { projectId: t2 })); - }, n2 = /* @__PURE__ */ new WeakSet(), r$3 = async function() { - return a2(this, i$4) ? true : (!a2(this, w2) && typeof window < "u" && y2(this, w2, o(this, m$3, g2).call(this)), a2(this, w2)); - }, m$3 = /* @__PURE__ */ new WeakSet(), g2 = async function() { - y2(this, i$4, await Q$4.init({ metadata: a2(this, h3).metadata, projectId: a2(this, h3).projectId, relayUrl: a2(this, h3).relayUrl })); - const e2 = await a2(this, i$4).core.crypto.getClientId(); - try { - localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e2); - } catch { - console.info("Unable to set client id"); - } - }; - const wc_aleo_methods$1 = [ - "decrypt", - "disconnect", - "getSelectedAccount", - "getBalance", - "getRecords", - "requestCreateEvent", - "getEvent", - "getEvents", - "createSharedState", - "importSharedState", - "requestSignature" - ]; - const wc_aleo_chains$1 = ["aleo:1"]; - const wc_events$1 = [ - "chainChanged", - "accountSelected", - "selectedAccountSynced", - "sharedAccountSynced" - ]; - const projectId$1 = "f0aaeffe71b636da453fce042d79d723"; - function isAndroid$1() { - if (!navigator) { - return false; - } - return /Android/i.test(navigator.userAgent); - } - const web3modal_puzzle_props_android$1 = { - projectId: projectId$1, - chains: ["aleo:3"], - enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" + }, this.getPendingSessionRequests = () => { + try { + return this.engine.getPendingSessionRequests(); + } catch (e2) { + throw this.logger.error(e2.message), e2; } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png" - } - }; - const web3modal_puzzle_props_default$1 = { - projectId: projectId$1, - chains: wc_aleo_chains$1, - enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], - mobileWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "puzzleapp://", - universal: "" + }, this.authenticate = async (e2) => { + try { + return await this.engine.authenticate(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - } - ], - desktopWallets: [ - { - id: "puzzle", - name: "Puzzle Wallet", - links: { - native: "", - universal: "https://walletconnect.puzzle.online/" + }, this.formatAuthMessage = (e2) => { + try { + return this.engine.formatAuthMessage(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - }, - { - id: "avail", - name: "Avail Wallet", - links: { - native: "avail://", - universal: "https://avail.global" + }, this.approveSessionAuthenticate = async (e2) => { + try { + return await this.engine.approveSessionAuthenticate(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; } - } - ], - walletImages: { - puzzle: "https://i.imgur.com/p9tHaFC.png", - avail: "https://i.imgur.com/GxNn8BO.png" + }, this.rejectSessionAuthenticate = async (e2) => { + try { + return await this.engine.rejectSessionAuthenticate(e2); + } catch (s22) { + throw this.logger.error(s22.message), s22; + } + }, this.name = (n4 == null ? void 0 : n4.name) || ie$1.name, this.metadata = (n4 == null ? void 0 : n4.metadata) || Xo$1(); + const t2 = typeof (n4 == null ? void 0 : n4.logger) < "u" && typeof (n4 == null ? void 0 : n4.logger) != "string" ? n4.logger : nt$1(k$2({ level: (n4 == null ? void 0 : n4.logger) || ie$1.logger })); + this.core = (n4 == null ? void 0 : n4.core) || new Br(n4), this.logger = E$1(t2, this.name), this.session = new We$3(this.core, this.logger), this.proposal = new Zt$1(this.core, this.logger), this.pendingRequest = new es2(this.core, this.logger), this.engine = new Wt$1(this), this.auth = new rs(this.core, this.logger); } - }; - const web3modal_puzzle_props$1 = isAndroid$1() ? web3modal_puzzle_props_android$1 : web3modal_puzzle_props_default$1; - const name$1 = "@puzzlehq/sdk-core"; - const displayName$1 = "Puzzle SDK"; - const version$2 = "0.3.1"; - const description$1 = "Your portal to privacy"; - const main$1 = "./dist/puzzle.cjs.js"; - const module$1 = "./dist/puzzle.es.js"; - const browser$1$1 = "./dist/puzzle.umd.js"; - const types$3 = "./dist/types/src/index.d.ts"; - const exports$2 = { - ".": { - "import": "./dist/puzzle.es.js", - require: "./dist/puzzle.cjs.js", - browser: "./dist/puzzle.umd.js", - types: "./dist/types/src/index.d.ts" + static async init(n4) { + const t2 = new ne3(n4); + return await t2.initialize(), t2; } - }; - const type$1 = "module"; - const scripts$1 = { - "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", - "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, - build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", - "type-check": "tsc --noEmit" - }; - const repository$1 = { - type: "git", - url: "git+https://github.com/puzzlehq/puzzle-sdk.git" - }; - const dependencies$1 = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", - "@walletconnect/types": "^2.11.2", - "@walletconnect/utils": "^2.11.2", - debug: "^4.3.4", - events: "^3.3.0", - ws: "^8.16.0" - }; - const peerDependencies$1 = { - buffer: "^6.0.3" - }; - const keywords$1 = [ - "puzzle", - "cryptocurrency wallet", - "privacy", - "aleo", - "web3", - "crypto", - "typescript" - ]; - const author$1 = "Puzzle"; - const license$1 = "ISC"; - const bugs$1 = { - url: "https://github.com/puzzlehq/puzzle-sdk/issues" - }; - const homepage$1 = "https://github.com/puzzlehq/puzzle-sdk#readme"; - const pkg$1 = { - name: name$1, - displayName: displayName$1, - version: version$2, - description: description$1, - main: main$1, - module: module$1, - browser: browser$1$1, - types: types$3, - "private": false, - exports: exports$2, - type: type$1, - scripts: scripts$1, - repository: repository$1, - dependencies: dependencies$1, - peerDependencies: peerDependencies$1, - keywords: keywords$1, - author: author$1, - license: license$1, - bugs: bugs$1, - homepage: homepage$1 - }; - const emitter$1 = new EventEmitter$1(); - let connection = void 0; - async function configureConnection$1(options) { - let disconnectSessions = false; - const thisVersion = pkg$1.version; - const prevVersion = localStorage.getItem("puzzle_sdk_version"); - if (thisVersion !== prevVersion) { - console.log( - `${pkg$1.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" - ); - localStorage.setItem("puzzle_sdk_version", thisVersion); - disconnectSessions = true; + get context() { + return y$2(this.logger); } - connection = new z$1$1({ - projectId: options.projectId ?? projectId$1, - metadata: { - name: options.dAppName, - description: options.dAppDescription, - url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", - icons: [options.dAppIconURL] - }, - modalOptions: { ...web3modal_puzzle_props$1 } - }); - if (disconnectSessions) { - localStorage.removeItem("puzzle-hasInjectedConnection"); + get pairing() { + return this.core.pairing.pairings; + } + async initialize() { + this.logger.trace("Initialized"); try { - disconnectOnVersionChange$1(connection, options.onDisconnect); - } catch (e2) { - console.error(e2); + await this.core.start(), await this.session.init(), await this.proposal.init(), await this.pendingRequest.init(), await this.engine.init(), await this.auth.init(), this.core.verify.init({ verifyUrl: this.metadata.verifyUrl }), this.logger.info("SignClient Initialization Success"); + } catch (n4) { + throw this.logger.info("SignClient Initialization Failure"), this.logger.error(n4.message), n4; } } - connection.onSessionDelete(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - connection.onSessionExpire(() => { - localStorage.removeItem("puzzle-hasInjectedConnection"); - options.onDisconnect && options.onDisconnect(); - }); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + }; + var N = Object.defineProperty, T$3 = Object.defineProperties, U$1 = Object.getOwnPropertyDescriptors, I$4 = Object.getOwnPropertySymbols, A$3 = Object.prototype.hasOwnProperty, D$3 = Object.prototype.propertyIsEnumerable, M$2 = (e2, t2, a3) => t2 in e2 ? N(e2, t2, { enumerable: true, configurable: true, writable: true, value: a3 }) : e2[t2] = a3, q = (e2, t2) => { + for (var a3 in t2 || (t2 = {})) + A$3.call(t2, a3) && M$2(e2, a3, t2[a3]); + if (I$4) + for (var a3 of I$4(t2)) + D$3.call(t2, a3) && M$2(e2, a3, t2[a3]); + return e2; + }, L$1$1 = (e2, t2) => T$3(e2, U$1(t2)), g2 = (e2, t2, a3) => { + if (!t2.has(e2)) + throw TypeError("Cannot " + a3); + }, s = (e2, t2, a3) => (g2(e2, t2, "read from private field"), a3 ? a3.call(e2) : t2.get(e2)), d4 = (e2, t2, a3) => { + if (t2.has(e2)) + throw TypeError("Cannot add the same private member more than once"); + t2 instanceof WeakSet ? t2.add(e2) : t2.set(e2, a3); + }, S$5 = (e2, t2, a3, h4) => (g2(e2, t2, "write to private field"), t2.set(e2, a3), a3), n3 = (e2, t2, a3) => (g2(e2, t2, "access private method"), a3), w2, f2, u2$1, o, O2, k$5, r2, c$5, j$1, P$2; + let G$2 = class G { + constructor(t2) { + d4(this, O2), d4(this, r2), d4(this, j$1), d4(this, w2, void 0), d4(this, f2, void 0), d4(this, u2$1, void 0), d4(this, o, void 0), S$5(this, w2, t2), S$5(this, f2, n3(this, O2, k$5).call(this)), n3(this, r2, c$5).call(this); + } + async connect(t2, a3 = true) { + const { requiredNamespaces: h4, optionalNamespaces: y3 } = t2; + return new Promise(async (W2, E2) => { + var _3, C2; + if (await n3(this, r2, c$5).call(this), a3) { + const p2 = s(this, f2).subscribeModal((i2) => { + i2.open || (p2(), E2(new Error("Modal closed"))); + }), { uri: v3, approval: m3 } = await s(this, o).connect(t2); + if (v3) { + const i2 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), y3 && Object.values(y3).forEach(({ chains: l2 }) => { + l2 && l2.forEach((b3) => i2.add(b3)); + }), await s(this, f2).openModal({ uri: v3, chains: Array.from(i2) }); + } + try { + const i2 = await m3(); + W2(i2); + } catch (i2) { + E2(i2); + } finally { + p2(), s(this, f2).closeModal(); + } + } else { + const { uri: p2, approval: v3 } = await s(this, o).connect(t2); + if (p2) { + const m3 = /* @__PURE__ */ new Set(); + h4 && Object.values(h4).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }), y3 && Object.values(y3).forEach(({ chains: i2 }) => { + i2 && i2.forEach((l2) => m3.add(l2)); + }); + try { + if ((_3 = window == null ? void 0 : window.aleo) != null && _3.connectPuzzle) { + (C2 = window == null ? void 0 : window.aleo) == null || C2.connectPuzzle({ wc: { uri: p2 } }); + const i2 = await v3(); + W2(i2); + } else + throw new Error("window.aleo.connectPuzzle is undefined! Set showModal to true."); + } catch (i2) { + console.error(i2), E2(i2); + } + } + } + }); } - if (typeof window !== "undefined") { - window.puzzleSdkConnection = connection; + async disconnect(t2) { + await n3(this, r2, c$5).call(this), await s(this, o).disconnect(t2); } - return connection; - } - async function disconnectOnVersionChange$1(connection2, onDisconnect) { - const session = await (connection2 == null ? void 0 : connection2.getSession()); - if (session) { - console.log("Disconnecting session", session); - onDisconnect && onDisconnect(); - connection2.disconnect({ - topic: session.topic, - reason: U$2("USER_DISCONNECTED") - }); + async request(t2) { + return await n3(this, r2, c$5).call(this), await s(this, o).request(t2); } - } - async function getWalletConnectModalSignClient$1() { - return new Promise((resolve) => { - if (connection) { - resolve(connection); - } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { - resolve(window.puzzleSdkConnection); - } else { - const interval = setInterval(() => { - if (connection) { - clearInterval(interval); - resolve(connection); - } - }, 200); - } - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); - if (choice && JSON.parse(choice).name !== "Android") { - window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); - } - }); - } - const checkForDesktopConnection$1 = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; + async getSessions() { + return await n3(this, r2, c$5).call(this), s(this, o).session.getAll(); } - try { - const res = await window.aleo.puzzleWalletClient.isConnected.query( - { sessionTopic } - ); - if (res) { - localStorage.setItem("puzzle-hasInjectedConnection", "true"); - return true; - } else { - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; - } - } catch (e2) { - console.warn(e2); - localStorage.setItem("puzzle-hasInjectedConnection", "false"); - return false; + async getSession() { + return await n3(this, r2, c$5).call(this), s(this, o).session.getAll().at(-1); + } + async onSessionEvent(t2) { + await n3(this, r2, c$5).call(this), s(this, o).on("session_event", t2); + } + async offSessionEvent(t2) { + await n3(this, r2, c$5).call(this), s(this, o).off("session_event", t2); + } + async onSessionUpdate(t2) { + await n3(this, r2, c$5).call(this), s(this, o).on("session_update", t2); + } + async offSessionUpdate(t2) { + await n3(this, r2, c$5).call(this), s(this, o).off("session_update", t2); + } + async onSessionDelete(t2) { + await n3(this, r2, c$5).call(this), s(this, o).on("session_delete", t2); + } + async offSessionDelete(t2) { + await n3(this, r2, c$5).call(this), s(this, o).off("session_delete", t2); + } + async onSessionExpire(t2) { + await n3(this, r2, c$5).call(this), s(this, o).on("session_expire", t2); + } + async offSessionExpire(t2) { + await n3(this, r2, c$5).call(this), s(this, o).off("session_expire", t2); } }; - const hasInjectedConnection$1 = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { - return false; + w2 = /* @__PURE__ */ new WeakMap(), f2 = /* @__PURE__ */ new WeakMap(), u2$1 = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), O2 = /* @__PURE__ */ new WeakSet(), k$5 = function() { + const { modalOptions: e2, projectId: t2 } = s(this, w2); + return new d$3(L$1$1(q({}, e2), { projectId: t2 })); + }, r2 = /* @__PURE__ */ new WeakSet(), c$5 = async function() { + return s(this, o) ? true : (!s(this, u2$1) && typeof window < "u" && S$5(this, u2$1, n3(this, j$1, P$2).call(this)), s(this, u2$1)); + }, j$1 = /* @__PURE__ */ new WeakSet(), P$2 = async function() { + S$5(this, o, await ne$1.init({ metadata: s(this, w2).metadata, projectId: s(this, w2).projectId, relayUrl: s(this, w2).relayUrl })); + const e2 = await s(this, o).core.crypto.getClientId(); + try { + localStorage.setItem("WCM_WALLETCONNECT_CLIENT_ID", e2); + } catch { + console.info("Unable to set client id"); } - const puzzleHasDesktopConnection = localStorage.getItem( - "puzzle-hasInjectedConnection" - ); - return puzzleHasDesktopConnection === "true"; }; var util$1; (function(util2) { @@ -13209,7 +16792,7 @@ path: fullPath }; let errorMessage = ""; - const maps = errorMaps.filter((m2) => !!m2).slice().reverse(); + const maps = errorMaps.filter((m3) => !!m3).slice().reverse(); for (const map of maps) { errorMessage = map(fullIssue, { data: data2, defaultError: errorMessage }).message; } @@ -13249,12 +16832,12 @@ } static mergeArray(status, results2) { const arrayValue = []; - for (const s2 of results2) { - if (s2.status === "aborted") + for (const s22 of results2) { + if (s22.status === "aborted") return INVALID$1; - if (s2.status === "dirty") + if (s22.status === "dirty") status.dirty(); - arrayValue.push(s2.value); + arrayValue.push(s22.value); } return { status: status.value, value: arrayValue }; } @@ -13433,11 +17016,11 @@ throw result.error; } safeParse(data2, params) { - var _a; + var _a2; const ctx = { common: { issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap }, path: (params === null || params === void 0 ? void 0 : params.path) || [], @@ -13793,7 +17376,7 @@ } else if (check.kind === "url") { try { new URL(input.data); - } catch (_a) { + } catch (_a2) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext$1(ctx, { validation: "url", @@ -13908,7 +17491,7 @@ return this._addCheck({ kind: "ip", ...errorUtil$1.errToObj(options) }); } datetime(options) { - var _a; + var _a2; if (typeof options === "string") { return this._addCheck({ kind: "datetime", @@ -13920,7 +17503,7 @@ return this._addCheck({ kind: "datetime", precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, ...errorUtil$1.errToObj(options === null || options === void 0 ? void 0 : options.message) }); } @@ -13975,59 +17558,59 @@ }); } get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); } get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); + return !!this._def.checks.find((ch2) => ch2.kind === "email"); } get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); + return !!this._def.checks.find((ch2) => ch2.kind === "url"); } get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); } get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); } get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); } get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); } get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); } get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); } get minLength() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxLength() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } }; ZodString$1.create = (params) => { - var _a; + var _a2; return new ZodString$1({ checks: [], typeName: ZodFirstPartyTypeKind$1.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, ...processCreateParams$1(params) }); }; @@ -14225,38 +17808,38 @@ } get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util$1.isInteger(ch.value)); + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util$1.isInteger(ch2.value)); } get isFinite() { let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return Number.isFinite(min) && Number.isFinite(max); @@ -14408,31 +17991,31 @@ } get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } }; ZodBigInt$1.create = (params) => { - var _a; + var _a2; return new ZodBigInt$1({ checks: [], typeName: ZodFirstPartyTypeKind$1.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, ...processCreateParams$1(params) }); }; @@ -14543,20 +18126,20 @@ } get minDate() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min != null ? new Date(min) : null; } get maxDate() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max != null ? new Date(max) : null; @@ -14938,8 +18521,8 @@ unknownKeys: "strict", ...message !== void 0 ? { errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; if (issue.code === "unrecognized_keys") return { message: (_d = errorUtil$1.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError @@ -15402,1197 +18985,4719 @@ const merged = mergeValues$1(parsedLeft.value, parsedRight.value); if (!merged.valid) { addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_intersection_types + code: ZodIssueCode$1.invalid_intersection_types + }); + return INVALID$1; + } + if (isDirty$1(parsedLeft) || isDirty$1(parsedRight)) { + status.dirty(); + } + return { status: status.value, value: merged.data }; + }; + if (ctx.common.async) { + return Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)); + } else { + return handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); + } + } + }; + ZodIntersection$1.create = (left, right, params) => { + return new ZodIntersection$1({ + left, + right, + typeName: ZodFirstPartyTypeKind$1.ZodIntersection, + ...processCreateParams$1(params) + }); + }; + let ZodTuple$1 = class ZodTuple2 extends ZodType$1 { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.array) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.array, + received: ctx.parsedType + }); + return INVALID$1; + } + if (ctx.data.length < this._def.items.length) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_small, + minimum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + return INVALID$1; + } + const rest = this._def.rest; + if (!rest && ctx.data.length > this._def.items.length) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + maximum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + status.dirty(); + } + const items = [...ctx.data].map((item, itemIndex) => { + const schema = this._def.items[itemIndex] || this._def.rest; + if (!schema) + return null; + return schema._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, itemIndex)); + }).filter((x2) => !!x2); + if (ctx.common.async) { + return Promise.all(items).then((results2) => { + return ParseStatus$1.mergeArray(status, results2); + }); + } else { + return ParseStatus$1.mergeArray(status, items); + } + } + get items() { + return this._def.items; + } + rest(rest) { + return new ZodTuple2({ + ...this._def, + rest + }); + } + }; + ZodTuple$1.create = (schemas, params) => { + if (!Array.isArray(schemas)) { + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + } + return new ZodTuple$1({ + items: schemas, + typeName: ZodFirstPartyTypeKind$1.ZodTuple, + rest: null, + ...processCreateParams$1(params) + }); + }; + let ZodRecord$1 = class ZodRecord2 extends ZodType$1 { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.object) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.object, + received: ctx.parsedType + }); + return INVALID$1; + } + const pairs = []; + const keyType = this._def.keyType; + const valueType = this._def.valueType; + for (const key in ctx.data) { + pairs.push({ + key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath$1(ctx, ctx.data[key], ctx.path, key)) + }); + } + if (ctx.common.async) { + return ParseStatus$1.mergeObjectAsync(status, pairs); + } else { + return ParseStatus$1.mergeObjectSync(status, pairs); + } + } + get element() { + return this._def.valueType; + } + static create(first, second, third) { + if (second instanceof ZodType$1) { + return new ZodRecord2({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind$1.ZodRecord, + ...processCreateParams$1(third) + }); + } + return new ZodRecord2({ + keyType: ZodString$1.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind$1.ZodRecord, + ...processCreateParams$1(second) + }); + } + }; + let ZodMap$1 = class ZodMap extends ZodType$1 { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.map) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.map, + received: ctx.parsedType + }); + return INVALID$1; + } + const keyType = this._def.keyType; + const valueType = this._def.valueType; + const pairs = [...ctx.data.entries()].map(([key, value], index) => { + return { + key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, [index, "key"])), + value: valueType._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, [index, "value"])) + }; + }); + if (ctx.common.async) { + const finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (const pair of pairs) { + const key = await pair.key; + const value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID$1; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + const finalMap = /* @__PURE__ */ new Map(); + for (const pair of pairs) { + const key = pair.key; + const value = pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID$1; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } + } + }; + ZodMap$1.create = (keyType, valueType, params) => { + return new ZodMap$1({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind$1.ZodMap, + ...processCreateParams$1(params) + }); + }; + let ZodSet$1 = class ZodSet2 extends ZodType$1 { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.set) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.set, + received: ctx.parsedType + }); + return INVALID$1; + } + const def = this._def; + if (def.minSize !== null) { + if (ctx.data.size < def.minSize.value) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_small, + minimum: def.minSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.minSize.message + }); + status.dirty(); + } + } + if (def.maxSize !== null) { + if (ctx.data.size > def.maxSize.value) { + addIssueToContext$1(ctx, { + code: ZodIssueCode$1.too_big, + maximum: def.maxSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.maxSize.message }); - return INVALID$1; - } - if (isDirty$1(parsedLeft) || isDirty$1(parsedRight)) { status.dirty(); } - return { status: status.value, value: merged.data }; - }; + } + const valueType = this._def.valueType; + function finalizeSet(elements2) { + const parsedSet = /* @__PURE__ */ new Set(); + for (const element of elements2) { + if (element.status === "aborted") + return INVALID$1; + if (element.status === "dirty") + status.dirty(); + parsedSet.add(element.value); + } + return { status: status.value, value: parsedSet }; + } + const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, i2))); if (ctx.common.async) { - return Promise.all([ - this._def.left._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), - this._def.right._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }) - ]).then(([left, right]) => handleParsed(left, right)); + return Promise.all(elements).then((elements2) => finalizeSet(elements2)); } else { - return handleParsed(this._def.left._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), this._def.right._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - })); + return finalizeSet(elements); } } + min(minSize, message) { + return new ZodSet2({ + ...this._def, + minSize: { value: minSize, message: errorUtil$1.toString(message) } + }); + } + max(maxSize, message) { + return new ZodSet2({ + ...this._def, + maxSize: { value: maxSize, message: errorUtil$1.toString(message) } + }); + } + size(size, message) { + return this.min(size, message).max(size, message); + } + nonempty(message) { + return this.min(1, message); + } }; - ZodIntersection$1.create = (left, right, params) => { - return new ZodIntersection$1({ - left, - right, - typeName: ZodFirstPartyTypeKind$1.ZodIntersection, + ZodSet$1.create = (valueType, params) => { + return new ZodSet$1({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind$1.ZodSet, ...processCreateParams$1(params) }); }; - let ZodTuple$1 = class ZodTuple2 extends ZodType$1 { + let ZodFunction$1 = class ZodFunction2 extends ZodType$1 { + constructor() { + super(...arguments); + this.validate = this.implement; + } _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.array) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.function) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.array, + expected: ZodParsedType$1.function, received: ctx.parsedType }); return INVALID$1; } - if (ctx.data.length < this._def.items.length) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - minimum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" + function makeArgsIssue(args, error) { + return makeIssue$1({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap$1(), + errorMap$1 + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode$1.invalid_arguments, + argumentsError: error + } }); - return INVALID$1; } - const rest = this._def.rest; - if (!rest && ctx.data.length > this._def.items.length) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - maximum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" + function makeReturnsIssue(returns, error) { + return makeIssue$1({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap$1(), + errorMap$1 + ].filter((x2) => !!x2), + issueData: { + code: ZodIssueCode$1.invalid_return_type, + returnTypeError: error + } }); - status.dirty(); } - const items = [...ctx.data].map((item, itemIndex) => { - const schema = this._def.items[itemIndex] || this._def.rest; - if (!schema) - return null; - return schema._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, itemIndex)); - }).filter((x2) => !!x2); - if (ctx.common.async) { - return Promise.all(items).then((results2) => { - return ParseStatus$1.mergeArray(status, results2); + const params = { errorMap: ctx.common.contextualErrorMap }; + const fn = ctx.data; + if (this._def.returns instanceof ZodPromise$1) { + return OK$1(async (...args) => { + const error = new ZodError$1([]); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { + error.addIssue(makeArgsIssue(args, e2)); + throw error; + }); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { + error.addIssue(makeReturnsIssue(result, e2)); + throw error; + }); + return parsedReturns; }); } else { - return ParseStatus$1.mergeArray(status, items); + return OK$1((...args) => { + const parsedArgs = this._def.args.safeParse(args, params); + if (!parsedArgs.success) { + throw new ZodError$1([makeArgsIssue(args, parsedArgs.error)]); + } + const result = fn(...parsedArgs.data); + const parsedReturns = this._def.returns.safeParse(result, params); + if (!parsedReturns.success) { + throw new ZodError$1([makeReturnsIssue(result, parsedReturns.error)]); + } + return parsedReturns.data; + }); } } - get items() { - return this._def.items; + parameters() { + return this._def.args; } - rest(rest) { - return new ZodTuple2({ + returnType() { + return this._def.returns; + } + args(...items) { + return new ZodFunction2({ ...this._def, - rest + args: ZodTuple$1.create(items).rest(ZodUnknown$1.create()) + }); + } + returns(returnType) { + return new ZodFunction2({ + ...this._def, + returns: returnType + }); + } + implement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + strictImplement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + static create(args, returns, params) { + return new ZodFunction2({ + args: args ? args : ZodTuple$1.create([]).rest(ZodUnknown$1.create()), + returns: returns || ZodUnknown$1.create(), + typeName: ZodFirstPartyTypeKind$1.ZodFunction, + ...processCreateParams$1(params) }); } }; - ZodTuple$1.create = (schemas, params) => { - if (!Array.isArray(schemas)) { - throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + let ZodLazy$1 = class ZodLazy extends ZodType$1 { + get schema() { + return this._def.getter(); } - return new ZodTuple$1({ - items: schemas, - typeName: ZodFirstPartyTypeKind$1.ZodTuple, - rest: null, + _parse(input) { + const { ctx } = this._processInputParams(input); + const lazySchema = this._def.getter(); + return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + } + }; + ZodLazy$1.create = (getter, params) => { + return new ZodLazy$1({ + getter, + typeName: ZodFirstPartyTypeKind$1.ZodLazy, + ...processCreateParams$1(params) + }); + }; + let ZodLiteral$1 = class ZodLiteral extends ZodType$1 { + _parse(input) { + if (input.data !== this._def.value) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext$1(ctx, { + received: ctx.data, + code: ZodIssueCode$1.invalid_literal, + expected: this._def.value + }); + return INVALID$1; + } + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } + }; + ZodLiteral$1.create = (value, params) => { + return new ZodLiteral$1({ + value, + typeName: ZodFirstPartyTypeKind$1.ZodLiteral, + ...processCreateParams$1(params) + }); + }; + function createZodEnum$1(values, params) { + return new ZodEnum$1({ + values, + typeName: ZodFirstPartyTypeKind$1.ZodEnum, ...processCreateParams$1(params) }); - }; - let ZodRecord$1 = class ZodRecord2 extends ZodType$1 { - get keySchema() { - return this._def.keyType; - } - get valueSchema() { - return this._def.valueType; - } + } + let ZodEnum$1 = class ZodEnum2 extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.object) { + if (typeof input.data !== "string") { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.object, - received: ctx.parsedType + expected: util$1.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode$1.invalid_type }); return INVALID$1; } - const pairs = []; - const keyType = this._def.keyType; - const valueType = this._def.valueType; - for (const key in ctx.data) { - pairs.push({ - key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, key)), - value: valueType._parse(new ParseInputLazyPath$1(ctx, ctx.data[key], ctx.path, key)) + if (this._def.values.indexOf(input.data) === -1) { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext$1(ctx, { + received: ctx.data, + code: ZodIssueCode$1.invalid_enum_value, + options: expectedValues }); + return INVALID$1; } - if (ctx.common.async) { - return ParseStatus$1.mergeObjectAsync(status, pairs); - } else { - return ParseStatus$1.mergeObjectSync(status, pairs); + return OK$1(input.data); + } + get options() { + return this._def.values; + } + get enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; } + return enumValues; } - get element() { - return this._def.valueType; + get Values() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; } - static create(first, second, third) { - if (second instanceof ZodType$1) { - return new ZodRecord2({ - keyType: first, - valueType: second, - typeName: ZodFirstPartyTypeKind$1.ZodRecord, - ...processCreateParams$1(third) - }); + get Enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; } - return new ZodRecord2({ - keyType: ZodString$1.create(), - valueType: first, - typeName: ZodFirstPartyTypeKind$1.ZodRecord, - ...processCreateParams$1(second) - }); + return enumValues; + } + extract(values) { + return ZodEnum2.create(values); + } + exclude(values) { + return ZodEnum2.create(this.options.filter((opt) => !values.includes(opt))); } }; - let ZodMap$1 = class ZodMap extends ZodType$1 { + ZodEnum$1.create = createZodEnum$1; + let ZodNativeEnum$1 = class ZodNativeEnum extends ZodType$1 { _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.map) { + const nativeEnumValues = util$1.getValidEnumValues(this._def.values); + const ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType$1.string && ctx.parsedType !== ZodParsedType$1.number) { + const expectedValues = util$1.objectValues(nativeEnumValues); addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.map, - received: ctx.parsedType + expected: util$1.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode$1.invalid_type }); return INVALID$1; } - const keyType = this._def.keyType; - const valueType = this._def.valueType; - const pairs = [...ctx.data.entries()].map(([key, value], index) => { - return { - key: keyType._parse(new ParseInputLazyPath$1(ctx, key, ctx.path, [index, "key"])), - value: valueType._parse(new ParseInputLazyPath$1(ctx, value, ctx.path, [index, "value"])) - }; - }); - if (ctx.common.async) { - const finalMap = /* @__PURE__ */ new Map(); - return Promise.resolve().then(async () => { - for (const pair of pairs) { - const key = await pair.key; - const value = await pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID$1; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; + if (nativeEnumValues.indexOf(input.data) === -1) { + const expectedValues = util$1.objectValues(nativeEnumValues); + addIssueToContext$1(ctx, { + received: ctx.data, + code: ZodIssueCode$1.invalid_enum_value, + options: expectedValues }); - } else { - const finalMap = /* @__PURE__ */ new Map(); - for (const pair of pairs) { - const key = pair.key; - const value = pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return INVALID$1; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; + return INVALID$1; } + return OK$1(input.data); + } + get enum() { + return this._def.values; } }; - ZodMap$1.create = (keyType, valueType, params) => { - return new ZodMap$1({ - valueType, - keyType, - typeName: ZodFirstPartyTypeKind$1.ZodMap, + ZodNativeEnum$1.create = (values, params) => { + return new ZodNativeEnum$1({ + values, + typeName: ZodFirstPartyTypeKind$1.ZodNativeEnum, ...processCreateParams$1(params) }); }; - let ZodSet$1 = class ZodSet2 extends ZodType$1 { + let ZodPromise$1 = class ZodPromise extends ZodType$1 { + unwrap() { + return this._def.type; + } _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.set) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType$1.promise && ctx.common.async === false) { addIssueToContext$1(ctx, { code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.set, + expected: ZodParsedType$1.promise, received: ctx.parsedType }); return INVALID$1; } - const def = this._def; - if (def.minSize !== null) { - if (ctx.data.size < def.minSize.value) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_small, - minimum: def.minSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.minSize.message + const promisified = ctx.parsedType === ZodParsedType$1.promise ? ctx.data : Promise.resolve(ctx.data); + return OK$1(promisified.then((data2) => { + return this._def.type.parseAsync(data2, { + path: ctx.path, + errorMap: ctx.common.contextualErrorMap + }); + })); + } + }; + ZodPromise$1.create = (schema, params) => { + return new ZodPromise$1({ + type: schema, + typeName: ZodFirstPartyTypeKind$1.ZodPromise, + ...processCreateParams$1(params) + }); + }; + let ZodEffects$1 = class ZodEffects extends ZodType$1 { + innerType() { + return this._def.schema; + } + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind$1.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const effect = this._def.effect || null; + if (effect.type === "preprocess") { + const processed = effect.transform(ctx.data); + if (ctx.common.async) { + return Promise.resolve(processed).then((processed2) => { + return this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + }); + }); + } else { + return this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx }); - status.dirty(); } } - if (def.maxSize !== null) { - if (ctx.data.size > def.maxSize.value) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.too_big, - maximum: def.maxSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.maxSize.message + const checkCtx = { + addIssue: (arg) => { + addIssueToContext$1(ctx, arg); + if (arg.fatal) { + status.abort(); + } else { + status.dirty(); + } + }, + get path() { + return ctx.path; + } + }; + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); + if (effect.type === "refinement") { + const executeRefinement = (acc) => { + const result = effect.refinement(acc, checkCtx); + if (ctx.common.async) { + return Promise.resolve(result); + } + if (result instanceof Promise) { + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + } + return acc; + }; + if (ctx.common.async === false) { + const inner = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx }); - status.dirty(); - } - } - const valueType = this._def.valueType; - function finalizeSet(elements2) { - const parsedSet = /* @__PURE__ */ new Set(); - for (const element of elements2) { - if (element.status === "aborted") + if (inner.status === "aborted") return INVALID$1; - if (element.status === "dirty") + if (inner.status === "dirty") status.dirty(); - parsedSet.add(element.value); + executeRefinement(inner.value); + return { status: status.value, value: inner.value }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { + if (inner.status === "aborted") + return INVALID$1; + if (inner.status === "dirty") + status.dirty(); + return executeRefinement(inner.value).then(() => { + return { status: status.value, value: inner.value }; + }); + }); } - return { status: status.value, value: parsedSet }; } - const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath$1(ctx, item, ctx.path, i2))); - if (ctx.common.async) { - return Promise.all(elements).then((elements2) => finalizeSet(elements2)); - } else { - return finalizeSet(elements); + if (effect.type === "transform") { + if (ctx.common.async === false) { + const base3 = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (!isValid$1(base3)) + return base3; + const result = effect.transform(base3.value, checkCtx); + if (result instanceof Promise) { + throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + } + return { status: status.value, value: result }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { + if (!isValid$1(base3)) + return base3; + return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); + }); + } } + util$1.assertNever(effect); } - min(minSize, message) { - return new ZodSet2({ - ...this._def, - minSize: { value: minSize, message: errorUtil$1.toString(message) } - }); + }; + ZodEffects$1.create = (schema, effect, params) => { + return new ZodEffects$1({ + schema, + typeName: ZodFirstPartyTypeKind$1.ZodEffects, + effect, + ...processCreateParams$1(params) + }); + }; + ZodEffects$1.createWithPreprocess = (preprocess, schema, params) => { + return new ZodEffects$1({ + schema, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind$1.ZodEffects, + ...processCreateParams$1(params) + }); + }; + let ZodOptional$1 = class ZodOptional extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType$1.undefined) { + return OK$1(void 0); + } + return this._def.innerType._parse(input); } - max(maxSize, message) { - return new ZodSet2({ - ...this._def, - maxSize: { value: maxSize, message: errorUtil$1.toString(message) } - }); + unwrap() { + return this._def.innerType; } - size(size, message) { - return this.min(size, message).max(size, message); + }; + ZodOptional$1.create = (type2, params) => { + return new ZodOptional$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodOptional, + ...processCreateParams$1(params) + }); + }; + let ZodNullable$1 = class ZodNullable extends ZodType$1 { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType$1.null) { + return OK$1(null); + } + return this._def.innerType._parse(input); } - nonempty(message) { - return this.min(1, message); + unwrap() { + return this._def.innerType; } }; - ZodSet$1.create = (valueType, params) => { - return new ZodSet$1({ - valueType, - minSize: null, - maxSize: null, - typeName: ZodFirstPartyTypeKind$1.ZodSet, + ZodNullable$1.create = (type2, params) => { + return new ZodNullable$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodNullable, ...processCreateParams$1(params) }); }; - let ZodFunction$1 = class ZodFunction2 extends ZodType$1 { - constructor() { - super(...arguments); - this.validate = this.implement; - } + let ZodDefault$1 = class ZodDefault extends ZodType$1 { _parse(input) { const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.function) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.function, - received: ctx.parsedType - }); - return INVALID$1; - } - function makeArgsIssue(args, error) { - return makeIssue$1({ - data: args, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap$1(), - errorMap$1 - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode$1.invalid_arguments, - argumentsError: error - } - }); - } - function makeReturnsIssue(returns, error) { - return makeIssue$1({ - data: returns, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - getErrorMap$1(), - errorMap$1 - ].filter((x2) => !!x2), - issueData: { - code: ZodIssueCode$1.invalid_return_type, - returnTypeError: error - } - }); - } - const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; - if (this._def.returns instanceof ZodPromise$1) { - return OK$1(async (...args) => { - const error = new ZodError$1([]); - const parsedArgs = await this._def.args.parseAsync(args, params).catch((e2) => { - error.addIssue(makeArgsIssue(args, e2)); - throw error; - }); - const result = await fn2(...parsedArgs); - const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { - error.addIssue(makeReturnsIssue(result, e2)); - throw error; - }); - return parsedReturns; - }); - } else { - return OK$1((...args) => { - const parsedArgs = this._def.args.safeParse(args, params); - if (!parsedArgs.success) { - throw new ZodError$1([makeArgsIssue(args, parsedArgs.error)]); - } - const result = fn2(...parsedArgs.data); - const parsedReturns = this._def.returns.safeParse(result, params); - if (!parsedReturns.success) { - throw new ZodError$1([makeReturnsIssue(result, parsedReturns.error)]); - } - return parsedReturns.data; - }); + let data2 = ctx.data; + if (ctx.parsedType === ZodParsedType$1.undefined) { + data2 = this._def.defaultValue(); } - } - parameters() { - return this._def.args; - } - returnType() { - return this._def.returns; - } - args(...items) { - return new ZodFunction2({ - ...this._def, - args: ZodTuple$1.create(items).rest(ZodUnknown$1.create()) - }); - } - returns(returnType) { - return new ZodFunction2({ - ...this._def, - returns: returnType + return this._def.innerType._parse({ + data: data2, + path: ctx.path, + parent: ctx }); } - implement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - strictImplement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; + removeDefault() { + return this._def.innerType; } - static create(args, returns, params) { - return new ZodFunction2({ - args: args ? args : ZodTuple$1.create([]).rest(ZodUnknown$1.create()), - returns: returns || ZodUnknown$1.create(), - typeName: ZodFirstPartyTypeKind$1.ZodFunction, - ...processCreateParams$1(params) + }; + ZodDefault$1.create = (type2, params) => { + return new ZodDefault$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodDefault, + defaultValue: typeof params.default === "function" ? params.default : () => params.default, + ...processCreateParams$1(params) + }); + }; + let ZodCatch$1 = class ZodCatch extends ZodType$1 { + _parse(input) { + const { ctx } = this._processInputParams(input); + const newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + } + }; + const result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx + } }); + if (isAsync$1(result)) { + return result.then((result2) => { + return { + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError$1(newCtx.common.issues); + } + }) + }; + }); + } else { + return { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError$1(newCtx.common.issues); + } + }) + }; + } } - }; - let ZodLazy$1 = class ZodLazy extends ZodType$1 { - get schema() { - return this._def.getter(); - } - _parse(input) { - const { ctx } = this._processInputParams(input); - const lazySchema = this._def.getter(); - return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + removeCatch() { + return this._def.innerType; } }; - ZodLazy$1.create = (getter, params) => { - return new ZodLazy$1({ - getter, - typeName: ZodFirstPartyTypeKind$1.ZodLazy, + ZodCatch$1.create = (type2, params) => { + return new ZodCatch$1({ + innerType: type2, + typeName: ZodFirstPartyTypeKind$1.ZodCatch, + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, ...processCreateParams$1(params) }); }; - let ZodLiteral$1 = class ZodLiteral extends ZodType$1 { + let ZodNaN$1 = class ZodNaN extends ZodType$1 { _parse(input) { - if (input.data !== this._def.value) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType$1.nan) { const ctx = this._getOrReturnCtx(input); addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_literal, - expected: this._def.value + code: ZodIssueCode$1.invalid_type, + expected: ZodParsedType$1.nan, + received: ctx.parsedType }); return INVALID$1; } return { status: "valid", value: input.data }; } - get value() { - return this._def.value; + }; + ZodNaN$1.create = (params) => { + return new ZodNaN$1({ + typeName: ZodFirstPartyTypeKind$1.ZodNaN, + ...processCreateParams$1(params) + }); + }; + const BRAND$1 = Symbol("zod_brand"); + let ZodBranded$1 = class ZodBranded extends ZodType$1 { + _parse(input) { + const { ctx } = this._processInputParams(input); + const data2 = ctx.data; + return this._def.type._parse({ + data: data2, + path: ctx.path, + parent: ctx + }); + } + unwrap() { + return this._def.type; + } + }; + let ZodPipeline$1 = class ZodPipeline2 extends ZodType$1 { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.common.async) { + const handleAsync = async () => { + const inResult = await this._def.in._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID$1; + if (inResult.status === "dirty") { + status.dirty(); + return DIRTY$1(inResult.value); + } else { + return this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + }; + return handleAsync(); + } else { + const inResult = this._def.in._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID$1; + if (inResult.status === "dirty") { + status.dirty(); + return { + status: "dirty", + value: inResult.value + }; + } else { + return this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + } + } + static create(a3, b3) { + return new ZodPipeline2({ + in: a3, + out: b3, + typeName: ZodFirstPartyTypeKind$1.ZodPipeline + }); + } + }; + const custom$1 = (check, params = {}, fatal) => { + if (check) + return ZodAny$1.create().superRefine((data2, ctx) => { + var _a2, _b; + if (!check(data2)) { + const p2 = typeof params === "function" ? params(data2) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; + ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); + } + }); + return ZodAny$1.create(); + }; + const late$1 = { + object: ZodObject$1.lazycreate + }; + var ZodFirstPartyTypeKind$1; + (function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; + ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; + ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; + ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; + ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; + ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; + ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; + ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; + ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; + ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; + ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; + ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; + ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; + ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; + ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; + ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; + ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; + ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; + ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; + ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; + ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; + ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; + ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; + ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; + ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; + ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; + ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; + ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; + ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; + ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; + ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; + ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; + ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; + ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; + ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; + })(ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {})); + const instanceOfType$1 = (cls, params = { + message: `Input not instance of ${cls.name}` + }) => custom$1((data2) => data2 instanceof cls, params); + const stringType$1 = ZodString$1.create; + const numberType$1 = ZodNumber$1.create; + const nanType$1 = ZodNaN$1.create; + const bigIntType$1 = ZodBigInt$1.create; + const booleanType$1 = ZodBoolean$1.create; + const dateType$1 = ZodDate$1.create; + const symbolType$1 = ZodSymbol$1.create; + const undefinedType$1 = ZodUndefined$1.create; + const nullType$1 = ZodNull$1.create; + const anyType$1 = ZodAny$1.create; + const unknownType$1 = ZodUnknown$1.create; + const neverType$1 = ZodNever$1.create; + const voidType$1 = ZodVoid$1.create; + const arrayType$1 = ZodArray$1.create; + const objectType$1 = ZodObject$1.create; + const strictObjectType$1 = ZodObject$1.strictCreate; + const unionType$1 = ZodUnion$1.create; + const discriminatedUnionType$1 = ZodDiscriminatedUnion$1.create; + const intersectionType$1 = ZodIntersection$1.create; + const tupleType$1 = ZodTuple$1.create; + const recordType$1 = ZodRecord$1.create; + const mapType$1 = ZodMap$1.create; + const setType$1 = ZodSet$1.create; + const functionType$1 = ZodFunction$1.create; + const lazyType$1 = ZodLazy$1.create; + const literalType$1 = ZodLiteral$1.create; + const enumType$1 = ZodEnum$1.create; + const nativeEnumType$1 = ZodNativeEnum$1.create; + const promiseType$1 = ZodPromise$1.create; + const effectsType$1 = ZodEffects$1.create; + const optionalType$1 = ZodOptional$1.create; + const nullableType$1 = ZodNullable$1.create; + const preprocessType$1 = ZodEffects$1.createWithPreprocess; + const pipelineType$1 = ZodPipeline$1.create; + const ostring$1 = () => stringType$1().optional(); + const onumber$1 = () => numberType$1().optional(); + const oboolean$1 = () => booleanType$1().optional(); + const coerce$2 = { + string: (arg) => ZodString$1.create({ ...arg, coerce: true }), + number: (arg) => ZodNumber$1.create({ ...arg, coerce: true }), + boolean: (arg) => ZodBoolean$1.create({ + ...arg, + coerce: true + }), + bigint: (arg) => ZodBigInt$1.create({ ...arg, coerce: true }), + date: (arg) => ZodDate$1.create({ ...arg, coerce: true }) + }; + const NEVER$1 = INVALID$1; + var z$5 = /* @__PURE__ */ Object.freeze({ + __proto__: null, + defaultErrorMap: errorMap$1, + setErrorMap: setErrorMap$1, + getErrorMap: getErrorMap$1, + makeIssue: makeIssue$1, + EMPTY_PATH: EMPTY_PATH$1, + addIssueToContext: addIssueToContext$1, + ParseStatus: ParseStatus$1, + INVALID: INVALID$1, + DIRTY: DIRTY$1, + OK: OK$1, + isAborted: isAborted$1, + isDirty: isDirty$1, + isValid: isValid$1, + isAsync: isAsync$1, + get util() { + return util$1; + }, + get objectUtil() { + return objectUtil$1; + }, + ZodParsedType: ZodParsedType$1, + getParsedType: getParsedType$1, + ZodType: ZodType$1, + ZodString: ZodString$1, + ZodNumber: ZodNumber$1, + ZodBigInt: ZodBigInt$1, + ZodBoolean: ZodBoolean$1, + ZodDate: ZodDate$1, + ZodSymbol: ZodSymbol$1, + ZodUndefined: ZodUndefined$1, + ZodNull: ZodNull$1, + ZodAny: ZodAny$1, + ZodUnknown: ZodUnknown$1, + ZodNever: ZodNever$1, + ZodVoid: ZodVoid$1, + ZodArray: ZodArray$1, + ZodObject: ZodObject$1, + ZodUnion: ZodUnion$1, + ZodDiscriminatedUnion: ZodDiscriminatedUnion$1, + ZodIntersection: ZodIntersection$1, + ZodTuple: ZodTuple$1, + ZodRecord: ZodRecord$1, + ZodMap: ZodMap$1, + ZodSet: ZodSet$1, + ZodFunction: ZodFunction$1, + ZodLazy: ZodLazy$1, + ZodLiteral: ZodLiteral$1, + ZodEnum: ZodEnum$1, + ZodNativeEnum: ZodNativeEnum$1, + ZodPromise: ZodPromise$1, + ZodEffects: ZodEffects$1, + ZodTransformer: ZodEffects$1, + ZodOptional: ZodOptional$1, + ZodNullable: ZodNullable$1, + ZodDefault: ZodDefault$1, + ZodCatch: ZodCatch$1, + ZodNaN: ZodNaN$1, + BRAND: BRAND$1, + ZodBranded: ZodBranded$1, + ZodPipeline: ZodPipeline$1, + custom: custom$1, + Schema: ZodType$1, + ZodSchema: ZodType$1, + late: late$1, + get ZodFirstPartyTypeKind() { + return ZodFirstPartyTypeKind$1; + }, + coerce: coerce$2, + any: anyType$1, + array: arrayType$1, + bigint: bigIntType$1, + boolean: booleanType$1, + date: dateType$1, + discriminatedUnion: discriminatedUnionType$1, + effect: effectsType$1, + "enum": enumType$1, + "function": functionType$1, + "instanceof": instanceOfType$1, + intersection: intersectionType$1, + lazy: lazyType$1, + literal: literalType$1, + map: mapType$1, + nan: nanType$1, + nativeEnum: nativeEnumType$1, + never: neverType$1, + "null": nullType$1, + nullable: nullableType$1, + number: numberType$1, + object: objectType$1, + oboolean: oboolean$1, + onumber: onumber$1, + optional: optionalType$1, + ostring: ostring$1, + pipeline: pipelineType$1, + preprocess: preprocessType$1, + promise: promiseType$1, + record: recordType$1, + set: setType$1, + strictObject: strictObjectType$1, + string: stringType$1, + symbol: symbolType$1, + transformer: effectsType$1, + tuple: tupleType$1, + "undefined": undefinedType$1, + union: unionType$1, + unknown: unknownType$1, + "void": voidType$1, + NEVER: NEVER$1, + ZodIssueCode: ZodIssueCode$1, + quotelessJson: quotelessJson$1, + ZodError: ZodError$1 + }); + const aleoAddressRegex$1 = /^aleo1[a-z0-9]{58}$/i; + const aleoViewKeyRegex$1 = /^AViewKey1[a-z0-9]{44}$/i; + const aleoPrivateKeyRegex$1 = /^APrivateKey1[a-z0-9]{47}$/i; + const aleoTransitionIdRegex$1 = /^au1[a-z0-9]{58}$/i; + const aleoTransactionIdRegex$1 = /^at1[a-z0-9]{58}$/i; + const aleoFieldRegex$1 = /^\d+field$/; + const aleoU32$1 = /^\d+u32$/; + const aleoU64$1 = /^\d+u64$/; + z$5.string().regex(aleoAddressRegex$1); + z$5.string().regex(aleoViewKeyRegex$1); + z$5.string().regex(aleoPrivateKeyRegex$1); + z$5.string().regex(aleoTransitionIdRegex$1); + z$5.string().regex(aleoTransactionIdRegex$1); + z$5.string().regex(aleoFieldRegex$1); + z$5.string().regex(aleoU32$1); + z$5.string().regex(aleoU64$1); + var InputOutputType$1; + (function(InputOutputType2) { + InputOutputType2["Record"] = "record"; + InputOutputType2["OutputRecord"] = "outputRecord"; + InputOutputType2["Public"] = "public"; + InputOutputType2["Private"] = "private"; + InputOutputType2["Constant"] = "constant"; + InputOutputType2["Future"] = "future"; + InputOutputType2["ExternalRecord"] = "external_record"; + })(InputOutputType$1 || (InputOutputType$1 = {})); + var EventType; + (function(EventType2) { + EventType2["Deploy"] = "Deploy"; + EventType2["Execute"] = "Execute"; + EventType2["Send"] = "Send"; + EventType2["Receive"] = "Receive"; + EventType2["Join"] = "Join"; + EventType2["Split"] = "Split"; + EventType2["Shield"] = "Shield"; + EventType2["Unshield"] = "Unshield"; + EventType2["Referral"] = "Referral"; + EventType2["Points"] = "Points"; + EventType2["Raffle"] = "Raffle"; + })(EventType || (EventType = {})); + var EventStatus; + (function(EventStatus2) { + EventStatus2["Creating"] = "Creating"; + EventStatus2["Pending"] = "Pending"; + EventStatus2["Settled"] = "Settled"; + EventStatus2["Failed"] = "Failed"; + })(EventStatus || (EventStatus = {})); + var Visibility; + (function(Visibility2) { + Visibility2["Private"] = "Private"; + Visibility2["Public"] = "Public"; + })(Visibility || (Visibility = {})); + var Network; + (function(Network2) { + Network2["AleoTestnet"] = "AleoTestnet"; + Network2["AleoCanarynet"] = "AleoCanarynet"; + Network2["AleoMainnet"] = "AleoMainnet"; + })(Network || (Network = {})); + z$5.nativeEnum(EventType); + z$5.nativeEnum(EventStatus); + z$5.nativeEnum(Network); + z$5.nativeEnum(Visibility); + const wc_aleo_methods$1 = [ + "decrypt", + "disconnect", + "getSelectedAccount", + "getBalance", + "getRecords", + "requestCreateEvent", + "getEvent", + "getEvents", + "createSharedState", + "importSharedState", + "requestSignature" + ]; + const wc_required_aleo_chains$1 = ["aleo:1"]; + const wc_optional_aleo_chains$1 = [ + "aleo:0" + // for eventual mainnet + ]; + const wc_aleo_chains$1 = [ + ...wc_required_aleo_chains$1, + ...wc_optional_aleo_chains$1 + ]; + const wc_events$1 = [ + "chainChanged", + "accountSelected", + "selectedAccountSynced", + "sharedAccountSynced" + ]; + const projectId$1 = "f0aaeffe71b636da453fce042d79d723"; + function isAndroid$1() { + if (typeof navigator === "undefined") { + return false; } - }; - ZodLiteral$1.create = (value, params) => { - return new ZodLiteral$1({ - value, - typeName: ZodFirstPartyTypeKind$1.ZodLiteral, - ...processCreateParams$1(params) - }); - }; - function createZodEnum$1(values, params) { - return new ZodEnum$1({ - values, - typeName: ZodFirstPartyTypeKind$1.ZodEnum, - ...processCreateParams$1(params) - }); + return /Android/i.test(navigator.userAgent); } - let ZodEnum$1 = class ZodEnum2 extends ZodType$1 { - _parse(input) { - if (typeof input.data !== "string") { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext$1(ctx, { - expected: util$1.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode$1.invalid_type - }); - return INVALID$1; - } - if (this._def.values.indexOf(input.data) === -1) { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_enum_value, - options: expectedValues - }); - return INVALID$1; - } - return OK$1(input.data); - } - get options() { - return this._def.values; - } - get enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - get Values() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - get Enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; + const web3modal_puzzle_props_android$1 = { + projectId: projectId$1, + chains: wc_aleo_chains$1, + enableExplorer: true, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } } - return enumValues; - } - extract(values) { - return ZodEnum2.create(values); - } - exclude(values) { - return ZodEnum2.create(this.options.filter((opt) => !values.includes(opt))); - } - }; - ZodEnum$1.create = createZodEnum$1; - let ZodNativeEnum$1 = class ZodNativeEnum extends ZodType$1 { - _parse(input) { - const nativeEnumValues = util$1.getValidEnumValues(this._def.values); - const ctx = this._getOrReturnCtx(input); - if (ctx.parsedType !== ZodParsedType$1.string && ctx.parsedType !== ZodParsedType$1.number) { - const expectedValues = util$1.objectValues(nativeEnumValues); - addIssueToContext$1(ctx, { - expected: util$1.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodIssueCode$1.invalid_type - }); - return INVALID$1; + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png" + } + }; + const web3modal_puzzle_props_default$1 = { + projectId: projectId$1, + chains: wc_aleo_chains$1, + enableExplorer: false, + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], + mobileWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "puzzleapp://", + universal: "" + } } - if (nativeEnumValues.indexOf(input.data) === -1) { - const expectedValues = util$1.objectValues(nativeEnumValues); - addIssueToContext$1(ctx, { - received: ctx.data, - code: ZodIssueCode$1.invalid_enum_value, - options: expectedValues - }); - return INVALID$1; + ], + desktopWallets: [ + { + id: "puzzle", + name: "Puzzle Wallet", + links: { + native: "", + universal: "https://walletconnect.puzzle.online/" + } + }, + { + id: "avail", + name: "Avail Wallet", + links: { + native: "avail://", + universal: "https://avail.global" + } } - return OK$1(input.data); + ], + walletImages: { + puzzle: "https://i.imgur.com/p9tHaFC.png", + avail: "https://i.imgur.com/GxNn8BO.png" } - get enum() { - return this._def.values; + }; + const web3modal_puzzle_props$1 = isAndroid$1() ? web3modal_puzzle_props_android$1 : web3modal_puzzle_props_default$1; + const name$1 = "@puzzlehq/sdk-core"; + const displayName$1 = "Puzzle SDK"; + const version$2 = "0.4.0"; + const description$1 = "Your portal to privacy"; + const main$1 = "./dist/puzzle.cjs.js"; + const module$1 = "./dist/puzzle.es.js"; + const browser$1$1 = "./dist/puzzle.umd.js"; + const types$3 = "./dist/types/src/index.d.ts"; + const exports$2 = { + ".": { + "import": "./dist/puzzle.es.js", + require: "./dist/puzzle.cjs.js", + browser: "./dist/puzzle.umd.js", + types: "./dist/types/src/index.d.ts" } }; - ZodNativeEnum$1.create = (values, params) => { - return new ZodNativeEnum$1({ - values, - typeName: ZodFirstPartyTypeKind$1.ZodNativeEnum, - ...processCreateParams$1(params) - }); + const type$1 = "module"; + const scripts$1 = { + "fetch-fix": "find dist -type f \\( -name '*.js' -o -name '*.cjs' \\) -exec sed -i '' 's/self.fetch[[:space:]]*||/fetch ||/g' {} \\;", + "ws-fix": `find ./dist -type f -name 'index*' -exec sed -i '' -e 's/require(\\"ws\\")/(() => {try { return require(\\"ws\\") } catch (e) { } })()/g' {} +;`, + build: "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types && pnpm fetch-fix && pnpm ws-fix", + "type-check": "tsc --noEmit" }; - let ZodPromise$1 = class ZodPromise extends ZodType$1 { - unwrap() { - return this._def.type; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== ZodParsedType$1.promise && ctx.common.async === false) { - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.promise, - received: ctx.parsedType - }); - return INVALID$1; - } - const promisified = ctx.parsedType === ZodParsedType$1.promise ? ctx.data : Promise.resolve(ctx.data); - return OK$1(promisified.then((data2) => { - return this._def.type.parseAsync(data2, { - path: ctx.path, - errorMap: ctx.common.contextualErrorMap - }); - })); - } + const repository$1 = { + type: "git", + url: "git+https://github.com/puzzlehq/puzzle-sdk.git" }; - ZodPromise$1.create = (schema, params) => { - return new ZodPromise$1({ - type: schema, - typeName: ZodFirstPartyTypeKind$1.ZodPromise, - ...processCreateParams$1(params) - }); + const dependencies$1 = { + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", + "@walletconnect/types": "^2.11.2", + "@walletconnect/utils": "^2.11.2", + debug: "^4.3.4", + events: "^3.3.0", + ws: "^8.16.0" }; - let ZodEffects$1 = class ZodEffects extends ZodType$1 { - innerType() { - return this._def.schema; - } - sourceType() { - return this._def.schema._def.typeName === ZodFirstPartyTypeKind$1.ZodEffects ? this._def.schema.sourceType() : this._def.schema; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const effect = this._def.effect || null; - if (effect.type === "preprocess") { - const processed = effect.transform(ctx.data); - if (ctx.common.async) { - return Promise.resolve(processed).then((processed2) => { - return this._def.schema._parseAsync({ - data: processed2, - path: ctx.path, - parent: ctx - }); - }); - } else { - return this._def.schema._parseSync({ - data: processed, - path: ctx.path, - parent: ctx - }); - } - } - const checkCtx = { - addIssue: (arg) => { - addIssueToContext$1(ctx, arg); - if (arg.fatal) { - status.abort(); - } else { - status.dirty(); - } - }, - get path() { - return ctx.path; - } + const peerDependencies$1 = { + buffer: "^6.0.3" + }; + const keywords$1 = [ + "puzzle", + "cryptocurrency wallet", + "privacy", + "aleo", + "web3", + "crypto", + "typescript" + ]; + const author$1 = "Puzzle"; + const license$1 = "ISC"; + const bugs$1 = { + url: "https://github.com/puzzlehq/puzzle-sdk/issues" + }; + const homepage$1 = "https://github.com/puzzlehq/puzzle-sdk#readme"; + const pkg$1 = { + name: name$1, + displayName: displayName$1, + version: version$2, + description: description$1, + main: main$1, + module: module$1, + browser: browser$1$1, + types: types$3, + "private": false, + exports: exports$2, + type: type$1, + scripts: scripts$1, + repository: repository$1, + dependencies: dependencies$1, + peerDependencies: peerDependencies$1, + keywords: keywords$1, + author: author$1, + license: license$1, + bugs: bugs$1, + homepage: homepage$1 + }; + var On = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; + function A0(e2) { + var t2 = e2.default; + if (typeof t2 == "function") { + var r3 = function() { + return t2.apply(this, arguments); }; - checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); - if (effect.type === "refinement") { - const executeRefinement = (acc) => { - const result = effect.refinement(acc, checkCtx); - if (ctx.common.async) { - return Promise.resolve(result); - } - if (result instanceof Promise) { - throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); - } - return acc; + r3.prototype = t2.prototype; + } else + r3 = {}; + return Object.defineProperty(r3, "__esModule", { value: true }), Object.keys(e2).forEach(function(i2) { + var n4 = Object.getOwnPropertyDescriptor(e2, i2); + Object.defineProperty(r3, i2, n4.get ? n4 : { enumerable: true, get: function() { + return e2[i2]; + } }); + }), r3; + } + var Pn = { exports: {} }; + /** + * [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 + */ + (function(e2) { + (function() { + var t2 = "input is invalid type", r3 = "finalize already called", i2 = typeof window == "object", n4 = i2 ? window : {}; + n4.JS_SHA3_NO_WINDOW && (i2 = false); + var o22 = !i2 && typeof self == "object", h4 = !n4.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + h4 ? n4 = On : o22 && (n4 = self); + var p2 = !n4.JS_SHA3_NO_COMMON_JS && true && e2.exports, b3 = !n4.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", m3 = "0123456789abcdef".split(""), w3 = [31, 7936, 2031616, 520093696], y3 = [4, 1024, 262144, 67108864], S2 = [1, 256, 65536, 16777216], I2 = [6, 1536, 393216, 100663296], N22 = [0, 8, 16, 24], C2 = [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], F2 = [224, 256, 384, 512], U2 = [128, 256], J2 = ["hex", "buffer", "arrayBuffer", "array", "digest"], Bt2 = { 128: 168, 256: 136 }; + (n4.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(u3) { + return Object.prototype.toString.call(u3) === "[object Array]"; + }), b3 && (n4.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(u3) { + return typeof u3 == "object" && u3.buffer && u3.buffer.constructor === ArrayBuffer; + }); + for (var G2 = function(u3, E2, _3) { + return function(B2) { + return new s22(u3, E2, u3).update(B2)[_3](); }; - if (ctx.common.async === false) { - const inner = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inner.status === "aborted") - return INVALID$1; - if (inner.status === "dirty") - status.dirty(); - executeRefinement(inner.value); - return { status: status.value, value: inner.value }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { - if (inner.status === "aborted") - return INVALID$1; - if (inner.status === "dirty") - status.dirty(); - return executeRefinement(inner.value).then(() => { - return { status: status.value, value: inner.value }; - }); - }); + }, H22 = function(u3, E2, _3) { + return function(B2, R2) { + return new s22(u3, E2, R2).update(B2)[_3](); + }; + }, z2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["cshake" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, Pt2 = function(u3, E2, _3) { + return function(B2, R2, T2, P2) { + return f3["kmac" + u3].update(B2, R2, T2, P2)[_3](); + }; + }, W2 = function(u3, E2, _3, B2) { + for (var R2 = 0; R2 < J2.length; ++R2) { + var T2 = J2[R2]; + u3[T2] = E2(_3, B2, T2); + } + return u3; + }, Rt2 = function(u3, E2) { + var _3 = G2(u3, E2, "hex"); + return _3.create = function() { + return new s22(u3, E2, u3); + }, _3.update = function(B2) { + return _3.create().update(B2); + }, W2(_3, G2, u3, E2); + }, Yt3 = function(u3, E2) { + var _3 = H22(u3, E2, "hex"); + return _3.create = function(B2) { + return new s22(u3, E2, B2); + }, _3.update = function(B2, R2) { + return _3.create(R2).update(B2); + }, W2(_3, H22, u3, E2); + }, Y2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = z2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return !T2 && !P2 ? f3["shake" + u3].create(R2) : new s22(u3, E2, R2).bytepad([T2, P2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(T2, P2, O3).update(R2); + }, W2(B2, z2, u3, E2); + }, Vt2 = function(u3, E2) { + var _3 = Bt2[u3], B2 = Pt2(u3, E2, "hex"); + return B2.create = function(R2, T2, P2) { + return new v3(u3, E2, T2).bytepad(["KMAC", P2], _3).bytepad([R2], _3); + }, B2.update = function(R2, T2, P2, O3) { + return B2.create(R2, P2, O3).update(T2); + }, W2(B2, Pt2, u3, E2); + }, A2 = [{ name: "keccak", padding: S2, bits: F2, createMethod: Rt2 }, { name: "sha3", padding: I2, bits: F2, createMethod: Rt2 }, { name: "shake", padding: w3, bits: U2, createMethod: Yt3 }, { name: "cshake", padding: y3, bits: U2, createMethod: Y2 }, { name: "kmac", padding: y3, bits: U2, createMethod: Vt2 }], f3 = {}, a3 = [], c2 = 0; c2 < A2.length; ++c2) + for (var d5 = A2[c2], g3 = d5.bits, x2 = 0; x2 < g3.length; ++x2) { + var M2 = d5.name + "_" + g3[x2]; + if (a3.push(M2), f3[M2] = d5.createMethod(g3[x2], d5.padding), d5.name !== "sha3") { + var l2 = d5.name + g3[x2]; + a3.push(l2), f3[l2] = f3[M2]; + } + } + function s22(u3, E2, _3) { + this.blocks = [], this.s = [], this.padding = E2, this.outputBits = _3, this.reset = true, this.finalized = false, this.block = 0, this.start = 0, this.blockCount = 1600 - (u3 << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = _3 >> 5, this.extraBytes = (_3 & 31) >> 3; + for (var B2 = 0; B2 < 50; ++B2) + this.s[B2] = 0; + } + s22.prototype.update = function(u3) { + if (this.finalized) + throw new Error(r3); + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + for (var B2 = this.blocks, R2 = this.byteCount, T2 = u3.length, P2 = this.blockCount, O3 = 0, Ct2 = this.s, D2, q2; O3 < T2; ) { + if (this.reset) + for (this.reset = false, B2[0] = this.block, D2 = 1; D2 < P2 + 1; ++D2) + B2[D2] = 0; + if (E2) + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + B2[D2 >> 2] |= u3[O3] << N22[D2++ & 3]; + else + for (D2 = this.start; O3 < T2 && D2 < R2; ++O3) + q2 = u3.charCodeAt(O3), q2 < 128 ? B2[D2 >> 2] |= q2 << N22[D2++ & 3] : q2 < 2048 ? (B2[D2 >> 2] |= (192 | q2 >> 6) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N22[D2++ & 3]) : q2 < 55296 || q2 >= 57344 ? (B2[D2 >> 2] |= (224 | q2 >> 12) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N22[D2++ & 3]) : (q2 = 65536 + ((q2 & 1023) << 10 | u3.charCodeAt(++O3) & 1023), B2[D2 >> 2] |= (240 | q2 >> 18) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 12 & 63) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 >> 6 & 63) << N22[D2++ & 3], B2[D2 >> 2] |= (128 | q2 & 63) << N22[D2++ & 3]); + if (this.lastByteIndex = D2, D2 >= R2) { + for (this.start = D2 - R2, this.block = B2[P2], D2 = 0; D2 < P2; ++D2) + Ct2[D2] ^= B2[D2]; + k2(Ct2), this.reset = true; + } else + this.start = D2; } + return this; + }, s22.prototype.encode = function(u3, E2) { + var _3 = u3 & 255, B2 = 1, R2 = [_3]; + for (u3 = u3 >> 8, _3 = u3 & 255; _3 > 0; ) + R2.unshift(_3), u3 = u3 >> 8, _3 = u3 & 255, ++B2; + return E2 ? R2.push(B2) : R2.unshift(B2), this.update(R2), R2.length; + }, s22.prototype.encodeString = function(u3) { + var E2, _3 = typeof u3; + if (_3 !== "string") { + if (_3 === "object") { + if (u3 === null) + throw new Error(t2); + if (b3 && u3.constructor === ArrayBuffer) + u3 = new Uint8Array(u3); + else if (!Array.isArray(u3) && (!b3 || !ArrayBuffer.isView(u3))) + throw new Error(t2); + } else + throw new Error(t2); + E2 = true; + } + var B2 = 0, R2 = u3.length; + if (E2) + B2 = R2; + else + for (var T2 = 0; T2 < u3.length; ++T2) { + var P2 = u3.charCodeAt(T2); + P2 < 128 ? B2 += 1 : P2 < 2048 ? B2 += 2 : P2 < 55296 || P2 >= 57344 ? B2 += 3 : (P2 = 65536 + ((P2 & 1023) << 10 | u3.charCodeAt(++T2) & 1023), B2 += 4); + } + return B2 += this.encode(B2 * 8), this.update(u3), B2; + }, s22.prototype.bytepad = function(u3, E2) { + for (var _3 = this.encode(E2), B2 = 0; B2 < u3.length; ++B2) + _3 += this.encodeString(u3[B2]); + var R2 = E2 - _3 % E2, T2 = []; + return T2.length = R2, this.update(T2), this; + }, s22.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = true; + var u3 = this.blocks, E2 = this.lastByteIndex, _3 = this.blockCount, B2 = this.s; + if (u3[E2 >> 2] |= this.padding[E2 & 3], this.lastByteIndex === this.byteCount) + for (u3[0] = u3[_3], E2 = 1; E2 < _3 + 1; ++E2) + u3[E2] = 0; + for (u3[_3 - 1] |= 2147483648, E2 = 0; E2 < _3; ++E2) + B2[E2] ^= u3[E2]; + k2(B2); + } + }, s22.prototype.toString = s22.prototype.hex = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = "", O3; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15] + m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15] + m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15] + m3[O3 >> 28 & 15] + m3[O3 >> 24 & 15]; + T2 % u3 === 0 && (k2(E2), R2 = 0); + } + return B2 && (O3 = E2[R2], P2 += m3[O3 >> 4 & 15] + m3[O3 & 15], B2 > 1 && (P2 += m3[O3 >> 12 & 15] + m3[O3 >> 8 & 15]), B2 > 2 && (P2 += m3[O3 >> 20 & 15] + m3[O3 >> 16 & 15])), P2; + }, s22.prototype.arrayBuffer = function() { + this.finalize(); + var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = this.outputBits >> 3, O3; + B2 ? O3 = new ArrayBuffer(_3 + 1 << 2) : O3 = new ArrayBuffer(P2); + for (var Ct2 = new Uint32Array(O3); T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + Ct2[T2] = E2[R2]; + T2 % u3 === 0 && k2(E2); + } + return B2 && (Ct2[R2] = E2[R2], O3 = O3.slice(0, P2)), O3; + }, s22.prototype.buffer = s22.prototype.arrayBuffer, s22.prototype.digest = s22.prototype.array = function() { + this.finalize(); + for (var u3 = this.blockCount, E2 = this.s, _3 = this.outputBlocks, B2 = this.extraBytes, R2 = 0, T2 = 0, P2 = [], O3, Ct2; T2 < _3; ) { + for (R2 = 0; R2 < u3 && T2 < _3; ++R2, ++T2) + O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, P2[O3 + 1] = Ct2 >> 8 & 255, P2[O3 + 2] = Ct2 >> 16 & 255, P2[O3 + 3] = Ct2 >> 24 & 255; + T2 % u3 === 0 && k2(E2); + } + return B2 && (O3 = T2 << 2, Ct2 = E2[R2], P2[O3] = Ct2 & 255, B2 > 1 && (P2[O3 + 1] = Ct2 >> 8 & 255), B2 > 2 && (P2[O3 + 2] = Ct2 >> 16 & 255)), P2; + }; + function v3(u3, E2, _3) { + s22.call(this, u3, E2, _3); } - if (effect.type === "transform") { - if (ctx.common.async === false) { - const base3 = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (!isValid$1(base3)) - return base3; - const result = effect.transform(base3.value, checkCtx); - if (result instanceof Promise) { - throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + v3.prototype = new s22(), v3.prototype.finalize = function() { + return this.encode(this.outputBits, true), s22.prototype.finalize.call(this); + }; + var k2 = function(u3) { + var E2, _3, B2, R2, T2, P2, O3, Ct2, D2, q2, De2, X2, Z22, Fe2, $2, tt2, Te2, et2, rt2, Ue2, it2, nt2, ke2, ft2, ot2, qe2, st2, at2, Ke2, ut2, ht2, He2, ct2, lt2, ze2, dt2, pt2, Le2, vt2, mt2, je2, gt2, At2, Qe2, bt2, yt2, Je2, wt2, xt2, Ge2, Mt2, Et2, Ye2, St2, Nt2, Ve2, It2, _t2, Me2, Ee2, Se2, Ne2, Ie2; + for (B2 = 0; B2 < 48; B2 += 2) + R2 = u3[0] ^ u3[10] ^ u3[20] ^ u3[30] ^ u3[40], T2 = u3[1] ^ u3[11] ^ u3[21] ^ u3[31] ^ u3[41], P2 = u3[2] ^ u3[12] ^ u3[22] ^ u3[32] ^ u3[42], O3 = u3[3] ^ u3[13] ^ u3[23] ^ u3[33] ^ u3[43], Ct2 = u3[4] ^ u3[14] ^ u3[24] ^ u3[34] ^ u3[44], D2 = u3[5] ^ u3[15] ^ u3[25] ^ u3[35] ^ u3[45], q2 = u3[6] ^ u3[16] ^ u3[26] ^ u3[36] ^ u3[46], De2 = u3[7] ^ u3[17] ^ u3[27] ^ u3[37] ^ u3[47], X2 = u3[8] ^ u3[18] ^ u3[28] ^ u3[38] ^ u3[48], Z22 = u3[9] ^ u3[19] ^ u3[29] ^ u3[39] ^ u3[49], E2 = X2 ^ (P2 << 1 | O3 >>> 31), _3 = Z22 ^ (O3 << 1 | P2 >>> 31), u3[0] ^= E2, u3[1] ^= _3, u3[10] ^= E2, u3[11] ^= _3, u3[20] ^= E2, u3[21] ^= _3, u3[30] ^= E2, u3[31] ^= _3, u3[40] ^= E2, u3[41] ^= _3, E2 = R2 ^ (Ct2 << 1 | D2 >>> 31), _3 = T2 ^ (D2 << 1 | Ct2 >>> 31), u3[2] ^= E2, u3[3] ^= _3, u3[12] ^= E2, u3[13] ^= _3, u3[22] ^= E2, u3[23] ^= _3, u3[32] ^= E2, u3[33] ^= _3, u3[42] ^= E2, u3[43] ^= _3, E2 = P2 ^ (q2 << 1 | De2 >>> 31), _3 = O3 ^ (De2 << 1 | q2 >>> 31), u3[4] ^= E2, u3[5] ^= _3, u3[14] ^= E2, u3[15] ^= _3, u3[24] ^= E2, u3[25] ^= _3, u3[34] ^= E2, u3[35] ^= _3, u3[44] ^= E2, u3[45] ^= _3, E2 = Ct2 ^ (X2 << 1 | Z22 >>> 31), _3 = D2 ^ (Z22 << 1 | X2 >>> 31), u3[6] ^= E2, u3[7] ^= _3, u3[16] ^= E2, u3[17] ^= _3, u3[26] ^= E2, u3[27] ^= _3, u3[36] ^= E2, u3[37] ^= _3, u3[46] ^= E2, u3[47] ^= _3, E2 = q2 ^ (R2 << 1 | T2 >>> 31), _3 = De2 ^ (T2 << 1 | R2 >>> 31), u3[8] ^= E2, u3[9] ^= _3, u3[18] ^= E2, u3[19] ^= _3, u3[28] ^= E2, u3[29] ^= _3, u3[38] ^= E2, u3[39] ^= _3, u3[48] ^= E2, u3[49] ^= _3, Fe2 = u3[0], $2 = u3[1], yt2 = u3[11] << 4 | u3[10] >>> 28, Je2 = u3[10] << 4 | u3[11] >>> 28, at2 = u3[20] << 3 | u3[21] >>> 29, Ke2 = u3[21] << 3 | u3[20] >>> 29, Ee2 = u3[31] << 9 | u3[30] >>> 23, Se2 = u3[30] << 9 | u3[31] >>> 23, gt2 = u3[40] << 18 | u3[41] >>> 14, At2 = u3[41] << 18 | u3[40] >>> 14, lt2 = u3[2] << 1 | u3[3] >>> 31, ze2 = u3[3] << 1 | u3[2] >>> 31, tt2 = u3[13] << 12 | u3[12] >>> 20, Te2 = u3[12] << 12 | u3[13] >>> 20, wt2 = u3[22] << 10 | u3[23] >>> 22, xt2 = u3[23] << 10 | u3[22] >>> 22, ut2 = u3[33] << 13 | u3[32] >>> 19, ht2 = u3[32] << 13 | u3[33] >>> 19, Ne2 = u3[42] << 2 | u3[43] >>> 30, Ie2 = u3[43] << 2 | u3[42] >>> 30, St2 = u3[5] << 30 | u3[4] >>> 2, Nt2 = u3[4] << 30 | u3[5] >>> 2, dt2 = u3[14] << 6 | u3[15] >>> 26, pt2 = u3[15] << 6 | u3[14] >>> 26, et2 = u3[25] << 11 | u3[24] >>> 21, rt2 = u3[24] << 11 | u3[25] >>> 21, Ge2 = u3[34] << 15 | u3[35] >>> 17, Mt2 = u3[35] << 15 | u3[34] >>> 17, He2 = u3[45] << 29 | u3[44] >>> 3, ct2 = u3[44] << 29 | u3[45] >>> 3, ft2 = u3[6] << 28 | u3[7] >>> 4, ot2 = u3[7] << 28 | u3[6] >>> 4, Ve2 = u3[17] << 23 | u3[16] >>> 9, It2 = u3[16] << 23 | u3[17] >>> 9, Le2 = u3[26] << 25 | u3[27] >>> 7, vt2 = u3[27] << 25 | u3[26] >>> 7, Ue2 = u3[36] << 21 | u3[37] >>> 11, it2 = u3[37] << 21 | u3[36] >>> 11, Et2 = u3[47] << 24 | u3[46] >>> 8, Ye2 = u3[46] << 24 | u3[47] >>> 8, Qe2 = u3[8] << 27 | u3[9] >>> 5, bt2 = u3[9] << 27 | u3[8] >>> 5, qe2 = u3[18] << 20 | u3[19] >>> 12, st2 = u3[19] << 20 | u3[18] >>> 12, _t2 = u3[29] << 7 | u3[28] >>> 25, Me2 = u3[28] << 7 | u3[29] >>> 25, mt2 = u3[38] << 8 | u3[39] >>> 24, je2 = u3[39] << 8 | u3[38] >>> 24, nt2 = u3[48] << 14 | u3[49] >>> 18, ke2 = u3[49] << 14 | u3[48] >>> 18, u3[0] = Fe2 ^ ~tt2 & et2, u3[1] = $2 ^ ~Te2 & rt2, u3[10] = ft2 ^ ~qe2 & at2, u3[11] = ot2 ^ ~st2 & Ke2, u3[20] = lt2 ^ ~dt2 & Le2, u3[21] = ze2 ^ ~pt2 & vt2, u3[30] = Qe2 ^ ~yt2 & wt2, u3[31] = bt2 ^ ~Je2 & xt2, u3[40] = St2 ^ ~Ve2 & _t2, u3[41] = Nt2 ^ ~It2 & Me2, u3[2] = tt2 ^ ~et2 & Ue2, u3[3] = Te2 ^ ~rt2 & it2, u3[12] = qe2 ^ ~at2 & ut2, u3[13] = st2 ^ ~Ke2 & ht2, u3[22] = dt2 ^ ~Le2 & mt2, u3[23] = pt2 ^ ~vt2 & je2, u3[32] = yt2 ^ ~wt2 & Ge2, u3[33] = Je2 ^ ~xt2 & Mt2, u3[42] = Ve2 ^ ~_t2 & Ee2, u3[43] = It2 ^ ~Me2 & Se2, u3[4] = et2 ^ ~Ue2 & nt2, u3[5] = rt2 ^ ~it2 & ke2, u3[14] = at2 ^ ~ut2 & He2, u3[15] = Ke2 ^ ~ht2 & ct2, u3[24] = Le2 ^ ~mt2 & gt2, u3[25] = vt2 ^ ~je2 & At2, u3[34] = wt2 ^ ~Ge2 & Et2, u3[35] = xt2 ^ ~Mt2 & Ye2, u3[44] = _t2 ^ ~Ee2 & Ne2, u3[45] = Me2 ^ ~Se2 & Ie2, u3[6] = Ue2 ^ ~nt2 & Fe2, u3[7] = it2 ^ ~ke2 & $2, u3[16] = ut2 ^ ~He2 & ft2, u3[17] = ht2 ^ ~ct2 & ot2, u3[26] = mt2 ^ ~gt2 & lt2, u3[27] = je2 ^ ~At2 & ze2, u3[36] = Ge2 ^ ~Et2 & Qe2, u3[37] = Mt2 ^ ~Ye2 & bt2, u3[46] = Ee2 ^ ~Ne2 & St2, u3[47] = Se2 ^ ~Ie2 & Nt2, u3[8] = nt2 ^ ~Fe2 & tt2, u3[9] = ke2 ^ ~$2 & Te2, u3[18] = He2 ^ ~ft2 & qe2, u3[19] = ct2 ^ ~ot2 & st2, u3[28] = gt2 ^ ~lt2 & dt2, u3[29] = At2 ^ ~ze2 & pt2, u3[38] = Et2 ^ ~Qe2 & yt2, u3[39] = Ye2 ^ ~bt2 & Je2, u3[48] = Ne2 ^ ~St2 & Ve2, u3[49] = Ie2 ^ ~Nt2 & It2, u3[0] ^= C2[B2], u3[1] ^= C2[B2 + 1]; + }; + if (p2) + e2.exports = f3; + else + for (c2 = 0; c2 < a3.length; ++c2) + n4[a3[c2]] = f3[a3[c2]]; + })(); + })(Pn); + const y0 = "logger/5.7.0"; + let Dn = false, Fn = false; + const Cr2 = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; + let Tn = Cr2.default, gi = null; + function w0() { + try { + const e2 = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((t2) => { + try { + if ("test".normalize(t2) !== "test") + throw new Error("bad normalize"); + } catch { + e2.push(t2); + } + }), e2.length) + throw new Error("missing " + e2.join(", ")); + if (String.fromCharCode(233).normalize("NFD") !== String.fromCharCode(101, 769)) + throw new Error("broken implementation"); + } catch (e2) { + return e2.message; + } + return null; + } + const Un = w0(); + var Ai; + (function(e2) { + e2.DEBUG = "DEBUG", e2.INFO = "INFO", e2.WARNING = "WARNING", e2.ERROR = "ERROR", e2.OFF = "OFF"; + })(Ai || (Ai = {})); + var re$3; + (function(e2) { + e2.UNKNOWN_ERROR = "UNKNOWN_ERROR", e2.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e2.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", e2.NETWORK_ERROR = "NETWORK_ERROR", e2.SERVER_ERROR = "SERVER_ERROR", e2.TIMEOUT = "TIMEOUT", e2.BUFFER_OVERRUN = "BUFFER_OVERRUN", e2.NUMERIC_FAULT = "NUMERIC_FAULT", e2.MISSING_NEW = "MISSING_NEW", e2.INVALID_ARGUMENT = "INVALID_ARGUMENT", e2.MISSING_ARGUMENT = "MISSING_ARGUMENT", e2.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", e2.CALL_EXCEPTION = "CALL_EXCEPTION", e2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", e2.NONCE_EXPIRED = "NONCE_EXPIRED", e2.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", e2.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", e2.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", e2.ACTION_REJECTED = "ACTION_REJECTED"; + })(re$3 || (re$3 = {})); + const kn = "0123456789abcdef"; + class L3 { + constructor(t2) { + Object.defineProperty(this, "version", { enumerable: true, value: t2, writable: false }); + } + _log(t2, r3) { + const i2 = t2.toLowerCase(); + Cr2[i2] == null && this.throwArgumentError("invalid log level name", "logLevel", t2), !(Tn > Cr2[i2]) && console.log.apply(console, r3); + } + debug(...t2) { + this._log(L3.levels.DEBUG, t2); + } + info(...t2) { + this._log(L3.levels.INFO, t2); + } + warn(...t2) { + this._log(L3.levels.WARNING, t2); + } + makeError(t2, r3, i2) { + if (Fn) + return this.makeError("censored error", r3, {}); + r3 || (r3 = L3.errors.UNKNOWN_ERROR), i2 || (i2 = {}); + const n4 = []; + Object.keys(i2).forEach((b3) => { + const m3 = i2[b3]; + try { + if (m3 instanceof Uint8Array) { + let w3 = ""; + for (let y3 = 0; y3 < m3.length; y3++) + w3 += kn[m3[y3] >> 4], w3 += kn[m3[y3] & 15]; + n4.push(b3 + "=Uint8Array(0x" + w3 + ")"); + } else + n4.push(b3 + "=" + JSON.stringify(m3)); + } catch { + n4.push(b3 + "=" + JSON.stringify(i2[b3].toString())); + } + }), n4.push(`code=${r3}`), n4.push(`version=${this.version}`); + const o22 = t2; + let h4 = ""; + switch (r3) { + case re$3.NUMERIC_FAULT: { + h4 = "NUMERIC_FAULT"; + const b3 = t2; + switch (b3) { + case "overflow": + case "underflow": + case "division-by-zero": + h4 += "-" + b3; + break; + case "negative-power": + case "negative-width": + h4 += "-unsupported"; + break; + case "unbound-bitwise-result": + h4 += "-unbound-result"; + break; } - return { status: status.value, value: result }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { - if (!isValid$1(base3)) - return base3; - return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); - }); + break; } + case re$3.CALL_EXCEPTION: + case re$3.INSUFFICIENT_FUNDS: + case re$3.MISSING_NEW: + case re$3.NONCE_EXPIRED: + case re$3.REPLACEMENT_UNDERPRICED: + case re$3.TRANSACTION_REPLACED: + case re$3.UNPREDICTABLE_GAS_LIMIT: + h4 = r3; + break; } - util$1.assertNever(effect); + h4 && (t2 += " [ See: https://links.ethers.org/v5-errors-" + h4 + " ]"), n4.length && (t2 += " (" + n4.join(", ") + ")"); + const p2 = new Error(t2); + return p2.reason = o22, p2.code = r3, Object.keys(i2).forEach(function(b3) { + p2[b3] = i2[b3]; + }), p2; } - }; - ZodEffects$1.create = (schema, effect, params) => { - return new ZodEffects$1({ - schema, - typeName: ZodFirstPartyTypeKind$1.ZodEffects, - effect, - ...processCreateParams$1(params) - }); - }; - ZodEffects$1.createWithPreprocess = (preprocess, schema, params) => { - return new ZodEffects$1({ - schema, - effect: { type: "preprocess", transform: preprocess }, - typeName: ZodFirstPartyTypeKind$1.ZodEffects, - ...processCreateParams$1(params) - }); - }; - let ZodOptional$1 = class ZodOptional extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType$1.undefined) { - return OK$1(void 0); - } - return this._def.innerType._parse(input); + throwError(t2, r3, i2) { + throw this.makeError(t2, r3, i2); } - unwrap() { - return this._def.innerType; + throwArgumentError(t2, r3, i2) { + return this.throwError(t2, L3.errors.INVALID_ARGUMENT, { argument: r3, value: i2 }); } - }; - ZodOptional$1.create = (type2, params) => { - return new ZodOptional$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodOptional, - ...processCreateParams$1(params) - }); - }; - let ZodNullable$1 = class ZodNullable extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === ZodParsedType$1.null) { - return OK$1(null); - } - return this._def.innerType._parse(input); + assert(t2, r3, i2, n4) { + t2 || this.throwError(r3, i2, n4); } - unwrap() { - return this._def.innerType; + assertArgument(t2, r3, i2, n4) { + t2 || this.throwArgumentError(r3, i2, n4); } - }; - ZodNullable$1.create = (type2, params) => { - return new ZodNullable$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodNullable, - ...processCreateParams$1(params) - }); - }; - let ZodDefault$1 = class ZodDefault extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - let data2 = ctx.data; - if (ctx.parsedType === ZodParsedType$1.undefined) { - data2 = this._def.defaultValue(); + checkNormalize(t2) { + Un && this.throwError("platform missing String.prototype.normalize", L3.errors.UNSUPPORTED_OPERATION, { operation: "String.prototype.normalize", form: Un }); + } + checkSafeUint53(t2, r3) { + typeof t2 == "number" && (r3 == null && (r3 = "value not safe"), (t2 < 0 || t2 >= 9007199254740991) && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "out-of-safe-range", value: t2 }), t2 % 1 && this.throwError(r3, L3.errors.NUMERIC_FAULT, { operation: "checkSafeInteger", fault: "non-integer", value: t2 })); + } + checkArgumentCount(t2, r3, i2) { + i2 ? i2 = ": " + i2 : i2 = "", t2 < r3 && this.throwError("missing argument" + i2, L3.errors.MISSING_ARGUMENT, { count: t2, expectedCount: r3 }), t2 > r3 && this.throwError("too many arguments" + i2, L3.errors.UNEXPECTED_ARGUMENT, { count: t2, expectedCount: r3 }); + } + checkNew(t2, r3) { + (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); + } + checkAbstract(t2, r3) { + t2 === r3 ? this.throwError("cannot instantiate abstract class " + JSON.stringify(r3.name) + " directly; use a sub-class", L3.errors.UNSUPPORTED_OPERATION, { name: t2.name, operation: "new" }) : (t2 === Object || t2 == null) && this.throwError("missing new", L3.errors.MISSING_NEW, { name: r3.name }); + } + static globalLogger() { + return gi || (gi = new L3(y0)), gi; + } + static setCensorship(t2, r3) { + if (!t2 && r3 && this.globalLogger().throwError("cannot permanently disable censorship", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }), Dn) { + if (!t2) + return; + this.globalLogger().throwError("error censorship permanent", L3.errors.UNSUPPORTED_OPERATION, { operation: "setCensorship" }); } - return this._def.innerType._parse({ - data: data2, - path: ctx.path, - parent: ctx - }); + Fn = !!t2, Dn = !!r3; } - removeDefault() { - return this._def.innerType; + static setLogLevel(t2) { + const r3 = Cr2[t2.toLowerCase()]; + if (r3 == null) { + L3.globalLogger().warn("invalid log level - " + t2); + return; + } + Tn = r3; } - }; - ZodDefault$1.create = (type2, params) => { - return new ZodDefault$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodDefault, - defaultValue: typeof params.default === "function" ? params.default : () => params.default, - ...processCreateParams$1(params) - }); - }; - let ZodCatch$1 = class ZodCatch extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const newCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] + static from(t2) { + return new L3(t2); + } + } + L3.errors = re$3, L3.levels = Ai; + const x0 = "bytes/5.7.0", Dt$3 = new L3(x0); + function qn(e2) { + return !!e2.toHexString; + } + function rr$3(e2) { + return e2.slice || (e2.slice = function() { + const t2 = Array.prototype.slice.call(arguments); + return rr$3(new Uint8Array(Array.prototype.slice.apply(e2, t2))); + }), e2; + } + function Kn(e2) { + return typeof e2 == "number" && e2 == e2 && e2 % 1 === 0; + } + function ir$3(e2) { + if (e2 == null) + return false; + if (e2.constructor === Uint8Array) + return true; + if (typeof e2 == "string" || !Kn(e2.length) || e2.length < 0) + return false; + for (let t2 = 0; t2 < e2.length; t2++) { + const r3 = e2[t2]; + if (!Kn(r3) || r3 < 0 || r3 >= 256) + return false; + } + return true; + } + function Ot2(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$3.checkSafeUint53(e2, "invalid arrayify value"); + const r3 = []; + for (; e2; ) + r3.unshift(e2 & 255), e2 = parseInt(String(e2 / 256)); + return r3.length === 0 && r3.push(0), rr$3(new Uint8Array(r3)); + } + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2) && (e2 = e2.toHexString()), Qt$2(e2)) { + let r3 = e2.substring(2); + r3.length % 2 && (t2.hexPad === "left" ? r3 = "0" + r3 : t2.hexPad === "right" ? r3 += "0" : Dt$3.throwArgumentError("hex data is odd-length", "value", e2)); + const i2 = []; + for (let n4 = 0; n4 < r3.length; n4 += 2) + i2.push(parseInt(r3.substring(n4, n4 + 2), 16)); + return rr$3(new Uint8Array(i2)); + } + return ir$3(e2) ? rr$3(new Uint8Array(e2)) : Dt$3.throwArgumentError("invalid arrayify value", "value", e2); + } + function Qt$2(e2, t2) { + return !(typeof e2 != "string" || !e2.match(/^0x[0-9A-Fa-f]*$/) || t2); + } + const bi = "0123456789abcdef"; + function Kt$3(e2, t2) { + if (t2 || (t2 = {}), typeof e2 == "number") { + Dt$3.checkSafeUint53(e2, "invalid hexlify value"); + let r3 = ""; + for (; e2; ) + r3 = bi[e2 & 15] + r3, e2 = Math.floor(e2 / 16); + return r3.length ? (r3.length % 2 && (r3 = "0" + r3), "0x" + r3) : "0x00"; + } + if (typeof e2 == "bigint") + return e2 = e2.toString(16), e2.length % 2 ? "0x0" + e2 : "0x" + e2; + if (t2.allowMissingPrefix && typeof e2 == "string" && e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), qn(e2)) + return e2.toHexString(); + if (Qt$2(e2)) + return e2.length % 2 && (t2.hexPad === "left" ? e2 = "0x0" + e2.substring(2) : t2.hexPad === "right" ? e2 += "0" : Dt$3.throwArgumentError("hex data is odd-length", "value", e2)), e2.toLowerCase(); + if (ir$3(e2)) { + let r3 = "0x"; + for (let i2 = 0; i2 < e2.length; i2++) { + let n4 = e2[i2]; + r3 += bi[(n4 & 240) >> 4] + bi[n4 & 15]; + } + return r3; + } + return Dt$3.throwArgumentError("invalid hexlify value", "value", e2); + } + function oe(e2, t2) { + for (typeof e2 != "string" ? e2 = Kt$3(e2) : Qt$2(e2) || Dt$3.throwArgumentError("invalid hex string", "value", e2), e2.length > 2 * t2 + 2 && Dt$3.throwArgumentError("value out of range", "value", arguments[1]); e2.length < 2 * t2 + 2; ) + e2 = "0x0" + e2.substring(2); + return e2; + } + var Ln = { exports: {} }, I0 = {}, _0 = Object.freeze({ __proto__: null, default: I0 }), B0 = A0(_0); + (function(e2) { + (function(t2, r3) { + function i2(A2, f3) { + if (!A2) + throw new Error(f3 || "Assertion failed"); + } + function n4(A2, f3) { + A2.super_ = f3; + var a3 = function() { + }; + a3.prototype = f3.prototype, A2.prototype = new a3(), A2.prototype.constructor = A2; + } + function o22(A2, f3, a3) { + if (o22.isBN(A2)) + return A2; + this.negative = 0, this.words = null, this.length = 0, this.red = null, A2 !== null && ((f3 === "le" || f3 === "be") && (a3 = f3, f3 = 10), this._init(A2 || 0, f3 || 10, a3 || "be")); + } + typeof t2 == "object" ? t2.exports = o22 : r3.BN = o22, o22.BN = o22, o22.wordSize = 26; + var h4; + try { + typeof window < "u" && typeof window.Buffer < "u" ? h4 = window.Buffer : h4 = B0.Buffer; + } catch { + } + o22.isBN = function(f3) { + return f3 instanceof o22 ? true : f3 !== null && typeof f3 == "object" && f3.constructor.wordSize === o22.wordSize && Array.isArray(f3.words); + }, o22.max = function(f3, a3) { + return f3.cmp(a3) > 0 ? f3 : a3; + }, o22.min = function(f3, a3) { + return f3.cmp(a3) < 0 ? f3 : a3; + }, o22.prototype._init = function(f3, a3, c2) { + if (typeof f3 == "number") + return this._initNumber(f3, a3, c2); + if (typeof f3 == "object") + return this._initArray(f3, a3, c2); + a3 === "hex" && (a3 = 16), i2(a3 === (a3 | 0) && a3 >= 2 && a3 <= 36), f3 = f3.toString().replace(/\s+/g, ""); + var d5 = 0; + f3[0] === "-" && (d5++, this.negative = 1), d5 < f3.length && (a3 === 16 ? this._parseHex(f3, d5, c2) : (this._parseBase(f3, a3, d5), c2 === "le" && this._initArray(this.toArray(), a3, c2))); + }, o22.prototype._initNumber = function(f3, a3, c2) { + f3 < 0 && (this.negative = 1, f3 = -f3), f3 < 67108864 ? (this.words = [f3 & 67108863], this.length = 1) : f3 < 4503599627370496 ? (this.words = [f3 & 67108863, f3 / 67108864 & 67108863], this.length = 2) : (i2(f3 < 9007199254740992), this.words = [f3 & 67108863, f3 / 67108864 & 67108863, 1], this.length = 3), c2 === "le" && this._initArray(this.toArray(), a3, c2); + }, o22.prototype._initArray = function(f3, a3, c2) { + if (i2(typeof f3.length == "number"), f3.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(f3.length / 3), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3, x2, M2 = 0; + if (c2 === "be") + for (d5 = f3.length - 1, g3 = 0; d5 >= 0; d5 -= 3) + x2 = f3[d5] | f3[d5 - 1] << 8 | f3[d5 - 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + else if (c2 === "le") + for (d5 = 0, g3 = 0; d5 < f3.length; d5 += 3) + x2 = f3[d5] | f3[d5 + 1] << 8 | f3[d5 + 2] << 16, this.words[g3] |= x2 << M2 & 67108863, this.words[g3 + 1] = x2 >>> 26 - M2 & 67108863, M2 += 24, M2 >= 26 && (M2 -= 26, g3++); + return this._strip(); + }; + function p2(A2, f3) { + var a3 = A2.charCodeAt(f3); + if (a3 >= 48 && a3 <= 57) + return a3 - 48; + if (a3 >= 65 && a3 <= 70) + return a3 - 55; + if (a3 >= 97 && a3 <= 102) + return a3 - 87; + i2(false, "Invalid character in " + A2); + } + function b3(A2, f3, a3) { + var c2 = p2(A2, a3); + return a3 - 1 >= f3 && (c2 |= p2(A2, a3 - 1) << 4), c2; + } + o22.prototype._parseHex = function(f3, a3, c2) { + this.length = Math.ceil((f3.length - a3) / 6), this.words = new Array(this.length); + for (var d5 = 0; d5 < this.length; d5++) + this.words[d5] = 0; + var g3 = 0, x2 = 0, M2; + if (c2 === "be") + for (d5 = f3.length - 1; d5 >= a3; d5 -= 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; + else { + var l2 = f3.length - a3; + for (d5 = l2 % 2 === 0 ? a3 + 1 : a3; d5 < f3.length; d5 += 2) + M2 = b3(f3, a3, d5) << g3, this.words[x2] |= M2 & 67108863, g3 >= 18 ? (g3 -= 18, x2 += 1, this.words[x2] |= M2 >>> 26) : g3 += 8; } + this._strip(); }; - const result = this._def.innerType._parse({ - data: newCtx.data, - path: newCtx.path, - parent: { - ...newCtx + function m3(A2, f3, a3, c2) { + for (var d5 = 0, g3 = 0, x2 = Math.min(A2.length, a3), M2 = f3; M2 < x2; M2++) { + var l2 = A2.charCodeAt(M2) - 48; + d5 *= c2, l2 >= 49 ? g3 = l2 - 49 + 10 : l2 >= 17 ? g3 = l2 - 17 + 10 : g3 = l2, i2(l2 >= 0 && g3 < c2, "Invalid character"), d5 += g3; + } + return d5; + } + o22.prototype._parseBase = function(f3, a3, c2) { + this.words = [0], this.length = 1; + for (var d5 = 0, g3 = 1; g3 <= 67108863; g3 *= a3) + d5++; + d5--, g3 = g3 / a3 | 0; + for (var x2 = f3.length - c2, M2 = x2 % d5, l2 = Math.min(x2, x2 - M2) + c2, s22 = 0, v3 = c2; v3 < l2; v3 += d5) + s22 = m3(f3, v3, v3 + d5, a3), this.imuln(g3), this.words[0] + s22 < 67108864 ? this.words[0] += s22 : this._iaddn(s22); + if (M2 !== 0) { + var k2 = 1; + for (s22 = m3(f3, v3, f3.length, a3), v3 = 0; v3 < M2; v3++) + k2 *= a3; + this.imuln(k2), this.words[0] + s22 < 67108864 ? this.words[0] += s22 : this._iaddn(s22); + } + this._strip(); + }, o22.prototype.copy = function(f3) { + f3.words = new Array(this.length); + for (var a3 = 0; a3 < this.length; a3++) + f3.words[a3] = this.words[a3]; + f3.length = this.length, f3.negative = this.negative, f3.red = this.red; + }; + function w3(A2, f3) { + A2.words = f3.words, A2.length = f3.length, A2.negative = f3.negative, A2.red = f3.red; + } + if (o22.prototype._move = function(f3) { + w3(f3, this); + }, o22.prototype.clone = function() { + var f3 = new o22(null); + return this.copy(f3), f3; + }, o22.prototype._expand = function(f3) { + for (; this.length < f3; ) + this.words[this.length++] = 0; + return this; + }, o22.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, o22.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + o22.prototype[Symbol.for("nodejs.util.inspect.custom")] = y3; + } catch { + o22.prototype.inspect = y3; } - }); - if (isAsync$1(result)) { - return result.then((result2) => { - return { - status: "valid", - value: result2.status === "valid" ? result2.value : this._def.catchValue({ - get error() { - return new ZodError$1(newCtx.common.issues); - } - }) - }; - }); - } else { - return { - status: "valid", - value: result.status === "valid" ? result.value : this._def.catchValue({ - get error() { - return new ZodError$1(newCtx.common.issues); + else + o22.prototype.inspect = y3; + function y3() { + return (this.red ? ""; + } + var S2 = ["", "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"], I2 = [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], N22 = [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]; + o22.prototype.toString = function(f3, a3) { + f3 = f3 || 10, a3 = a3 | 0 || 1; + var c2; + if (f3 === 16 || f3 === "hex") { + c2 = ""; + for (var d5 = 0, g3 = 0, x2 = 0; x2 < this.length; x2++) { + var M2 = this.words[x2], l2 = ((M2 << d5 | g3) & 16777215).toString(16); + g3 = M2 >>> 24 - d5 & 16777215, d5 += 2, d5 >= 26 && (d5 -= 26, x2--), g3 !== 0 || x2 !== this.length - 1 ? c2 = S2[6 - l2.length] + l2 + c2 : c2 = l2 + c2; + } + for (g3 !== 0 && (c2 = g3.toString(16) + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + if (f3 === (f3 | 0) && f3 >= 2 && f3 <= 36) { + var s22 = I2[f3], v3 = N22[f3]; + c2 = ""; + var k2 = this.clone(); + for (k2.negative = 0; !k2.isZero(); ) { + var u3 = k2.modrn(v3).toString(f3); + k2 = k2.idivn(v3), k2.isZero() ? c2 = u3 + c2 : c2 = S2[s22 - u3.length] + u3 + c2; + } + for (this.isZero() && (c2 = "0" + c2); c2.length % a3 !== 0; ) + c2 = "0" + c2; + return this.negative !== 0 && (c2 = "-" + c2), c2; + } + i2(false, "Base should be between 2 and 36"); + }, o22.prototype.toNumber = function() { + var f3 = this.words[0]; + return this.length === 2 ? f3 += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f3 += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && i2(false, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f3 : f3; + }, o22.prototype.toJSON = function() { + return this.toString(16, 2); + }, h4 && (o22.prototype.toBuffer = function(f3, a3) { + return this.toArrayLike(h4, f3, a3); + }), o22.prototype.toArray = function(f3, a3) { + return this.toArrayLike(Array, f3, a3); + }; + var C2 = function(f3, a3) { + return f3.allocUnsafe ? f3.allocUnsafe(a3) : new f3(a3); + }; + o22.prototype.toArrayLike = function(f3, a3, c2) { + this._strip(); + var d5 = this.byteLength(), g3 = c2 || Math.max(1, d5); + i2(d5 <= g3, "byte array longer than desired length"), i2(g3 > 0, "Requested array length <= 0"); + var x2 = C2(f3, g3), M2 = a3 === "le" ? "LE" : "BE"; + return this["_toArrayLike" + M2](x2, d5), x2; + }, o22.prototype._toArrayLikeLE = function(f3, a3) { + for (var c2 = 0, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2++] = M2 & 255, c2 < f3.length && (f3[c2++] = M2 >> 8 & 255), c2 < f3.length && (f3[c2++] = M2 >> 16 & 255), x2 === 6 ? (c2 < f3.length && (f3[c2++] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 < f3.length) + for (f3[c2++] = d5; c2 < f3.length; ) + f3[c2++] = 0; + }, o22.prototype._toArrayLikeBE = function(f3, a3) { + for (var c2 = f3.length - 1, d5 = 0, g3 = 0, x2 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] << x2 | d5; + f3[c2--] = M2 & 255, c2 >= 0 && (f3[c2--] = M2 >> 8 & 255), c2 >= 0 && (f3[c2--] = M2 >> 16 & 255), x2 === 6 ? (c2 >= 0 && (f3[c2--] = M2 >> 24 & 255), d5 = 0, x2 = 0) : (d5 = M2 >>> 24, x2 += 2); + } + if (c2 >= 0) + for (f3[c2--] = d5; c2 >= 0; ) + f3[c2--] = 0; + }, Math.clz32 ? o22.prototype._countBits = function(f3) { + return 32 - Math.clz32(f3); + } : o22.prototype._countBits = function(f3) { + var a3 = f3, c2 = 0; + return a3 >= 4096 && (c2 += 13, a3 >>>= 13), a3 >= 64 && (c2 += 7, a3 >>>= 7), a3 >= 8 && (c2 += 4, a3 >>>= 4), a3 >= 2 && (c2 += 2, a3 >>>= 2), c2 + a3; + }, o22.prototype._zeroBits = function(f3) { + if (f3 === 0) + return 26; + var a3 = f3, c2 = 0; + return a3 & 8191 || (c2 += 13, a3 >>>= 13), a3 & 127 || (c2 += 7, a3 >>>= 7), a3 & 15 || (c2 += 4, a3 >>>= 4), a3 & 3 || (c2 += 2, a3 >>>= 2), a3 & 1 || c2++, c2; + }, o22.prototype.bitLength = function() { + var f3 = this.words[this.length - 1], a3 = this._countBits(f3); + return (this.length - 1) * 26 + a3; + }; + function F2(A2) { + for (var f3 = new Array(A2.bitLength()), a3 = 0; a3 < f3.length; a3++) { + var c2 = a3 / 26 | 0, d5 = a3 % 26; + f3[a3] = A2.words[c2] >>> d5 & 1; + } + return f3; + } + o22.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var f3 = 0, a3 = 0; a3 < this.length; a3++) { + var c2 = this._zeroBits(this.words[a3]); + if (f3 += c2, c2 !== 26) + break; + } + return f3; + }, o22.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o22.prototype.toTwos = function(f3) { + return this.negative !== 0 ? this.abs().inotn(f3).iaddn(1) : this.clone(); + }, o22.prototype.fromTwos = function(f3) { + return this.testn(f3 - 1) ? this.notn(f3).iaddn(1).ineg() : this.clone(); + }, o22.prototype.isNeg = function() { + return this.negative !== 0; + }, o22.prototype.neg = function() { + return this.clone().ineg(); + }, o22.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, o22.prototype.iuor = function(f3) { + for (; this.length < f3.length; ) + this.words[this.length++] = 0; + for (var a3 = 0; a3 < f3.length; a3++) + this.words[a3] = this.words[a3] | f3.words[a3]; + return this._strip(); + }, o22.prototype.ior = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuor(f3); + }, o22.prototype.or = function(f3) { + return this.length > f3.length ? this.clone().ior(f3) : f3.clone().ior(this); + }, o22.prototype.uor = function(f3) { + return this.length > f3.length ? this.clone().iuor(f3) : f3.clone().iuor(this); + }, o22.prototype.iuand = function(f3) { + var a3; + this.length > f3.length ? a3 = f3 : a3 = this; + for (var c2 = 0; c2 < a3.length; c2++) + this.words[c2] = this.words[c2] & f3.words[c2]; + return this.length = a3.length, this._strip(); + }, o22.prototype.iand = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuand(f3); + }, o22.prototype.and = function(f3) { + return this.length > f3.length ? this.clone().iand(f3) : f3.clone().iand(this); + }, o22.prototype.uand = function(f3) { + return this.length > f3.length ? this.clone().iuand(f3) : f3.clone().iuand(this); + }, o22.prototype.iuxor = function(f3) { + var a3, c2; + this.length > f3.length ? (a3 = this, c2 = f3) : (a3 = f3, c2 = this); + for (var d5 = 0; d5 < c2.length; d5++) + this.words[d5] = a3.words[d5] ^ c2.words[d5]; + if (this !== a3) + for (; d5 < a3.length; d5++) + this.words[d5] = a3.words[d5]; + return this.length = a3.length, this._strip(); + }, o22.prototype.ixor = function(f3) { + return i2((this.negative | f3.negative) === 0), this.iuxor(f3); + }, o22.prototype.xor = function(f3) { + return this.length > f3.length ? this.clone().ixor(f3) : f3.clone().ixor(this); + }, o22.prototype.uxor = function(f3) { + return this.length > f3.length ? this.clone().iuxor(f3) : f3.clone().iuxor(this); + }, o22.prototype.inotn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = Math.ceil(f3 / 26) | 0, c2 = f3 % 26; + this._expand(a3), c2 > 0 && a3--; + for (var d5 = 0; d5 < a3; d5++) + this.words[d5] = ~this.words[d5] & 67108863; + return c2 > 0 && (this.words[d5] = ~this.words[d5] & 67108863 >> 26 - c2), this._strip(); + }, o22.prototype.notn = function(f3) { + return this.clone().inotn(f3); + }, o22.prototype.setn = function(f3, a3) { + i2(typeof f3 == "number" && f3 >= 0); + var c2 = f3 / 26 | 0, d5 = f3 % 26; + return this._expand(c2 + 1), a3 ? this.words[c2] = this.words[c2] | 1 << d5 : this.words[c2] = this.words[c2] & ~(1 << d5), this._strip(); + }, o22.prototype.iadd = function(f3) { + var a3; + if (this.negative !== 0 && f3.negative === 0) + return this.negative = 0, a3 = this.isub(f3), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && f3.negative !== 0) + return f3.negative = 0, a3 = this.isub(f3), f3.negative = 1, a3._normSign(); + var c2, d5; + this.length > f3.length ? (c2 = this, d5 = f3) : (c2 = f3, d5 = this); + for (var g3 = 0, x2 = 0; x2 < d5.length; x2++) + a3 = (c2.words[x2] | 0) + (d5.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + for (; g3 !== 0 && x2 < c2.length; x2++) + a3 = (c2.words[x2] | 0) + g3, this.words[x2] = a3 & 67108863, g3 = a3 >>> 26; + if (this.length = c2.length, g3 !== 0) + this.words[this.length] = g3, this.length++; + else if (c2 !== this) + for (; x2 < c2.length; x2++) + this.words[x2] = c2.words[x2]; + return this; + }, o22.prototype.add = function(f3) { + var a3; + return f3.negative !== 0 && this.negative === 0 ? (f3.negative = 0, a3 = this.sub(f3), f3.negative ^= 1, a3) : f3.negative === 0 && this.negative !== 0 ? (this.negative = 0, a3 = f3.sub(this), this.negative = 1, a3) : this.length > f3.length ? this.clone().iadd(f3) : f3.clone().iadd(this); + }, o22.prototype.isub = function(f3) { + if (f3.negative !== 0) { + f3.negative = 0; + var a3 = this.iadd(f3); + return f3.negative = 1, a3._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(f3), this.negative = 1, this._normSign(); + var c2 = this.cmp(f3); + if (c2 === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var d5, g3; + c2 > 0 ? (d5 = this, g3 = f3) : (d5 = f3, g3 = this); + for (var x2 = 0, M2 = 0; M2 < g3.length; M2++) + a3 = (d5.words[M2] | 0) - (g3.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + for (; x2 !== 0 && M2 < d5.length; M2++) + a3 = (d5.words[M2] | 0) + x2, x2 = a3 >> 26, this.words[M2] = a3 & 67108863; + if (x2 === 0 && M2 < d5.length && d5 !== this) + for (; M2 < d5.length; M2++) + this.words[M2] = d5.words[M2]; + return this.length = Math.max(this.length, M2), d5 !== this && (this.negative = 1), this._strip(); + }, o22.prototype.sub = function(f3) { + return this.clone().isub(f3); + }; + function U2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative; + var c2 = A2.length + f3.length | 0; + a3.length = c2, c2 = c2 - 1 | 0; + var d5 = A2.words[0] | 0, g3 = f3.words[0] | 0, x2 = d5 * g3, M2 = x2 & 67108863, l2 = x2 / 67108864 | 0; + a3.words[0] = M2; + for (var s22 = 1; s22 < c2; s22++) { + for (var v3 = l2 >>> 26, k2 = l2 & 67108863, u3 = Math.min(s22, f3.length - 1), E2 = Math.max(0, s22 - A2.length + 1); E2 <= u3; E2++) { + var _3 = s22 - E2 | 0; + d5 = A2.words[_3] | 0, g3 = f3.words[E2] | 0, x2 = d5 * g3 + k2, v3 += x2 / 67108864 | 0, k2 = x2 & 67108863; + } + a3.words[s22] = k2 | 0, l2 = v3 | 0; + } + return l2 !== 0 ? a3.words[s22] = l2 | 0 : a3.length--, a3._strip(); + } + var J2 = function(f3, a3, c2) { + var d5 = f3.words, g3 = a3.words, x2 = c2.words, M2 = 0, l2, s22, v3, k2 = d5[0] | 0, u3 = k2 & 8191, E2 = k2 >>> 13, _3 = d5[1] | 0, B2 = _3 & 8191, R2 = _3 >>> 13, T2 = d5[2] | 0, P2 = T2 & 8191, O3 = T2 >>> 13, Ct2 = d5[3] | 0, D2 = Ct2 & 8191, q2 = Ct2 >>> 13, De2 = d5[4] | 0, X2 = De2 & 8191, Z22 = De2 >>> 13, Fe2 = d5[5] | 0, $2 = Fe2 & 8191, tt2 = Fe2 >>> 13, Te2 = d5[6] | 0, et2 = Te2 & 8191, rt2 = Te2 >>> 13, Ue2 = d5[7] | 0, it2 = Ue2 & 8191, nt2 = Ue2 >>> 13, ke2 = d5[8] | 0, ft2 = ke2 & 8191, ot2 = ke2 >>> 13, qe2 = d5[9] | 0, st2 = qe2 & 8191, at2 = qe2 >>> 13, Ke2 = g3[0] | 0, ut2 = Ke2 & 8191, ht2 = Ke2 >>> 13, He2 = g3[1] | 0, ct2 = He2 & 8191, lt2 = He2 >>> 13, ze2 = g3[2] | 0, dt2 = ze2 & 8191, pt2 = ze2 >>> 13, Le2 = g3[3] | 0, vt2 = Le2 & 8191, mt2 = Le2 >>> 13, je2 = g3[4] | 0, gt2 = je2 & 8191, At2 = je2 >>> 13, Qe2 = g3[5] | 0, bt2 = Qe2 & 8191, yt2 = Qe2 >>> 13, Je2 = g3[6] | 0, wt2 = Je2 & 8191, xt2 = Je2 >>> 13, Ge2 = g3[7] | 0, Mt2 = Ge2 & 8191, Et2 = Ge2 >>> 13, Ye2 = g3[8] | 0, St2 = Ye2 & 8191, Nt2 = Ye2 >>> 13, Ve2 = g3[9] | 0, It2 = Ve2 & 8191, _t2 = Ve2 >>> 13; + c2.negative = f3.negative ^ a3.negative, c2.length = 19, l2 = Math.imul(u3, ut2), s22 = Math.imul(u3, ht2), s22 = s22 + Math.imul(E2, ut2) | 0, v3 = Math.imul(E2, ht2); + var Me2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Me2 >>> 26) | 0, Me2 &= 67108863, l2 = Math.imul(B2, ut2), s22 = Math.imul(B2, ht2), s22 = s22 + Math.imul(R2, ut2) | 0, v3 = Math.imul(R2, ht2), l2 = l2 + Math.imul(u3, ct2) | 0, s22 = s22 + Math.imul(u3, lt2) | 0, s22 = s22 + Math.imul(E2, ct2) | 0, v3 = v3 + Math.imul(E2, lt2) | 0; + var Ee2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Ee2 >>> 26) | 0, Ee2 &= 67108863, l2 = Math.imul(P2, ut2), s22 = Math.imul(P2, ht2), s22 = s22 + Math.imul(O3, ut2) | 0, v3 = Math.imul(O3, ht2), l2 = l2 + Math.imul(B2, ct2) | 0, s22 = s22 + Math.imul(B2, lt2) | 0, s22 = s22 + Math.imul(R2, ct2) | 0, v3 = v3 + Math.imul(R2, lt2) | 0, l2 = l2 + Math.imul(u3, dt2) | 0, s22 = s22 + Math.imul(u3, pt2) | 0, s22 = s22 + Math.imul(E2, dt2) | 0, v3 = v3 + Math.imul(E2, pt2) | 0; + var Se2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Se2 >>> 26) | 0, Se2 &= 67108863, l2 = Math.imul(D2, ut2), s22 = Math.imul(D2, ht2), s22 = s22 + Math.imul(q2, ut2) | 0, v3 = Math.imul(q2, ht2), l2 = l2 + Math.imul(P2, ct2) | 0, s22 = s22 + Math.imul(P2, lt2) | 0, s22 = s22 + Math.imul(O3, ct2) | 0, v3 = v3 + Math.imul(O3, lt2) | 0, l2 = l2 + Math.imul(B2, dt2) | 0, s22 = s22 + Math.imul(B2, pt2) | 0, s22 = s22 + Math.imul(R2, dt2) | 0, v3 = v3 + Math.imul(R2, pt2) | 0, l2 = l2 + Math.imul(u3, vt2) | 0, s22 = s22 + Math.imul(u3, mt2) | 0, s22 = s22 + Math.imul(E2, vt2) | 0, v3 = v3 + Math.imul(E2, mt2) | 0; + var Ne2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Ne2 >>> 26) | 0, Ne2 &= 67108863, l2 = Math.imul(X2, ut2), s22 = Math.imul(X2, ht2), s22 = s22 + Math.imul(Z22, ut2) | 0, v3 = Math.imul(Z22, ht2), l2 = l2 + Math.imul(D2, ct2) | 0, s22 = s22 + Math.imul(D2, lt2) | 0, s22 = s22 + Math.imul(q2, ct2) | 0, v3 = v3 + Math.imul(q2, lt2) | 0, l2 = l2 + Math.imul(P2, dt2) | 0, s22 = s22 + Math.imul(P2, pt2) | 0, s22 = s22 + Math.imul(O3, dt2) | 0, v3 = v3 + Math.imul(O3, pt2) | 0, l2 = l2 + Math.imul(B2, vt2) | 0, s22 = s22 + Math.imul(B2, mt2) | 0, s22 = s22 + Math.imul(R2, vt2) | 0, v3 = v3 + Math.imul(R2, mt2) | 0, l2 = l2 + Math.imul(u3, gt2) | 0, s22 = s22 + Math.imul(u3, At2) | 0, s22 = s22 + Math.imul(E2, gt2) | 0, v3 = v3 + Math.imul(E2, At2) | 0; + var Ie2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Ie2 >>> 26) | 0, Ie2 &= 67108863, l2 = Math.imul($2, ut2), s22 = Math.imul($2, ht2), s22 = s22 + Math.imul(tt2, ut2) | 0, v3 = Math.imul(tt2, ht2), l2 = l2 + Math.imul(X2, ct2) | 0, s22 = s22 + Math.imul(X2, lt2) | 0, s22 = s22 + Math.imul(Z22, ct2) | 0, v3 = v3 + Math.imul(Z22, lt2) | 0, l2 = l2 + Math.imul(D2, dt2) | 0, s22 = s22 + Math.imul(D2, pt2) | 0, s22 = s22 + Math.imul(q2, dt2) | 0, v3 = v3 + Math.imul(q2, pt2) | 0, l2 = l2 + Math.imul(P2, vt2) | 0, s22 = s22 + Math.imul(P2, mt2) | 0, s22 = s22 + Math.imul(O3, vt2) | 0, v3 = v3 + Math.imul(O3, mt2) | 0, l2 = l2 + Math.imul(B2, gt2) | 0, s22 = s22 + Math.imul(B2, At2) | 0, s22 = s22 + Math.imul(R2, gt2) | 0, v3 = v3 + Math.imul(R2, At2) | 0, l2 = l2 + Math.imul(u3, bt2) | 0, s22 = s22 + Math.imul(u3, yt2) | 0, s22 = s22 + Math.imul(E2, bt2) | 0, v3 = v3 + Math.imul(E2, yt2) | 0; + var Wr = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Wr >>> 26) | 0, Wr &= 67108863, l2 = Math.imul(et2, ut2), s22 = Math.imul(et2, ht2), s22 = s22 + Math.imul(rt2, ut2) | 0, v3 = Math.imul(rt2, ht2), l2 = l2 + Math.imul($2, ct2) | 0, s22 = s22 + Math.imul($2, lt2) | 0, s22 = s22 + Math.imul(tt2, ct2) | 0, v3 = v3 + Math.imul(tt2, lt2) | 0, l2 = l2 + Math.imul(X2, dt2) | 0, s22 = s22 + Math.imul(X2, pt2) | 0, s22 = s22 + Math.imul(Z22, dt2) | 0, v3 = v3 + Math.imul(Z22, pt2) | 0, l2 = l2 + Math.imul(D2, vt2) | 0, s22 = s22 + Math.imul(D2, mt2) | 0, s22 = s22 + Math.imul(q2, vt2) | 0, v3 = v3 + Math.imul(q2, mt2) | 0, l2 = l2 + Math.imul(P2, gt2) | 0, s22 = s22 + Math.imul(P2, At2) | 0, s22 = s22 + Math.imul(O3, gt2) | 0, v3 = v3 + Math.imul(O3, At2) | 0, l2 = l2 + Math.imul(B2, bt2) | 0, s22 = s22 + Math.imul(B2, yt2) | 0, s22 = s22 + Math.imul(R2, bt2) | 0, v3 = v3 + Math.imul(R2, yt2) | 0, l2 = l2 + Math.imul(u3, wt2) | 0, s22 = s22 + Math.imul(u3, xt2) | 0, s22 = s22 + Math.imul(E2, wt2) | 0, v3 = v3 + Math.imul(E2, xt2) | 0; + var Xr = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Xr >>> 26) | 0, Xr &= 67108863, l2 = Math.imul(it2, ut2), s22 = Math.imul(it2, ht2), s22 = s22 + Math.imul(nt2, ut2) | 0, v3 = Math.imul(nt2, ht2), l2 = l2 + Math.imul(et2, ct2) | 0, s22 = s22 + Math.imul(et2, lt2) | 0, s22 = s22 + Math.imul(rt2, ct2) | 0, v3 = v3 + Math.imul(rt2, lt2) | 0, l2 = l2 + Math.imul($2, dt2) | 0, s22 = s22 + Math.imul($2, pt2) | 0, s22 = s22 + Math.imul(tt2, dt2) | 0, v3 = v3 + Math.imul(tt2, pt2) | 0, l2 = l2 + Math.imul(X2, vt2) | 0, s22 = s22 + Math.imul(X2, mt2) | 0, s22 = s22 + Math.imul(Z22, vt2) | 0, v3 = v3 + Math.imul(Z22, mt2) | 0, l2 = l2 + Math.imul(D2, gt2) | 0, s22 = s22 + Math.imul(D2, At2) | 0, s22 = s22 + Math.imul(q2, gt2) | 0, v3 = v3 + Math.imul(q2, At2) | 0, l2 = l2 + Math.imul(P2, bt2) | 0, s22 = s22 + Math.imul(P2, yt2) | 0, s22 = s22 + Math.imul(O3, bt2) | 0, v3 = v3 + Math.imul(O3, yt2) | 0, l2 = l2 + Math.imul(B2, wt2) | 0, s22 = s22 + Math.imul(B2, xt2) | 0, s22 = s22 + Math.imul(R2, wt2) | 0, v3 = v3 + Math.imul(R2, xt2) | 0, l2 = l2 + Math.imul(u3, Mt2) | 0, s22 = s22 + Math.imul(u3, Et2) | 0, s22 = s22 + Math.imul(E2, Mt2) | 0, v3 = v3 + Math.imul(E2, Et2) | 0; + var Zr = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (Zr >>> 26) | 0, Zr &= 67108863, l2 = Math.imul(ft2, ut2), s22 = Math.imul(ft2, ht2), s22 = s22 + Math.imul(ot2, ut2) | 0, v3 = Math.imul(ot2, ht2), l2 = l2 + Math.imul(it2, ct2) | 0, s22 = s22 + Math.imul(it2, lt2) | 0, s22 = s22 + Math.imul(nt2, ct2) | 0, v3 = v3 + Math.imul(nt2, lt2) | 0, l2 = l2 + Math.imul(et2, dt2) | 0, s22 = s22 + Math.imul(et2, pt2) | 0, s22 = s22 + Math.imul(rt2, dt2) | 0, v3 = v3 + Math.imul(rt2, pt2) | 0, l2 = l2 + Math.imul($2, vt2) | 0, s22 = s22 + Math.imul($2, mt2) | 0, s22 = s22 + Math.imul(tt2, vt2) | 0, v3 = v3 + Math.imul(tt2, mt2) | 0, l2 = l2 + Math.imul(X2, gt2) | 0, s22 = s22 + Math.imul(X2, At2) | 0, s22 = s22 + Math.imul(Z22, gt2) | 0, v3 = v3 + Math.imul(Z22, At2) | 0, l2 = l2 + Math.imul(D2, bt2) | 0, s22 = s22 + Math.imul(D2, yt2) | 0, s22 = s22 + Math.imul(q2, bt2) | 0, v3 = v3 + Math.imul(q2, yt2) | 0, l2 = l2 + Math.imul(P2, wt2) | 0, s22 = s22 + Math.imul(P2, xt2) | 0, s22 = s22 + Math.imul(O3, wt2) | 0, v3 = v3 + Math.imul(O3, xt2) | 0, l2 = l2 + Math.imul(B2, Mt2) | 0, s22 = s22 + Math.imul(B2, Et2) | 0, s22 = s22 + Math.imul(R2, Mt2) | 0, v3 = v3 + Math.imul(R2, Et2) | 0, l2 = l2 + Math.imul(u3, St2) | 0, s22 = s22 + Math.imul(u3, Nt2) | 0, s22 = s22 + Math.imul(E2, St2) | 0, v3 = v3 + Math.imul(E2, Nt2) | 0; + var $r2 = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + ($r2 >>> 26) | 0, $r2 &= 67108863, l2 = Math.imul(st2, ut2), s22 = Math.imul(st2, ht2), s22 = s22 + Math.imul(at2, ut2) | 0, v3 = Math.imul(at2, ht2), l2 = l2 + Math.imul(ft2, ct2) | 0, s22 = s22 + Math.imul(ft2, lt2) | 0, s22 = s22 + Math.imul(ot2, ct2) | 0, v3 = v3 + Math.imul(ot2, lt2) | 0, l2 = l2 + Math.imul(it2, dt2) | 0, s22 = s22 + Math.imul(it2, pt2) | 0, s22 = s22 + Math.imul(nt2, dt2) | 0, v3 = v3 + Math.imul(nt2, pt2) | 0, l2 = l2 + Math.imul(et2, vt2) | 0, s22 = s22 + Math.imul(et2, mt2) | 0, s22 = s22 + Math.imul(rt2, vt2) | 0, v3 = v3 + Math.imul(rt2, mt2) | 0, l2 = l2 + Math.imul($2, gt2) | 0, s22 = s22 + Math.imul($2, At2) | 0, s22 = s22 + Math.imul(tt2, gt2) | 0, v3 = v3 + Math.imul(tt2, At2) | 0, l2 = l2 + Math.imul(X2, bt2) | 0, s22 = s22 + Math.imul(X2, yt2) | 0, s22 = s22 + Math.imul(Z22, bt2) | 0, v3 = v3 + Math.imul(Z22, yt2) | 0, l2 = l2 + Math.imul(D2, wt2) | 0, s22 = s22 + Math.imul(D2, xt2) | 0, s22 = s22 + Math.imul(q2, wt2) | 0, v3 = v3 + Math.imul(q2, xt2) | 0, l2 = l2 + Math.imul(P2, Mt2) | 0, s22 = s22 + Math.imul(P2, Et2) | 0, s22 = s22 + Math.imul(O3, Mt2) | 0, v3 = v3 + Math.imul(O3, Et2) | 0, l2 = l2 + Math.imul(B2, St2) | 0, s22 = s22 + Math.imul(B2, Nt2) | 0, s22 = s22 + Math.imul(R2, St2) | 0, v3 = v3 + Math.imul(R2, Nt2) | 0, l2 = l2 + Math.imul(u3, It2) | 0, s22 = s22 + Math.imul(u3, _t2) | 0, s22 = s22 + Math.imul(E2, It2) | 0, v3 = v3 + Math.imul(E2, _t2) | 0; + var ti = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ti >>> 26) | 0, ti &= 67108863, l2 = Math.imul(st2, ct2), s22 = Math.imul(st2, lt2), s22 = s22 + Math.imul(at2, ct2) | 0, v3 = Math.imul(at2, lt2), l2 = l2 + Math.imul(ft2, dt2) | 0, s22 = s22 + Math.imul(ft2, pt2) | 0, s22 = s22 + Math.imul(ot2, dt2) | 0, v3 = v3 + Math.imul(ot2, pt2) | 0, l2 = l2 + Math.imul(it2, vt2) | 0, s22 = s22 + Math.imul(it2, mt2) | 0, s22 = s22 + Math.imul(nt2, vt2) | 0, v3 = v3 + Math.imul(nt2, mt2) | 0, l2 = l2 + Math.imul(et2, gt2) | 0, s22 = s22 + Math.imul(et2, At2) | 0, s22 = s22 + Math.imul(rt2, gt2) | 0, v3 = v3 + Math.imul(rt2, At2) | 0, l2 = l2 + Math.imul($2, bt2) | 0, s22 = s22 + Math.imul($2, yt2) | 0, s22 = s22 + Math.imul(tt2, bt2) | 0, v3 = v3 + Math.imul(tt2, yt2) | 0, l2 = l2 + Math.imul(X2, wt2) | 0, s22 = s22 + Math.imul(X2, xt2) | 0, s22 = s22 + Math.imul(Z22, wt2) | 0, v3 = v3 + Math.imul(Z22, xt2) | 0, l2 = l2 + Math.imul(D2, Mt2) | 0, s22 = s22 + Math.imul(D2, Et2) | 0, s22 = s22 + Math.imul(q2, Mt2) | 0, v3 = v3 + Math.imul(q2, Et2) | 0, l2 = l2 + Math.imul(P2, St2) | 0, s22 = s22 + Math.imul(P2, Nt2) | 0, s22 = s22 + Math.imul(O3, St2) | 0, v3 = v3 + Math.imul(O3, Nt2) | 0, l2 = l2 + Math.imul(B2, It2) | 0, s22 = s22 + Math.imul(B2, _t2) | 0, s22 = s22 + Math.imul(R2, It2) | 0, v3 = v3 + Math.imul(R2, _t2) | 0; + var ei = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ei >>> 26) | 0, ei &= 67108863, l2 = Math.imul(st2, dt2), s22 = Math.imul(st2, pt2), s22 = s22 + Math.imul(at2, dt2) | 0, v3 = Math.imul(at2, pt2), l2 = l2 + Math.imul(ft2, vt2) | 0, s22 = s22 + Math.imul(ft2, mt2) | 0, s22 = s22 + Math.imul(ot2, vt2) | 0, v3 = v3 + Math.imul(ot2, mt2) | 0, l2 = l2 + Math.imul(it2, gt2) | 0, s22 = s22 + Math.imul(it2, At2) | 0, s22 = s22 + Math.imul(nt2, gt2) | 0, v3 = v3 + Math.imul(nt2, At2) | 0, l2 = l2 + Math.imul(et2, bt2) | 0, s22 = s22 + Math.imul(et2, yt2) | 0, s22 = s22 + Math.imul(rt2, bt2) | 0, v3 = v3 + Math.imul(rt2, yt2) | 0, l2 = l2 + Math.imul($2, wt2) | 0, s22 = s22 + Math.imul($2, xt2) | 0, s22 = s22 + Math.imul(tt2, wt2) | 0, v3 = v3 + Math.imul(tt2, xt2) | 0, l2 = l2 + Math.imul(X2, Mt2) | 0, s22 = s22 + Math.imul(X2, Et2) | 0, s22 = s22 + Math.imul(Z22, Mt2) | 0, v3 = v3 + Math.imul(Z22, Et2) | 0, l2 = l2 + Math.imul(D2, St2) | 0, s22 = s22 + Math.imul(D2, Nt2) | 0, s22 = s22 + Math.imul(q2, St2) | 0, v3 = v3 + Math.imul(q2, Nt2) | 0, l2 = l2 + Math.imul(P2, It2) | 0, s22 = s22 + Math.imul(P2, _t2) | 0, s22 = s22 + Math.imul(O3, It2) | 0, v3 = v3 + Math.imul(O3, _t2) | 0; + var ri = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ri >>> 26) | 0, ri &= 67108863, l2 = Math.imul(st2, vt2), s22 = Math.imul(st2, mt2), s22 = s22 + Math.imul(at2, vt2) | 0, v3 = Math.imul(at2, mt2), l2 = l2 + Math.imul(ft2, gt2) | 0, s22 = s22 + Math.imul(ft2, At2) | 0, s22 = s22 + Math.imul(ot2, gt2) | 0, v3 = v3 + Math.imul(ot2, At2) | 0, l2 = l2 + Math.imul(it2, bt2) | 0, s22 = s22 + Math.imul(it2, yt2) | 0, s22 = s22 + Math.imul(nt2, bt2) | 0, v3 = v3 + Math.imul(nt2, yt2) | 0, l2 = l2 + Math.imul(et2, wt2) | 0, s22 = s22 + Math.imul(et2, xt2) | 0, s22 = s22 + Math.imul(rt2, wt2) | 0, v3 = v3 + Math.imul(rt2, xt2) | 0, l2 = l2 + Math.imul($2, Mt2) | 0, s22 = s22 + Math.imul($2, Et2) | 0, s22 = s22 + Math.imul(tt2, Mt2) | 0, v3 = v3 + Math.imul(tt2, Et2) | 0, l2 = l2 + Math.imul(X2, St2) | 0, s22 = s22 + Math.imul(X2, Nt2) | 0, s22 = s22 + Math.imul(Z22, St2) | 0, v3 = v3 + Math.imul(Z22, Nt2) | 0, l2 = l2 + Math.imul(D2, It2) | 0, s22 = s22 + Math.imul(D2, _t2) | 0, s22 = s22 + Math.imul(q2, It2) | 0, v3 = v3 + Math.imul(q2, _t2) | 0; + var ii = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ii >>> 26) | 0, ii &= 67108863, l2 = Math.imul(st2, gt2), s22 = Math.imul(st2, At2), s22 = s22 + Math.imul(at2, gt2) | 0, v3 = Math.imul(at2, At2), l2 = l2 + Math.imul(ft2, bt2) | 0, s22 = s22 + Math.imul(ft2, yt2) | 0, s22 = s22 + Math.imul(ot2, bt2) | 0, v3 = v3 + Math.imul(ot2, yt2) | 0, l2 = l2 + Math.imul(it2, wt2) | 0, s22 = s22 + Math.imul(it2, xt2) | 0, s22 = s22 + Math.imul(nt2, wt2) | 0, v3 = v3 + Math.imul(nt2, xt2) | 0, l2 = l2 + Math.imul(et2, Mt2) | 0, s22 = s22 + Math.imul(et2, Et2) | 0, s22 = s22 + Math.imul(rt2, Mt2) | 0, v3 = v3 + Math.imul(rt2, Et2) | 0, l2 = l2 + Math.imul($2, St2) | 0, s22 = s22 + Math.imul($2, Nt2) | 0, s22 = s22 + Math.imul(tt2, St2) | 0, v3 = v3 + Math.imul(tt2, Nt2) | 0, l2 = l2 + Math.imul(X2, It2) | 0, s22 = s22 + Math.imul(X2, _t2) | 0, s22 = s22 + Math.imul(Z22, It2) | 0, v3 = v3 + Math.imul(Z22, _t2) | 0; + var ni = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ni >>> 26) | 0, ni &= 67108863, l2 = Math.imul(st2, bt2), s22 = Math.imul(st2, yt2), s22 = s22 + Math.imul(at2, bt2) | 0, v3 = Math.imul(at2, yt2), l2 = l2 + Math.imul(ft2, wt2) | 0, s22 = s22 + Math.imul(ft2, xt2) | 0, s22 = s22 + Math.imul(ot2, wt2) | 0, v3 = v3 + Math.imul(ot2, xt2) | 0, l2 = l2 + Math.imul(it2, Mt2) | 0, s22 = s22 + Math.imul(it2, Et2) | 0, s22 = s22 + Math.imul(nt2, Mt2) | 0, v3 = v3 + Math.imul(nt2, Et2) | 0, l2 = l2 + Math.imul(et2, St2) | 0, s22 = s22 + Math.imul(et2, Nt2) | 0, s22 = s22 + Math.imul(rt2, St2) | 0, v3 = v3 + Math.imul(rt2, Nt2) | 0, l2 = l2 + Math.imul($2, It2) | 0, s22 = s22 + Math.imul($2, _t2) | 0, s22 = s22 + Math.imul(tt2, It2) | 0, v3 = v3 + Math.imul(tt2, _t2) | 0; + var fi = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (fi >>> 26) | 0, fi &= 67108863, l2 = Math.imul(st2, wt2), s22 = Math.imul(st2, xt2), s22 = s22 + Math.imul(at2, wt2) | 0, v3 = Math.imul(at2, xt2), l2 = l2 + Math.imul(ft2, Mt2) | 0, s22 = s22 + Math.imul(ft2, Et2) | 0, s22 = s22 + Math.imul(ot2, Mt2) | 0, v3 = v3 + Math.imul(ot2, Et2) | 0, l2 = l2 + Math.imul(it2, St2) | 0, s22 = s22 + Math.imul(it2, Nt2) | 0, s22 = s22 + Math.imul(nt2, St2) | 0, v3 = v3 + Math.imul(nt2, Nt2) | 0, l2 = l2 + Math.imul(et2, It2) | 0, s22 = s22 + Math.imul(et2, _t2) | 0, s22 = s22 + Math.imul(rt2, It2) | 0, v3 = v3 + Math.imul(rt2, _t2) | 0; + var oi = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (oi >>> 26) | 0, oi &= 67108863, l2 = Math.imul(st2, Mt2), s22 = Math.imul(st2, Et2), s22 = s22 + Math.imul(at2, Mt2) | 0, v3 = Math.imul(at2, Et2), l2 = l2 + Math.imul(ft2, St2) | 0, s22 = s22 + Math.imul(ft2, Nt2) | 0, s22 = s22 + Math.imul(ot2, St2) | 0, v3 = v3 + Math.imul(ot2, Nt2) | 0, l2 = l2 + Math.imul(it2, It2) | 0, s22 = s22 + Math.imul(it2, _t2) | 0, s22 = s22 + Math.imul(nt2, It2) | 0, v3 = v3 + Math.imul(nt2, _t2) | 0; + var si = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (si >>> 26) | 0, si &= 67108863, l2 = Math.imul(st2, St2), s22 = Math.imul(st2, Nt2), s22 = s22 + Math.imul(at2, St2) | 0, v3 = Math.imul(at2, Nt2), l2 = l2 + Math.imul(ft2, It2) | 0, s22 = s22 + Math.imul(ft2, _t2) | 0, s22 = s22 + Math.imul(ot2, It2) | 0, v3 = v3 + Math.imul(ot2, _t2) | 0; + var ai = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + M2 = (v3 + (s22 >>> 13) | 0) + (ai >>> 26) | 0, ai &= 67108863, l2 = Math.imul(st2, It2), s22 = Math.imul(st2, _t2), s22 = s22 + Math.imul(at2, It2) | 0, v3 = Math.imul(at2, _t2); + var ui = (M2 + l2 | 0) + ((s22 & 8191) << 13) | 0; + return M2 = (v3 + (s22 >>> 13) | 0) + (ui >>> 26) | 0, ui &= 67108863, x2[0] = Me2, x2[1] = Ee2, x2[2] = Se2, x2[3] = Ne2, x2[4] = Ie2, x2[5] = Wr, x2[6] = Xr, x2[7] = Zr, x2[8] = $r2, x2[9] = ti, x2[10] = ei, x2[11] = ri, x2[12] = ii, x2[13] = ni, x2[14] = fi, x2[15] = oi, x2[16] = si, x2[17] = ai, x2[18] = ui, M2 !== 0 && (x2[19] = M2, c2.length++), c2; + }; + Math.imul || (J2 = U2); + function Bt2(A2, f3, a3) { + a3.negative = f3.negative ^ A2.negative, a3.length = A2.length + f3.length; + for (var c2 = 0, d5 = 0, g3 = 0; g3 < a3.length - 1; g3++) { + var x2 = d5; + d5 = 0; + for (var M2 = c2 & 67108863, l2 = Math.min(g3, f3.length - 1), s22 = Math.max(0, g3 - A2.length + 1); s22 <= l2; s22++) { + var v3 = g3 - s22, k2 = A2.words[v3] | 0, u3 = f3.words[s22] | 0, E2 = k2 * u3, _3 = E2 & 67108863; + x2 = x2 + (E2 / 67108864 | 0) | 0, _3 = _3 + M2 | 0, M2 = _3 & 67108863, x2 = x2 + (_3 >>> 26) | 0, d5 += x2 >>> 26, x2 &= 67108863; + } + a3.words[g3] = M2, c2 = x2, x2 = d5; + } + return c2 !== 0 ? a3.words[g3] = c2 : a3.length--, a3._strip(); + } + function G2(A2, f3, a3) { + return Bt2(A2, f3, a3); + } + o22.prototype.mulTo = function(f3, a3) { + var c2, d5 = this.length + f3.length; + return this.length === 10 && f3.length === 10 ? c2 = J2(this, f3, a3) : d5 < 63 ? c2 = U2(this, f3, a3) : d5 < 1024 ? c2 = Bt2(this, f3, a3) : c2 = G2(this, f3, a3), c2; + }, o22.prototype.mul = function(f3) { + var a3 = new o22(null); + return a3.words = new Array(this.length + f3.length), this.mulTo(f3, a3); + }, o22.prototype.mulf = function(f3) { + var a3 = new o22(null); + return a3.words = new Array(this.length + f3.length), G2(this, f3, a3); + }, o22.prototype.imul = function(f3) { + return this.clone().mulTo(f3, this); + }, o22.prototype.imuln = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(typeof f3 == "number"), i2(f3 < 67108864); + for (var c2 = 0, d5 = 0; d5 < this.length; d5++) { + var g3 = (this.words[d5] | 0) * f3, x2 = (g3 & 67108863) + (c2 & 67108863); + c2 >>= 26, c2 += g3 / 67108864 | 0, c2 += x2 >>> 26, this.words[d5] = x2 & 67108863; + } + return c2 !== 0 && (this.words[d5] = c2, this.length++), a3 ? this.ineg() : this; + }, o22.prototype.muln = function(f3) { + return this.clone().imuln(f3); + }, o22.prototype.sqr = function() { + return this.mul(this); + }, o22.prototype.isqr = function() { + return this.imul(this.clone()); + }, o22.prototype.pow = function(f3) { + var a3 = F2(f3); + if (a3.length === 0) + return new o22(1); + for (var c2 = this, d5 = 0; d5 < a3.length && a3[d5] === 0; d5++, c2 = c2.sqr()) + ; + if (++d5 < a3.length) + for (var g3 = c2.sqr(); d5 < a3.length; d5++, g3 = g3.sqr()) + a3[d5] !== 0 && (c2 = c2.mul(g3)); + return c2; + }, o22.prototype.iushln = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 67108863 >>> 26 - a3 << 26 - a3, g3; + if (a3 !== 0) { + var x2 = 0; + for (g3 = 0; g3 < this.length; g3++) { + var M2 = this.words[g3] & d5, l2 = (this.words[g3] | 0) - M2 << a3; + this.words[g3] = l2 | x2, x2 = M2 >>> 26 - a3; + } + x2 && (this.words[g3] = x2, this.length++); + } + if (c2 !== 0) { + for (g3 = this.length - 1; g3 >= 0; g3--) + this.words[g3 + c2] = this.words[g3]; + for (g3 = 0; g3 < c2; g3++) + this.words[g3] = 0; + this.length += c2; + } + return this._strip(); + }, o22.prototype.ishln = function(f3) { + return i2(this.negative === 0), this.iushln(f3); + }, o22.prototype.iushrn = function(f3, a3, c2) { + i2(typeof f3 == "number" && f3 >= 0); + var d5; + a3 ? d5 = (a3 - a3 % 26) / 26 : d5 = 0; + var g3 = f3 % 26, x2 = Math.min((f3 - g3) / 26, this.length), M2 = 67108863 ^ 67108863 >>> g3 << g3, l2 = c2; + if (d5 -= x2, d5 = Math.max(0, d5), l2) { + for (var s22 = 0; s22 < x2; s22++) + l2.words[s22] = this.words[s22]; + l2.length = x2; + } + if (x2 !== 0) + if (this.length > x2) + for (this.length -= x2, s22 = 0; s22 < this.length; s22++) + this.words[s22] = this.words[s22 + x2]; + else + this.words[0] = 0, this.length = 1; + var v3 = 0; + for (s22 = this.length - 1; s22 >= 0 && (v3 !== 0 || s22 >= d5); s22--) { + var k2 = this.words[s22] | 0; + this.words[s22] = v3 << 26 - g3 | k2 >>> g3, v3 = k2 & M2; + } + return l2 && v3 !== 0 && (l2.words[l2.length++] = v3), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, o22.prototype.ishrn = function(f3, a3, c2) { + return i2(this.negative === 0), this.iushrn(f3, a3, c2); + }, o22.prototype.shln = function(f3) { + return this.clone().ishln(f3); + }, o22.prototype.ushln = function(f3) { + return this.clone().iushln(f3); + }, o22.prototype.shrn = function(f3) { + return this.clone().ishrn(f3); + }, o22.prototype.ushrn = function(f3) { + return this.clone().iushrn(f3); + }, o22.prototype.testn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return false; + var g3 = this.words[c2]; + return !!(g3 & d5); + }, o22.prototype.imaskn = function(f3) { + i2(typeof f3 == "number" && f3 >= 0); + var a3 = f3 % 26, c2 = (f3 - a3) / 26; + if (i2(this.negative === 0, "imaskn works only with positive numbers"), this.length <= c2) + return this; + if (a3 !== 0 && c2++, this.length = Math.min(c2, this.length), a3 !== 0) { + var d5 = 67108863 ^ 67108863 >>> a3 << a3; + this.words[this.length - 1] &= d5; + } + return this._strip(); + }, o22.prototype.maskn = function(f3) { + return this.clone().imaskn(f3); + }, o22.prototype.iaddn = function(f3) { + return i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0 ? this.isubn(-f3) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f3 ? (this.words[0] = f3 - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f3), this.negative = 1, this) : this._iaddn(f3); + }, o22.prototype._iaddn = function(f3) { + this.words[0] += f3; + for (var a3 = 0; a3 < this.length && this.words[a3] >= 67108864; a3++) + this.words[a3] -= 67108864, a3 === this.length - 1 ? this.words[a3 + 1] = 1 : this.words[a3 + 1]++; + return this.length = Math.max(this.length, a3 + 1), this; + }, o22.prototype.isubn = function(f3) { + if (i2(typeof f3 == "number"), i2(f3 < 67108864), f3 < 0) + return this.iaddn(-f3); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(f3), this.negative = 1, this; + if (this.words[0] -= f3, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var a3 = 0; a3 < this.length && this.words[a3] < 0; a3++) + this.words[a3] += 67108864, this.words[a3 + 1] -= 1; + return this._strip(); + }, o22.prototype.addn = function(f3) { + return this.clone().iaddn(f3); + }, o22.prototype.subn = function(f3) { + return this.clone().isubn(f3); + }, o22.prototype.iabs = function() { + return this.negative = 0, this; + }, o22.prototype.abs = function() { + return this.clone().iabs(); + }, o22.prototype._ishlnsubmul = function(f3, a3, c2) { + var d5 = f3.length + c2, g3; + this._expand(d5); + var x2, M2 = 0; + for (g3 = 0; g3 < f3.length; g3++) { + x2 = (this.words[g3 + c2] | 0) + M2; + var l2 = (f3.words[g3] | 0) * a3; + x2 -= l2 & 67108863, M2 = (x2 >> 26) - (l2 / 67108864 | 0), this.words[g3 + c2] = x2 & 67108863; + } + for (; g3 < this.length - c2; g3++) + x2 = (this.words[g3 + c2] | 0) + M2, M2 = x2 >> 26, this.words[g3 + c2] = x2 & 67108863; + if (M2 === 0) + return this._strip(); + for (i2(M2 === -1), M2 = 0, g3 = 0; g3 < this.length; g3++) + x2 = -(this.words[g3] | 0) + M2, M2 = x2 >> 26, this.words[g3] = x2 & 67108863; + return this.negative = 1, this._strip(); + }, o22.prototype._wordDiv = function(f3, a3) { + var c2 = this.length - f3.length, d5 = this.clone(), g3 = f3, x2 = g3.words[g3.length - 1] | 0, M2 = this._countBits(x2); + c2 = 26 - M2, c2 !== 0 && (g3 = g3.ushln(c2), d5.iushln(c2), x2 = g3.words[g3.length - 1] | 0); + var l2 = d5.length - g3.length, s22; + if (a3 !== "mod") { + s22 = new o22(null), s22.length = l2 + 1, s22.words = new Array(s22.length); + for (var v3 = 0; v3 < s22.length; v3++) + s22.words[v3] = 0; + } + var k2 = d5.clone()._ishlnsubmul(g3, 1, l2); + k2.negative === 0 && (d5 = k2, s22 && (s22.words[l2] = 1)); + for (var u3 = l2 - 1; u3 >= 0; u3--) { + var E2 = (d5.words[g3.length + u3] | 0) * 67108864 + (d5.words[g3.length + u3 - 1] | 0); + for (E2 = Math.min(E2 / x2 | 0, 67108863), d5._ishlnsubmul(g3, E2, u3); d5.negative !== 0; ) + E2--, d5.negative = 0, d5._ishlnsubmul(g3, 1, u3), d5.isZero() || (d5.negative ^= 1); + s22 && (s22.words[u3] = E2); + } + return s22 && s22._strip(), d5._strip(), a3 !== "div" && c2 !== 0 && d5.iushrn(c2), { div: s22 || null, mod: d5 }; + }, o22.prototype.divmod = function(f3, a3, c2) { + if (i2(!f3.isZero()), this.isZero()) + return { div: new o22(0), mod: new o22(0) }; + var d5, g3, x2; + return this.negative !== 0 && f3.negative === 0 ? (x2 = this.neg().divmod(f3, a3), a3 !== "mod" && (d5 = x2.div.neg()), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.iadd(f3)), { div: d5, mod: g3 }) : this.negative === 0 && f3.negative !== 0 ? (x2 = this.divmod(f3.neg(), a3), a3 !== "mod" && (d5 = x2.div.neg()), { div: d5, mod: x2.mod }) : this.negative & f3.negative ? (x2 = this.neg().divmod(f3.neg(), a3), a3 !== "div" && (g3 = x2.mod.neg(), c2 && g3.negative !== 0 && g3.isub(f3)), { div: x2.div, mod: g3 }) : f3.length > this.length || this.cmp(f3) < 0 ? { div: new o22(0), mod: this } : f3.length === 1 ? a3 === "div" ? { div: this.divn(f3.words[0]), mod: null } : a3 === "mod" ? { div: null, mod: new o22(this.modrn(f3.words[0])) } : { div: this.divn(f3.words[0]), mod: new o22(this.modrn(f3.words[0])) } : this._wordDiv(f3, a3); + }, o22.prototype.div = function(f3) { + return this.divmod(f3, "div", false).div; + }, o22.prototype.mod = function(f3) { + return this.divmod(f3, "mod", false).mod; + }, o22.prototype.umod = function(f3) { + return this.divmod(f3, "mod", true).mod; + }, o22.prototype.divRound = function(f3) { + var a3 = this.divmod(f3); + if (a3.mod.isZero()) + return a3.div; + var c2 = a3.div.negative !== 0 ? a3.mod.isub(f3) : a3.mod, d5 = f3.ushrn(1), g3 = f3.andln(1), x2 = c2.cmp(d5); + return x2 < 0 || g3 === 1 && x2 === 0 ? a3.div : a3.div.negative !== 0 ? a3.div.isubn(1) : a3.div.iaddn(1); + }, o22.prototype.modrn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = (1 << 26) % f3, d5 = 0, g3 = this.length - 1; g3 >= 0; g3--) + d5 = (c2 * d5 + (this.words[g3] | 0)) % f3; + return a3 ? -d5 : d5; + }, o22.prototype.modn = function(f3) { + return this.modrn(f3); + }, o22.prototype.idivn = function(f3) { + var a3 = f3 < 0; + a3 && (f3 = -f3), i2(f3 <= 67108863); + for (var c2 = 0, d5 = this.length - 1; d5 >= 0; d5--) { + var g3 = (this.words[d5] | 0) + c2 * 67108864; + this.words[d5] = g3 / f3 | 0, c2 = g3 % f3; + } + return this._strip(), a3 ? this.ineg() : this; + }, o22.prototype.divn = function(f3) { + return this.clone().idivn(f3); + }, o22.prototype.egcd = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o22(1), g3 = new o22(0), x2 = new o22(0), M2 = new o22(1), l2 = 0; a3.isEven() && c2.isEven(); ) + a3.iushrn(1), c2.iushrn(1), ++l2; + for (var s22 = c2.clone(), v3 = a3.clone(); !a3.isZero(); ) { + for (var k2 = 0, u3 = 1; !(a3.words[0] & u3) && k2 < 26; ++k2, u3 <<= 1) + ; + if (k2 > 0) + for (a3.iushrn(k2); k2-- > 0; ) + (d5.isOdd() || g3.isOdd()) && (d5.iadd(s22), g3.isub(v3)), d5.iushrn(1), g3.iushrn(1); + for (var E2 = 0, _3 = 1; !(c2.words[0] & _3) && E2 < 26; ++E2, _3 <<= 1) + ; + if (E2 > 0) + for (c2.iushrn(E2); E2-- > 0; ) + (x2.isOdd() || M2.isOdd()) && (x2.iadd(s22), M2.isub(v3)), x2.iushrn(1), M2.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(x2), g3.isub(M2)) : (c2.isub(a3), x2.isub(d5), M2.isub(g3)); + } + return { a: x2, b: M2, gcd: c2.iushln(l2) }; + }, o22.prototype._invmp = function(f3) { + i2(f3.negative === 0), i2(!f3.isZero()); + var a3 = this, c2 = f3.clone(); + a3.negative !== 0 ? a3 = a3.umod(f3) : a3 = a3.clone(); + for (var d5 = new o22(1), g3 = new o22(0), x2 = c2.clone(); a3.cmpn(1) > 0 && c2.cmpn(1) > 0; ) { + for (var M2 = 0, l2 = 1; !(a3.words[0] & l2) && M2 < 26; ++M2, l2 <<= 1) + ; + if (M2 > 0) + for (a3.iushrn(M2); M2-- > 0; ) + d5.isOdd() && d5.iadd(x2), d5.iushrn(1); + for (var s22 = 0, v3 = 1; !(c2.words[0] & v3) && s22 < 26; ++s22, v3 <<= 1) + ; + if (s22 > 0) + for (c2.iushrn(s22); s22-- > 0; ) + g3.isOdd() && g3.iadd(x2), g3.iushrn(1); + a3.cmp(c2) >= 0 ? (a3.isub(c2), d5.isub(g3)) : (c2.isub(a3), g3.isub(d5)); + } + var k2; + return a3.cmpn(1) === 0 ? k2 = d5 : k2 = g3, k2.cmpn(0) < 0 && k2.iadd(f3), k2; + }, o22.prototype.gcd = function(f3) { + if (this.isZero()) + return f3.abs(); + if (f3.isZero()) + return this.abs(); + var a3 = this.clone(), c2 = f3.clone(); + a3.negative = 0, c2.negative = 0; + for (var d5 = 0; a3.isEven() && c2.isEven(); d5++) + a3.iushrn(1), c2.iushrn(1); + do { + for (; a3.isEven(); ) + a3.iushrn(1); + for (; c2.isEven(); ) + c2.iushrn(1); + var g3 = a3.cmp(c2); + if (g3 < 0) { + var x2 = a3; + a3 = c2, c2 = x2; + } else if (g3 === 0 || c2.cmpn(1) === 0) + break; + a3.isub(c2); + } while (true); + return c2.iushln(d5); + }, o22.prototype.invm = function(f3) { + return this.egcd(f3).a.umod(f3); + }, o22.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, o22.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, o22.prototype.andln = function(f3) { + return this.words[0] & f3; + }, o22.prototype.bincn = function(f3) { + i2(typeof f3 == "number"); + var a3 = f3 % 26, c2 = (f3 - a3) / 26, d5 = 1 << a3; + if (this.length <= c2) + return this._expand(c2 + 1), this.words[c2] |= d5, this; + for (var g3 = d5, x2 = c2; g3 !== 0 && x2 < this.length; x2++) { + var M2 = this.words[x2] | 0; + M2 += g3, g3 = M2 >>> 26, M2 &= 67108863, this.words[x2] = M2; + } + return g3 !== 0 && (this.words[x2] = g3, this.length++), this; + }, o22.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, o22.prototype.cmpn = function(f3) { + var a3 = f3 < 0; + if (this.negative !== 0 && !a3) + return -1; + if (this.negative === 0 && a3) + return 1; + this._strip(); + var c2; + if (this.length > 1) + c2 = 1; + else { + a3 && (f3 = -f3), i2(f3 <= 67108863, "Number is too big"); + var d5 = this.words[0] | 0; + c2 = d5 === f3 ? 0 : d5 < f3 ? -1 : 1; + } + return this.negative !== 0 ? -c2 | 0 : c2; + }, o22.prototype.cmp = function(f3) { + if (this.negative !== 0 && f3.negative === 0) + return -1; + if (this.negative === 0 && f3.negative !== 0) + return 1; + var a3 = this.ucmp(f3); + return this.negative !== 0 ? -a3 | 0 : a3; + }, o22.prototype.ucmp = function(f3) { + if (this.length > f3.length) + return 1; + if (this.length < f3.length) + return -1; + for (var a3 = 0, c2 = this.length - 1; c2 >= 0; c2--) { + var d5 = this.words[c2] | 0, g3 = f3.words[c2] | 0; + if (d5 !== g3) { + d5 < g3 ? a3 = -1 : d5 > g3 && (a3 = 1); + break; + } + } + return a3; + }, o22.prototype.gtn = function(f3) { + return this.cmpn(f3) === 1; + }, o22.prototype.gt = function(f3) { + return this.cmp(f3) === 1; + }, o22.prototype.gten = function(f3) { + return this.cmpn(f3) >= 0; + }, o22.prototype.gte = function(f3) { + return this.cmp(f3) >= 0; + }, o22.prototype.ltn = function(f3) { + return this.cmpn(f3) === -1; + }, o22.prototype.lt = function(f3) { + return this.cmp(f3) === -1; + }, o22.prototype.lten = function(f3) { + return this.cmpn(f3) <= 0; + }, o22.prototype.lte = function(f3) { + return this.cmp(f3) <= 0; + }, o22.prototype.eqn = function(f3) { + return this.cmpn(f3) === 0; + }, o22.prototype.eq = function(f3) { + return this.cmp(f3) === 0; + }, o22.red = function(f3) { + return new Y2(f3); + }, o22.prototype.toRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), i2(this.negative === 0, "red works only with positives"), f3.convertTo(this)._forceRed(f3); + }, o22.prototype.fromRed = function() { + return i2(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, o22.prototype._forceRed = function(f3) { + return this.red = f3, this; + }, o22.prototype.forceRed = function(f3) { + return i2(!this.red, "Already a number in reduction context"), this._forceRed(f3); + }, o22.prototype.redAdd = function(f3) { + return i2(this.red, "redAdd works only with red numbers"), this.red.add(this, f3); + }, o22.prototype.redIAdd = function(f3) { + return i2(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f3); + }, o22.prototype.redSub = function(f3) { + return i2(this.red, "redSub works only with red numbers"), this.red.sub(this, f3); + }, o22.prototype.redISub = function(f3) { + return i2(this.red, "redISub works only with red numbers"), this.red.isub(this, f3); + }, o22.prototype.redShl = function(f3) { + return i2(this.red, "redShl works only with red numbers"), this.red.shl(this, f3); + }, o22.prototype.redMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.mul(this, f3); + }, o22.prototype.redIMul = function(f3) { + return i2(this.red, "redMul works only with red numbers"), this.red._verify2(this, f3), this.red.imul(this, f3); + }, o22.prototype.redSqr = function() { + return i2(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, o22.prototype.redISqr = function() { + return i2(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, o22.prototype.redSqrt = function() { + return i2(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, o22.prototype.redInvm = function() { + return i2(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, o22.prototype.redNeg = function() { + return i2(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, o22.prototype.redPow = function(f3) { + return i2(this.red && !f3.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f3); + }; + var H22 = { k256: null, p224: null, p192: null, p25519: null }; + function z2(A2, f3) { + this.name = A2, this.p = new o22(f3, 16), this.n = this.p.bitLength(), this.k = new o22(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + z2.prototype._tmp = function() { + var f3 = new o22(null); + return f3.words = new Array(Math.ceil(this.n / 13)), f3; + }, z2.prototype.ireduce = function(f3) { + var a3 = f3, c2; + do + this.split(a3, this.tmp), a3 = this.imulK(a3), a3 = a3.iadd(this.tmp), c2 = a3.bitLength(); + while (c2 > this.n); + var d5 = c2 < this.n ? -1 : a3.ucmp(this.p); + return d5 === 0 ? (a3.words[0] = 0, a3.length = 1) : d5 > 0 ? a3.isub(this.p) : a3.strip !== void 0 ? a3.strip() : a3._strip(), a3; + }, z2.prototype.split = function(f3, a3) { + f3.iushrn(this.n, 0, a3); + }, z2.prototype.imulK = function(f3) { + return f3.imul(this.k); + }; + function Pt2() { + z2.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + n4(Pt2, z2), Pt2.prototype.split = function(f3, a3) { + for (var c2 = 4194303, d5 = Math.min(f3.length, 9), g3 = 0; g3 < d5; g3++) + a3.words[g3] = f3.words[g3]; + if (a3.length = d5, f3.length <= 9) { + f3.words[0] = 0, f3.length = 1; + return; + } + var x2 = f3.words[9]; + for (a3.words[a3.length++] = x2 & c2, g3 = 10; g3 < f3.length; g3++) { + var M2 = f3.words[g3] | 0; + f3.words[g3 - 10] = (M2 & c2) << 4 | x2 >>> 22, x2 = M2; + } + x2 >>>= 22, f3.words[g3 - 10] = x2, x2 === 0 && f3.length > 10 ? f3.length -= 10 : f3.length -= 9; + }, Pt2.prototype.imulK = function(f3) { + f3.words[f3.length] = 0, f3.words[f3.length + 1] = 0, f3.length += 2; + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = f3.words[c2] | 0; + a3 += d5 * 977, f3.words[c2] = a3 & 67108863, a3 = d5 * 64 + (a3 / 67108864 | 0); + } + return f3.words[f3.length - 1] === 0 && (f3.length--, f3.words[f3.length - 1] === 0 && f3.length--), f3; + }; + function W2() { + z2.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + n4(W2, z2); + function Rt2() { + z2.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + n4(Rt2, z2); + function Yt3() { + z2.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + n4(Yt3, z2), Yt3.prototype.imulK = function(f3) { + for (var a3 = 0, c2 = 0; c2 < f3.length; c2++) { + var d5 = (f3.words[c2] | 0) * 19 + a3, g3 = d5 & 67108863; + d5 >>>= 26, f3.words[c2] = g3, a3 = d5; + } + return a3 !== 0 && (f3.words[f3.length++] = a3), f3; + }, o22._prime = function(f3) { + if (H22[f3]) + return H22[f3]; + var a3; + if (f3 === "k256") + a3 = new Pt2(); + else if (f3 === "p224") + a3 = new W2(); + else if (f3 === "p192") + a3 = new Rt2(); + else if (f3 === "p25519") + a3 = new Yt3(); + else + throw new Error("Unknown prime " + f3); + return H22[f3] = a3, a3; + }; + function Y2(A2) { + if (typeof A2 == "string") { + var f3 = o22._prime(A2); + this.m = f3.p, this.prime = f3; + } else + i2(A2.gtn(1), "modulus must be greater than 1"), this.m = A2, this.prime = null; + } + Y2.prototype._verify1 = function(f3) { + i2(f3.negative === 0, "red works only with positives"), i2(f3.red, "red works only with red numbers"); + }, Y2.prototype._verify2 = function(f3, a3) { + i2((f3.negative | a3.negative) === 0, "red works only with positives"), i2(f3.red && f3.red === a3.red, "red works only with red numbers"); + }, Y2.prototype.imod = function(f3) { + return this.prime ? this.prime.ireduce(f3)._forceRed(this) : (w3(f3, f3.umod(this.m)._forceRed(this)), f3); + }, Y2.prototype.neg = function(f3) { + return f3.isZero() ? f3.clone() : this.m.sub(f3)._forceRed(this); + }, Y2.prototype.add = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.add(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2._forceRed(this); + }, Y2.prototype.iadd = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.iadd(a3); + return c2.cmp(this.m) >= 0 && c2.isub(this.m), c2; + }, Y2.prototype.sub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.sub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2._forceRed(this); + }, Y2.prototype.isub = function(f3, a3) { + this._verify2(f3, a3); + var c2 = f3.isub(a3); + return c2.cmpn(0) < 0 && c2.iadd(this.m), c2; + }, Y2.prototype.shl = function(f3, a3) { + return this._verify1(f3), this.imod(f3.ushln(a3)); + }, Y2.prototype.imul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.imul(a3)); + }, Y2.prototype.mul = function(f3, a3) { + return this._verify2(f3, a3), this.imod(f3.mul(a3)); + }, Y2.prototype.isqr = function(f3) { + return this.imul(f3, f3.clone()); + }, Y2.prototype.sqr = function(f3) { + return this.mul(f3, f3); + }, Y2.prototype.sqrt = function(f3) { + if (f3.isZero()) + return f3.clone(); + var a3 = this.m.andln(3); + if (i2(a3 % 2 === 1), a3 === 3) { + var c2 = this.m.add(new o22(1)).iushrn(2); + return this.pow(f3, c2); + } + for (var d5 = this.m.subn(1), g3 = 0; !d5.isZero() && d5.andln(1) === 0; ) + g3++, d5.iushrn(1); + i2(!d5.isZero()); + var x2 = new o22(1).toRed(this), M2 = x2.redNeg(), l2 = this.m.subn(1).iushrn(1), s22 = this.m.bitLength(); + for (s22 = new o22(2 * s22 * s22).toRed(this); this.pow(s22, l2).cmp(M2) !== 0; ) + s22.redIAdd(M2); + for (var v3 = this.pow(s22, d5), k2 = this.pow(f3, d5.addn(1).iushrn(1)), u3 = this.pow(f3, d5), E2 = g3; u3.cmp(x2) !== 0; ) { + for (var _3 = u3, B2 = 0; _3.cmp(x2) !== 0; B2++) + _3 = _3.redSqr(); + i2(B2 < E2); + var R2 = this.pow(v3, new o22(1).iushln(E2 - B2 - 1)); + k2 = k2.redMul(R2), v3 = R2.redSqr(), u3 = u3.redMul(v3), E2 = B2; + } + return k2; + }, Y2.prototype.invm = function(f3) { + var a3 = f3._invmp(this.m); + return a3.negative !== 0 ? (a3.negative = 0, this.imod(a3).redNeg()) : this.imod(a3); + }, Y2.prototype.pow = function(f3, a3) { + if (a3.isZero()) + return new o22(1).toRed(this); + if (a3.cmpn(1) === 0) + return f3.clone(); + var c2 = 4, d5 = new Array(1 << c2); + d5[0] = new o22(1).toRed(this), d5[1] = f3; + for (var g3 = 2; g3 < d5.length; g3++) + d5[g3] = this.mul(d5[g3 - 1], f3); + var x2 = d5[0], M2 = 0, l2 = 0, s22 = a3.bitLength() % 26; + for (s22 === 0 && (s22 = 26), g3 = a3.length - 1; g3 >= 0; g3--) { + for (var v3 = a3.words[g3], k2 = s22 - 1; k2 >= 0; k2--) { + var u3 = v3 >> k2 & 1; + if (x2 !== d5[0] && (x2 = this.sqr(x2)), u3 === 0 && M2 === 0) { + l2 = 0; + continue; } - }) - }; - } + M2 <<= 1, M2 |= u3, l2++, !(l2 !== c2 && (g3 !== 0 || k2 !== 0)) && (x2 = this.mul(x2, d5[M2]), l2 = 0, M2 = 0); + } + s22 = 26; + } + return x2; + }, Y2.prototype.convertTo = function(f3) { + var a3 = f3.umod(this.m); + return a3 === f3 ? a3.clone() : a3; + }, Y2.prototype.convertFrom = function(f3) { + var a3 = f3.clone(); + return a3.red = null, a3; + }, o22.mont = function(f3) { + return new Vt2(f3); + }; + function Vt2(A2) { + Y2.call(this, A2), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new o22(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); + } + n4(Vt2, Y2), Vt2.prototype.convertTo = function(f3) { + return this.imod(f3.ushln(this.shift)); + }, Vt2.prototype.convertFrom = function(f3) { + var a3 = this.imod(f3.mul(this.rinv)); + return a3.red = null, a3; + }, Vt2.prototype.imul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return f3.words[0] = 0, f3.length = 1, f3; + var c2 = f3.imul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.mul = function(f3, a3) { + if (f3.isZero() || a3.isZero()) + return new o22(0)._forceRed(this); + var c2 = f3.mul(a3), d5 = c2.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), g3 = c2.isub(d5).iushrn(this.shift), x2 = g3; + return g3.cmp(this.m) >= 0 ? x2 = g3.isub(this.m) : g3.cmpn(0) < 0 && (x2 = g3.iadd(this.m)), x2._forceRed(this); + }, Vt2.prototype.invm = function(f3) { + var a3 = this.imod(f3._invmp(this.m).mul(this.r2)); + return a3._forceRed(this); + }; + })(e2, On); + })(Ln); + var K2 = Ln.exports; + const jn = "bignumber/5.7.0"; + var Rr = K2.BN; + const Ae$2 = new L3(jn), wi = {}, Qn = 9007199254740991; + function C0(e2) { + return e2 != null && (V2.isBigNumber(e2) || typeof e2 == "number" && e2 % 1 === 0 || typeof e2 == "string" && !!e2.match(/^-?[0-9]+$/) || Qt$2(e2) || typeof e2 == "bigint" || ir$3(e2)); + } + let Jn = false; + class V2 { + constructor(t2, r3) { + t2 !== wi && Ae$2.throwError("cannot call constructor directly; use BigNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }), this._hex = r3, this._isBigNumber = true, Object.freeze(this); } - removeCatch() { - return this._def.innerType; + fromTwos(t2) { + return Lt$3(j(this).fromTwos(t2)); } - }; - ZodCatch$1.create = (type2, params) => { - return new ZodCatch$1({ - innerType: type2, - typeName: ZodFirstPartyTypeKind$1.ZodCatch, - catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, - ...processCreateParams$1(params) - }); - }; - let ZodNaN$1 = class ZodNaN extends ZodType$1 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== ZodParsedType$1.nan) { - const ctx = this._getOrReturnCtx(input); - addIssueToContext$1(ctx, { - code: ZodIssueCode$1.invalid_type, - expected: ZodParsedType$1.nan, - received: ctx.parsedType - }); - return INVALID$1; + toTwos(t2) { + return Lt$3(j(this).toTwos(t2)); + } + abs() { + return this._hex[0] === "-" ? V2.from(this._hex.substring(1)) : this; + } + add(t2) { + return Lt$3(j(this).add(j(t2))); + } + sub(t2) { + return Lt$3(j(this).sub(j(t2))); + } + div(t2) { + return V2.from(t2).isZero() && Wt2("division-by-zero", "div"), Lt$3(j(this).div(j(t2))); + } + mul(t2) { + return Lt$3(j(this).mul(j(t2))); + } + mod(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("division-by-zero", "mod"), Lt$3(j(this).umod(r3)); + } + pow(t2) { + const r3 = j(t2); + return r3.isNeg() && Wt2("negative-power", "pow"), Lt$3(j(this).pow(r3)); + } + and(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "and"), Lt$3(j(this).and(r3)); + } + or(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "or"), Lt$3(j(this).or(r3)); + } + xor(t2) { + const r3 = j(t2); + return (this.isNegative() || r3.isNeg()) && Wt2("unbound-bitwise-result", "xor"), Lt$3(j(this).xor(r3)); + } + mask(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "mask"), Lt$3(j(this).maskn(t2)); + } + shl(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shl"), Lt$3(j(this).shln(t2)); + } + shr(t2) { + return (this.isNegative() || t2 < 0) && Wt2("negative-width", "shr"), Lt$3(j(this).shrn(t2)); + } + eq(t2) { + return j(this).eq(j(t2)); + } + lt(t2) { + return j(this).lt(j(t2)); + } + lte(t2) { + return j(this).lte(j(t2)); + } + gt(t2) { + return j(this).gt(j(t2)); + } + gte(t2) { + return j(this).gte(j(t2)); + } + isNegative() { + return this._hex[0] === "-"; + } + isZero() { + return j(this).isZero(); + } + toNumber() { + try { + return j(this).toNumber(); + } catch { + Wt2("overflow", "toNumber", this.toString()); + } + return null; + } + toBigInt() { + try { + return BigInt(this.toString()); + } catch { + } + return Ae$2.throwError("this platform does not support BigInt", L3.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); + } + toString() { + return arguments.length > 0 && (arguments[0] === 10 ? Jn || (Jn = true, Ae$2.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")) : arguments[0] === 16 ? Ae$2.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", L3.errors.UNEXPECTED_ARGUMENT, {}) : Ae$2.throwError("BigNumber.toString does not accept parameters", L3.errors.UNEXPECTED_ARGUMENT, {})), j(this).toString(10); + } + toHexString() { + return this._hex; + } + toJSON(t2) { + return { type: "BigNumber", hex: this.toHexString() }; + } + static from(t2) { + if (t2 instanceof V2) + return t2; + if (typeof t2 == "string") + return t2.match(/^-?0x[0-9a-f]+$/i) ? new V2(wi, vr(t2)) : t2.match(/^-?[0-9]+$/) ? new V2(wi, vr(new Rr(t2))) : Ae$2.throwArgumentError("invalid BigNumber string", "value", t2); + if (typeof t2 == "number") + return t2 % 1 && Wt2("underflow", "BigNumber.from", t2), (t2 >= Qn || t2 <= -Qn) && Wt2("overflow", "BigNumber.from", t2), V2.from(String(t2)); + const r3 = t2; + if (typeof r3 == "bigint") + return V2.from(r3.toString()); + if (ir$3(r3)) + return V2.from(Kt$3(r3)); + if (r3) + if (r3.toHexString) { + const i2 = r3.toHexString(); + if (typeof i2 == "string") + return V2.from(i2); + } else { + let i2 = r3._hex; + if (i2 == null && r3.type === "BigNumber" && (i2 = r3.hex), typeof i2 == "string" && (Qt$2(i2) || i2[0] === "-" && Qt$2(i2.substring(1)))) + return V2.from(i2); + } + return Ae$2.throwArgumentError("invalid BigNumber value", "value", t2); + } + static isBigNumber(t2) { + return !!(t2 && t2._isBigNumber); + } + } + function vr(e2) { + if (typeof e2 != "string") + return vr(e2.toString(16)); + if (e2[0] === "-") + return e2 = e2.substring(1), e2[0] === "-" && Ae$2.throwArgumentError("invalid hex", "value", e2), e2 = vr(e2), e2 === "0x00" ? e2 : "-" + e2; + if (e2.substring(0, 2) !== "0x" && (e2 = "0x" + e2), e2 === "0x") + return "0x00"; + for (e2.length % 2 && (e2 = "0x0" + e2.substring(2)); e2.length > 4 && e2.substring(0, 4) === "0x00"; ) + e2 = "0x" + e2.substring(4); + return e2; + } + function Lt$3(e2) { + return V2.from(vr(e2)); + } + function j(e2) { + const t2 = V2.from(e2).toHexString(); + return t2[0] === "-" ? new Rr("-" + t2.substring(3), 16) : new Rr(t2.substring(2), 16); + } + function Wt2(e2, t2, r3) { + const i2 = { fault: e2, operation: t2 }; + return r3 != null && (i2.value = r3), Ae$2.throwError(e2, L3.errors.NUMERIC_FAULT, i2); + } + const Ht2 = new L3(jn), mr$3 = {}, Gn = V2.from(0), Yn = V2.from(-1); + function Vn(e2, t2, r3, i2) { + const n4 = { fault: t2, operation: r3 }; + return i2 !== void 0 && (n4.value = i2), Ht2.throwError(e2, L3.errors.NUMERIC_FAULT, n4); + } + let gr = "0"; + for (; gr.length < 256; ) + gr += gr; + function xi(e2) { + if (typeof e2 != "number") + try { + e2 = V2.from(e2).toNumber(); + } catch { } - return { status: "valid", value: input.data }; + return typeof e2 == "number" && e2 >= 0 && e2 <= 256 && !(e2 % 1) ? "1" + gr.substring(0, e2) : Ht2.throwArgumentError("invalid decimal size", "decimals", e2); + } + function Mi(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + e2 = V2.from(e2); + const i2 = e2.lt(Gn); + i2 && (e2 = e2.mul(Yn)); + let n4 = e2.mod(r3).toString(); + for (; n4.length < r3.length - 1; ) + n4 = "0" + n4; + n4 = n4.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + const o22 = e2.div(r3).toString(); + return r3.length === 1 ? e2 = o22 : e2 = o22 + "." + n4, i2 && (e2 = "-" + e2), e2; + } + function be(e2, t2) { + t2 == null && (t2 = 0); + const r3 = xi(t2); + (typeof e2 != "string" || !e2.match(/^-?[0-9.]+$/)) && Ht2.throwArgumentError("invalid decimal value", "value", e2); + const i2 = e2.substring(0, 1) === "-"; + i2 && (e2 = e2.substring(1)), e2 === "." && Ht2.throwArgumentError("missing value", "value", e2); + const n4 = e2.split("."); + n4.length > 2 && Ht2.throwArgumentError("too many decimal points", "value", e2); + let o22 = n4[0], h4 = n4[1]; + for (o22 || (o22 = "0"), h4 || (h4 = "0"); h4[h4.length - 1] === "0"; ) + h4 = h4.substring(0, h4.length - 1); + for (h4.length > r3.length - 1 && Vn("fractional component exceeds decimals", "underflow", "parseFixed"), h4 === "" && (h4 = "0"); h4.length < r3.length - 1; ) + h4 += "0"; + const p2 = V2.from(o22), b3 = V2.from(h4); + let m3 = p2.mul(r3).add(b3); + return i2 && (m3 = m3.mul(Yn)), m3; + } + class dr2 { + constructor(t2, r3, i2, n4) { + t2 !== mr$3 && Ht2.throwError("cannot use FixedFormat constructor; use FixedFormat.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.signed = r3, this.width = i2, this.decimals = n4, this.name = (r3 ? "" : "u") + "fixed" + String(i2) + "x" + String(n4), this._multiplier = xi(n4), Object.freeze(this); + } + static from(t2) { + if (t2 instanceof dr2) + return t2; + typeof t2 == "number" && (t2 = `fixed128x${t2}`); + let r3 = true, i2 = 128, n4 = 18; + if (typeof t2 == "string") { + if (t2 !== "fixed") + if (t2 === "ufixed") + r3 = false; + else { + const o22 = t2.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + o22 || Ht2.throwArgumentError("invalid fixed format", "format", t2), r3 = o22[1] !== "u", i2 = parseInt(o22[2]), n4 = parseInt(o22[3]); + } + } else if (t2) { + const o22 = (h4, p2, b3) => t2[h4] == null ? b3 : (typeof t2[h4] !== p2 && Ht2.throwArgumentError("invalid fixed format (" + h4 + " not " + p2 + ")", "format." + h4, t2[h4]), t2[h4]); + r3 = o22("signed", "boolean", r3), i2 = o22("width", "number", i2), n4 = o22("decimals", "number", n4); + } + return i2 % 8 && Ht2.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", i2), n4 > 80 && Ht2.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", n4), new dr2(mr$3, r3, i2, n4); + } + } + class Ut3 { + constructor(t2, r3, i2, n4) { + t2 !== mr$3 && Ht2.throwError("cannot use FixedNumber constructor; use FixedNumber.from", L3.errors.UNSUPPORTED_OPERATION, { operation: "new FixedFormat" }), this.format = n4, this._hex = r3, this._value = i2, this._isFixedNumber = true, Object.freeze(this); + } + _checkFormat(t2) { + this.format.name !== t2.format.name && Ht2.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", t2); + } + addUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.add(i2), this.format.decimals, this.format); + } + subUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.sub(i2), this.format.decimals, this.format); + } + mulUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(i2).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(t2) { + this._checkFormat(t2); + const r3 = be(this._value, this.format.decimals), i2 = be(t2._value, t2.format.decimals); + return Ut3.fromValue(r3.mul(this.format._multiplier).div(i2), this.format.decimals, this.format); + } + floor() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return this.isNegative() && i2 && (r3 = r3.subUnsafe(Wn.toFormat(r3.format))), r3; + } + ceiling() { + const t2 = this.toString().split("."); + t2.length === 1 && t2.push("0"); + let r3 = Ut3.from(t2[0], this.format); + const i2 = !t2[1].match(/^(0*)$/); + return !this.isNegative() && i2 && (r3 = r3.addUnsafe(Wn.toFormat(r3.format))), r3; + } + round(t2) { + t2 == null && (t2 = 0); + const r3 = this.toString().split("."); + if (r3.length === 1 && r3.push("0"), (t2 < 0 || t2 > 80 || t2 % 1) && Ht2.throwArgumentError("invalid decimal count", "decimals", t2), r3[1].length <= t2) + return this; + const i2 = Ut3.from("1" + gr.substring(0, t2), this.format), n4 = O0.toFormat(this.format); + return this.mulUnsafe(i2).addUnsafe(n4).floor().divUnsafe(i2); } - }; - ZodNaN$1.create = (params) => { - return new ZodNaN$1({ - typeName: ZodFirstPartyTypeKind$1.ZodNaN, - ...processCreateParams$1(params) + isZero() { + return this._value === "0.0" || this._value === "0"; + } + isNegative() { + return this._value[0] === "-"; + } + toString() { + return this._value; + } + toHexString(t2) { + if (t2 == null) + return this._hex; + t2 % 8 && Ht2.throwArgumentError("invalid byte width", "width", t2); + const r3 = V2.from(this._hex).fromTwos(this.format.width).toTwos(t2).toHexString(); + return oe(r3, t2 / 8); + } + toUnsafeFloat() { + return parseFloat(this.toString()); + } + toFormat(t2) { + return Ut3.fromString(this._value, t2); + } + static fromValue(t2, r3, i2) { + return i2 == null && r3 != null && !C0(r3) && (i2 = r3, r3 = null), r3 == null && (r3 = 0), i2 == null && (i2 = "fixed"), Ut3.fromString(Mi(t2, r3), dr2.from(i2)); + } + static fromString(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3), n4 = be(t2, i2.decimals); + !i2.signed && n4.lt(Gn) && Vn("unsigned value cannot be negative", "overflow", "value", t2); + let o22 = null; + i2.signed ? o22 = n4.toTwos(i2.width).toHexString() : (o22 = n4.toHexString(), o22 = oe(o22, i2.width / 8)); + const h4 = Mi(n4, i2.decimals); + return new Ut3(mr$3, o22, h4, i2); + } + static fromBytes(t2, r3) { + r3 == null && (r3 = "fixed"); + const i2 = dr2.from(r3); + if (Ot2(t2).length > i2.width / 8) + throw new Error("overflow"); + let n4 = V2.from(t2); + i2.signed && (n4 = n4.fromTwos(i2.width)); + const o22 = n4.toTwos((i2.signed ? 0 : 1) + i2.width).toHexString(), h4 = Mi(n4, i2.decimals); + return new Ut3(mr$3, o22, h4, i2); + } + static from(t2, r3) { + if (typeof t2 == "string") + return Ut3.fromString(t2, r3); + if (ir$3(t2)) + return Ut3.fromBytes(t2, r3); + try { + return Ut3.fromValue(t2, 0, r3); + } catch (i2) { + if (i2.code !== L3.errors.INVALID_ARGUMENT) + throw i2; + } + return Ht2.throwArgumentError("invalid FixedNumber value", "value", t2); + } + static isFixedNumber(t2) { + return !!(t2 && t2._isFixedNumber); + } + } + const Wn = Ut3.from(1), O0 = Ut3.from("0.5"); + var Or; + (function(e2) { + e2.current = "", e2.NFC = "NFC", e2.NFD = "NFD", e2.NFKC = "NFKC", e2.NFKD = "NFKD"; + })(Or || (Or = {})); + var nr$3; + (function(e2) { + e2.UNEXPECTED_CONTINUE = "unexpected continuation byte", e2.BAD_PREFIX = "bad codepoint prefix", e2.OVERRUN = "string overrun", e2.MISSING_CONTINUE = "missing continuation byte", e2.OUT_OF_RANGE = "out of UTF-8 range", e2.UTF16_SURROGATE = "UTF-16 surrogate", e2.OVERLONG = "overlong representation"; + })(nr$3 || (nr$3 = {})); + function T0(e2) { + if (e2.length % 4 !== 0) + throw new Error("bad data"); + let t2 = []; + for (let r3 = 0; r3 < e2.length; r3 += 4) + t2.push(parseInt(e2.substring(r3, r3 + 4), 16)); + return t2; + } + function Si(e2, t2) { + t2 || (t2 = function(n4) { + return [parseInt(n4, 16)]; }); - }; - const BRAND$1 = Symbol("zod_brand"); - let ZodBranded$1 = class ZodBranded extends ZodType$1 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const data2 = ctx.data; - return this._def.type._parse({ - data: data2, - path: ctx.path, - parent: ctx + let r3 = 0, i2 = {}; + return e2.split(",").forEach((n4) => { + let o22 = n4.split(":"); + r3 += parseInt(o22[0], 16), i2[r3] = t2(o22[1]); + }), i2; + } + function $n(e2) { + let t2 = 0; + return e2.split(",").map((r3) => { + let i2 = r3.split("-"); + i2.length === 1 ? i2[1] = "0" : i2[1] === "" && (i2[1] = "1"); + let n4 = t2 + parseInt(i2[0], 16); + return t2 = parseInt(i2[1], 16), { l: n4, h: t2 }; + }); + } + $n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"), "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((e2) => parseInt(e2, 16)), Si("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"), Si("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"), Si("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", T0), $n("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); + function U0(e2) { + e2 = atob(e2); + const t2 = []; + for (let r3 = 0; r3 < e2.length; r3++) + t2.push(e2.charCodeAt(r3)); + return Ot2(t2); + } + function ef(e2, t2) { + t2 == null && (t2 = 1); + const r3 = [], i2 = r3.forEach, n4 = function(o22, h4) { + i2.call(o22, function(p2) { + h4 > 0 && Array.isArray(p2) ? n4(p2, h4 - 1) : r3.push(p2); }); + }; + return n4(e2, t2), r3; + } + function k0(e2) { + const t2 = {}; + for (let r3 = 0; r3 < e2.length; r3++) { + const i2 = e2[r3]; + t2[i2[0]] = i2[1]; } - unwrap() { - return this._def.type; - } - }; - let ZodPipeline$1 = class ZodPipeline2 extends ZodType$1 { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.common.async) { - const handleAsync = async () => { - const inResult = await this._def.in._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID$1; - if (inResult.status === "dirty") { - status.dirty(); - return DIRTY$1(inResult.value); - } else { - return this._def.out._parseAsync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - }; - return handleAsync(); - } else { - const inResult = this._def.in._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return INVALID$1; - if (inResult.status === "dirty") { - status.dirty(); - return { - status: "dirty", - value: inResult.value - }; - } else { - return this._def.out._parseSync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } + return t2; + } + function q0(e2) { + let t2 = 0; + function r3() { + return e2[t2++] << 8 | e2[t2++]; + } + let i2 = r3(), n4 = 1, o22 = [0, 1]; + for (let H22 = 1; H22 < i2; H22++) + o22.push(n4 += r3()); + let h4 = r3(), p2 = t2; + t2 += h4; + let b3 = 0, m3 = 0; + function w3() { + return b3 == 0 && (m3 = m3 << 8 | e2[t2++], b3 = 8), m3 >> --b3 & 1; + } + const y3 = 31, S2 = Math.pow(2, y3), I2 = S2 >>> 1, N22 = I2 >> 1, C2 = S2 - 1; + let F2 = 0; + for (let H22 = 0; H22 < y3; H22++) + F2 = F2 << 1 | w3(); + let U2 = [], J2 = 0, Bt2 = S2; + for (; ; ) { + let H22 = Math.floor(((F2 - J2 + 1) * n4 - 1) / Bt2), z2 = 0, Pt2 = i2; + for (; Pt2 - z2 > 1; ) { + let Yt3 = z2 + Pt2 >>> 1; + H22 < o22[Yt3] ? Pt2 = Yt3 : z2 = Yt3; + } + if (z2 == 0) + break; + U2.push(z2); + let W2 = J2 + Math.floor(Bt2 * o22[z2] / n4), Rt2 = J2 + Math.floor(Bt2 * o22[z2 + 1] / n4) - 1; + for (; !((W2 ^ Rt2) & I2); ) + F2 = F2 << 1 & C2 | w3(), W2 = W2 << 1 & C2, Rt2 = Rt2 << 1 & C2 | 1; + for (; W2 & ~Rt2 & N22; ) + F2 = F2 & I2 | F2 << 1 & C2 >>> 1 | w3(), W2 = W2 << 1 ^ I2, Rt2 = (Rt2 ^ I2) << 1 | I2 | 1; + J2 = W2, Bt2 = 1 + Rt2 - W2; + } + let G2 = i2 - 4; + return U2.map((H22) => { + switch (H22 - G2) { + case 3: + return G2 + 65792 + (e2[p2++] << 16 | e2[p2++] << 8 | e2[p2++]); + case 2: + return G2 + 256 + (e2[p2++] << 8 | e2[p2++]); + case 1: + return G2 + e2[p2++]; + default: + return H22 - 1; } + }); + } + function K0(e2) { + let t2 = 0; + return () => e2[t2++]; + } + function H0(e2) { + return K0(q0(e2)); + } + function z0(e2) { + return e2 & 1 ? ~e2 >> 1 : e2 >> 1; + } + function L0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0; i2 < e2; i2++) + r3[i2] = 1 + t2(); + return r3; + } + function rf(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = -1; i2 < e2; i2++) + r3[i2] = n4 += 1 + t2(); + return r3; + } + function j0(e2, t2) { + let r3 = Array(e2); + for (let i2 = 0, n4 = 0; i2 < e2; i2++) + r3[i2] = n4 += z0(t2()); + return r3; + } + function Pr(e2, t2) { + let r3 = rf(e2(), e2), i2 = e2(), n4 = rf(i2, e2), o22 = L0(i2, e2); + for (let h4 = 0; h4 < i2; h4++) + for (let p2 = 0; p2 < o22[h4]; p2++) + r3.push(n4[h4] + p2); + return t2 ? r3.map((h4) => t2[h4]) : r3; + } + function Q0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(G0(r3, e2)); } - static create(a3, b3) { - return new ZodPipeline2({ - in: a3, - out: b3, - typeName: ZodFirstPartyTypeKind$1.ZodPipeline + for (; ; ) { + let r3 = e2() - 1; + if (r3 < 0) + break; + t2.push(Y0(r3, e2)); + } + return k0(ef(t2)); + } + function J0(e2) { + let t2 = []; + for (; ; ) { + let r3 = e2(); + if (r3 == 0) + break; + t2.push(r3); + } + return t2; + } + function nf(e2, t2, r3) { + let i2 = Array(e2).fill(void 0).map(() => []); + for (let n4 = 0; n4 < t2; n4++) + j0(e2, r3).forEach((o22, h4) => i2[h4].push(o22)); + return i2; + } + function G0(e2, t2) { + let r3 = 1 + t2(), i2 = t2(), n4 = J0(t2), o22 = nf(n4.length, 1 + e2, t2); + return ef(o22.map((h4, p2) => { + const b3 = h4[0], m3 = h4.slice(1); + return Array(n4[p2]).fill(void 0).map((w3, y3) => { + let S2 = y3 * i2; + return [b3 + y3 * r3, m3.map((I2) => I2 + S2)]; }); + })); + } + function Y0(e2, t2) { + let r3 = 1 + t2(); + return nf(r3, 1 + e2, t2).map((n4) => [n4[0], n4.slice(1)]); + } + function V0(e2) { + let t2 = Pr(e2).sort((i2, n4) => i2 - n4); + return r3(); + function r3() { + let i2 = []; + for (; ; ) { + let m3 = Pr(e2, t2); + if (m3.length == 0) + break; + i2.push({ set: new Set(m3), node: r3() }); + } + i2.sort((m3, w3) => w3.set.size - m3.set.size); + let n4 = e2(), o22 = n4 % 3; + n4 = n4 / 3 | 0; + let h4 = !!(n4 & 1); + n4 >>= 1; + let p2 = n4 == 1, b3 = n4 == 2; + return { branches: i2, valid: o22, fe0f: h4, save: p2, check: b3 }; + } + } + function W0() { + return H0(U0("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")); + } + const Dr = W0(); + new Set(Pr(Dr)), new Set(Pr(Dr)), Q0(Dr), V0(Dr); + const X0 = new Uint8Array(32); + X0.fill(0); + const os = new Uint8Array(32); + os.fill(0), V2.from(-1); + const ss3 = V2.from(0), as = V2.from(1); + V2.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), oe(as.toHexString(), 32), oe(ss3.toHexString(), 32); + var se$4 = {}, Q = {}, yr = af; + function af(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); + } + af.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); + }; + var Ii = { exports: {} }; + typeof Object.create == "function" ? Ii.exports = function(t2, r3) { + r3 && (t2.super_ = r3, t2.prototype = Object.create(r3.prototype, { constructor: { value: t2, enumerable: false, writable: true, configurable: true } })); + } : Ii.exports = function(t2, r3) { + if (r3) { + t2.super_ = r3; + var i2 = function() { + }; + i2.prototype = r3.prototype, t2.prototype = new i2(), t2.prototype.constructor = t2; } }; - const custom$1 = (check, params = {}, fatal) => { - if (check) - return ZodAny$1.create().superRefine((data2, ctx) => { - var _a, _b; - if (!check(data2)) { - const p3 = typeof params === "function" ? params(data2) : params; - const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p3 === "string" ? { message: p3 } : p3; - ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); + var us = yr, hs = Ii.exports; + Q.inherits = hs; + function cs(e2, t2) { + return (e2.charCodeAt(t2) & 64512) !== 55296 || t2 < 0 || t2 + 1 >= e2.length ? false : (e2.charCodeAt(t2 + 1) & 64512) === 56320; + } + function ls(e2, t2) { + if (Array.isArray(e2)) + return e2.slice(); + if (!e2) + return []; + var r3 = []; + if (typeof e2 == "string") + if (t2) { + if (t2 === "hex") + for (e2 = e2.replace(/[^a-z0-9]+/ig, ""), e2.length % 2 !== 0 && (e2 = "0" + e2), n4 = 0; n4 < e2.length; n4 += 2) + r3.push(parseInt(e2[n4] + e2[n4 + 1], 16)); + } else + for (var i2 = 0, n4 = 0; n4 < e2.length; n4++) { + var o22 = e2.charCodeAt(n4); + o22 < 128 ? r3[i2++] = o22 : o22 < 2048 ? (r3[i2++] = o22 >> 6 | 192, r3[i2++] = o22 & 63 | 128) : cs(e2, n4) ? (o22 = 65536 + ((o22 & 1023) << 10) + (e2.charCodeAt(++n4) & 1023), r3[i2++] = o22 >> 18 | 240, r3[i2++] = o22 >> 12 & 63 | 128, r3[i2++] = o22 >> 6 & 63 | 128, r3[i2++] = o22 & 63 | 128) : (r3[i2++] = o22 >> 12 | 224, r3[i2++] = o22 >> 6 & 63 | 128, r3[i2++] = o22 & 63 | 128); } - }); - return ZodAny$1.create(); - }; - const late$1 = { - object: ZodObject$1.lazycreate + else + for (n4 = 0; n4 < e2.length; n4++) + r3[n4] = e2[n4] | 0; + return r3; + } + Q.toArray = ls; + function ds(e2) { + for (var t2 = "", r3 = 0; r3 < e2.length; r3++) + t2 += hf(e2[r3].toString(16)); + return t2; + } + Q.toHex = ds; + function uf(e2) { + var t2 = e2 >>> 24 | e2 >>> 8 & 65280 | e2 << 8 & 16711680 | (e2 & 255) << 24; + return t2 >>> 0; + } + Q.htonl = uf; + function ps(e2, t2) { + for (var r3 = "", i2 = 0; i2 < e2.length; i2++) { + var n4 = e2[i2]; + t2 === "little" && (n4 = uf(n4)), r3 += cf(n4.toString(16)); + } + return r3; + } + Q.toHex32 = ps; + function hf(e2) { + return e2.length === 1 ? "0" + e2 : e2; + } + Q.zero2 = hf; + function cf(e2) { + return e2.length === 7 ? "0" + e2 : e2.length === 6 ? "00" + e2 : e2.length === 5 ? "000" + e2 : e2.length === 4 ? "0000" + e2 : e2.length === 3 ? "00000" + e2 : e2.length === 2 ? "000000" + e2 : e2.length === 1 ? "0000000" + e2 : e2; + } + Q.zero8 = cf; + function vs(e2, t2, r3, i2) { + var n4 = r3 - t2; + us(n4 % 4 === 0); + for (var o22 = new Array(n4 / 4), h4 = 0, p2 = t2; h4 < o22.length; h4++, p2 += 4) { + var b3; + i2 === "big" ? b3 = e2[p2] << 24 | e2[p2 + 1] << 16 | e2[p2 + 2] << 8 | e2[p2 + 3] : b3 = e2[p2 + 3] << 24 | e2[p2 + 2] << 16 | e2[p2 + 1] << 8 | e2[p2], o22[h4] = b3 >>> 0; + } + return o22; + } + Q.join32 = vs; + function ms$1(e2, t2) { + for (var r3 = new Array(e2.length * 4), i2 = 0, n4 = 0; i2 < e2.length; i2++, n4 += 4) { + var o22 = e2[i2]; + t2 === "big" ? (r3[n4] = o22 >>> 24, r3[n4 + 1] = o22 >>> 16 & 255, r3[n4 + 2] = o22 >>> 8 & 255, r3[n4 + 3] = o22 & 255) : (r3[n4 + 3] = o22 >>> 24, r3[n4 + 2] = o22 >>> 16 & 255, r3[n4 + 1] = o22 >>> 8 & 255, r3[n4] = o22 & 255); + } + return r3; + } + Q.split32 = ms$1; + function gs(e2, t2) { + return e2 >>> t2 | e2 << 32 - t2; + } + Q.rotr32 = gs; + function As(e2, t2) { + return e2 << t2 | e2 >>> 32 - t2; + } + Q.rotl32 = As; + function bs(e2, t2) { + return e2 + t2 >>> 0; + } + Q.sum32 = bs; + function ys(e2, t2, r3) { + return e2 + t2 + r3 >>> 0; + } + Q.sum32_3 = ys; + function ws(e2, t2, r3, i2) { + return e2 + t2 + r3 + i2 >>> 0; + } + Q.sum32_4 = ws; + function xs(e2, t2, r3, i2, n4) { + return e2 + t2 + r3 + i2 + n4 >>> 0; + } + Q.sum32_5 = xs; + function Ms(e2, t2, r3, i2) { + var n4 = e2[t2], o22 = e2[t2 + 1], h4 = i2 + o22 >>> 0, p2 = (h4 < i2 ? 1 : 0) + r3 + n4; + e2[t2] = p2 >>> 0, e2[t2 + 1] = h4; + } + Q.sum64 = Ms; + function Es(e2, t2, r3, i2) { + var n4 = t2 + i2 >>> 0, o22 = (n4 < t2 ? 1 : 0) + e2 + r3; + return o22 >>> 0; + } + Q.sum64_hi = Es; + function Ss(e2, t2, r3, i2) { + var n4 = t2 + i2; + return n4 >>> 0; + } + Q.sum64_lo = Ss; + function Ns(e2, t2, r3, i2, n4, o22, h4, p2) { + var b3 = 0, m3 = t2; + m3 = m3 + i2 >>> 0, b3 += m3 < t2 ? 1 : 0, m3 = m3 + o22 >>> 0, b3 += m3 < o22 ? 1 : 0, m3 = m3 + p2 >>> 0, b3 += m3 < p2 ? 1 : 0; + var w3 = e2 + r3 + n4 + h4 + b3; + return w3 >>> 0; + } + Q.sum64_4_hi = Ns; + function Is(e2, t2, r3, i2, n4, o22, h4, p2) { + var b3 = t2 + i2 + o22 + p2; + return b3 >>> 0; + } + Q.sum64_4_lo = Is; + function _s(e2, t2, r3, i2, n4, o22, h4, p2, b3, m3) { + var w3 = 0, y3 = t2; + y3 = y3 + i2 >>> 0, w3 += y3 < t2 ? 1 : 0, y3 = y3 + o22 >>> 0, w3 += y3 < o22 ? 1 : 0, y3 = y3 + p2 >>> 0, w3 += y3 < p2 ? 1 : 0, y3 = y3 + m3 >>> 0, w3 += y3 < m3 ? 1 : 0; + var S2 = e2 + r3 + n4 + h4 + b3 + w3; + return S2 >>> 0; + } + Q.sum64_5_hi = _s; + function Bs(e2, t2, r3, i2, n4, o22, h4, p2, b3, m3) { + var w3 = t2 + i2 + o22 + p2 + m3; + return w3 >>> 0; + } + Q.sum64_5_lo = Bs; + function Cs(e2, t2, r3) { + var i2 = t2 << 32 - r3 | e2 >>> r3; + return i2 >>> 0; + } + Q.rotr64_hi = Cs; + function Rs(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; + } + Q.rotr64_lo = Rs; + function Os(e2, t2, r3) { + return e2 >>> r3; + } + Q.shr64_hi = Os; + function Ps(e2, t2, r3) { + var i2 = e2 << 32 - r3 | t2 >>> r3; + return i2 >>> 0; + } + Q.shr64_lo = Ps; + var fr = {}, lf = Q, Ds = yr; + function Fr() { + 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; + } + fr.BlockHash = Fr, Fr.prototype.update = function(t2, r3) { + if (t2 = lf.toArray(t2, r3), this.pending ? this.pending = this.pending.concat(t2) : this.pending = t2, this.pendingTotal += t2.length, this.pending.length >= this._delta8) { + t2 = this.pending; + var i2 = t2.length % this._delta8; + this.pending = t2.slice(t2.length - i2, t2.length), this.pending.length === 0 && (this.pending = null), t2 = lf.join32(t2, 0, t2.length - i2, this.endian); + for (var n4 = 0; n4 < t2.length; n4 += this._delta32) + this._update(t2, n4, n4 + this._delta32); + } + return this; + }, Fr.prototype.digest = function(t2) { + return this.update(this._pad()), Ds(this.pending === null), this._digest(t2); + }, Fr.prototype._pad = function() { + var t2 = this.pendingTotal, r3 = this._delta8, i2 = r3 - (t2 + this.padLength) % r3, n4 = new Array(i2 + this.padLength); + n4[0] = 128; + for (var o22 = 1; o22 < i2; o22++) + n4[o22] = 0; + if (t2 <<= 3, this.endian === "big") { + for (var h4 = 8; h4 < this.padLength; h4++) + n4[o22++] = 0; + n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = t2 >>> 24 & 255, n4[o22++] = t2 >>> 16 & 255, n4[o22++] = t2 >>> 8 & 255, n4[o22++] = t2 & 255; + } else + for (n4[o22++] = t2 & 255, n4[o22++] = t2 >>> 8 & 255, n4[o22++] = t2 >>> 16 & 255, n4[o22++] = t2 >>> 24 & 255, n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = 0, n4[o22++] = 0, h4 = 8; h4 < this.padLength; h4++) + n4[o22++] = 0; + return n4; + }; + var or = {}, ae$2 = {}, Fs = Q, ue = Fs.rotr32; + function Ts(e2, t2, r3, i2) { + if (e2 === 0) + return df(t2, r3, i2); + if (e2 === 1 || e2 === 3) + return vf(t2, r3, i2); + if (e2 === 2) + return pf(t2, r3, i2); + } + ae$2.ft_1 = Ts; + function df(e2, t2, r3) { + return e2 & t2 ^ ~e2 & r3; + } + ae$2.ch32 = df; + function pf(e2, t2, r3) { + return e2 & t2 ^ e2 & r3 ^ t2 & r3; + } + ae$2.maj32 = pf; + function vf(e2, t2, r3) { + return e2 ^ t2 ^ r3; + } + ae$2.p32 = vf; + function Us(e2) { + return ue(e2, 2) ^ ue(e2, 13) ^ ue(e2, 22); + } + ae$2.s0_256 = Us; + function ks(e2) { + return ue(e2, 6) ^ ue(e2, 11) ^ ue(e2, 25); + } + ae$2.s1_256 = ks; + function qs(e2) { + return ue(e2, 7) ^ ue(e2, 18) ^ e2 >>> 3; + } + ae$2.g0_256 = qs; + function Ks(e2) { + return ue(e2, 17) ^ ue(e2, 19) ^ e2 >>> 10; + } + ae$2.g1_256 = Ks; + var sr$3 = Q, Hs = fr, zs = ae$2, _i = sr$3.rotl32, wr$2 = sr$3.sum32, Ls = sr$3.sum32_5, js = zs.ft_1, mf = Hs.BlockHash, Qs = [1518500249, 1859775393, 2400959708, 3395469782]; + function he$2() { + if (!(this instanceof he$2)) + return new he$2(); + mf.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); + } + sr$3.inherits(he$2, mf); + var Js = he$2; + he$2.blockSize = 512, he$2.outSize = 160, he$2.hmacStrength = 80, he$2.padLength = 64, he$2.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = _i(i2[n4 - 3] ^ i2[n4 - 8] ^ i2[n4 - 14] ^ i2[n4 - 16], 1); + var o22 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4]; + for (n4 = 0; n4 < i2.length; n4++) { + var w3 = ~~(n4 / 20), y3 = Ls(_i(o22, 5), js(w3, h4, p2, b3), m3, i2[n4], Qs[w3]); + m3 = b3, b3 = p2, p2 = _i(h4, 30), h4 = o22, o22 = y3; + } + this.h[0] = wr$2(this.h[0], o22), this.h[1] = wr$2(this.h[1], h4), this.h[2] = wr$2(this.h[2], p2), this.h[3] = wr$2(this.h[3], b3), this.h[4] = wr$2(this.h[4], m3); + }, he$2.prototype._digest = function(t2) { + return t2 === "hex" ? sr$3.toHex32(this.h, "big") : sr$3.split32(this.h, "big"); + }; + var ar2 = Q, Gs = fr, ur = ae$2, Ys = yr, ie2 = ar2.sum32, Vs = ar2.sum32_4, Ws = ar2.sum32_5, Xs = ur.ch32, Zs = ur.maj32, $s = ur.s0_256, ta = ur.s1_256, ea = ur.g0_256, ra = ur.g1_256, gf = Gs.BlockHash, ia = [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 ce$2() { + if (!(this instanceof ce$2)) + return new ce$2(); + gf.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = ia, this.W = new Array(64); + } + ar2.inherits(ce$2, gf); + var Af = ce$2; + ce$2.blockSize = 512, ce$2.outSize = 256, ce$2.hmacStrength = 192, ce$2.padLength = 64, ce$2.prototype._update = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 16; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4++) + i2[n4] = Vs(ra(i2[n4 - 2]), i2[n4 - 7], ea(i2[n4 - 15]), i2[n4 - 16]); + var o22 = this.h[0], h4 = this.h[1], p2 = this.h[2], b3 = this.h[3], m3 = this.h[4], w3 = this.h[5], y3 = this.h[6], S2 = this.h[7]; + for (Ys(this.k.length === i2.length), n4 = 0; n4 < i2.length; n4++) { + var I2 = Ws(S2, ta(m3), Xs(m3, w3, y3), this.k[n4], i2[n4]), N22 = ie2($s(o22), Zs(o22, h4, p2)); + S2 = y3, y3 = w3, w3 = m3, m3 = ie2(b3, I2), b3 = p2, p2 = h4, h4 = o22, o22 = ie2(I2, N22); + } + this.h[0] = ie2(this.h[0], o22), this.h[1] = ie2(this.h[1], h4), this.h[2] = ie2(this.h[2], p2), this.h[3] = ie2(this.h[3], b3), this.h[4] = ie2(this.h[4], m3), this.h[5] = ie2(this.h[5], w3), this.h[6] = ie2(this.h[6], y3), this.h[7] = ie2(this.h[7], S2); + }, ce$2.prototype._digest = function(t2) { + return t2 === "hex" ? ar2.toHex32(this.h, "big") : ar2.split32(this.h, "big"); + }; + var Bi = Q, bf = Af; + function ye$3() { + if (!(this instanceof ye$3)) + return new ye$3(); + bf.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; + } + Bi.inherits(ye$3, bf); + var na = ye$3; + ye$3.blockSize = 512, ye$3.outSize = 224, ye$3.hmacStrength = 192, ye$3.padLength = 64, ye$3.prototype._digest = function(t2) { + return t2 === "hex" ? Bi.toHex32(this.h.slice(0, 7), "big") : Bi.split32(this.h.slice(0, 7), "big"); + }; + var jt2 = Q, fa = fr, oa = yr, le$2 = jt2.rotr64_hi, de$3 = jt2.rotr64_lo, yf = jt2.shr64_hi, wf = jt2.shr64_lo, Be$4 = jt2.sum64, Ci = jt2.sum64_hi, Ri = jt2.sum64_lo, sa = jt2.sum64_4_hi, aa = jt2.sum64_4_lo, ua = jt2.sum64_5_hi, ha = jt2.sum64_5_lo, xf = fa.BlockHash, ca = [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 ne2() { + if (!(this instanceof ne2)) + return new ne2(); + xf.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = ca, this.W = new Array(160); + } + jt2.inherits(ne2, xf); + var Mf = ne2; + ne2.blockSize = 1024, ne2.outSize = 512, ne2.hmacStrength = 192, ne2.padLength = 128, ne2.prototype._prepareBlock = function(t2, r3) { + for (var i2 = this.W, n4 = 0; n4 < 32; n4++) + i2[n4] = t2[r3 + n4]; + for (; n4 < i2.length; n4 += 2) { + var o22 = xa(i2[n4 - 4], i2[n4 - 3]), h4 = Ma(i2[n4 - 4], i2[n4 - 3]), p2 = i2[n4 - 14], b3 = i2[n4 - 13], m3 = ya(i2[n4 - 30], i2[n4 - 29]), w3 = wa(i2[n4 - 30], i2[n4 - 29]), y3 = i2[n4 - 32], S2 = i2[n4 - 31]; + i2[n4] = sa(o22, h4, p2, b3, m3, w3, y3, S2), i2[n4 + 1] = aa(o22, h4, p2, b3, m3, w3, y3, S2); + } + }, ne2.prototype._update = function(t2, r3) { + this._prepareBlock(t2, r3); + var i2 = this.W, n4 = this.h[0], o22 = this.h[1], h4 = this.h[2], p2 = this.h[3], b3 = this.h[4], m3 = this.h[5], w3 = this.h[6], y3 = this.h[7], S2 = this.h[8], I2 = this.h[9], N22 = this.h[10], C2 = this.h[11], F2 = this.h[12], U2 = this.h[13], J2 = this.h[14], Bt2 = this.h[15]; + oa(this.k.length === i2.length); + for (var G2 = 0; G2 < i2.length; G2 += 2) { + var H22 = J2, z2 = Bt2, Pt2 = Aa(S2, I2), W2 = ba(S2, I2), Rt2 = la(S2, I2, N22, C2, F2), Yt3 = da(S2, I2, N22, C2, F2, U2), Y2 = this.k[G2], Vt2 = this.k[G2 + 1], A2 = i2[G2], f3 = i2[G2 + 1], a3 = ua(H22, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3), c2 = ha(H22, z2, Pt2, W2, Rt2, Yt3, Y2, Vt2, A2, f3); + H22 = ma(n4, o22), z2 = ga(n4, o22), Pt2 = pa(n4, o22, h4, p2, b3), W2 = va(n4, o22, h4, p2, b3, m3); + var d5 = Ci(H22, z2, Pt2, W2), g3 = Ri(H22, z2, Pt2, W2); + J2 = F2, Bt2 = U2, F2 = N22, U2 = C2, N22 = S2, C2 = I2, S2 = Ci(w3, y3, a3, c2), I2 = Ri(y3, y3, a3, c2), w3 = b3, y3 = m3, b3 = h4, m3 = p2, h4 = n4, p2 = o22, n4 = Ci(a3, c2, d5, g3), o22 = Ri(a3, c2, d5, g3); + } + Be$4(this.h, 0, n4, o22), Be$4(this.h, 2, h4, p2), Be$4(this.h, 4, b3, m3), Be$4(this.h, 6, w3, y3), Be$4(this.h, 8, S2, I2), Be$4(this.h, 10, N22, C2), Be$4(this.h, 12, F2, U2), Be$4(this.h, 14, J2, Bt2); + }, ne2.prototype._digest = function(t2) { + return t2 === "hex" ? jt2.toHex32(this.h, "big") : jt2.split32(this.h, "big"); + }; + function la(e2, t2, r3, i2, n4) { + var o22 = e2 & r3 ^ ~e2 & n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function da(e2, t2, r3, i2, n4, o22) { + var h4 = t2 & i2 ^ ~t2 & o22; + return h4 < 0 && (h4 += 4294967296), h4; + } + function pa(e2, t2, r3, i2, n4) { + var o22 = e2 & r3 ^ e2 & n4 ^ r3 & n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function va(e2, t2, r3, i2, n4, o22) { + var h4 = t2 & i2 ^ t2 & o22 ^ i2 & o22; + return h4 < 0 && (h4 += 4294967296), h4; + } + function ma(e2, t2) { + var r3 = le$2(e2, t2, 28), i2 = le$2(t2, e2, 2), n4 = le$2(t2, e2, 7), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function ga(e2, t2) { + var r3 = de$3(e2, t2, 28), i2 = de$3(t2, e2, 2), n4 = de$3(t2, e2, 7), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function Aa(e2, t2) { + var r3 = le$2(e2, t2, 14), i2 = le$2(e2, t2, 18), n4 = le$2(t2, e2, 9), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function ba(e2, t2) { + var r3 = de$3(e2, t2, 14), i2 = de$3(e2, t2, 18), n4 = de$3(t2, e2, 9), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function ya(e2, t2) { + var r3 = le$2(e2, t2, 1), i2 = le$2(e2, t2, 8), n4 = yf(e2, t2, 7), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function wa(e2, t2) { + var r3 = de$3(e2, t2, 1), i2 = de$3(e2, t2, 8), n4 = wf(e2, t2, 7), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function xa(e2, t2) { + var r3 = le$2(e2, t2, 19), i2 = le$2(t2, e2, 29), n4 = yf(e2, t2, 6), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + function Ma(e2, t2) { + var r3 = de$3(e2, t2, 19), i2 = de$3(t2, e2, 29), n4 = wf(e2, t2, 6), o22 = r3 ^ i2 ^ n4; + return o22 < 0 && (o22 += 4294967296), o22; + } + var Oi = Q, Ef = Mf; + function we$2() { + if (!(this instanceof we$2)) + return new we$2(); + Ef.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; + } + Oi.inherits(we$2, Ef); + var Ea = we$2; + we$2.blockSize = 1024, we$2.outSize = 384, we$2.hmacStrength = 192, we$2.padLength = 128, we$2.prototype._digest = function(t2) { + return t2 === "hex" ? Oi.toHex32(this.h.slice(0, 12), "big") : Oi.split32(this.h.slice(0, 12), "big"); + }, or.sha1 = Js, or.sha224 = na, or.sha256 = Af, or.sha384 = Ea, or.sha512 = Mf; + var Sf = {}, Xe = Q, Sa = fr, Tr = Xe.rotl32, Nf = Xe.sum32, xr = Xe.sum32_3, If = Xe.sum32_4, _f = Sa.BlockHash; + function pe$3() { + if (!(this instanceof pe$3)) + return new pe$3(); + _f.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; + } + Xe.inherits(pe$3, _f), Sf.ripemd160 = pe$3, pe$3.blockSize = 512, pe$3.outSize = 160, pe$3.hmacStrength = 192, pe$3.padLength = 64, pe$3.prototype._update = function(t2, r3) { + for (var i2 = this.h[0], n4 = this.h[1], o22 = this.h[2], h4 = this.h[3], p2 = this.h[4], b3 = i2, m3 = n4, w3 = o22, y3 = h4, S2 = p2, I2 = 0; I2 < 80; I2++) { + var N22 = Nf(Tr(If(i2, Bf(I2, n4, o22, h4), t2[_a[I2] + r3], Na(I2)), Ca[I2]), p2); + i2 = p2, p2 = h4, h4 = Tr(o22, 10), o22 = n4, n4 = N22, N22 = Nf(Tr(If(b3, Bf(79 - I2, m3, w3, y3), t2[Ba[I2] + r3], Ia(I2)), Ra[I2]), S2), b3 = S2, S2 = y3, y3 = Tr(w3, 10), w3 = m3, m3 = N22; + } + N22 = xr(this.h[1], o22, y3), this.h[1] = xr(this.h[2], h4, S2), this.h[2] = xr(this.h[3], p2, b3), this.h[3] = xr(this.h[4], i2, m3), this.h[4] = xr(this.h[0], n4, w3), this.h[0] = N22; + }, pe$3.prototype._digest = function(t2) { + return t2 === "hex" ? Xe.toHex32(this.h, "little") : Xe.split32(this.h, "little"); + }; + function Bf(e2, t2, r3, i2) { + return e2 <= 15 ? t2 ^ r3 ^ i2 : e2 <= 31 ? t2 & r3 | ~t2 & i2 : e2 <= 47 ? (t2 | ~r3) ^ i2 : e2 <= 63 ? t2 & i2 | r3 & ~i2 : t2 ^ (r3 | ~i2); + } + function Na(e2) { + return e2 <= 15 ? 0 : e2 <= 31 ? 1518500249 : e2 <= 47 ? 1859775393 : e2 <= 63 ? 2400959708 : 2840853838; + } + function Ia(e2) { + return e2 <= 15 ? 1352829926 : e2 <= 31 ? 1548603684 : e2 <= 47 ? 1836072691 : e2 <= 63 ? 2053994217 : 0; + } + var _a = [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], Ba = [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], Ca = [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], Ra = [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], Oa = Q, Pa = yr; + function hr2(e2, t2, r3) { + if (!(this instanceof hr2)) + return new hr2(e2, t2, r3); + this.Hash = e2, this.blockSize = e2.blockSize / 8, this.outSize = e2.outSize / 8, this.inner = null, this.outer = null, this._init(Oa.toArray(t2, r3)); + } + var Da = hr2; + hr2.prototype._init = function(t2) { + t2.length > this.blockSize && (t2 = new this.Hash().update(t2).digest()), Pa(t2.length <= this.blockSize); + for (var r3 = t2.length; r3 < this.blockSize; r3++) + t2.push(0); + for (r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 54; + for (this.inner = new this.Hash().update(t2), r3 = 0; r3 < t2.length; r3++) + t2[r3] ^= 106; + this.outer = new this.Hash().update(t2); + }, hr2.prototype.update = function(t2, r3) { + return this.inner.update(t2, r3), this; + }, hr2.prototype.digest = function(t2) { + return this.outer.update(this.inner.digest()), this.outer.digest(t2); + }, function(e2) { + var t2 = e2; + t2.utils = Q, t2.common = fr, t2.sha = or, t2.ripemd = Sf, t2.hmac = Da, t2.sha1 = t2.sha.sha1, t2.sha256 = t2.sha.sha256, t2.sha224 = t2.sha.sha224, t2.sha384 = t2.sha.sha384, t2.sha512 = t2.sha.sha512, t2.ripemd160 = t2.ripemd.ripemd160; + }(se$4); + function cr$3(e2, t2, r3) { + return r3 = { path: t2, exports: {}, require: function(i2, n4) { + return Fa(i2, n4 ?? r3.path); + } }, e2(r3, r3.exports), r3.exports; + } + function Fa() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); + } + var Pi = Cf; + function Cf(e2, t2) { + if (!e2) + throw new Error(t2 || "Assertion failed"); + } + Cf.equal = function(t2, r3, i2) { + if (t2 != r3) + throw new Error(i2 || "Assertion failed: " + t2 + " != " + r3); + }; + var fe$3 = cr$3(function(e2, t2) { + var r3 = t2; + function i2(h4, p2) { + if (Array.isArray(h4)) + return h4.slice(); + if (!h4) + return []; + var b3 = []; + if (typeof h4 != "string") { + for (var m3 = 0; m3 < h4.length; m3++) + b3[m3] = h4[m3] | 0; + return b3; + } + if (p2 === "hex") { + h4 = h4.replace(/[^a-z0-9]+/ig, ""), h4.length % 2 !== 0 && (h4 = "0" + h4); + for (var m3 = 0; m3 < h4.length; m3 += 2) + b3.push(parseInt(h4[m3] + h4[m3 + 1], 16)); + } else + for (var m3 = 0; m3 < h4.length; m3++) { + var w3 = h4.charCodeAt(m3), y3 = w3 >> 8, S2 = w3 & 255; + y3 ? b3.push(y3, S2) : b3.push(S2); + } + return b3; + } + r3.toArray = i2; + function n4(h4) { + return h4.length === 1 ? "0" + h4 : h4; + } + r3.zero2 = n4; + function o22(h4) { + for (var p2 = "", b3 = 0; b3 < h4.length; b3++) + p2 += n4(h4[b3].toString(16)); + return p2; + } + r3.toHex = o22, r3.encode = function(p2, b3) { + return b3 === "hex" ? o22(p2) : p2; + }; + }), Jt$4 = cr$3(function(e2, t2) { + var r3 = t2; + r3.assert = Pi, r3.toArray = fe$3.toArray, r3.zero2 = fe$3.zero2, r3.toHex = fe$3.toHex, r3.encode = fe$3.encode; + function i2(b3, m3, w3) { + var y3 = new Array(Math.max(b3.bitLength(), w3) + 1); + y3.fill(0); + for (var S2 = 1 << m3 + 1, I2 = b3.clone(), N22 = 0; N22 < y3.length; N22++) { + var C2, F2 = I2.andln(S2 - 1); + I2.isOdd() ? (F2 > (S2 >> 1) - 1 ? C2 = (S2 >> 1) - F2 : C2 = F2, I2.isubn(C2)) : C2 = 0, y3[N22] = C2, I2.iushrn(1); + } + return y3; + } + r3.getNAF = i2; + function n4(b3, m3) { + var w3 = [[], []]; + b3 = b3.clone(), m3 = m3.clone(); + for (var y3 = 0, S2 = 0, I2; b3.cmpn(-y3) > 0 || m3.cmpn(-S2) > 0; ) { + var N22 = b3.andln(3) + y3 & 3, C2 = m3.andln(3) + S2 & 3; + N22 === 3 && (N22 = -1), C2 === 3 && (C2 = -1); + var F2; + N22 & 1 ? (I2 = b3.andln(7) + y3 & 7, (I2 === 3 || I2 === 5) && C2 === 2 ? F2 = -N22 : F2 = N22) : F2 = 0, w3[0].push(F2); + var U2; + C2 & 1 ? (I2 = m3.andln(7) + S2 & 7, (I2 === 3 || I2 === 5) && N22 === 2 ? U2 = -C2 : U2 = C2) : U2 = 0, w3[1].push(U2), 2 * y3 === F2 + 1 && (y3 = 1 - y3), 2 * S2 === U2 + 1 && (S2 = 1 - S2), b3.iushrn(1), m3.iushrn(1); + } + return w3; + } + r3.getJSF = n4; + function o22(b3, m3, w3) { + var y3 = "_" + m3; + b3.prototype[m3] = function() { + return this[y3] !== void 0 ? this[y3] : this[y3] = w3.call(this); + }; + } + r3.cachedProperty = o22; + function h4(b3) { + return typeof b3 == "string" ? r3.toArray(b3, "hex") : b3; + } + r3.parseBytes = h4; + function p2(b3) { + return new K2(b3, "hex", "le"); + } + r3.intFromLE = p2; + }), Ur = Jt$4.getNAF, Ta = Jt$4.getJSF, kr = Jt$4.assert; + function Ce$2(e2, t2) { + this.type = e2, this.p = new K2(t2.p, 16), this.red = t2.prime ? K2.red(t2.prime) : K2.mont(this.p), this.zero = new K2(0).toRed(this.red), this.one = new K2(1).toRed(this.red), this.two = new K2(2).toRed(this.red), this.n = t2.n && new K2(t2.n, 16), this.g = t2.g && this.pointFromJSON(t2.g, t2.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 r3 = this.n && this.p.div(this.n); + !r3 || r3.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); + } + var Ze$3 = Ce$2; + Ce$2.prototype.point = function() { + throw new Error("Not implemented"); + }, Ce$2.prototype.validate = function() { + throw new Error("Not implemented"); + }, Ce$2.prototype._fixedNafMul = function(t2, r3) { + kr(t2.precomputed); + var i2 = t2._getDoubles(), n4 = Ur(r3, 1, this._bitLength), o22 = (1 << i2.step + 1) - (i2.step % 2 === 0 ? 2 : 1); + o22 /= 3; + var h4 = [], p2, b3; + for (p2 = 0; p2 < n4.length; p2 += i2.step) { + b3 = 0; + for (var m3 = p2 + i2.step - 1; m3 >= p2; m3--) + b3 = (b3 << 1) + n4[m3]; + h4.push(b3); + } + for (var w3 = this.jpoint(null, null, null), y3 = this.jpoint(null, null, null), S2 = o22; S2 > 0; S2--) { + for (p2 = 0; p2 < h4.length; p2++) + b3 = h4[p2], b3 === S2 ? y3 = y3.mixedAdd(i2.points[p2]) : b3 === -S2 && (y3 = y3.mixedAdd(i2.points[p2].neg())); + w3 = w3.add(y3); + } + return w3.toP(); + }, Ce$2.prototype._wnafMul = function(t2, r3) { + var i2 = 4, n4 = t2._getNAFPoints(i2); + i2 = n4.wnd; + for (var o22 = n4.points, h4 = Ur(r3, i2, this._bitLength), p2 = this.jpoint(null, null, null), b3 = h4.length - 1; b3 >= 0; b3--) { + for (var m3 = 0; b3 >= 0 && h4[b3] === 0; b3--) + m3++; + if (b3 >= 0 && m3++, p2 = p2.dblp(m3), b3 < 0) + break; + var w3 = h4[b3]; + kr(w3 !== 0), t2.type === "affine" ? w3 > 0 ? p2 = p2.mixedAdd(o22[w3 - 1 >> 1]) : p2 = p2.mixedAdd(o22[-w3 - 1 >> 1].neg()) : w3 > 0 ? p2 = p2.add(o22[w3 - 1 >> 1]) : p2 = p2.add(o22[-w3 - 1 >> 1].neg()); + } + return t2.type === "affine" ? p2.toP() : p2; + }, Ce$2.prototype._wnafMulAdd = function(t2, r3, i2, n4, o22) { + var h4 = this._wnafT1, p2 = this._wnafT2, b3 = this._wnafT3, m3 = 0, w3, y3, S2; + for (w3 = 0; w3 < n4; w3++) { + S2 = r3[w3]; + var I2 = S2._getNAFPoints(t2); + h4[w3] = I2.wnd, p2[w3] = I2.points; + } + for (w3 = n4 - 1; w3 >= 1; w3 -= 2) { + var N22 = w3 - 1, C2 = w3; + if (h4[N22] !== 1 || h4[C2] !== 1) { + b3[N22] = Ur(i2[N22], h4[N22], this._bitLength), b3[C2] = Ur(i2[C2], h4[C2], this._bitLength), m3 = Math.max(b3[N22].length, m3), m3 = Math.max(b3[C2].length, m3); + continue; + } + var F2 = [r3[N22], null, null, r3[C2]]; + r3[N22].y.cmp(r3[C2].y) === 0 ? (F2[1] = r3[N22].add(r3[C2]), F2[2] = r3[N22].toJ().mixedAdd(r3[C2].neg())) : r3[N22].y.cmp(r3[C2].y.redNeg()) === 0 ? (F2[1] = r3[N22].toJ().mixedAdd(r3[C2]), F2[2] = r3[N22].add(r3[C2].neg())) : (F2[1] = r3[N22].toJ().mixedAdd(r3[C2]), F2[2] = r3[N22].toJ().mixedAdd(r3[C2].neg())); + var U2 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], J2 = Ta(i2[N22], i2[C2]); + for (m3 = Math.max(J2[0].length, m3), b3[N22] = new Array(m3), b3[C2] = new Array(m3), y3 = 0; y3 < m3; y3++) { + var Bt2 = J2[0][y3] | 0, G2 = J2[1][y3] | 0; + b3[N22][y3] = U2[(Bt2 + 1) * 3 + (G2 + 1)], b3[C2][y3] = 0, p2[N22] = F2; + } + } + var H22 = this.jpoint(null, null, null), z2 = this._wnafT4; + for (w3 = m3; w3 >= 0; w3--) { + for (var Pt2 = 0; w3 >= 0; ) { + var W2 = true; + for (y3 = 0; y3 < n4; y3++) + z2[y3] = b3[y3][w3] | 0, z2[y3] !== 0 && (W2 = false); + if (!W2) + break; + Pt2++, w3--; + } + if (w3 >= 0 && Pt2++, H22 = H22.dblp(Pt2), w3 < 0) + break; + for (y3 = 0; y3 < n4; y3++) { + var Rt2 = z2[y3]; + Rt2 !== 0 && (Rt2 > 0 ? S2 = p2[y3][Rt2 - 1 >> 1] : Rt2 < 0 && (S2 = p2[y3][-Rt2 - 1 >> 1].neg()), S2.type === "affine" ? H22 = H22.mixedAdd(S2) : H22 = H22.add(S2)); + } + } + for (w3 = 0; w3 < n4; w3++) + p2[w3] = null; + return o22 ? H22 : H22.toP(); + }; + function Xt$4(e2, t2) { + this.curve = e2, this.type = t2, this.precomputed = null; + } + Ce$2.BasePoint = Xt$4, Xt$4.prototype.eq = function() { + throw new Error("Not implemented"); + }, Xt$4.prototype.validate = function() { + return this.curve.validate(this); + }, Ce$2.prototype.decodePoint = function(t2, r3) { + t2 = Jt$4.toArray(t2, r3); + var i2 = this.p.byteLength(); + if ((t2[0] === 4 || t2[0] === 6 || t2[0] === 7) && t2.length - 1 === 2 * i2) { + t2[0] === 6 ? kr(t2[t2.length - 1] % 2 === 0) : t2[0] === 7 && kr(t2[t2.length - 1] % 2 === 1); + var n4 = this.point(t2.slice(1, 1 + i2), t2.slice(1 + i2, 1 + 2 * i2)); + return n4; + } else if ((t2[0] === 2 || t2[0] === 3) && t2.length - 1 === i2) + return this.pointFromX(t2.slice(1, 1 + i2), t2[0] === 3); + throw new Error("Unknown point format"); + }, Xt$4.prototype.encodeCompressed = function(t2) { + return this.encode(t2, true); + }, Xt$4.prototype._encode = function(t2) { + var r3 = this.curve.p.byteLength(), i2 = this.getX().toArray("be", r3); + return t2 ? [this.getY().isEven() ? 2 : 3].concat(i2) : [4].concat(i2, this.getY().toArray("be", r3)); + }, Xt$4.prototype.encode = function(t2, r3) { + return Jt$4.encode(this._encode(r3), t2); + }, Xt$4.prototype.precompute = function(t2) { + if (this.precomputed) + return this; + var r3 = { doubles: null, naf: null, beta: null }; + return r3.naf = this._getNAFPoints(8), r3.doubles = this._getDoubles(4, t2), r3.beta = this._getBeta(), this.precomputed = r3, this; + }, Xt$4.prototype._hasDoubles = function(t2) { + if (!this.precomputed) + return false; + var r3 = this.precomputed.doubles; + return r3 ? r3.points.length >= Math.ceil((t2.bitLength() + 1) / r3.step) : false; + }, Xt$4.prototype._getDoubles = function(t2, r3) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var i2 = [this], n4 = this, o22 = 0; o22 < r3; o22 += t2) { + for (var h4 = 0; h4 < t2; h4++) + n4 = n4.dbl(); + i2.push(n4); + } + return { step: t2, points: i2 }; + }, Xt$4.prototype._getNAFPoints = function(t2) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r3 = [this], i2 = (1 << t2) - 1, n4 = i2 === 1 ? null : this.dbl(), o22 = 1; o22 < i2; o22++) + r3[o22] = r3[o22 - 1].add(n4); + return { wnd: t2, points: r3 }; + }, Xt$4.prototype._getBeta = function() { + return null; + }, Xt$4.prototype.dblp = function(t2) { + for (var r3 = this, i2 = 0; i2 < t2; i2++) + r3 = r3.dbl(); + return r3; + }; + var Di = cr$3(function(e2) { + typeof Object.create == "function" ? e2.exports = function(r3, i2) { + i2 && (r3.super_ = i2, r3.prototype = Object.create(i2.prototype, { constructor: { value: r3, enumerable: false, writable: true, configurable: true } })); + } : e2.exports = function(r3, i2) { + if (i2) { + r3.super_ = i2; + var n4 = function() { + }; + n4.prototype = i2.prototype, r3.prototype = new n4(), r3.prototype.constructor = r3; + } + }; + }), Ua = Jt$4.assert; + function Zt2(e2) { + Ze$3.call(this, "short", e2), this.a = new K2(e2.a, 16).toRed(this.red), this.b = new K2(e2.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(e2), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); + } + Di(Zt2, Ze$3); + var ka = Zt2; + Zt2.prototype._getEndomorphism = function(t2) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r3, i2; + if (t2.beta) + r3 = new K2(t2.beta, 16).toRed(this.red); + else { + var n4 = this._getEndoRoots(this.p); + r3 = n4[0].cmp(n4[1]) < 0 ? n4[0] : n4[1], r3 = r3.toRed(this.red); + } + if (t2.lambda) + i2 = new K2(t2.lambda, 16); + else { + var o22 = this._getEndoRoots(this.n); + this.g.mul(o22[0]).x.cmp(this.g.x.redMul(r3)) === 0 ? i2 = o22[0] : (i2 = o22[1], Ua(this.g.mul(i2).x.cmp(this.g.x.redMul(r3)) === 0)); + } + var h4; + return t2.basis ? h4 = t2.basis.map(function(p2) { + return { a: new K2(p2.a, 16), b: new K2(p2.b, 16) }; + }) : h4 = this._getEndoBasis(i2), { beta: r3, lambda: i2, basis: h4 }; + } + }, Zt2.prototype._getEndoRoots = function(t2) { + var r3 = t2 === this.p ? this.red : K2.mont(t2), i2 = new K2(2).toRed(r3).redInvm(), n4 = i2.redNeg(), o22 = new K2(3).toRed(r3).redNeg().redSqrt().redMul(i2), h4 = n4.redAdd(o22).fromRed(), p2 = n4.redSub(o22).fromRed(); + return [h4, p2]; + }, Zt2.prototype._getEndoBasis = function(t2) { + for (var r3 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), i2 = t2, n4 = this.n.clone(), o22 = new K2(1), h4 = new K2(0), p2 = new K2(0), b3 = new K2(1), m3, w3, y3, S2, I2, N22, C2, F2 = 0, U2, J2; i2.cmpn(0) !== 0; ) { + var Bt2 = n4.div(i2); + U2 = n4.sub(Bt2.mul(i2)), J2 = p2.sub(Bt2.mul(o22)); + var G2 = b3.sub(Bt2.mul(h4)); + if (!y3 && U2.cmp(r3) < 0) + m3 = C2.neg(), w3 = o22, y3 = U2.neg(), S2 = J2; + else if (y3 && ++F2 === 2) + break; + C2 = U2, n4 = i2, i2 = U2, p2 = o22, o22 = J2, b3 = h4, h4 = G2; + } + I2 = U2.neg(), N22 = J2; + var H22 = y3.sqr().add(S2.sqr()), z2 = I2.sqr().add(N22.sqr()); + return z2.cmp(H22) >= 0 && (I2 = m3, N22 = w3), y3.negative && (y3 = y3.neg(), S2 = S2.neg()), I2.negative && (I2 = I2.neg(), N22 = N22.neg()), [{ a: y3, b: S2 }, { a: I2, b: N22 }]; + }, Zt2.prototype._endoSplit = function(t2) { + var r3 = this.endo.basis, i2 = r3[0], n4 = r3[1], o22 = n4.b.mul(t2).divRound(this.n), h4 = i2.b.neg().mul(t2).divRound(this.n), p2 = o22.mul(i2.a), b3 = h4.mul(n4.a), m3 = o22.mul(i2.b), w3 = h4.mul(n4.b), y3 = t2.sub(p2).sub(b3), S2 = m3.add(w3).neg(); + return { k1: y3, k2: S2 }; + }, Zt2.prototype.pointFromX = function(t2, r3) { + t2 = new K2(t2, 16), t2.red || (t2 = t2.toRed(this.red)); + var i2 = t2.redSqr().redMul(t2).redIAdd(t2.redMul(this.a)).redIAdd(this.b), n4 = i2.redSqrt(); + if (n4.redSqr().redSub(i2).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var o22 = n4.fromRed().isOdd(); + return (r3 && !o22 || !r3 && o22) && (n4 = n4.redNeg()), this.point(t2, n4); + }, Zt2.prototype.validate = function(t2) { + if (t2.inf) + return true; + var r3 = t2.x, i2 = t2.y, n4 = this.a.redMul(r3), o22 = r3.redSqr().redMul(r3).redIAdd(n4).redIAdd(this.b); + return i2.redSqr().redISub(o22).cmpn(0) === 0; + }, Zt2.prototype._endoWnafMulAdd = function(t2, r3, i2) { + for (var n4 = this._endoWnafT1, o22 = this._endoWnafT2, h4 = 0; h4 < t2.length; h4++) { + var p2 = this._endoSplit(r3[h4]), b3 = t2[h4], m3 = b3._getBeta(); + p2.k1.negative && (p2.k1.ineg(), b3 = b3.neg(true)), p2.k2.negative && (p2.k2.ineg(), m3 = m3.neg(true)), n4[h4 * 2] = b3, n4[h4 * 2 + 1] = m3, o22[h4 * 2] = p2.k1, o22[h4 * 2 + 1] = p2.k2; + } + for (var w3 = this._wnafMulAdd(1, n4, o22, h4 * 2, i2), y3 = 0; y3 < h4 * 2; y3++) + n4[y3] = null, o22[y3] = null; + return w3; }; - var ZodFirstPartyTypeKind$1; - (function(ZodFirstPartyTypeKind2) { - ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; - ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; - ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; - ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; - ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; - ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; - ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; - ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; - ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; - ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; - ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; - ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; - ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; - ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; - ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; - ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; - ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; - ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; - ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; - ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; - ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; - ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; - ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; - ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; - ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; - ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; - ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; - ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; - ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; - ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; - ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; - ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; - ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; - ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; - ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; - })(ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {})); - const instanceOfType$1 = (cls, params = { - message: `Input not instance of ${cls.name}` - }) => custom$1((data2) => data2 instanceof cls, params); - const stringType$1 = ZodString$1.create; - const numberType$1 = ZodNumber$1.create; - const nanType$1 = ZodNaN$1.create; - const bigIntType$1 = ZodBigInt$1.create; - const booleanType$1 = ZodBoolean$1.create; - const dateType$1 = ZodDate$1.create; - const symbolType$1 = ZodSymbol$1.create; - const undefinedType$1 = ZodUndefined$1.create; - const nullType$1 = ZodNull$1.create; - const anyType$1 = ZodAny$1.create; - const unknownType$1 = ZodUnknown$1.create; - const neverType$1 = ZodNever$1.create; - const voidType$1 = ZodVoid$1.create; - const arrayType$1 = ZodArray$1.create; - const objectType$1 = ZodObject$1.create; - const strictObjectType$1 = ZodObject$1.strictCreate; - const unionType$1 = ZodUnion$1.create; - const discriminatedUnionType$1 = ZodDiscriminatedUnion$1.create; - const intersectionType$1 = ZodIntersection$1.create; - const tupleType$1 = ZodTuple$1.create; - const recordType$1 = ZodRecord$1.create; - const mapType$1 = ZodMap$1.create; - const setType$1 = ZodSet$1.create; - const functionType$1 = ZodFunction$1.create; - const lazyType$1 = ZodLazy$1.create; - const literalType$1 = ZodLiteral$1.create; - const enumType$1 = ZodEnum$1.create; - const nativeEnumType$1 = ZodNativeEnum$1.create; - const promiseType$1 = ZodPromise$1.create; - const effectsType$1 = ZodEffects$1.create; - const optionalType$1 = ZodOptional$1.create; - const nullableType$1 = ZodNullable$1.create; - const preprocessType$1 = ZodEffects$1.createWithPreprocess; - const pipelineType$1 = ZodPipeline$1.create; - const ostring$1 = () => stringType$1().optional(); - const onumber$1 = () => numberType$1().optional(); - const oboolean$1 = () => booleanType$1().optional(); - const coerce$2 = { - string: (arg) => ZodString$1.create({ ...arg, coerce: true }), - number: (arg) => ZodNumber$1.create({ ...arg, coerce: true }), - boolean: (arg) => ZodBoolean$1.create({ - ...arg, - coerce: true - }), - bigint: (arg) => ZodBigInt$1.create({ ...arg, coerce: true }), - date: (arg) => ZodDate$1.create({ ...arg, coerce: true }) + function Ft$3(e2, t2, r3, i2) { + Ze$3.BasePoint.call(this, e2, "affine"), t2 === null && r3 === null ? (this.x = null, this.y = null, this.inf = true) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), i2 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); + } + Di(Ft$3, Ze$3.BasePoint), Zt2.prototype.point = function(t2, r3, i2) { + return new Ft$3(this, t2, r3, i2); + }, Zt2.prototype.pointFromJSON = function(t2, r3) { + return Ft$3.fromJSON(this, t2, r3); + }, Ft$3.prototype._getBeta = function() { + if (this.curve.endo) { + var t2 = this.precomputed; + if (t2 && t2.beta) + return t2.beta; + var r3 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (t2) { + var i2 = this.curve, n4 = function(o22) { + return i2.point(o22.x.redMul(i2.endo.beta), o22.y); + }; + t2.beta = r3, r3.precomputed = { beta: null, naf: t2.naf && { wnd: t2.naf.wnd, points: t2.naf.points.map(n4) }, doubles: t2.doubles && { step: t2.doubles.step, points: t2.doubles.points.map(n4) } }; + } + return r3; + } + }, Ft$3.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; + }, Ft$3.fromJSON = function(t2, r3, i2) { + typeof r3 == "string" && (r3 = JSON.parse(r3)); + var n4 = t2.point(r3[0], r3[1], i2); + if (!r3[2]) + return n4; + function o22(p2) { + return t2.point(p2[0], p2[1], i2); + } + var h4 = r3[2]; + return n4.precomputed = { beta: null, doubles: h4.doubles && { step: h4.doubles.step, points: [n4].concat(h4.doubles.points.map(o22)) }, naf: h4.naf && { wnd: h4.naf.wnd, points: [n4].concat(h4.naf.points.map(o22)) } }, n4; + }, Ft$3.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, Ft$3.prototype.isInfinity = function() { + return this.inf; + }, Ft$3.prototype.add = function(t2) { + if (this.inf) + return t2; + if (t2.inf) + return this; + if (this.eq(t2)) + return this.dbl(); + if (this.neg().eq(t2)) + return this.curve.point(null, null); + if (this.x.cmp(t2.x) === 0) + return this.curve.point(null, null); + var r3 = this.y.redSub(t2.y); + r3.cmpn(0) !== 0 && (r3 = r3.redMul(this.x.redSub(t2.x).redInvm())); + var i2 = r3.redSqr().redISub(this.x).redISub(t2.x), n4 = r3.redMul(this.x.redSub(i2)).redISub(this.y); + return this.curve.point(i2, n4); + }, Ft$3.prototype.dbl = function() { + if (this.inf) + return this; + var t2 = this.y.redAdd(this.y); + if (t2.cmpn(0) === 0) + return this.curve.point(null, null); + var r3 = this.curve.a, i2 = this.x.redSqr(), n4 = t2.redInvm(), o22 = i2.redAdd(i2).redIAdd(i2).redIAdd(r3).redMul(n4), h4 = o22.redSqr().redISub(this.x.redAdd(this.x)), p2 = o22.redMul(this.x.redSub(h4)).redISub(this.y); + return this.curve.point(h4, p2); + }, Ft$3.prototype.getX = function() { + return this.x.fromRed(); + }, Ft$3.prototype.getY = function() { + return this.y.fromRed(); + }, Ft$3.prototype.mul = function(t2) { + return t2 = new K2(t2, 16), this.isInfinity() ? this : this._hasDoubles(t2) ? this.curve._fixedNafMul(this, t2) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [t2]) : this.curve._wnafMul(this, t2); + }, Ft$3.prototype.mulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o22 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o22) : this.curve._wnafMulAdd(1, n4, o22, 2); + }, Ft$3.prototype.jmulAdd = function(t2, r3, i2) { + var n4 = [this, r3], o22 = [t2, i2]; + return this.curve.endo ? this.curve._endoWnafMulAdd(n4, o22, true) : this.curve._wnafMulAdd(1, n4, o22, 2, true); + }, Ft$3.prototype.eq = function(t2) { + return this === t2 || this.inf === t2.inf && (this.inf || this.x.cmp(t2.x) === 0 && this.y.cmp(t2.y) === 0); + }, Ft$3.prototype.neg = function(t2) { + if (this.inf) + return this; + var r3 = this.curve.point(this.x, this.y.redNeg()); + if (t2 && this.precomputed) { + var i2 = this.precomputed, n4 = function(o22) { + return o22.neg(); + }; + r3.precomputed = { naf: i2.naf && { wnd: i2.naf.wnd, points: i2.naf.points.map(n4) }, doubles: i2.doubles && { step: i2.doubles.step, points: i2.doubles.points.map(n4) } }; + } + return r3; + }, Ft$3.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var t2 = this.curve.jpoint(this.x, this.y, this.curve.one); + return t2; }; - const NEVER$1 = INVALID$1; - var z2 = /* @__PURE__ */ Object.freeze({ - __proto__: null, - defaultErrorMap: errorMap$1, - setErrorMap: setErrorMap$1, - getErrorMap: getErrorMap$1, - makeIssue: makeIssue$1, - EMPTY_PATH: EMPTY_PATH$1, - addIssueToContext: addIssueToContext$1, - ParseStatus: ParseStatus$1, - INVALID: INVALID$1, - DIRTY: DIRTY$1, - OK: OK$1, - isAborted: isAborted$1, - isDirty: isDirty$1, - isValid: isValid$1, - isAsync: isAsync$1, - get util() { - return util$1; - }, - get objectUtil() { - return objectUtil$1; - }, - ZodParsedType: ZodParsedType$1, - getParsedType: getParsedType$1, - ZodType: ZodType$1, - ZodString: ZodString$1, - ZodNumber: ZodNumber$1, - ZodBigInt: ZodBigInt$1, - ZodBoolean: ZodBoolean$1, - ZodDate: ZodDate$1, - ZodSymbol: ZodSymbol$1, - ZodUndefined: ZodUndefined$1, - ZodNull: ZodNull$1, - ZodAny: ZodAny$1, - ZodUnknown: ZodUnknown$1, - ZodNever: ZodNever$1, - ZodVoid: ZodVoid$1, - ZodArray: ZodArray$1, - ZodObject: ZodObject$1, - ZodUnion: ZodUnion$1, - ZodDiscriminatedUnion: ZodDiscriminatedUnion$1, - ZodIntersection: ZodIntersection$1, - ZodTuple: ZodTuple$1, - ZodRecord: ZodRecord$1, - ZodMap: ZodMap$1, - ZodSet: ZodSet$1, - ZodFunction: ZodFunction$1, - ZodLazy: ZodLazy$1, - ZodLiteral: ZodLiteral$1, - ZodEnum: ZodEnum$1, - ZodNativeEnum: ZodNativeEnum$1, - ZodPromise: ZodPromise$1, - ZodEffects: ZodEffects$1, - ZodTransformer: ZodEffects$1, - ZodOptional: ZodOptional$1, - ZodNullable: ZodNullable$1, - ZodDefault: ZodDefault$1, - ZodCatch: ZodCatch$1, - ZodNaN: ZodNaN$1, - BRAND: BRAND$1, - ZodBranded: ZodBranded$1, - ZodPipeline: ZodPipeline$1, - custom: custom$1, - Schema: ZodType$1, - ZodSchema: ZodType$1, - late: late$1, - get ZodFirstPartyTypeKind() { - return ZodFirstPartyTypeKind$1; - }, - coerce: coerce$2, - any: anyType$1, - array: arrayType$1, - bigint: bigIntType$1, - boolean: booleanType$1, - date: dateType$1, - discriminatedUnion: discriminatedUnionType$1, - effect: effectsType$1, - "enum": enumType$1, - "function": functionType$1, - "instanceof": instanceOfType$1, - intersection: intersectionType$1, - lazy: lazyType$1, - literal: literalType$1, - map: mapType$1, - nan: nanType$1, - nativeEnum: nativeEnumType$1, - never: neverType$1, - "null": nullType$1, - nullable: nullableType$1, - number: numberType$1, - object: objectType$1, - oboolean: oboolean$1, - onumber: onumber$1, - optional: optionalType$1, - ostring: ostring$1, - pipeline: pipelineType$1, - preprocess: preprocessType$1, - promise: promiseType$1, - record: recordType$1, - set: setType$1, - strictObject: strictObjectType$1, - string: stringType$1, - symbol: symbolType$1, - transformer: effectsType$1, - tuple: tupleType$1, - "undefined": undefinedType$1, - union: unionType$1, - unknown: unknownType$1, - "void": voidType$1, - NEVER: NEVER$1, - ZodIssueCode: ZodIssueCode$1, - quotelessJson: quotelessJson$1, - ZodError: ZodError$1 + function Tt$3(e2, t2, r3, i2) { + Ze$3.BasePoint.call(this, e2, "jacobian"), t2 === null && r3 === null && i2 === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new K2(0)) : (this.x = new K2(t2, 16), this.y = new K2(r3, 16), this.z = new K2(i2, 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; + } + Di(Tt$3, Ze$3.BasePoint), Zt2.prototype.jpoint = function(t2, r3, i2) { + return new Tt$3(this, t2, r3, i2); + }, Tt$3.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var t2 = this.z.redInvm(), r3 = t2.redSqr(), i2 = this.x.redMul(r3), n4 = this.y.redMul(r3).redMul(t2); + return this.curve.point(i2, n4); + }, Tt$3.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }, Tt$3.prototype.add = function(t2) { + if (this.isInfinity()) + return t2; + if (t2.isInfinity()) + return this; + var r3 = t2.z.redSqr(), i2 = this.z.redSqr(), n4 = this.x.redMul(r3), o22 = t2.x.redMul(i2), h4 = this.y.redMul(r3.redMul(t2.z)), p2 = t2.y.redMul(i2.redMul(this.z)), b3 = n4.redSub(o22), m3 = h4.redSub(p2); + if (b3.cmpn(0) === 0) + return m3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var w3 = b3.redSqr(), y3 = w3.redMul(b3), S2 = n4.redMul(w3), I2 = m3.redSqr().redIAdd(y3).redISub(S2).redISub(S2), N22 = m3.redMul(S2.redISub(I2)).redISub(h4.redMul(y3)), C2 = this.z.redMul(t2.z).redMul(b3); + return this.curve.jpoint(I2, N22, C2); + }, Tt$3.prototype.mixedAdd = function(t2) { + if (this.isInfinity()) + return t2.toJ(); + if (t2.isInfinity()) + return this; + var r3 = this.z.redSqr(), i2 = this.x, n4 = t2.x.redMul(r3), o22 = this.y, h4 = t2.y.redMul(r3).redMul(this.z), p2 = i2.redSub(n4), b3 = o22.redSub(h4); + if (p2.cmpn(0) === 0) + return b3.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var m3 = p2.redSqr(), w3 = m3.redMul(p2), y3 = i2.redMul(m3), S2 = b3.redSqr().redIAdd(w3).redISub(y3).redISub(y3), I2 = b3.redMul(y3.redISub(S2)).redISub(o22.redMul(w3)), N22 = this.z.redMul(p2); + return this.curve.jpoint(S2, I2, N22); + }, Tt$3.prototype.dblp = function(t2) { + if (t2 === 0) + return this; + if (this.isInfinity()) + return this; + if (!t2) + return this.dbl(); + var r3; + if (this.curve.zeroA || this.curve.threeA) { + var i2 = this; + for (r3 = 0; r3 < t2; r3++) + i2 = i2.dbl(); + return i2; + } + var n4 = this.curve.a, o22 = this.curve.tinv, h4 = this.x, p2 = this.y, b3 = this.z, m3 = b3.redSqr().redSqr(), w3 = p2.redAdd(p2); + for (r3 = 0; r3 < t2; r3++) { + var y3 = h4.redSqr(), S2 = w3.redSqr(), I2 = S2.redSqr(), N22 = y3.redAdd(y3).redIAdd(y3).redIAdd(n4.redMul(m3)), C2 = h4.redMul(S2), F2 = N22.redSqr().redISub(C2.redAdd(C2)), U2 = C2.redISub(F2), J2 = N22.redMul(U2); + J2 = J2.redIAdd(J2).redISub(I2); + var Bt2 = w3.redMul(b3); + r3 + 1 < t2 && (m3 = m3.redMul(I2)), h4 = F2, b3 = Bt2, w3 = J2; + } + return this.curve.jpoint(h4, w3.redMul(o22), b3); + }, Tt$3.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); + }, Tt$3.prototype._zeroDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o22 = this.y.redSqr(), h4 = o22.redSqr(), p2 = this.x.redAdd(o22).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4), m3 = b3.redSqr().redISub(p2).redISub(p2), w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), t2 = m3, r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.x.redSqr(), S2 = this.y.redSqr(), I2 = S2.redSqr(), N22 = this.x.redAdd(S2).redSqr().redISub(y3).redISub(I2); + N22 = N22.redIAdd(N22); + var C2 = y3.redAdd(y3).redIAdd(y3), F2 = C2.redSqr(), U2 = I2.redIAdd(I2); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), t2 = F2.redISub(N22).redISub(N22), r3 = C2.redMul(N22.redISub(t2)).redISub(U2), i2 = this.y.redMul(this.z), i2 = i2.redIAdd(i2); + } + return this.curve.jpoint(t2, r3, i2); + }, Tt$3.prototype._threeDbl = function() { + var t2, r3, i2; + if (this.zOne) { + var n4 = this.x.redSqr(), o22 = this.y.redSqr(), h4 = o22.redSqr(), p2 = this.x.redAdd(o22).redSqr().redISub(n4).redISub(h4); + p2 = p2.redIAdd(p2); + var b3 = n4.redAdd(n4).redIAdd(n4).redIAdd(this.curve.a), m3 = b3.redSqr().redISub(p2).redISub(p2); + t2 = m3; + var w3 = h4.redIAdd(h4); + w3 = w3.redIAdd(w3), w3 = w3.redIAdd(w3), r3 = b3.redMul(p2.redISub(m3)).redISub(w3), i2 = this.y.redAdd(this.y); + } else { + var y3 = this.z.redSqr(), S2 = this.y.redSqr(), I2 = this.x.redMul(S2), N22 = this.x.redSub(y3).redMul(this.x.redAdd(y3)); + N22 = N22.redAdd(N22).redIAdd(N22); + var C2 = I2.redIAdd(I2); + C2 = C2.redIAdd(C2); + var F2 = C2.redAdd(C2); + t2 = N22.redSqr().redISub(F2), i2 = this.y.redAdd(this.z).redSqr().redISub(S2).redISub(y3); + var U2 = S2.redSqr(); + U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), U2 = U2.redIAdd(U2), r3 = N22.redMul(C2.redISub(t2)).redISub(U2); + } + return this.curve.jpoint(t2, r3, i2); + }, Tt$3.prototype._dbl = function() { + var t2 = this.curve.a, r3 = this.x, i2 = this.y, n4 = this.z, o22 = n4.redSqr().redSqr(), h4 = r3.redSqr(), p2 = i2.redSqr(), b3 = h4.redAdd(h4).redIAdd(h4).redIAdd(t2.redMul(o22)), m3 = r3.redAdd(r3); + m3 = m3.redIAdd(m3); + var w3 = m3.redMul(p2), y3 = b3.redSqr().redISub(w3.redAdd(w3)), S2 = w3.redISub(y3), I2 = p2.redSqr(); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N22 = b3.redMul(S2).redISub(I2), C2 = i2.redAdd(i2).redMul(n4); + return this.curve.jpoint(y3, N22, C2); + }, Tt$3.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var t2 = this.x.redSqr(), r3 = this.y.redSqr(), i2 = this.z.redSqr(), n4 = r3.redSqr(), o22 = t2.redAdd(t2).redIAdd(t2), h4 = o22.redSqr(), p2 = this.x.redAdd(r3).redSqr().redISub(t2).redISub(n4); + p2 = p2.redIAdd(p2), p2 = p2.redAdd(p2).redIAdd(p2), p2 = p2.redISub(h4); + var b3 = p2.redSqr(), m3 = n4.redIAdd(n4); + m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3), m3 = m3.redIAdd(m3); + var w3 = o22.redIAdd(p2).redSqr().redISub(h4).redISub(b3).redISub(m3), y3 = r3.redMul(w3); + y3 = y3.redIAdd(y3), y3 = y3.redIAdd(y3); + var S2 = this.x.redMul(b3).redISub(y3); + S2 = S2.redIAdd(S2), S2 = S2.redIAdd(S2); + var I2 = this.y.redMul(w3.redMul(m3.redISub(w3)).redISub(p2.redMul(b3))); + I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2), I2 = I2.redIAdd(I2); + var N22 = this.z.redAdd(p2).redSqr().redISub(i2).redISub(b3); + return this.curve.jpoint(S2, I2, N22); + }, Tt$3.prototype.mul = function(t2, r3) { + return t2 = new K2(t2, r3), this.curve._wnafMul(this, t2); + }, Tt$3.prototype.eq = function(t2) { + if (t2.type === "affine") + return this.eq(t2.toJ()); + if (this === t2) + return true; + var r3 = this.z.redSqr(), i2 = t2.z.redSqr(); + if (this.x.redMul(i2).redISub(t2.x.redMul(r3)).cmpn(0) !== 0) + return false; + var n4 = r3.redMul(this.z), o22 = i2.redMul(t2.z); + return this.y.redMul(o22).redISub(t2.y.redMul(n4)).cmpn(0) === 0; + }, Tt$3.prototype.eqXToP = function(t2) { + var r3 = this.z.redSqr(), i2 = t2.toRed(this.curve.red).redMul(r3); + if (this.x.cmp(i2) === 0) + return true; + for (var n4 = t2.clone(), o22 = this.curve.redN.redMul(r3); ; ) { + if (n4.iadd(this.curve.n), n4.cmp(this.curve.p) >= 0) + return false; + if (i2.redIAdd(o22), this.x.cmp(i2) === 0) + return true; + } + }, Tt$3.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, Tt$3.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; + }; + var qr = cr$3(function(e2, t2) { + var r3 = t2; + r3.base = Ze$3, r3.short = ka, r3.mont = null, r3.edwards = null; + }), Kr = cr$3(function(e2, t2) { + var r3 = t2, i2 = Jt$4.assert; + function n4(p2) { + p2.type === "short" ? this.curve = new qr.short(p2) : p2.type === "edwards" ? this.curve = new qr.edwards(p2) : this.curve = new qr.mont(p2), this.g = this.curve.g, this.n = this.curve.n, this.hash = p2.hash, i2(this.g.validate(), "Invalid curve"), i2(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r3.PresetCurve = n4; + function o22(p2, b3) { + Object.defineProperty(r3, p2, { configurable: true, enumerable: true, get: function() { + var m3 = new n4(b3); + return Object.defineProperty(r3, p2, { configurable: true, enumerable: true, value: m3 }), m3; + } }); + } + o22("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: se$4.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), o22("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: se$4.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), o22("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: se$4.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), o22("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: se$4.sha384, gRed: false, 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"] }), o22("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: se$4.sha512, gRed: false, 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"] }), o22("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: se$4.sha256, gRed: false, g: ["9"] }), o22("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: se$4.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + var h4; + try { + h4 = null.crash(); + } catch { + h4 = void 0; + } + o22("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: se$4.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", h4] }); }); - const aleoAddressRegex$1 = /^aleo1[a-z0-9]{58}$/i; - const aleoViewKeyRegex$1 = /^AViewKey1[a-z0-9]{44}$/i; - const aleoPrivateKeyRegex$1 = /^APrivateKey1[a-z0-9]{47}$/i; - const aleoTransactionIdRegex$1 = /^at1[a-z0-9]{58}$/i; - const aleoFieldRegex$1 = /^\d+field$/; - const aleoU32$1 = /^\d+u32$/; - const aleoU64$1 = /^\d+u64$/; - z2.string().regex(aleoAddressRegex$1); - z2.string().regex(aleoViewKeyRegex$1); - z2.string().regex(aleoPrivateKeyRegex$1); - z2.string().regex(aleoTransactionIdRegex$1); - z2.string().regex(aleoFieldRegex$1); - z2.string().regex(aleoU32$1); - z2.string().regex(aleoU64$1); - var InputOutputType$1; - (function(InputOutputType2) { - InputOutputType2["Record"] = "record"; - InputOutputType2["OutputRecord"] = "outputRecord"; - InputOutputType2["Public"] = "public"; - InputOutputType2["Private"] = "private"; - InputOutputType2["Constant"] = "constant"; - InputOutputType2["Future"] = "future"; - InputOutputType2["ExternalRecord"] = "external_record"; - })(InputOutputType$1 || (InputOutputType$1 = {})); - var EventType; - (function(EventType2) { - EventType2["Deploy"] = "Deploy"; - EventType2["Execute"] = "Execute"; - EventType2["Send"] = "Send"; - EventType2["Receive"] = "Receive"; - EventType2["Join"] = "Join"; - EventType2["Split"] = "Split"; - EventType2["Shield"] = "Shield"; - EventType2["Unshield"] = "Unshield"; - })(EventType || (EventType = {})); - var EventStatus; - (function(EventStatus2) { - EventStatus2["Creating"] = "Creating"; - EventStatus2["Pending"] = "Pending"; - EventStatus2["Settled"] = "Settled"; - EventStatus2["Failed"] = "Failed"; - })(EventStatus || (EventStatus = {})); - var Visibility; - (function(Visibility2) { - Visibility2["Private"] = "Private"; - Visibility2["Public"] = "Public"; - })(Visibility || (Visibility = {})); - var Network; - (function(Network2) { - Network2["AleoTestnet"] = "AleoTestnet"; - Network2["AleoMainnet"] = "AleoMainnet"; - })(Network || (Network = {})); - var AssetType; - (function(AssetType2) { - AssetType2[AssetType2["ALEO"] = 0] = "ALEO"; - })(AssetType || (AssetType = {})); - z2.nativeEnum(EventType); - z2.nativeEnum(EventStatus); - z2.nativeEnum(Network); - z2.nativeEnum(Visibility); + function Re$3(e2) { + if (!(this instanceof Re$3)) + return new Re$3(e2); + this.hash = e2.hash, this.predResist = !!e2.predResist, this.outLen = this.hash.outSize, this.minEntropy = e2.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var t2 = fe$3.toArray(e2.entropy, e2.entropyEnc || "hex"), r3 = fe$3.toArray(e2.nonce, e2.nonceEnc || "hex"), i2 = fe$3.toArray(e2.pers, e2.persEnc || "hex"); + Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(t2, r3, i2); + } + var Rf = Re$3; + Re$3.prototype._init = function(t2, r3, i2) { + var n4 = t2.concat(r3).concat(i2); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var o22 = 0; o22 < this.V.length; o22++) + this.K[o22] = 0, this.V[o22] = 1; + this._update(n4), this._reseed = 1, this.reseedInterval = 281474976710656; + }, Re$3.prototype._hmac = function() { + return new se$4.hmac(this.hash, this.K); + }, Re$3.prototype._update = function(t2) { + var r3 = this._hmac().update(this.V).update([0]); + t2 && (r3 = r3.update(t2)), this.K = r3.digest(), this.V = this._hmac().update(this.V).digest(), t2 && (this.K = this._hmac().update(this.V).update([1]).update(t2).digest(), this.V = this._hmac().update(this.V).digest()); + }, Re$3.prototype.reseed = function(t2, r3, i2, n4) { + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), t2 = fe$3.toArray(t2, r3), i2 = fe$3.toArray(i2, n4), Pi(t2.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t2.concat(i2 || [])), this._reseed = 1; + }, Re$3.prototype.generate = function(t2, r3, i2, n4) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r3 != "string" && (n4 = i2, i2 = r3, r3 = null), i2 && (i2 = fe$3.toArray(i2, n4 || "hex"), this._update(i2)); + for (var o22 = []; o22.length < t2; ) + this.V = this._hmac().update(this.V).digest(), o22 = o22.concat(this.V); + var h4 = o22.slice(0, t2); + return this._update(i2), this._reseed++, fe$3.encode(h4, r3); + }; + var Fi = Jt$4.assert; + function kt2(e2, t2) { + this.ec = e2, this.priv = null, this.pub = null, t2.priv && this._importPrivate(t2.priv, t2.privEnc), t2.pub && this._importPublic(t2.pub, t2.pubEnc); + } + var Ti = kt2; + kt2.fromPublic = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { pub: r3, pubEnc: i2 }); + }, kt2.fromPrivate = function(t2, r3, i2) { + return r3 instanceof kt2 ? r3 : new kt2(t2, { priv: r3, privEnc: i2 }); + }, kt2.prototype.validate = function() { + var t2 = this.getPublic(); + return t2.isInfinity() ? { result: false, reason: "Invalid public key" } : t2.validate() ? t2.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; + }, kt2.prototype.getPublic = function(t2, r3) { + return typeof t2 == "string" && (r3 = t2, t2 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r3 ? this.pub.encode(r3, t2) : this.pub; + }, kt2.prototype.getPrivate = function(t2) { + return t2 === "hex" ? this.priv.toString(16, 2) : this.priv; + }, kt2.prototype._importPrivate = function(t2, r3) { + this.priv = new K2(t2, r3 || 16), this.priv = this.priv.umod(this.ec.curve.n); + }, kt2.prototype._importPublic = function(t2, r3) { + if (t2.x || t2.y) { + this.ec.curve.type === "mont" ? Fi(t2.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && Fi(t2.x && t2.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(t2.x, t2.y); + return; + } + this.pub = this.ec.curve.decodePoint(t2, r3); + }, kt2.prototype.derive = function(t2) { + return t2.validate() || Fi(t2.validate(), "public point not validated"), t2.mul(this.priv).getX(); + }, kt2.prototype.sign = function(t2, r3, i2) { + return this.ec.sign(t2, this, r3, i2); + }, kt2.prototype.verify = function(t2, r3) { + return this.ec.verify(t2, r3, this); + }, kt2.prototype.inspect = function() { + return ""; + }; + var qa = Jt$4.assert; + function Hr(e2, t2) { + if (e2 instanceof Hr) + return e2; + this._importDER(e2, t2) || (qa(e2.r && e2.s, "Signature without r or s"), this.r = new K2(e2.r, 16), this.s = new K2(e2.s, 16), e2.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = e2.recoveryParam); + } + var zr = Hr; + function Ka() { + this.place = 0; + } + function Ui(e2, t2) { + var r3 = e2[t2.place++]; + if (!(r3 & 128)) + return r3; + var i2 = r3 & 15; + if (i2 === 0 || i2 > 4) + return false; + for (var n4 = 0, o22 = 0, h4 = t2.place; o22 < i2; o22++, h4++) + n4 <<= 8, n4 |= e2[h4], n4 >>>= 0; + return n4 <= 127 ? false : (t2.place = h4, n4); + } + function Of(e2) { + for (var t2 = 0, r3 = e2.length - 1; !e2[t2] && !(e2[t2 + 1] & 128) && t2 < r3; ) + t2++; + return t2 === 0 ? e2 : e2.slice(t2); + } + Hr.prototype._importDER = function(t2, r3) { + t2 = Jt$4.toArray(t2, r3); + var i2 = new Ka(); + if (t2[i2.place++] !== 48) + return false; + var n4 = Ui(t2, i2); + if (n4 === false || n4 + i2.place !== t2.length || t2[i2.place++] !== 2) + return false; + var o22 = Ui(t2, i2); + if (o22 === false) + return false; + var h4 = t2.slice(i2.place, o22 + i2.place); + if (i2.place += o22, t2[i2.place++] !== 2) + return false; + var p2 = Ui(t2, i2); + if (p2 === false || t2.length !== p2 + i2.place) + return false; + var b3 = t2.slice(i2.place, p2 + i2.place); + if (h4[0] === 0) + if (h4[1] & 128) + h4 = h4.slice(1); + else + return false; + if (b3[0] === 0) + if (b3[1] & 128) + b3 = b3.slice(1); + else + return false; + return this.r = new K2(h4), this.s = new K2(b3), this.recoveryParam = null, true; + }; + function ki(e2, t2) { + if (t2 < 128) { + e2.push(t2); + return; + } + var r3 = 1 + (Math.log(t2) / Math.LN2 >>> 3); + for (e2.push(r3 | 128); --r3; ) + e2.push(t2 >>> (r3 << 3) & 255); + e2.push(t2); + } + Hr.prototype.toDER = function(t2) { + var r3 = this.r.toArray(), i2 = this.s.toArray(); + for (r3[0] & 128 && (r3 = [0].concat(r3)), i2[0] & 128 && (i2 = [0].concat(i2)), r3 = Of(r3), i2 = Of(i2); !i2[0] && !(i2[1] & 128); ) + i2 = i2.slice(1); + var n4 = [2]; + ki(n4, r3.length), n4 = n4.concat(r3), n4.push(2), ki(n4, i2.length); + var o22 = n4.concat(i2), h4 = [48]; + return ki(h4, o22.length), h4 = h4.concat(o22), Jt$4.encode(h4, t2); + }; + var Ha = function() { + throw new Error("unsupported"); + }, Pf = Jt$4.assert; + function $t$3(e2) { + if (!(this instanceof $t$3)) + return new $t$3(e2); + typeof e2 == "string" && (Pf(Object.prototype.hasOwnProperty.call(Kr, e2), "Unknown curve " + e2), e2 = Kr[e2]), e2 instanceof Kr.PresetCurve && (e2 = { curve: e2 }), this.curve = e2.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e2.curve.g, this.g.precompute(e2.curve.n.bitLength() + 1), this.hash = e2.hash || e2.curve.hash; + } + var za = $t$3; + $t$3.prototype.keyPair = function(t2) { + return new Ti(this, t2); + }, $t$3.prototype.keyFromPrivate = function(t2, r3) { + return Ti.fromPrivate(this, t2, r3); + }, $t$3.prototype.keyFromPublic = function(t2, r3) { + return Ti.fromPublic(this, t2, r3); + }, $t$3.prototype.genKeyPair = function(t2) { + t2 || (t2 = {}); + for (var r3 = new Rf({ hash: this.hash, pers: t2.pers, persEnc: t2.persEnc || "utf8", entropy: t2.entropy || Ha(this.hash.hmacStrength), entropyEnc: t2.entropy && t2.entropyEnc || "utf8", nonce: this.n.toArray() }), i2 = this.n.byteLength(), n4 = this.n.sub(new K2(2)); ; ) { + var o22 = new K2(r3.generate(i2)); + if (!(o22.cmp(n4) > 0)) + return o22.iaddn(1), this.keyFromPrivate(o22); + } + }, $t$3.prototype._truncateToN = function(t2, r3) { + var i2 = t2.byteLength() * 8 - this.n.bitLength(); + return i2 > 0 && (t2 = t2.ushrn(i2)), !r3 && t2.cmp(this.n) >= 0 ? t2.sub(this.n) : t2; + }, $t$3.prototype.sign = function(t2, r3, i2, n4) { + typeof i2 == "object" && (n4 = i2, i2 = null), n4 || (n4 = {}), r3 = this.keyFromPrivate(r3, i2), t2 = this._truncateToN(new K2(t2, 16)); + for (var o22 = this.n.byteLength(), h4 = r3.getPrivate().toArray("be", o22), p2 = t2.toArray("be", o22), b3 = new Rf({ hash: this.hash, entropy: h4, nonce: p2, pers: n4.pers, persEnc: n4.persEnc || "utf8" }), m3 = this.n.sub(new K2(1)), w3 = 0; ; w3++) { + var y3 = n4.k ? n4.k(w3) : new K2(b3.generate(this.n.byteLength())); + if (y3 = this._truncateToN(y3, true), !(y3.cmpn(1) <= 0 || y3.cmp(m3) >= 0)) { + var S2 = this.g.mul(y3); + if (!S2.isInfinity()) { + var I2 = S2.getX(), N22 = I2.umod(this.n); + if (N22.cmpn(0) !== 0) { + var C2 = y3.invm(this.n).mul(N22.mul(r3.getPrivate()).iadd(t2)); + if (C2 = C2.umod(this.n), C2.cmpn(0) !== 0) { + var F2 = (S2.getY().isOdd() ? 1 : 0) | (I2.cmp(N22) !== 0 ? 2 : 0); + return n4.canonical && C2.cmp(this.nh) > 0 && (C2 = this.n.sub(C2), F2 ^= 1), new zr({ r: N22, s: C2, recoveryParam: F2 }); + } + } + } + } + } + }, $t$3.prototype.verify = function(t2, r3, i2, n4) { + t2 = this._truncateToN(new K2(t2, 16)), i2 = this.keyFromPublic(i2, n4), r3 = new zr(r3, "hex"); + var o22 = r3.r, h4 = r3.s; + if (o22.cmpn(1) < 0 || o22.cmp(this.n) >= 0 || h4.cmpn(1) < 0 || h4.cmp(this.n) >= 0) + return false; + var p2 = h4.invm(this.n), b3 = p2.mul(t2).umod(this.n), m3 = p2.mul(o22).umod(this.n), w3; + return this.curve._maxwellTrick ? (w3 = this.g.jmulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.eqXToP(o22)) : (w3 = this.g.mulAdd(b3, i2.getPublic(), m3), w3.isInfinity() ? false : w3.getX().umod(this.n).cmp(o22) === 0); + }, $t$3.prototype.recoverPubKey = function(e2, t2, r3, i2) { + Pf((3 & r3) === r3, "The recovery param is more than two bits"), t2 = new zr(t2, i2); + var n4 = this.n, o22 = new K2(e2), h4 = t2.r, p2 = t2.s, b3 = r3 & 1, m3 = r3 >> 1; + if (h4.cmp(this.curve.p.umod(this.curve.n)) >= 0 && m3) + throw new Error("Unable to find sencond key candinate"); + m3 ? h4 = this.curve.pointFromX(h4.add(this.curve.n), b3) : h4 = this.curve.pointFromX(h4, b3); + var w3 = t2.r.invm(n4), y3 = n4.sub(o22).mul(w3).umod(n4), S2 = p2.mul(w3).umod(n4); + return this.g.mulAdd(y3, h4, S2); + }, $t$3.prototype.getKeyRecoveryParam = function(e2, t2, r3, i2) { + if (t2 = new zr(t2, i2), t2.recoveryParam !== null) + return t2.recoveryParam; + for (var n4 = 0; n4 < 4; n4++) { + var o22; + try { + o22 = this.recoverPubKey(e2, t2, n4); + } catch { + continue; + } + if (o22.eq(r3)) + return n4; + } + throw new Error("Unable to find valid recovery factor"); + }; + var La = cr$3(function(e2, t2) { + var r3 = t2; + r3.version = "6.5.4", r3.utils = Jt$4, r3.rand = function() { + throw new Error("unsupported"); + }, r3.curve = qr, r3.curves = Kr, r3.ec = za, r3.eddsa = null; + }); + La.ec; + var Ff; + (function(e2) { + e2[e2.legacy = 0] = "legacy", e2[e2.eip2930 = 1] = "eip2930", e2[e2.eip1559 = 2] = "eip1559"; + })(Ff || (Ff = {})); + const go$2 = { 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 } }; + function tr(e2, t2) { + const { message: r3, code: i2 } = go$2[e2]; + return { message: t2 ? `${r3} ${t2}` : r3, code: i2 }; + } + const emitter$1 = new EventEmitter$1(); + let connection = void 0; + async function configureConnection$1(options) { + let disconnectSessions = false; + const thisVersion = pkg$1.version; + const prevVersion = localStorage.getItem("puzzle_sdk_version"); + if (thisVersion !== prevVersion) { + console.log( + `${pkg$1.name}: Updated from ` + prevVersion + " to " + thisVersion + "!" + ); + localStorage.setItem("puzzle_sdk_version", thisVersion); + disconnectSessions = true; + } + connection = new G$2({ + projectId: options.projectId ?? projectId$1, + metadata: { + name: options.dAppName, + description: options.dAppDescription, + url: window ? window.location.hostname : options.dAppUrl ?? "NO URL", + icons: [options.dAppIconURL] + }, + modalOptions: { ...web3modal_puzzle_props$1 } + }); + if (disconnectSessions) { + localStorage.removeItem("puzzle-hasInjectedConnection"); + try { + disconnectOnVersionChange$1(connection, options.onDisconnect); + } catch (e2) { + console.error(e2); + } + } + connection.onSessionDelete(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + connection.onSessionExpire(() => { + localStorage.removeItem("puzzle-hasInjectedConnection"); + options.onDisconnect && options.onDisconnect(); + }); + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + if (typeof window !== "undefined") { + window.puzzleSdkConnection = connection; + } + return connection; + } + async function disconnectOnVersionChange$1(connection2, onDisconnect) { + const session = await (connection2 == null ? void 0 : connection2.getSession()); + if (session) { + console.log("Disconnecting session", session); + onDisconnect && onDisconnect(); + connection2.disconnect({ + topic: session.topic, + reason: tr("USER_DISCONNECTED") + }); + } + } + async function getWalletConnectModalSignClient$1() { + return new Promise((resolve) => { + if (connection) { + resolve(connection); + } else if (typeof window !== "undefined" && (window == null ? void 0 : window.puzzleSdkConnection)) { + resolve(window.puzzleSdkConnection); + } else { + const interval = setInterval(() => { + if (connection) { + clearInterval(interval); + resolve(connection); + } + }, 200); + } + const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + if (choice && JSON.parse(choice).name !== "Android") { + window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); + } + }); + } + const checkForDesktopConnection$1 = async (sessionTopic) => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + try { + const res = await window.aleo.puzzleWalletClient.isConnected.query( + { sessionTopic } + ); + if (res) { + localStorage.setItem("puzzle-hasInjectedConnection", "true"); + return true; + } else { + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + } catch (e2) { + console.warn(e2); + localStorage.setItem("puzzle-hasInjectedConnection", "false"); + return false; + } + }; + const hasInjectedConnection$1 = () => { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + return false; + } + const puzzleHasDesktopConnection = localStorage.getItem( + "puzzle-hasInjectedConnection" + ); + return puzzleHasDesktopConnection === "true"; + }; var browser$5 = { exports: {} }; var ms; var hasRequiredMs; @@ -16600,12 +23705,12 @@ if (hasRequiredMs) return ms; hasRequiredMs = 1; - var s2 = 1e3; - var m2 = s2 * 60; - var h4 = m2 * 60; - var d3 = h4 * 24; - var w3 = d3 * 7; - var y3 = d3 * 365.25; + var s22 = 1e3; + var m3 = s22 * 60; + var h4 = m3 * 60; + var d5 = h4 * 24; + var w3 = d5 * 7; + var y3 = d5 * 365.25; ms = function(val, options) { options = options || {}; var type2 = typeof val; @@ -16629,7 +23734,7 @@ if (!match) { return; } - var n3 = parseFloat(match[1]); + var n4 = parseFloat(match[1]); var type2 = (match[2] || "ms").toLowerCase(); switch (type2) { case "years": @@ -16637,78 +23742,78 @@ case "yrs": case "yr": case "y": - return n3 * y3; + return n4 * y3; case "weeks": case "week": case "w": - return n3 * w3; + return n4 * w3; case "days": case "day": case "d": - return n3 * d3; + return n4 * d5; case "hours": case "hour": case "hrs": case "hr": case "h": - return n3 * h4; + return n4 * h4; case "minutes": case "minute": case "mins": case "min": case "m": - return n3 * m2; + return n4 * m3; case "seconds": case "second": case "secs": case "sec": case "s": - return n3 * s2; + return n4 * s22; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": - return n3; + return n4; default: return void 0; } } function fmtShort(ms2) { var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return Math.round(ms2 / d3) + "d"; + if (msAbs >= d5) { + return Math.round(ms2 / d5) + "d"; } if (msAbs >= h4) { return Math.round(ms2 / h4) + "h"; } - if (msAbs >= m2) { - return Math.round(ms2 / m2) + "m"; + if (msAbs >= m3) { + return Math.round(ms2 / m3) + "m"; } - if (msAbs >= s2) { - return Math.round(ms2 / s2) + "s"; + if (msAbs >= s22) { + return Math.round(ms2 / s22) + "s"; } return ms2 + "ms"; } function fmtLong(ms2) { var msAbs = Math.abs(ms2); - if (msAbs >= d3) { - return plural(ms2, msAbs, d3, "day"); + if (msAbs >= d5) { + return plural(ms2, msAbs, d5, "day"); } if (msAbs >= h4) { return plural(ms2, msAbs, h4, "hour"); } - if (msAbs >= m2) { - return plural(ms2, msAbs, m2, "minute"); + if (msAbs >= m3) { + return plural(ms2, msAbs, m3, "minute"); } - if (msAbs >= s2) { - return plural(ms2, msAbs, s2, "second"); + if (msAbs >= s22) { + return plural(ms2, msAbs, s22, "second"); } return ms2 + " ms"; } - function plural(ms2, msAbs, n3, name2) { - var isPlural = msAbs >= n3 * 1.5; - return Math.round(ms2 / n3) + " " + name2 + (isPlural ? "s" : ""); + function plural(ms2, msAbs, n4, name2) { + var isPlural = msAbs >= n4 * 1.5; + return Math.round(ms2 / n4) + " " + name2 + (isPlural ? "s" : ""); } return ms; } @@ -16757,12 +23862,12 @@ args.unshift("%O"); } let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => { if (match === "%%") { return "%"; } index++; - const formatter = createDebug.formatters[format]; + const formatter = createDebug.formatters[format2]; if (typeof formatter === "function") { const val = args[index]; match = formatter.call(self2, val); @@ -17008,15 +24113,15 @@ } } function load() { - let r2; + let r3; try { - r2 = exports22.storage.getItem("debug"); + r3 = exports22.storage.getItem("debug"); } catch (error) { } - if (!r2 && typeof process !== "undefined" && "env" in process) { - r2 = process.env.DEBUG; + if (!r3 && typeof process !== "undefined" && "env" in process) { + r3 = process.env.DEBUG; } - return r2; + return r3; } function localstorage() { try { @@ -17084,14 +24189,14 @@ } const persistStorage = { getItem: (name2) => { - var _a; + var _a2; const parse = (str2) => { if (str2 === null) { return null; } - return JSON.parse(str2, options == null ? void 0 : options.reviver); + return JSON.parse(str2, void 0); }; - const str = (_a = storage.getItem(name2)) != null ? _a : null; + const str = (_a2 = storage.getItem(name2)) != null ? _a2 : null; if (str instanceof Promise) { return str.then(parse); } @@ -17099,15 +24204,15 @@ }, setItem: (name2, newValue) => storage.setItem( name2, - JSON.stringify(newValue, options == null ? void 0 : options.replacer) + JSON.stringify(newValue, void 0) ), removeItem: (name2) => storage.removeItem(name2) }; return persistStorage; } - const toThenable = (fn2) => (input) => { + const toThenable = (fn) => (input) => { try { - const result = fn2(input); + const result = fn(input); if (result instanceof Promise) { return result; } @@ -17192,12 +24297,12 @@ ); let stateFromStorage; const hydrate = () => { - var _a; + var _a2; if (!storage) return; hasHydrated = false; hydrationListeners.forEach((cb) => cb(get2())); - const postRehydrationCallback = ((_a = options.onRehydrateStorage) == null ? void 0 : _a.call(options, get2())) || void 0; + const postRehydrationCallback = ((_a2 = options.onRehydrateStorage) == null ? void 0 : _a2.call(options, get2())) || void 0; return toThenable(storage.getItem.bind(storage))(options.name).then((storageValue) => { if (storageValue) { return options.deserialize(storageValue); @@ -17219,10 +24324,10 @@ } } }).then((migratedState) => { - var _a2; + var _a22; stateFromStorage = options.merge( migratedState, - (_a2 = get2()) != null ? _a2 : configResult + (_a22 = get2()) != null ? _a22 : configResult ); set2(stateFromStorage, true); return setItem(); @@ -17316,15 +24421,15 @@ api.getInitialState = () => configResult; let stateFromStorage; const hydrate = () => { - var _a, _b; + var _a2, _b; if (!storage) return; hasHydrated = false; hydrationListeners.forEach((cb) => { - var _a2; - return cb((_a2 = get2()) != null ? _a2 : configResult); + var _a22; + return cb((_a22 = get2()) != null ? _a22 : configResult); }); - const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get2()) != null ? _a : configResult)) || void 0; + const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a2 = get2()) != null ? _a2 : configResult)) || void 0; return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => { if (deserializedStorageValue) { if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) { @@ -17342,10 +24447,10 @@ } } }).then((migratedState) => { - var _a2; + var _a22; stateFromStorage = options.merge( migratedState, - (_a2 = get2()) != null ? _a2 : configResult + (_a22 = get2()) != null ? _a22 : configResult ); set2(stateFromStorage, true); return setItem(); @@ -17456,15 +24561,15 @@ queryKey, async () => fetchRequest(wcParams, queryKey), queryOptions ?? { - staleTime: queryKey[0] === "getEvent" ? 7500 : 45e3, - refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 3e4, + staleTime: queryKey[0] === "getEvent" ? 7500 : 3e4, + refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 15e3, refetchIntervalInBackground: true, enabled, retry: true } ); } - function useExtensionRequestQuery({ + function useInjectedRequestQuery({ queryKey, wcParams, enabled, @@ -17475,8 +24580,8 @@ queryKey, async () => fetchFunction(wcParams), queryOptions ?? { - staleTime: queryKey[0] === "getEvent" ? 7500 : 45e3, - refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 3e4, + staleTime: queryKey[0] === "getEvent" ? 7500 : 3e4, + refetchInterval: queryKey[0] === "getEvent" ? 5e3 : 15e3, refetchIntervalInBackground: true, enabled, retry: true @@ -17502,7 +24607,7 @@ } return { data: data2, error, loading, request }; } - function useExtensionRequest(params, fetchFunction) { + function useInjectedRequest(params, fetchFunction) { const { data: data2, error, loading, setData, setError, setLoading } = useAsyncAction(); async function request(paramsOverride) { try { @@ -17551,9 +24656,11 @@ } ); return () => { - subscriptions.forEach((subscription) => subscription.unsubscribe()); + subscriptions.forEach((subscription) => { + subscription.unsubscribe(); + }); }; - }, [session == null ? void 0 : session.topic, configs]); + }, [session == null ? void 0 : session.topic, ...configs.flatMap((config) => config.dependencies)]); }; var jsxRuntime = { exports: {} }; var reactJsxRuntime_production_min = {}; @@ -17571,18 +24678,18 @@ if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min; hasRequiredReactJsxRuntime_production_min = 1; - var f2 = React, k2 = Symbol.for("react.element"), l2 = Symbol.for("react.fragment"), m2 = Object.prototype.hasOwnProperty, n3 = f2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p3 = { key: true, ref: true, __self: true, __source: true }; + var f3 = React, k2 = Symbol.for("react.element"), l2 = Symbol.for("react.fragment"), m3 = Object.prototype.hasOwnProperty, n2 = f3.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p2 = { key: true, ref: true, __self: true, __source: true }; function q2(c2, a3, g3) { - var b3, d3 = {}, e2 = null, h2 = null; + var b3, d2 = {}, e2 = null, h2 = null; void 0 !== g3 && (e2 = "" + g3); void 0 !== a3.key && (e2 = "" + a3.key); void 0 !== a3.ref && (h2 = a3.ref); for (b3 in a3) - m2.call(a3, b3) && !p3.hasOwnProperty(b3) && (d3[b3] = a3[b3]); + m3.call(a3, b3) && !p2.hasOwnProperty(b3) && (d2[b3] = a3[b3]); if (c2 && c2.defaultProps) for (b3 in a3 = c2.defaultProps, a3) - void 0 === d3[b3] && (d3[b3] = a3[b3]); - return { $$typeof: k2, type: c2, key: e2, ref: h2, props: d3, _owner: n3.current }; + void 0 === d2[b3] && (d2[b3] = a3[b3]); + return { $$typeof: k2, type: c2, key: e2, ref: h2, props: d2, _owner: n2.current }; } reactJsxRuntime_production_min.Fragment = l2; reactJsxRuntime_production_min.jsx = q2; @@ -17633,28 +24740,28 @@ return null; } var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - function error(format) { + function error(format2) { { { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } - printWarning("error", format, args); + printWarning("error", format2, args); } } } - function printWarning(level, format, args) { + function printWarning(level, format2, args) { { var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ReactDebugCurrentFrame2.getStackAddendum(); if (stack !== "") { - format += "%s"; + format2 += "%s"; args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { return String(item); }); - argsWithFormat.unshift("Warning: " + format); + argsWithFormat.unshift("Warning: " + format2); Function.prototype.apply.call(console[level], console, argsWithFormat); } } @@ -17855,12 +24962,12 @@ var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; componentFrameCache = new PossiblyWeakMap(); } - function describeNativeComponentFrame(fn2, construct) { - if (!fn2 || reentry) { + function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) { return ""; } { - var frame = componentFrameCache.get(fn2); + var frame = componentFrameCache.get(fn); if (frame !== void 0) { return frame; } @@ -17891,14 +24998,14 @@ } catch (x2) { control = x2; } - Reflect.construct(fn2, [], Fake); + Reflect.construct(fn, [], Fake); } else { try { Fake.call(); } catch (x2) { control = x2; } - fn2.call(Fake.prototype); + fn.call(Fake.prototype); } } else { try { @@ -17906,36 +25013,36 @@ } catch (x2) { control = x2; } - fn2(); + fn(); } } catch (sample) { if (sample && control && typeof sample.stack === "string") { var sampleLines = sample.stack.split("\n"); var controlLines = control.stack.split("\n"); - var s2 = sampleLines.length - 1; + var s3 = sampleLines.length - 1; var c2 = controlLines.length - 1; - while (s2 >= 1 && c2 >= 0 && sampleLines[s2] !== controlLines[c2]) { + while (s3 >= 1 && c2 >= 0 && sampleLines[s3] !== controlLines[c2]) { c2--; } - for (; s2 >= 1 && c2 >= 0; s2--, c2--) { - if (sampleLines[s2] !== controlLines[c2]) { - if (s2 !== 1 || c2 !== 1) { + for (; s3 >= 1 && c2 >= 0; s3--, c2--) { + if (sampleLines[s3] !== controlLines[c2]) { + if (s3 !== 1 || c2 !== 1) { do { - s2--; + s3--; c2--; - if (c2 < 0 || sampleLines[s2] !== controlLines[c2]) { - var _frame = "\n" + sampleLines[s2].replace(" at new ", " at "); - if (fn2.displayName && _frame.includes("")) { - _frame = _frame.replace("", fn2.displayName); + if (c2 < 0 || sampleLines[s3] !== controlLines[c2]) { + var _frame = "\n" + sampleLines[s3].replace(" at new ", " at "); + if (fn.displayName && _frame.includes("")) { + _frame = _frame.replace("", fn.displayName); } { - if (typeof fn2 === "function") { - componentFrameCache.set(fn2, _frame); + if (typeof fn === "function") { + componentFrameCache.set(fn, _frame); } } return _frame; } - } while (s2 >= 1 && c2 >= 0); + } while (s3 >= 1 && c2 >= 0); } break; } @@ -17949,18 +25056,18 @@ } Error.prepareStackTrace = previousPrepareStackTrace; } - var name2 = fn2 ? fn2.displayName || fn2.name : ""; + var name2 = fn ? fn.displayName || fn.name : ""; var syntheticFrame = name2 ? describeBuiltInComponentFrame(name2) : ""; { - if (typeof fn2 === "function") { - componentFrameCache.set(fn2, syntheticFrame); + if (typeof fn === "function") { + componentFrameCache.set(fn, syntheticFrame); } } return syntheticFrame; } - function describeFunctionComponentFrame(fn2, source, ownerFn) { + function describeFunctionComponentFrame(fn, source, ownerFn) { { - return describeNativeComponentFrame(fn2, false); + return describeNativeComponentFrame(fn, false); } } function shouldConstruct(Component) { @@ -18278,11 +25385,6 @@ } function getSourceInfoErrorAddendum(source) { { - if (source !== void 0) { - var fileName = source.fileName.replace(/^.*[\\\/]/, ""); - var lineNumber = source.lineNumber; - return "\n\nCheck your code at " + fileName + ":" + lineNumber + "."; - } return ""; } } @@ -18399,6 +25501,7 @@ } } } + var didWarnAboutKeySpread = {}; function jsxWithValidation(type2, props, key, isStaticChildren, source, self2) { { var validType = isValidElementType(type2); @@ -18407,7 +25510,7 @@ if (type2 === void 0 || typeof type2 === "object" && type2 !== null && Object.keys(type2).length === 0) { info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."; } - var sourceInfo = getSourceInfoErrorAddendum(source); + var sourceInfo = getSourceInfoErrorAddendum(); if (sourceInfo) { info += sourceInfo; } else { @@ -18449,6 +25552,20 @@ } } } + { + if (hasOwnProperty.call(props, "key")) { + var componentName = getComponentNameFromType(type2); + var keys2 = Object.keys(props).filter(function(k2) { + return k2 !== "key"; + }); + var beforeExample = keys2.length > 0 ? "{key: someKey, " + keys2.join(": ..., ") + ": ...}" : "{key: someKey}"; + if (!didWarnAboutKeySpread[componentName + beforeExample]) { + var afterExample = keys2.length > 0 ? "{" + keys2.join(": ..., ") + ": ...}" : "{}"; + error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName); + didWarnAboutKeySpread[componentName + beforeExample] = true; + } + } + } if (type2 === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); } else { @@ -19194,24 +26311,24 @@ }() ); var __extends = /* @__PURE__ */ function() { - var extendStatics2 = function(d3, b3) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { - d4.__proto__ = b4; - } || function(d4, b4) { - for (var p3 in b4) - if (Object.prototype.hasOwnProperty.call(b4, p3)) - d4[p3] = b4[p3]; + var extendStatics2 = function(d2, b3) { + extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b4) { + d3.__proto__ = b4; + } || function(d3, b4) { + for (var p2 in b4) + if (Object.prototype.hasOwnProperty.call(b4, p2)) + d3[p2] = b4[p2]; }; - return extendStatics2(d3, b3); + return extendStatics2(d2, b3); }; - return function(d3, b3) { + return function(d2, b3) { if (typeof b3 !== "function" && b3 !== null) throw new TypeError("Class extends value " + String(b3) + " is not a constructor or null"); - extendStatics2(d3, b3); + extendStatics2(d2, b3); function __() { - this.constructor = d3; + this.constructor = d2; } - d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); + d2.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); }; }(); var ClassRegistry = ( @@ -19241,26 +26358,26 @@ return ClassRegistry2; }(Registry) ); - var __read$3 = function(o3, n3) { - var m2 = typeof Symbol === "function" && o3[Symbol.iterator]; - if (!m2) + var __read$3 = function(o3, n2) { + var m3 = typeof Symbol === "function" && o3[Symbol.iterator]; + if (!m3) return o3; - var i2 = m2.call(o3), r2, ar2 = [], e2; + var i2 = m3.call(o3), r3, ar = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n2 === void 0 || n2-- > 0) && !(r3 = i2.next()).done) + ar.push(r3.value); } catch (error) { e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { if (e2) throw e2.error; } } - return ar2; + return ar; }; function valuesOfObj(record) { if ("values" in Object) { @@ -19289,8 +26406,8 @@ return void 0; } function forEach(record, run) { - Object.entries(record).forEach(function(_a) { - var _b = __read$3(_a, 2), key = _b[0], value = _b[1]; + Object.entries(record).forEach(function(_a2) { + var _b = __read$3(_a2, 2), key = _b[0], value = _b[1]; return run(value, key); }); } @@ -19426,36 +26543,36 @@ }; var __assign$1 = function() { __assign$1 = Object.assign || function(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { - s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var s3, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { + s3 = arguments[i2]; + for (var p2 in s3) + if (Object.prototype.hasOwnProperty.call(s3, p2)) + t2[p2] = s3[p2]; } return t2; }; return __assign$1.apply(this, arguments); }; - var __read$2 = function(o3, n3) { - var m2 = typeof Symbol === "function" && o3[Symbol.iterator]; - if (!m2) + var __read$2 = function(o3, n2) { + var m3 = typeof Symbol === "function" && o3[Symbol.iterator]; + if (!m3) return o3; - var i2 = m2.call(o3), r2, ar2 = [], e2; + var i2 = m3.call(o3), r3, ar = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n2 === void 0 || n2-- > 0) && !(r3 = i2.next()).done) + ar.push(r3.value); } catch (error) { e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { if (e2) throw e2.error; } } - return ar2; + return ar; }; var __spreadArray$2 = function(to2, from2) { for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) @@ -19563,14 +26680,14 @@ untransform }; } - var symbolRule = compositeTransformation(function(s2, superJson) { - if (isSymbol(s2)) { - var isRegistered = !!superJson.symbolRegistry.getIdentifier(s2); + var symbolRule = compositeTransformation(function(s3, superJson) { + if (isSymbol(s3)) { + var isRegistered = !!superJson.symbolRegistry.getIdentifier(s3); return isRegistered; } return false; - }, function(s2, superJson) { - var identifier = superJson.symbolRegistry.getIdentifier(s2); + }, function(s3, superJson) { + var identifier = superJson.symbolRegistry.getIdentifier(s3); return ["symbol", identifier]; }, function(v3) { return v3.description; @@ -19696,11 +26813,11 @@ return transformation.untransform(json, superJson); } }; - var getNthKey = function(value, n3) { + var getNthKey = function(value, n2) { var keys2 = value.keys(); - while (n3 > 0) { + while (n2 > 0) { keys2.next(); - n3--; + n2--; } return keys2.next().value; }; @@ -19808,26 +26925,26 @@ } return object; }; - var __read$1 = function(o3, n3) { - var m2 = typeof Symbol === "function" && o3[Symbol.iterator]; - if (!m2) + var __read$1 = function(o3, n2) { + var m3 = typeof Symbol === "function" && o3[Symbol.iterator]; + if (!m3) return o3; - var i2 = m2.call(o3), r2, ar2 = [], e2; + var i2 = m3.call(o3), r3, ar = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n2 === void 0 || n2-- > 0) && !(r3 = i2.next()).done) + ar.push(r3.value); } catch (error) { e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { if (e2) throw e2.error; } } - return ar2; + return ar; }; var __spreadArray$1 = function(to2, from2) { for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) @@ -19847,7 +26964,7 @@ }); return; } - var _a = __read$1(tree, 2), nodeValue = _a[0], children = _a[1]; + var _a2 = __read$1(tree, 2), nodeValue = _a2[0], children = _a2[1]; if (children) { forEach(children, function(child, key) { traverse(child, walker2, __spreadArray$1(__spreadArray$1([], __read$1(origin)), __read$1(parsePath(key)))); @@ -19873,7 +26990,7 @@ }); } if (isArray$1(annotations)) { - var _a = __read$1(annotations, 2), root = _a[0], other = _a[1]; + var _a2 = __read$1(annotations, 2), root = _a2[0], other = _a2[1]; root.forEach(function(identicalPath) { plain = setDeep(plain, parsePath(identicalPath), function() { return plain; @@ -19912,7 +27029,7 @@ return a3.length - b3.length; }); } - var _a = __read$1(paths), representativePath = _a[0], identicalPaths = _a.slice(1); + var _a2 = __read$1(paths), representativePath = _a2[0], identicalPaths = _a2.slice(1); if (representativePath.length === 0) { rootEqualityPaths = identicalPaths.map(stringifyPath); } else { @@ -19930,7 +27047,7 @@ } } var walker = function(object, identities, superJson, dedupe, path, objectsInThisPath, seenObjects) { - var _a; + var _a2; if (path === void 0) { path = []; } @@ -19969,7 +27086,7 @@ }; } var transformationResult = transformValue(object, superJson); - var transformed = (_a = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a !== void 0 ? _a : object; + var transformed = (_a2 = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a2 !== void 0 ? _a2 : object; var transformedValue = isArray$1(transformed) ? [] : {}; var innerAnnotations = {}; forEach(transformed, function(value, index) { @@ -20041,36 +27158,36 @@ } var __assign = function() { __assign = Object.assign || function(t2) { - for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) { - s2 = arguments[i2]; - for (var p3 in s2) - if (Object.prototype.hasOwnProperty.call(s2, p3)) - t2[p3] = s2[p3]; + for (var s3, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { + s3 = arguments[i2]; + for (var p2 in s3) + if (Object.prototype.hasOwnProperty.call(s3, p2)) + t2[p2] = s3[p2]; } return t2; }; return __assign.apply(this, arguments); }; - var __read = function(o3, n3) { - var m2 = typeof Symbol === "function" && o3[Symbol.iterator]; - if (!m2) + var __read = function(o3, n2) { + var m3 = typeof Symbol === "function" && o3[Symbol.iterator]; + if (!m3) return o3; - var i2 = m2.call(o3), r2, ar2 = [], e2; + var i2 = m3.call(o3), r3, ar = [], e2; try { - while ((n3 === void 0 || n3-- > 0) && !(r2 = i2.next()).done) - ar2.push(r2.value); + while ((n2 === void 0 || n2-- > 0) && !(r3 = i2.next()).done) + ar.push(r3.value); } catch (error) { e2 = { error }; } finally { try { - if (r2 && !r2.done && (m2 = i2["return"])) - m2.call(i2); + if (r3 && !r3.done && (m3 = i2["return"])) + m3.call(i2); } finally { if (e2) throw e2.error; } } - return ar2; + return ar; }; var __spreadArray = function(to2, from2) { for (var i2 = 0, il = from2.length, j2 = to2.length; i2 < il; i2++, j2++) @@ -20080,12 +27197,12 @@ var SuperJSON = ( /** @class */ function() { - function SuperJSON2(_a) { - var _b = _a === void 0 ? {} : _a, _c = _b.dedupe, dedupe = _c === void 0 ? false : _c; + function SuperJSON2(_a2) { + var _b = _a2 === void 0 ? {} : _a2, _c = _b.dedupe, dedupe = _c === void 0 ? false : _c; this.classRegistry = new ClassRegistry(); - this.symbolRegistry = new Registry(function(s2) { - var _a2; - return (_a2 = s2.description) !== null && _a2 !== void 0 ? _a2 : ""; + this.symbolRegistry = new Registry(function(s3) { + var _a3; + return (_a3 = s3.description) !== null && _a3 !== void 0 ? _a3 : ""; }); this.customTransformerRegistry = new CustomTransformerRegistry(); this.allowedErrorProps = []; @@ -20133,12 +27250,12 @@ this.customTransformerRegistry.register(__assign({ name: name2 }, transformer)); }; SuperJSON2.prototype.allowErrorProps = function() { - var _a; + var _a2; var props = []; - for (var _i = 0; _i < arguments.length; _i++) { - props[_i] = arguments[_i]; + for (var _i2 = 0; _i2 < arguments.length; _i2++) { + props[_i2] = arguments[_i2]; } - (_a = this.allowedErrorProps).push.apply(_a, __spreadArray([], __read(props))); + (_a2 = this.allowedErrorProps).push.apply(_a2, __spreadArray([], __read(props))); }; SuperJSON2.defaultInstance = new SuperJSON2(); SuperJSON2.serialize = SuperJSON2.defaultInstance.serialize.bind(SuperJSON2.defaultInstance); @@ -20623,7 +27740,7 @@ }) : null, expanded ? subEntryPages.length === 1 ? /* @__PURE__ */ React__namespace.createElement(SubEntries, null, subEntries.map(handleEntry)) : /* @__PURE__ */ React__namespace.createElement(SubEntries, null, subEntryPages.map((entries, index) => /* @__PURE__ */ React__namespace.createElement("div", { key: index }, /* @__PURE__ */ React__namespace.createElement(Entry, null, /* @__PURE__ */ React__namespace.createElement(LabelButton, { - onClick: () => setExpandedPages((old) => old.includes(index) ? old.filter((d3) => d3 !== index) : [...old, index]) + onClick: () => setExpandedPages((old) => old.includes(index) ? old.filter((d2) => d2 !== index) : [...old, index]) }, /* @__PURE__ */ React__namespace.createElement(Expander, { expanded }), " [", index * pageSize, " ...", " ", index * pageSize + pageSize - 1, "]"), expandedPages.includes(index) ? /* @__PURE__ */ React__namespace.createElement(SubEntries, null, entries.map(handleEntry)) : null)))) : null) : /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(Label, null, label, ":"), " ", /* @__PURE__ */ React__namespace.createElement(Value, null, displayValue(value)))); @@ -20654,9 +27771,9 @@ }; if (Array.isArray(value)) { type2 = "array"; - subEntries = value.map((d3, i2) => makeProperty({ + subEntries = value.map((d2, i2) => makeProperty({ label: i2.toString(), - value: d3 + value: d2 })); } else if (value !== null && typeof value === "object" && isIterable(value) && typeof value[Symbol.iterator] === "function") { type2 = "Iterable"; @@ -20736,30 +27853,30 @@ function h2(a3, b3) { return a3 === b3 && (0 !== a3 || 1 / a3 === 1 / b3) || a3 !== a3 && b3 !== b3; } - var k2 = "function" === typeof Object.is ? Object.is : h2, l2 = e2.useState, m2 = e2.useEffect, n3 = e2.useLayoutEffect, p3 = e2.useDebugValue; + var k2 = "function" === typeof Object.is ? Object.is : h2, l2 = e2.useState, m3 = e2.useEffect, n2 = e2.useLayoutEffect, p2 = e2.useDebugValue; function q2(a3, b3) { - var d3 = b3(), f2 = l2({ inst: { value: d3, getSnapshot: b3 } }), c2 = f2[0].inst, g3 = f2[1]; - n3(function() { - c2.value = d3; + var d2 = b3(), f3 = l2({ inst: { value: d2, getSnapshot: b3 } }), c2 = f3[0].inst, g3 = f3[1]; + n2(function() { + c2.value = d2; c2.getSnapshot = b3; - r2(c2) && g3({ inst: c2 }); - }, [a3, d3, b3]); - m2(function() { - r2(c2) && g3({ inst: c2 }); + r3(c2) && g3({ inst: c2 }); + }, [a3, d2, b3]); + m3(function() { + r3(c2) && g3({ inst: c2 }); return a3(function() { - r2(c2) && g3({ inst: c2 }); + r3(c2) && g3({ inst: c2 }); }); }, [a3]); - p3(d3); - return d3; + p2(d2); + return d2; } - function r2(a3) { + function r3(a3) { var b3 = a3.getSnapshot; a3 = a3.value; try { - var d3 = b3(); - return !k2(a3, d3); - } catch (f2) { + var d2 = b3(); + return !k2(a3, d2); + } catch (f3) { return true; } } @@ -20792,35 +27909,35 @@ } var React$1 = React; var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - function error(format) { + function error(format2) { { { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } - printWarning("error", format, args); + printWarning("error", format2, args); } } } - function printWarning(level, format, args) { + function printWarning(level, format2, args) { { var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { - format += "%s"; + format2 += "%s"; args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { return String(item); }); - argsWithFormat.unshift("Warning: " + format); + argsWithFormat.unshift("Warning: " + format2); Function.prototype.apply.call(console[level], console, argsWithFormat); } } - function is2(x2, y3) { + function is(x2, y3) { return x2 === y3 && (x2 !== 0 || 1 / x2 === 1 / y3) || x2 !== x2 && y3 !== y3; } - var objectIs = typeof Object.is === "function" ? Object.is : is2; + var objectIs = typeof Object.is === "function" ? Object.is : is; var useState = React$1.useState, useEffect = React$1.useEffect, useLayoutEffect = React$1.useLayoutEffect, useDebugValue = React$1.useDebugValue; var didWarnOld18Alpha = false; var didWarnUncachedGetSnapshot = false; @@ -21815,7 +28932,9 @@ return session; } const queryClient = new reactQuery.QueryClient(); - const SessionContext = React.createContext(void 0); + const SessionContext = React.createContext( + void 0 + ); const PuzzleWalletProvider = ({ dAppName, dAppDescription, @@ -21824,7 +28943,9 @@ children, debugQuery = false }) => { - const [session, setSession] = React.useState(void 0); + const [session, setSession] = React.useState( + void 0 + ); const _session = useSession(); React.useEffect(() => { setSession(_session); @@ -21870,10 +28991,10 @@ state.setAccount, state.onDisconnect ]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getSelectedAccount" @@ -21902,8 +29023,8 @@ return !!(data2 == null ? void 0 : data2.address); }, onData: (data2) => { - var _a, _b; - const network = ((_a = data2.chain) == null ? void 0 : _a.split(":")[0]) ?? "aleo"; + var _a2, _b; + const network = ((_a2 = data2.chain) == null ? void 0 : _a2.split(":")[0]) ?? "aleo"; const chainId = ((_b = data2.chain) == null ? void 0 : _b.split(":")[1]) ?? "1"; setAccount({ network, @@ -21911,7 +29032,8 @@ address: data2.address, shortenedAddress: shortenAddress(data2.address) }); - } + }, + dependencies: [] } ] }); @@ -21940,7 +29062,7 @@ shortenedAddress: shortenAddress(address) }); }); - useOnSessionDelete(({ params, topic }) => { + useOnSessionDelete(() => { onDisconnect(); }); React.useEffect(() => { @@ -21964,18 +29086,17 @@ loading }; }; - const useBalance = ({ address, multisig }) => { + const useBalance = ({ address, multisig } = {}) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getBalance", params: { - assetId: void 0, address } } @@ -22008,14 +29129,16 @@ condition: () => { return !multisig; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data2) => { return !!multisig && (data2 == null ? void 0 : data2.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig, address] } ] }); @@ -22036,7 +29159,7 @@ const balances = response == null ? void 0 : response.balances; return { balances, error, loading }; }; - function useConnect() { + function useConnect(showModal = true) { const session = useWalletSession(); const isConnected = !!session; const { data: data2, error, loading, setData, setError, setLoading } = useAsyncAction(); @@ -22050,11 +29173,18 @@ requiredNamespaces: { aleo: { methods: wc_aleo_methods$1, - chains: wc_aleo_chains$1, + chains: wc_required_aleo_chains$1, + events: wc_events$1 + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains$1, + methods: wc_aleo_methods$1, events: wc_events$1 } } - }); + }, showModal); setData(response); await checkForDesktopConnection$1(response.topic); const account = response.namespaces["aleo"]["accounts"][0].split(":"); @@ -22065,7 +29195,9 @@ shortenedAddress: shortenAddress(account[2]) }); emitter$1.emit("session_change"); - const choice = window.localStorage.getItem("WALLETCONNECT_DEEPLINK_CHOICE"); + const choice = window.localStorage.getItem( + "WALLETCONNECT_DEEPLINK_CHOICE" + ); if (choice && JSON.parse(choice).name !== "Android") { window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE"); } @@ -22082,7 +29214,8 @@ } const useCreateSharedState = () => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22091,7 +29224,7 @@ } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "createSharedState", @@ -22109,7 +29242,8 @@ }; const useDecrypt = (ciphertexts) => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22118,7 +29252,7 @@ } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "decrypt", @@ -22175,10 +29309,10 @@ const useEvent = ({ id, address, multisig = false }) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getEvent", @@ -22216,14 +29350,16 @@ { subscriptionName: "onSelectedAccountSynced", condition: () => !!id && !multisig, - onData: () => refetch() + onData: () => refetch(), + dependencies: [id, multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data2) => { return !!id && !!multisig && (data2 == null ? void 0 : data2.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [id, multisig, address] } ] }); @@ -22256,10 +29392,10 @@ if ((filter == null ? void 0 : filter.programId) === "") { filter.programId = void 0; } - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getEvents", @@ -22279,7 +29415,7 @@ queryKey: [ "useEvents", account == null ? void 0 : account.address, - debouncedFilter, + JSON.stringify(debouncedFilter), page, session == null ? void 0 : session.topic ], @@ -22296,7 +29432,8 @@ { subscriptionName: "onSelectedAccountSynced", condition: () => true, - onData: () => refetch() + onData: () => refetch(), + dependencies: [] } ] }); @@ -22325,7 +29462,8 @@ }; const useImportSharedState = (seed) => { const session = useWalletSession(); - const useRequestFunction = hasInjectedConnection$1() ? useExtensionRequest : useRequest; + const [account] = useWalletStore((state) => [state.account]); + const useRequestFunction = hasInjectedConnection$1() ? useInjectedRequest : useRequest; const { request, data: wc_data, @@ -22334,7 +29472,7 @@ } = useRequestFunction( { topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "importSharedState", @@ -22344,8 +29482,8 @@ } }, (params) => { - var _a; - return (_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient.importSharedState.mutate(params); + var _a2; + return (_a2 = window.aleo) == null ? void 0 : _a2.puzzleWalletClient.importSharedState.mutate(params); } ); const error = wc_error ? wc_error.message : wc_data && wc_data.error; @@ -22372,10 +29510,10 @@ }) => { const session = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); - const useQueryFunction = hasInjectedConnection$1() ? useExtensionRequestQuery : useRequestQuery; + const useQueryFunction = hasInjectedConnection$1() ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session == null ? void 0 : session.topic, - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "getRecords", @@ -22398,7 +29536,7 @@ account == null ? void 0 : account.address, address, multisig, - debouncedFilter, + JSON.stringify(debouncedFilter), page, session == null ? void 0 : session.topic ], @@ -22416,14 +29554,16 @@ { subscriptionName: "onSelectedAccountSynced", condition: () => !multisig, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig] }, { subscriptionName: "onSharedAccountSynced", condition: (data2) => { return !!multisig && (data2 == null ? void 0 : data2.address) === address; }, - onData: () => refetch() + onData: () => refetch(), + dependencies: [multisig, address] } ] }); @@ -22448,6 +29588,7 @@ }; const useRequestCreateEvent = (requestData) => { const session = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const inputs = requestData == null ? void 0 : requestData.inputs.map((input) => { if (typeof input === "string") { return input; @@ -22461,7 +29602,7 @@ loading } = useRequest({ topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "requestCreateEvent", @@ -22835,7 +29976,7 @@ path: fullPath }; let errorMessage = ""; - const maps = errorMaps.filter((m2) => !!m2).slice().reverse(); + const maps = errorMaps.filter((m3) => !!m3).slice().reverse(); for (const map of maps) { errorMessage = map(fullIssue, { data: data2, defaultError: errorMessage }).message; } @@ -22875,12 +30016,12 @@ } static mergeArray(status, results2) { const arrayValue = []; - for (const s2 of results2) { - if (s2.status === "aborted") + for (const s3 of results2) { + if (s3.status === "aborted") return INVALID; - if (s2.status === "dirty") + if (s3.status === "dirty") status.dirty(); - arrayValue.push(s2.value); + arrayValue.push(s3.value); } return { status: status.value, value: arrayValue }; } @@ -23059,11 +30200,11 @@ throw result.error; } safeParse(data2, params) { - var _a; + var _a2; const ctx = { common: { issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap }, path: (params === null || params === void 0 ? void 0 : params.path) || [], @@ -23419,7 +30560,7 @@ } else if (check.kind === "url") { try { new URL(input.data); - } catch (_a) { + } catch (_a2) { ctx = this._getOrReturnCtx(input, ctx); addIssueToContext(ctx, { validation: "url", @@ -23534,7 +30675,7 @@ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); } datetime(options) { - var _a; + var _a2; if (typeof options === "string") { return this._addCheck({ kind: "datetime", @@ -23546,7 +30687,7 @@ return this._addCheck({ kind: "datetime", precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) }); } @@ -23601,59 +30742,59 @@ }); } get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); + return !!this._def.checks.find((ch2) => ch2.kind === "datetime"); } get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); + return !!this._def.checks.find((ch2) => ch2.kind === "email"); } get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); + return !!this._def.checks.find((ch2) => ch2.kind === "url"); } get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); + return !!this._def.checks.find((ch2) => ch2.kind === "emoji"); } get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); + return !!this._def.checks.find((ch2) => ch2.kind === "uuid"); } get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); + return !!this._def.checks.find((ch2) => ch2.kind === "cuid"); } get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); + return !!this._def.checks.find((ch2) => ch2.kind === "cuid2"); } get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); + return !!this._def.checks.find((ch2) => ch2.kind === "ulid"); } get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); + return !!this._def.checks.find((ch2) => ch2.kind === "ip"); } get minLength() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxLength() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } } ZodString.create = (params) => { - var _a; + var _a2; return new ZodString({ checks: [], typeName: ZodFirstPartyTypeKind.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, ...processCreateParams(params) }); }; @@ -23851,38 +30992,38 @@ } get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); + return !!this._def.checks.find((ch2) => ch2.kind === "int" || ch2.kind === "multipleOf" && util.isInteger(ch2.value)); } get isFinite() { let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { + for (const ch2 of this._def.checks) { + if (ch2.kind === "finite" || ch2.kind === "int" || ch2.kind === "multipleOf") { return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + } else if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; + } else if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return Number.isFinite(min) && Number.isFinite(max); @@ -24034,31 +31175,31 @@ } get minValue() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min; } get maxValue() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max; } } ZodBigInt.create = (params) => { - var _a; + var _a2; return new ZodBigInt({ checks: [], typeName: ZodFirstPartyTypeKind.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, ...processCreateParams(params) }); }; @@ -24169,20 +31310,20 @@ } get minDate() { let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "min") { + if (min === null || ch2.value > min) + min = ch2.value; } } return min != null ? new Date(min) : null; } get maxDate() { let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; + for (const ch2 of this._def.checks) { + if (ch2.kind === "max") { + if (max === null || ch2.value < max) + max = ch2.value; } } return max != null ? new Date(max) : null; @@ -24564,8 +31705,8 @@ unknownKeys: "strict", ...message !== void 0 ? { errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; if (issue.code === "unrecognized_keys") return { message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError @@ -25383,7 +32524,7 @@ }); } const params = { errorMap: ctx.common.contextualErrorMap }; - const fn2 = ctx.data; + const fn = ctx.data; if (this._def.returns instanceof ZodPromise) { return OK(async (...args) => { const error = new ZodError([]); @@ -25391,7 +32532,7 @@ error.addIssue(makeArgsIssue(args, e2)); throw error; }); - const result = await fn2(...parsedArgs); + const result = await fn(...parsedArgs); const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e2) => { error.addIssue(makeReturnsIssue(result, e2)); throw error; @@ -25404,7 +32545,7 @@ if (!parsedArgs.success) { throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); } - const result = fn2(...parsedArgs.data); + const result = fn(...parsedArgs.data); const parsedReturns = this._def.returns.safeParse(result, params); if (!parsedReturns.success) { throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); @@ -25943,11 +33084,11 @@ const custom = (check, params = {}, fatal) => { if (check) return ZodAny.create().superRefine((data2, ctx) => { - var _a, _b; + var _a2, _b; if (!check(data2)) { - const p3 = typeof params === "function" ? params(data2) : params; - const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p22 = typeof p3 === "string" ? { message: p3 } : p3; + const p2 = typeof params === "function" ? params(data2) : params; + const _fatal = (_b = (_a2 = p2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p2 === "string" ? { message: p2 } : p2; ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); } }); @@ -26162,6 +33303,7 @@ const aleoAddressRegex = /^aleo1[a-z0-9]{58}$/i; const aleoViewKeyRegex = /^AViewKey1[a-z0-9]{44}$/i; const aleoPrivateKeyRegex = /^APrivateKey1[a-z0-9]{47}$/i; + const aleoTransitionIdRegex = /^au1[a-z0-9]{58}$/i; const aleoTransactionIdRegex = /^at1[a-z0-9]{58}$/i; const aleoFieldRegex = /^\d+field$/; const aleoU32 = /^\d+u32$/; @@ -26169,6 +33311,7 @@ const zodAddress = z$1.string().regex(aleoAddressRegex); const zodViewKey = z$1.string().regex(aleoViewKeyRegex); const zodPrivateKey = z$1.string().regex(aleoPrivateKeyRegex); + z$1.string().regex(aleoTransitionIdRegex); const zodTransactionId = z$1.string().regex(aleoTransactionIdRegex); const zodField = z$1.string().regex(aleoFieldRegex); const zodU32 = z$1.string().regex(aleoU32); @@ -26193,6 +33336,9 @@ EventType2["Split"] = "Split"; EventType2["Shield"] = "Shield"; EventType2["Unshield"] = "Unshield"; + EventType2["Referral"] = "Referral"; + EventType2["Points"] = "Points"; + EventType2["Raffle"] = "Raffle"; })(exports2.EventType || (exports2.EventType = {})); exports2.EventStatus = void 0; (function(EventStatus2) { @@ -26209,18 +33355,16 @@ exports2.Network = void 0; (function(Network2) { Network2["AleoTestnet"] = "AleoTestnet"; + Network2["AleoCanarynet"] = "AleoCanarynet"; Network2["AleoMainnet"] = "AleoMainnet"; })(exports2.Network || (exports2.Network = {})); - exports2.AssetType = void 0; - (function(AssetType2) { - AssetType2[AssetType2["ALEO"] = 0] = "ALEO"; - })(exports2.AssetType || (exports2.AssetType = {})); const zodEventType = z$1.nativeEnum(exports2.EventType); const zodEventStatus = z$1.nativeEnum(exports2.EventStatus); const zodNetwork = z$1.nativeEnum(exports2.Network); const zodVisibility = z$1.nativeEnum(exports2.Visibility); - const useRequestSignature = (message, address) => { + const useRequestSignature = ({ message, address, method, network }) => { const session = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const { request, data: wc_data, @@ -26228,13 +33372,14 @@ loading } = useRequest({ topic: (session == null ? void 0 : session.topic) ?? "", - chainId: "aleo:1", + chainId: account ? `${account.network}:${account.chainId}` : "aleo:1", request: { jsonrpc: "2.0", method: "requestSignature", params: { message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method } } }); @@ -26261,7 +33406,15 @@ "importSharedState", "requestSignature" ]; - const wc_aleo_chains = ["aleo:1"]; + const wc_required_aleo_chains = ["aleo:1"]; + const wc_optional_aleo_chains = [ + "aleo:0" + // for eventual mainnet + ]; + const wc_aleo_chains = [ + ...wc_required_aleo_chains, + ...wc_optional_aleo_chains + ]; const wc_events = [ "chainChanged", "accountSelected", @@ -26270,16 +33423,18 @@ ]; const projectId = "f0aaeffe71b636da453fce042d79d723"; function isAndroid() { - if (!navigator) { + if (typeof navigator === "undefined") { return false; } return /Android/i.test(navigator.userAgent); } const web3modal_puzzle_props_android = { projectId, - chains: ["aleo:3"], + chains: wc_aleo_chains, enableExplorer: true, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], mobileWallets: [ { id: "puzzle", @@ -26298,7 +33453,9 @@ projectId, chains: wc_aleo_chains, enableExplorer: false, - explorerRecommendedWalletIds: ["7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a"], + explorerRecommendedWalletIds: [ + "7ee7b95f4ae8b3e08aab5158be7fe8e71f79bcd3717594254b34fa1f3cd4611a" + ], mobileWallets: [ { id: "puzzle", @@ -26342,9 +33499,32 @@ } } }; + const networkToChainId = (network, includePrefix = true) => { + let chain; + switch (network) { + case exports2.Network.AleoMainnet: + chain = "aleo:0"; + break; + case exports2.Network.AleoCanarynet: + chain = "aleo:0"; + break; + case exports2.Network.AleoTestnet: + chain = "aleo:1"; + break; + } + return includePrefix ? chain : chain.replace("aleo:", ""); + }; + const chainIdToNetwork = (chainId) => { + switch (chainId) { + case "aleo:0": + return exports2.Network.AleoCanarynet; + case "aleo:1": + return exports2.Network.AleoTestnet; + } + }; const name = "@puzzlehq/sdk-core"; const displayName = "Puzzle SDK"; - const version$1 = "0.3.1"; + const version$1 = "0.4.0"; const description = "Your portal to privacy"; const main = "./dist/puzzle.cjs.js"; const module2 = "./dist/puzzle.es.js"; @@ -26370,8 +33550,8 @@ url: "git+https://github.com/puzzlehq/puzzle-sdk.git" }; const dependencies = { - "@puzzlehq/types": "1.0.11", - "@walletconnect/modal-sign-html": "^2.6.2", + "@puzzlehq/types": "1.0.21", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", "@walletconnect/types": "^2.11.2", "@walletconnect/utils": "^2.11.2", debug: "^4.3.4", @@ -26431,7 +33611,7 @@ localStorage.setItem("puzzle_sdk_version", thisVersion); disconnectSessions = true; } - exports2.connection = new modalSignHtml.WalletConnectModalSign({ + exports2.connection = new walletconnectModalSignHtml.WalletConnectModalSign({ projectId: options.projectId ?? projectId, metadata: { name: options.dAppName, @@ -26498,9 +33678,10 @@ }); } const checkForDesktopConnection = async (sessionTopic) => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { + console.log("!!window?.aleo?.puzzleWalletClient", injectedConnection); localStorage.setItem("puzzle-hasInjectedConnection", "false"); return false; } @@ -26522,9 +33703,9 @@ } }; const hasInjectedConnection = () => { - var _a; - const extensionDownloaded = !!((_a = window == null ? void 0 : window.aleo) == null ? void 0 : _a.puzzleWalletClient); - if (!extensionDownloaded) { + var _a2; + const injectedConnection = !!((_a2 = window == null ? void 0 : window.aleo) == null ? void 0 : _a2.puzzleWalletClient); + if (!injectedConnection) { return false; } const puzzleHasDesktopConnection = localStorage.getItem( @@ -26532,15 +33713,18 @@ ); return puzzleHasDesktopConnection === "true"; }; - const getAccount = async () => { + const getAccount = async (network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await connection2.getSession(); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getSelectedAccount" @@ -26565,21 +33749,24 @@ } }; const getBalance = async ({ - address + address, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await connection2.getSession(); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getBalance", params: { - assetId: void 0, address } } @@ -26603,10 +33790,10 @@ return { error }; } }; - const connect = async () => { + const connect = async (showModal = true) => { const connection2 = await getWalletConnectModalSignClient(); if (!connection2) { - throw new Error("call setConnection() first!"); + throw new Error("call configureConnection() first!"); } const existingSession = await connection2.getSession(); if (existingSession) { @@ -26618,11 +33805,18 @@ requiredNamespaces: { aleo: { methods: wc_aleo_methods, - chains: wc_aleo_chains, + chains: wc_required_aleo_chains, + events: wc_events + } + }, + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains, + methods: wc_aleo_methods, events: wc_events } } - }); + }, showModal); emitter.emit("session_change"); if (newSession) { await checkForDesktopConnection(newSession.topic); @@ -26636,7 +33830,7 @@ console.error("connect error", e2); } }; - const requestCreateEvent = async (requestData) => { + const requestCreateEvent = async (requestData, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { @@ -26648,10 +33842,13 @@ } return input.plaintext; }); + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } try { const response = await connection2.request({ topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "requestCreateEvent", @@ -26668,15 +33865,18 @@ return { error }; } }; - const createSharedState = async () => { + const createSharedState = async (network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "createSharedState", @@ -26685,9 +33885,7 @@ }; if (hasInjectedConnection()) { try { - const response = await window.aleo.puzzleWalletClient.createSharedState.mutate( - query - ); + const response = await window.aleo.puzzleWalletClient.createSharedState.mutate(query); return response; } catch (e2) { console.error("createSharedState error", e2); @@ -26704,15 +33902,18 @@ return { error }; } }; - const decrypt = async (ciphertexts) => { + const decrypt = async (ciphertexts, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "decrypt", @@ -26765,16 +33966,20 @@ }; const getEvent = async ({ id, - address + address, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { event: void 0, error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getEvent", @@ -26807,7 +34012,7 @@ return { error }; } }; - const getEvents = async (filter) => { + const getEvents = async (filter, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { @@ -26816,9 +34021,15 @@ if ((filter == null ? void 0 : filter.programId) === "") { filter.programId = void 0; } + if (!session || !connection2) { + return { error: "no session or connection" }; + } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getEvents", @@ -26851,15 +34062,18 @@ return { error }; } }; - const importSharedState = async (seed) => { + const importSharedState = async (seed, network) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "importSharedState", @@ -26890,16 +34104,20 @@ const getRecords = async ({ address, filter, - page = 0 + page = 0, + network }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } const query = { topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "getRecords", @@ -26935,23 +34153,29 @@ }; const requestSignature = async ({ message, - address + address, + network, + method }) => { const connection2 = await getWalletConnectModalSignClient(); const session = await (connection2 == null ? void 0 : connection2.getSession()); if (!session || !connection2) { return { error: "no session or connection" }; } + if (network && !wc_aleo_chains.includes(network)) { + return { error: "network not in wc_aleo_chains" }; + } try { const response = await connection2.request({ topic: session.topic, - chainId: "aleo:1", + chainId: network ?? "aleo:1", request: { jsonrpc: "2.0", method: "requestSignature", params: { message, - address: aleoAddressRegex.test(address ?? "") ? address : void 0 + address: aleoAddressRegex.test(address ?? "") ? address : void 0, + method } } }); @@ -26970,19 +34194,19 @@ * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ - const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$3 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); + const t$3 = window, e$5 = t$3.ShadowRoot && (void 0 === t$3.ShadyCSS || t$3.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$4 = Symbol(), n$5 = /* @__PURE__ */ new WeakMap(); let o$4 = class o { - constructor(t2, e2, n22) { - if (this._$cssResult$ = true, n22 !== s$3) + constructor(t2, e2, n2) { + if (this._$cssResult$ = true, n2 !== s$4) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t2, this.t = e2; } get styleSheet() { let t2 = this.o; - const s2 = this.t; + const s3 = this.t; if (e$5 && void 0 === t2) { - const e2 = void 0 !== s2 && 1 === s2.length; - e2 && (t2 = n$5.get(s2)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s2, t2)); + const e2 = void 0 !== s3 && 1 === s3.length; + e2 && (t2 = n$5.get(s3)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && n$5.set(s3, t2)); } return t2; } @@ -26990,24 +34214,24 @@ return this.cssText; } }; - const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$3), i$3 = (t2, ...e2) => { - const n22 = 1 === t2.length ? t2[0] : e2.reduce((e3, s2, n3) => e3 + ((t3) => { + const r$2 = (t2) => new o$4("string" == typeof t2 ? t2 : t2 + "", void 0, s$4), i$3 = (t2, ...e2) => { + const n2 = 1 === t2.length ? t2[0] : e2.reduce((e3, s3, n32) => e3 + ((t3) => { if (true === t3._$cssResult$) return t3.cssText; if ("number" == typeof t3) return t3; throw Error("Value passed to 'css' function must be a 'css' function result: " + t3 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); - })(s2) + t2[n3 + 1], t2[0]); - return new o$4(n22, t2, s$3); - }, S$2 = (s2, n22) => { - e$5 ? s2.adoptedStyleSheets = n22.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n22.forEach((e2) => { - const n3 = document.createElement("style"), o3 = t$3.litNonce; - void 0 !== o3 && n3.setAttribute("nonce", o3), n3.textContent = e2.cssText, s2.appendChild(n3); + })(s3) + t2[n32 + 1], t2[0]); + return new o$4(n2, t2, s$4); + }, S$2 = (s3, n2) => { + e$5 ? s3.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((e2) => { + const n32 = document.createElement("style"), o3 = t$3.litNonce; + void 0 !== o3 && n32.setAttribute("nonce", o3), n32.textContent = e2.cssText, s3.appendChild(n32); }); - }, c$2 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { + }, c$1 = e$5 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => { let e2 = ""; - for (const s2 of t3.cssRules) - e2 += s2.cssText; + for (const s3 of t3.cssRules) + e2 += s3.cssText; return r$2(e2); })(t2) : t2; /** @@ -27015,7 +34239,7 @@ * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ - var s$2; + var s$3; const e$4 = window, r$1 = e$4.trustedTypes, h$2 = r$1 ? r$1.emptyScript : "", o$3 = e$4.reactiveElementPolyfillSupport, n$4 = { toAttribute(t2, i2) { switch (i2) { case Boolean: @@ -27027,23 +34251,23 @@ } return t2; }, fromAttribute(t2, i2) { - let s2 = t2; + let s3 = t2; switch (i2) { case Boolean: - s2 = null !== t2; + s3 = null !== t2; break; case Number: - s2 = null === t2 ? null : Number(t2); + s3 = null === t2 ? null : Number(t2); break; case Object: case Array: try { - s2 = JSON.parse(t2); + s3 = JSON.parse(t2); } catch (t3) { - s2 = null; + s3 = null; } } - return s2; + return s3; } }, a$1 = (t2, i2) => i2 !== t2 && (i2 == i2 || t2 == t2), l$3 = { attribute: true, type: String, converter: n$4, reflect: false, hasChanged: a$1 }, d$1 = "finalized"; let u$1 = class u extends HTMLElement { constructor() { @@ -27056,23 +34280,23 @@ static get observedAttributes() { this.finalize(); const t2 = []; - return this.elementProperties.forEach((i2, s2) => { - const e2 = this._$Ep(s2, i2); - void 0 !== e2 && (this._$Ev.set(e2, s2), t2.push(e2)); + return this.elementProperties.forEach((i2, s3) => { + const e2 = this._$Ep(s3, i2); + void 0 !== e2 && (this._$Ev.set(e2, s3), t2.push(e2)); }), t2; } static createProperty(t2, i2 = l$3) { if (i2.state && (i2.attribute = false), this.finalize(), this.elementProperties.set(t2, i2), !i2.noAccessor && !this.prototype.hasOwnProperty(t2)) { - const s2 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s2, i2); + const s3 = "symbol" == typeof t2 ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s3, i2); void 0 !== e2 && Object.defineProperty(this.prototype, t2, e2); } } - static getPropertyDescriptor(t2, i2, s2) { + static getPropertyDescriptor(t2, i2, s3) { return { get() { return this[i2]; }, set(e2) { - const r2 = this[t2]; - this[i2] = e2, this.requestUpdate(t2, r2, s2); + const r22 = this[t2]; + this[i2] = e2, this.requestUpdate(t2, r22, s3); }, configurable: true, enumerable: true }; } static getPropertyOptions(t2) { @@ -27085,32 +34309,32 @@ const t2 = Object.getPrototypeOf(this); if (t2.finalize(), void 0 !== t2.h && (this.h = [...t2.h]), this.elementProperties = new Map(t2.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { const t3 = this.properties, i2 = [...Object.getOwnPropertyNames(t3), ...Object.getOwnPropertySymbols(t3)]; - for (const s2 of i2) - this.createProperty(s2, t3[s2]); + for (const s3 of i2) + this.createProperty(s3, t3[s3]); } return this.elementStyles = this.finalizeStyles(this.styles), true; } static finalizeStyles(i2) { - const s2 = []; + const s3 = []; if (Array.isArray(i2)) { const e2 = new Set(i2.flat(1 / 0).reverse()); for (const i3 of e2) - s2.unshift(c$2(i3)); + s3.unshift(c$1(i3)); } else - void 0 !== i2 && s2.push(c$2(i2)); - return s2; + void 0 !== i2 && s3.push(c$1(i2)); + return s3; } static _$Ep(t2, i2) { - const s2 = i2.attribute; - return false === s2 ? void 0 : "string" == typeof s2 ? s2 : "string" == typeof t2 ? t2.toLowerCase() : void 0; + const s3 = i2.attribute; + return false === s3 ? void 0 : "string" == typeof s3 ? s3 : "string" == typeof t2 ? t2.toLowerCase() : void 0; } _$Eu() { var t2; this._$E_ = new Promise((t3) => this.enableUpdating = t3), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t2 = this.constructor.h) || void 0 === t2 || t2.forEach((t3) => t3(this)); } addController(t2) { - var i2, s2; - (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s2 = t2.hostConnected) || void 0 === s2 || s2.call(t2)); + var i2, s3; + (null !== (i2 = this._$ES) && void 0 !== i2 ? i2 : this._$ES = []).push(t2), void 0 !== this.renderRoot && this.isConnected && (null === (s3 = t2.hostConnected) || void 0 === s3 || s3.call(t2)); } removeController(t2) { var i2; @@ -27123,8 +34347,8 @@ } createRenderRoot() { var t2; - const s2 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); - return S$2(s2, this.constructor.elementStyles), s2; + const s3 = null !== (t2 = this.shadowRoot) && void 0 !== t2 ? t2 : this.attachShadow(this.constructor.shadowRootOptions); + return S$2(s3, this.constructor.elementStyles), s3; } connectedCallback() { var t2; @@ -27142,28 +34366,28 @@ return null === (i2 = t3.hostDisconnected) || void 0 === i2 ? void 0 : i2.call(t3); }); } - attributeChangedCallback(t2, i2, s2) { - this._$AK(t2, s2); + attributeChangedCallback(t2, i2, s3) { + this._$AK(t2, s3); } - _$EO(t2, i2, s2 = l$3) { + _$EO(t2, i2, s3 = l$3) { var e2; - const r2 = this.constructor._$Ep(t2, s2); - if (void 0 !== r2 && true === s2.reflect) { - const h2 = (void 0 !== (null === (e2 = s2.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s2.converter : n$4).toAttribute(i2, s2.type); - this._$El = t2, null == h2 ? this.removeAttribute(r2) : this.setAttribute(r2, h2), this._$El = null; + const r22 = this.constructor._$Ep(t2, s3); + if (void 0 !== r22 && true === s3.reflect) { + const h2 = (void 0 !== (null === (e2 = s3.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s3.converter : n$4).toAttribute(i2, s3.type); + this._$El = t2, null == h2 ? this.removeAttribute(r22) : this.setAttribute(r22, h2), this._$El = null; } } _$AK(t2, i2) { - var s2; - const e2 = this.constructor, r2 = e2._$Ev.get(t2); - if (void 0 !== r2 && this._$El !== r2) { - const t3 = e2.getPropertyOptions(r2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s2 = t3.converter) || void 0 === s2 ? void 0 : s2.fromAttribute) ? t3.converter : n$4; - this._$El = r2, this[r2] = h2.fromAttribute(i2, t3.type), this._$El = null; + var s3; + const e2 = this.constructor, r22 = e2._$Ev.get(t2); + if (void 0 !== r22 && this._$El !== r22) { + const t3 = e2.getPropertyOptions(r22), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== (null === (s3 = t3.converter) || void 0 === s3 ? void 0 : s3.fromAttribute) ? t3.converter : n$4; + this._$El = r22, this[r22] = h2.fromAttribute(i2, t3.type), this._$El = null; } } - requestUpdate(t2, i2, s2) { + requestUpdate(t2, i2, s3) { let e2 = true; - void 0 !== t2 && (((s2 = s2 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s2.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s2))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); + void 0 !== t2 && (((s3 = s3 || this.constructor.getPropertyOptions(t2)).hasChanged || a$1)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), true === s3.reflect && this._$El !== t2 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s3))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej()); } async _$Ej() { this.isUpdatePending = true; @@ -27184,16 +34408,16 @@ return; this.hasUpdated, this._$Ei && (this._$Ei.forEach((t3, i3) => this[i3] = t3), this._$Ei = void 0); let i2 = false; - const s2 = this._$AL; + const s3 = this._$AL; try { - i2 = this.shouldUpdate(s2), i2 ? (this.willUpdate(s2), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { + i2 = this.shouldUpdate(s3), i2 ? (this.willUpdate(s3), null === (t2 = this._$ES) || void 0 === t2 || t2.forEach((t3) => { var i3; return null === (i3 = t3.hostUpdate) || void 0 === i3 ? void 0 : i3.call(t3); - }), this.update(s2)) : this._$Ek(); + }), this.update(s3)) : this._$Ek(); } catch (t3) { throw i2 = false, this._$Ek(), t3; } - i2 && this._$AE(s2); + i2 && this._$AE(s3); } willUpdate(t2) { } @@ -27224,40 +34448,40 @@ firstUpdated(t2) { } }; - u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$2 = e$4.reactiveElementVersions) && void 0 !== s$2 ? s$2 : e$4.reactiveElementVersions = []).push("1.6.3"); + u$1[d$1] = true, u$1.elementProperties = /* @__PURE__ */ new Map(), u$1.elementStyles = [], u$1.shadowRootOptions = { mode: "open" }, null == o$3 || o$3({ ReactiveElement: u$1 }), (null !== (s$3 = e$4.reactiveElementVersions) && void 0 !== s$3 ? s$3 : e$4.reactiveElementVersions = []).push("1.6.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ var t$2; - const i$2 = window, s$1 = i$2.trustedTypes, e$3 = s$1 ? s$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c$1 = Array.isArray, v$1 = (t2) => c$1(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), b = w(2), T$1 = Symbol.for("lit-noChange"), A$1 = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); - function P(t2, i2) { + const i$2 = window, s$2 = i$2.trustedTypes, e$3 = s$2 ? s$2.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o$2 = "$lit$", n$3 = `lit$${(Math.random() + "").slice(9)}$`, l$2 = "?" + n$3, h$1 = `<${l$2}>`, r = document, u2 = () => r.createComment(""), d = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _$1 = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s3) => ({ _$litType$: t2, strings: i2, values: s3 }), x = w(1), b$1 = w(2), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false); + function P$1(t2, i2) { if (!Array.isArray(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array"); return void 0 !== e$3 ? e$3.createHTML(i2) : i2; } const V = (t2, i2) => { - const s2 = t2.length - 1, e2 = []; - let l2, r2 = 2 === i2 ? "" : "", u3 = f; - for (let i3 = 0; i3 < s2; i3++) { - const s3 = t2[i3]; - let d22, c2, v22 = -1, a22 = 0; - for (; a22 < s3.length && (u3.lastIndex = a22, c2 = u3.exec(s3), null !== c2); ) - a22 = u3.lastIndex, u3 === f ? "!--" === c2[1] ? u3 = _$1 : void 0 !== c2[1] ? u3 = m : void 0 !== c2[2] ? (y.test(c2[2]) && (l2 = RegExp("" === c2[0] ? (u3 = null != l2 ? l2 : f, v22 = -1) : void 0 === c2[1] ? v22 = -2 : (v22 = u3.lastIndex - c2[2].length, d22 = c2[1], u3 = void 0 === c2[3] ? p : '"' === c2[3] ? $ : g) : u3 === $ || u3 === g ? u3 = p : u3 === _$1 || u3 === m ? u3 = f : (u3 = p, l2 = void 0); + const s3 = t2.length - 1, e2 = []; + let l2, r22 = 2 === i2 ? "" : "", u3 = f; + for (let i3 = 0; i3 < s3; i3++) { + const s4 = t2[i3]; + let d2, c2, v22 = -1, a22 = 0; + for (; a22 < s4.length && (u3.lastIndex = a22, c2 = u3.exec(s4), null !== c2); ) + a22 = u3.lastIndex, u3 === f ? "!--" === c2[1] ? u3 = _$1 : void 0 !== c2[1] ? u3 = m : void 0 !== c2[2] ? (y.test(c2[2]) && (l2 = RegExp("" === c2[0] ? (u3 = null != l2 ? l2 : f, v22 = -1) : void 0 === c2[1] ? v22 = -2 : (v22 = u3.lastIndex - c2[2].length, d2 = c2[1], u3 = void 0 === c2[3] ? p : '"' === c2[3] ? $ : g) : u3 === $ || u3 === g ? u3 = p : u3 === _$1 || u3 === m ? u3 = f : (u3 = p, l2 = void 0); const w22 = u3 === p && t2[i3 + 1].startsWith("/>") ? " " : ""; - r2 += u3 === f ? s3 + h$1 : v22 >= 0 ? (e2.push(d22), s3.slice(0, v22) + o$2 + s3.slice(v22) + n$3 + w22) : s3 + n$3 + (-2 === v22 ? (e2.push(void 0), i3) : w22); + r22 += u3 === f ? s4 + h$1 : v22 >= 0 ? (e2.push(d2), s4.slice(0, v22) + o$2 + s4.slice(v22) + n$3 + w22) : s4 + n$3 + (-2 === v22 ? (e2.push(void 0), i3) : w22); } - return [P(t2, r2 + (t2[s2] || "") + (2 === i2 ? "" : "")), e2]; + return [P$1(t2, r22 + (t2[s3] || "") + (2 === i2 ? "" : "")), e2]; }; - class N { + let N$1 = class N3 { constructor({ strings: t2, _$litType$: i2 }, e2) { let h2; this.parts = []; - let r2 = 0, d22 = 0; - const c2 = t2.length - 1, v22 = this.parts, [a22, f2] = V(t2, i2); - if (this.el = N.createElement(a22, e2), C.currentNode = this.el.content, 2 === i2) { + let r22 = 0, d2 = 0; + const c2 = t2.length - 1, v22 = this.parts, [a22, f22] = V(t2, i2); + if (this.el = N3.createElement(a22, e2), C.currentNode = this.el.content, 2 === i2) { const t3 = this.el.content, i3 = t3.firstChild; i3.remove(), t3.append(...i3.childNodes); } @@ -27267,12 +34491,12 @@ const t3 = []; for (const i3 of h2.getAttributeNames()) if (i3.endsWith(o$2) || i3.startsWith(n$3)) { - const s2 = f2[d22++]; - if (t3.push(i3), void 0 !== s2) { - const t4 = h2.getAttribute(s2.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s2); - v22.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? H : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); + const s3 = f22[d2++]; + if (t3.push(i3), void 0 !== s3) { + const t4 = h2.getAttribute(s3.toLowerCase() + o$2).split(n$3), i4 = /([.?@])?(.*)/.exec(s3); + v22.push({ type: 1, index: r22, name: i4[2], strings: t4, ctor: "." === i4[1] ? H$1 : "?" === i4[1] ? L$1 : "@" === i4[1] ? z : k }); } else - v22.push({ type: 6, index: r2 }); + v22.push({ type: 6, index: r22 }); } for (const i3 of t3) h2.removeAttribute(i3); @@ -27280,35 +34504,35 @@ if (y.test(h2.tagName)) { const t3 = h2.textContent.split(n$3), i3 = t3.length - 1; if (i3 > 0) { - h2.textContent = s$1 ? s$1.emptyScript : ""; - for (let s2 = 0; s2 < i3; s2++) - h2.append(t3[s2], u2()), C.nextNode(), v22.push({ type: 2, index: ++r2 }); + h2.textContent = s$2 ? s$2.emptyScript : ""; + for (let s3 = 0; s3 < i3; s3++) + h2.append(t3[s3], u2()), C.nextNode(), v22.push({ type: 2, index: ++r22 }); h2.append(t3[i3], u2()); } } } else if (8 === h2.nodeType) if (h2.data === l$2) - v22.push({ type: 2, index: r2 }); + v22.push({ type: 2, index: r22 }); else { let t3 = -1; for (; -1 !== (t3 = h2.data.indexOf(n$3, t3 + 1)); ) - v22.push({ type: 7, index: r2 }), t3 += n$3.length - 1; + v22.push({ type: 7, index: r22 }), t3 += n$3.length - 1; } - r2++; + r22++; } } static createElement(t2, i2) { - const s2 = r.createElement("template"); - return s2.innerHTML = t2, s2; + const s3 = r.createElement("template"); + return s3.innerHTML = t2, s3; } - } - function S$1(t2, i2, s2 = t2, e2) { - var o3, n22, l2, h2; - if (i2 === T$1) + }; + function S$1(t2, i2, s3 = t2, e2) { + var o3, n2, l2, h2; + if (i2 === T) return i2; - let r2 = void 0 !== e2 ? null === (o3 = s2._$Co) || void 0 === o3 ? void 0 : o3[e2] : s2._$Cl; + let r22 = void 0 !== e2 ? null === (o3 = s3._$Co) || void 0 === o3 ? void 0 : o3[e2] : s3._$Cl; const u3 = d(i2) ? void 0 : i2._$litDirective$; - return (null == r2 ? void 0 : r2.constructor) !== u3 && (null === (n22 = null == r2 ? void 0 : r2._$AO) || void 0 === n22 || n22.call(r2, false), void 0 === u3 ? r2 = void 0 : (r2 = new u3(t2), r2._$AT(t2, s2, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s2)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s2._$Cl = r2), void 0 !== r2 && (i2 = S$1(t2, r2._$AS(t2, i2.values), r2, e2)), i2; + return (null == r22 ? void 0 : r22.constructor) !== u3 && (null === (n2 = null == r22 ? void 0 : r22._$AO) || void 0 === n2 || n2.call(r22, false), void 0 === u3 ? r22 = void 0 : (r22 = new u3(t2), r22._$AT(t2, s3, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s3)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r22 : s3._$Cl = r22), void 0 !== r22 && (i2 = S$1(t2, r22._$AS(t2, i2.values), r22, e2)), i2; } class M { constructor(t2, i2) { @@ -27322,28 +34546,28 @@ } u(t2) { var i2; - const { el: { content: s2 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s2, true); + const { el: { content: s3 }, parts: e2 } = this._$AD, o3 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s3, true); C.currentNode = o3; - let n22 = C.nextNode(), l2 = 0, h2 = 0, u3 = e2[0]; + let n2 = C.nextNode(), l2 = 0, h2 = 0, u3 = e2[0]; for (; void 0 !== u3; ) { if (l2 === u3.index) { let i3; - 2 === u3.type ? i3 = new R(n22, n22.nextSibling, this, t2) : 1 === u3.type ? i3 = new u3.ctor(n22, u3.name, u3.strings, this, t2) : 6 === u3.type && (i3 = new Z$1(n22, this, t2)), this._$AV.push(i3), u3 = e2[++h2]; + 2 === u3.type ? i3 = new R(n2, n2.nextSibling, this, t2) : 1 === u3.type ? i3 = new u3.ctor(n2, u3.name, u3.strings, this, t2) : 6 === u3.type && (i3 = new Z$1(n2, this, t2)), this._$AV.push(i3), u3 = e2[++h2]; } - l2 !== (null == u3 ? void 0 : u3.index) && (n22 = C.nextNode(), l2++); + l2 !== (null == u3 ? void 0 : u3.index) && (n2 = C.nextNode(), l2++); } return C.currentNode = r, o3; } v(t2) { let i2 = 0; - for (const s2 of this._$AV) - void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++; + for (const s3 of this._$AV) + void 0 !== s3 && (void 0 !== s3.strings ? (s3._$AI(t2, s3, i2), i2 += s3.strings.length - 2) : s3._$AI(t2[i2])), i2++; } } class R { - constructor(t2, i2, s2, e2) { + constructor(t2, i2, s3, e2) { var o3; - this.type = 2, this._$AH = A$1, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; + this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s3, this.options = e2, this._$Cp = null === (o3 = null == e2 ? void 0 : e2.isConnected) || void 0 === o3 || o3; } get _$AU() { var t2, i2; @@ -27361,7 +34585,7 @@ return this._$AB; } _$AI(t2, i2 = this) { - t2 = S$1(this, t2, i2), d(t2) ? t2 === A$1 || null == t2 || "" === t2 ? (this._$AH !== A$1 && this._$AR(), this._$AH = A$1) : t2 !== this._$AH && t2 !== T$1 && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v$1(t2) ? this.T(t2) : this._(t2); + t2 = S$1(this, t2, i2), d(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v(t2) ? this.T(t2) : this._(t2); } k(t2) { return this._$AA.parentNode.insertBefore(t2, this._$AB); @@ -27370,33 +34594,33 @@ this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2)); } _(t2) { - this._$AH !== A$1 && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; + this._$AH !== A && d(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2; } g(t2) { var i2; - const { values: s2, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N.createElement(P(e2.h, e2.h[0]), this.options)), e2); + const { values: s3, _$litType$: e2 } = t2, o3 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = N$1.createElement(P$1(e2.h, e2.h[0]), this.options)), e2); if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o3) - this._$AH.v(s2); + this._$AH.v(s3); else { const t3 = new M(o3, this), i3 = t3.u(this.options); - t3.v(s2), this.$(i3), this._$AH = t3; + t3.v(s3), this.$(i3), this._$AH = t3; } } _$AC(t2) { let i2 = E.get(t2.strings); - return void 0 === i2 && E.set(t2.strings, i2 = new N(t2)), i2; + return void 0 === i2 && E.set(t2.strings, i2 = new N$1(t2)), i2; } T(t2) { - c$1(this._$AH) || (this._$AH = [], this._$AR()); + c(this._$AH) || (this._$AH = [], this._$AR()); const i2 = this._$AH; - let s2, e2 = 0; + let s3, e2 = 0; for (const o3 of t2) - e2 === i2.length ? i2.push(s2 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s2 = i2[e2], s2._$AI(o3), e2++; - e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2); + e2 === i2.length ? i2.push(s3 = new R(this.k(u2()), this.k(u2()), this, this.options)) : s3 = i2[e2], s3._$AI(o3), e2++; + e2 < i2.length && (this._$AR(s3 && s3._$AB.nextSibling, e2), i2.length = e2); } _$AR(t2 = this._$AA.nextSibling, i2) { - var s2; - for (null === (s2 = this._$AP) || void 0 === s2 || s2.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { + var s3; + for (null === (s3 = this._$AP) || void 0 === s3 || s3.call(this, false, true, i2); t2 && t2 !== this._$AB; ) { const i3 = t2.nextSibling; t2.remove(), t2 = i3; } @@ -27407,8 +34631,8 @@ } } class k { - constructor(t2, i2, s2, e2, o3) { - this.type = 1, this._$AH = A$1, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = A$1; + constructor(t2, i2, s3, e2, o3) { + this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o3, s3.length > 2 || "" !== s3[0] || "" !== s3[1] ? (this._$AH = Array(s3.length - 1).fill(new String()), this.strings = s3) : this._$AH = A; } get tagName() { return this.element.tagName; @@ -27416,59 +34640,59 @@ get _$AU() { return this._$AM._$AU; } - _$AI(t2, i2 = this, s2, e2) { + _$AI(t2, i2 = this, s3, e2) { const o3 = this.strings; - let n22 = false; + let n2 = false; if (void 0 === o3) - t2 = S$1(this, t2, i2, 0), n22 = !d(t2) || t2 !== this._$AH && t2 !== T$1, n22 && (this._$AH = t2); + t2 = S$1(this, t2, i2, 0), n2 = !d(t2) || t2 !== this._$AH && t2 !== T, n2 && (this._$AH = t2); else { const e3 = t2; let l2, h2; for (t2 = o3[0], l2 = 0; l2 < o3.length - 1; l2++) - h2 = S$1(this, e3[s2 + l2], i2, l2), h2 === T$1 && (h2 = this._$AH[l2]), n22 || (n22 = !d(h2) || h2 !== this._$AH[l2]), h2 === A$1 ? t2 = A$1 : t2 !== A$1 && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; + h2 = S$1(this, e3[s3 + l2], i2, l2), h2 === T && (h2 = this._$AH[l2]), n2 || (n2 = !d(h2) || h2 !== this._$AH[l2]), h2 === A ? t2 = A : t2 !== A && (t2 += (null != h2 ? h2 : "") + o3[l2 + 1]), this._$AH[l2] = h2; } - n22 && !e2 && this.j(t2); + n2 && !e2 && this.j(t2); } j(t2) { - t2 === A$1 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); + t2 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : ""); } } - class H extends k { + let H$1 = class H extends k { constructor() { super(...arguments), this.type = 3; } j(t2) { - this.element[this.name] = t2 === A$1 ? void 0 : t2; + this.element[this.name] = t2 === A ? void 0 : t2; } - } - const I = s$1 ? s$1.emptyScript : ""; + }; + const I = s$2 ? s$2.emptyScript : ""; let L$1 = class L extends k { constructor() { super(...arguments), this.type = 4; } j(t2) { - t2 && t2 !== A$1 ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); + t2 && t2 !== A ? this.element.setAttribute(this.name, I) : this.element.removeAttribute(this.name); } }; class z extends k { - constructor(t2, i2, s2, e2, o3) { - super(t2, i2, s2, e2, o3), this.type = 5; + constructor(t2, i2, s3, e2, o3) { + super(t2, i2, s3, e2, o3), this.type = 5; } _$AI(t2, i2 = this) { - var s2; - if ((t2 = null !== (s2 = S$1(this, t2, i2, 0)) && void 0 !== s2 ? s2 : A$1) === T$1) + var s3; + if ((t2 = null !== (s3 = S$1(this, t2, i2, 0)) && void 0 !== s3 ? s3 : A) === T) return; - const e2 = this._$AH, o3 = t2 === A$1 && e2 !== A$1 || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n22 = t2 !== A$1 && (e2 === A$1 || o3); - o3 && this.element.removeEventListener(this.name, this, e2), n22 && this.element.addEventListener(this.name, this, t2), this._$AH = t2; + const e2 = this._$AH, o3 = t2 === A && e2 !== A || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A && (e2 === A || o3); + o3 && this.element.removeEventListener(this.name, this, e2), n2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2; } handleEvent(t2) { - var i2, s2; - "function" == typeof this._$AH ? this._$AH.call(null !== (s2 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s2 ? s2 : this.element, t2) : this._$AH.handleEvent(t2); + var i2, s3; + "function" == typeof this._$AH ? this._$AH.call(null !== (s3 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s3 ? s3 : this.element, t2) : this._$AH.handleEvent(t2); } } let Z$1 = class Z { - constructor(t2, i2, s2) { - this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s2; + constructor(t2, i2, s3) { + this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s3; } get _$AU() { return this._$AM._$AU; @@ -27478,14 +34702,14 @@ } }; const B$1 = i$2.litHtmlPolyfillSupport; - null == B$1 || B$1(N, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); - const D$1 = (t2, i2, s2) => { + null == B$1 || B$1(N$1, R), (null !== (t$2 = i$2.litHtmlVersions) && void 0 !== t$2 ? t$2 : i$2.litHtmlVersions = []).push("2.8.0"); + const D$1 = (t2, i2, s3) => { var e2, o3; - const n22 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2; - let l2 = n22._$litPart$; + const n2 = null !== (e2 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== e2 ? e2 : i2; + let l2 = n2._$litPart$; if (void 0 === l2) { - const t3 = null !== (o3 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== o3 ? o3 : null; - n22._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s2 ? s2 : {}); + const t3 = null !== (o3 = null == s3 ? void 0 : s3.renderBefore) && void 0 !== o3 ? o3 : null; + n2._$litPart$ = l2 = new R(i2.insertBefore(u2(), t3), t3, void 0, null != s3 ? s3 : {}); } return l2._$AI(t2), l2; }; @@ -27495,7 +34719,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ var l$1, o$1; - class s extends u$1 { + let s$1 = class s extends u$1 { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } @@ -27517,40 +34741,40 @@ super.disconnectedCallback(), null === (t2 = this._$Do) || void 0 === t2 || t2.setConnected(false); } render() { - return T$1; + return T; } - } - s.finalized = true, s._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s }); + }; + s$1.finalized = true, s$1._$litElement$ = true, null === (l$1 = globalThis.litElementHydrateSupport) || void 0 === l$1 || l$1.call(globalThis, { LitElement: s$1 }); const n$2 = globalThis.litElementPolyfillSupport; - null == n$2 || n$2({ LitElement: s }); + null == n$2 || n$2({ LitElement: s$1 }); (null !== (o$1 = globalThis.litElementVersions) && void 0 !== o$1 ? o$1 : globalThis.litElementVersions = []).push("3.3.3"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ - const e$2 = (e2) => (n22) => "function" == typeof n22 ? ((e3, n3) => (customElements.define(e3, n3), n3))(e2, n22) : ((e3, n3) => { - const { kind: t2, elements: s2 } = n3; - return { kind: t2, elements: s2, finisher(n4) { + const e$2 = (e2) => (n2) => "function" == typeof n2 ? ((e3, n32) => (customElements.define(e3, n32), n32))(e2, n2) : ((e3, n32) => { + const { kind: t2, elements: s3 } = n32; + return { kind: t2, elements: s3, finisher(n4) { customElements.define(e3, n4); } }; - })(e2, n22); + })(e2, n2); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ - const i$1 = (i2, e2) => "method" === e2.kind && e2.descriptor && !("value" in e2.descriptor) ? { ...e2, finisher(n22) { - n22.createProperty(e2.key, i2); + const i$1 = (i2, e2) => "method" === e2.kind && e2.descriptor && !("value" in e2.descriptor) ? { ...e2, finisher(n2) { + n2.createProperty(e2.key, i2); } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e2.key, initializer() { "function" == typeof e2.initializer && (this[e2.key] = e2.initializer.call(this)); - }, finisher(n22) { - n22.createProperty(e2.key, i2); - } }, e$1 = (i2, e2, n22) => { - e2.constructor.createProperty(n22, i2); + }, finisher(n2) { + n2.createProperty(e2.key, i2); + } }, e$1 = (i2, e2, n2) => { + e2.constructor.createProperty(n2, i2); }; - function n$1(n22) { - return (t2, o3) => void 0 !== o3 ? e$1(n22, t2, o3) : i$1(n22, t2); + function n$1(n2) { + return (t2, o3) => void 0 !== o3 ? e$1(n2, t2, o3) : i$1(n2, t2); } /** * @license @@ -27566,7 +34790,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ var n; - null != (null === (n = window.HTMLSlotElement) || void 0 === n ? void 0 : n.prototype.assignedElements) ? (o3, n22) => o3.assignedElements(n22) : (o3, n22) => o3.assignedNodes(n22).filter((o4) => o4.nodeType === Node.ELEMENT_NODE); + null != (null === (n = window.HTMLSlotElement) || void 0 === n ? void 0 : n.prototype.assignedElements) ? (o3, n2) => o3.assignedElements(n2) : (o3, n2) => o3.assignedNodes(n2).filter((o4) => o4.nodeType === Node.ELEMENT_NODE); /** * @license * Copyright 2017 Google LLC @@ -27603,23 +34827,23 @@ render(t2) { return " " + Object.keys(t2).filter((i2) => t2[i2]).join(" ") + " "; } - update(i2, [s2]) { - var r2, o3; + update(i2, [s3]) { + var r22, o3; if (void 0 === this.it) { this.it = /* @__PURE__ */ new Set(), void 0 !== i2.strings && (this.nt = new Set(i2.strings.join(" ").split(/\s/).filter((t2) => "" !== t2))); - for (const t2 in s2) - s2[t2] && !(null === (r2 = this.nt) || void 0 === r2 ? void 0 : r2.has(t2)) && this.it.add(t2); - return this.render(s2); + for (const t2 in s3) + s3[t2] && !(null === (r22 = this.nt) || void 0 === r22 ? void 0 : r22.has(t2)) && this.it.add(t2); + return this.render(s3); } const e2 = i2.element.classList; this.it.forEach((t2) => { - t2 in s2 || (e2.remove(t2), this.it.delete(t2)); + t2 in s3 || (e2.remove(t2), this.it.delete(t2)); }); - for (const t2 in s2) { - const i3 = !!s2[t2]; + for (const t2 in s3) { + const i3 = !!s3[t2]; i3 === this.it.has(t2) || (null === (o3 = this.nt) || void 0 === o3 ? void 0 : o3.has(t2)) || (i3 ? (e2.add(t2), this.it.add(t2)) : (e2.remove(t2), this.it.delete(t2))); } - return T$1; + return T; } }); function addUniqueItem(array, item) { @@ -27763,7 +34987,7 @@ this.updateDuration(initialDuration); const interpolate$1 = interpolate(keyframes, offset, isEasingList(easing) ? easing.map(getEasingFunction) : noopReturn); this.tick = (timestamp) => { - var _a; + var _a2; delay2 = delay2; let t2 = 0; if (this.pauseTime !== void 0) { @@ -27788,13 +35012,13 @@ if (direction === "reverse" || direction === "alternate" && iterationIsOdd || direction === "alternate-reverse" && !iterationIsOdd) { iterationProgress = 1 - iterationProgress; } - const p22 = t2 >= this.totalDuration ? 1 : Math.min(iterationProgress, 1); - const latest = interpolate$1(this.easing(p22)); + const p2 = t2 >= this.totalDuration ? 1 : Math.min(iterationProgress, 1); + const latest = interpolate$1(this.easing(p2)); output(latest); const isAnimationFinished = this.pauseTime === void 0 && (this.playState === "finished" || t2 >= this.totalDuration + endDelay); if (isAnimationFinished) { this.playState = "finished"; - (_a = this.resolve) === null || _a === void 0 ? void 0 : _a.call(this, latest); + (_a2 = this.resolve) === null || _a2 === void 0 ? void 0 : _a2.call(this, latest); } else if (this.playState !== "idle") { this.frameRequestId = requestAnimationFrame(this.tick); } @@ -27823,12 +35047,12 @@ this.tick(0); } stop() { - var _a; + var _a2; this.playState = "idle"; if (this.frameRequestId !== void 0) { cancelAnimationFrame(this.frameRequestId); } - (_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, false); + (_a2 = this.reject) === null || _a2 === void 0 ? void 0 : _a2.call(this, false); } cancel() { this.stop(); @@ -28006,7 +35230,7 @@ return isCubicBezier(easing) ? cubicBezierAsString(easing) : easing; } }; - const cubicBezierAsString = ([a22, b22, c2, d22]) => `cubic-bezier(${a22}, ${b22}, ${c2}, ${d22})`; + const cubicBezierAsString = ([a22, b22, c2, d2]) => `cubic-bezier(${a22}, ${b22}, ${c2}, ${d2})`; function hydrateKeyframes(keyframes, readInitialValue) { for (let i2 = 0; i2 < keyframes.length; i2++) { if (keyframes[i2] === null) { @@ -28055,11 +35279,11 @@ } } function getUnitConverter(keyframes, definition) { - var _a; + var _a2; let toUnit = (definition === null || definition === void 0 ? void 0 : definition.toDefaultUnit) || noopReturn; const finalKeyframe = keyframes[keyframes.length - 1]; if (isString(finalKeyframe)) { - const unit = ((_a = finalKeyframe.match(/(-?[\d.]+)([a-z%]*)/)) === null || _a === void 0 ? void 0 : _a[2]) || ""; + const unit = ((_a2 = finalKeyframe.match(/(-?[\d.]+)([a-z%]*)/)) === null || _a2 === void 0 ? void 0 : _a2[2]) || ""; if (unit) toUnit = (value) => value + unit; } @@ -28083,8 +35307,8 @@ stopAnimation(motionValue.animation, !(isEasingGenerator(easing) && motionValue.generator) && options.record !== false); return () => { const readInitialValue = () => { - var _a, _b; - return (_b = (_a = style.get(element, name2)) !== null && _a !== void 0 ? _a : definition === null || definition === void 0 ? void 0 : definition.initialValue) !== null && _b !== void 0 ? _b : 0; + var _a2, _b; + return (_b = (_a2 = style.get(element, name2)) !== null && _a2 !== void 0 ? _a2 : definition === null || definition === void 0 ? void 0 : definition.initialValue) !== null && _b !== void 0 ? _b : 0; }; let keyframes = hydrateKeyframes(keyframesList(keyframesDefinition), readInitialValue); const toUnit = getUnitConverter(keyframes, definition); @@ -28179,12 +35403,8 @@ options[key] ? Object.assign(Object.assign({}, options), options[key]) : Object.assign({}, options) ); function resolveElements(elements, selectorCache) { - var _a; if (typeof elements === "string") { - if (selectorCache) { - (_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : selectorCache[elements] = document.querySelectorAll(elements); - elements = selectorCache[elements]; - } else { + { elements = document.querySelectorAll(elements); } } else if (elements instanceof Element) { @@ -28298,7 +35518,7 @@ * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ - const l = (l2) => null != l2 ? l2 : A$1; + const l = (l2) => null != l2 ? l2 : A; var browser = {}; var canPromise$1 = function() { return typeof Promise === "function" && Promise.prototype && Promise.prototype.then; @@ -28368,11 +35588,11 @@ } return digit; }; - utils$1.setToSJISFunction = function setToSJISFunction(f2) { - if (typeof f2 !== "function") { + utils$1.setToSJISFunction = function setToSJISFunction(f22) { + if (typeof f22 !== "function") { throw new Error('"toSJISFunc" is not a valid function.'); } - toSJISFunction = f2; + toSJISFunction = f22; }; utils$1.isKanjiModeEnabled = function() { return typeof toSJISFunction !== "undefined"; @@ -28657,14 +35877,14 @@ const numPatterns = Object.keys(exports3.Patterns).length; let bestPattern = 0; let lowerPenalty = Infinity; - for (let p22 = 0; p22 < numPatterns; p22++) { - setupFormatFunc(p22); - exports3.applyMask(p22, data2); + for (let p2 = 0; p2 < numPatterns; p2++) { + setupFormatFunc(p2); + exports3.applyMask(p2, data2); const penalty = exports3.getPenaltyN1(data2) + exports3.getPenaltyN2(data2) + exports3.getPenaltyN3(data2) + exports3.getPenaltyN4(data2); - exports3.applyMask(p22, data2); + exports3.applyMask(p2, data2); if (penalty < lowerPenalty) { lowerPenalty = penalty; - bestPattern = p22; + bestPattern = p2; } } return bestPattern; @@ -29044,13 +36264,13 @@ EXP_TABLE[i2] = EXP_TABLE[i2 - 255]; } })(); - galoisField.log = function log(n22) { - if (n22 < 1) - throw new Error("log(" + n22 + ")"); - return LOG_TABLE[n22]; + galoisField.log = function log(n2) { + if (n2 < 1) + throw new Error("log(" + n2 + ")"); + return LOG_TABLE[n2]; }; - galoisField.exp = function exp(n22) { - return EXP_TABLE[n22]; + galoisField.exp = function exp(n2) { + return EXP_TABLE[n2]; }; galoisField.mul = function mul(x2, y22) { if (x2 === 0 || y22 === 0) @@ -29059,11 +36279,11 @@ }; (function(exports3) { const GF = galoisField; - exports3.mul = function mul2(p1, p22) { - const coeff = new Uint8Array(p1.length + p22.length - 1); + exports3.mul = function mul2(p1, p2) { + const coeff = new Uint8Array(p1.length + p2.length - 1); for (let i2 = 0; i2 < p1.length; i2++) { - for (let j2 = 0; j2 < p22.length; j2++) { - coeff[i2 + j2] ^= GF.mul(p1[i2], p22[j2]); + for (let j2 = 0; j2 < p2.length; j2++) { + coeff[i2 + j2] ^= GF.mul(p1[i2], p2[j2]); } } return coeff; @@ -29317,11 +36537,11 @@ if (!VersionCheck.isValid(version2) || version2 < 7) { throw new Error("Invalid QR Code version"); } - let d22 = version2 << 12; - while (Utils2.getBCHDigit(d22) - G18_BCH >= 0) { - d22 ^= G18 << Utils2.getBCHDigit(d22) - G18_BCH; + let d2 = version2 << 12; + while (Utils2.getBCHDigit(d2) - G18_BCH >= 0) { + d2 ^= G18 << Utils2.getBCHDigit(d2) - G18_BCH; } - return version2 << 12 | d22; + return version2 << 12 | d2; }; })(version); var formatInfo = {}; @@ -29331,11 +36551,11 @@ const G15_BCH = Utils$3.getBCHDigit(G15); formatInfo.getEncodedBits = function getEncodedBits(errorCorrectionLevel2, mask) { const data2 = errorCorrectionLevel2.bit << 3 | mask; - let d22 = data2 << 10; - while (Utils$3.getBCHDigit(d22) - G15_BCH >= 0) { - d22 ^= G15 << Utils$3.getBCHDigit(d22) - G15_BCH; + let d2 = data2 << 10; + while (Utils$3.getBCHDigit(d2) - G15_BCH >= 0) { + d2 ^= G15 << Utils$3.getBCHDigit(d2) - G15_BCH; } - return (data2 << 10 | d22) ^ G15_MASK; + return (data2 << 10 | d2) ^ G15_MASK; }; var segments = {}; const Mode$4 = mode; @@ -29538,12 +36758,12 @@ var dijkstra = { exports: {} }; (function(module3) { var dijkstra2 = { - single_source_shortest_paths: function(graph, s2, d22) { + single_source_shortest_paths: function(graph, s3, d2) { var predecessors = {}; var costs = {}; - costs[s2] = 0; + costs[s3] = 0; var open = dijkstra2.PriorityQueue.make(); - open.push(s2, 0); + open.push(s3, 0); var closest, u3, v22, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; while (!open.empty()) { closest = open.pop(); @@ -29564,15 +36784,15 @@ } } } - if (typeof d22 !== "undefined" && typeof costs[d22] === "undefined") { - var msg = ["Could not find a path from ", s2, " to ", d22, "."].join(""); + if (typeof d2 !== "undefined" && typeof costs[d2] === "undefined") { + var msg = ["Could not find a path from ", s3, " to ", d2, "."].join(""); throw new Error(msg); } return predecessors; }, - extract_shortest_path_from_predecessor_list: function(predecessors, d22) { + extract_shortest_path_from_predecessor_list: function(predecessors, d2) { var nodes = []; - var u3 = d22; + var u3 = d2; while (u3) { nodes.push(u3); predecessors[u3]; @@ -29581,11 +36801,11 @@ nodes.reverse(); return nodes; }, - find_path: function(graph, s2, d22) { - var predecessors = dijkstra2.single_source_shortest_paths(graph, s2, d22); + find_path: function(graph, s3, d2) { + var predecessors = dijkstra2.single_source_shortest_paths(graph, s3, d2); return dijkstra2.extract_shortest_path_from_predecessor_list( predecessors, - d22 + d2 ); }, /** @@ -29670,8 +36890,8 @@ kanjiSegs = []; } const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs); - return segs.sort(function(s1, s2) { - return s1.index - s2.index; + return segs.sort(function(s1, s22) { + return s1.index - s22.index; }).map(function(obj) { return { data: obj.data, @@ -29748,8 +36968,8 @@ currentNodeIds.push(key); table[key] = { node: node2, lastCount: 0 }; graph[key] = {}; - for (let n22 = 0; n22 < prevNodeIds.length; n22++) { - const prevNodeId = prevNodeIds[n22]; + for (let n2 = 0; n2 < prevNodeIds.length; n2++) { + const prevNodeId = prevNodeIds[n2]; if (table[prevNodeId] && table[prevNodeId].node.mode === node2.mode) { graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node2.length, node2.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node2.mode); table[prevNodeId].lastCount += node2.length; @@ -29762,8 +36982,8 @@ } prevNodeIds = currentNodeIds; } - for (let n22 = 0; n22 < prevNodeIds.length; n22++) { - graph[prevNodeIds[n22]].end = 0; + for (let n2 = 0; n2 < prevNodeIds.length; n2++) { + graph[prevNodeIds[n2]].end = 0; } return { map: graph, table }; } @@ -29834,16 +37054,16 @@ for (let i2 = 0; i2 < pos.length; i2++) { const row = pos[i2][0]; const col = pos[i2][1]; - for (let r2 = -1; r2 <= 7; r2++) { - if (row + r2 <= -1 || size <= row + r2) + for (let r22 = -1; r22 <= 7; r22++) { + if (row + r22 <= -1 || size <= row + r22) continue; for (let c2 = -1; c2 <= 7; c2++) { if (col + c2 <= -1 || size <= col + c2) continue; - if (r2 >= 0 && r2 <= 6 && (c2 === 0 || c2 === 6) || c2 >= 0 && c2 <= 6 && (r2 === 0 || r2 === 6) || r2 >= 2 && r2 <= 4 && c2 >= 2 && c2 <= 4) { - matrix.set(row + r2, col + c2, true, true); + if (r22 >= 0 && r22 <= 6 && (c2 === 0 || c2 === 6) || c2 >= 0 && c2 <= 6 && (r22 === 0 || r22 === 6) || r22 >= 2 && r22 <= 4 && c2 >= 2 && c2 <= 4) { + matrix.set(row + r22, col + c2, true, true); } else { - matrix.set(row + r2, col + c2, false, true); + matrix.set(row + r22, col + c2, false, true); } } } @@ -29851,10 +37071,10 @@ } function setupTimingPattern(matrix) { const size = matrix.size; - for (let r2 = 8; r2 < size - 8; r2++) { - const value = r2 % 2 === 0; - matrix.set(r2, 6, value, true); - matrix.set(6, r2, value, true); + for (let r22 = 8; r22 < size - 8; r22++) { + const value = r22 % 2 === 0; + matrix.set(r22, 6, value, true); + matrix.set(6, r22, value, true); } } function setupAlignmentPattern(matrix, version2) { @@ -29862,12 +37082,12 @@ for (let i2 = 0; i2 < pos.length; i2++) { const row = pos[i2][0]; const col = pos[i2][1]; - for (let r2 = -2; r2 <= 2; r2++) { + for (let r22 = -2; r22 <= 2; r22++) { for (let c2 = -2; c2 <= 2; c2++) { - if (r2 === -2 || r2 === 2 || c2 === -2 || c2 === 2 || r2 === 0 && c2 === 0) { - matrix.set(row + r2, col + c2, true, true); + if (r22 === -2 || r22 === 2 || c2 === -2 || c2 === 2 || r22 === 0 && c2 === 0) { + matrix.set(row + r22, col + c2, true, true); } else { - matrix.set(row + r2, col + c2, false, true); + matrix.set(row + r22, col + c2, false, true); } } } @@ -29989,17 +37209,17 @@ } const data2 = new Uint8Array(totalCodewords); let index = 0; - let i2, r2; + let i2, r22; for (i2 = 0; i2 < maxDataSize; i2++) { - for (r2 = 0; r2 < ecTotalBlocks; r2++) { - if (i2 < dcData[r2].length) { - data2[index++] = dcData[r2][i2]; + for (r22 = 0; r22 < ecTotalBlocks; r22++) { + if (i2 < dcData[r22].length) { + data2[index++] = dcData[r22][i2]; } } } for (i2 = 0; i2 < ecCount; i2++) { - for (r2 = 0; r2 < ecTotalBlocks; r2++) { - data2[index++] = ecData[r2][i2]; + for (r22 = 0; r22 < ecTotalBlocks; r22++) { + data2[index++] = ecData[r22][i2]; } } return data2; @@ -30130,9 +37350,9 @@ const scale = exports3.getScale(qrSize, opts); return Math.floor((qrSize + opts.margin * 2) * scale); }; - exports3.qrToImageData = function qrToImageData(imgData, qr, opts) { - const size = qr.modules.size; - const data2 = qr.modules.data; + exports3.qrToImageData = function qrToImageData(imgData, qr2, opts) { + const size = qr2.modules.size; + const data2 = qr2.modules.data; const scale = exports3.getScale(size, opts); const symbolSize = Math.floor((size + opts.margin * 2) * scale); const scaledMargin = opts.margin * scale; @@ -30324,150 +37544,54 @@ browser.toString = renderCanvas.bind(null, function(data2, _22, opts) { return SvgRenderer.render(data2, opts); }); - var et = Object.defineProperty, Be = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Ue = (e2, o3, r2) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[o3] = r2, ve = (e2, o3) => { - for (var r2 in o3 || (o3 = {})) - tt.call(o3, r2) && Ue(e2, r2, o3[r2]); - if (Be) - for (var r2 of Be(o3)) - ot.call(o3, r2) && Ue(e2, r2, o3[r2]); + var et = Object.defineProperty, Se = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, Be = (e2, o3, r22) => o3 in e2 ? et(e2, o3, { enumerable: true, configurable: true, writable: true, value: r22 }) : e2[o3] = r22, fe = (e2, o3) => { + for (var r22 in o3 || (o3 = {})) + tt.call(o3, r22) && Be(e2, r22, o3[r22]); + if (Se) + for (var r22 of Se(o3)) + ot.call(o3, r22) && Be(e2, r22, o3[r22]); return e2; }; function rt() { var e2; - const o3 = (e2 = ne$1.state.themeMode) != null ? e2 : "dark", r2 = { - light: { - foreground: { - 1: "rgb(20,20,20)", - 2: "rgb(121,134,134)", - 3: "rgb(158,169,169)" - }, - background: { - 1: "rgb(255,255,255)", - 2: "rgb(241,243,243)", - 3: "rgb(228,231,231)" - }, - overlay: "rgba(0,0,0,0.1)" - }, - dark: { - foreground: { - 1: "rgb(228,231,231)", - 2: "rgb(148,158,158)", - 3: "rgb(110,119,119)" - }, - background: { - 1: "rgb(20,20,20)", - 2: "rgb(39,42,42)", - 3: "rgb(59,64,64)" - }, - overlay: "rgba(255,255,255,0.1)" - } - }[o3]; - return { - "--wcm-color-fg-1": r2.foreground[1], - "--wcm-color-fg-2": r2.foreground[2], - "--wcm-color-fg-3": r2.foreground[3], - "--wcm-color-bg-1": r2.background[1], - "--wcm-color-bg-2": r2.background[2], - "--wcm-color-bg-3": r2.background[3], - "--wcm-color-overlay": r2.overlay - }; + const o3 = (e2 = ne$3.state.themeMode) != null ? e2 : "dark", r22 = { light: { foreground: { 1: "rgb(20,20,20)", 2: "rgb(121,134,134)", 3: "rgb(158,169,169)" }, background: { 1: "rgb(255,255,255)", 2: "rgb(241,243,243)", 3: "rgb(228,231,231)" }, overlay: "rgba(0,0,0,0.1)" }, dark: { foreground: { 1: "rgb(228,231,231)", 2: "rgb(148,158,158)", 3: "rgb(110,119,119)" }, background: { 1: "rgb(20,20,20)", 2: "rgb(39,42,42)", 3: "rgb(59,64,64)" }, overlay: "rgba(255,255,255,0.1)" } }[o3]; + return { "--wcm-color-fg-1": r22.foreground[1], "--wcm-color-fg-2": r22.foreground[2], "--wcm-color-fg-3": r22.foreground[3], "--wcm-color-bg-1": r22.background[1], "--wcm-color-bg-2": r22.background[2], "--wcm-color-bg-3": r22.background[3], "--wcm-color-overlay": r22.overlay }; } - function He() { - return { - "--wcm-accent-color": "#3396FF", - "--wcm-accent-fill-color": "#FFFFFF", - "--wcm-z-index": "89", - "--wcm-background-color": "#3396FF", - "--wcm-background-border-radius": "8px", - "--wcm-container-border-radius": "30px", - "--wcm-wallet-icon-border-radius": "15px", - "--wcm-wallet-icon-large-border-radius": "30px", - "--wcm-wallet-icon-small-border-radius": "7px", - "--wcm-input-border-radius": "28px", - "--wcm-button-border-radius": "10px", - "--wcm-notification-border-radius": "36px", - "--wcm-secondary-button-border-radius": "28px", - "--wcm-icon-button-border-radius": "50%", - "--wcm-button-hover-highlight-border-radius": "10px", - "--wcm-text-big-bold-size": "20px", - "--wcm-text-big-bold-weight": "600", - "--wcm-text-big-bold-line-height": "24px", - "--wcm-text-big-bold-letter-spacing": "-0.03em", - "--wcm-text-big-bold-text-transform": "none", - "--wcm-text-xsmall-bold-size": "10px", - "--wcm-text-xsmall-bold-weight": "700", - "--wcm-text-xsmall-bold-line-height": "12px", - "--wcm-text-xsmall-bold-letter-spacing": "0.02em", - "--wcm-text-xsmall-bold-text-transform": "uppercase", - "--wcm-text-xsmall-regular-size": "12px", - "--wcm-text-xsmall-regular-weight": "600", - "--wcm-text-xsmall-regular-line-height": "14px", - "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", - "--wcm-text-xsmall-regular-text-transform": "none", - "--wcm-text-small-thin-size": "14px", - "--wcm-text-small-thin-weight": "500", - "--wcm-text-small-thin-line-height": "16px", - "--wcm-text-small-thin-letter-spacing": "-0.03em", - "--wcm-text-small-thin-text-transform": "none", - "--wcm-text-small-regular-size": "14px", - "--wcm-text-small-regular-weight": "600", - "--wcm-text-small-regular-line-height": "16px", - "--wcm-text-small-regular-letter-spacing": "-0.03em", - "--wcm-text-small-regular-text-transform": "none", - "--wcm-text-medium-regular-size": "16px", - "--wcm-text-medium-regular-weight": "600", - "--wcm-text-medium-regular-line-height": "20px", - "--wcm-text-medium-regular-letter-spacing": "-0.03em", - "--wcm-text-medium-regular-text-transform": "none", - "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", - "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", - "--wcm-success-color": "rgb(38,181,98)", - "--wcm-error-color": "rgb(242, 90, 103)", - "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", - "--wcm-overlay-backdrop-filter": "none" - }; + function Ue() { + return { "--wcm-accent-color": "#3396FF", "--wcm-accent-fill-color": "#FFFFFF", "--wcm-z-index": "89", "--wcm-background-color": "#3396FF", "--wcm-background-border-radius": "8px", "--wcm-container-border-radius": "30px", "--wcm-wallet-icon-border-radius": "15px", "--wcm-wallet-icon-large-border-radius": "30px", "--wcm-wallet-icon-small-border-radius": "7px", "--wcm-input-border-radius": "28px", "--wcm-button-border-radius": "10px", "--wcm-notification-border-radius": "36px", "--wcm-secondary-button-border-radius": "28px", "--wcm-icon-button-border-radius": "50%", "--wcm-button-hover-highlight-border-radius": "10px", "--wcm-text-big-bold-size": "20px", "--wcm-text-big-bold-weight": "600", "--wcm-text-big-bold-line-height": "24px", "--wcm-text-big-bold-letter-spacing": "-0.03em", "--wcm-text-big-bold-text-transform": "none", "--wcm-text-xsmall-bold-size": "10px", "--wcm-text-xsmall-bold-weight": "700", "--wcm-text-xsmall-bold-line-height": "12px", "--wcm-text-xsmall-bold-letter-spacing": "0.02em", "--wcm-text-xsmall-bold-text-transform": "uppercase", "--wcm-text-xsmall-regular-size": "12px", "--wcm-text-xsmall-regular-weight": "600", "--wcm-text-xsmall-regular-line-height": "14px", "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", "--wcm-text-xsmall-regular-text-transform": "none", "--wcm-text-small-thin-size": "14px", "--wcm-text-small-thin-weight": "500", "--wcm-text-small-thin-line-height": "16px", "--wcm-text-small-thin-letter-spacing": "-0.03em", "--wcm-text-small-thin-text-transform": "none", "--wcm-text-small-regular-size": "14px", "--wcm-text-small-regular-weight": "600", "--wcm-text-small-regular-line-height": "16px", "--wcm-text-small-regular-letter-spacing": "-0.03em", "--wcm-text-small-regular-text-transform": "none", "--wcm-text-medium-regular-size": "16px", "--wcm-text-medium-regular-weight": "600", "--wcm-text-medium-regular-line-height": "20px", "--wcm-text-medium-regular-letter-spacing": "-0.03em", "--wcm-text-medium-regular-text-transform": "none", "--wcm-font-family": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", "--wcm-success-color": "rgb(38,181,98)", "--wcm-error-color": "rgb(242, 90, 103)", "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", "--wcm-overlay-backdrop-filter": "none" }; } - const h = { - getPreset(e2) { - return He()[e2]; - }, - setTheme() { - const e2 = document.querySelector(":root"), { themeVariables: o3 } = ne$1.state; - if (e2) { - const r2 = ve(ve(ve({}, rt()), He()), o3); - Object.entries(r2).forEach(([a22, t2]) => e2.style.setProperty(a22, t2)); - } - }, - globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` - }, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; - var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, F = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? it(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && lt(o3, r2, t2), t2; - }; - let T = class extends s { + const h = { getPreset(e2) { + return Ue()[e2]; + }, setTheme() { + const e2 = document.querySelector(":root"), { themeVariables: o3 } = ne$3.state; + if (e2) { + const r22 = fe(fe(fe({}, rt()), Ue()), o3); + Object.entries(r22).forEach(([a22, t2]) => e2.style.setProperty(a22, t2)); + } + }, globalCss: i$3`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}` }, at = i$3`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; + var lt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, K = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? it(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && lt(o3, r22, t2), t2; + }; + let _ = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.iconLeft = void 0, this.iconRight = void 0, this.onClick = () => null, this.variant = "default"; } render() { - const e2 = { - "wcm-icon-left": this.iconLeft !== void 0, - "wcm-icon-right": this.iconRight !== void 0, - "wcm-ghost": this.variant === "ghost", - "wcm-outline": this.variant === "outline" - }; + const e2 = { "wcm-icon-left": this.iconLeft !== void 0, "wcm-icon-right": this.iconRight !== void 0, "wcm-ghost": this.variant === "ghost", "wcm-outline": this.variant === "outline" }; let o$12 = "inverse"; return this.variant === "ghost" && (o$12 = "secondary"), this.variant === "outline" && (o$12 = "accent"), x``; } }; - T.styles = [h.globalCss, at], F([n$1({ type: Boolean })], T.prototype, "disabled", 2), F([n$1()], T.prototype, "iconLeft", 2), F([n$1()], T.prototype, "iconRight", 2), F([n$1()], T.prototype, "onClick", 2), F([n$1()], T.prototype, "variant", 2), T = F([e$2("wcm-button")], T); + _.styles = [h.globalCss, at], K([n$1({ type: Boolean })], _.prototype, "disabled", 2), K([n$1()], _.prototype, "iconLeft", 2), K([n$1()], _.prototype, "iconRight", 2), K([n$1()], _.prototype, "onClick", 2), K([n$1()], _.prototype, "variant", 2), _ = K([e$2("wcm-button")], _); const nt = i$3`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`; - var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, ue = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? st(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && ct(o3, r2, t2), t2; + var ct = Object.defineProperty, st = Object.getOwnPropertyDescriptor, xe = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? st(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && ct(o3, r22, t2), t2; }; - let ee = class extends s { + let re = class extends s$1 { constructor() { super(...arguments), this.disabled = false, this.variant = "primary"; } @@ -30476,203 +37600,159 @@ return x``; } }; - ee.styles = [h.globalCss, nt], ue([n$1({ type: Boolean })], ee.prototype, "disabled", 2), ue([n$1()], ee.prototype, "variant", 2), ee = ue([e$2("wcm-button-big")], ee); + re.styles = [h.globalCss, nt], xe([n$1({ type: Boolean })], re.prototype, "disabled", 2), xe([n$1()], re.prototype, "variant", 2), re = xe([e$2("wcm-button-big")], re); const dt = i$3`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`; - var mt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, wt = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && mt(o3, r2, t2), t2; + var ht = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let be = class extends s { + let ye = class extends s$1 { render() { return x`
`; } }; - be.styles = [h.globalCss, dt], be = wt([e$2("wcm-info-footer")], be); - const v = { - CROSS_ICON: b``, - WALLET_CONNECT_LOGO: b``, - WALLET_CONNECT_ICON: b``, - WALLET_CONNECT_ICON_COLORED: b``, - BACK_ICON: b``, - COPY_ICON: b``, - RETRY_ICON: b``, - DESKTOP_ICON: b``, - MOBILE_ICON: b``, - ARROW_DOWN_ICON: b``, - ARROW_UP_RIGHT_ICON: b``, - ARROW_RIGHT_ICON: b``, - QRCODE_ICON: b``, - SCAN_ICON: b``, - CHECKMARK_ICON: b``, - SEARCH_ICON: b``, - WALLET_PLACEHOLDER: b``, - GLOBE_ICON: b`` - }, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; - var gt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, ut = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? vt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && gt(o3, r2, t2), t2; - }; - let fe = class extends s { + ye.styles = [h.globalCss, dt], ye = ht([e$2("wcm-info-footer")], ye); + const b = { CROSS_ICON: b$1``, WALLET_CONNECT_LOGO: b$1``, WALLET_CONNECT_ICON: b$1``, WALLET_CONNECT_ICON_COLORED: b$1``, BACK_ICON: b$1``, COPY_ICON: b$1``, RETRY_ICON: b$1``, DESKTOP_ICON: b$1``, MOBILE_ICON: b$1``, ARROW_DOWN_ICON: b$1``, ARROW_UP_RIGHT_ICON: b$1``, ARROW_RIGHT_ICON: b$1``, QRCODE_ICON: b$1``, SCAN_ICON: b$1``, CHECKMARK_ICON: b$1``, SEARCH_ICON: b$1``, WALLET_PLACEHOLDER: b$1``, GLOBE_ICON: b$1`` }, pt = i$3`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; + var ut = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; + }; + let $e = class extends s$1 { render() { - return x`
${v.WALLET_CONNECT_LOGO}
`; + return x`
${b.WALLET_CONNECT_LOGO}
`; } }; - fe.styles = [h.globalCss, pt], fe = ut([e$2("wcm-modal-backcard")], fe); + $e.styles = [h.globalCss, pt], $e = ut([e$2("wcm-modal-backcard")], $e); const bt = i$3`main{padding:20px;padding-top:0;width:100%}`; - var ft = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, yt = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? xt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && ft(o3, r2, t2), t2; + var yt = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let xe = class extends s { + let Ce = class extends s$1 { render() { return x`
`; } }; - xe.styles = [h.globalCss, bt], xe = yt([e$2("wcm-modal-content")], xe); + Ce.styles = [h.globalCss, bt], Ce = yt([e$2("wcm-modal-content")], Ce); const $t = i$3`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`; - var Ct = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, Ot = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? kt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Ct(o3, r2, t2), t2; + var Ot = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let ye = class extends s { + let ke = class extends s$1 { render() { return x`
`; } }; - ye.styles = [h.globalCss, $t], ye = Ot([e$2("wcm-modal-footer")], ye); - const Wt = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; - var It = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, te = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Et(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && It(o3, r2, t2), t2; + ke.styles = [h.globalCss, $t], ke = Ot([e$2("wcm-modal-footer")], ke); + const It = i$3`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; + var Wt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, ae = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Et(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Wt(o3, r22, t2), t2; }; - let S = class extends s { + let B = class extends s$1 { constructor() { super(...arguments), this.title = "", this.onAction = void 0, this.actionIcon = void 0, this.border = false; } backBtnTemplate() { - return x``; + return x``; } actionBtnTemplate() { return x``; } render() { - const e2 = { "wcm-border": this.border }, o$12 = T$1$1.state.history.length > 1, r2 = this.title ? x`${this.title}` : x``; - return x`
${o$12 ? this.backBtnTemplate() : null} ${r2} ${this.onAction ? this.actionBtnTemplate() : null}
`; - } - }; - S.styles = [h.globalCss, Wt], te([n$1()], S.prototype, "title", 2), te([n$1()], S.prototype, "onAction", 2), te([n$1()], S.prototype, "actionIcon", 2), te([n$1({ type: Boolean })], S.prototype, "border", 2), S = te([e$2("wcm-modal-header")], S); - const c = { - MOBILE_BREAKPOINT: 600, - WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", - EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", - getShadowRootElement(e2, o3) { - const r2 = e2.renderRoot.querySelector(o3); - if (!r2) - throw new Error(`${o3} not found`); - return r2; - }, - getWalletIcon({ id: e2, image_id: o3 }) { - const { walletImages: r2 } = y$3.state; - return r2 != null && r2[e2] ? r2[e2] : o3 ? te$2.getWalletImageUrl(o3) : ""; - }, - getWalletName(e2, o3 = false) { - return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; - }, - isMobileAnimation() { - return window.innerWidth <= c.MOBILE_BREAKPOINT; - }, - async preloadImage(e2) { - const o3 = new Promise((r2, a22) => { - const t2 = new Image(); - t2.onload = r2, t2.onerror = a22, t2.crossOrigin = "anonymous", t2.src = e2; - }); - return Promise.race([o3, a$3.wait(3e3)]); - }, - getErrorMessage(e2) { - return e2 instanceof Error ? e2.message : "Unknown Error"; - }, - debounce(e2, o3 = 500) { - let r2; - return (...a22) => { - function t2() { - e2(...a22); - } - r2 && clearTimeout(r2), r2 = setTimeout(t2, o3); - }; - }, - handleMobileLinking(e2) { - const { walletConnectUri: o3 } = p$3.state, { mobile: r2, name: a22 } = e2, t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - c.setRecentWallet(e2); - function i2(s2) { - let $2 = ""; - t2 ? $2 = a$3.formatUniversalUrl(t2, s2, a22) : l2 && ($2 = a$3.formatNativeUrl(l2, s2, a22)), a$3.openHref($2, "_self"); - } - o3 && i2(o3); - }, - async handleUriCopy() { - const { walletConnectUri: e2 } = p$3.state; - if (e2) - try { - await navigator.clipboard.writeText(e2), oe$1.openToast("Link copied", "success"); - } catch { - oe$1.openToast("Failed to copy", "error"); - } - }, - getCustomImageUrls() { - const { walletImages: e2 } = y$3.state, o3 = Object.values(e2 ?? {}); - return Object.values(o3); - }, - truncate(e2, o3 = 8) { - return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; - }, - setRecentWallet(e2) { - try { - localStorage.setItem(c.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); - } catch { - console.info("Unable to set recent wallet"); - } - }, - getRecentWallet() { + const e2 = { "wcm-border": this.border }, o$12 = T$2.state.history.length > 1, r22 = this.title ? x`${this.title}` : x``; + return x`
${o$12 ? this.backBtnTemplate() : null} ${r22} ${this.onAction ? this.actionBtnTemplate() : null}
`; + } + }; + B.styles = [h.globalCss, It], ae([n$1()], B.prototype, "title", 2), ae([n$1()], B.prototype, "onAction", 2), ae([n$1()], B.prototype, "actionIcon", 2), ae([n$1({ type: Boolean })], B.prototype, "border", 2), B = ae([e$2("wcm-modal-header")], B); + const s2 = { MOBILE_BREAKPOINT: 600, WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", getShadowRootElement(e2, o3) { + const r22 = e2.renderRoot.querySelector(o3); + if (!r22) + throw new Error(`${o3} not found`); + return r22; + }, getWalletIcon({ id: e2, image_id: o3 }) { + const { walletImages: r22 } = y$4.state; + return r22 != null && r22[e2] ? r22[e2] : o3 ? te$1.getWalletImageUrl(o3) : ""; + }, getWalletName(e2, o3 = false) { + return o3 && e2.length > 8 ? `${e2.substring(0, 8)}..` : e2; + }, isMobileAnimation() { + return window.innerWidth <= s2.MOBILE_BREAKPOINT; + }, async preloadImage(e2) { + const o3 = new Promise((r22, a22) => { + const t2 = new Image(); + t2.onload = r22, t2.onerror = a22, t2.crossOrigin = "anonymous", t2.src = e2; + }); + return Promise.race([o3, i$1$1.wait(3e3)]); + }, getErrorMessage(e2) { + return e2 instanceof Error ? e2.message : "Unknown Error"; + }, debounce(e2, o3 = 500) { + let r22; + return (...a22) => { + function t2() { + e2(...a22); + } + r22 && clearTimeout(r22), r22 = setTimeout(t2, o3); + }; + }, handleMobileLinking(e2) { + const { walletConnectUri: o3 } = p$2.state, { mobile: r22, name: a22 } = e2, t2 = r22 == null ? void 0 : r22.native, l2 = r22 == null ? void 0 : r22.universal; + s2.setRecentWallet(e2); + function i2(c2) { + let u3 = ""; + t2 ? u3 = i$1$1.formatUniversalUrl(t2, c2, a22) : l2 && (u3 = i$1$1.formatNativeUrl(l2, c2, a22)), i$1$1.openHref(u3, "_self"); + } + o3 && i2(o3); + }, async handleUriCopy() { + const { walletConnectUri: e2 } = p$2.state; + if (e2) try { - const e2 = localStorage.getItem(c.WCM_RECENT_WALLET_DATA); - return e2 ? JSON.parse(e2) : void 0; + await navigator.clipboard.writeText(e2), oe$2.openToast("Link copied", "success"); } catch { - console.info("Unable to get recent wallet"); - } - }, - caseSafeIncludes(e2, o3) { - return e2.toUpperCase().includes(o3.toUpperCase()); - }, - openWalletExplorerUrl() { - a$3.openHref(c.EXPLORER_WALLET_URL, "_blank"); - }, - getCachedRouterWalletPlatforms() { - const { desktop: e2, mobile: o3 } = a$3.getWalletRouterData(), r2 = Boolean(e2 == null ? void 0 : e2.native), a22 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); - return { isDesktop: r2, isMobile: t2, isWeb: a22 }; - }, - goToConnectingView(e2) { - T$1$1.setData({ Wallet: e2 }); - const o3 = a$3.isMobile(), { - isDesktop: r2, - isWeb: a22, - isMobile: t2 - } = c.getCachedRouterWalletPlatforms(); - o3 ? t2 ? T$1$1.push("MobileConnecting") : a22 ? T$1$1.push("WebConnecting") : T$1$1.push("InstallWallet") : r2 ? T$1$1.push("DesktopConnecting") : a22 ? T$1$1.push("WebConnecting") : t2 ? T$1$1.push("MobileQrcodeConnecting") : T$1$1.push("InstallWallet"); - } - }, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; - var Lt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, $e = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Rt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Lt(o3, r2, t2), t2; - }; - let oe = class extends s { + oe$2.openToast("Failed to copy", "error"); + } + }, getCustomImageUrls() { + const { walletImages: e2 } = y$4.state, o3 = Object.values(e2 ?? {}); + return Object.values(o3); + }, truncate(e2, o3 = 8) { + return e2.length <= o3 ? e2 : `${e2.substring(0, 4)}...${e2.substring(e2.length - 4)}`; + }, setRecentWallet(e2) { + try { + localStorage.setItem(s2.WCM_RECENT_WALLET_DATA, JSON.stringify(e2)); + } catch { + console.info("Unable to set recent wallet"); + } + }, getRecentWallet() { + try { + const e2 = localStorage.getItem(s2.WCM_RECENT_WALLET_DATA); + return e2 ? JSON.parse(e2) : void 0; + } catch { + console.info("Unable to get recent wallet"); + } + }, caseSafeIncludes(e2, o3) { + return e2.toUpperCase().includes(o3.toUpperCase()); + }, openWalletExplorerUrl() { + i$1$1.openHref(s2.EXPLORER_WALLET_URL, "_blank"); + }, getCachedRouterWalletPlatforms() { + const { desktop: e2, mobile: o3 } = i$1$1.getWalletRouterData(), r22 = Boolean(e2 == null ? void 0 : e2.native), a22 = Boolean(e2 == null ? void 0 : e2.universal), t2 = Boolean(o3 == null ? void 0 : o3.native) || Boolean(o3 == null ? void 0 : o3.universal); + return { isDesktop: r22, isMobile: t2, isWeb: a22 }; + }, goToConnectingView(e2) { + T$2.setData({ Wallet: e2 }); + const o3 = i$1$1.isMobile(), { isDesktop: r22, isWeb: a22, isMobile: t2 } = s2.getCachedRouterWalletPlatforms(); + o3 ? t2 ? T$2.push("MobileConnecting") : a22 ? T$2.push("WebConnecting") : T$2.push("InstallWallet") : r22 ? T$2.push("DesktopConnecting") : a22 ? T$2.push("WebConnecting") : t2 ? T$2.push("MobileQrcodeConnecting") : T$2.push("InstallWallet"); + } }, Mt = i$3`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; + var Pt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Lt(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Pt(o3, r22, t2), t2; + }; + let le = class extends s$1 { constructor() { - super(), this.view = T$1$1.state.view, this.prevView = T$1$1.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = T$1$1.subscribe((e2) => { + super(), this.view = T$2.state.view, this.prevView = T$2.state.view, this.unsubscribe = void 0, this.oldHeight = "0px", this.resizeObserver = void 0, this.unsubscribe = T$2.subscribe((e2) => { this.view !== e2.view && this.onChangeRoute(); }); } @@ -30687,10 +37767,10 @@ (e2 = this.unsubscribe) == null || e2.call(this), (o3 = this.resizeObserver) == null || o3.disconnect(); } get routerEl() { - return c.getShadowRootElement(this, ".wcm-router"); + return s2.getShadowRootElement(this, ".wcm-router"); } get contentEl() { - return c.getShadowRootElement(this, ".wcm-content"); + return s2.getShadowRootElement(this, ".wcm-content"); } viewTemplate() { switch (this.view) { @@ -30715,196 +37795,157 @@ } } async onChangeRoute() { - await animate( - this.routerEl, - { opacity: [1, 0], scale: [1, 1.02] }, - { duration: 0.15, delay: 0.1 } - ).finished, this.view = T$1$1.state.view, animate( - this.routerEl, - { opacity: [0, 1], scale: [0.99, 1] }, - { duration: 0.37, delay: 0.05 } - ); + await animate(this.routerEl, { opacity: [1, 0], scale: [1, 1.02] }, { duration: 0.15, delay: 0.1 }).finished, this.view = T$2.state.view, animate(this.routerEl, { opacity: [0, 1], scale: [0.99, 1] }, { duration: 0.37, delay: 0.05 }); } render() { return x`
${this.viewTemplate()}
`; } }; - oe.styles = [h.globalCss, Mt], $e([t$1()], oe.prototype, "view", 2), $e([t$1()], oe.prototype, "prevView", 2), oe = $e([e$2("wcm-modal-router")], oe); - const At = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; - var Pt = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, ze = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Tt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Pt(o3, r2, t2), t2; + le.styles = [h.globalCss, Mt], Oe([t$1()], le.prototype, "view", 2), Oe([t$1()], le.prototype, "prevView", 2), le = Oe([e$2("wcm-modal-router")], le); + const Rt = i$3`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; + var At = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, He = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Tt(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && At(o3, r22, t2), t2; }; - let ne = class extends s { + let de = class extends s$1 { constructor() { - super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = oe$1.subscribe((e2) => { - e2.open ? (this.open = true, this.timeout = setTimeout(() => oe$1.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); + super(), this.open = false, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = oe$2.subscribe((e2) => { + e2.open ? (this.open = true, this.timeout = setTimeout(() => oe$2.closeToast(), 2200)) : (this.open = false, clearTimeout(this.timeout)); }); } disconnectedCallback() { var e2; - (e2 = this.unsubscribe) == null || e2.call(this), clearTimeout(this.timeout), oe$1.closeToast(); + (e2 = this.unsubscribe) == null || e2.call(this), clearTimeout(this.timeout), oe$2.closeToast(); } render() { - const { message: e2, variant: o$12 } = oe$1.state, r2 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; - return this.open ? x`
${o$12 === "success" ? v.CHECKMARK_ICON : null} ${o$12 === "error" ? v.CROSS_ICON : null}${e2}
` : null; + const { message: e2, variant: o$12 } = oe$2.state, r22 = { "wcm-success": o$12 === "success", "wcm-error": o$12 === "error" }; + return this.open ? x`
${o$12 === "success" ? b.CHECKMARK_ICON : null} ${o$12 === "error" ? b.CROSS_ICON : null}${e2}
` : null; } }; - ne.styles = [h.globalCss, At], ze([t$1()], ne.prototype, "open", 2), ne = ze([e$2("wcm-modal-toast")], ne); - const jt = 0.1, Ve = 2.5, A = 7; - function Ce(e2, o3, r2) { - return e2 === o3 ? false : (e2 - o3 < 0 ? o3 - e2 : e2 - o3) <= r2 + jt; + de.styles = [h.globalCss, Rt], He([t$1()], de.prototype, "open", 2), de = He([e$2("wcm-modal-toast")], de); + const jt = 0.1, Ve = 2.5, L2 = 7; + function Ie(e2, o3, r22) { + return e2 === o3 ? false : (e2 - o3 < 0 ? o3 - e2 : e2 - o3) <= r22 + jt; } function _t(e2, o3) { - const r2 = Array.prototype.slice.call( - browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, - 0 - ), a22 = Math.sqrt(r2.length); - return r2.reduce( - (t2, l2, i2) => (i2 % a22 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, - [] - ); + const r22 = Array.prototype.slice.call(browser.create(e2, { errorCorrectionLevel: o3 }).modules.data, 0), a22 = Math.sqrt(r22.length); + return r22.reduce((t2, l2, i2) => (i2 % a22 === 0 ? t2.push([l2]) : t2[t2.length - 1].push(l2)) && t2, []); } - const Dt = { - generate(e2, o3, r2) { - const a22 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), s2 = o3 / i2.length, $2 = [ - { x: 0, y: 0 }, - { x: 1, y: 0 }, - { x: 0, y: 1 } - ]; - $2.forEach(({ x: y22, y: u3 }) => { - const O2 = (i2.length - A) * s2 * y22, b$12 = (i2.length - A) * s2 * u3, E2 = 0.45; - for (let M2 = 0; M2 < $2.length; M2 += 1) { - const V2 = s2 * (A - M2 * 2); - l2.push( - b`` - ); + const Dt = { generate(e2, o3, r22) { + const a22 = "#141414", t2 = "#ffffff", l2 = [], i2 = _t(e2, "Q"), c2 = o3 / i2.length, u3 = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }]; + u3.forEach(({ x: $2, y: f22 }) => { + const O = (i2.length - L2) * c2 * $2, x2 = (i2.length - L2) * c2 * f22, E2 = 0.45; + for (let M2 = 0; M2 < u3.length; M2 += 1) { + const Q2 = c2 * (L2 - M2 * 2); + l2.push(b$1``); + } + }); + const w22 = Math.floor((r22 + 25) / c2), F2 = i2.length / 2 - w22 / 2, T2 = i2.length / 2 + w22 / 2 - 1, j2 = []; + i2.forEach(($2, f22) => { + $2.forEach((O, x2) => { + if (i2[f22][x2] && !(f22 < L2 && x2 < L2 || f22 > i2.length - (L2 + 1) && x2 < L2 || f22 < L2 && x2 > i2.length - (L2 + 1)) && !(f22 > F2 && f22 < T2 && x2 > F2 && x2 < T2)) { + const E2 = f22 * c2 + c2 / 2, M2 = x2 * c2 + c2 / 2; + j2.push([E2, M2]); } }); - const f2 = Math.floor((r2 + 25) / s2), Ne2 = i2.length / 2 - f2 / 2, Ze2 = i2.length / 2 + f2 / 2 - 1, Se = []; - i2.forEach((y22, u3) => { - y22.forEach((O2, b22) => { - if (i2[u3][b22] && !(u3 < A && b22 < A || u3 > i2.length - (A + 1) && b22 < A || u3 < A && b22 > i2.length - (A + 1)) && !(u3 > Ne2 && u3 < Ze2 && b22 > Ne2 && b22 < Ze2)) { - const E2 = u3 * s2 + s2 / 2, M2 = b22 * s2 + s2 / 2; - Se.push([E2, M2]); - } - }); + }); + const oe2 = {}; + return j2.forEach(([$2, f22]) => { + oe2[$2] ? oe2[$2].push(f22) : oe2[$2] = [f22]; + }), Object.entries(oe2).map(([$2, f22]) => { + const O = f22.filter((x2) => f22.every((E2) => !Ie(x2, E2, c2))); + return [Number($2), O]; + }).forEach(([$2, f22]) => { + f22.forEach((O) => { + l2.push(b$1``); }); - const J2 = {}; - return Se.forEach(([y22, u3]) => { - J2[y22] ? J2[y22].push(u3) : J2[y22] = [u3]; - }), Object.entries(J2).map(([y22, u3]) => { - const O2 = u3.filter((b22) => u3.every((E2) => !Ce(b22, E2, s2))); - return [Number(y22), O2]; - }).forEach(([y22, u3]) => { - u3.forEach((O2) => { - l2.push( - b`` - ); - }); - }), Object.entries(J2).filter(([y22, u3]) => u3.length > 1).map(([y22, u3]) => { - const O2 = u3.filter((b22) => u3.some((E2) => Ce(b22, E2, s2))); - return [Number(y22), O2]; - }).map(([y22, u3]) => { - u3.sort((b22, E2) => b22 < E2 ? -1 : 1); - const O2 = []; - for (const b22 of u3) { - const E2 = O2.find((M2) => M2.some((V2) => Ce(b22, V2, s2))); - E2 ? E2.push(b22) : O2.push([b22]); - } - return [y22, O2.map((b22) => [b22[0], b22[b22.length - 1]])]; - }).forEach(([y22, u3]) => { - u3.forEach(([O2, b$12]) => { - l2.push( - b`` - ); - }); - }), l2; - } - }, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; - var Zt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, q = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? St(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Zt(o3, r2, t2), t2; - }; - let j = class extends s { + }), Object.entries(oe2).filter(([$2, f22]) => f22.length > 1).map(([$2, f22]) => { + const O = f22.filter((x2) => f22.some((E2) => Ie(x2, E2, c2))); + return [Number($2), O]; + }).map(([$2, f22]) => { + f22.sort((x2, E2) => x2 < E2 ? -1 : 1); + const O = []; + for (const x2 of f22) { + const E2 = O.find((M2) => M2.some((Q2) => Ie(x2, Q2, c2))); + E2 ? E2.push(x2) : O.push([x2]); + } + return [$2, O.map((x2) => [x2[0], x2[x2.length - 1]])]; + }).forEach(([$2, f22]) => { + f22.forEach(([O, x2]) => { + l2.push(b$1``); + }); + }), l2; + } }, Nt = i$3`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; + var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Y = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? zt(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Zt(o3, r22, t2), t2; + }; + let D = class extends s$1 { constructor() { super(...arguments), this.uri = "", this.size = 0, this.imageId = void 0, this.walletId = void 0, this.imageUrl = void 0; } svgTemplate() { - const e2 = ne$1.state.themeMode === "light" ? this.size : this.size - 36; - return b`${Dt.generate(this.uri, e2, e2 / 4)}`; + const e2 = ne$3.state.themeMode === "light" ? this.size : this.size - 36; + return b$1`${Dt.generate(this.uri, e2, e2 / 4)}`; } render() { - const e2 = { "wcm-dark": ne$1.state.themeMode === "dark" }; - return x`
${this.walletId || this.imageUrl ? x`` : v.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; + const e2 = { "wcm-dark": ne$3.state.themeMode === "dark" }; + return x`
${this.walletId || this.imageUrl ? x`` : b.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; } }; - j.styles = [h.globalCss, Nt], q([n$1()], j.prototype, "uri", 2), q([n$1({ type: Number })], j.prototype, "size", 2), q([n$1()], j.prototype, "imageId", 2), q([n$1()], j.prototype, "walletId", 2), q([n$1()], j.prototype, "imageUrl", 2), j = q([e$2("wcm-qrcode")], j); - const Bt = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; - var Ut = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Ht(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Ut(o3, r2, t2), t2; + D.styles = [h.globalCss, Nt], Y([n$1()], D.prototype, "uri", 2), Y([n$1({ type: Number })], D.prototype, "size", 2), Y([n$1()], D.prototype, "imageId", 2), Y([n$1()], D.prototype, "walletId", 2), Y([n$1()], D.prototype, "imageUrl", 2), D = Y([e$2("wcm-qrcode")], D); + const St = i$3`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; + var Bt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, qe = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Ut(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Bt(o3, r22, t2), t2; }; - let ce = class extends s { + let me = class extends s$1 { constructor() { super(...arguments), this.onChange = () => null; } render() { - return x` ${v.SEARCH_ICON}`; + return x` ${b.SEARCH_ICON}`; } }; - ce.styles = [h.globalCss, Bt], Fe([n$1()], ce.prototype, "onChange", 2), ce = Fe([e$2("wcm-search-input")], ce); - const zt = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; - var Vt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, qt = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Ft(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Vt(o3, r2, t2), t2; + me.styles = [h.globalCss, St], qe([n$1()], me.prototype, "onChange", 2), me = qe([e$2("wcm-search-input")], me); + const Ht = i$3`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; + var Ft = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let ke = class extends s { + let We = class extends s$1 { render() { return x``; } }; - ke.styles = [h.globalCss, zt], ke = qt([e$2("wcm-spinner")], ke); + We.styles = [h.globalCss, Ht], We = Ft([e$2("wcm-spinner")], We); const Qt = i$3`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`; - var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Oe = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Yt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Kt(o3, r2, t2), t2; + var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Ee = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Yt(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Kt(o3, r22, t2), t2; }; - let re = class extends s { + let ie = class extends s$1 { constructor() { super(...arguments), this.variant = "medium-regular", this.color = "primary"; } render() { - const e2 = { - "wcm-big-bold": this.variant === "big-bold", - "wcm-medium-regular": this.variant === "medium-regular", - "wcm-small-regular": this.variant === "small-regular", - "wcm-small-thin": this.variant === "small-thin", - "wcm-xsmall-regular": this.variant === "xsmall-regular", - "wcm-xsmall-bold": this.variant === "xsmall-bold", - "wcm-color-primary": this.color === "primary", - "wcm-color-secondary": this.color === "secondary", - "wcm-color-tertiary": this.color === "tertiary", - "wcm-color-inverse": this.color === "inverse", - "wcm-color-accnt": this.color === "accent", - "wcm-color-error": this.color === "error" - }; + const e2 = { "wcm-big-bold": this.variant === "big-bold", "wcm-medium-regular": this.variant === "medium-regular", "wcm-small-regular": this.variant === "small-regular", "wcm-small-thin": this.variant === "small-thin", "wcm-xsmall-regular": this.variant === "xsmall-regular", "wcm-xsmall-bold": this.variant === "xsmall-bold", "wcm-color-primary": this.color === "primary", "wcm-color-secondary": this.color === "secondary", "wcm-color-tertiary": this.color === "tertiary", "wcm-color-inverse": this.color === "inverse", "wcm-color-accnt": this.color === "accent", "wcm-color-error": this.color === "error" }; return x``; } }; - re.styles = [h.globalCss, Qt], Oe([n$1()], re.prototype, "variant", 2), Oe([n$1()], re.prototype, "color", 2), re = Oe([e$2("wcm-text")], re); + ie.styles = [h.globalCss, Qt], Ee([n$1()], ie.prototype, "variant", 2), Ee([n$1()], ie.prototype, "color", 2), ie = Ee([e$2("wcm-text")], ie); const Gt = i$3`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`; - var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, _ = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Jt(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Xt(o3, r2, t2), t2; + var Xt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, N2 = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Jt(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Xt(o3, r22, t2), t2; }; - let L2 = class extends s { + let P = class extends s$1 { constructor() { super(...arguments), this.onClick = () => null, this.name = "", this.walletId = "", this.label = void 0, this.imageId = void 0, this.installed = false, this.recent = false; } @@ -30912,79 +37953,76 @@ return this.recent ? x`RECENT` : this.installed ? x`INSTALLED` : null; } handleClick() { - R$4.click({ name: "WALLET_BUTTON", walletId: this.walletId }), this.onClick(); + R$1.click({ name: "WALLET_BUTTON", walletId: this.walletId }), this.onClick(); } render() { var e2; - return x``; + return x``; } }; - L2.styles = [h.globalCss, Gt], _([n$1()], L2.prototype, "onClick", 2), _([n$1()], L2.prototype, "name", 2), _([n$1()], L2.prototype, "walletId", 2), _([n$1()], L2.prototype, "label", 2), _([n$1()], L2.prototype, "imageId", 2), _([n$1({ type: Boolean })], L2.prototype, "installed", 2), _([n$1({ type: Boolean })], L2.prototype, "recent", 2), L2 = _([e$2("wcm-wallet-button")], L2); + P.styles = [h.globalCss, Gt], N2([n$1()], P.prototype, "onClick", 2), N2([n$1()], P.prototype, "name", 2), N2([n$1()], P.prototype, "walletId", 2), N2([n$1()], P.prototype, "label", 2), N2([n$1()], P.prototype, "imageId", 2), N2([n$1({ type: Boolean })], P.prototype, "installed", 2), N2([n$1({ type: Boolean })], P.prototype, "recent", 2), P = N2([e$2("wcm-wallet-button")], P); const eo = i$3`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; - var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, se = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? oo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && to(o3, r2, t2), t2; + var to = Object.defineProperty, oo = Object.getOwnPropertyDescriptor, we = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? oo(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && to(o3, r22, t2), t2; }; - let Q = class extends s { + let G = class extends s$1 { constructor() { super(...arguments), this.walletId = "", this.imageId = void 0, this.imageUrl = void 0; } render() { var e2; - const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : c.getWalletIcon({ id: this.walletId, image_id: this.imageId }); - return x`${o3.length ? x`
${this.id}
` : v.WALLET_PLACEHOLDER}`; + const o3 = (e2 = this.imageUrl) != null && e2.length ? this.imageUrl : s2.getWalletIcon({ id: this.walletId, image_id: this.imageId }); + return x`${o3.length ? x`
${this.id}
` : b.WALLET_PLACEHOLDER}`; } }; - Q.styles = [h.globalCss, eo], se([n$1()], Q.prototype, "walletId", 2), se([n$1()], Q.prototype, "imageId", 2), se([n$1()], Q.prototype, "imageUrl", 2), Q = se([e$2("wcm-wallet-image")], Q); - var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, qe = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? ao(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && ro(o3, r2, t2), t2; + G.styles = [h.globalCss, eo], we([n$1()], G.prototype, "walletId", 2), we([n$1()], G.prototype, "imageId", 2), we([n$1()], G.prototype, "imageUrl", 2), G = we([e$2("wcm-wallet-image")], G); + var ro = Object.defineProperty, ao = Object.getOwnPropertyDescriptor, Fe = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? ao(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && ro(o3, r22, t2), t2; }; - let We = class extends s { + let Me = class extends s$1 { constructor() { super(), this.preload = true, this.preloadData(); } async loadImages(e2) { try { - e2 != null && e2.length && await Promise.all(e2.map(async (o3) => c.preloadImage(o3))); + e2 != null && e2.length && await Promise.all(e2.map(async (o3) => s2.preloadImage(o3))); } catch { console.info("Unsuccessful attempt at preloading some images", e2); } } async preloadListings() { - if (y$3.state.enableExplorer) { - await te$2.getRecomendedWallets(), p$3.setIsDataLoaded(true); - const { recomendedWallets: e2 } = te$2.state, o3 = e2.map((r2) => c.getWalletIcon(r2)); + if (y$4.state.enableExplorer) { + await te$1.getRecomendedWallets(), p$2.setIsDataLoaded(true); + const { recomendedWallets: e2 } = te$1.state, o3 = e2.map((r22) => s2.getWalletIcon(r22)); await this.loadImages(o3); } else - p$3.setIsDataLoaded(true); + p$2.setIsDataLoaded(true); } async preloadCustomImages() { - const e2 = c.getCustomImageUrls(); + const e2 = s2.getCustomImageUrls(); await this.loadImages(e2); } async preloadData() { try { - this.preload && (this.preload = false, await Promise.all([ - this.preloadListings(), - this.preloadCustomImages() - ])); + this.preload && (this.preload = false, await Promise.all([this.preloadListings(), this.preloadCustomImages()])); } catch (e2) { - console.error(e2), oe$1.openToast("Failed preloading", "error"); + console.error(e2), oe$2.openToast("Failed preloading", "error"); } } }; - qe([t$1()], We.prototype, "preload", 2), We = qe([e$2("wcm-explorer-context")], We); - var lo = Object.defineProperty, io = Object.getOwnPropertyDescriptor, no = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? io(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && lo(o3, r2, t2), t2; + Fe([t$1()], Me.prototype, "preload", 2), Me = Fe([e$2("wcm-explorer-context")], Me); + var no = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Qe = class extends s { + let Qe = class extends s$1 { constructor() { - super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = ne$1.subscribe(h.setTheme); + super(), this.unsubscribeTheme = void 0, h.setTheme(), this.unsubscribeTheme = ne$3.subscribe(h.setTheme); } disconnectedCallback() { var e2; @@ -30993,44 +38031,42 @@ }; Qe = no([e$2("wcm-theme-context")], Qe); const co = i$3`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; - var so = Object.defineProperty, mo = Object.getOwnPropertyDescriptor, ho = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? mo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && so(o3, r2, t2), t2; + var wo = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Ie = class extends s { + let Pe = class extends s$1 { onConnect(e2) { - a$3.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + i$1$1.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onGoToQrcode() { - T$1$1.push("Qrcode"); + T$2.push("Qrcode"); } render() { - const { recomendedWallets: e2 } = te$2.state, o3 = [...e2, ...e2], r2 = a$3.RECOMMENDED_WALLET_AMOUNT * 2; - return x`
${v.MOBILE_ICON}WalletConnect
${[ - ...Array(r2) - ].map((a22, t2) => { + const { recomendedWallets: e2 } = te$1.state, o3 = [...e2, ...e2], r22 = i$1$1.RECOMMENDED_WALLET_AMOUNT * 2; + return x`
${b.MOBILE_ICON}WalletConnect
${[...Array(r22)].map((a22, t2) => { const l2 = o3[t2 % o3.length]; - return l2 ? x`` : v.WALLET_PLACEHOLDER; + return l2 ? x`` : b.WALLET_PLACEHOLDER; })}
Select Wallet
Choose WalletConnect to see supported apps on your device`; } }; - Ie.styles = [h.globalCss, co], Ie = ho([e$2("wcm-android-wallet-selection")], Ie); - const wo = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; - var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, K = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? go(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && po(o3, r2, t2), t2; + Pe.styles = [h.globalCss, co], Pe = wo([e$2("wcm-android-wallet-selection")], Pe); + const ho = i$3`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; + var po = Object.defineProperty, go = Object.getOwnPropertyDescriptor, X = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? go(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && po(o3, r22, t2), t2; }; - let D = class extends s { + let Z2 = class extends s$1 { constructor() { super(...arguments), this.walletId = void 0, this.imageId = void 0, this.isError = false, this.isStale = false, this.label = ""; } svgLoaderTemplate() { var e2, o3; - const r2 = (o3 = (e2 = ne$1.state.themeVariables) == null ? void 0 : e2["--wcm-wallet-icon-large-border-radius"]) != null ? o3 : h.getPreset("--wcm-wallet-icon-large-border-radius"); + const r22 = (o3 = (e2 = ne$3.state.themeVariables) == null ? void 0 : e2["--wcm-wallet-icon-large-border-radius"]) != null ? o3 : h.getPreset("--wcm-wallet-icon-large-border-radius"); let a22 = 0; - r2.includes("%") ? a22 = 88 / 100 * parseInt(r2, 10) : a22 = parseInt(r2, 10), a22 *= 1.17; + r22.includes("%") ? a22 = 88 / 100 * parseInt(r22, 10) : a22 = parseInt(r22, 10), a22 *= 1.17; const t2 = 317 - a22 * 1.57, l2 = 425 - a22 * 1.8; return x``; } @@ -31039,113 +38075,90 @@ return x`
${this.svgLoaderTemplate()}
${this.isError ? "Connection declined" : this.label}`; } }; - D.styles = [h.globalCss, wo], K([n$1()], D.prototype, "walletId", 2), K([n$1()], D.prototype, "imageId", 2), K([n$1({ type: Boolean })], D.prototype, "isError", 2), K([n$1({ type: Boolean })], D.prototype, "isStale", 2), K([n$1()], D.prototype, "label", 2), D = K([e$2("wcm-connector-waiting")], D); - const G = { - manualWallets() { - var e2, o3; - const { mobileWallets: r2, desktopWallets: a22 } = y$3.state, t2 = (e2 = G.recentWallet()) == null ? void 0 : e2.id, l2 = a$3.isMobile() ? r2 : a22, i2 = l2 == null ? void 0 : l2.filter((s2) => t2 !== s2.id); - return (o3 = a$3.isMobile() ? i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - mobile: f2, - links: f2 - })) : i2 == null ? void 0 : i2.map(({ id: s2, name: $2, links: f2 }) => ({ - id: s2, - name: $2, - desktop: f2, - links: f2 - }))) != null ? o3 : []; - }, - recentWallet() { - return c.getRecentWallet(); - }, - recomendedWallets(e2 = false) { - var o3; - const r2 = e2 || (o3 = G.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a22 } = te$2.state; - return a22.filter((t2) => r2 !== t2.id); - } - }, Z2 = { - onConnecting(e2) { - c.goToConnectingView(e2); - }, - manualWalletsTemplate() { - return G.manualWallets().map( - (e2) => x`` - ); - }, - recomendedWalletsTemplate(e2 = false) { - return G.recomendedWallets(e2).map( - (o3) => x`` - ); - }, - recentWalletTemplate() { - const e2 = G.recentWallet(); - if (e2) - return x``; - } - }, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; - var uo = Object.defineProperty, bo = Object.getOwnPropertyDescriptor, fo = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? bo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && uo(o3, r2, t2), t2; - }; - let Ee = class extends s { + Z2.styles = [h.globalCss, ho], X([n$1()], Z2.prototype, "walletId", 2), X([n$1()], Z2.prototype, "imageId", 2), X([n$1({ type: Boolean })], Z2.prototype, "isError", 2), X([n$1({ type: Boolean })], Z2.prototype, "isStale", 2), X([n$1()], Z2.prototype, "label", 2), Z2 = X([e$2("wcm-connector-waiting")], Z2); + const ee = { manualWallets() { + var e2, o3; + const { mobileWallets: r22, desktopWallets: a22 } = y$4.state, t2 = (e2 = ee.recentWallet()) == null ? void 0 : e2.id, l2 = i$1$1.isMobile() ? r22 : a22, i2 = l2 == null ? void 0 : l2.filter((c2) => t2 !== c2.id); + return (o3 = i$1$1.isMobile() ? i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w22 }) => ({ id: c2, name: u3, mobile: w22, links: w22 })) : i2 == null ? void 0 : i2.map(({ id: c2, name: u3, links: w22 }) => ({ id: c2, name: u3, desktop: w22, links: w22 }))) != null ? o3 : []; + }, recentWallet() { + return s2.getRecentWallet(); + }, recomendedWallets(e2 = false) { + var o3; + const r22 = e2 || (o3 = ee.recentWallet()) == null ? void 0 : o3.id, { recomendedWallets: a22 } = te$1.state; + return a22.filter((t2) => r22 !== t2.id); + } }, S = { onConnecting(e2) { + s2.goToConnectingView(e2); + }, manualWalletsTemplate() { + return ee.manualWallets().map((e2) => x``); + }, recomendedWalletsTemplate(e2 = false) { + return ee.recomendedWallets(e2).map((o3) => x``); + }, recentWalletTemplate() { + const e2 = ee.recentWallet(); + if (e2) + return x``; + } }, vo = i$3`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; + var fo = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; + }; + let Le = class extends s$1 { render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$3.state, r2 = e2 !== "ALL" && o3, a22 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a22, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$4.state, r22 = e2 !== "ALL" && o3, a22 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a22, ...t2]; l2 = l2.filter(Boolean); - const i2 = l2.length > 4 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 3) : s2 = l2; - const $2 = Boolean(s2.length); - return x`
${v.MOBILE_ICON}Mobile
${v.SCAN_ICON}Scan with your wallet
${$2 ? x`
${v.DESKTOP_ICON}Desktop
${s2} ${i2 ? x`` : null}
` : null}`; + const i2 = l2.length > 4 || r22; + let c2 = []; + i2 ? c2 = l2.slice(0, 3) : c2 = l2; + const u3 = Boolean(c2.length); + return x`
${b.MOBILE_ICON}Mobile
${b.SCAN_ICON}Scan with your wallet
${u3 ? x`
${b.DESKTOP_ICON}Desktop
${c2} ${i2 ? x`` : null}
` : null}`; } }; - Ee.styles = [h.globalCss, vo], Ee = fo([e$2("wcm-desktop-wallet-selection")], Ee); + Le.styles = [h.globalCss, vo], Le = fo([e$2("wcm-desktop-wallet-selection")], Le); const xo = i$3`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`; - var yo = Object.defineProperty, $o = Object.getOwnPropertyDescriptor, Co = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? $o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && yo(o3, r2, t2), t2; + var Co = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Me = class extends s { + let Re = class extends s$1 { render() { - const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = y$3.state; + const { termsOfServiceUrl: e2, privacyPolicyUrl: o3 } = y$4.state; return e2 ?? o3 ? x`
By connecting your wallet to this app, you agree to the app's ${e2 ? x`Terms of Service` : null} ${e2 && o3 ? "and" : null} ${o3 ? x`Privacy Policy` : null}
` : null; } }; - Me.styles = [h.globalCss, xo], Me = Co([e$2("wcm-legal-notice")], Me); + Re.styles = [h.globalCss, xo], Re = Co([e$2("wcm-legal-notice")], Re); const ko = i$3`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`; - var Oo = Object.defineProperty, Wo = Object.getOwnPropertyDescriptor, Io = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Wo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Oo(o3, r2, t2), t2; + var Wo = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Le = class extends s { + let Ae = class extends s$1 { onQrcode() { - T$1$1.push("Qrcode"); + T$2.push("Qrcode"); } render() { - const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$3.state, r2 = e2 !== "ALL" && o3, a22 = Z2.manualWalletsTemplate(), t2 = Z2.recomendedWalletsTemplate(); - let l2 = [Z2.recentWalletTemplate(), ...a22, ...t2]; + const { explorerExcludedWalletIds: e2, enableExplorer: o3 } = y$4.state, r22 = e2 !== "ALL" && o3, a22 = S.manualWalletsTemplate(), t2 = S.recomendedWalletsTemplate(); + let l2 = [S.recentWalletTemplate(), ...a22, ...t2]; l2 = l2.filter(Boolean); - const i2 = l2.length > 8 || r2; - let s2 = []; - i2 ? s2 = l2.slice(0, 7) : s2 = l2; - const $2 = Boolean(s2.length); - return x`${$2 ? x`
${s2} ${i2 ? x`` : null}
` : null}`; + const i2 = l2.length > 8 || r22; + let c2 = []; + i2 ? c2 = l2.slice(0, 7) : c2 = l2; + const u3 = Boolean(c2.length); + return x`${u3 ? x`
${c2} ${i2 ? x`` : null}
` : null}`; } }; - Le.styles = [h.globalCss, ko], Le = Io([e$2("wcm-mobile-wallet-selection")], Le); + Ae.styles = [h.globalCss, ko], Ae = Wo([e$2("wcm-mobile-wallet-selection")], Ae); const Eo = i$3`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`; - var Mo = Object.defineProperty, Lo = Object.getOwnPropertyDescriptor, Re = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Lo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Mo(o3, r2, t2), t2; + var Mo = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, Te = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Po(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Mo(o3, r22, t2), t2; }; - let ae = class extends s { + let ne = class extends s$1 { constructor() { - super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = se$1.subscribe((e2) => { + super(), this.open = false, this.active = false, this.unsubscribeModal = void 0, this.abortController = void 0, this.unsubscribeModal = se$3.subscribe((e2) => { e2.open ? this.onOpenModalEvent() : this.onCloseModalEvent(); }); } @@ -31154,10 +38167,10 @@ (e2 = this.unsubscribeModal) == null || e2.call(this); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-overlay"); + return s2.getShadowRootElement(this, ".wcm-overlay"); } get containerEl() { - return c.getShadowRootElement(this, ".wcm-container"); + return s2.getShadowRootElement(this, ".wcm-container"); } toggleBodyScroll(e2) { if (document.querySelector("body")) @@ -31165,40 +38178,27 @@ const o3 = document.getElementById("wcm-styles"); o3 == null ? void 0 : o3.remove(); } else - document.head.insertAdjacentHTML( - "beforeend", - '' - ); + document.head.insertAdjacentHTML("beforeend", ''); } onCloseModal(e2) { - e2.target === e2.currentTarget && se$1.close(); + e2.target === e2.currentTarget && se$3.close(); } onOpenModalEvent() { this.toggleBodyScroll(false), this.addKeyboardEvents(), this.open = true, setTimeout(async () => { - const e2 = c.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r2 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r2 }).finished, - animate(this.containerEl, e2, { delay: o3, duration: r2 }).finished - ]), this.active = true; + const e2 = s2.isMobileAnimation() ? { y: ["50vh", "0vh"] } : { scale: [0.98, 1] }, o3 = 0.1, r22 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [0, 1] }, { delay: o3, duration: r22 }).finished, animate(this.containerEl, e2, { delay: o3, duration: r22 }).finished]), this.active = true; }, 0); } async onCloseModalEvent() { this.toggleBodyScroll(true), this.removeKeyboardEvents(); - const e2 = c.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; - await Promise.all([ - animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, - animate(this.containerEl, e2, { duration: o3 }).finished - ]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; + const e2 = s2.isMobileAnimation() ? { y: ["0vh", "50vh"] } : { scale: [1, 0.98] }, o3 = 0.2; + await Promise.all([animate(this.overlayEl, { opacity: [1, 0] }, { duration: o3 }).finished, animate(this.containerEl, e2, { duration: o3 }).finished]), this.containerEl.removeAttribute("style"), this.active = false, this.open = false; } addKeyboardEvents() { - this.abortController = new AbortController(), window.addEventListener( - "keydown", - (e2) => { - var o3; - e2.key === "Escape" ? se$1.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); - }, - this.abortController - ), this.containerEl.focus(); + this.abortController = new AbortController(), window.addEventListener("keydown", (e2) => { + var o3; + e2.key === "Escape" ? se$3.close() : e2.key === "Tab" && ((o3 = e2.target) != null && o3.tagName.includes("wcm-") || this.containerEl.focus()); + }, this.abortController), this.containerEl.focus(); } removeKeyboardEvents() { var e2; @@ -31209,212 +38209,213 @@ return x`
${this.open ? x`
` : null}
`; } }; - ae.styles = [h.globalCss, Eo], Re([t$1()], ae.prototype, "open", 2), Re([t$1()], ae.prototype, "active", 2), ae = Re([e$2("wcm-modal")], ae); - const Ro = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; - var Ao = Object.defineProperty, Po = Object.getOwnPropertyDescriptor, le = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Po(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Ao(o3, r2, t2), t2; + ne.styles = [h.globalCss, Eo], Te([t$1()], ne.prototype, "open", 2), Te([t$1()], ne.prototype, "active", 2), ne = Te([e$2("wcm-modal")], ne); + const Lo = i$3`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; + var Ro = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, ce = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Ao(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Ro(o3, r22, t2), t2; }; - let B = class extends s { + let U = class extends s$1 { constructor() { super(...arguments), this.isMobile = false, this.isDesktop = false, this.isWeb = false, this.isRetry = false; } onMobile() { - a$3.isMobile() ? T$1$1.replace("MobileConnecting") : T$1$1.replace("MobileQrcodeConnecting"); + i$1$1.isMobile() ? T$2.replace("MobileConnecting") : T$2.replace("MobileQrcodeConnecting"); } onDesktop() { - T$1$1.replace("DesktopConnecting"); + T$2.replace("DesktopConnecting"); } onWeb() { - T$1$1.replace("WebConnecting"); + T$2.replace("WebConnecting"); } render() { - return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; + return x`
${this.isRetry ? x`` : null} ${this.isMobile ? x`Mobile` : null} ${this.isDesktop ? x`Desktop` : null} ${this.isWeb ? x`Web` : null}
`; } }; - B.styles = [h.globalCss, Ro], le([n$1({ type: Boolean })], B.prototype, "isMobile", 2), le([n$1({ type: Boolean })], B.prototype, "isDesktop", 2), le([n$1({ type: Boolean })], B.prototype, "isWeb", 2), le([n$1({ type: Boolean })], B.prototype, "isRetry", 2), B = le([e$2("wcm-platform-selection")], B); + U.styles = [h.globalCss, Lo], ce([n$1({ type: Boolean })], U.prototype, "isMobile", 2), ce([n$1({ type: Boolean })], U.prototype, "isDesktop", 2), ce([n$1({ type: Boolean })], U.prototype, "isWeb", 2), ce([n$1({ type: Boolean })], U.prototype, "isRetry", 2), U = ce([e$2("wcm-platform-selection")], U); const To = i$3`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; - var jo = Object.defineProperty, _o = Object.getOwnPropertyDescriptor, Do = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? _o(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && jo(o3, r2, t2), t2; + var Do = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Ae = class extends s { + let je = class extends s$1 { onClick() { - T$1$1.push("WalletExplorer"); + T$2.push("WalletExplorer"); } render() { - const { recomendedWallets: e2 } = te$2.state, o3 = G.manualWallets(), r2 = [...e2, ...o3].reverse().slice(0, 4); - return x``; + const { recomendedWallets: e2 } = te$1.state, o3 = ee.manualWallets(), r22 = [...e2, ...o3].reverse().slice(0, 4); + return x``; } }; - Ae.styles = [h.globalCss, To], Ae = Do([e$2("wcm-view-all-wallets-button")], Ae); + je.styles = [h.globalCss, To], je = Do([e$2("wcm-view-all-wallets-button")], je); const No = i$3`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`; - var Zo = Object.defineProperty, So = Object.getOwnPropertyDescriptor, de = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? So(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Zo(o3, r2, t2), t2; + var Zo = Object.defineProperty, zo = Object.getOwnPropertyDescriptor, he = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? zo(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Zo(o3, r22, t2), t2; }; - let Y = class extends s { + let J = class extends s$1 { constructor() { super(), this.walletId = "", this.imageId = "", this.uri = "", setTimeout(() => { - const { walletConnectUri: e2 } = p$3.state; + const { walletConnectUri: e2 } = p$2.state; this.uri = e2; }, 0); } get overlayEl() { - return c.getShadowRootElement(this, ".wcm-qr-container"); + return s2.getShadowRootElement(this, ".wcm-qr-container"); } render() { return x`
${this.uri ? x`` : x``}
`; } }; - Y.styles = [h.globalCss, No], de([n$1()], Y.prototype, "walletId", 2), de([n$1()], Y.prototype, "imageId", 2), de([t$1()], Y.prototype, "uri", 2), Y = de([e$2("wcm-walletconnect-qr")], Y); - var Bo = Object.defineProperty, Uo = Object.getOwnPropertyDescriptor, Ho = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Uo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Bo(o3, r2, t2), t2; + J.styles = [h.globalCss, No], he([n$1()], J.prototype, "walletId", 2), he([n$1()], J.prototype, "imageId", 2), he([t$1()], J.prototype, "uri", 2), J = he([e$2("wcm-walletconnect-qr")], J); + var Uo = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Pe = class extends s { + let _e = class extends s$1 { viewTemplate() { - return a$3.isAndroid() ? x`` : a$3.isMobile() ? x`` : x``; + return i$1$1.isAndroid() ? x`` : i$1$1.isMobile() ? x`` : x``; } render() { return x`${this.viewTemplate()}`; } }; - Pe.styles = [h.globalCss], Pe = Ho([e$2("wcm-connect-wallet-view")], Pe); - const zo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; - var Vo = Object.defineProperty, Fo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Fo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Vo(o3, r2, t2), t2; + _e.styles = [h.globalCss], _e = Uo([e$2("wcm-connect-wallet-view")], _e); + const Ho = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; + var Vo = Object.defineProperty, qo = Object.getOwnPropertyDescriptor, Ke = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? qo(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Vo(o3, r22, t2), t2; }; - let me = class extends s { + let pe = class extends s$1 { constructor() { super(), this.isError = false, this.openDesktopApp(); } onFormatAndRedirect(e2) { - const { desktop: o3, name: r2 } = a$3.getWalletRouterData(), a22 = o3 == null ? void 0 : o3.native; - if (a22) { - const t2 = a$3.formatNativeUrl(a22, e2, r2); - a$3.openHref(t2, "_self"); + var o3; + const { desktop: r22, name: a22 } = i$1$1.getWalletRouterData(), t2 = r22 == null ? void 0 : r22.native; + if (t2) { + const l2 = i$1$1.formatNativeUrl(t2, e2, a22); + if (a22 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w22 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w22 ?? void 0 } }); + } else + i$1$1.openHref(l2, "_self"); } } openDesktopApp() { - const { walletConnectUri: e2 } = p$3.state, o3 = a$3.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = p$2.state, o3 = i$1$1.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = a$3.getWalletRouterData(), { isMobile: a22, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; + const { name: e2, id: o3, image_id: r22 } = i$1$1.getWalletRouterData(), { isMobile: a22, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Connection can continue loading if ${e2} is not installed on your device`}Retry`; } }; - me.styles = [h.globalCss, zo], Ke([t$1()], me.prototype, "isError", 2), me = Ke([e$2("wcm-desktop-connecting-view")], me); - const qo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; - var Qo = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, Yo = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Ko(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Qo(o3, r2, t2), t2; + pe.styles = [h.globalCss, Ho], Ke([t$1()], pe.prototype, "isError", 2), pe = Ke([e$2("wcm-desktop-connecting-view")], pe); + const Fo = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; + var Yo = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let Te = class extends s { + let De = class extends s$1 { onInstall(e2) { - e2 && a$3.openHref(e2, "_blank"); + e2 && i$1$1.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - homepage: a22 - } = a$3.getWalletRouterData(); - return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; + const { name: e2, id: o3, image_id: r22, homepage: a22 } = i$1$1.getWalletRouterData(); + return x`${`Download ${e2} to continue. If multiple browser extensions are installed, disable non ${e2} ones and try again`}Download`; } }; - Te.styles = [h.globalCss, qo], Te = Yo([e$2("wcm-install-wallet-view")], Te); + De.styles = [h.globalCss, Fo], De = Yo([e$2("wcm-install-wallet-view")], De); const Go = i$3`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`; - var Xo = Object.defineProperty, Jo = Object.getOwnPropertyDescriptor, Ye = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? Jo(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && Xo(o3, r2, t2), t2; + var Xo = Object.defineProperty, Jo = Object.getOwnPropertyDescriptor, Ye = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? Jo(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && Xo(o3, r22, t2), t2; }; - let he = class extends s { + let ge = class extends s$1 { constructor() { super(), this.isError = false, this.openMobileApp(); } onFormatAndRedirect(e2, o3 = false) { - const { mobile: r2, name: a22 } = a$3.getWalletRouterData(), t2 = r2 == null ? void 0 : r2.native, l2 = r2 == null ? void 0 : r2.universal; - if (t2 && !o3) { - const i2 = a$3.formatNativeUrl(t2, e2, a22); - a$3.openHref(i2, "_self"); - } else if (l2) { - const i2 = a$3.formatUniversalUrl(l2, e2, a22); - a$3.openHref(i2, "_self"); + var r22, a22; + const { mobile: t2, name: l2 } = i$1$1.getWalletRouterData(), i2 = t2 == null ? void 0 : t2.native, c2 = t2 == null ? void 0 : t2.universal; + if (i2 && !o3) { + const u3 = i$1$1.formatNativeUrl(i2, e2, l2); + if (l2 === "Puzzle Wallet" && (r22 = window == null ? void 0 : window.aleo) != null && r22.connectPuzzle) { + const w22 = new URL(u3).searchParams, F2 = w22.get("uri"), T2 = w22.get("requestId"), j2 = w22.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F2, requestId: T2 ?? void 0, sessionTopic: j2 ?? void 0 } }); + } else + i$1$1.openHref(u3, "_self"); + } else if (c2) { + const u3 = i$1$1.formatUniversalUrl(c2, e2, l2); + if (l2 === "Puzzle Wallet" && (a22 = window == null ? void 0 : window.aleo) != null && a22.connectPuzzle) { + const w22 = new URL(u3).searchParams, F2 = w22.get("uri"), T2 = w22.get("requestId"), j2 = w22.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: F2, requestId: T2 ?? void 0, sessionTopic: j2 ?? void 0 } }); + } else + i$1$1.openHref(u3, "_self"); } } openMobileApp(e2 = false) { - const { walletConnectUri: o3 } = p$3.state, r2 = a$3.getWalletRouterData(); - c.setRecentWallet(r2), o3 && this.onFormatAndRedirect(o3, e2); + const { walletConnectUri: o3 } = p$2.state, r22 = i$1$1.getWalletRouterData(); + s2.setRecentWallet(r22), o3 && this.onFormatAndRedirect(o3, e2); } onGoToAppStore(e2) { - e2 && a$3.openHref(e2, "_blank"); + e2 && i$1$1.openHref(e2, "_blank"); } render() { - const { - name: e2, - id: o3, - image_id: r2, - app: a22, - mobile: t2 - } = a$3.getWalletRouterData(), { isWeb: l$12 } = c.getCachedRouterWalletPlatforms(), i2 = a22 == null ? void 0 : a22.ios, s2 = t2 == null ? void 0 : t2.universal; - return x`Retry${s2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; + const { name: e2, id: o3, image_id: r22, app: a22, mobile: t2 } = i$1$1.getWalletRouterData(), { isWeb: l$12 } = s2.getCachedRouterWalletPlatforms(), i2 = a22 == null ? void 0 : a22.ios, c2 = t2 == null ? void 0 : t2.universal; + return x`Retry${c2 ? x`Still doesn't work? Try this alternate link` : null}
${`Get ${e2}`}
App Store
`; } }; - he.styles = [h.globalCss, Go], Ye([t$1()], he.prototype, "isError", 2), he = Ye([e$2("wcm-mobile-connecting-view")], he); + ge.styles = [h.globalCss, Go], Ye([t$1()], ge.prototype, "isError", 2), ge = Ye([e$2("wcm-mobile-connecting-view")], ge); const er = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; - var tr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, rr = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? or(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && tr(o3, r2, t2), t2; + var rr = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let je = class extends s { + let Ne = class extends s$1 { render() { - const { name: e2, id: o3, image_id: r2 } = a$3.getWalletRouterData(), { isDesktop: a22, isWeb: t2 } = c.getCachedRouterWalletPlatforms(); - return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; + const { name: e2, id: o3, image_id: r22 } = i$1$1.getWalletRouterData(), { isDesktop: a22, isWeb: t2 } = s2.getCachedRouterWalletPlatforms(); + return x`${`Scan this QR Code with your phone's camera or inside ${e2} app`}`; } }; - je.styles = [h.globalCss, er], je = rr([e$2("wcm-mobile-qr-connecting-view")], je); - var ar = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, ir = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? lr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && ar(o3, r2, t2), t2; + Ne.styles = [h.globalCss, er], Ne = rr([e$2("wcm-mobile-qr-connecting-view")], Ne); + var ir = (e2, o3, r22, a22) => { + for (var t2 = o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = i2(t2) || t2); + return t2; }; - let _e = class extends s { + let Ze = class extends s$1 { render() { - return x``; + return x``; } }; - _e.styles = [h.globalCss], _e = ir([e$2("wcm-qrcode-view")], _e); + Ze.styles = [h.globalCss], Ze = ir([e$2("wcm-qrcode-view")], Ze); const nr = i$3`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`; - var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, ie = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? sr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && cr(o3, r2, t2), t2; + var cr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, se = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? sr(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && cr(o3, r22, t2), t2; }; - const De = 40; - let U = class extends s { + const ze = 40; + let H2 = class extends s$1 { constructor() { - super(...arguments), this.loading = !te$2.state.wallets.listings.length, this.firstFetch = !te$2.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = c.debounce((e2) => { - e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, te$2.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), te$2.resetSearch()); + super(...arguments), this.loading = !te$1.state.wallets.listings.length, this.firstFetch = !te$1.state.wallets.listings.length, this.search = "", this.endReached = false, this.intersectionObserver = void 0, this.searchDebounce = s2.debounce((e2) => { + e2.length >= 1 ? (this.firstFetch = true, this.endReached = false, this.search = e2, te$1.resetSearch(), this.fetchWallets()) : this.search && (this.search = "", this.endReached = this.isLastPage(), te$1.resetSearch()); }); } firstUpdated() { @@ -31425,7 +38426,7 @@ (e2 = this.intersectionObserver) == null || e2.disconnect(); } get placeholderEl() { - return c.getShadowRootElement(this, ".wcm-placeholder-block"); + return s2.getShadowRootElement(this, ".wcm-placeholder-block"); } createPaginationObserver() { this.intersectionObserver = new IntersectionObserver(([e2]) => { @@ -31433,102 +38434,78 @@ }), this.intersectionObserver.observe(this.placeholderEl); } isLastPage() { - const { wallets: e2, search: o3 } = te$2.state, { listings: r2, total: a22 } = this.search ? o3 : e2; - return a22 <= De || r2.length >= a22; + const { wallets: e2, search: o3 } = te$1.state, { listings: r22, total: a22 } = this.search ? o3 : e2; + return a22 <= ze || r22.length >= a22; } async fetchWallets() { var e2; - const { wallets: o3, search: r2 } = te$2.state, { listings: a22, total: t2, page: l2 } = this.search ? r2 : o3; - if (!this.endReached && (this.firstFetch || t2 > De && a22.length < t2)) + const { wallets: o3, search: r22 } = te$1.state, { listings: a22, total: t2, page: l2 } = this.search ? r22 : o3; + if (!this.endReached && (this.firstFetch || t2 > ze && a22.length < t2)) try { this.loading = true; - const i2 = (e2 = p$3.state.chains) == null ? void 0 : e2.join(","), { listings: s2 } = await te$2.getWallets({ - page: this.firstFetch ? 1 : l2 + 1, - entries: De, - search: this.search, - version: 2, - chains: i2 - }), $2 = s2.map((f2) => c.getWalletIcon(f2)); - await Promise.all([ - ...$2.map(async (f2) => c.preloadImage(f2)), - a$3.wait(300) - ]), this.endReached = this.isLastPage(); + const i2 = (e2 = p$2.state.chains) == null ? void 0 : e2.join(","), { listings: c2 } = await te$1.getWallets({ page: this.firstFetch ? 1 : l2 + 1, entries: ze, search: this.search, version: 2, chains: i2 }), u3 = c2.map((w22) => s2.getWalletIcon(w22)); + await Promise.all([...u3.map(async (w22) => s2.preloadImage(w22)), i$1$1.wait(300)]), this.endReached = this.isLastPage(); } catch (i2) { - console.error(i2), oe$1.openToast(c.getErrorMessage(i2), "error"); + console.error(i2), oe$2.openToast(s2.getErrorMessage(i2), "error"); } finally { this.loading = false, this.firstFetch = false; } } onConnect(e2) { - a$3.isAndroid() ? c.handleMobileLinking(e2) : c.goToConnectingView(e2); + i$1$1.isAndroid() ? s2.handleMobileLinking(e2) : s2.goToConnectingView(e2); } onSearchChange(e2) { const { value: o3 } = e2.target; this.searchDebounce(o3); } render() { - const { wallets: e2, search: o$12 } = te$2.state, { listings: r2 } = this.search ? o$12 : e2, a22 = this.loading && !r2.length, t2 = this.search.length >= 3; - let l2 = Z2.manualWalletsTemplate(), i2 = Z2.recomendedWalletsTemplate(true); - t2 && (l2 = l2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search)), i2 = i2.filter(({ values: f2 }) => c.caseSafeIncludes(f2[0], this.search))); - const s2 = !this.loading && !r2.length && !i2.length, $2 = { - "wcm-loading": a22, - "wcm-end-reached": this.endReached || !this.loading, - "wcm-empty": s2 - }; - return x`
${a22 ? null : l2} ${a22 ? null : i2} ${a22 ? null : r2.map((f2) => x`${f2 ? x`` : null}`)}
${s2 ? x`No results found` : null} ${!s2 && this.loading ? x`` : null}
`; + const { wallets: e2, search: o$12 } = te$1.state, { listings: r22 } = this.search ? o$12 : e2, a22 = this.loading && !r22.length, t2 = this.search.length >= 3; + let l2 = S.manualWalletsTemplate(), i2 = S.recomendedWalletsTemplate(true); + t2 && (l2 = l2.filter(({ values: w22 }) => s2.caseSafeIncludes(w22[0], this.search)), i2 = i2.filter(({ values: w22 }) => s2.caseSafeIncludes(w22[0], this.search))); + const c2 = !this.loading && !r22.length && !i2.length, u3 = { "wcm-loading": a22, "wcm-end-reached": this.endReached || !this.loading, "wcm-empty": c2 }; + return x`
${a22 ? null : l2} ${a22 ? null : i2} ${a22 ? null : r22.map((w22) => x`${w22 ? x`` : null}`)}
${c2 ? x`No results found` : null} ${!c2 && this.loading ? x`` : null}
`; } }; - U.styles = [h.globalCss, nr], ie([t$1()], U.prototype, "loading", 2), ie([t$1()], U.prototype, "firstFetch", 2), ie([t$1()], U.prototype, "search", 2), ie([t$1()], U.prototype, "endReached", 2), U = ie([e$2("wcm-wallet-explorer-view")], U); + H2.styles = [h.globalCss, nr], se([t$1()], H2.prototype, "loading", 2), se([t$1()], H2.prototype, "firstFetch", 2), se([t$1()], H2.prototype, "search", 2), se([t$1()], H2.prototype, "endReached", 2), H2 = se([e$2("wcm-wallet-explorer-view")], H2); const dr = i$3`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; - var mr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r2, a22) => { - for (var t2 = a22 > 1 ? void 0 : a22 ? hr(o3, r2) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) - (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r2, t2) : i2(t2)) || t2); - return a22 && t2 && mr(o3, r2, t2), t2; + var mr = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, Ge = (e2, o3, r22, a22) => { + for (var t2 = a22 > 1 ? void 0 : a22 ? wr(o3, r22) : o3, l2 = e2.length - 1, i2; l2 >= 0; l2--) + (i2 = e2[l2]) && (t2 = (a22 ? i2(o3, r22, t2) : i2(t2)) || t2); + return a22 && t2 && mr(o3, r22, t2), t2; }; - let we = class extends s { + let ve = class extends s$1 { constructor() { super(), this.isError = false, this.openWebWallet(); } onFormatAndRedirect(e2) { - var _a; - const { desktop: o3, name: r2 } = a$3.getWalletRouterData(), a22 = o3 == null ? void 0 : o3.universal; - if (a22) { - const t2 = a$3.formatUniversalUrl(a22, e2, r2); - if (r2 === "Puzzle Wallet" && window && ((_a = window.aleo) == null ? void 0 : _a.puzzleWalletClient)) { - const url = new URL(t2); - const params = url.searchParams; - const wcUri = params.get("uri"); - const requestId = params.get("requestId"); - const sessionTopic = params.get("sessionTopic"); - void window.aleo.connectPuzzle({ - wc: { - uri: wcUri, - requestId: requestId ?? void 0, - sessionTopic: sessionTopic ?? void 0 - } - }); - } else { - a$3.openHref(t2, "_blank"); - } + var o3; + const { desktop: r22, name: a22 } = i$1$1.getWalletRouterData(), t2 = r22 == null ? void 0 : r22.universal; + if (t2) { + const l2 = i$1$1.formatUniversalUrl(t2, e2, a22); + if (a22 === "Puzzle Wallet" && (o3 = window == null ? void 0 : window.aleo) != null && o3.connectPuzzle) { + const i2 = new URL(l2).searchParams, c2 = i2.get("uri"), u3 = i2.get("requestId"), w22 = i2.get("sessionTopic"); + window.aleo.connectPuzzle({ wc: { uri: c2, requestId: u3 ?? void 0, sessionTopic: w22 ?? void 0 } }); + } else + i$1$1.openHref(l2, "_blank"); } } openWebWallet() { - const { walletConnectUri: e2 } = p$3.state, o3 = a$3.getWalletRouterData(); - c.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); + const { walletConnectUri: e2 } = p$2.state, o3 = i$1$1.getWalletRouterData(); + s2.setRecentWallet(o3), e2 && this.onFormatAndRedirect(e2); } render() { - const { name: e2, id: o3, image_id: r2 } = a$3.getWalletRouterData(), { isMobile: a22, isDesktop: t2 } = c.getCachedRouterWalletPlatforms(), l$12 = a$3.isMobile(); - return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; + const { name: e2, id: o3, image_id: r22 } = i$1$1.getWalletRouterData(), { isMobile: a22, isDesktop: t2 } = s2.getCachedRouterWalletPlatforms(), l$12 = i$1$1.isMobile(); + return x`${`${e2} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; } }; - we.styles = [h.globalCss, dr], Ge([t$1()], we.prototype, "isError", 2), we = Ge([e$2("wcm-web-connecting-view")], we); - const indexB2etef5O = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + ve.styles = [h.globalCss, dr], Ge([t$1()], ve.prototype, "isError", 2), ve = Ge([e$2("wcm-web-connecting-view")], ve); + const indexF3LbIFb5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, get WcmModal() { - return ae; + return ne; }, get WcmQrCode() { - return j; + return D; } }, Symbol.toStringTag, { value: "Module" })); exports2.PAGE_SIZE = PAGE_SIZE; @@ -31540,6 +38517,7 @@ exports2.aleoU32 = aleoU32; exports2.aleoU64 = aleoU64; exports2.aleoViewKeyRegex = aleoViewKeyRegex; + exports2.chainIdToNetwork = chainIdToNetwork; exports2.checkForDesktopConnection = checkForDesktopConnection; exports2.configureConnection = configureConnection; exports2.connect = connect; @@ -31557,6 +38535,7 @@ exports2.hasInjectedConnection = hasInjectedConnection; exports2.importSharedState = importSharedState; exports2.log_sdk = log_sdk; + exports2.networkToChainId = networkToChainId; exports2.projectId = projectId; exports2.queryClient = queryClient; exports2.requestCreateEvent = requestCreateEvent; @@ -31581,10 +38560,11 @@ exports2.useRequestSignature = useRequestSignature; exports2.useSession = useSession; exports2.useWalletSession = useWalletSession; - exports2.useWalletStore = useWalletStore; exports2.wc_aleo_chains = wc_aleo_chains; exports2.wc_aleo_methods = wc_aleo_methods; exports2.wc_events = wc_events; + exports2.wc_optional_aleo_chains = wc_optional_aleo_chains; + exports2.wc_required_aleo_chains = wc_required_aleo_chains; exports2.web3modal_puzzle_props = web3modal_puzzle_props; exports2.web3modal_puzzle_props_android = web3modal_puzzle_props_android; exports2.web3modal_puzzle_props_default = web3modal_puzzle_props_default; diff --git a/packages/react/dist/types/core/src/client.d.ts b/packages/react/dist/types/core/src/client.d.ts index 0ed98d2b..74cb5058 100644 --- a/packages/react/dist/types/core/src/client.d.ts +++ b/packages/react/dist/types/core/src/client.d.ts @@ -1,7 +1,7 @@ /// -import { WalletConnectModalSign } from '@walletconnect/modal-sign-html'; +import { WalletConnectModalSign } from '@puzzlehq/walletconnect-modal-sign-html'; import EventEmitter from 'events'; -export declare const emitter: EventEmitter; +export declare const emitter: EventEmitter<[never]>; export declare let connection: WalletConnectModalSign | undefined; export type WalletConnectModalSignInstance = InstanceType; export declare function configureConnection(options: { diff --git a/packages/react/dist/types/core/src/data/events.d.ts b/packages/react/dist/types/core/src/data/events.d.ts index dca910ad..4a571ee4 100644 --- a/packages/react/dist/types/core/src/data/events.d.ts +++ b/packages/react/dist/types/core/src/data/events.d.ts @@ -1,4 +1,4 @@ -import { Balance } from '../messages/balance.js'; +import { Balance } from '@puzzlehq/types'; export type AccountSelectedResponse = { address: string; balances: Balance[]; diff --git a/packages/react/dist/types/core/src/data/walletconnect.d.ts b/packages/react/dist/types/core/src/data/walletconnect.d.ts index 4a092294..2199ffe2 100644 --- a/packages/react/dist/types/core/src/data/walletconnect.d.ts +++ b/packages/react/dist/types/core/src/data/walletconnect.d.ts @@ -1,4 +1,7 @@ +import { Network } from '@puzzlehq/types'; export declare const wc_aleo_methods: string[]; +export declare const wc_required_aleo_chains: string[]; +export declare const wc_optional_aleo_chains: string[]; export declare const wc_aleo_chains: string[]; export declare const wc_events: string[]; export declare const projectId = "f0aaeffe71b636da453fce042d79d723"; @@ -71,3 +74,5 @@ export declare const signClient_puzzleProps: { }; }; }; +export declare const networkToChainId: (network: Network, includePrefix?: boolean) => string; +export declare const chainIdToNetwork: (chainId: 'aleo:0' | 'aleo:1') => Network.AleoTestnet | Network.AleoCanarynet; diff --git a/packages/react/dist/types/core/src/index.d.ts b/packages/react/dist/types/core/src/index.d.ts index 008738d0..cc88a3fa 100644 --- a/packages/react/dist/types/core/src/index.d.ts +++ b/packages/react/dist/types/core/src/index.d.ts @@ -5,5 +5,7 @@ export * from './data/walletconnect.js'; export * from './utils/logger.js'; export * from './utils/clientInfo.js'; export * from './client.js'; -import { type Account, type Asset, AssetType, type AssetValue, type Event, type EventCreate, EventStatus, EventType, Network, type Record, type RecordWithPlaintext, Visibility, aleoAddressRegex, aleoFieldRegex, aleoPrivateKeyRegex, aleoTransactionIdRegex, aleoU32, aleoU64, aleoViewKeyRegex, zodAddress, zodEventStatus, zodEventType, zodField, zodNetwork, zodPrivateKey, zodTransactionId, zodU32, zodU64, zodViewKey, zodVisibility } from '@puzzlehq/types'; -export { type Account, type Asset, AssetType, type AssetValue, type Event, type EventCreate, EventStatus, EventType, Network, type Record, type RecordWithPlaintext, Visibility, aleoAddressRegex, aleoFieldRegex, aleoPrivateKeyRegex, aleoTransactionIdRegex, aleoU32, aleoU64, aleoViewKeyRegex, zodAddress, zodEventStatus, zodEventType, zodField, zodNetwork, zodPrivateKey, zodTransactionId, zodU32, zodU64, zodViewKey, zodVisibility, }; +import { type SessionTypes } from '@walletconnect/types'; +import { type Account, type Event, type EventCreate, EventStatus, EventType, Network, type Record, type RecordWithPlaintext, Visibility, aleoAddressRegex, aleoFieldRegex, aleoPrivateKeyRegex, aleoTransactionIdRegex, aleoU32, aleoU64, aleoViewKeyRegex, zodAddress, zodEventStatus, zodEventType, zodField, zodNetwork, zodPrivateKey, zodTransactionId, zodU32, zodU64, zodViewKey, zodVisibility } from '@puzzlehq/types'; +export { SessionTypes }; +export { type Account, type Event, type EventCreate, EventStatus, EventType, Network, type Record, type RecordWithPlaintext, Visibility, aleoAddressRegex, aleoFieldRegex, aleoPrivateKeyRegex, aleoTransactionIdRegex, aleoU32, aleoU64, aleoViewKeyRegex, zodAddress, zodEventStatus, zodEventType, zodField, zodNetwork, zodPrivateKey, zodTransactionId, zodU32, zodU64, zodViewKey, zodVisibility, }; diff --git a/packages/react/dist/types/core/src/messages/account.d.ts b/packages/react/dist/types/core/src/messages/account.d.ts index 36f9cc2d..e2de7b9c 100644 --- a/packages/react/dist/types/core/src/messages/account.d.ts +++ b/packages/react/dist/types/core/src/messages/account.d.ts @@ -3,4 +3,4 @@ export type GetSelectedAccountResponse = { account?: PuzzleAccount; error?: string; }; -export declare const getAccount: () => Promise; +export declare const getAccount: (network?: string) => Promise; diff --git a/packages/react/dist/types/core/src/messages/balance.d.ts b/packages/react/dist/types/core/src/messages/balance.d.ts index 74ed07c7..1cb7803c 100644 --- a/packages/react/dist/types/core/src/messages/balance.d.ts +++ b/packages/react/dist/types/core/src/messages/balance.d.ts @@ -1,15 +1,12 @@ +import { Balance } from '@puzzlehq/types'; export type GetBalancesRequest = { - assetId?: string; address?: string; }; -export type Balance = { - private: number; - public: number; -}; export type GetBalancesResponse = { balances?: Balance[]; error?: string; }; -export declare const getBalance: ({ address, }: { +export declare const getBalance: ({ address, network, }: { address?: string | undefined; + network?: string | undefined; }) => Promise; diff --git a/packages/react/dist/types/core/src/messages/connect.d.ts b/packages/react/dist/types/core/src/messages/connect.d.ts index 11f29e03..b1ea24b4 100644 --- a/packages/react/dist/types/core/src/messages/connect.d.ts +++ b/packages/react/dist/types/core/src/messages/connect.d.ts @@ -1,2 +1,2 @@ import { SessionTypes } from '@walletconnect/types'; -export declare const connect: () => Promise; +export declare const connect: (showModal?: boolean) => Promise; diff --git a/packages/react/dist/types/core/src/messages/createEvent.d.ts b/packages/react/dist/types/core/src/messages/createEvent.d.ts index 2e8821e7..21c15edc 100644 --- a/packages/react/dist/types/core/src/messages/createEvent.d.ts +++ b/packages/react/dist/types/core/src/messages/createEvent.d.ts @@ -20,4 +20,4 @@ export type CreateEventResponse = { eventId?: string; error?: string; }; -export declare const requestCreateEvent: (requestData?: CreateEventRequestData) => Promise; +export declare const requestCreateEvent: (requestData: CreateEventRequestData, network?: string) => Promise; diff --git a/packages/react/dist/types/core/src/messages/createSharedState.d.ts b/packages/react/dist/types/core/src/messages/createSharedState.d.ts index dc24cf35..13050df4 100644 --- a/packages/react/dist/types/core/src/messages/createSharedState.d.ts +++ b/packages/react/dist/types/core/src/messages/createSharedState.d.ts @@ -5,4 +5,4 @@ export type CreateSharedStateResponse = { }; error?: string; }; -export declare const createSharedState: () => Promise; +export declare const createSharedState: (network?: string) => Promise; diff --git a/packages/react/dist/types/core/src/messages/decrypt.d.ts b/packages/react/dist/types/core/src/messages/decrypt.d.ts index 1465b9ff..c9da5d80 100644 --- a/packages/react/dist/types/core/src/messages/decrypt.d.ts +++ b/packages/react/dist/types/core/src/messages/decrypt.d.ts @@ -5,4 +5,4 @@ export type DecryptResponse = { plaintexts?: string[]; error?: string; }; -export declare const decrypt: (ciphertexts?: string[]) => Promise; +export declare const decrypt: (ciphertexts?: string[], network?: string) => Promise; diff --git a/packages/react/dist/types/core/src/messages/event.d.ts b/packages/react/dist/types/core/src/messages/event.d.ts index e981d17e..59f644f5 100644 --- a/packages/react/dist/types/core/src/messages/event.d.ts +++ b/packages/react/dist/types/core/src/messages/event.d.ts @@ -2,9 +2,10 @@ import { Event } from '../index.js'; export type GetEventRequest = { id: string; address?: string; + network?: string; }; export type GetEventResponse = { event?: Event; error?: string; }; -export declare const getEvent: ({ id, address, }: GetEventRequest) => Promise; +export declare const getEvent: ({ id, address, network, }: GetEventRequest) => Promise; diff --git a/packages/react/dist/types/core/src/messages/events.d.ts b/packages/react/dist/types/core/src/messages/events.d.ts index b0cd6761..931f8684 100644 --- a/packages/react/dist/types/core/src/messages/events.d.ts +++ b/packages/react/dist/types/core/src/messages/events.d.ts @@ -13,4 +13,4 @@ export type GetEventsResponse = { pageCount?: number; error?: string; }; -export declare const getEvents: (filter: EventsFilter) => Promise; +export declare const getEvents: (filter: EventsFilter, network?: string) => Promise; diff --git a/packages/react/dist/types/core/src/messages/importSharedState.d.ts b/packages/react/dist/types/core/src/messages/importSharedState.d.ts index bd152d8a..9294eea8 100644 --- a/packages/react/dist/types/core/src/messages/importSharedState.d.ts +++ b/packages/react/dist/types/core/src/messages/importSharedState.d.ts @@ -8,4 +8,4 @@ export type ImportSharedStateResponse = { }; error?: string; }; -export declare const importSharedState: (seed: string) => Promise; +export declare const importSharedState: (seed: string, network?: string) => Promise; diff --git a/packages/react/dist/types/core/src/messages/records.d.ts b/packages/react/dist/types/core/src/messages/records.d.ts index fe5db9dc..38a460d8 100644 --- a/packages/react/dist/types/core/src/messages/records.d.ts +++ b/packages/react/dist/types/core/src/messages/records.d.ts @@ -2,17 +2,18 @@ import { type RecordWithPlaintext } from '@puzzlehq/types'; export type RecordsFilter = { programIds?: string[]; functionId?: string; - type: 'all' | 'spent' | 'unspent'; + type: 'all' | 'spent' | 'unspent' | 'pending'; names?: string[]; }; export type GetRecordsRequest = { address?: string; filter?: RecordsFilter; page?: number; + network?: string; }; export type GetRecordsResponse = { records?: RecordWithPlaintext[]; pageCount?: number; error?: string; }; -export declare const getRecords: ({ address, filter, page, }: GetRecordsRequest) => Promise; +export declare const getRecords: ({ address, filter, page, network, }: GetRecordsRequest) => Promise; diff --git a/packages/react/dist/types/core/src/messages/requestSignature.d.ts b/packages/react/dist/types/core/src/messages/requestSignature.d.ts index 2964fb72..89acb250 100644 --- a/packages/react/dist/types/core/src/messages/requestSignature.d.ts +++ b/packages/react/dist/types/core/src/messages/requestSignature.d.ts @@ -1,10 +1,12 @@ export type SignatureRequest = { message: string; address?: string; + network?: string; + method?: 'aleo' | 'puzzle'; }; export type SignatureResponse = { signature?: string; messageFields?: string; error?: string; }; -export declare const requestSignature: ({ message, address, }: SignatureRequest) => Promise; +export declare const requestSignature: ({ message, address, network, method }: SignatureRequest) => Promise; diff --git a/packages/react/dist/types/react/src/hooks/useBalance.d.ts b/packages/react/dist/types/react/src/hooks/useBalance.d.ts index ca8fcaa4..b536fff6 100644 --- a/packages/react/dist/types/react/src/hooks/useBalance.d.ts +++ b/packages/react/dist/types/react/src/hooks/useBalance.d.ts @@ -1,9 +1,9 @@ -import { Balance } from '@puzzlehq/sdk-core'; +import { Balance } from '@puzzlehq/types'; type UseBalanceParams = { address?: string; multisig?: boolean; }; -export declare const useBalance: ({ address, multisig }: UseBalanceParams) => { +export declare const useBalance: ({ address, multisig }?: UseBalanceParams) => { balances: Balance[] | undefined; error: string | undefined; loading: boolean; diff --git a/packages/react/dist/types/react/src/hooks/useConnect.d.ts b/packages/react/dist/types/react/src/hooks/useConnect.d.ts index 5cea38fb..d5d34a4c 100644 --- a/packages/react/dist/types/react/src/hooks/useConnect.d.ts +++ b/packages/react/dist/types/react/src/hooks/useConnect.d.ts @@ -1,5 +1,5 @@ import { SessionTypes } from '@walletconnect/types'; -export declare function useConnect(): { +export declare function useConnect(showModal?: boolean): { data: any; error: unknown; loading: boolean; diff --git a/packages/react/dist/types/react/src/hooks/useRequestSignature.d.ts b/packages/react/dist/types/react/src/hooks/useRequestSignature.d.ts index dc1be5ce..73abf886 100644 --- a/packages/react/dist/types/react/src/hooks/useRequestSignature.d.ts +++ b/packages/react/dist/types/react/src/hooks/useRequestSignature.d.ts @@ -1,5 +1,5 @@ -import { SignatureResponse } from '@puzzlehq/sdk-core'; -export declare const useRequestSignature: (message: string, address?: string) => { +import { SignatureRequest, SignatureResponse } from '@puzzlehq/sdk-core'; +export declare const useRequestSignature: ({ message, address, method, network }: SignatureRequest) => { requestSignature: () => void; response: SignatureResponse | undefined; loading: boolean; diff --git a/packages/react/dist/types/react/src/hooks/utils/useInjectedSubscription.d.ts b/packages/react/dist/types/react/src/hooks/utils/useInjectedSubscription.d.ts index 9cc1b56e..12188cc3 100644 --- a/packages/react/dist/types/react/src/hooks/utils/useInjectedSubscription.d.ts +++ b/packages/react/dist/types/react/src/hooks/utils/useInjectedSubscription.d.ts @@ -4,6 +4,7 @@ type SubscriptionConfig = { subscriptionName: string; condition: (data: AccountSelectedResponse) => boolean; onData: (data: AccountSelectedResponse) => void; + dependencies: any[]; }; type UseInjectedSubscriptionsParams = { session: SessionTypes.Struct | undefined; diff --git a/packages/react/dist/types/react/src/hooks/wc/useOnSessionDelete.d.ts b/packages/react/dist/types/react/src/hooks/wc/useOnSessionDelete.d.ts index 2ceb1534..19cc17c0 100644 --- a/packages/react/dist/types/react/src/hooks/wc/useOnSessionDelete.d.ts +++ b/packages/react/dist/types/react/src/hooks/wc/useOnSessionDelete.d.ts @@ -1,2 +1,2 @@ -import type { WalletConnectModalEventCallback } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalEventCallback } from '@puzzlehq/walletconnect-modal-sign-html'; export declare function useOnSessionDelete(callback: WalletConnectModalEventCallback): void; diff --git a/packages/react/dist/types/react/src/hooks/wc/useOnSessionEvent.d.ts b/packages/react/dist/types/react/src/hooks/wc/useOnSessionEvent.d.ts index 261d4c86..72d0046d 100644 --- a/packages/react/dist/types/react/src/hooks/wc/useOnSessionEvent.d.ts +++ b/packages/react/dist/types/react/src/hooks/wc/useOnSessionEvent.d.ts @@ -1,2 +1,2 @@ -import type { WalletConnectModalEventCallback } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalEventCallback } from '@puzzlehq/walletconnect-modal-sign-html'; export declare function useOnSessionEvent(callback: WalletConnectModalEventCallback): void; diff --git a/packages/react/dist/types/react/src/hooks/wc/useOnSessionExpire.d.ts b/packages/react/dist/types/react/src/hooks/wc/useOnSessionExpire.d.ts index 9f914c4b..2a6d2a49 100644 --- a/packages/react/dist/types/react/src/hooks/wc/useOnSessionExpire.d.ts +++ b/packages/react/dist/types/react/src/hooks/wc/useOnSessionExpire.d.ts @@ -1,2 +1,2 @@ -import type { WalletConnectModalEventCallback } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalEventCallback } from '@puzzlehq/walletconnect-modal-sign-html'; export declare function useOnSessionExpire(callback: WalletConnectModalEventCallback): void; diff --git a/packages/react/dist/types/react/src/hooks/wc/useOnSessionUpdate.d.ts b/packages/react/dist/types/react/src/hooks/wc/useOnSessionUpdate.d.ts index 1022926d..4a0feb9b 100644 --- a/packages/react/dist/types/react/src/hooks/wc/useOnSessionUpdate.d.ts +++ b/packages/react/dist/types/react/src/hooks/wc/useOnSessionUpdate.d.ts @@ -1,2 +1,2 @@ -import type { WalletConnectModalEventCallback } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalEventCallback } from '@puzzlehq/walletconnect-modal-sign-html'; export declare function useOnSessionUpdate(callback: WalletConnectModalEventCallback): void; diff --git a/packages/react/dist/types/react/src/hooks/wc/useRequest.d.ts b/packages/react/dist/types/react/src/hooks/wc/useRequest.d.ts index aea55df9..05cd6418 100644 --- a/packages/react/dist/types/react/src/hooks/wc/useRequest.d.ts +++ b/packages/react/dist/types/react/src/hooks/wc/useRequest.d.ts @@ -1,4 +1,4 @@ -import type { WalletConnectModalSignRequestArguments } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalSignRequestArguments } from '@puzzlehq/walletconnect-modal-sign-html'; import { QueryKey, UseQueryOptions } from '@tanstack/react-query'; type UseRequestParams = { queryKey: QueryKey; @@ -8,14 +8,14 @@ type UseRequestParams = { fetchFunction?: (request: any) => Promise; }; export declare function useRequestQuery({ queryKey, wcParams, enabled, queryOptions, }: UseRequestParams): import("@tanstack/react-query").UseQueryResult; -export declare function useExtensionRequestQuery({ queryKey, wcParams, enabled, queryOptions, fetchFunction, }: UseRequestParams): import("@tanstack/react-query").UseQueryResult; +export declare function useInjectedRequestQuery({ queryKey, wcParams, enabled, queryOptions, fetchFunction, }: UseRequestParams): import("@tanstack/react-query").UseQueryResult; export declare function useRequest(params: WalletConnectModalSignRequestArguments, fetchFunction?: (params: WalletConnectModalSignRequestArguments) => any): { data: Result | undefined; error: unknown; loading: boolean; request: (paramsOverride?: any) => Promise; }; -export declare function useExtensionRequest(params: WalletConnectModalSignRequestArguments, fetchFunction?: (params: WalletConnectModalSignRequestArguments) => any): { +export declare function useInjectedRequest(params: WalletConnectModalSignRequestArguments, fetchFunction?: (params: WalletConnectModalSignRequestArguments) => any): { data: Result | undefined; error: unknown; loading: boolean; diff --git a/packages/react/dist/types/react/src/index.d.ts b/packages/react/dist/types/react/src/index.d.ts index adc48933..d86dadf4 100644 --- a/packages/react/dist/types/react/src/index.d.ts +++ b/packages/react/dist/types/react/src/index.d.ts @@ -16,5 +16,4 @@ export * from './hooks/wc/useOnSessionExpire.js'; export * from './hooks/wc/useOnSessionUpdate.js'; export * from './hooks/wc/useSession.js'; export * from './provider/PuzzleWalletProvider.js'; -export * from './store.js'; export * from '../../core/src/index.js'; diff --git a/packages/react/package.json b/packages/react/package.json index b09d5b6b..d9a57f71 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,7 +1,7 @@ { "name": "@puzzlehq/sdk", "displayName": "Puzzle React SDK", - "version": "0.3.1", + "version": "0.4.0", "description": "Your portal to privacy", "main": "./dist/puzzle.cjs.js", "module": "./dist/puzzle.es.js", @@ -24,10 +24,10 @@ }, "dependencies": { "@puzzlehq/sdk-core": "../core", - "@puzzlehq/types": "1.0.11", + "@puzzlehq/types": "1.0.21", "@tanstack/react-query": "^4.29.5", "@trpc/server": "^10.31.0", - "@walletconnect/modal-sign-html": "^2.6.2", + "@puzzlehq/walletconnect-modal-sign-html": "^0.0.6", "@walletconnect/types": "^2.11.2", "@walletconnect/utils": "^2.11.2", "debug": "^4.3.4", diff --git a/packages/react/src/hooks/useAccount.ts b/packages/react/src/hooks/useAccount.ts index 321b2ee9..10df8ab3 100644 --- a/packages/react/src/hooks/useAccount.ts +++ b/packages/react/src/hooks/useAccount.ts @@ -8,7 +8,7 @@ import { useOnSessionDelete } from './wc/useOnSessionDelete.js'; import { useOnSessionUpdate } from './wc/useOnSessionUpdate.js'; import { useOnSessionEvent } from './wc/useOnSessionEvent.js'; import { useWalletStore } from '../store.js'; -import { useExtensionRequestQuery, useRequestQuery } from './wc/useRequest.js'; +import { useInjectedRequestQuery, useRequestQuery } from './wc/useRequest.js'; import useInjectedSubscriptions from './utils/useInjectedSubscription.js'; import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; @@ -40,12 +40,12 @@ export const useAccount = () => { ]); const useQueryFunction = hasInjectedConnection() - ? useExtensionRequestQuery + ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session?.topic, - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'getSelectedAccount', @@ -87,6 +87,7 @@ export const useAccount = () => { shortenedAddress: shortenAddress(data.address), }); }, + dependencies: [] }, ], }); @@ -115,7 +116,6 @@ export const useAccount = () => { useOnSessionUpdate(({ params, topic }) => { const address = params.event.address ?? params.event.data.address; - const network = params.chainId.split(':')[0]; const chainId = params.chainId.split(':')[1]; setAccount({ @@ -126,7 +126,7 @@ export const useAccount = () => { }); }); - useOnSessionDelete(({ params, topic }) => { + useOnSessionDelete(() => { onDisconnect(); }); diff --git a/packages/react/src/hooks/useBalance.ts b/packages/react/src/hooks/useBalance.ts index 98836db2..8d31c0a5 100644 --- a/packages/react/src/hooks/useBalance.ts +++ b/packages/react/src/hooks/useBalance.ts @@ -1,13 +1,13 @@ import { useEffect } from 'react'; import { - Balance, GetBalancesRequest, GetBalancesResponse, hasInjectedConnection, } from '@puzzlehq/sdk-core'; +import { Balance } from '@puzzlehq/types'; import { SessionTypes } from '@walletconnect/types'; import { useOnSessionEvent } from './wc/useOnSessionEvent.js'; -import { useExtensionRequestQuery, useRequestQuery } from './wc/useRequest.js'; +import { useInjectedRequestQuery, useRequestQuery } from './wc/useRequest.js'; import { useWalletStore } from '../store.js'; import useInjectedSubscriptions from './utils/useInjectedSubscription.js'; import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; @@ -17,22 +17,21 @@ type UseBalanceParams = { multisig?: boolean; }; -export const useBalance = ({ address, multisig }: UseBalanceParams) => { +export const useBalance = ({ address, multisig }: UseBalanceParams = {}) => { const session: SessionTypes.Struct | undefined = useWalletSession(); const [account] = useWalletStore((state) => [state.account]); const useQueryFunction = hasInjectedConnection() - ? useExtensionRequestQuery + ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session?.topic, - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'getBalance', params: { - assetId: undefined, address, } as GetBalancesRequest, }, @@ -70,6 +69,7 @@ export const useBalance = ({ address, multisig }: UseBalanceParams) => { return !multisig; }, onData: () => refetch(), + dependencies: [multisig] }, { subscriptionName: 'onSharedAccountSynced', @@ -77,6 +77,7 @@ export const useBalance = ({ address, multisig }: UseBalanceParams) => { return !!multisig && data?.address === address; }, onData: () => refetch(), + dependencies: [multisig, address] }, ], }); diff --git a/packages/react/src/hooks/useConnect.ts b/packages/react/src/hooks/useConnect.ts index 3349a0ed..3390a349 100644 --- a/packages/react/src/hooks/useConnect.ts +++ b/packages/react/src/hooks/useConnect.ts @@ -4,9 +4,10 @@ import { emitter, getWalletConnectModalSignClient, checkForDesktopConnection, - wc_aleo_chains, wc_aleo_methods, wc_events, + wc_required_aleo_chains, + wc_optional_aleo_chains, } from '@puzzlehq/sdk-core'; import { useAsyncAction } from './wc/_useAsyncAction.js'; import { useWalletStore } from '../store.js'; @@ -15,7 +16,7 @@ import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; type Data = Awaited>; -export function useConnect() { +export function useConnect(showModal = true) { const session: SessionTypes.Struct | undefined = useWalletSession(); const isConnected = !!session; const { data, error, loading, setData, setError, setLoading } = @@ -31,11 +32,18 @@ export function useConnect() { requiredNamespaces: { aleo: { methods: wc_aleo_methods, - chains: wc_aleo_chains, + chains: wc_required_aleo_chains, events: wc_events, }, }, - }); + optionalNamespaces: { + aleo: { + chains: wc_optional_aleo_chains, + methods: wc_aleo_methods, + events: wc_events, + } + }, + }, showModal); setData(response); await checkForDesktopConnection(response.topic); const account = response.namespaces['aleo']['accounts'][0].split(':'); @@ -47,7 +55,9 @@ export function useConnect() { }); emitter.emit('session_change'); - const choice = window.localStorage.getItem('WALLETCONNECT_DEEPLINK_CHOICE'); + const choice = window.localStorage.getItem( + 'WALLETCONNECT_DEEPLINK_CHOICE', + ); if (choice && JSON.parse(choice).name !== 'Android') { // remove to prevent walletconnect from redirecting to the wallet page window.localStorage.removeItem('WALLETCONNECT_DEEPLINK_CHOICE'); diff --git a/packages/react/src/hooks/useCreateSharedState.ts b/packages/react/src/hooks/useCreateSharedState.ts index f9b7ef84..60fa426d 100644 --- a/packages/react/src/hooks/useCreateSharedState.ts +++ b/packages/react/src/hooks/useCreateSharedState.ts @@ -3,14 +3,16 @@ import { CreateSharedStateResponse, hasInjectedConnection, } from '@puzzlehq/sdk-core'; -import { useExtensionRequest, useRequest } from './wc/useRequest.js'; +import { useInjectedRequest, useRequest } from './wc/useRequest.js'; import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; +import { useWalletStore } from '../store.js'; export const useCreateSharedState = () => { const session: SessionTypes.Struct | undefined = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const useRequestFunction = hasInjectedConnection() - ? useExtensionRequest + ? useInjectedRequest : useRequest; const { @@ -21,7 +23,7 @@ export const useCreateSharedState = () => { } = useRequestFunction( { topic: session?.topic ?? '', - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'createSharedState', diff --git a/packages/react/src/hooks/useDecrypt.ts b/packages/react/src/hooks/useDecrypt.ts index 669a2f81..3769532a 100644 --- a/packages/react/src/hooks/useDecrypt.ts +++ b/packages/react/src/hooks/useDecrypt.ts @@ -1,13 +1,20 @@ import { SessionTypes } from '@walletconnect/types'; -import { DecryptRequest, DecryptResponse, hasInjectedConnection, log_sdk } from '@puzzlehq/sdk-core'; -import { useExtensionRequest, useRequest } from './wc/useRequest.js'; +import { + DecryptRequest, + DecryptResponse, + hasInjectedConnection, + log_sdk, +} from '@puzzlehq/sdk-core'; +import { useInjectedRequest, useRequest } from './wc/useRequest.js'; import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; +import { useWalletStore } from '../store.js'; export const useDecrypt = (ciphertexts?: string[]) => { const session: SessionTypes.Struct | undefined = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const useRequestFunction = hasInjectedConnection() - ? useExtensionRequest + ? useInjectedRequest : useRequest; const { @@ -18,7 +25,7 @@ export const useDecrypt = (ciphertexts?: string[]) => { } = useRequestFunction( { topic: session?.topic ?? '', - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'decrypt', diff --git a/packages/react/src/hooks/useEvent.ts b/packages/react/src/hooks/useEvent.ts index 8c6a10cf..68aec905 100644 --- a/packages/react/src/hooks/useEvent.ts +++ b/packages/react/src/hooks/useEvent.ts @@ -7,7 +7,7 @@ import { } from '@puzzlehq/sdk-core'; import { Event } from '@puzzlehq/types'; import { useOnSessionEvent } from './wc/useOnSessionEvent.js'; -import { useExtensionRequestQuery, useRequestQuery } from './wc/useRequest.js'; +import { useInjectedRequestQuery, useRequestQuery } from './wc/useRequest.js'; import { useWalletStore } from '../store.js'; import useInjectedSubscriptions from './utils/useInjectedSubscription.js'; import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; @@ -23,12 +23,12 @@ export const useEvent = ({ id, address, multisig = false }: UseEventParams) => { const [account] = useWalletStore((state) => [state.account]); const useQueryFunction = hasInjectedConnection() - ? useExtensionRequestQuery + ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session?.topic, - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'getEvent', @@ -77,6 +77,7 @@ export const useEvent = ({ id, address, multisig = false }: UseEventParams) => { subscriptionName: 'onSelectedAccountSynced', condition: () => !!id && !multisig, onData: () => refetch(), + dependencies: [id, multisig] }, { subscriptionName: 'onSharedAccountSynced', @@ -84,6 +85,7 @@ export const useEvent = ({ id, address, multisig = false }: UseEventParams) => { return !!id && !!multisig && data?.address === address; }, onData: () => refetch(), + dependencies: [id, multisig, address] }, ], }); diff --git a/packages/react/src/hooks/useEvents.ts b/packages/react/src/hooks/useEvents.ts index e21b0dd6..02e042d1 100644 --- a/packages/react/src/hooks/useEvents.ts +++ b/packages/react/src/hooks/useEvents.ts @@ -7,7 +7,7 @@ import { hasInjectedConnection, } from '@puzzlehq/sdk-core'; import { Event } from '@puzzlehq/types'; -import { useExtensionRequestQuery, useRequestQuery } from './wc/useRequest.js'; +import { useInjectedRequestQuery, useRequestQuery } from './wc/useRequest.js'; import { useWalletStore } from '../store.js'; import { useOnSessionEvent } from './wc/useOnSessionEvent.js'; import { useDebounce } from 'use-debounce'; @@ -28,12 +28,12 @@ export const useEvents = ({ filter, page }: UseEventsParams) => { } const useQueryFunction = hasInjectedConnection() - ? useExtensionRequestQuery + ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session?.topic ?? '', - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'getEvents', @@ -55,7 +55,7 @@ export const useEvents = ({ filter, page }: UseEventsParams) => { queryKey: [ 'useEvents', account?.address, - debouncedFilter, + JSON.stringify(debouncedFilter), page, session?.topic, ], @@ -76,6 +76,7 @@ export const useEvents = ({ filter, page }: UseEventsParams) => { subscriptionName: 'onSelectedAccountSynced', condition: () => true, onData: () => refetch(), + dependencies: [] }, ], }); diff --git a/packages/react/src/hooks/useImportSharedState.ts b/packages/react/src/hooks/useImportSharedState.ts index 7611b0d0..e3f68d2c 100644 --- a/packages/react/src/hooks/useImportSharedState.ts +++ b/packages/react/src/hooks/useImportSharedState.ts @@ -4,14 +4,16 @@ import { ImportSharedStateResponse, hasInjectedConnection, } from '@puzzlehq/sdk-core'; -import { useExtensionRequest, useRequest } from './wc/useRequest.js'; +import { useInjectedRequest, useRequest } from './wc/useRequest.js'; import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; +import { useWalletStore } from '../store.js'; export const useImportSharedState = (seed?: string) => { const session: SessionTypes.Struct | undefined = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const useRequestFunction = hasInjectedConnection() - ? useExtensionRequest + ? useInjectedRequest : useRequest; const { @@ -22,7 +24,7 @@ export const useImportSharedState = (seed?: string) => { } = useRequestFunction( { topic: session?.topic ?? '', - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'importSharedState', diff --git a/packages/react/src/hooks/useRecords.ts b/packages/react/src/hooks/useRecords.ts index c9588e88..38d0673a 100644 --- a/packages/react/src/hooks/useRecords.ts +++ b/packages/react/src/hooks/useRecords.ts @@ -8,7 +8,7 @@ import { import { type RecordWithPlaintext } from '@puzzlehq/types'; import { SessionTypes } from '@walletconnect/types'; import { useWalletStore } from '../store.js'; -import { useExtensionRequestQuery, useRequestQuery } from './wc/useRequest.js'; +import { useInjectedRequestQuery, useRequestQuery } from './wc/useRequest.js'; import { useOnSessionEvent } from './wc/useOnSessionEvent.js'; import { useDebounce } from 'use-debounce'; import useInjectedSubscriptions from './utils/useInjectedSubscription.js'; @@ -39,12 +39,12 @@ export const useRecords = ({ const [account] = useWalletStore((state) => [state.account]); const useQueryFunction = hasInjectedConnection() - ? useExtensionRequestQuery + ? useInjectedRequestQuery : useRequestQuery; const query = { topic: session?.topic, - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'getRecords', @@ -69,7 +69,7 @@ export const useRecords = ({ account?.address, address, multisig, - debouncedFilter, + JSON.stringify(debouncedFilter), page, session?.topic, ], @@ -92,6 +92,7 @@ export const useRecords = ({ subscriptionName: 'onSelectedAccountSynced', condition: () => !multisig, onData: () => refetch(), + dependencies: [multisig] }, { subscriptionName: 'onSharedAccountSynced', @@ -99,6 +100,7 @@ export const useRecords = ({ return !!multisig && data?.address === address; }, onData: () => refetch(), + dependencies: [multisig, address] }, ], }); diff --git a/packages/react/src/hooks/useRequestCreateEvent.ts b/packages/react/src/hooks/useRequestCreateEvent.ts index adf66981..bfa26c62 100644 --- a/packages/react/src/hooks/useRequestCreateEvent.ts +++ b/packages/react/src/hooks/useRequestCreateEvent.ts @@ -7,9 +7,12 @@ import { log_sdk, } from '@puzzlehq/sdk-core'; import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; +import { useWalletStore } from '../store.js'; export const useRequestCreateEvent = (requestData?: CreateEventRequestData) => { const session: SessionTypes.Struct | undefined = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); + const inputs = requestData?.inputs.map((input) => { if (typeof input === 'string') { return input; @@ -24,7 +27,7 @@ export const useRequestCreateEvent = (requestData?: CreateEventRequestData) => { loading, } = useRequest({ topic: session?.topic ?? '', - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'requestCreateEvent', diff --git a/packages/react/src/hooks/useRequestSignature.ts b/packages/react/src/hooks/useRequestSignature.ts index 56054080..4c41df85 100644 --- a/packages/react/src/hooks/useRequestSignature.ts +++ b/packages/react/src/hooks/useRequestSignature.ts @@ -7,9 +7,11 @@ import { import { aleoAddressRegex } from '@puzzlehq/types'; import { useRequest } from './wc/useRequest.js'; import { useWalletSession } from '../provider/PuzzleWalletProvider.js'; +import { useWalletStore } from '../store.js'; -export const useRequestSignature = (message: string, address?: string) => { +export const useRequestSignature = ({message, address, method, network}: SignatureRequest) => { const session: SessionTypes.Struct | undefined = useWalletSession(); + const [account] = useWalletStore((state) => [state.account]); const { request, @@ -18,13 +20,14 @@ export const useRequestSignature = (message: string, address?: string) => { loading, } = useRequest({ topic: session?.topic ?? '', - chainId: 'aleo:1', + chainId: account ? `${account.network}:${account.chainId}` : 'aleo:1', request: { jsonrpc: '2.0', method: 'requestSignature', params: { message, address: aleoAddressRegex.test(address ?? '') ? address : undefined, + method } as SignatureRequest, }, }); diff --git a/packages/react/src/hooks/utils/useInjectedSubscription.ts b/packages/react/src/hooks/utils/useInjectedSubscription.ts index 0d9dc285..139ab8a3 100644 --- a/packages/react/src/hooks/utils/useInjectedSubscription.ts +++ b/packages/react/src/hooks/utils/useInjectedSubscription.ts @@ -1,4 +1,4 @@ -import { useEffect } from 'react'; +import { useEffect, useMemo } from 'react'; import { SessionTypes } from '@walletconnect/types'; import { AccountSelectedResponse, @@ -10,6 +10,7 @@ type SubscriptionConfig = { subscriptionName: string; condition: (data: AccountSelectedResponse) => boolean; onData: (data: AccountSelectedResponse) => void; + dependencies: any[] }; type UseInjectedSubscriptionsParams = { @@ -51,9 +52,11 @@ const useInjectedSubscriptions = ({ // Cleanup on unmount or when dependencies change return () => { - subscriptions.forEach((subscription) => subscription.unsubscribe()); + subscriptions.forEach((subscription) => { + subscription.unsubscribe() + }); }; - }, [session?.topic, configs]); + }, [session?.topic, ...configs.flatMap((config) => config.dependencies)]); }; export default useInjectedSubscriptions; diff --git a/packages/react/src/hooks/wc/useOnSessionDelete.ts b/packages/react/src/hooks/wc/useOnSessionDelete.ts index 4e66bbcb..60c56a0e 100644 --- a/packages/react/src/hooks/wc/useOnSessionDelete.ts +++ b/packages/react/src/hooks/wc/useOnSessionDelete.ts @@ -1,4 +1,4 @@ -import type { WalletConnectModalEventCallback } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalEventCallback } from '@puzzlehq/walletconnect-modal-sign-html'; import { useEffect } from 'react'; import { getWalletConnectModalSignClient } from '@puzzlehq/sdk-core'; diff --git a/packages/react/src/hooks/wc/useOnSessionEvent.ts b/packages/react/src/hooks/wc/useOnSessionEvent.ts index 528231fb..a6dc7751 100644 --- a/packages/react/src/hooks/wc/useOnSessionEvent.ts +++ b/packages/react/src/hooks/wc/useOnSessionEvent.ts @@ -1,4 +1,4 @@ -import type { WalletConnectModalEventCallback } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalEventCallback } from '@puzzlehq/walletconnect-modal-sign-html'; import { useEffect } from 'react'; import { getWalletConnectModalSignClient } from '@puzzlehq/sdk-core'; diff --git a/packages/react/src/hooks/wc/useOnSessionExpire.ts b/packages/react/src/hooks/wc/useOnSessionExpire.ts index 2122d5a7..4e2a77de 100644 --- a/packages/react/src/hooks/wc/useOnSessionExpire.ts +++ b/packages/react/src/hooks/wc/useOnSessionExpire.ts @@ -1,4 +1,4 @@ -import type { WalletConnectModalEventCallback } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalEventCallback } from '@puzzlehq/walletconnect-modal-sign-html'; import { useEffect } from 'react'; import { getWalletConnectModalSignClient } from '@puzzlehq/sdk-core'; diff --git a/packages/react/src/hooks/wc/useOnSessionUpdate.ts b/packages/react/src/hooks/wc/useOnSessionUpdate.ts index ea718856..79bd751d 100644 --- a/packages/react/src/hooks/wc/useOnSessionUpdate.ts +++ b/packages/react/src/hooks/wc/useOnSessionUpdate.ts @@ -1,4 +1,4 @@ -import type { WalletConnectModalEventCallback } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalEventCallback } from '@puzzlehq/walletconnect-modal-sign-html'; import { useEffect } from 'react'; import { getWalletConnectModalSignClient } from '@puzzlehq/sdk-core'; diff --git a/packages/react/src/hooks/wc/useRequest.ts b/packages/react/src/hooks/wc/useRequest.ts index c0e81df2..3b0a81f2 100644 --- a/packages/react/src/hooks/wc/useRequest.ts +++ b/packages/react/src/hooks/wc/useRequest.ts @@ -1,4 +1,4 @@ -import type { WalletConnectModalSignRequestArguments } from '@walletconnect/modal-sign-html'; +import type { WalletConnectModalSignRequestArguments } from '@puzzlehq/walletconnect-modal-sign-html'; import { getWalletConnectModalSignClient } from '@puzzlehq/sdk-core'; import { QueryKey, UseQueryOptions, useQuery } from '@tanstack/react-query'; import { useAsyncAction } from './_useAsyncAction.js'; @@ -34,8 +34,8 @@ export function useRequestQuery({ queryKey, async () => fetchRequest(wcParams, queryKey), queryOptions ?? { - staleTime: queryKey[0] === 'getEvent' ? 7_500 : 45_000, - refetchInterval: queryKey[0] === 'getEvent' ? 5_000 : 30_000, + staleTime: queryKey[0] === 'getEvent' ? 7_500 : 30_000, + refetchInterval: queryKey[0] === 'getEvent' ? 5_000 : 15_000, refetchIntervalInBackground: true, enabled, retry: true, @@ -43,7 +43,7 @@ export function useRequestQuery({ ); } -export function useExtensionRequestQuery({ +export function useInjectedRequestQuery({ queryKey, wcParams, enabled, @@ -54,8 +54,8 @@ export function useExtensionRequestQuery({ queryKey, async () => fetchFunction!(wcParams), queryOptions ?? { - staleTime: queryKey[0] === 'getEvent' ? 7_500 : 45_000, - refetchInterval: queryKey[0] === 'getEvent' ? 5_000 : 30_000, + staleTime: queryKey[0] === 'getEvent' ? 7_500 : 30_000, + refetchInterval: queryKey[0] === 'getEvent' ? 5_000 : 15_000, refetchIntervalInBackground: true, enabled, retry: true, @@ -89,7 +89,7 @@ export function useRequest( return { data, error, loading, request }; } -export function useExtensionRequest( +export function useInjectedRequest( params: WalletConnectModalSignRequestArguments, fetchFunction?: (params: WalletConnectModalSignRequestArguments) => any, ) { diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index b874ca6f..eeaa02fc 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -16,6 +16,5 @@ export * from './hooks/wc/useOnSessionExpire.js'; export * from './hooks/wc/useOnSessionUpdate.js'; export * from './hooks/wc/useSession.js'; export * from './provider/PuzzleWalletProvider.js'; -export * from './store.js'; export * from '../../core/src/index.js'; diff --git a/packages/react/src/provider/PuzzleWalletProvider.tsx b/packages/react/src/provider/PuzzleWalletProvider.tsx index 3681cfc2..e9a03910 100644 --- a/packages/react/src/provider/PuzzleWalletProvider.tsx +++ b/packages/react/src/provider/PuzzleWalletProvider.tsx @@ -17,7 +17,9 @@ type PuzzleWalletProviderProps = { }; export const queryClient = new QueryClient(); -const SessionContext = createContext(undefined); +const SessionContext = createContext( + undefined, +); export const PuzzleWalletProvider = ({ dAppName, @@ -27,13 +29,15 @@ export const PuzzleWalletProvider = ({ children, debugQuery = false, }: PuzzleWalletProviderProps) => { - const [session, setSession] = useState(undefined); + const [session, setSession] = useState( + undefined, + ); const _session = useSession(); useEffect(() => { setSession(_session); - },[_session]) + }, [_session]); useEffect(() => { configureConnection({ @@ -60,4 +64,4 @@ export const PuzzleWalletProvider = ({ export const useWalletSession = () => { const session = useContext(SessionContext); return session; -}; \ No newline at end of file +}; diff --git a/packages/react/vite.config.js b/packages/react/vite.config.js index 27c39036..c5f59209 100644 --- a/packages/react/vite.config.js +++ b/packages/react/vite.config.js @@ -29,7 +29,7 @@ export default defineConfig({ // Provide global variables to use in the UMD build for externalized deps globals: { react: 'React', - '@walletconnect/modal-sign-html': 'modalSignHtml', + '@puzzlehq/walletconnect-modal-sign-html': 'modalSignHtml', events: 'EventEmitter', zustand: 'zustand', '@tanstack/react-query': 'reactQuery', diff --git a/patches/@walletconnect__modal-core@2.6.2.patch b/patches/@walletconnect__modal-core@2.6.2.patch deleted file mode 100644 index 8c766b41..00000000 --- a/patches/@walletconnect__modal-core@2.6.2.patch +++ /dev/null @@ -1,484 +0,0 @@ -diff --git a/dist/index.js b/dist/index.js -index 6de33056a365cdd927ec112875c7bdd949511ab0..443c20e0fabda22dbe1c9af895f0ab1cb0eadbe4 100644 ---- a/dist/index.js -+++ b/dist/index.js -@@ -1,2 +1,478 @@ --import{proxy as u,subscribe as h,snapshot as P}from"valtio/vanilla";const o=u({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),T={state:o,subscribe(e){return h(o,()=>e(o))},push(e,t){e!==o.view&&(o.view=e,t&&(o.data=t),o.history.push(e))},reset(e){o.view=e,o.history=[e]},replace(e){o.history.length>1&&(o.history[o.history.length-1]=e,o.view=e)},goBack(){if(o.history.length>1){o.history.pop();const[e]=o.history.slice(-1);o.view=e}},setData(e){o.data=e}},a={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?Boolean(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return a.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return a.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(a.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const i=encodeURIComponent(t);return`${n}wc?uri=${i}`},formatUniversalUrl(e,t,s){if(!a.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const i=encodeURIComponent(t);return`${n}wc?uri=${i}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(a.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(a.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(a.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(a.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=T.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},_=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),r=u({enabled:_,userSessionId:"",events:[],connectedWalletId:void 0}),R={state:r,subscribe(e){return h(r.events,()=>e(P(r.events[r.events.length-1])))},initialize(){r.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(r.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){r.connectedWalletId=e},click(e){if(r.enabled){const t={type:"CLICK",name:e.name,userSessionId:r.userSessionId,timestamp:Date.now(),data:e};r.events.push(t)}},track(e){if(r.enabled){const t={type:"TRACK",name:e.name,userSessionId:r.userSessionId,timestamp:Date.now(),data:e};r.events.push(t)}},view(e){if(r.enabled){const t={type:"VIEW",name:e.name,userSessionId:r.userSessionId,timestamp:Date.now(),data:e};r.events.push(t)}}},c=u({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),p={state:c,subscribe(e){return h(c,()=>e(c))},setChains(e){c.chains=e},setWalletConnectUri(e){c.walletConnectUri=e},setIsCustomDesktop(e){c.isCustomDesktop=e},setIsCustomMobile(e){c.isCustomMobile=e},setIsDataLoaded(e){c.isDataLoaded=e},setIsUiLoaded(e){c.isUiLoaded=e},setIsAuth(e){c.isAuth=e}},W=u({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),y={state:W,subscribe(e){return h(W,()=>e(W))},setConfig(e){var t,s;R.initialize(),p.setChains(e.chains),p.setIsAuth(Boolean(e.enableAuthMode)),p.setIsCustomMobile(Boolean((t=e.mobileWallets)==null?void 0:t.length)),p.setIsCustomDesktop(Boolean((s=e.desktopWallets)==null?void 0:s.length)),a.setModalVersionInStorage(),Object.assign(W,e)}};var V=Object.defineProperty,D=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable,M=(e,t,s)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,K=(e,t)=>{for(var s in t||(t={}))H.call(t,s)&&M(e,s,t[s]);if(D)for(var s of D(t))B.call(t,s)&&M(e,s,t[s]);return e};const L="https://explorer-api.walletconnect.com",E="wcm",O="js-2.6.2";async function w(e,t){const s=K({sdkType:E,sdkVersion:O},t),n=new URL(e,L);return n.searchParams.append("projectId",y.state.projectId),Object.entries(s).forEach(([i,l])=>{l&&n.searchParams.append(i,String(l))}),(await fetch(n)).json()}const m={async getDesktopListings(e){return w("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return w("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return w("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return w("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${L}/w3m/v1/getWalletImage/${e}?projectId=${y.state.projectId}&sdkType=${E}&sdkVersion=${O}`},getAssetImageUrl(e){return`${L}/w3m/v1/getAssetImage/${e}?projectId=${y.state.projectId}&sdkType=${E}&sdkVersion=${O}`}};var z=Object.defineProperty,j=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,k=(e,t,s)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,F=(e,t)=>{for(var s in t||(t={}))J.call(t,s)&&k(e,s,t[s]);if(j)for(var s of j(t))q.call(t,s)&&k(e,s,t[s]);return e};const N=a.isMobile(),d=u({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),te={state:d,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=y.state;if(e==="NONE"||t==="ALL"&&!e)return d.recomendedWallets;if(a.isArray(e)){const s={recommendedIds:e.join(",")},{listings:n}=await m.getAllListings(s),i=Object.values(n);i.sort((l,v)=>{const b=e.indexOf(l.id),f=e.indexOf(v.id);return b-f}),d.recomendedWallets=i}else{const{chains:s,isAuth:n}=p.state,i=s?.join(","),l=a.isArray(t),v={page:1,sdks:n?"auth_v1":void 0,entries:a.RECOMMENDED_WALLET_AMOUNT,chains:i,version:2,excludedIds:l?t.join(","):void 0},{listings:b}=N?await m.getMobileListings(v):await m.getDesktopListings(v);d.recomendedWallets=Object.values(b)}return d.recomendedWallets},async getWallets(e){const t=F({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=y.state,{recomendedWallets:i}=d;if(n==="ALL")return d.wallets;i.length?t.excludedIds=i.map(x=>x.id).join(","):a.isArray(s)&&(t.excludedIds=s.join(",")),a.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),p.state.isAuth&&(t.sdks="auth_v1");const{page:l,search:v}=e,{listings:b,total:f}=N?await m.getMobileListings(t):await m.getDesktopListings(t),A=Object.values(b),U=v?"search":"wallets";return d[U]={listings:[...d[U].listings,...A],total:f,page:l??1},{listings:A,total:f}},getWalletImageUrl(e){return m.getWalletImageUrl(e)},getAssetImageUrl(e){return m.getAssetImageUrl(e)},resetSearch(){d.search={listings:[],total:0,page:1}}},I=u({open:!1}),se={state:I,subscribe(e){return h(I,()=>e(I))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=p.state;if(a.removeWalletConnectDeepLink(),p.setWalletConnectUri(e?.uri),p.setChains(e?.chains),T.reset("ConnectWallet"),s&&n)I.open=!0,t();else{const i=setInterval(()=>{const l=p.state;l.isUiLoaded&&l.isDataLoaded&&(clearInterval(i),I.open=!0,t())},200)}})},close(){I.open=!1}};var G=Object.defineProperty,$=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,S=(e,t,s)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Y=(e,t)=>{for(var s in t||(t={}))Q.call(t,s)&&S(e,s,t[s]);if($)for(var s of $(t))X.call(t,s)&&S(e,s,t[s]);return e};function Z(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const C=u({themeMode:Z()?"dark":"light"}),ne={state:C,subscribe(e){return h(C,()=>e(C))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(C.themeMode=t),s&&(C.themeVariables=Y({},s))}},g=u({open:!1,message:"",variant:"success"}),oe={state:g,subscribe(e){return h(g,()=>e(g))},openToast(e,t){g.open=!0,g.message=e,g.variant=t},closeToast(){g.open=!1}};export{y as ConfigCtrl,a as CoreUtil,R as EventsCtrl,te as ExplorerCtrl,se as ModalCtrl,p as OptionsCtrl,T as RouterCtrl,ne as ThemeCtrl,oe as ToastCtrl}; -+import { proxy as u, subscribe as h, snapshot as P } from "valtio/vanilla"; -+const o = u({ -+ history: ["ConnectWallet"], -+ view: "ConnectWallet", -+ data: void 0, -+ }), -+ T = { -+ state: o, -+ subscribe(e) { -+ return h(o, () => e(o)); -+ }, -+ push(e, t) { -+ e !== o.view && ((o.view = e), t && (o.data = t), o.history.push(e)); -+ }, -+ reset(e) { -+ (o.view = e), (o.history = [e]); -+ }, -+ replace(e) { -+ o.history.length > 1 && -+ ((o.history[o.history.length - 1] = e), (o.view = e)); -+ }, -+ goBack() { -+ if (o.history.length > 1) { -+ o.history.pop(); -+ const [e] = o.history.slice(-1); -+ o.view = e; -+ } -+ }, -+ setData(e) { -+ o.data = e; -+ }, -+ }, -+ a = { -+ WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", -+ WCM_VERSION: "WCM_VERSION", -+ RECOMMENDED_WALLET_AMOUNT: 9, -+ isMobile() { -+ return typeof window < "u" -+ ? Boolean( -+ window.matchMedia("(pointer:coarse)").matches || -+ /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test( -+ navigator.userAgent, -+ ), -+ ) -+ : !1; -+ }, -+ isAndroid() { -+ return ( -+ a.isMobile() && navigator.userAgent.toLowerCase().includes("android") -+ ); -+ }, -+ isIos() { -+ const e = navigator.userAgent.toLowerCase(); -+ return a.isMobile() && (e.includes("iphone") || e.includes("ipad")); -+ }, -+ isHttpUrl(e) { -+ return e.startsWith("http://") || e.startsWith("https://"); -+ }, -+ isArray(e) { -+ return Array.isArray(e) && e.length > 0; -+ }, -+ formatNativeUrl(e, t, s) { -+ if (a.isHttpUrl(e)) return this.formatUniversalUrl(e, t, s); -+ let n = e; -+ n.includes("://") || -+ ((n = e.replaceAll("/", "").replaceAll(":", "")), (n = `${n}://`)), -+ n.endsWith("/") || (n = `${n}/`), -+ this.setWalletConnectDeepLink(n, s); -+ const i = encodeURIComponent(t); -+ return `${n}wc?uri=${i}`; -+ }, -+ formatUniversalUrl(e, t, s) { -+ if (!a.isHttpUrl(e)) return this.formatNativeUrl(e, t, s); -+ let n = e; -+ n.endsWith("/") || (n = `${n}/`), this.setWalletConnectDeepLink(n, s); -+ const i = encodeURIComponent(t); -+ return `${n}wc?uri=${i}`; -+ }, -+ async wait(e) { -+ return new Promise((t) => { -+ setTimeout(t, e); -+ }); -+ }, -+ openHref(e, t) { -+ window.open(e, t, "noreferrer noopener"); -+ }, -+ setWalletConnectDeepLink(e, t) { -+ try { -+ localStorage.setItem( -+ a.WALLETCONNECT_DEEPLINK_CHOICE, -+ JSON.stringify({ href: e, name: t }), -+ ); -+ } catch { -+ console.info("Unable to set WalletConnect deep link"); -+ } -+ }, -+ setWalletConnectAndroidDeepLink(e) { -+ try { -+ const [t] = e.split("?"); -+ localStorage.setItem( -+ a.WALLETCONNECT_DEEPLINK_CHOICE, -+ JSON.stringify({ href: t, name: "Android" }), -+ ); -+ } catch { -+ console.info("Unable to set WalletConnect android deep link"); -+ } -+ }, -+ removeWalletConnectDeepLink() { -+ try { -+ localStorage.removeItem(a.WALLETCONNECT_DEEPLINK_CHOICE); -+ } catch { -+ console.info("Unable to remove WalletConnect deep link"); -+ } -+ }, -+ setModalVersionInStorage() { -+ try { -+ typeof localStorage < "u" && -+ localStorage.setItem(a.WCM_VERSION, "2.6.2"); -+ } catch { -+ console.info("Unable to set Web3Modal version in storage"); -+ } -+ }, -+ getWalletRouterData() { -+ var e; -+ const t = (e = T.state.data) == null ? void 0 : e.Wallet; -+ if (!t) throw new Error('Missing "Wallet" view data'); -+ return t; -+ }, -+ }, -+ _ = -+ typeof location < "u" && -+ (location.hostname.includes("localhost") || -+ location.protocol.includes("https")), -+ r = u({ -+ enabled: _, -+ userSessionId: "", -+ events: [], -+ connectedWalletId: void 0, -+ }), -+ R = { -+ state: r, -+ subscribe(e) { -+ return h(r.events, () => e(P(r.events[r.events.length - 1]))); -+ }, -+ initialize() { -+ r.enabled && -+ typeof (crypto == null ? void 0 : crypto.randomUUID) < "u" && -+ (r.userSessionId = crypto.randomUUID()); -+ }, -+ setConnectedWalletId(e) { -+ r.connectedWalletId = e; -+ }, -+ click(e) { -+ if (r.enabled) { -+ const t = { -+ type: "CLICK", -+ name: e.name, -+ userSessionId: r.userSessionId, -+ timestamp: Date.now(), -+ data: e, -+ }; -+ r.events.push(t); -+ } -+ }, -+ track(e) { -+ if (r.enabled) { -+ const t = { -+ type: "TRACK", -+ name: e.name, -+ userSessionId: r.userSessionId, -+ timestamp: Date.now(), -+ data: e, -+ }; -+ r.events.push(t); -+ } -+ }, -+ view(e) { -+ if (r.enabled) { -+ const t = { -+ type: "VIEW", -+ name: e.name, -+ userSessionId: r.userSessionId, -+ timestamp: Date.now(), -+ data: e, -+ }; -+ r.events.push(t); -+ } -+ }, -+ }, -+ c = u({ -+ chains: void 0, -+ walletConnectUri: void 0, -+ isAuth: !1, -+ isCustomDesktop: !1, -+ isCustomMobile: !1, -+ isDataLoaded: !1, -+ isUiLoaded: !1, -+ }), -+ p = { -+ state: c, -+ subscribe(e) { -+ return h(c, () => e(c)); -+ }, -+ setChains(e) { -+ c.chains = e; -+ }, -+ setWalletConnectUri(e) { -+ c.walletConnectUri = e; -+ }, -+ setIsCustomDesktop(e) { -+ c.isCustomDesktop = e; -+ }, -+ setIsCustomMobile(e) { -+ c.isCustomMobile = e; -+ }, -+ setIsDataLoaded(e) { -+ c.isDataLoaded = e; -+ }, -+ setIsUiLoaded(e) { -+ c.isUiLoaded = e; -+ }, -+ setIsAuth(e) { -+ c.isAuth = e; -+ }, -+ }, -+ W = u({ -+ projectId: "", -+ mobileWallets: void 0, -+ desktopWallets: void 0, -+ walletImages: void 0, -+ chains: void 0, -+ enableAuthMode: !1, -+ enableExplorer: !0, -+ explorerExcludedWalletIds: void 0, -+ explorerRecommendedWalletIds: void 0, -+ termsOfServiceUrl: void 0, -+ privacyPolicyUrl: void 0, -+ }), -+ y = { -+ state: W, -+ subscribe(e) { -+ return h(W, () => e(W)); -+ }, -+ setConfig(e) { -+ var t, s; -+ R.initialize(), -+ p.setChains(e.chains), -+ p.setIsAuth(Boolean(e.enableAuthMode)), -+ p.setIsCustomMobile( -+ Boolean((t = e.mobileWallets) == null ? void 0 : t.length), -+ ), -+ p.setIsCustomDesktop( -+ Boolean((s = e.desktopWallets) == null ? void 0 : s.length), -+ ), -+ a.setModalVersionInStorage(), -+ Object.assign(W, e); -+ }, -+ }; -+var V = Object.defineProperty, -+ D = Object.getOwnPropertySymbols, -+ H = Object.prototype.hasOwnProperty, -+ B = Object.prototype.propertyIsEnumerable, -+ M = (e, t, s) => -+ t in e -+ ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) -+ : (e[t] = s), -+ K = (e, t) => { -+ for (var s in t || (t = {})) H.call(t, s) && M(e, s, t[s]); -+ if (D) for (var s of D(t)) B.call(t, s) && M(e, s, t[s]); -+ return e; -+ }; -+const L = "https://explorer-api.walletconnect.com", -+ E = "wcm", -+ O = "js-2.6.2"; -+async function w(e, t) { -+ const s = K({ sdkType: E, sdkVersion: O }, t), -+ n = new URL(e, L); -+ return ( -+ n.searchParams.append("projectId", y.state.projectId), -+ Object.entries(s).forEach(([i, l]) => { -+ l && n.searchParams.append(i, String(l)); -+ }), -+ (await fetch(n)).json() -+ ); -+} -+const m = { -+ async getDesktopListings(e) { -+ return w("/w3m/v1/getDesktopListings", e); -+ }, -+ async getMobileListings(e) { -+ return w("/w3m/v1/getMobileListings", e); -+ }, -+ async getInjectedListings(e) { -+ return w("/w3m/v1/getInjectedListings", e); -+ }, -+ async getAllListings(e) { -+ return w("/w3m/v1/getAllListings", e); -+ }, -+ getWalletImageUrl(e) { -+ return `${L}/w3m/v1/getWalletImage/${e}?projectId=${y.state.projectId}&sdkType=${E}&sdkVersion=${O}`; -+ }, -+ getAssetImageUrl(e) { -+ return `${L}/w3m/v1/getAssetImage/${e}?projectId=${y.state.projectId}&sdkType=${E}&sdkVersion=${O}`; -+ }, -+}; -+var z = Object.defineProperty, -+ j = Object.getOwnPropertySymbols, -+ J = Object.prototype.hasOwnProperty, -+ q = Object.prototype.propertyIsEnumerable, -+ k = (e, t, s) => -+ t in e -+ ? z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) -+ : (e[t] = s), -+ F = (e, t) => { -+ for (var s in t || (t = {})) J.call(t, s) && k(e, s, t[s]); -+ if (j) for (var s of j(t)) q.call(t, s) && k(e, s, t[s]); -+ return e; -+ }; -+const N = a.isMobile(), -+ d = u({ -+ wallets: { listings: [], total: 0, page: 1 }, -+ search: { listings: [], total: 0, page: 1 }, -+ recomendedWallets: [], -+ }), -+ te = { -+ state: d, -+ async getRecomendedWallets() { -+ const { explorerRecommendedWalletIds: e, explorerExcludedWalletIds: t } = -+ y.state; -+ if (e === "NONE" || (t === "ALL" && !e)) return d.recomendedWallets; -+ if (a.isArray(e)) { -+ const s = { recommendedIds: e.join(",") }, -+ { listings: n } = await m.getAllListings(s), -+ i = Object.values(n); -+ (i.sort && i.sort((l, v) => { -+ const b = e.indexOf(l.id), -+ f = e.indexOf(v.id); -+ return b - f; -+ })), -+ (d.recomendedWallets = i); -+ } else { -+ const { chains: s, isAuth: n } = p.state, -+ i = s?.join(","), -+ l = a.isArray(t), -+ v = { -+ page: 1, -+ sdks: n ? "auth_v1" : void 0, -+ entries: a.RECOMMENDED_WALLET_AMOUNT, -+ chains: i, -+ version: 2, -+ excludedIds: l ? t.join(",") : void 0, -+ }, -+ { listings: b } = N -+ ? await m.getMobileListings(v) -+ : await m.getDesktopListings(v); -+ d.recomendedWallets = Object.values(b); -+ } -+ return d.recomendedWallets; -+ }, -+ async getWallets(e) { -+ const t = F({}, e), -+ { explorerRecommendedWalletIds: s, explorerExcludedWalletIds: n } = -+ y.state, -+ { recomendedWallets: i } = d; -+ if (n === "ALL") return d.wallets; -+ i.length -+ ? (t.excludedIds = i.map((x) => x.id).join(",")) -+ : a.isArray(s) && (t.excludedIds = s.join(",")), -+ a.isArray(n) && -+ (t.excludedIds = [t.excludedIds, n].filter(Boolean).join(",")), -+ p.state.isAuth && (t.sdks = "auth_v1"); -+ const { page: l, search: v } = e, -+ { listings: b, total: f } = N -+ ? await m.getMobileListings(t) -+ : await m.getDesktopListings(t), -+ A = Object.values(b), -+ U = v ? "search" : "wallets"; -+ return ( -+ (d[U] = { listings: [...d[U].listings, ...A], total: f, page: l ?? 1 }), -+ { listings: A, total: f } -+ ); -+ }, -+ getWalletImageUrl(e) { -+ return m.getWalletImageUrl(e); -+ }, -+ getAssetImageUrl(e) { -+ return m.getAssetImageUrl(e); -+ }, -+ resetSearch() { -+ d.search = { listings: [], total: 0, page: 1 }; -+ }, -+ }, -+ I = u({ open: !1 }), -+ se = { -+ state: I, -+ subscribe(e) { -+ return h(I, () => e(I)); -+ }, -+ async open(e) { -+ return new Promise((t) => { -+ const { isUiLoaded: s, isDataLoaded: n } = p.state; -+ if ( -+ (a.removeWalletConnectDeepLink(), -+ p.setWalletConnectUri(e?.uri), -+ p.setChains(e?.chains), -+ T.reset("ConnectWallet"), -+ s && n) -+ ) -+ (I.open = !0), t(); -+ else { -+ const i = setInterval(() => { -+ const l = p.state; -+ l.isUiLoaded && -+ l.isDataLoaded && -+ (clearInterval(i), (I.open = !0), t()); -+ }, 200); -+ } -+ }); -+ }, -+ close() { -+ I.open = !1; -+ }, -+ }; -+var G = Object.defineProperty, -+ $ = Object.getOwnPropertySymbols, -+ Q = Object.prototype.hasOwnProperty, -+ X = Object.prototype.propertyIsEnumerable, -+ S = (e, t, s) => -+ t in e -+ ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) -+ : (e[t] = s), -+ Y = (e, t) => { -+ for (var s in t || (t = {})) Q.call(t, s) && S(e, s, t[s]); -+ if ($) for (var s of $(t)) X.call(t, s) && S(e, s, t[s]); -+ return e; -+ }; -+function Z() { -+ return ( -+ typeof matchMedia < "u" && -+ matchMedia("(prefers-color-scheme: dark)").matches -+ ); -+} -+const C = u({ themeMode: Z() ? "dark" : "light" }), -+ ne = { -+ state: C, -+ subscribe(e) { -+ return h(C, () => e(C)); -+ }, -+ setThemeConfig(e) { -+ const { themeMode: t, themeVariables: s } = e; -+ t && (C.themeMode = t), s && (C.themeVariables = Y({}, s)); -+ }, -+ }, -+ g = u({ open: !1, message: "", variant: "success" }), -+ oe = { -+ state: g, -+ subscribe(e) { -+ return h(g, () => e(g)); -+ }, -+ openToast(e, t) { -+ (g.open = !0), (g.message = e), (g.variant = t); -+ }, -+ closeToast() { -+ g.open = !1; -+ }, -+ }; -+export { -+ y as ConfigCtrl, -+ a as CoreUtil, -+ R as EventsCtrl, -+ te as ExplorerCtrl, -+ se as ModalCtrl, -+ p as OptionsCtrl, -+ T as RouterCtrl, -+ ne as ThemeCtrl, -+ oe as ToastCtrl, -+}; - //# sourceMappingURL=index.js.map diff --git a/patches/@walletconnect__modal-ui@2.6.2.patch b/patches/@walletconnect__modal-ui@2.6.2.patch deleted file mode 100644 index 2c010698..00000000 --- a/patches/@walletconnect__modal-ui@2.6.2.patch +++ /dev/null @@ -1,1781 +0,0 @@ -diff --git a/dist/index.js b/dist/index.js -index f6ac95cd9b61c4ff6bbb87fd18061e2f604d5577..38af34089e51d992c9e8cd9c30173898351642c0 100644 ---- a/dist/index.js -+++ b/dist/index.js -@@ -1,2 +1,1775 @@ --import{css as g,LitElement as w,html as n,svg as pe}from"lit";import{property as d,customElement as p,state as I}from"lit/decorators.js";import{classMap as P}from"lit/directives/class-map.js";import{ThemeCtrl as X,ModalCtrl as ge,RouterCtrl as x,ConfigCtrl as z,ExplorerCtrl as W,CoreUtil as m,OptionsCtrl as R,ToastCtrl as N,EventsCtrl as Xe}from"@walletconnect/modal-core";import{svg as C}from"lit-html";import{animate as H}from"motion";import{ifDefined as k}from"lit/directives/if-defined.js";import Je from"qrcode";var et=Object.defineProperty,Be=Object.getOwnPropertySymbols,tt=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,Ue=(e,o,r)=>o in e?et(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,ve=(e,o)=>{for(var r in o||(o={}))tt.call(o,r)&&Ue(e,r,o[r]);if(Be)for(var r of Be(o))ot.call(o,r)&&Ue(e,r,o[r]);return e};function rt(){var e;const o=(e=X.state.themeMode)!=null?e:"dark",r={light:{foreground:{1:"rgb(20,20,20)",2:"rgb(121,134,134)",3:"rgb(158,169,169)"},background:{1:"rgb(255,255,255)",2:"rgb(241,243,243)",3:"rgb(228,231,231)"},overlay:"rgba(0,0,0,0.1)"},dark:{foreground:{1:"rgb(228,231,231)",2:"rgb(148,158,158)",3:"rgb(110,119,119)"},background:{1:"rgb(20,20,20)",2:"rgb(39,42,42)",3:"rgb(59,64,64)"},overlay:"rgba(255,255,255,0.1)"}}[o];return{"--wcm-color-fg-1":r.foreground[1],"--wcm-color-fg-2":r.foreground[2],"--wcm-color-fg-3":r.foreground[3],"--wcm-color-bg-1":r.background[1],"--wcm-color-bg-2":r.background[2],"--wcm-color-bg-3":r.background[3],"--wcm-color-overlay":r.overlay}}function He(){return{"--wcm-accent-color":"#3396FF","--wcm-accent-fill-color":"#FFFFFF","--wcm-z-index":"89","--wcm-background-color":"#3396FF","--wcm-background-border-radius":"8px","--wcm-container-border-radius":"30px","--wcm-wallet-icon-border-radius":"15px","--wcm-wallet-icon-large-border-radius":"30px","--wcm-wallet-icon-small-border-radius":"7px","--wcm-input-border-radius":"28px","--wcm-button-border-radius":"10px","--wcm-notification-border-radius":"36px","--wcm-secondary-button-border-radius":"28px","--wcm-icon-button-border-radius":"50%","--wcm-button-hover-highlight-border-radius":"10px","--wcm-text-big-bold-size":"20px","--wcm-text-big-bold-weight":"600","--wcm-text-big-bold-line-height":"24px","--wcm-text-big-bold-letter-spacing":"-0.03em","--wcm-text-big-bold-text-transform":"none","--wcm-text-xsmall-bold-size":"10px","--wcm-text-xsmall-bold-weight":"700","--wcm-text-xsmall-bold-line-height":"12px","--wcm-text-xsmall-bold-letter-spacing":"0.02em","--wcm-text-xsmall-bold-text-transform":"uppercase","--wcm-text-xsmall-regular-size":"12px","--wcm-text-xsmall-regular-weight":"600","--wcm-text-xsmall-regular-line-height":"14px","--wcm-text-xsmall-regular-letter-spacing":"-0.03em","--wcm-text-xsmall-regular-text-transform":"none","--wcm-text-small-thin-size":"14px","--wcm-text-small-thin-weight":"500","--wcm-text-small-thin-line-height":"16px","--wcm-text-small-thin-letter-spacing":"-0.03em","--wcm-text-small-thin-text-transform":"none","--wcm-text-small-regular-size":"14px","--wcm-text-small-regular-weight":"600","--wcm-text-small-regular-line-height":"16px","--wcm-text-small-regular-letter-spacing":"-0.03em","--wcm-text-small-regular-text-transform":"none","--wcm-text-medium-regular-size":"16px","--wcm-text-medium-regular-weight":"600","--wcm-text-medium-regular-line-height":"20px","--wcm-text-medium-regular-letter-spacing":"-0.03em","--wcm-text-medium-regular-text-transform":"none","--wcm-font-family":"-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif","--wcm-font-feature-settings":"'tnum' on, 'lnum' on, 'case' on","--wcm-success-color":"rgb(38,181,98)","--wcm-error-color":"rgb(242, 90, 103)","--wcm-overlay-background-color":"rgba(0, 0, 0, 0.3)","--wcm-overlay-backdrop-filter":"none"}}const h={getPreset(e){return He()[e]},setTheme(){const e=document.querySelector(":root"),{themeVariables:o}=X.state;if(e){const r=ve(ve(ve({},rt()),He()),o);Object.entries(r).forEach(([a,t])=>e.style.setProperty(a,t))}},globalCss:g`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}`},at=g`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`;var lt=Object.defineProperty,it=Object.getOwnPropertyDescriptor,F=(e,o,r,a)=>{for(var t=a>1?void 0:a?it(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&<(o,r,t),t};let T=class extends w{constructor(){super(...arguments),this.disabled=!1,this.iconLeft=void 0,this.iconRight=void 0,this.onClick=()=>null,this.variant="default"}render(){const e={"wcm-icon-left":this.iconLeft!==void 0,"wcm-icon-right":this.iconRight!==void 0,"wcm-ghost":this.variant==="ghost","wcm-outline":this.variant==="outline"};let o="inverse";return this.variant==="ghost"&&(o="secondary"),this.variant==="outline"&&(o="accent"),n``}};T.styles=[h.globalCss,at],F([d({type:Boolean})],T.prototype,"disabled",2),F([d()],T.prototype,"iconLeft",2),F([d()],T.prototype,"iconRight",2),F([d()],T.prototype,"onClick",2),F([d()],T.prototype,"variant",2),T=F([p("wcm-button")],T);const nt=g`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`;var ct=Object.defineProperty,st=Object.getOwnPropertyDescriptor,ue=(e,o,r,a)=>{for(var t=a>1?void 0:a?st(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&ct(o,r,t),t};let ee=class extends w{constructor(){super(...arguments),this.disabled=!1,this.variant="primary"}render(){const e={"wcm-secondary":this.variant==="secondary"};return n``}};ee.styles=[h.globalCss,nt],ue([d({type:Boolean})],ee.prototype,"disabled",2),ue([d()],ee.prototype,"variant",2),ee=ue([p("wcm-button-big")],ee);const dt=g`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`;var mt=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,wt=(e,o,r,a)=>{for(var t=a>1?void 0:a?ht(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&mt(o,r,t),t};let be=class extends w{render(){return n`
`}};be.styles=[h.globalCss,dt],be=wt([p("wcm-info-footer")],be);const v={CROSS_ICON:C``,WALLET_CONNECT_LOGO:C``,WALLET_CONNECT_ICON:C``,WALLET_CONNECT_ICON_COLORED:C``,BACK_ICON:C``,COPY_ICON:C``,RETRY_ICON:C``,DESKTOP_ICON:C``,MOBILE_ICON:C``,ARROW_DOWN_ICON:C``,ARROW_UP_RIGHT_ICON:C``,ARROW_RIGHT_ICON:C``,QRCODE_ICON:C``,SCAN_ICON:C``,CHECKMARK_ICON:C``,SEARCH_ICON:C``,WALLET_PLACEHOLDER:C``,GLOBE_ICON:C``},pt=g`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`;var gt=Object.defineProperty,vt=Object.getOwnPropertyDescriptor,ut=(e,o,r,a)=>{for(var t=a>1?void 0:a?vt(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&>(o,r,t),t};let fe=class extends w{render(){return n`
${v.WALLET_CONNECT_LOGO}
`}};fe.styles=[h.globalCss,pt],fe=ut([p("wcm-modal-backcard")],fe);const bt=g`main{padding:20px;padding-top:0;width:100%}`;var ft=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,yt=(e,o,r,a)=>{for(var t=a>1?void 0:a?xt(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&ft(o,r,t),t};let xe=class extends w{render(){return n`
`}};xe.styles=[h.globalCss,bt],xe=yt([p("wcm-modal-content")],xe);const $t=g`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`;var Ct=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,Ot=(e,o,r,a)=>{for(var t=a>1?void 0:a?kt(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Ct(o,r,t),t};let ye=class extends w{render(){return n`
`}};ye.styles=[h.globalCss,$t],ye=Ot([p("wcm-modal-footer")],ye);const Wt=g`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`;var It=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,te=(e,o,r,a)=>{for(var t=a>1?void 0:a?Et(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&It(o,r,t),t};let S=class extends w{constructor(){super(...arguments),this.title="",this.onAction=void 0,this.actionIcon=void 0,this.border=!1}backBtnTemplate(){return n``}actionBtnTemplate(){return n``}render(){const e={"wcm-border":this.border},o=x.state.history.length>1,r=this.title?n`${this.title}`:n``;return n`
${o?this.backBtnTemplate():null} ${r} ${this.onAction?this.actionBtnTemplate():null}
`}};S.styles=[h.globalCss,Wt],te([d()],S.prototype,"title",2),te([d()],S.prototype,"onAction",2),te([d()],S.prototype,"actionIcon",2),te([d({type:Boolean})],S.prototype,"border",2),S=te([p("wcm-modal-header")],S);const c={MOBILE_BREAKPOINT:600,WCM_RECENT_WALLET_DATA:"WCM_RECENT_WALLET_DATA",EXPLORER_WALLET_URL:"https://explorer.walletconnect.com/?type=wallet",getShadowRootElement(e,o){const r=e.renderRoot.querySelector(o);if(!r)throw new Error(`${o} not found`);return r},getWalletIcon({id:e,image_id:o}){const{walletImages:r}=z.state;return r!=null&&r[e]?r[e]:o?W.getWalletImageUrl(o):""},getWalletName(e,o=!1){return o&&e.length>8?`${e.substring(0,8)}..`:e},isMobileAnimation(){return window.innerWidth<=c.MOBILE_BREAKPOINT},async preloadImage(e){const o=new Promise((r,a)=>{const t=new Image;t.onload=r,t.onerror=a,t.crossOrigin="anonymous",t.src=e});return Promise.race([o,m.wait(3e3)])},getErrorMessage(e){return e instanceof Error?e.message:"Unknown Error"},debounce(e,o=500){let r;return(...a)=>{function t(){e(...a)}r&&clearTimeout(r),r=setTimeout(t,o)}},handleMobileLinking(e){const{walletConnectUri:o}=R.state,{mobile:r,name:a}=e,t=r?.native,l=r?.universal;c.setRecentWallet(e);function i(s){let $="";t?$=m.formatUniversalUrl(t,s,a):l&&($=m.formatNativeUrl(l,s,a)),m.openHref($,"_self")}o&&i(o)},handleAndroidLinking(){const{walletConnectUri:e}=R.state;e&&(m.setWalletConnectAndroidDeepLink(e),m.openHref(e,"_self"))},async handleUriCopy(){const{walletConnectUri:e}=R.state;if(e)try{await navigator.clipboard.writeText(e),N.openToast("Link copied","success")}catch{N.openToast("Failed to copy","error")}},getCustomImageUrls(){const{walletImages:e}=z.state,o=Object.values(e??{});return Object.values(o)},truncate(e,o=8){return e.length<=o?e:`${e.substring(0,4)}...${e.substring(e.length-4)}`},setRecentWallet(e){try{localStorage.setItem(c.WCM_RECENT_WALLET_DATA,JSON.stringify(e))}catch{console.info("Unable to set recent wallet")}},getRecentWallet(){try{const e=localStorage.getItem(c.WCM_RECENT_WALLET_DATA);return e?JSON.parse(e):void 0}catch{console.info("Unable to get recent wallet")}},caseSafeIncludes(e,o){return e.toUpperCase().includes(o.toUpperCase())},openWalletExplorerUrl(){m.openHref(c.EXPLORER_WALLET_URL,"_blank")},getCachedRouterWalletPlatforms(){const{desktop:e,mobile:o}=m.getWalletRouterData(),r=Boolean(e?.native),a=Boolean(e?.universal),t=Boolean(o?.native)||Boolean(o?.universal);return{isDesktop:r,isMobile:t,isWeb:a}},goToConnectingView(e){x.setData({Wallet:e});const o=m.isMobile(),{isDesktop:r,isWeb:a,isMobile:t}=c.getCachedRouterWalletPlatforms();o?t?x.push("MobileConnecting"):a?x.push("WebConnecting"):x.push("InstallWallet"):r?x.push("DesktopConnecting"):a?x.push("WebConnecting"):t?x.push("MobileQrcodeConnecting"):x.push("InstallWallet")}},Mt=g`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`;var Lt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,$e=(e,o,r,a)=>{for(var t=a>1?void 0:a?Rt(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Lt(o,r,t),t};let oe=class extends w{constructor(){super(),this.view=x.state.view,this.prevView=x.state.view,this.unsubscribe=void 0,this.oldHeight="0px",this.resizeObserver=void 0,this.unsubscribe=x.subscribe(e=>{this.view!==e.view&&this.onChangeRoute()})}firstUpdated(){this.resizeObserver=new ResizeObserver(([e])=>{const o=`${e.contentRect.height}px`;this.oldHeight!=="0px"&&H(this.routerEl,{height:[this.oldHeight,o]},{duration:.2}),this.oldHeight=o}),this.resizeObserver.observe(this.contentEl)}disconnectedCallback(){var e,o;(e=this.unsubscribe)==null||e.call(this),(o=this.resizeObserver)==null||o.disconnect()}get routerEl(){return c.getShadowRootElement(this,".wcm-router")}get contentEl(){return c.getShadowRootElement(this,".wcm-content")}viewTemplate(){switch(this.view){case"ConnectWallet":return n``;case"DesktopConnecting":return n``;case"MobileConnecting":return n``;case"WebConnecting":return n``;case"MobileQrcodeConnecting":return n``;case"WalletExplorer":return n``;case"Qrcode":return n``;case"InstallWallet":return n``;default:return n`
Not Found
`}}async onChangeRoute(){await H(this.routerEl,{opacity:[1,0],scale:[1,1.02]},{duration:.15,delay:.1}).finished,this.view=x.state.view,H(this.routerEl,{opacity:[0,1],scale:[.99,1]},{duration:.37,delay:.05})}render(){return n`
${this.viewTemplate()}
`}};oe.styles=[h.globalCss,Mt],$e([I()],oe.prototype,"view",2),$e([I()],oe.prototype,"prevView",2),oe=$e([p("wcm-modal-router")],oe);const At=g`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`;var Pt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,ze=(e,o,r,a)=>{for(var t=a>1?void 0:a?Tt(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Pt(o,r,t),t};let ne=class extends w{constructor(){super(),this.open=!1,this.unsubscribe=void 0,this.timeout=void 0,this.unsubscribe=N.subscribe(e=>{e.open?(this.open=!0,this.timeout=setTimeout(()=>N.closeToast(),2200)):(this.open=!1,clearTimeout(this.timeout))})}disconnectedCallback(){var e;(e=this.unsubscribe)==null||e.call(this),clearTimeout(this.timeout),N.closeToast()}render(){const{message:e,variant:o}=N.state,r={"wcm-success":o==="success","wcm-error":o==="error"};return this.open?n`
${o==="success"?v.CHECKMARK_ICON:null} ${o==="error"?v.CROSS_ICON:null}${e}
`:null}};ne.styles=[h.globalCss,At],ze([I()],ne.prototype,"open",2),ne=ze([p("wcm-modal-toast")],ne);const jt=.1,Ve=2.5,A=7;function Ce(e,o,r){return e===o?!1:(e-o<0?o-e:e-o)<=r+jt}function _t(e,o){const r=Array.prototype.slice.call(Je.create(e,{errorCorrectionLevel:o}).modules.data,0),a=Math.sqrt(r.length);return r.reduce((t,l,i)=>(i%a===0?t.push([l]):t[t.length-1].push(l))&&t,[])}const Dt={generate(e,o,r){const a="#141414",t="#ffffff",l=[],i=_t(e,"Q"),s=o/i.length,$=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];$.forEach(({x:y,y:u})=>{const O=(i.length-A)*s*y,b=(i.length-A)*s*u,E=.45;for(let M=0;M<$.length;M+=1){const V=s*(A-M*2);l.push(pe``)}});const f=Math.floor((r+25)/s),Ne=i.length/2-f/2,Ze=i.length/2+f/2-1,Se=[];i.forEach((y,u)=>{y.forEach((O,b)=>{if(i[u][b]&&!(ui.length-(A+1)&&bi.length-(A+1))&&!(u>Ne&&uNe&&b{J[y]?J[y].push(u):J[y]=[u]}),Object.entries(J).map(([y,u])=>{const O=u.filter(b=>u.every(E=>!Ce(b,E,s)));return[Number(y),O]}).forEach(([y,u])=>{u.forEach(O=>{l.push(pe``)})}),Object.entries(J).filter(([y,u])=>u.length>1).map(([y,u])=>{const O=u.filter(b=>u.some(E=>Ce(b,E,s)));return[Number(y),O]}).map(([y,u])=>{u.sort((b,E)=>bM.some(V=>Ce(b,V,s)));E?E.push(b):O.push([b])}return[y,O.map(b=>[b[0],b[b.length-1]])]}).forEach(([y,u])=>{u.forEach(([O,b])=>{l.push(pe``)})}),l}},Nt=g`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`;var Zt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,q=(e,o,r,a)=>{for(var t=a>1?void 0:a?St(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Zt(o,r,t),t};let j=class extends w{constructor(){super(...arguments),this.uri="",this.size=0,this.imageId=void 0,this.walletId=void 0,this.imageUrl=void 0}svgTemplate(){const e=X.state.themeMode==="light"?this.size:this.size-36;return pe`${Dt.generate(this.uri,e,e/4)}`}render(){const e={"wcm-dark":X.state.themeMode==="dark"};return n`
${this.walletId||this.imageUrl?n``:v.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`}};j.styles=[h.globalCss,Nt],q([d()],j.prototype,"uri",2),q([d({type:Number})],j.prototype,"size",2),q([d()],j.prototype,"imageId",2),q([d()],j.prototype,"walletId",2),q([d()],j.prototype,"imageUrl",2),j=q([p("wcm-qrcode")],j);const Bt=g`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`;var Ut=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Fe=(e,o,r,a)=>{for(var t=a>1?void 0:a?Ht(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Ut(o,r,t),t};let ce=class extends w{constructor(){super(...arguments),this.onChange=()=>null}render(){return n` ${v.SEARCH_ICON}`}};ce.styles=[h.globalCss,Bt],Fe([d()],ce.prototype,"onChange",2),ce=Fe([p("wcm-search-input")],ce);const zt=g`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`;var Vt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,qt=(e,o,r,a)=>{for(var t=a>1?void 0:a?Ft(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Vt(o,r,t),t};let ke=class extends w{render(){return n``}};ke.styles=[h.globalCss,zt],ke=qt([p("wcm-spinner")],ke);const Qt=g`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`;var Kt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Oe=(e,o,r,a)=>{for(var t=a>1?void 0:a?Yt(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Kt(o,r,t),t};let re=class extends w{constructor(){super(...arguments),this.variant="medium-regular",this.color="primary"}render(){const e={"wcm-big-bold":this.variant==="big-bold","wcm-medium-regular":this.variant==="medium-regular","wcm-small-regular":this.variant==="small-regular","wcm-small-thin":this.variant==="small-thin","wcm-xsmall-regular":this.variant==="xsmall-regular","wcm-xsmall-bold":this.variant==="xsmall-bold","wcm-color-primary":this.color==="primary","wcm-color-secondary":this.color==="secondary","wcm-color-tertiary":this.color==="tertiary","wcm-color-inverse":this.color==="inverse","wcm-color-accnt":this.color==="accent","wcm-color-error":this.color==="error"};return n``}};re.styles=[h.globalCss,Qt],Oe([d()],re.prototype,"variant",2),Oe([d()],re.prototype,"color",2),re=Oe([p("wcm-text")],re);const Gt=g`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`;var Xt=Object.defineProperty,Jt=Object.getOwnPropertyDescriptor,_=(e,o,r,a)=>{for(var t=a>1?void 0:a?Jt(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Xt(o,r,t),t};let L=class extends w{constructor(){super(...arguments),this.onClick=()=>null,this.name="",this.walletId="",this.label=void 0,this.imageId=void 0,this.installed=!1,this.recent=!1}sublabelTemplate(){return this.recent?n`RECENT`:this.installed?n`INSTALLED`:null}handleClick(){Xe.click({name:"WALLET_BUTTON",walletId:this.walletId}),this.onClick()}render(){var e;return n``}};L.styles=[h.globalCss,Gt],_([d()],L.prototype,"onClick",2),_([d()],L.prototype,"name",2),_([d()],L.prototype,"walletId",2),_([d()],L.prototype,"label",2),_([d()],L.prototype,"imageId",2),_([d({type:Boolean})],L.prototype,"installed",2),_([d({type:Boolean})],L.prototype,"recent",2),L=_([p("wcm-wallet-button")],L);const eo=g`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var to=Object.defineProperty,oo=Object.getOwnPropertyDescriptor,se=(e,o,r,a)=>{for(var t=a>1?void 0:a?oo(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&to(o,r,t),t};let Q=class extends w{constructor(){super(...arguments),this.walletId="",this.imageId=void 0,this.imageUrl=void 0}render(){var e;const o=(e=this.imageUrl)!=null&&e.length?this.imageUrl:c.getWalletIcon({id:this.walletId,image_id:this.imageId});return n`${o.length?n`
${this.id}
`:v.WALLET_PLACEHOLDER}`}};Q.styles=[h.globalCss,eo],se([d()],Q.prototype,"walletId",2),se([d()],Q.prototype,"imageId",2),se([d()],Q.prototype,"imageUrl",2),Q=se([p("wcm-wallet-image")],Q);var ro=Object.defineProperty,ao=Object.getOwnPropertyDescriptor,qe=(e,o,r,a)=>{for(var t=a>1?void 0:a?ao(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&ro(o,r,t),t};let We=class extends w{constructor(){super(),this.preload=!0,this.preloadData()}async loadImages(e){try{e!=null&&e.length&&await Promise.all(e.map(async o=>c.preloadImage(o)))}catch{console.info("Unsuccessful attempt at preloading some images",e)}}async preloadListings(){if(z.state.enableExplorer){await W.getRecomendedWallets(),R.setIsDataLoaded(!0);const{recomendedWallets:e}=W.state,o=e.map(r=>c.getWalletIcon(r));await this.loadImages(o)}else R.setIsDataLoaded(!0)}async preloadCustomImages(){const e=c.getCustomImageUrls();await this.loadImages(e)}async preloadData(){try{this.preload&&(this.preload=!1,await Promise.all([this.preloadListings(),this.preloadCustomImages()]))}catch(e){console.error(e),N.openToast("Failed preloading","error")}}};qe([I()],We.prototype,"preload",2),We=qe([p("wcm-explorer-context")],We);var lo=Object.defineProperty,io=Object.getOwnPropertyDescriptor,no=(e,o,r,a)=>{for(var t=a>1?void 0:a?io(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&lo(o,r,t),t};let Qe=class extends w{constructor(){super(),this.unsubscribeTheme=void 0,h.setTheme(),this.unsubscribeTheme=X.subscribe(h.setTheme)}disconnectedCallback(){var e;(e=this.unsubscribeTheme)==null||e.call(this)}};Qe=no([p("wcm-theme-context")],Qe);const co=g`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var so=Object.defineProperty,mo=Object.getOwnPropertyDescriptor,ho=(e,o,r,a)=>{for(var t=a>1?void 0:a?mo(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&so(o,r,t),t};let Ie=class extends w{onGoToQrcode(){x.push("Qrcode")}render(){const{recomendedWallets:e}=W.state,o=[...e,...e],r=m.RECOMMENDED_WALLET_AMOUNT*2;return n`
${v.MOBILE_ICON}WalletConnect
${[...Array(r)].map((a,t)=>{const l=o[t%o.length];return l?n``:v.WALLET_PLACEHOLDER})}
Select Wallet
Choose WalletConnect to see supported apps on your device`}};Ie.styles=[h.globalCss,co],Ie=ho([p("wcm-android-wallet-selection")],Ie);const wo=g`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`;var po=Object.defineProperty,go=Object.getOwnPropertyDescriptor,K=(e,o,r,a)=>{for(var t=a>1?void 0:a?go(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&po(o,r,t),t};let D=class extends w{constructor(){super(...arguments),this.walletId=void 0,this.imageId=void 0,this.isError=!1,this.isStale=!1,this.label=""}svgLoaderTemplate(){var e,o;const r=(o=(e=X.state.themeVariables)==null?void 0:e["--wcm-wallet-icon-large-border-radius"])!=null?o:h.getPreset("--wcm-wallet-icon-large-border-radius");let a=0;r.includes("%")?a=88/100*parseInt(r,10):a=parseInt(r,10),a*=1.17;const t=317-a*1.57,l=425-a*1.8;return n``}render(){const e={"wcm-error":this.isError,"wcm-stale":this.isStale};return n`
${this.svgLoaderTemplate()}
${this.isError?"Connection declined":this.label}`}};D.styles=[h.globalCss,wo],K([d()],D.prototype,"walletId",2),K([d()],D.prototype,"imageId",2),K([d({type:Boolean})],D.prototype,"isError",2),K([d({type:Boolean})],D.prototype,"isStale",2),K([d()],D.prototype,"label",2),D=K([p("wcm-connector-waiting")],D);const G={manualWallets(){var e,o;const{mobileWallets:r,desktopWallets:a}=z.state,t=(e=G.recentWallet())==null?void 0:e.id,l=m.isMobile()?r:a,i=l?.filter(s=>t!==s.id);return(o=m.isMobile()?i?.map(({id:s,name:$,links:f})=>({id:s,name:$,mobile:f,links:f})):i?.map(({id:s,name:$,links:f})=>({id:s,name:$,desktop:f,links:f})))!=null?o:[]},recentWallet(){return c.getRecentWallet()},recomendedWallets(e=!1){var o;const r=e||(o=G.recentWallet())==null?void 0:o.id,{recomendedWallets:a}=W.state;return a.filter(t=>r!==t.id)}},Z={onConnecting(e){c.goToConnectingView(e)},manualWalletsTemplate(){return G.manualWallets().map(e=>n``)},recomendedWalletsTemplate(e=!1){return G.recomendedWallets(e).map(o=>n``)},recentWalletTemplate(){const e=G.recentWallet();if(e)return n``}},vo=g`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;var uo=Object.defineProperty,bo=Object.getOwnPropertyDescriptor,fo=(e,o,r,a)=>{for(var t=a>1?void 0:a?bo(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&uo(o,r,t),t};let Ee=class extends w{render(){const{explorerExcludedWalletIds:e,enableExplorer:o}=z.state,r=e!=="ALL"&&o,a=Z.manualWalletsTemplate(),t=Z.recomendedWalletsTemplate();let l=[Z.recentWalletTemplate(),...a,...t];l=l.filter(Boolean);const i=l.length>4||r;let s=[];i?s=l.slice(0,3):s=l;const $=Boolean(s.length);return n`
${v.MOBILE_ICON}Mobile
${v.SCAN_ICON}Scan with your wallet
${$?n`
${v.DESKTOP_ICON}Desktop
${s} ${i?n``:null}
`:null}`}};Ee.styles=[h.globalCss,vo],Ee=fo([p("wcm-desktop-wallet-selection")],Ee);const xo=g`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`;var yo=Object.defineProperty,$o=Object.getOwnPropertyDescriptor,Co=(e,o,r,a)=>{for(var t=a>1?void 0:a?$o(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&yo(o,r,t),t};let Me=class extends w{render(){const{termsOfServiceUrl:e,privacyPolicyUrl:o}=z.state;return e??o?n`
By connecting your wallet to this app, you agree to the app's ${e?n`Terms of Service`:null} ${e&&o?"and":null} ${o?n`Privacy Policy`:null}
`:null}};Me.styles=[h.globalCss,xo],Me=Co([p("wcm-legal-notice")],Me);const ko=g`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`;var Oo=Object.defineProperty,Wo=Object.getOwnPropertyDescriptor,Io=(e,o,r,a)=>{for(var t=a>1?void 0:a?Wo(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Oo(o,r,t),t};let Le=class extends w{onQrcode(){x.push("Qrcode")}render(){const{explorerExcludedWalletIds:e,enableExplorer:o}=z.state,r=e!=="ALL"&&o,a=Z.manualWalletsTemplate(),t=Z.recomendedWalletsTemplate();let l=[Z.recentWalletTemplate(),...a,...t];l=l.filter(Boolean);const i=l.length>8||r;let s=[];i?s=l.slice(0,7):s=l;const $=Boolean(s.length);return n`${$?n`
${s} ${i?n``:null}
`:null}`}};Le.styles=[h.globalCss,ko],Le=Io([p("wcm-mobile-wallet-selection")],Le);const Eo=g`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`;var Mo=Object.defineProperty,Lo=Object.getOwnPropertyDescriptor,Re=(e,o,r,a)=>{for(var t=a>1?void 0:a?Lo(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Mo(o,r,t),t};let ae=class extends w{constructor(){super(),this.open=!1,this.active=!1,this.unsubscribeModal=void 0,this.abortController=void 0,this.unsubscribeModal=ge.subscribe(e=>{e.open?this.onOpenModalEvent():this.onCloseModalEvent()})}disconnectedCallback(){var e;(e=this.unsubscribeModal)==null||e.call(this)}get overlayEl(){return c.getShadowRootElement(this,".wcm-overlay")}get containerEl(){return c.getShadowRootElement(this,".wcm-container")}toggleBodyScroll(e){if(document.querySelector("body"))if(e){const o=document.getElementById("wcm-styles");o?.remove()}else document.head.insertAdjacentHTML("beforeend",'')}onCloseModal(e){e.target===e.currentTarget&&ge.close()}onOpenModalEvent(){this.toggleBodyScroll(!1),this.addKeyboardEvents(),this.open=!0,setTimeout(async()=>{const e=c.isMobileAnimation()?{y:["50vh","0vh"]}:{scale:[.98,1]},o=.1,r=.2;await Promise.all([H(this.overlayEl,{opacity:[0,1]},{delay:o,duration:r}).finished,H(this.containerEl,e,{delay:o,duration:r}).finished]),this.active=!0},0)}async onCloseModalEvent(){this.toggleBodyScroll(!0),this.removeKeyboardEvents();const e=c.isMobileAnimation()?{y:["0vh","50vh"]}:{scale:[1,.98]},o=.2;await Promise.all([H(this.overlayEl,{opacity:[1,0]},{duration:o}).finished,H(this.containerEl,e,{duration:o}).finished]),this.containerEl.removeAttribute("style"),this.active=!1,this.open=!1}addKeyboardEvents(){this.abortController=new AbortController,window.addEventListener("keydown",e=>{var o;e.key==="Escape"?ge.close():e.key==="Tab"&&((o=e.target)!=null&&o.tagName.includes("wcm-")||this.containerEl.focus())},this.abortController),this.containerEl.focus()}removeKeyboardEvents(){var e;(e=this.abortController)==null||e.abort(),this.abortController=void 0}render(){const e={"wcm-overlay":!0,"wcm-active":this.active};return n`
${this.open?n`
`:null}
`}};ae.styles=[h.globalCss,Eo],Re([I()],ae.prototype,"open",2),Re([I()],ae.prototype,"active",2),ae=Re([p("wcm-modal")],ae);const Ro=g`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`;var Ao=Object.defineProperty,Po=Object.getOwnPropertyDescriptor,le=(e,o,r,a)=>{for(var t=a>1?void 0:a?Po(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Ao(o,r,t),t};let B=class extends w{constructor(){super(...arguments),this.isMobile=!1,this.isDesktop=!1,this.isWeb=!1,this.isRetry=!1}onMobile(){m.isMobile()?x.replace("MobileConnecting"):x.replace("MobileQrcodeConnecting")}onDesktop(){x.replace("DesktopConnecting")}onWeb(){x.replace("WebConnecting")}render(){return n`
${this.isRetry?n``:null} ${this.isMobile?n`Mobile`:null} ${this.isDesktop?n`Desktop`:null} ${this.isWeb?n`Web`:null}
`}};B.styles=[h.globalCss,Ro],le([d({type:Boolean})],B.prototype,"isMobile",2),le([d({type:Boolean})],B.prototype,"isDesktop",2),le([d({type:Boolean})],B.prototype,"isWeb",2),le([d({type:Boolean})],B.prototype,"isRetry",2),B=le([p("wcm-platform-selection")],B);const To=g`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var jo=Object.defineProperty,_o=Object.getOwnPropertyDescriptor,Do=(e,o,r,a)=>{for(var t=a>1?void 0:a?_o(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&jo(o,r,t),t};let Ae=class extends w{onClick(){x.push("WalletExplorer")}render(){const{recomendedWallets:e}=W.state,o=G.manualWallets(),r=[...e,...o].reverse().slice(0,4);return n``}};Ae.styles=[h.globalCss,To],Ae=Do([p("wcm-view-all-wallets-button")],Ae);const No=g`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`;var Zo=Object.defineProperty,So=Object.getOwnPropertyDescriptor,de=(e,o,r,a)=>{for(var t=a>1?void 0:a?So(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Zo(o,r,t),t};let Y=class extends w{constructor(){super(),this.walletId="",this.imageId="",this.uri="",setTimeout(()=>{const{walletConnectUri:e}=R.state;this.uri=e},0)}get overlayEl(){return c.getShadowRootElement(this,".wcm-qr-container")}render(){return n`
${this.uri?n``:n``}
`}};Y.styles=[h.globalCss,No],de([d()],Y.prototype,"walletId",2),de([d()],Y.prototype,"imageId",2),de([I()],Y.prototype,"uri",2),Y=de([p("wcm-walletconnect-qr")],Y);var Bo=Object.defineProperty,Uo=Object.getOwnPropertyDescriptor,Ho=(e,o,r,a)=>{for(var t=a>1?void 0:a?Uo(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Bo(o,r,t),t};let Pe=class extends w{viewTemplate(){return m.isAndroid()?n``:m.isMobile()?n``:n``}render(){return n`${this.viewTemplate()}`}};Pe.styles=[h.globalCss],Pe=Ho([p("wcm-connect-wallet-view")],Pe);const zo=g`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var Vo=Object.defineProperty,Fo=Object.getOwnPropertyDescriptor,Ke=(e,o,r,a)=>{for(var t=a>1?void 0:a?Fo(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Vo(o,r,t),t};let me=class extends w{constructor(){super(),this.isError=!1,this.openDesktopApp()}onFormatAndRedirect(e){const{desktop:o,name:r}=m.getWalletRouterData(),a=o?.native;if(a){const t=m.formatNativeUrl(a,e,r);m.openHref(t,"_self")}}openDesktopApp(){const{walletConnectUri:e}=R.state,o=m.getWalletRouterData();c.setRecentWallet(o),e&&this.onFormatAndRedirect(e)}render(){const{name:e,id:o,image_id:r}=m.getWalletRouterData(),{isMobile:a,isWeb:t}=c.getCachedRouterWalletPlatforms();return n`${`Connection can continue loading if ${e} is not installed on your device`}Retry`}};me.styles=[h.globalCss,zo],Ke([I()],me.prototype,"isError",2),me=Ke([p("wcm-desktop-connecting-view")],me);const qo=g`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`;var Qo=Object.defineProperty,Ko=Object.getOwnPropertyDescriptor,Yo=(e,o,r,a)=>{for(var t=a>1?void 0:a?Ko(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Qo(o,r,t),t};let Te=class extends w{onInstall(e){e&&m.openHref(e,"_blank")}render(){const{name:e,id:o,image_id:r,homepage:a}=m.getWalletRouterData();return n`${`Download ${e} to continue. If multiple browser extensions are installed, disable non ${e} ones and try again`}Download`}};Te.styles=[h.globalCss,qo],Te=Yo([p("wcm-install-wallet-view")],Te);const Go=g`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`;var Xo=Object.defineProperty,Jo=Object.getOwnPropertyDescriptor,Ye=(e,o,r,a)=>{for(var t=a>1?void 0:a?Jo(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&Xo(o,r,t),t};let he=class extends w{constructor(){super(),this.isError=!1,this.openMobileApp()}onFormatAndRedirect(e,o=!1){const{mobile:r,name:a}=m.getWalletRouterData(),t=r?.native,l=r?.universal;if(t&&!o){const i=m.formatNativeUrl(t,e,a);m.openHref(i,"_self")}else if(l){const i=m.formatUniversalUrl(l,e,a);m.openHref(i,"_self")}}openMobileApp(e=!1){const{walletConnectUri:o}=R.state,r=m.getWalletRouterData();c.setRecentWallet(r),o&&this.onFormatAndRedirect(o,e)}onGoToAppStore(e){e&&m.openHref(e,"_blank")}render(){const{name:e,id:o,image_id:r,app:a,mobile:t}=m.getWalletRouterData(),{isWeb:l}=c.getCachedRouterWalletPlatforms(),i=a?.ios,s=t?.universal;return n`Retry${s?n`Still doesn't work? Try this alternate link`:null}
${`Get ${e}`}
App Store
`}};he.styles=[h.globalCss,Go],Ye([I()],he.prototype,"isError",2),he=Ye([p("wcm-mobile-connecting-view")],he);const er=g`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var tr=Object.defineProperty,or=Object.getOwnPropertyDescriptor,rr=(e,o,r,a)=>{for(var t=a>1?void 0:a?or(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&tr(o,r,t),t};let je=class extends w{render(){const{name:e,id:o,image_id:r}=m.getWalletRouterData(),{isDesktop:a,isWeb:t}=c.getCachedRouterWalletPlatforms();return n`${`Scan this QR Code with your phone's camera or inside ${e} app`}`}};je.styles=[h.globalCss,er],je=rr([p("wcm-mobile-qr-connecting-view")],je);var ar=Object.defineProperty,lr=Object.getOwnPropertyDescriptor,ir=(e,o,r,a)=>{for(var t=a>1?void 0:a?lr(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&ar(o,r,t),t};let _e=class extends w{render(){return n``}};_e.styles=[h.globalCss],_e=ir([p("wcm-qrcode-view")],_e);const nr=g`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`;var cr=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,ie=(e,o,r,a)=>{for(var t=a>1?void 0:a?sr(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&cr(o,r,t),t};const De=40;let U=class extends w{constructor(){super(...arguments),this.loading=!W.state.wallets.listings.length,this.firstFetch=!W.state.wallets.listings.length,this.search="",this.endReached=!1,this.intersectionObserver=void 0,this.searchDebounce=c.debounce(e=>{e.length>=1?(this.firstFetch=!0,this.endReached=!1,this.search=e,W.resetSearch(),this.fetchWallets()):this.search&&(this.search="",this.endReached=this.isLastPage(),W.resetSearch())})}firstUpdated(){this.createPaginationObserver()}disconnectedCallback(){var e;(e=this.intersectionObserver)==null||e.disconnect()}get placeholderEl(){return c.getShadowRootElement(this,".wcm-placeholder-block")}createPaginationObserver(){this.intersectionObserver=new IntersectionObserver(([e])=>{e.isIntersecting&&!(this.search&&this.firstFetch)&&this.fetchWallets()}),this.intersectionObserver.observe(this.placeholderEl)}isLastPage(){const{wallets:e,search:o}=W.state,{listings:r,total:a}=this.search?o:e;return a<=De||r.length>=a}async fetchWallets(){var e;const{wallets:o,search:r}=W.state,{listings:a,total:t,page:l}=this.search?r:o;if(!this.endReached&&(this.firstFetch||t>De&&a.lengthc.getWalletIcon(f));await Promise.all([...$.map(async f=>c.preloadImage(f)),m.wait(300)]),this.endReached=this.isLastPage()}catch(i){console.error(i),N.openToast(c.getErrorMessage(i),"error")}finally{this.loading=!1,this.firstFetch=!1}}onConnect(e){m.isAndroid()?c.handleMobileLinking(e):c.goToConnectingView(e)}onSearchChange(e){const{value:o}=e.target;this.searchDebounce(o)}render(){const{wallets:e,search:o}=W.state,{listings:r}=this.search?o:e,a=this.loading&&!r.length,t=this.search.length>=3;let l=Z.manualWalletsTemplate(),i=Z.recomendedWalletsTemplate(!0);t&&(l=l.filter(({values:f})=>c.caseSafeIncludes(f[0],this.search)),i=i.filter(({values:f})=>c.caseSafeIncludes(f[0],this.search)));const s=!this.loading&&!r.length&&!i.length,$={"wcm-loading":a,"wcm-end-reached":this.endReached||!this.loading,"wcm-empty":s};return n`
${a?null:l} ${a?null:i} ${a?null:r.map(f=>n`${f?n``:null}`)}
${s?n`No results found`:null} ${!s&&this.loading?n``:null}
`}};U.styles=[h.globalCss,nr],ie([I()],U.prototype,"loading",2),ie([I()],U.prototype,"firstFetch",2),ie([I()],U.prototype,"search",2),ie([I()],U.prototype,"endReached",2),U=ie([p("wcm-wallet-explorer-view")],U);const dr=g`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var mr=Object.defineProperty,hr=Object.getOwnPropertyDescriptor,Ge=(e,o,r,a)=>{for(var t=a>1?void 0:a?hr(o,r):o,l=e.length-1,i;l>=0;l--)(i=e[l])&&(t=(a?i(o,r,t):i(t))||t);return a&&t&&mr(o,r,t),t};let we=class extends w{constructor(){super(),this.isError=!1,this.openWebWallet()}onFormatAndRedirect(e){const{desktop:o,name:r}=m.getWalletRouterData(),a=o?.universal;if(a){const t=m.formatUniversalUrl(a,e,r);m.openHref(t,"_blank")}}openWebWallet(){const{walletConnectUri:e}=R.state,o=m.getWalletRouterData();c.setRecentWallet(o),e&&this.onFormatAndRedirect(e)}render(){const{name:e,id:o,image_id:r}=m.getWalletRouterData(),{isMobile:a,isDesktop:t}=c.getCachedRouterWalletPlatforms(),l=m.isMobile();return n`${`${e} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`}};we.styles=[h.globalCss,dr],Ge([I()],we.prototype,"isError",2),we=Ge([p("wcm-web-connecting-view")],we);export{ae as WcmModal,j as WcmQrCode}; -+import { css as g, LitElement as w, html as n, svg as pe } from "lit"; -+import { -+ property as d, -+ customElement as p, -+ state as I, -+} from "lit/decorators.js"; -+import { classMap as P } from "lit/directives/class-map.js"; -+import { -+ ThemeCtrl as X, -+ ModalCtrl as ge, -+ RouterCtrl as x, -+ ConfigCtrl as z, -+ ExplorerCtrl as W, -+ CoreUtil as m, -+ OptionsCtrl as R, -+ ToastCtrl as N, -+ EventsCtrl as Xe, -+} from "@walletconnect/modal-core"; -+import { svg as C } from "lit-html"; -+import { animate as H } from "motion"; -+import { ifDefined as k } from "lit/directives/if-defined.js"; -+import Je from "qrcode"; -+var et = Object.defineProperty, -+ Be = Object.getOwnPropertySymbols, -+ tt = Object.prototype.hasOwnProperty, -+ ot = Object.prototype.propertyIsEnumerable, -+ Ue = (e, o, r) => -+ o in e -+ ? et(e, o, { enumerable: !0, configurable: !0, writable: !0, value: r }) -+ : (e[o] = r), -+ ve = (e, o) => { -+ for (var r in o || (o = {})) tt.call(o, r) && Ue(e, r, o[r]); -+ if (Be) for (var r of Be(o)) ot.call(o, r) && Ue(e, r, o[r]); -+ return e; -+ }; -+function rt() { -+ var e; -+ const o = (e = X.state.themeMode) != null ? e : "dark", -+ r = { -+ light: { -+ foreground: { -+ 1: "rgb(20,20,20)", -+ 2: "rgb(121,134,134)", -+ 3: "rgb(158,169,169)", -+ }, -+ background: { -+ 1: "rgb(255,255,255)", -+ 2: "rgb(241,243,243)", -+ 3: "rgb(228,231,231)", -+ }, -+ overlay: "rgba(0,0,0,0.1)", -+ }, -+ dark: { -+ foreground: { -+ 1: "rgb(228,231,231)", -+ 2: "rgb(148,158,158)", -+ 3: "rgb(110,119,119)", -+ }, -+ background: { -+ 1: "rgb(20,20,20)", -+ 2: "rgb(39,42,42)", -+ 3: "rgb(59,64,64)", -+ }, -+ overlay: "rgba(255,255,255,0.1)", -+ }, -+ }[o]; -+ return { -+ "--wcm-color-fg-1": r.foreground[1], -+ "--wcm-color-fg-2": r.foreground[2], -+ "--wcm-color-fg-3": r.foreground[3], -+ "--wcm-color-bg-1": r.background[1], -+ "--wcm-color-bg-2": r.background[2], -+ "--wcm-color-bg-3": r.background[3], -+ "--wcm-color-overlay": r.overlay, -+ }; -+} -+function He() { -+ return { -+ "--wcm-accent-color": "#3396FF", -+ "--wcm-accent-fill-color": "#FFFFFF", -+ "--wcm-z-index": "89", -+ "--wcm-background-color": "#3396FF", -+ "--wcm-background-border-radius": "8px", -+ "--wcm-container-border-radius": "30px", -+ "--wcm-wallet-icon-border-radius": "15px", -+ "--wcm-wallet-icon-large-border-radius": "30px", -+ "--wcm-wallet-icon-small-border-radius": "7px", -+ "--wcm-input-border-radius": "28px", -+ "--wcm-button-border-radius": "10px", -+ "--wcm-notification-border-radius": "36px", -+ "--wcm-secondary-button-border-radius": "28px", -+ "--wcm-icon-button-border-radius": "50%", -+ "--wcm-button-hover-highlight-border-radius": "10px", -+ "--wcm-text-big-bold-size": "20px", -+ "--wcm-text-big-bold-weight": "600", -+ "--wcm-text-big-bold-line-height": "24px", -+ "--wcm-text-big-bold-letter-spacing": "-0.03em", -+ "--wcm-text-big-bold-text-transform": "none", -+ "--wcm-text-xsmall-bold-size": "10px", -+ "--wcm-text-xsmall-bold-weight": "700", -+ "--wcm-text-xsmall-bold-line-height": "12px", -+ "--wcm-text-xsmall-bold-letter-spacing": "0.02em", -+ "--wcm-text-xsmall-bold-text-transform": "uppercase", -+ "--wcm-text-xsmall-regular-size": "12px", -+ "--wcm-text-xsmall-regular-weight": "600", -+ "--wcm-text-xsmall-regular-line-height": "14px", -+ "--wcm-text-xsmall-regular-letter-spacing": "-0.03em", -+ "--wcm-text-xsmall-regular-text-transform": "none", -+ "--wcm-text-small-thin-size": "14px", -+ "--wcm-text-small-thin-weight": "500", -+ "--wcm-text-small-thin-line-height": "16px", -+ "--wcm-text-small-thin-letter-spacing": "-0.03em", -+ "--wcm-text-small-thin-text-transform": "none", -+ "--wcm-text-small-regular-size": "14px", -+ "--wcm-text-small-regular-weight": "600", -+ "--wcm-text-small-regular-line-height": "16px", -+ "--wcm-text-small-regular-letter-spacing": "-0.03em", -+ "--wcm-text-small-regular-text-transform": "none", -+ "--wcm-text-medium-regular-size": "16px", -+ "--wcm-text-medium-regular-weight": "600", -+ "--wcm-text-medium-regular-line-height": "20px", -+ "--wcm-text-medium-regular-letter-spacing": "-0.03em", -+ "--wcm-text-medium-regular-text-transform": "none", -+ "--wcm-font-family": -+ "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif", -+ "--wcm-font-feature-settings": "'tnum' on, 'lnum' on, 'case' on", -+ "--wcm-success-color": "rgb(38,181,98)", -+ "--wcm-error-color": "rgb(242, 90, 103)", -+ "--wcm-overlay-background-color": "rgba(0, 0, 0, 0.3)", -+ "--wcm-overlay-backdrop-filter": "none", -+ }; -+} -+const h = { -+ getPreset(e) { -+ return He()[e]; -+ }, -+ setTheme() { -+ const e = document.querySelector(":root"), -+ { themeVariables: o } = X.state; -+ if (e) { -+ const r = ve(ve(ve({}, rt()), He()), o); -+ Object.entries(r).forEach(([a, t]) => e.style.setProperty(a, t)); -+ } -+ }, -+ globalCss: g`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}`, -+ }, -+ at = g`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`; -+var lt = Object.defineProperty, -+ it = Object.getOwnPropertyDescriptor, -+ F = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? it(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && lt(o, r, t), t; -+ }; -+let T = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.disabled = !1), -+ (this.iconLeft = void 0), -+ (this.iconRight = void 0), -+ (this.onClick = () => null), -+ (this.variant = "default"); -+ } -+ render() { -+ const e = { -+ "wcm-icon-left": this.iconLeft !== void 0, -+ "wcm-icon-right": this.iconRight !== void 0, -+ "wcm-ghost": this.variant === "ghost", -+ "wcm-outline": this.variant === "outline", -+ }; -+ let o = "inverse"; -+ return ( -+ this.variant === "ghost" && (o = "secondary"), -+ this.variant === "outline" && (o = "accent"), -+ n`` -+ ); -+ } -+}; -+(T.styles = [h.globalCss, at]), -+ F([d({ type: Boolean })], T.prototype, "disabled", 2), -+ F([d()], T.prototype, "iconLeft", 2), -+ F([d()], T.prototype, "iconRight", 2), -+ F([d()], T.prototype, "onClick", 2), -+ F([d()], T.prototype, "variant", 2), -+ (T = F([p("wcm-button")], T)); -+const nt = g`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`; -+var ct = Object.defineProperty, -+ st = Object.getOwnPropertyDescriptor, -+ ue = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? st(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && ct(o, r, t), t; -+ }; -+let ee = class extends w { -+ constructor() { -+ super(...arguments), (this.disabled = !1), (this.variant = "primary"); -+ } -+ render() { -+ const e = { "wcm-secondary": this.variant === "secondary" }; -+ return n``; -+ } -+}; -+(ee.styles = [h.globalCss, nt]), -+ ue([d({ type: Boolean })], ee.prototype, "disabled", 2), -+ ue([d()], ee.prototype, "variant", 2), -+ (ee = ue([p("wcm-button-big")], ee)); -+const dt = g`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`; -+var mt = Object.defineProperty, -+ ht = Object.getOwnPropertyDescriptor, -+ wt = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? ht(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && mt(o, r, t), t; -+ }; -+let be = class extends w { -+ render() { -+ return n`
`; -+ } -+}; -+(be.styles = [h.globalCss, dt]), (be = wt([p("wcm-info-footer")], be)); -+const v = { -+ CROSS_ICON: C``, -+ WALLET_CONNECT_LOGO: C``, -+ WALLET_CONNECT_ICON: C``, -+ WALLET_CONNECT_ICON_COLORED: C``, -+ BACK_ICON: C``, -+ COPY_ICON: C``, -+ RETRY_ICON: C``, -+ DESKTOP_ICON: C``, -+ MOBILE_ICON: C``, -+ ARROW_DOWN_ICON: C``, -+ ARROW_UP_RIGHT_ICON: C``, -+ ARROW_RIGHT_ICON: C``, -+ QRCODE_ICON: C``, -+ SCAN_ICON: C``, -+ CHECKMARK_ICON: C``, -+ SEARCH_ICON: C``, -+ WALLET_PLACEHOLDER: C``, -+ GLOBE_ICON: C``, -+ }, -+ pt = g`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`; -+var gt = Object.defineProperty, -+ vt = Object.getOwnPropertyDescriptor, -+ ut = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? vt(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && gt(o, r, t), t; -+ }; -+let fe = class extends w { -+ render() { -+ return n`
${v.WALLET_CONNECT_LOGO}
`; -+ } -+}; -+(fe.styles = [h.globalCss, pt]), (fe = ut([p("wcm-modal-backcard")], fe)); -+const bt = g`main{padding:20px;padding-top:0;width:100%}`; -+var ft = Object.defineProperty, -+ xt = Object.getOwnPropertyDescriptor, -+ yt = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? xt(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && ft(o, r, t), t; -+ }; -+let xe = class extends w { -+ render() { -+ return n`
`; -+ } -+}; -+(xe.styles = [h.globalCss, bt]), (xe = yt([p("wcm-modal-content")], xe)); -+const $t = g`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`; -+var Ct = Object.defineProperty, -+ kt = Object.getOwnPropertyDescriptor, -+ Ot = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? kt(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Ct(o, r, t), t; -+ }; -+let ye = class extends w { -+ render() { -+ return n`
`; -+ } -+}; -+(ye.styles = [h.globalCss, $t]), (ye = Ot([p("wcm-modal-footer")], ye)); -+const Wt = g`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`; -+var It = Object.defineProperty, -+ Et = Object.getOwnPropertyDescriptor, -+ te = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Et(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && It(o, r, t), t; -+ }; -+let S = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.title = ""), -+ (this.onAction = void 0), -+ (this.actionIcon = void 0), -+ (this.border = !1); -+ } -+ backBtnTemplate() { -+ return n``; -+ } -+ actionBtnTemplate() { -+ return n``; -+ } -+ render() { -+ const e = { "wcm-border": this.border }, -+ o = x.state.history.length > 1, -+ r = this.title -+ ? n`${this.title}` -+ : n``; -+ return n`
${o ? this.backBtnTemplate() : null} ${r} ${this.onAction ? this.actionBtnTemplate() : null}
`; -+ } -+}; -+(S.styles = [h.globalCss, Wt]), -+ te([d()], S.prototype, "title", 2), -+ te([d()], S.prototype, "onAction", 2), -+ te([d()], S.prototype, "actionIcon", 2), -+ te([d({ type: Boolean })], S.prototype, "border", 2), -+ (S = te([p("wcm-modal-header")], S)); -+const c = { -+ MOBILE_BREAKPOINT: 600, -+ WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_DATA", -+ EXPLORER_WALLET_URL: "https://explorer.walletconnect.com/?type=wallet", -+ getShadowRootElement(e, o) { -+ const r = e.renderRoot.querySelector(o); -+ if (!r) throw new Error(`${o} not found`); -+ return r; -+ }, -+ getWalletIcon({ id: e, image_id: o }) { -+ const { walletImages: r } = z.state; -+ return r != null && r[e] ? r[e] : o ? W.getWalletImageUrl(o) : ""; -+ }, -+ getWalletName(e, o = !1) { -+ return o && e.length > 8 ? `${e.substring(0, 8)}..` : e; -+ }, -+ isMobileAnimation() { -+ return window.innerWidth <= c.MOBILE_BREAKPOINT; -+ }, -+ async preloadImage(e) { -+ const o = new Promise((r, a) => { -+ const t = new Image(); -+ (t.onload = r), -+ (t.onerror = a), -+ (t.crossOrigin = "anonymous"), -+ (t.src = e); -+ }); -+ return Promise.race([o, m.wait(3e3)]); -+ }, -+ getErrorMessage(e) { -+ return e instanceof Error ? e.message : "Unknown Error"; -+ }, -+ debounce(e, o = 500) { -+ let r; -+ return (...a) => { -+ function t() { -+ e(...a); -+ } -+ r && clearTimeout(r), (r = setTimeout(t, o)); -+ }; -+ }, -+ handleMobileLinking(e) { -+ const { walletConnectUri: o } = R.state, -+ { mobile: r, name: a } = e, -+ t = r?.native, -+ l = r?.universal; -+ c.setRecentWallet(e); -+ function i(s) { -+ let $ = ""; -+ t -+ ? ($ = m.formatUniversalUrl(t, s, a)) -+ : l && ($ = m.formatNativeUrl(l, s, a)), -+ m.openHref($, "_self"); -+ } -+ o && i(o); -+ }, -+ async handleUriCopy() { -+ const { walletConnectUri: e } = R.state; -+ if (e) -+ try { -+ await navigator.clipboard.writeText(e), -+ N.openToast("Link copied", "success"); -+ } catch { -+ N.openToast("Failed to copy", "error"); -+ } -+ }, -+ getCustomImageUrls() { -+ const { walletImages: e } = z.state, -+ o = Object.values(e ?? {}); -+ return Object.values(o); -+ }, -+ truncate(e, o = 8) { -+ return e.length <= o -+ ? e -+ : `${e.substring(0, 4)}...${e.substring(e.length - 4)}`; -+ }, -+ setRecentWallet(e) { -+ try { -+ localStorage.setItem(c.WCM_RECENT_WALLET_DATA, JSON.stringify(e)); -+ } catch { -+ console.info("Unable to set recent wallet"); -+ } -+ }, -+ getRecentWallet() { -+ try { -+ const e = localStorage.getItem(c.WCM_RECENT_WALLET_DATA); -+ return e ? JSON.parse(e) : void 0; -+ } catch { -+ console.info("Unable to get recent wallet"); -+ } -+ }, -+ caseSafeIncludes(e, o) { -+ return e.toUpperCase().includes(o.toUpperCase()); -+ }, -+ openWalletExplorerUrl() { -+ m.openHref(c.EXPLORER_WALLET_URL, "_blank"); -+ }, -+ getCachedRouterWalletPlatforms() { -+ const { desktop: e, mobile: o } = m.getWalletRouterData(), -+ r = Boolean(e?.native), -+ a = Boolean(e?.universal), -+ t = Boolean(o?.native) || Boolean(o?.universal); -+ return { isDesktop: r, isMobile: t, isWeb: a }; -+ }, -+ goToConnectingView(e) { -+ x.setData({ Wallet: e }); -+ const o = m.isMobile(), -+ { -+ isDesktop: r, -+ isWeb: a, -+ isMobile: t, -+ } = c.getCachedRouterWalletPlatforms(); -+ o -+ ? t -+ ? x.push("MobileConnecting") -+ : a -+ ? x.push("WebConnecting") -+ : x.push("InstallWallet") -+ : r -+ ? x.push("DesktopConnecting") -+ : a -+ ? x.push("WebConnecting") -+ : t -+ ? x.push("MobileQrcodeConnecting") -+ : x.push("InstallWallet"); -+ }, -+ }, -+ Mt = g`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`; -+var Lt = Object.defineProperty, -+ Rt = Object.getOwnPropertyDescriptor, -+ $e = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Rt(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Lt(o, r, t), t; -+ }; -+let oe = class extends w { -+ constructor() { -+ super(), -+ (this.view = x.state.view), -+ (this.prevView = x.state.view), -+ (this.unsubscribe = void 0), -+ (this.oldHeight = "0px"), -+ (this.resizeObserver = void 0), -+ (this.unsubscribe = x.subscribe((e) => { -+ this.view !== e.view && this.onChangeRoute(); -+ })); -+ } -+ firstUpdated() { -+ (this.resizeObserver = new ResizeObserver(([e]) => { -+ const o = `${e.contentRect.height}px`; -+ this.oldHeight !== "0px" && -+ H(this.routerEl, { height: [this.oldHeight, o] }, { duration: 0.2 }), -+ (this.oldHeight = o); -+ })), -+ this.resizeObserver.observe(this.contentEl); -+ } -+ disconnectedCallback() { -+ var e, o; -+ (e = this.unsubscribe) == null || e.call(this), -+ (o = this.resizeObserver) == null || o.disconnect(); -+ } -+ get routerEl() { -+ return c.getShadowRootElement(this, ".wcm-router"); -+ } -+ get contentEl() { -+ return c.getShadowRootElement(this, ".wcm-content"); -+ } -+ viewTemplate() { -+ switch (this.view) { -+ case "ConnectWallet": -+ return n``; -+ case "DesktopConnecting": -+ return n``; -+ case "MobileConnecting": -+ return n``; -+ case "WebConnecting": -+ return n``; -+ case "MobileQrcodeConnecting": -+ return n``; -+ case "WalletExplorer": -+ return n``; -+ case "Qrcode": -+ return n``; -+ case "InstallWallet": -+ return n``; -+ default: -+ return n`
Not Found
`; -+ } -+ } -+ async onChangeRoute() { -+ await H( -+ this.routerEl, -+ { opacity: [1, 0], scale: [1, 1.02] }, -+ { duration: 0.15, delay: 0.1 }, -+ ).finished, -+ (this.view = x.state.view), -+ H( -+ this.routerEl, -+ { opacity: [0, 1], scale: [0.99, 1] }, -+ { duration: 0.37, delay: 0.05 }, -+ ); -+ } -+ render() { -+ return n`
${this.viewTemplate()}
`; -+ } -+}; -+(oe.styles = [h.globalCss, Mt]), -+ $e([I()], oe.prototype, "view", 2), -+ $e([I()], oe.prototype, "prevView", 2), -+ (oe = $e([p("wcm-modal-router")], oe)); -+const At = g`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`; -+var Pt = Object.defineProperty, -+ Tt = Object.getOwnPropertyDescriptor, -+ ze = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Tt(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Pt(o, r, t), t; -+ }; -+let ne = class extends w { -+ constructor() { -+ super(), -+ (this.open = !1), -+ (this.unsubscribe = void 0), -+ (this.timeout = void 0), -+ (this.unsubscribe = N.subscribe((e) => { -+ e.open -+ ? ((this.open = !0), -+ (this.timeout = setTimeout(() => N.closeToast(), 2200))) -+ : ((this.open = !1), clearTimeout(this.timeout)); -+ })); -+ } -+ disconnectedCallback() { -+ var e; -+ (e = this.unsubscribe) == null || e.call(this), -+ clearTimeout(this.timeout), -+ N.closeToast(); -+ } -+ render() { -+ const { message: e, variant: o } = N.state, -+ r = { "wcm-success": o === "success", "wcm-error": o === "error" }; -+ return this.open -+ ? n`
${o === "success" ? v.CHECKMARK_ICON : null} ${o === "error" ? v.CROSS_ICON : null}${e}
` -+ : null; -+ } -+}; -+(ne.styles = [h.globalCss, At]), -+ ze([I()], ne.prototype, "open", 2), -+ (ne = ze([p("wcm-modal-toast")], ne)); -+const jt = 0.1, -+ Ve = 2.5, -+ A = 7; -+function Ce(e, o, r) { -+ return e === o ? !1 : (e - o < 0 ? o - e : e - o) <= r + jt; -+} -+function _t(e, o) { -+ const r = Array.prototype.slice.call( -+ Je.create(e, { errorCorrectionLevel: o }).modules.data, -+ 0, -+ ), -+ a = Math.sqrt(r.length); -+ return r.reduce( -+ (t, l, i) => (i % a === 0 ? t.push([l]) : t[t.length - 1].push(l)) && t, -+ [], -+ ); -+} -+const Dt = { -+ generate(e, o, r) { -+ const a = "#141414", -+ t = "#ffffff", -+ l = [], -+ i = _t(e, "Q"), -+ s = o / i.length, -+ $ = [ -+ { x: 0, y: 0 }, -+ { x: 1, y: 0 }, -+ { x: 0, y: 1 }, -+ ]; -+ $.forEach(({ x: y, y: u }) => { -+ const O = (i.length - A) * s * y, -+ b = (i.length - A) * s * u, -+ E = 0.45; -+ for (let M = 0; M < $.length; M += 1) { -+ const V = s * (A - M * 2); -+ l.push( -+ pe``, -+ ); -+ } -+ }); -+ const f = Math.floor((r + 25) / s), -+ Ne = i.length / 2 - f / 2, -+ Ze = i.length / 2 + f / 2 - 1, -+ Se = []; -+ i.forEach((y, u) => { -+ y.forEach((O, b) => { -+ if ( -+ i[u][b] && -+ !( -+ (u < A && b < A) || -+ (u > i.length - (A + 1) && b < A) || -+ (u < A && b > i.length - (A + 1)) -+ ) && -+ !(u > Ne && u < Ze && b > Ne && b < Ze) -+ ) { -+ const E = u * s + s / 2, -+ M = b * s + s / 2; -+ Se.push([E, M]); -+ } -+ }); -+ }); -+ const J = {}; -+ return ( -+ Se.forEach(([y, u]) => { -+ J[y] ? J[y].push(u) : (J[y] = [u]); -+ }), -+ Object.entries(J) -+ .map(([y, u]) => { -+ const O = u.filter((b) => u.every((E) => !Ce(b, E, s))); -+ return [Number(y), O]; -+ }) -+ .forEach(([y, u]) => { -+ u.forEach((O) => { -+ l.push( -+ pe``, -+ ); -+ }); -+ }), -+ Object.entries(J) -+ .filter(([y, u]) => u.length > 1) -+ .map(([y, u]) => { -+ const O = u.filter((b) => u.some((E) => Ce(b, E, s))); -+ return [Number(y), O]; -+ }) -+ .map(([y, u]) => { -+ u.sort((b, E) => (b < E ? -1 : 1)); -+ const O = []; -+ for (const b of u) { -+ const E = O.find((M) => M.some((V) => Ce(b, V, s))); -+ E ? E.push(b) : O.push([b]); -+ } -+ return [y, O.map((b) => [b[0], b[b.length - 1]])]; -+ }) -+ .forEach(([y, u]) => { -+ u.forEach(([O, b]) => { -+ l.push( -+ pe``, -+ ); -+ }); -+ }), -+ l -+ ); -+ }, -+ }, -+ Nt = g`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`; -+var Zt = Object.defineProperty, -+ St = Object.getOwnPropertyDescriptor, -+ q = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? St(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Zt(o, r, t), t; -+ }; -+let j = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.uri = ""), -+ (this.size = 0), -+ (this.imageId = void 0), -+ (this.walletId = void 0), -+ (this.imageUrl = void 0); -+ } -+ svgTemplate() { -+ const e = X.state.themeMode === "light" ? this.size : this.size - 36; -+ return pe`${Dt.generate(this.uri, e, e / 4)}`; -+ } -+ render() { -+ const e = { "wcm-dark": X.state.themeMode === "dark" }; -+ return n`
${this.walletId || this.imageUrl ? n`` : v.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`; -+ } -+}; -+(j.styles = [h.globalCss, Nt]), -+ q([d()], j.prototype, "uri", 2), -+ q([d({ type: Number })], j.prototype, "size", 2), -+ q([d()], j.prototype, "imageId", 2), -+ q([d()], j.prototype, "walletId", 2), -+ q([d()], j.prototype, "imageUrl", 2), -+ (j = q([p("wcm-qrcode")], j)); -+const Bt = g`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`; -+var Ut = Object.defineProperty, -+ Ht = Object.getOwnPropertyDescriptor, -+ Fe = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Ht(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Ut(o, r, t), t; -+ }; -+let ce = class extends w { -+ constructor() { -+ super(...arguments), (this.onChange = () => null); -+ } -+ render() { -+ return n` ${v.SEARCH_ICON}`; -+ } -+}; -+(ce.styles = [h.globalCss, Bt]), -+ Fe([d()], ce.prototype, "onChange", 2), -+ (ce = Fe([p("wcm-search-input")], ce)); -+const zt = g`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`; -+var Vt = Object.defineProperty, -+ Ft = Object.getOwnPropertyDescriptor, -+ qt = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Ft(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Vt(o, r, t), t; -+ }; -+let ke = class extends w { -+ render() { -+ return n``; -+ } -+}; -+(ke.styles = [h.globalCss, zt]), (ke = qt([p("wcm-spinner")], ke)); -+const Qt = g`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`; -+var Kt = Object.defineProperty, -+ Yt = Object.getOwnPropertyDescriptor, -+ Oe = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Yt(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Kt(o, r, t), t; -+ }; -+let re = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.variant = "medium-regular"), -+ (this.color = "primary"); -+ } -+ render() { -+ const e = { -+ "wcm-big-bold": this.variant === "big-bold", -+ "wcm-medium-regular": this.variant === "medium-regular", -+ "wcm-small-regular": this.variant === "small-regular", -+ "wcm-small-thin": this.variant === "small-thin", -+ "wcm-xsmall-regular": this.variant === "xsmall-regular", -+ "wcm-xsmall-bold": this.variant === "xsmall-bold", -+ "wcm-color-primary": this.color === "primary", -+ "wcm-color-secondary": this.color === "secondary", -+ "wcm-color-tertiary": this.color === "tertiary", -+ "wcm-color-inverse": this.color === "inverse", -+ "wcm-color-accnt": this.color === "accent", -+ "wcm-color-error": this.color === "error", -+ }; -+ return n``; -+ } -+}; -+(re.styles = [h.globalCss, Qt]), -+ Oe([d()], re.prototype, "variant", 2), -+ Oe([d()], re.prototype, "color", 2), -+ (re = Oe([p("wcm-text")], re)); -+const Gt = g`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`; -+var Xt = Object.defineProperty, -+ Jt = Object.getOwnPropertyDescriptor, -+ _ = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Jt(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Xt(o, r, t), t; -+ }; -+let L = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.onClick = () => null), -+ (this.name = ""), -+ (this.walletId = ""), -+ (this.label = void 0), -+ (this.imageId = void 0), -+ (this.installed = !1), -+ (this.recent = !1); -+ } -+ sublabelTemplate() { -+ return this.recent -+ ? n`RECENT` -+ : this.installed -+ ? n`INSTALLED` -+ : null; -+ } -+ handleClick() { -+ Xe.click({ name: "WALLET_BUTTON", walletId: this.walletId }), -+ this.onClick(); -+ } -+ render() { -+ var e; -+ return n``; -+ } -+}; -+(L.styles = [h.globalCss, Gt]), -+ _([d()], L.prototype, "onClick", 2), -+ _([d()], L.prototype, "name", 2), -+ _([d()], L.prototype, "walletId", 2), -+ _([d()], L.prototype, "label", 2), -+ _([d()], L.prototype, "imageId", 2), -+ _([d({ type: Boolean })], L.prototype, "installed", 2), -+ _([d({ type: Boolean })], L.prototype, "recent", 2), -+ (L = _([p("wcm-wallet-button")], L)); -+const eo = g`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -+var to = Object.defineProperty, -+ oo = Object.getOwnPropertyDescriptor, -+ se = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? oo(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && to(o, r, t), t; -+ }; -+let Q = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.walletId = ""), -+ (this.imageId = void 0), -+ (this.imageUrl = void 0); -+ } -+ render() { -+ var e; -+ const o = -+ (e = this.imageUrl) != null && e.length -+ ? this.imageUrl -+ : c.getWalletIcon({ id: this.walletId, image_id: this.imageId }); -+ return n`${o.length ? n`
${this.id}
` : v.WALLET_PLACEHOLDER}`; -+ } -+}; -+(Q.styles = [h.globalCss, eo]), -+ se([d()], Q.prototype, "walletId", 2), -+ se([d()], Q.prototype, "imageId", 2), -+ se([d()], Q.prototype, "imageUrl", 2), -+ (Q = se([p("wcm-wallet-image")], Q)); -+var ro = Object.defineProperty, -+ ao = Object.getOwnPropertyDescriptor, -+ qe = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? ao(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && ro(o, r, t), t; -+ }; -+let We = class extends w { -+ constructor() { -+ super(), (this.preload = !0), this.preloadData(); -+ } -+ async loadImages(e) { -+ try { -+ e != null && -+ e.length && -+ (await Promise.all(e.map(async (o) => c.preloadImage(o)))); -+ } catch { -+ console.info("Unsuccessful attempt at preloading some images", e); -+ } -+ } -+ async preloadListings() { -+ if (z.state.enableExplorer) { -+ await W.getRecomendedWallets(), R.setIsDataLoaded(!0); -+ const { recomendedWallets: e } = W.state, -+ o = e.map((r) => c.getWalletIcon(r)); -+ await this.loadImages(o); -+ } else R.setIsDataLoaded(!0); -+ } -+ async preloadCustomImages() { -+ const e = c.getCustomImageUrls(); -+ await this.loadImages(e); -+ } -+ async preloadData() { -+ try { -+ this.preload && -+ ((this.preload = !1), -+ await Promise.all([ -+ this.preloadListings(), -+ this.preloadCustomImages(), -+ ])); -+ } catch (e) { -+ console.error(e), N.openToast("Failed preloading", "error"); -+ } -+ } -+}; -+qe([I()], We.prototype, "preload", 2), -+ (We = qe([p("wcm-explorer-context")], We)); -+var lo = Object.defineProperty, -+ io = Object.getOwnPropertyDescriptor, -+ no = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? io(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && lo(o, r, t), t; -+ }; -+let Qe = class extends w { -+ constructor() { -+ super(), -+ (this.unsubscribeTheme = void 0), -+ h.setTheme(), -+ (this.unsubscribeTheme = X.subscribe(h.setTheme)); -+ } -+ disconnectedCallback() { -+ var e; -+ (e = this.unsubscribeTheme) == null || e.call(this); -+ } -+}; -+Qe = no([p("wcm-theme-context")], Qe); -+const co = g`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -+var so = Object.defineProperty, -+ mo = Object.getOwnPropertyDescriptor, -+ ho = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? mo(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && so(o, r, t), t; -+ }; -+let Ie = class extends w { -+ onConnect(e) { -+ m.isAndroid() ? c.handleMobileLinking(e) : c.goToConnectingView(e); -+ } -+ onGoToQrcode() { -+ x.push("Qrcode"); -+ } -+ render() { -+ const { recomendedWallets: e } = W.state, -+ o = [...e, ...e], -+ r = m.RECOMMENDED_WALLET_AMOUNT * 2; -+ return n`
${v.MOBILE_ICON}WalletConnect
${[ -+ ...Array(r), -+ ].map((a, t) => { -+ const l = o[t % o.length]; -+ return l -+ ? n`` -+ : v.WALLET_PLACEHOLDER; -+ })}
Select Wallet
Choose WalletConnect to see supported apps on your device`; -+ } -+}; -+(Ie.styles = [h.globalCss, co]), -+ (Ie = ho([p("wcm-android-wallet-selection")], Ie)); -+const wo = g`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`; -+var po = Object.defineProperty, -+ go = Object.getOwnPropertyDescriptor, -+ K = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? go(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && po(o, r, t), t; -+ }; -+let D = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.walletId = void 0), -+ (this.imageId = void 0), -+ (this.isError = !1), -+ (this.isStale = !1), -+ (this.label = ""); -+ } -+ svgLoaderTemplate() { -+ var e, o; -+ const r = -+ (o = -+ (e = X.state.themeVariables) == null -+ ? void 0 -+ : e["--wcm-wallet-icon-large-border-radius"]) != null -+ ? o -+ : h.getPreset("--wcm-wallet-icon-large-border-radius"); -+ let a = 0; -+ r.includes("%") -+ ? (a = (88 / 100) * parseInt(r, 10)) -+ : (a = parseInt(r, 10)), -+ (a *= 1.17); -+ const t = 317 - a * 1.57, -+ l = 425 - a * 1.8; -+ return n``; -+ } -+ render() { -+ const e = { "wcm-error": this.isError, "wcm-stale": this.isStale }; -+ return n`
${this.svgLoaderTemplate()}
${this.isError ? "Connection declined" : this.label}`; -+ } -+}; -+(D.styles = [h.globalCss, wo]), -+ K([d()], D.prototype, "walletId", 2), -+ K([d()], D.prototype, "imageId", 2), -+ K([d({ type: Boolean })], D.prototype, "isError", 2), -+ K([d({ type: Boolean })], D.prototype, "isStale", 2), -+ K([d()], D.prototype, "label", 2), -+ (D = K([p("wcm-connector-waiting")], D)); -+const G = { -+ manualWallets() { -+ var e, o; -+ const { mobileWallets: r, desktopWallets: a } = z.state, -+ t = (e = G.recentWallet()) == null ? void 0 : e.id, -+ l = m.isMobile() ? r : a, -+ i = l?.filter((s) => t !== s.id); -+ return (o = m.isMobile() -+ ? i?.map(({ id: s, name: $, links: f }) => ({ -+ id: s, -+ name: $, -+ mobile: f, -+ links: f, -+ })) -+ : i?.map(({ id: s, name: $, links: f }) => ({ -+ id: s, -+ name: $, -+ desktop: f, -+ links: f, -+ }))) != null -+ ? o -+ : []; -+ }, -+ recentWallet() { -+ return c.getRecentWallet(); -+ }, -+ recomendedWallets(e = !1) { -+ var o; -+ const r = e || (o = G.recentWallet()) == null ? void 0 : o.id, -+ { recomendedWallets: a } = W.state; -+ return a.filter((t) => r !== t.id); -+ }, -+ }, -+ Z = { -+ onConnecting(e) { -+ c.goToConnectingView(e); -+ }, -+ manualWalletsTemplate() { -+ return G.manualWallets().map( -+ (e) => -+ n``, -+ ); -+ }, -+ recomendedWalletsTemplate(e = !1) { -+ return G.recomendedWallets(e).map( -+ (o) => -+ n``, -+ ); -+ }, -+ recentWalletTemplate() { -+ const e = G.recentWallet(); -+ if (e) -+ return n``; -+ }, -+ }, -+ vo = g`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`; -+var uo = Object.defineProperty, -+ bo = Object.getOwnPropertyDescriptor, -+ fo = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? bo(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && uo(o, r, t), t; -+ }; -+let Ee = class extends w { -+ render() { -+ const { explorerExcludedWalletIds: e, enableExplorer: o } = z.state, -+ r = e !== "ALL" && o, -+ a = Z.manualWalletsTemplate(), -+ t = Z.recomendedWalletsTemplate(); -+ let l = [Z.recentWalletTemplate(), ...a, ...t]; -+ l = l.filter(Boolean); -+ const i = l.length > 4 || r; -+ let s = []; -+ i ? (s = l.slice(0, 3)) : (s = l); -+ const $ = Boolean(s.length); -+ return n`
${v.MOBILE_ICON}Mobile
${v.SCAN_ICON}Scan with your wallet
${$ ? n`
${v.DESKTOP_ICON}Desktop
${s} ${i ? n`` : null}
` : null}`; -+ } -+}; -+(Ee.styles = [h.globalCss, vo]), -+ (Ee = fo([p("wcm-desktop-wallet-selection")], Ee)); -+const xo = g`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`; -+var yo = Object.defineProperty, -+ $o = Object.getOwnPropertyDescriptor, -+ Co = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? $o(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && yo(o, r, t), t; -+ }; -+let Me = class extends w { -+ render() { -+ const { termsOfServiceUrl: e, privacyPolicyUrl: o } = z.state; -+ return e ?? o -+ ? n`
By connecting your wallet to this app, you agree to the app's ${e ? n`Terms of Service` : null} ${e && o ? "and" : null} ${o ? n`Privacy Policy` : null}
` -+ : null; -+ } -+}; -+(Me.styles = [h.globalCss, xo]), (Me = Co([p("wcm-legal-notice")], Me)); -+const ko = g`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`; -+var Oo = Object.defineProperty, -+ Wo = Object.getOwnPropertyDescriptor, -+ Io = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Wo(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Oo(o, r, t), t; -+ }; -+let Le = class extends w { -+ onQrcode() { -+ x.push("Qrcode"); -+ } -+ render() { -+ const { explorerExcludedWalletIds: e, enableExplorer: o } = z.state, -+ r = e !== "ALL" && o, -+ a = Z.manualWalletsTemplate(), -+ t = Z.recomendedWalletsTemplate(); -+ let l = [Z.recentWalletTemplate(), ...a, ...t]; -+ l = l.filter(Boolean); -+ const i = l.length > 8 || r; -+ let s = []; -+ i ? (s = l.slice(0, 7)) : (s = l); -+ const $ = Boolean(s.length); -+ return n`${$ ? n`
${s} ${i ? n`` : null}
` : null}`; -+ } -+}; -+(Le.styles = [h.globalCss, ko]), -+ (Le = Io([p("wcm-mobile-wallet-selection")], Le)); -+const Eo = g`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`; -+var Mo = Object.defineProperty, -+ Lo = Object.getOwnPropertyDescriptor, -+ Re = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Lo(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Mo(o, r, t), t; -+ }; -+let ae = class extends w { -+ constructor() { -+ super(), -+ (this.open = !1), -+ (this.active = !1), -+ (this.unsubscribeModal = void 0), -+ (this.abortController = void 0), -+ (this.unsubscribeModal = ge.subscribe((e) => { -+ e.open ? this.onOpenModalEvent() : this.onCloseModalEvent(); -+ })); -+ } -+ disconnectedCallback() { -+ var e; -+ (e = this.unsubscribeModal) == null || e.call(this); -+ } -+ get overlayEl() { -+ return c.getShadowRootElement(this, ".wcm-overlay"); -+ } -+ get containerEl() { -+ return c.getShadowRootElement(this, ".wcm-container"); -+ } -+ toggleBodyScroll(e) { -+ if (document.querySelector("body")) -+ if (e) { -+ const o = document.getElementById("wcm-styles"); -+ o?.remove(); -+ } else -+ document.head.insertAdjacentHTML( -+ "beforeend", -+ '', -+ ); -+ } -+ onCloseModal(e) { -+ e.target === e.currentTarget && ge.close(); -+ } -+ onOpenModalEvent() { -+ this.toggleBodyScroll(!1), -+ this.addKeyboardEvents(), -+ (this.open = !0), -+ setTimeout(async () => { -+ const e = c.isMobileAnimation() -+ ? { y: ["50vh", "0vh"] } -+ : { scale: [0.98, 1] }, -+ o = 0.1, -+ r = 0.2; -+ await Promise.all([ -+ H(this.overlayEl, { opacity: [0, 1] }, { delay: o, duration: r }) -+ .finished, -+ H(this.containerEl, e, { delay: o, duration: r }).finished, -+ ]), -+ (this.active = !0); -+ }, 0); -+ } -+ async onCloseModalEvent() { -+ this.toggleBodyScroll(!0), this.removeKeyboardEvents(); -+ const e = c.isMobileAnimation() -+ ? { y: ["0vh", "50vh"] } -+ : { scale: [1, 0.98] }, -+ o = 0.2; -+ await Promise.all([ -+ H(this.overlayEl, { opacity: [1, 0] }, { duration: o }).finished, -+ H(this.containerEl, e, { duration: o }).finished, -+ ]), -+ this.containerEl.removeAttribute("style"), -+ (this.active = !1), -+ (this.open = !1); -+ } -+ addKeyboardEvents() { -+ (this.abortController = new AbortController()), -+ window.addEventListener( -+ "keydown", -+ (e) => { -+ var o; -+ e.key === "Escape" -+ ? ge.close() -+ : e.key === "Tab" && -+ (((o = e.target) != null && o.tagName.includes("wcm-")) || -+ this.containerEl.focus()); -+ }, -+ this.abortController, -+ ), -+ this.containerEl.focus(); -+ } -+ removeKeyboardEvents() { -+ var e; -+ (e = this.abortController) == null || e.abort(), -+ (this.abortController = void 0); -+ } -+ render() { -+ const e = { "wcm-overlay": !0, "wcm-active": this.active }; -+ return n`
${this.open ? n`
` : null}
`; -+ } -+}; -+(ae.styles = [h.globalCss, Eo]), -+ Re([I()], ae.prototype, "open", 2), -+ Re([I()], ae.prototype, "active", 2), -+ (ae = Re([p("wcm-modal")], ae)); -+const Ro = g`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`; -+var Ao = Object.defineProperty, -+ Po = Object.getOwnPropertyDescriptor, -+ le = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Po(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Ao(o, r, t), t; -+ }; -+let B = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.isMobile = !1), -+ (this.isDesktop = !1), -+ (this.isWeb = !1), -+ (this.isRetry = !1); -+ } -+ onMobile() { -+ m.isMobile() -+ ? x.replace("MobileConnecting") -+ : x.replace("MobileQrcodeConnecting"); -+ } -+ onDesktop() { -+ x.replace("DesktopConnecting"); -+ } -+ onWeb() { -+ x.replace("WebConnecting"); -+ } -+ render() { -+ return n`
${this.isRetry ? n`` : null} ${this.isMobile ? n`Mobile` : null} ${this.isDesktop ? n`Desktop` : null} ${this.isWeb ? n`Web` : null}
`; -+ } -+}; -+(B.styles = [h.globalCss, Ro]), -+ le([d({ type: Boolean })], B.prototype, "isMobile", 2), -+ le([d({ type: Boolean })], B.prototype, "isDesktop", 2), -+ le([d({ type: Boolean })], B.prototype, "isWeb", 2), -+ le([d({ type: Boolean })], B.prototype, "isRetry", 2), -+ (B = le([p("wcm-platform-selection")], B)); -+const To = g`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`; -+var jo = Object.defineProperty, -+ _o = Object.getOwnPropertyDescriptor, -+ Do = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? _o(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && jo(o, r, t), t; -+ }; -+let Ae = class extends w { -+ onClick() { -+ x.push("WalletExplorer"); -+ } -+ render() { -+ const { recomendedWallets: e } = W.state, -+ o = G.manualWallets(), -+ r = [...e, ...o].reverse().slice(0, 4); -+ return n``; -+ } -+}; -+(Ae.styles = [h.globalCss, To]), -+ (Ae = Do([p("wcm-view-all-wallets-button")], Ae)); -+const No = g`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`; -+var Zo = Object.defineProperty, -+ So = Object.getOwnPropertyDescriptor, -+ de = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? So(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Zo(o, r, t), t; -+ }; -+let Y = class extends w { -+ constructor() { -+ super(), -+ (this.walletId = ""), -+ (this.imageId = ""), -+ (this.uri = ""), -+ setTimeout(() => { -+ const { walletConnectUri: e } = R.state; -+ this.uri = e; -+ }, 0); -+ } -+ get overlayEl() { -+ return c.getShadowRootElement(this, ".wcm-qr-container"); -+ } -+ render() { -+ return n`
${this.uri ? n`` : n``}
`; -+ } -+}; -+(Y.styles = [h.globalCss, No]), -+ de([d()], Y.prototype, "walletId", 2), -+ de([d()], Y.prototype, "imageId", 2), -+ de([I()], Y.prototype, "uri", 2), -+ (Y = de([p("wcm-walletconnect-qr")], Y)); -+var Bo = Object.defineProperty, -+ Uo = Object.getOwnPropertyDescriptor, -+ Ho = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Uo(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Bo(o, r, t), t; -+ }; -+let Pe = class extends w { -+ viewTemplate() { -+ return m.isAndroid() -+ ? n`` -+ : m.isMobile() -+ ? n`` -+ : n``; -+ } -+ render() { -+ return n`${this.viewTemplate()}`; -+ } -+}; -+(Pe.styles = [h.globalCss]), (Pe = Ho([p("wcm-connect-wallet-view")], Pe)); -+const zo = g`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -+var Vo = Object.defineProperty, -+ Fo = Object.getOwnPropertyDescriptor, -+ Ke = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Fo(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Vo(o, r, t), t; -+ }; -+let me = class extends w { -+ constructor() { -+ super(), (this.isError = !1), this.openDesktopApp(); -+ } -+ onFormatAndRedirect(e) { -+ const { desktop: o, name: r } = m.getWalletRouterData(), -+ a = o?.native; -+ if (a) { -+ const t = m.formatNativeUrl(a, e, r); -+ m.openHref(t, "_self"); -+ } -+ } -+ openDesktopApp() { -+ const { walletConnectUri: e } = R.state, -+ o = m.getWalletRouterData(); -+ c.setRecentWallet(o), e && this.onFormatAndRedirect(e); -+ } -+ render() { -+ const { name: e, id: o, image_id: r } = m.getWalletRouterData(), -+ { isMobile: a, isWeb: t } = c.getCachedRouterWalletPlatforms(); -+ return n`${`Connection can continue loading if ${e} is not installed on your device`}Retry`; -+ } -+}; -+(me.styles = [h.globalCss, zo]), -+ Ke([I()], me.prototype, "isError", 2), -+ (me = Ke([p("wcm-desktop-connecting-view")], me)); -+const qo = g`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`; -+var Qo = Object.defineProperty, -+ Ko = Object.getOwnPropertyDescriptor, -+ Yo = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Ko(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Qo(o, r, t), t; -+ }; -+let Te = class extends w { -+ onInstall(e) { -+ e && m.openHref(e, "_blank"); -+ } -+ render() { -+ const { -+ name: e, -+ id: o, -+ image_id: r, -+ homepage: a, -+ } = m.getWalletRouterData(); -+ return n`${`Download ${e} to continue. If multiple browser extensions are installed, disable non ${e} ones and try again`}Download`; -+ } -+}; -+(Te.styles = [h.globalCss, qo]), (Te = Yo([p("wcm-install-wallet-view")], Te)); -+const Go = g`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`; -+var Xo = Object.defineProperty, -+ Jo = Object.getOwnPropertyDescriptor, -+ Ye = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? Jo(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && Xo(o, r, t), t; -+ }; -+let he = class extends w { -+ constructor() { -+ super(), (this.isError = !1), this.openMobileApp(); -+ } -+ onFormatAndRedirect(e, o = !1) { -+ const { mobile: r, name: a } = m.getWalletRouterData(), -+ t = r?.native, -+ l = r?.universal; -+ if (t && !o) { -+ const i = m.formatNativeUrl(t, e, a); -+ m.openHref(i, "_self"); -+ } else if (l) { -+ const i = m.formatUniversalUrl(l, e, a); -+ m.openHref(i, "_self"); -+ } -+ } -+ openMobileApp(e = !1) { -+ const { walletConnectUri: o } = R.state, -+ r = m.getWalletRouterData(); -+ c.setRecentWallet(r), o && this.onFormatAndRedirect(o, e); -+ } -+ onGoToAppStore(e) { -+ e && m.openHref(e, "_blank"); -+ } -+ render() { -+ const { -+ name: e, -+ id: o, -+ image_id: r, -+ app: a, -+ mobile: t, -+ } = m.getWalletRouterData(), -+ { isWeb: l } = c.getCachedRouterWalletPlatforms(), -+ i = a?.ios, -+ s = t?.universal; -+ return n`Retry${s ? n`Still doesn't work? Try this alternate link` : null}
${`Get ${e}`}
App Store
`; -+ } -+}; -+(he.styles = [h.globalCss, Go]), -+ Ye([I()], he.prototype, "isError", 2), -+ (he = Ye([p("wcm-mobile-connecting-view")], he)); -+const er = g`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -+var tr = Object.defineProperty, -+ or = Object.getOwnPropertyDescriptor, -+ rr = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? or(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && tr(o, r, t), t; -+ }; -+let je = class extends w { -+ render() { -+ const { name: e, id: o, image_id: r } = m.getWalletRouterData(), -+ { isDesktop: a, isWeb: t } = c.getCachedRouterWalletPlatforms(); -+ return n`${`Scan this QR Code with your phone's camera or inside ${e} app`}`; -+ } -+}; -+(je.styles = [h.globalCss, er]), -+ (je = rr([p("wcm-mobile-qr-connecting-view")], je)); -+var ar = Object.defineProperty, -+ lr = Object.getOwnPropertyDescriptor, -+ ir = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? lr(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && ar(o, r, t), t; -+ }; -+let _e = class extends w { -+ render() { -+ return n``; -+ } -+}; -+(_e.styles = [h.globalCss]), (_e = ir([p("wcm-qrcode-view")], _e)); -+const nr = g`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`; -+var cr = Object.defineProperty, -+ sr = Object.getOwnPropertyDescriptor, -+ ie = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? sr(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && cr(o, r, t), t; -+ }; -+const De = 40; -+let U = class extends w { -+ constructor() { -+ super(...arguments), -+ (this.loading = !W.state.wallets.listings.length), -+ (this.firstFetch = !W.state.wallets.listings.length), -+ (this.search = ""), -+ (this.endReached = !1), -+ (this.intersectionObserver = void 0), -+ (this.searchDebounce = c.debounce((e) => { -+ e.length >= 1 -+ ? ((this.firstFetch = !0), -+ (this.endReached = !1), -+ (this.search = e), -+ W.resetSearch(), -+ this.fetchWallets()) -+ : this.search && -+ ((this.search = ""), -+ (this.endReached = this.isLastPage()), -+ W.resetSearch()); -+ })); -+ } -+ firstUpdated() { -+ this.createPaginationObserver(); -+ } -+ disconnectedCallback() { -+ var e; -+ (e = this.intersectionObserver) == null || e.disconnect(); -+ } -+ get placeholderEl() { -+ return c.getShadowRootElement(this, ".wcm-placeholder-block"); -+ } -+ createPaginationObserver() { -+ (this.intersectionObserver = new IntersectionObserver(([e]) => { -+ e.isIntersecting && -+ !(this.search && this.firstFetch) && -+ this.fetchWallets(); -+ })), -+ this.intersectionObserver.observe(this.placeholderEl); -+ } -+ isLastPage() { -+ const { wallets: e, search: o } = W.state, -+ { listings: r, total: a } = this.search ? o : e; -+ return a <= De || r.length >= a; -+ } -+ async fetchWallets() { -+ var e; -+ const { wallets: o, search: r } = W.state, -+ { listings: a, total: t, page: l } = this.search ? r : o; -+ if (!this.endReached && (this.firstFetch || (t > De && a.length < t))) -+ try { -+ this.loading = !0; -+ const i = (e = R.state.chains) == null ? void 0 : e.join(","), -+ { listings: s } = await W.getWallets({ -+ page: this.firstFetch ? 1 : l + 1, -+ entries: De, -+ search: this.search, -+ version: 2, -+ chains: i, -+ }), -+ $ = s.map((f) => c.getWalletIcon(f)); -+ await Promise.all([ -+ ...$.map(async (f) => c.preloadImage(f)), -+ m.wait(300), -+ ]), -+ (this.endReached = this.isLastPage()); -+ } catch (i) { -+ console.error(i), N.openToast(c.getErrorMessage(i), "error"); -+ } finally { -+ (this.loading = !1), (this.firstFetch = !1); -+ } -+ } -+ onConnect(e) { -+ m.isAndroid() ? c.handleMobileLinking(e) : c.goToConnectingView(e); -+ } -+ onSearchChange(e) { -+ const { value: o } = e.target; -+ this.searchDebounce(o); -+ } -+ render() { -+ const { wallets: e, search: o } = W.state, -+ { listings: r } = this.search ? o : e, -+ a = this.loading && !r.length, -+ t = this.search.length >= 3; -+ let l = Z.manualWalletsTemplate(), -+ i = Z.recomendedWalletsTemplate(!0); -+ t && -+ ((l = l.filter(({ values: f }) => c.caseSafeIncludes(f[0], this.search))), -+ (i = i.filter(({ values: f }) => c.caseSafeIncludes(f[0], this.search)))); -+ const s = !this.loading && !r.length && !i.length, -+ $ = { -+ "wcm-loading": a, -+ "wcm-end-reached": this.endReached || !this.loading, -+ "wcm-empty": s, -+ }; -+ return n`
${a ? null : l} ${a ? null : i} ${a ? null : r.map((f) => n`${f ? n`` : null}`)}
${s ? n`No results found` : null} ${!s && this.loading ? n`` : null}
`; -+ } -+}; -+(U.styles = [h.globalCss, nr]), -+ ie([I()], U.prototype, "loading", 2), -+ ie([I()], U.prototype, "firstFetch", 2), -+ ie([I()], U.prototype, "search", 2), -+ ie([I()], U.prototype, "endReached", 2), -+ (U = ie([p("wcm-wallet-explorer-view")], U)); -+const dr = g`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`; -+var mr = Object.defineProperty, -+ hr = Object.getOwnPropertyDescriptor, -+ Ge = (e, o, r, a) => { -+ for ( -+ var t = a > 1 ? void 0 : a ? hr(o, r) : o, l = e.length - 1, i; -+ l >= 0; -+ l-- -+ ) -+ (i = e[l]) && (t = (a ? i(o, r, t) : i(t)) || t); -+ return a && t && mr(o, r, t), t; -+ }; -+let we = class extends w { -+ constructor() { -+ super(), (this.isError = !1), this.openWebWallet(); -+ } -+ onFormatAndRedirect(e) { -+ const { desktop: o, name: r } = m.getWalletRouterData(), -+ a = o?.universal; -+ if (a) { -+ const t = m.formatUniversalUrl(a, e, r); -+ if (r === 'Puzzle Wallet' && window && window.aleo?.puzzleWalletClient) { -+ const url = new URL(t); -+ const params = url.searchParams -+ const wcUri = params.get('uri'); -+ const requestId = params.get('requestId'); -+ const sessionTopic = params.get('sessionTopic'); -+ void window.aleo.connectPuzzle({ -+ wc: { -+ uri: wcUri, -+ requestId: requestId ?? undefined, -+ sessionTopic: sessionTopic ?? undefined, -+ }, -+ }) -+ } else { -+ m.openHref(t, "_blank"); -+ } -+ } -+ } -+ openWebWallet() { -+ const { walletConnectUri: e } = R.state, -+ o = m.getWalletRouterData(); -+ c.setRecentWallet(o), e && this.onFormatAndRedirect(e); -+ } -+ render() { -+ const { name: e, id: o, image_id: r } = m.getWalletRouterData(), -+ { isMobile: a, isDesktop: t } = c.getCachedRouterWalletPlatforms(), -+ l = m.isMobile(); -+ return n`${`${e} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`; -+ } -+}; -+(we.styles = [h.globalCss, dr]), -+ Ge([I()], we.prototype, "isError", 2), -+ (we = Ge([p("wcm-web-connecting-view")], we)); -+export { ae as WcmModal, j as WcmQrCode }; - //# sourceMappingURL=index.js.map diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f99c3e9c..3e3383cc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,25 +4,19 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -overrides: - '@walletconnect/core': ^2.11.2 - '@walletconnect/sign-client': ^2.11.2 - -patchedDependencies: - '@walletconnect/modal-core@2.6.2': - hash: p5neo4brmh5osp6hvq2kavfkgq - path: patches/@walletconnect__modal-core@2.6.2.patch - '@walletconnect/modal-ui@2.6.2': - hash: niac4rovmnthpoxeu5wh4alxci - path: patches/@walletconnect__modal-ui@2.6.2.patch - importers: .: dependencies: + '@changesets/cli': + specifier: ^2.27.1 + version: 2.27.1 '@puzzlehq/types': - specifier: 1.0.11 - version: 1.0.11 + specifier: 1.0.21 + version: 1.0.21 + '@puzzlehq/walletconnect-modal-sign-html': + specifier: ^0.0.6 + version: 0.0.6(@types/react@18.3.1)(react@18.3.1) buffer: specifier: ^6.0.3 version: 6.0.3 @@ -35,7 +29,7 @@ importers: version: 4.1.12 '@types/node': specifier: ^18.11.18 - version: 18.19.18 + version: 18.19.33 prettier: specifier: ^3.2.5 version: 3.2.5 @@ -47,22 +41,22 @@ importers: version: 4.9.5 vite: specifier: ^5.0.10 - version: 5.1.4(@types/node@18.19.18) + version: 5.2.11(@types/node@18.19.33) packages/core: dependencies: '@puzzlehq/types': - specifier: 1.0.11 - version: 1.0.11 - '@walletconnect/modal-sign-html': - specifier: ^2.6.2 - version: 2.6.2(@types/react@18.2.58)(react@18.2.0) + specifier: 1.0.21 + version: 1.0.21 + '@puzzlehq/walletconnect-modal-sign-html': + specifier: ^0.0.6 + version: 0.0.6(@types/react@18.3.1)(react@18.3.1) '@walletconnect/types': specifier: ^2.11.2 - version: 2.11.2 + version: 2.13.0 '@walletconnect/utils': specifier: ^2.11.2 - version: 2.11.2 + version: 2.13.0 buffer: specifier: ^6.0.3 version: 6.0.3 @@ -74,7 +68,7 @@ importers: version: 3.3.0 ws: specifier: ^8.16.0 - version: 8.16.0 + version: 8.17.0 packages/react: dependencies: @@ -82,23 +76,23 @@ importers: specifier: ../core version: link:../core '@puzzlehq/types': - specifier: 1.0.11 - version: 1.0.11 + specifier: 1.0.21 + version: 1.0.21 + '@puzzlehq/walletconnect-modal-sign-html': + specifier: ^0.0.6 + version: 0.0.6(@types/react@18.3.1)(react@18.3.1) '@tanstack/react-query': specifier: ^4.29.5 - version: 4.36.1(react-dom@18.2.0)(react@18.2.0) + version: 4.36.1(react-dom@18.3.1)(react@18.3.1) '@trpc/server': specifier: ^10.31.0 - version: 10.45.1 - '@walletconnect/modal-sign-html': - specifier: ^2.6.2 - version: 2.6.2(@types/react@18.2.58)(react@18.2.0) + version: 10.45.2 '@walletconnect/types': specifier: ^2.11.2 - version: 2.11.2 + version: 2.13.0 '@walletconnect/utils': specifier: ^2.11.2 - version: 2.11.2 + version: 2.13.0 debug: specifier: ^4.3.4 version: 4.3.4 @@ -110,31 +104,244 @@ importers: version: 9.0.21 react: specifier: ^18.2.0 - version: 18.2.0 + version: 18.3.1 use-debounce: specifier: ^10.0.0 - version: 10.0.0(react@18.2.0) + version: 10.0.0(react@18.3.1) ws: specifier: ^8.16.0 - version: 8.16.0 + version: 8.17.0 zustand: specifier: ^4.3.9 - version: 4.5.1(@types/react@18.2.58)(immer@9.0.21)(react@18.2.0) + version: 4.5.2(@types/react@18.3.1)(immer@9.0.21)(react@18.3.1) devDependencies: '@tanstack/react-query-devtools': specifier: ^4.29.5 - version: 4.36.1(@tanstack/react-query@4.36.1)(react-dom@18.2.0)(react@18.2.0) + version: 4.36.1(@tanstack/react-query@4.36.1)(react-dom@18.3.1)(react@18.3.1) '@types/react': specifier: ^18.2.0 - version: 18.2.58 + version: 18.3.1 '@types/react-dom': specifier: ^18.2.0 - version: 18.2.19 + version: 18.3.0 packages: - /@esbuild/aix-ppc64@0.19.12: - resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==} + /@babel/code-frame@7.24.2: + resolution: {integrity: sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/highlight': 7.24.5 + picocolors: 1.0.0 + dev: false + + /@babel/helper-validator-identifier@7.24.5: + resolution: {integrity: sha512-3q93SSKX2TWCG30M2G2kwaKeTYgEUp5Snjuj8qm729SObL6nbtUldAi37qbxkD5gg3xnBio+f9nqpSepGZMvxA==} + engines: {node: '>=6.9.0'} + dev: false + + /@babel/highlight@7.24.5: + resolution: {integrity: sha512-8lLmua6AVh/8SLJRRVD6V8p73Hir9w5mJrhE+IPpILG31KKlI9iz5zmBYKcWPS59qSfgP9RaSBQSHHE81WKuEw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.24.5 + chalk: 2.4.2 + js-tokens: 4.0.0 + picocolors: 1.0.0 + dev: false + + /@babel/runtime@7.24.5: + resolution: {integrity: sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==} + engines: {node: '>=6.9.0'} + dependencies: + regenerator-runtime: 0.14.1 + dev: false + + /@changesets/apply-release-plan@7.0.0: + resolution: {integrity: sha512-vfi69JR416qC9hWmFGSxj7N6wA5J222XNBmezSVATPWDVPIF7gkd4d8CpbEbXmRWbVrkoli3oerGS6dcL/BGsQ==} + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/config': 3.0.0 + '@changesets/get-version-range-type': 0.4.0 + '@changesets/git': 3.0.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + detect-indent: 6.1.0 + fs-extra: 7.0.1 + lodash.startcase: 4.4.0 + outdent: 0.5.0 + prettier: 2.8.8 + resolve-from: 5.0.0 + semver: 7.6.2 + dev: false + + /@changesets/assemble-release-plan@6.0.0: + resolution: {integrity: sha512-4QG7NuisAjisbW4hkLCmGW2lRYdPrKzro+fCtZaILX+3zdUELSvYjpL4GTv0E4aM9Mef3PuIQp89VmHJ4y2bfw==} + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.0.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + semver: 7.6.2 + dev: false + + /@changesets/changelog-git@0.2.0: + resolution: {integrity: sha512-bHOx97iFI4OClIT35Lok3sJAwM31VbUM++gnMBV16fdbtBhgYu4dxsphBF/0AZZsyAHMrnM0yFcj5gZM1py6uQ==} + dependencies: + '@changesets/types': 6.0.0 + dev: false + + /@changesets/cli@2.27.1: + resolution: {integrity: sha512-iJ91xlvRnnrJnELTp4eJJEOPjgpF3NOh4qeQehM6Ugiz9gJPRZ2t+TsXun6E3AMN4hScZKjqVXl0TX+C7AB3ZQ==} + hasBin: true + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/apply-release-plan': 7.0.0 + '@changesets/assemble-release-plan': 6.0.0 + '@changesets/changelog-git': 0.2.0 + '@changesets/config': 3.0.0 + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.0.0 + '@changesets/get-release-plan': 4.0.0 + '@changesets/git': 3.0.0 + '@changesets/logger': 0.1.0 + '@changesets/pre': 2.0.0 + '@changesets/read': 0.6.0 + '@changesets/types': 6.0.0 + '@changesets/write': 0.3.0 + '@manypkg/get-packages': 1.1.3 + '@types/semver': 7.5.8 + ansi-colors: 4.1.3 + chalk: 2.4.2 + ci-info: 3.9.0 + enquirer: 2.4.1 + external-editor: 3.1.0 + fs-extra: 7.0.1 + human-id: 1.0.2 + meow: 6.1.1 + outdent: 0.5.0 + p-limit: 2.3.0 + preferred-pm: 3.1.3 + resolve-from: 5.0.0 + semver: 7.6.2 + spawndamnit: 2.0.0 + term-size: 2.2.1 + tty-table: 4.2.3 + dev: false + + /@changesets/config@3.0.0: + resolution: {integrity: sha512-o/rwLNnAo/+j9Yvw9mkBQOZySDYyOr/q+wptRLcAVGlU6djOeP9v1nlalbL9MFsobuBVQbZCTp+dIzdq+CLQUA==} + dependencies: + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.0.0 + '@changesets/logger': 0.1.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + fs-extra: 7.0.1 + micromatch: 4.0.5 + dev: false + + /@changesets/errors@0.2.0: + resolution: {integrity: sha512-6BLOQUscTpZeGljvyQXlWOItQyU71kCdGz7Pi8H8zdw6BI0g3m43iL4xKUVPWtG+qrrL9DTjpdn8eYuCQSRpow==} + dependencies: + extendable-error: 0.1.7 + dev: false + + /@changesets/get-dependents-graph@2.0.0: + resolution: {integrity: sha512-cafUXponivK4vBgZ3yLu944mTvam06XEn2IZGjjKc0antpenkYANXiiE6GExV/yKdsCnE8dXVZ25yGqLYZmScA==} + dependencies: + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + chalk: 2.4.2 + fs-extra: 7.0.1 + semver: 7.6.2 + dev: false + + /@changesets/get-release-plan@4.0.0: + resolution: {integrity: sha512-9L9xCUeD/Tb6L/oKmpm8nyzsOzhdNBBbt/ZNcjynbHC07WW4E1eX8NMGC5g5SbM5z/V+MOrYsJ4lRW41GCbg3w==} + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/assemble-release-plan': 6.0.0 + '@changesets/config': 3.0.0 + '@changesets/pre': 2.0.0 + '@changesets/read': 0.6.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + dev: false + + /@changesets/get-version-range-type@0.4.0: + resolution: {integrity: sha512-hwawtob9DryoGTpixy1D3ZXbGgJu1Rhr+ySH2PvTLHvkZuQ7sRT4oQwMh0hbqZH1weAooedEjRsbrWcGLCeyVQ==} + dev: false + + /@changesets/git@3.0.0: + resolution: {integrity: sha512-vvhnZDHe2eiBNRFHEgMiGd2CT+164dfYyrJDhwwxTVD/OW0FUD6G7+4DIx1dNwkwjHyzisxGAU96q0sVNBns0w==} + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/errors': 0.2.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + is-subdir: 1.2.0 + micromatch: 4.0.5 + spawndamnit: 2.0.0 + dev: false + + /@changesets/logger@0.1.0: + resolution: {integrity: sha512-pBrJm4CQm9VqFVwWnSqKEfsS2ESnwqwH+xR7jETxIErZcfd1u2zBSqrHbRHR7xjhSgep9x2PSKFKY//FAshA3g==} + dependencies: + chalk: 2.4.2 + dev: false + + /@changesets/parse@0.4.0: + resolution: {integrity: sha512-TS/9KG2CdGXS27S+QxbZXgr8uPsP4yNJYb4BC2/NeFUj80Rni3TeD2qwWmabymxmrLo7JEsytXH1FbpKTbvivw==} + dependencies: + '@changesets/types': 6.0.0 + js-yaml: 3.14.1 + dev: false + + /@changesets/pre@2.0.0: + resolution: {integrity: sha512-HLTNYX/A4jZxc+Sq8D1AMBsv+1qD6rmmJtjsCJa/9MSRybdxh0mjbTvE6JYZQ/ZiQ0mMlDOlGPXTm9KLTU3jyw==} + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/errors': 0.2.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + fs-extra: 7.0.1 + dev: false + + /@changesets/read@0.6.0: + resolution: {integrity: sha512-ZypqX8+/im1Fm98K4YcZtmLKgjs1kDQ5zHpc2U1qdtNBmZZfo/IBiG162RoP0CUF05tvp2y4IspH11PLnPxuuw==} + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/git': 3.0.0 + '@changesets/logger': 0.1.0 + '@changesets/parse': 0.4.0 + '@changesets/types': 6.0.0 + chalk: 2.4.2 + fs-extra: 7.0.1 + p-filter: 2.1.0 + dev: false + + /@changesets/types@4.1.0: + resolution: {integrity: sha512-LDQvVDv5Kb50ny2s25Fhm3d9QSZimsoUGBsUioj6MC3qbMUCuC8GPIvk/M6IvXx3lYhAs0lwWUQLb+VIEUCECw==} + dev: false + + /@changesets/types@6.0.0: + resolution: {integrity: sha512-b1UkfNulgKoWfqyHtzKS5fOZYSJO+77adgL7DLRDr+/7jhChN+QcHnbjiQVOz/U+Ts3PGNySq7diAItzDgugfQ==} + dev: false + + /@changesets/write@0.3.0: + resolution: {integrity: sha512-slGLb21fxZVUYbyea+94uFiD6ntQW0M2hIKNznFizDhZPDgn2c/fv1UzzlW43RVzh1BEDuIqW6hzlJ1OflNmcw==} + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/types': 6.0.0 + fs-extra: 7.0.1 + human-id: 1.0.2 + prettier: 2.8.8 + dev: false + + /@esbuild/aix-ppc64@0.20.2: + resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==} engines: {node: '>=12'} cpu: [ppc64] os: [aix] @@ -142,8 +349,8 @@ packages: dev: true optional: true - /@esbuild/android-arm64@0.19.12: - resolution: {integrity: sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==} + /@esbuild/android-arm64@0.20.2: + resolution: {integrity: sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==} engines: {node: '>=12'} cpu: [arm64] os: [android] @@ -151,8 +358,8 @@ packages: dev: true optional: true - /@esbuild/android-arm@0.19.12: - resolution: {integrity: sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==} + /@esbuild/android-arm@0.20.2: + resolution: {integrity: sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==} engines: {node: '>=12'} cpu: [arm] os: [android] @@ -160,8 +367,8 @@ packages: dev: true optional: true - /@esbuild/android-x64@0.19.12: - resolution: {integrity: sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==} + /@esbuild/android-x64@0.20.2: + resolution: {integrity: sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==} engines: {node: '>=12'} cpu: [x64] os: [android] @@ -169,8 +376,8 @@ packages: dev: true optional: true - /@esbuild/darwin-arm64@0.19.12: - resolution: {integrity: sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==} + /@esbuild/darwin-arm64@0.20.2: + resolution: {integrity: sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] @@ -178,8 +385,8 @@ packages: dev: true optional: true - /@esbuild/darwin-x64@0.19.12: - resolution: {integrity: sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==} + /@esbuild/darwin-x64@0.20.2: + resolution: {integrity: sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==} engines: {node: '>=12'} cpu: [x64] os: [darwin] @@ -187,8 +394,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-arm64@0.19.12: - resolution: {integrity: sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==} + /@esbuild/freebsd-arm64@0.20.2: + resolution: {integrity: sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] @@ -196,8 +403,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-x64@0.19.12: - resolution: {integrity: sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==} + /@esbuild/freebsd-x64@0.20.2: + resolution: {integrity: sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] @@ -205,8 +412,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm64@0.19.12: - resolution: {integrity: sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==} + /@esbuild/linux-arm64@0.20.2: + resolution: {integrity: sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==} engines: {node: '>=12'} cpu: [arm64] os: [linux] @@ -214,8 +421,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm@0.19.12: - resolution: {integrity: sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==} + /@esbuild/linux-arm@0.20.2: + resolution: {integrity: sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==} engines: {node: '>=12'} cpu: [arm] os: [linux] @@ -223,8 +430,8 @@ packages: dev: true optional: true - /@esbuild/linux-ia32@0.19.12: - resolution: {integrity: sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==} + /@esbuild/linux-ia32@0.20.2: + resolution: {integrity: sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==} engines: {node: '>=12'} cpu: [ia32] os: [linux] @@ -232,8 +439,8 @@ packages: dev: true optional: true - /@esbuild/linux-loong64@0.19.12: - resolution: {integrity: sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==} + /@esbuild/linux-loong64@0.20.2: + resolution: {integrity: sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==} engines: {node: '>=12'} cpu: [loong64] os: [linux] @@ -241,8 +448,8 @@ packages: dev: true optional: true - /@esbuild/linux-mips64el@0.19.12: - resolution: {integrity: sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==} + /@esbuild/linux-mips64el@0.20.2: + resolution: {integrity: sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] @@ -250,8 +457,8 @@ packages: dev: true optional: true - /@esbuild/linux-ppc64@0.19.12: - resolution: {integrity: sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==} + /@esbuild/linux-ppc64@0.20.2: + resolution: {integrity: sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] @@ -259,8 +466,8 @@ packages: dev: true optional: true - /@esbuild/linux-riscv64@0.19.12: - resolution: {integrity: sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==} + /@esbuild/linux-riscv64@0.20.2: + resolution: {integrity: sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] @@ -268,8 +475,8 @@ packages: dev: true optional: true - /@esbuild/linux-s390x@0.19.12: - resolution: {integrity: sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==} + /@esbuild/linux-s390x@0.20.2: + resolution: {integrity: sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==} engines: {node: '>=12'} cpu: [s390x] os: [linux] @@ -277,8 +484,8 @@ packages: dev: true optional: true - /@esbuild/linux-x64@0.19.12: - resolution: {integrity: sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==} + /@esbuild/linux-x64@0.20.2: + resolution: {integrity: sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==} engines: {node: '>=12'} cpu: [x64] os: [linux] @@ -286,8 +493,8 @@ packages: dev: true optional: true - /@esbuild/netbsd-x64@0.19.12: - resolution: {integrity: sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==} + /@esbuild/netbsd-x64@0.20.2: + resolution: {integrity: sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] @@ -295,8 +502,8 @@ packages: dev: true optional: true - /@esbuild/openbsd-x64@0.19.12: - resolution: {integrity: sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==} + /@esbuild/openbsd-x64@0.20.2: + resolution: {integrity: sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] @@ -304,8 +511,8 @@ packages: dev: true optional: true - /@esbuild/sunos-x64@0.19.12: - resolution: {integrity: sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==} + /@esbuild/sunos-x64@0.20.2: + resolution: {integrity: sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==} engines: {node: '>=12'} cpu: [x64] os: [sunos] @@ -313,8 +520,8 @@ packages: dev: true optional: true - /@esbuild/win32-arm64@0.19.12: - resolution: {integrity: sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==} + /@esbuild/win32-arm64@0.20.2: + resolution: {integrity: sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==} engines: {node: '>=12'} cpu: [arm64] os: [win32] @@ -322,8 +529,8 @@ packages: dev: true optional: true - /@esbuild/win32-ia32@0.19.12: - resolution: {integrity: sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==} + /@esbuild/win32-ia32@0.20.2: + resolution: {integrity: sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==} engines: {node: '>=12'} cpu: [ia32] os: [win32] @@ -331,8 +538,8 @@ packages: dev: true optional: true - /@esbuild/win32-x64@0.19.12: - resolution: {integrity: sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==} + /@esbuild/win32-x64@0.20.2: + resolution: {integrity: sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==} engines: {node: '>=12'} cpu: [x64] os: [win32] @@ -340,10 +547,6 @@ packages: dev: true optional: true - /@ioredis/commands@1.2.0: - resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==} - dev: false - /@lit-labs/ssr-dom-shim@1.2.0: resolution: {integrity: sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g==} dev: false @@ -354,6 +557,26 @@ packages: '@lit-labs/ssr-dom-shim': 1.2.0 dev: false + /@manypkg/find-root@1.1.0: + resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} + dependencies: + '@babel/runtime': 7.24.5 + '@types/node': 12.20.55 + find-up: 4.1.0 + fs-extra: 8.1.0 + dev: false + + /@manypkg/get-packages@1.1.3: + resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} + dependencies: + '@babel/runtime': 7.24.5 + '@changesets/types': 4.1.0 + '@manypkg/find-root': 1.1.0 + fs-extra: 8.1.0 + globby: 11.1.0 + read-yaml-file: 1.1.0 + dev: false + /@motionone/animation@10.17.0: resolution: {integrity: sha512-ANfIN9+iq1kGgsZxs+Nz96uiNcPLGTXwfNo2Xz/fcJXniPYpaz/Uyrfa+7I5BPLxCP82sh7quVDudf1GABqHbg==} dependencies: @@ -416,6 +639,27 @@ packages: tslib: 2.6.2 dev: false + /@nodelib/fs.scandir@2.1.5: + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + dev: false + + /@nodelib/fs.stat@2.0.5: + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + dev: false + + /@nodelib/fs.walk@1.2.8: + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.17.1 + dev: false + /@parcel/watcher-android-arm64@2.4.1: resolution: {integrity: sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==} engines: {node: '>= 10.0.0'} @@ -557,110 +801,192 @@ packages: '@parcel/watcher-win32-x64': 2.4.1 dev: false - /@puzzlehq/types@1.0.11: - resolution: {integrity: sha512-Elk1gs+RxTR3zBGdENpH3TMdp6aQaO17bI+ubfkbAPW6gN4PyYicN4z++TQCCvXwtIarOr0I2K0kLe8yQAIovw==} + /@puzzlehq/types@1.0.21: + resolution: {integrity: sha512-wO2HtC4wbQ9yijHFu06xArco8P5o2uJw/05mDSKfn/T/dLMzWjOaDyAfh5DxzysRpwNRzGQopawpJure3EToyA==} dependencies: zod: 3.21.1 dev: false - /@rollup/rollup-android-arm-eabi@4.12.0: - resolution: {integrity: sha512-+ac02NL/2TCKRrJu2wffk1kZ+RyqxVUlbjSagNgPm94frxtr+XDL12E5Ll1enWskLrtrZ2r8L3wED1orIibV/w==} + /@puzzlehq/walletconnect-modal-core@0.0.6(@types/react@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-ZNQqAPRGTDdETNZbvwFWUU6kEKnVHX6eXlGJQ+aqHQuYcYjMjwNACqo2jWqqaKfNJYmtf14cq6OAGoYzsJZHHg==} + dependencies: + valtio: 1.11.2(@types/react@18.3.1)(react@18.3.1) + transitivePeerDependencies: + - '@types/react' + - react + dev: false + + /@puzzlehq/walletconnect-modal-sign-html@0.0.6(@types/react@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-GlUXn1nMb4byll0d44gwyTb6IirHx8NaVeJhQlq2WKnALocfPUNED109NJgrmwmqPkStLSIJgNdIatxKjaNNNw==} + dependencies: + '@puzzlehq/walletconnect-modal': 0.0.6(@types/react@18.3.1)(react@18.3.1) + '@walletconnect/sign-client': 2.12.2 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@types/react' + - '@upstash/redis' + - '@vercel/kv' + - bufferutil + - encoding + - ioredis + - react + - uWebSockets.js + - utf-8-validate + dev: false + + /@puzzlehq/walletconnect-modal-ui@0.0.6(@types/react@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-4mfJgAibplgEsUDUIwOugro+SQWdDKGd9qlLO5WBAU7ItbMjT1BlHDKfTHPFi0Z5fcgCiH+cTWq8EP7fPbDZkA==} + dependencies: + '@puzzlehq/walletconnect-modal-core': 0.0.6(@types/react@18.3.1)(react@18.3.1) + lit: 2.8.0 + motion: 10.16.2 + qrcode: 1.5.3 + transitivePeerDependencies: + - '@types/react' + - react + dev: false + + /@puzzlehq/walletconnect-modal@0.0.6(@types/react@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-neqezlqFS6eIeJCrlPr0YUMrZZqydLKQsuLQgGiqEfV1wD7OrUDheyjES0HiSL6r8fc8sHmHewh5NYphoVlH2Q==} + dependencies: + '@puzzlehq/walletconnect-modal-core': 0.0.6(@types/react@18.3.1)(react@18.3.1) + '@puzzlehq/walletconnect-modal-ui': 0.0.6(@types/react@18.3.1)(react@18.3.1) + transitivePeerDependencies: + - '@types/react' + - react + dev: false + + /@rollup/rollup-android-arm-eabi@4.17.2: + resolution: {integrity: sha512-NM0jFxY8bB8QLkoKxIQeObCaDlJKewVlIEkuyYKm5An1tdVZ966w2+MPQ2l8LBZLjR+SgyV+nRkTIunzOYBMLQ==} cpu: [arm] os: [android] requiresBuild: true dev: true optional: true - /@rollup/rollup-android-arm64@4.12.0: - resolution: {integrity: sha512-OBqcX2BMe6nvjQ0Nyp7cC90cnumt8PXmO7Dp3gfAju/6YwG0Tj74z1vKrfRz7qAv23nBcYM8BCbhrsWqO7PzQQ==} + /@rollup/rollup-android-arm64@4.17.2: + resolution: {integrity: sha512-yeX/Usk7daNIVwkq2uGoq2BYJKZY1JfyLTaHO/jaiSwi/lsf8fTFoQW/n6IdAsx5tx+iotu2zCJwz8MxI6D/Bw==} cpu: [arm64] os: [android] requiresBuild: true dev: true optional: true - /@rollup/rollup-darwin-arm64@4.12.0: - resolution: {integrity: sha512-X64tZd8dRE/QTrBIEs63kaOBG0b5GVEd3ccoLtyf6IdXtHdh8h+I56C2yC3PtC9Ucnv0CpNFJLqKFVgCYe0lOQ==} + /@rollup/rollup-darwin-arm64@4.17.2: + resolution: {integrity: sha512-kcMLpE6uCwls023+kknm71ug7MZOrtXo+y5p/tsg6jltpDtgQY1Eq5sGfHcQfb+lfuKwhBmEURDga9N0ol4YPw==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /@rollup/rollup-darwin-x64@4.12.0: - resolution: {integrity: sha512-cc71KUZoVbUJmGP2cOuiZ9HSOP14AzBAThn3OU+9LcA1+IUqswJyR1cAJj3Mg55HbjZP6OLAIscbQsQLrpgTOg==} + /@rollup/rollup-darwin-x64@4.17.2: + resolution: {integrity: sha512-AtKwD0VEx0zWkL0ZjixEkp5tbNLzX+FCqGG1SvOu993HnSz4qDI6S4kGzubrEJAljpVkhRSlg5bzpV//E6ysTQ==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.12.0: - resolution: {integrity: sha512-a6w/Y3hyyO6GlpKL2xJ4IOh/7d+APaqLYdMf86xnczU3nurFTaVN9s9jOXQg97BE4nYm/7Ga51rjec5nfRdrvA==} + /@rollup/rollup-linux-arm-gnueabihf@4.17.2: + resolution: {integrity: sha512-3reX2fUHqN7sffBNqmEyMQVj/CKhIHZd4y631duy0hZqI8Qoqf6lTtmAKvJFYa6bhU95B1D0WgzHkmTg33In0A==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm-musleabihf@4.17.2: + resolution: {integrity: sha512-uSqpsp91mheRgw96xtyAGP9FW5ChctTFEoXP0r5FAzj/3ZRv3Uxjtc7taRQSaQM/q85KEKjKsZuiZM3GyUivRg==} cpu: [arm] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-arm64-gnu@4.12.0: - resolution: {integrity: sha512-0fZBq27b+D7Ar5CQMofVN8sggOVhEtzFUwOwPppQt0k+VR+7UHMZZY4y+64WJ06XOhBTKXtQB/Sv0NwQMXyNAA==} + /@rollup/rollup-linux-arm64-gnu@4.17.2: + resolution: {integrity: sha512-EMMPHkiCRtE8Wdk3Qhtciq6BndLtstqZIroHiiGzB3C5LDJmIZcSzVtLRbwuXuUft1Cnv+9fxuDtDxz3k3EW2A==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-arm64-musl@4.12.0: - resolution: {integrity: sha512-eTvzUS3hhhlgeAv6bfigekzWZjaEX9xP9HhxB0Dvrdbkk5w/b+1Sxct2ZuDxNJKzsRStSq1EaEkVSEe7A7ipgQ==} + /@rollup/rollup-linux-arm64-musl@4.17.2: + resolution: {integrity: sha512-NMPylUUZ1i0z/xJUIx6VUhISZDRT+uTWpBcjdv0/zkp7b/bQDF+NfnfdzuTiB1G6HTodgoFa93hp0O1xl+/UbA==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-riscv64-gnu@4.12.0: - resolution: {integrity: sha512-ix+qAB9qmrCRiaO71VFfY8rkiAZJL8zQRXveS27HS+pKdjwUfEhqo2+YF2oI+H/22Xsiski+qqwIBxVewLK7sw==} + /@rollup/rollup-linux-powerpc64le-gnu@4.17.2: + resolution: {integrity: sha512-T19My13y8uYXPw/L/k0JYaX1fJKFT/PWdXiHr8mTbXWxjVF1t+8Xl31DgBBvEKclw+1b00Chg0hxE2O7bTG7GQ==} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-riscv64-gnu@4.17.2: + resolution: {integrity: sha512-BOaNfthf3X3fOWAB+IJ9kxTgPmMqPPH5f5k2DcCsRrBIbWnaJCgX2ll77dV1TdSy9SaXTR5iDXRL8n7AnoP5cg==} cpu: [riscv64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-x64-gnu@4.12.0: - resolution: {integrity: sha512-TenQhZVOtw/3qKOPa7d+QgkeM6xY0LtwzR8OplmyL5LrgTWIXpTQg2Q2ycBf8jm+SFW2Wt/DTn1gf7nFp3ssVA==} + /@rollup/rollup-linux-s390x-gnu@4.17.2: + resolution: {integrity: sha512-W0UP/x7bnn3xN2eYMql2T/+wpASLE5SjObXILTMPUBDB/Fg/FxC+gX4nvCfPBCbNhz51C+HcqQp2qQ4u25ok6g==} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-x64-gnu@4.17.2: + resolution: {integrity: sha512-Hy7pLwByUOuyaFC6mAr7m+oMC+V7qyifzs/nW2OJfC8H4hbCzOX07Ov0VFk/zP3kBsELWNFi7rJtgbKYsav9QQ==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-x64-musl@4.12.0: - resolution: {integrity: sha512-LfFdRhNnW0zdMvdCb5FNuWlls2WbbSridJvxOvYWgSBOYZtgBfW9UGNJG//rwMqTX1xQE9BAodvMH9tAusKDUw==} + /@rollup/rollup-linux-x64-musl@4.17.2: + resolution: {integrity: sha512-h1+yTWeYbRdAyJ/jMiVw0l6fOOm/0D1vNLui9iPuqgRGnXA0u21gAqOyB5iHjlM9MMfNOm9RHCQ7zLIzT0x11Q==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-win32-arm64-msvc@4.12.0: - resolution: {integrity: sha512-JPDxovheWNp6d7AHCgsUlkuCKvtu3RB55iNEkaQcf0ttsDU/JZF+iQnYcQJSk/7PtT4mjjVG8N1kpwnI9SLYaw==} + /@rollup/rollup-win32-arm64-msvc@4.17.2: + resolution: {integrity: sha512-tmdtXMfKAjy5+IQsVtDiCfqbynAQE/TQRpWdVataHmhMb9DCoJxp9vLcCBjEQWMiUYxO1QprH/HbY9ragCEFLA==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /@rollup/rollup-win32-ia32-msvc@4.12.0: - resolution: {integrity: sha512-fjtuvMWRGJn1oZacG8IPnzIV6GF2/XG+h71FKn76OYFqySXInJtseAqdprVTDTyqPxQOG9Exak5/E9Z3+EJ8ZA==} + /@rollup/rollup-win32-ia32-msvc@4.17.2: + resolution: {integrity: sha512-7II/QCSTAHuE5vdZaQEwJq2ZACkBpQDOmQsE6D6XUbnBHW8IAhm4eTufL6msLJorzrHDFv3CF8oCA/hSIRuZeQ==} cpu: [ia32] os: [win32] requiresBuild: true dev: true optional: true - /@rollup/rollup-win32-x64-msvc@4.12.0: - resolution: {integrity: sha512-ZYmr5mS2wd4Dew/JjT0Fqi2NPB/ZhZ2VvPp7SmvPZb4Y1CG/LRcS6tcRo2cYU7zLK5A7cdbhWnnWmUjoI4qapg==} + /@rollup/rollup-win32-x64-msvc@4.17.2: + resolution: {integrity: sha512-TGGO7v7qOq4CYmSBVEYpI1Y5xDuCEnbVC5Vth8mOsW0gDSzxNrVERPc790IGHsrT2dQSimgMr9Ub3Y1Jci5/8w==} cpu: [x64] os: [win32] requiresBuild: true @@ -783,32 +1109,32 @@ packages: '@stablelib/wipe': 1.0.1 dev: false - /@tanstack/match-sorter-utils@8.11.8: - resolution: {integrity: sha512-3VPh0SYMGCa5dWQEqNab87UpCMk+ANWHDP4ALs5PeEW9EpfTAbrezzaOk/OiM52IESViefkoAOYuxdoa04p6aA==} + /@tanstack/match-sorter-utils@8.15.1: + resolution: {integrity: sha512-PnVV3d2poenUM31ZbZi/yXkBu3J7kd5k2u51CGwwNojag451AjTH9N6n41yjXz2fpLeewleyLBmNS6+HcGDlXw==} engines: {node: '>=12'} dependencies: - remove-accents: 0.4.2 + remove-accents: 0.5.0 dev: true /@tanstack/query-core@4.36.1: resolution: {integrity: sha512-DJSilV5+ytBP1FbFcEJovv4rnnm/CokuVvrBEtW/Va9DvuJ3HksbXUJEpI0aV1KtuL4ZoO9AVE6PyNLzF7tLeA==} - /@tanstack/react-query-devtools@4.36.1(@tanstack/react-query@4.36.1)(react-dom@18.2.0)(react@18.2.0): + /@tanstack/react-query-devtools@4.36.1(@tanstack/react-query@4.36.1)(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-WYku83CKP3OevnYSG8Y/QO9g0rT75v1om5IvcWUwiUZJ4LanYGLVCZ8TdFG5jfsq4Ej/lu2wwDAULEUnRIMBSw==} peerDependencies: '@tanstack/react-query': ^4.36.1 react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 dependencies: - '@tanstack/match-sorter-utils': 8.11.8 - '@tanstack/react-query': 4.36.1(react-dom@18.2.0)(react@18.2.0) - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) + '@tanstack/match-sorter-utils': 8.15.1 + '@tanstack/react-query': 4.36.1(react-dom@18.3.1)(react@18.3.1) + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) superjson: 1.13.3 - use-sync-external-store: 1.2.0(react@18.2.0) + use-sync-external-store: 1.2.2(react@18.3.1) dev: true - /@tanstack/react-query@4.36.1(react-dom@18.2.0)(react@18.2.0): + /@tanstack/react-query@4.36.1(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-y7ySVHFyyQblPl3J3eQBWpXZkliroki3ARnBKsdJchlgt7yJLRDUcf4B8soufgiYt3pEQIkBWBx1N9/ZPIeUWw==} peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -821,18 +1147,18 @@ packages: optional: true dependencies: '@tanstack/query-core': 4.36.1 - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) - use-sync-external-store: 1.2.0(react@18.2.0) + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + use-sync-external-store: 1.2.2(react@18.3.1) - /@trpc/server@10.45.1: - resolution: {integrity: sha512-KOzBEVaHW9IxEedUP9E50y0tYxAuvlzyjn80Bpemw4rcNbT4WtJnhkFPUY+qDJl7Crt3B/oY2qMgSxVWi9toLg==} + /@trpc/server@10.45.2: + resolution: {integrity: sha512-wOrSThNNE4HUnuhJG6PfDRp4L2009KDVxsd+2VYH8ro6o/7/jwYZ8Uu5j+VaW+mOmc8EHerHzGcdbGNQSAUPgg==} dev: false /@types/chrome@0.0.228: resolution: {integrity: sha512-rDmyVEF+l9H+6FQYqsEGqQOjBw/uaSx6KJ6o47FwbQmPPcskmt8XlPbKjy5KeQXU3ZLiV2x45Fk4kdtRMSghfQ==} dependencies: - '@types/filesystem': 0.0.35 + '@types/filesystem': 0.0.36 '@types/har-format': 1.2.15 dev: true @@ -846,8 +1172,8 @@ packages: resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} dev: true - /@types/filesystem@0.0.35: - resolution: {integrity: sha512-1eKvCaIBdrD2mmMgy5dwh564rVvfEhZTWVQQGRNn0Nt4ZEnJ0C8oSUCzvMKRA4lGde5oEVo+q2MrTTbV/GHDCQ==} + /@types/filesystem@0.0.36: + resolution: {integrity: sha512-vPDXOZuannb9FZdxgHnqSwAG/jvdGM8Wq+6N4D/d80z+D4HWH+bItqsZaVRQykAn6WEVeEkLm2oQigyHtgb0RA==} dependencies: '@types/filewriter': 0.0.33 dev: true @@ -860,41 +1186,53 @@ packages: resolution: {integrity: sha512-RpQH4rXLuvTXKR0zqHq3go0RVXYv/YVqv4TnPH95VbwUxZdQlK1EtcMvQvMpDngHbt13Csh9Z4qT9AbkiQH5BA==} dev: true + /@types/minimist@1.2.5: + resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} + dev: false + /@types/ms@0.7.34: resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==} dev: true - /@types/node@18.19.18: - resolution: {integrity: sha512-80CP7B8y4PzZF0GWx15/gVWRrB5y/bIjNI84NK3cmQJu0WZwvmj2WMA5LcofQFVfLqqCSp545+U2LsrVzX36Zg==} + /@types/node@12.20.55: + resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} + dev: false + + /@types/node@18.19.33: + resolution: {integrity: sha512-NR9+KrpSajr2qBVp/Yt5TU/rp+b5Mayi3+OlMlcg2cVCfRmcG5PWZ7S4+MG9PZ5gWBoc9Pd0BKSRViuBCRPu0A==} dependencies: undici-types: 5.26.5 dev: true - /@types/prop-types@15.7.11: - resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==} + /@types/normalize-package-data@2.4.4: + resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} + dev: false + + /@types/prop-types@15.7.12: + resolution: {integrity: sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==} - /@types/react-dom@18.2.19: - resolution: {integrity: sha512-aZvQL6uUbIJpjZk4U8JZGbau9KDeAwMfmhyWorxgBkqDIEf6ROjRozcmPIicqsUwPUjbkDfHKgGee1Lq65APcA==} + /@types/react-dom@18.3.0: + resolution: {integrity: sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==} dependencies: - '@types/react': 18.2.58 + '@types/react': 18.3.1 dev: true - /@types/react@18.2.58: - resolution: {integrity: sha512-TaGvMNhxvG2Q0K0aYxiKfNDS5m5ZsoIBBbtfUorxdH4NGSXIlYvZxLJI+9Dd3KjeB3780bciLyAb7ylO8pLhPw==} + /@types/react@18.3.1: + resolution: {integrity: sha512-V0kuGBX3+prX+DQ/7r2qsv1NsdfnCLnTgnRJ1pYnxykBhGMz+qj+box5lq7XsO5mtZsBqpjwwTu/7wszPfMBcw==} dependencies: - '@types/prop-types': 15.7.11 - '@types/scheduler': 0.16.8 + '@types/prop-types': 15.7.12 csstype: 3.1.3 - /@types/scheduler@0.16.8: - resolution: {integrity: sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==} + /@types/semver@7.5.8: + resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} + dev: false /@types/trusted-types@2.0.7: resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} dev: false - /@walletconnect/core@2.11.2: - resolution: {integrity: sha512-bB4SiXX8hX3/hyBfVPC5gwZCXCl+OPj+/EDVM71iAO3TDsh78KPbrVAbDnnsbHzZVHlsMohtXX3j5XVsheN3+g==} + /@walletconnect/core@2.12.2: + resolution: {integrity: sha512-7Adv/b3pp9F42BkvReaaM4KS8NEvlkS7AMtwO3uF/o6aRMKtcfTJq9/jgWdKJh4RP8pPRTRFjCw6XQ/RZtT4aQ==} dependencies: '@walletconnect/heartbeat': 1.2.1 '@walletconnect/jsonrpc-provider': 1.0.13 @@ -902,13 +1240,13 @@ packages: '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/jsonrpc-ws-connection': 1.0.14 '@walletconnect/keyvaluestorage': 1.1.1 - '@walletconnect/logger': 2.0.1 - '@walletconnect/relay-api': 1.0.9 + '@walletconnect/logger': 2.1.2 + '@walletconnect/relay-api': 1.0.10 '@walletconnect/relay-auth': 1.0.4 '@walletconnect/safe-json': 1.0.2 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.11.2 - '@walletconnect/utils': 2.11.2 + '@walletconnect/types': 2.12.2 + '@walletconnect/utils': 2.12.2 events: 3.3.0 isomorphic-unfetch: 3.1.0 lodash.isequal: 4.5.0 @@ -928,7 +1266,7 @@ packages: - '@vercel/kv' - bufferutil - encoding - - supports-color + - ioredis - uWebSockets.js - utf-8-validate dev: false @@ -954,6 +1292,14 @@ packages: tslib: 1.14.1 dev: false + /@walletconnect/heartbeat@1.2.2: + resolution: {integrity: sha512-uASiRmC5MwhuRuf05vq4AT48Pq8RMi876zV8rr8cV969uTOzWdB/k+Lj5yI2PBtB1bGQisGen7MM1GcZlQTBXw==} + dependencies: + '@walletconnect/events': 1.0.1 + '@walletconnect/time': 1.0.2 + events: 3.3.0 + dev: false + /@walletconnect/jsonrpc-provider@1.0.13: resolution: {integrity: sha512-K73EpThqHnSR26gOyNEL+acEex3P7VWZe6KE12ZwKzAt2H4e5gldZHbjsu2QR9cLeJ8AXuO7kEMOIcRv1QEc7g==} dependencies: @@ -969,11 +1315,18 @@ packages: tslib: 1.14.1 dev: false + /@walletconnect/jsonrpc-types@1.0.4: + resolution: {integrity: sha512-P6679fG/M+wuWg9TY8mh6xFSdYnFyFjwFelxyISxMDrlbXokorEVXYOxiqEbrU3x1BmBoCAJJ+vtEaEoMlpCBQ==} + dependencies: + events: 3.3.0 + keyvaluestorage-interface: 1.0.0 + dev: false + /@walletconnect/jsonrpc-utils@1.0.8: resolution: {integrity: sha512-vdeb03bD8VzJUL6ZtzRYsFMq1eZQcM3EAzT0a3st59dyLfJ0wq+tKMpmGH7HlB7waD858UWgfIcudbPFsbzVdw==} dependencies: '@walletconnect/environment': 1.0.1 - '@walletconnect/jsonrpc-types': 1.0.3 + '@walletconnect/jsonrpc-types': 1.0.4 tslib: 1.14.1 dev: false @@ -999,7 +1352,7 @@ packages: dependencies: '@walletconnect/safe-json': 1.0.2 idb-keyval: 6.2.1 - unstorage: 1.10.1(idb-keyval@6.2.1) + unstorage: 1.10.2(idb-keyval@6.2.1) transitivePeerDependencies: - '@azure/app-configuration' - '@azure/cosmos' @@ -1012,82 +1365,21 @@ packages: - '@planetscale/database' - '@upstash/redis' - '@vercel/kv' - - supports-color + - ioredis - uWebSockets.js dev: false - /@walletconnect/logger@2.0.1: - resolution: {integrity: sha512-SsTKdsgWm+oDTBeNE/zHxxr5eJfZmE9/5yp/Ku+zJtcTAjELb3DXueWkDXmE9h8uHIbJzIb5wj5lPdzyrjT6hQ==} + /@walletconnect/logger@2.1.2: + resolution: {integrity: sha512-aAb28I3S6pYXZHQm5ESB+V6rDqIYfsnHaQyzFbwUUBFY4H0OXx/YtTl8lvhUNhMMfb9UxbwEBS253TlXUYJWSw==} dependencies: + '@walletconnect/safe-json': 1.0.2 pino: 7.11.0 - tslib: 1.14.1 - dev: false - - /@walletconnect/modal-core@2.6.2(patch_hash=p5neo4brmh5osp6hvq2kavfkgq)(@types/react@18.2.58)(react@18.2.0): - resolution: {integrity: sha512-cv8ibvdOJQv2B+nyxP9IIFdxvQznMz8OOr/oR/AaUZym4hjXNL/l1a2UlSQBXrVjo3xxbouMxLb3kBsHoYP2CA==} - dependencies: - valtio: 1.11.2(@types/react@18.2.58)(react@18.2.0) - transitivePeerDependencies: - - '@types/react' - - react - dev: false - patched: true - - /@walletconnect/modal-sign-html@2.6.2(@types/react@18.2.58)(react@18.2.0): - resolution: {integrity: sha512-p9VhWTikRfUIdUUrOsHj0vRFx0FmI6qraE6kVqxOeLwO9OoLQ6xpIRYpYwPrmASMaXRKFbLul1R3F1MKpBPvcA==} - dependencies: - '@walletconnect/modal': 2.6.2(@types/react@18.2.58)(react@18.2.0) - '@walletconnect/sign-client': 2.11.2 - transitivePeerDependencies: - - '@azure/app-configuration' - - '@azure/cosmos' - - '@azure/data-tables' - - '@azure/identity' - - '@azure/keyvault-secrets' - - '@azure/storage-blob' - - '@capacitor/preferences' - - '@netlify/blobs' - - '@planetscale/database' - - '@react-native-async-storage/async-storage' - - '@types/react' - - '@upstash/redis' - - '@vercel/kv' - - bufferutil - - encoding - - react - - supports-color - - uWebSockets.js - - utf-8-validate - dev: false - - /@walletconnect/modal-ui@2.6.2(patch_hash=niac4rovmnthpoxeu5wh4alxci)(@types/react@18.2.58)(react@18.2.0): - resolution: {integrity: sha512-rbdstM1HPGvr7jprQkyPggX7rP4XiCG85ZA+zWBEX0dVQg8PpAgRUqpeub4xQKDgY7pY/xLRXSiCVdWGqvG2HA==} - dependencies: - '@walletconnect/modal-core': 2.6.2(patch_hash=p5neo4brmh5osp6hvq2kavfkgq)(@types/react@18.2.58)(react@18.2.0) - lit: 2.8.0 - motion: 10.16.2 - qrcode: 1.5.3 - transitivePeerDependencies: - - '@types/react' - - react - dev: false - patched: true - - /@walletconnect/modal@2.6.2(@types/react@18.2.58)(react@18.2.0): - resolution: {integrity: sha512-eFopgKi8AjKf/0U4SemvcYw9zlLpx9njVN8sf6DAkowC2Md0gPU/UNEbH1Wwj407pEKnEds98pKWib1NN1ACoA==} - dependencies: - '@walletconnect/modal-core': 2.6.2(patch_hash=p5neo4brmh5osp6hvq2kavfkgq)(@types/react@18.2.58)(react@18.2.0) - '@walletconnect/modal-ui': 2.6.2(patch_hash=niac4rovmnthpoxeu5wh4alxci)(@types/react@18.2.58)(react@18.2.0) - transitivePeerDependencies: - - '@types/react' - - react dev: false - /@walletconnect/relay-api@1.0.9: - resolution: {integrity: sha512-Q3+rylJOqRkO1D9Su0DPE3mmznbAalYapJ9qmzDgK28mYF9alcP3UwG/og5V7l7CFOqzCLi7B8BvcBUrpDj0Rg==} + /@walletconnect/relay-api@1.0.10: + resolution: {integrity: sha512-tqrdd4zU9VBNqUaXXQASaexklv6A54yEyQQEXYOCr+Jz8Ket0dmPBDyg19LVSNUN2cipAghQc45/KVmfFJ0cYw==} dependencies: - '@walletconnect/jsonrpc-types': 1.0.3 - tslib: 1.14.1 + '@walletconnect/jsonrpc-types': 1.0.4 dev: false /@walletconnect/relay-auth@1.0.4: @@ -1107,17 +1399,17 @@ packages: tslib: 1.14.1 dev: false - /@walletconnect/sign-client@2.11.2: - resolution: {integrity: sha512-MfBcuSz2GmMH+P7MrCP46mVE5qhP0ZyWA0FyIH6/WuxQ6G+MgKsGfaITqakpRPsykWOJq8tXMs3XvUPDU413OQ==} + /@walletconnect/sign-client@2.12.2: + resolution: {integrity: sha512-cM0ualXj6nVvLqS4BDNRk+ZWR+lubcsz/IHreH+3wYrQ2sV+C0fN6ctrd7MMGZss0C0qacWCx0pm62ZBuoKvqA==} dependencies: - '@walletconnect/core': 2.11.2 + '@walletconnect/core': 2.12.2 '@walletconnect/events': 1.0.1 '@walletconnect/heartbeat': 1.2.1 '@walletconnect/jsonrpc-utils': 1.0.8 - '@walletconnect/logger': 2.0.1 + '@walletconnect/logger': 2.1.2 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.11.2 - '@walletconnect/utils': 2.11.2 + '@walletconnect/types': 2.12.2 + '@walletconnect/utils': 2.12.2 events: 3.3.0 transitivePeerDependencies: - '@azure/app-configuration' @@ -1134,7 +1426,7 @@ packages: - '@vercel/kv' - bufferutil - encoding - - supports-color + - ioredis - uWebSockets.js - utf-8-validate dev: false @@ -1145,14 +1437,40 @@ packages: tslib: 1.14.1 dev: false - /@walletconnect/types@2.11.2: - resolution: {integrity: sha512-p632MFB+lJbip2cvtXPBQslpUdiw1sDtQ5y855bOlAGquay+6fZ4h1DcDePeKQDQM3P77ax2a9aNPZxV6y/h1Q==} + /@walletconnect/types@2.12.2: + resolution: {integrity: sha512-9CmwTlPbrFTzayTL9q7xM7s3KTJkS6kYFtH2m1/fHFgALs6pIUjf1qAx1TF2E4tv7SEzLAIzU4NqgYUt2vWXTg==} dependencies: '@walletconnect/events': 1.0.1 '@walletconnect/heartbeat': 1.2.1 '@walletconnect/jsonrpc-types': 1.0.3 '@walletconnect/keyvaluestorage': 1.1.1 - '@walletconnect/logger': 2.0.1 + '@walletconnect/logger': 2.1.2 + events: 3.3.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - ioredis + - uWebSockets.js + dev: false + + /@walletconnect/types@2.13.0: + resolution: {integrity: sha512-MWaVT0FkZwzYbD3tvk8F+2qpPlz1LUSWHuqbINUtMXnSzJtXN49Y99fR7FuBhNFtDalfuWsEK17GrNA+KnAsPQ==} + dependencies: + '@walletconnect/events': 1.0.1 + '@walletconnect/heartbeat': 1.2.2 + '@walletconnect/jsonrpc-types': 1.0.4 + '@walletconnect/keyvaluestorage': 1.1.1 + '@walletconnect/logger': 2.1.2 events: 3.3.0 transitivePeerDependencies: - '@azure/app-configuration' @@ -1167,22 +1485,22 @@ packages: - '@react-native-async-storage/async-storage' - '@upstash/redis' - '@vercel/kv' - - supports-color + - ioredis - uWebSockets.js dev: false - /@walletconnect/utils@2.11.2: - resolution: {integrity: sha512-LyfdmrnZY6dWqlF4eDrx5jpUwsB2bEPjoqR5Z6rXPiHJKUOdJt7az+mNOn5KTSOlRpd1DmozrBrWr+G9fFLYVw==} + /@walletconnect/utils@2.12.2: + resolution: {integrity: sha512-zf50HeS3SfoLv1N9GPl2IXTZ9TsXfet4usVAsZmX9P6/Xzq7d/7QakjVQCHH/Wk1O9XkcsfeoZoUhRxoMJ5uJw==} dependencies: '@stablelib/chacha20poly1305': 1.0.1 '@stablelib/hkdf': 1.0.1 '@stablelib/random': 1.0.2 '@stablelib/sha256': 1.0.1 '@stablelib/x25519': 1.0.3 - '@walletconnect/relay-api': 1.0.9 + '@walletconnect/relay-api': 1.0.10 '@walletconnect/safe-json': 1.0.2 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.11.2 + '@walletconnect/types': 2.12.2 '@walletconnect/window-getters': 1.0.1 '@walletconnect/window-metadata': 1.0.1 detect-browser: 5.3.0 @@ -1201,34 +1519,80 @@ packages: - '@react-native-async-storage/async-storage' - '@upstash/redis' - '@vercel/kv' - - supports-color + - ioredis - uWebSockets.js dev: false - /@walletconnect/window-getters@1.0.1: - resolution: {integrity: sha512-vHp+HqzGxORPAN8gY03qnbTMnhqIwjeRJNOMOAzePRg4xVEEE2WvYsI9G2NMjOknA8hnuYbU3/hwLcKbjhc8+Q==} - dependencies: - tslib: 1.14.1 - dev: false - - /@walletconnect/window-metadata@1.0.1: - resolution: {integrity: sha512-9koTqyGrM2cqFRW517BPY/iEtUDx2r1+Pwwu5m7sJ7ka79wi3EyqhqcICk/yDmv6jAS1rjKgTKXlEhanYjijcA==} + /@walletconnect/utils@2.13.0: + resolution: {integrity: sha512-q1eDCsRHj5iLe7fF8RroGoPZpdo2CYMZzQSrw1iqL+2+GOeqapxxuJ1vaJkmDUkwgklfB22ufqG6KQnz78sD4w==} dependencies: + '@stablelib/chacha20poly1305': 1.0.1 + '@stablelib/hkdf': 1.0.1 + '@stablelib/random': 1.0.2 + '@stablelib/sha256': 1.0.1 + '@stablelib/x25519': 1.0.3 + '@walletconnect/relay-api': 1.0.10 + '@walletconnect/safe-json': 1.0.2 + '@walletconnect/time': 1.0.2 + '@walletconnect/types': 2.13.0 '@walletconnect/window-getters': 1.0.1 - tslib: 1.14.1 - dev: false - - /acorn@8.11.3: - resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} - engines: {node: '>=0.4.0'} - hasBin: true - dev: false - - /ansi-regex@5.0.1: + '@walletconnect/window-metadata': 1.0.1 + detect-browser: 5.3.0 + query-string: 7.1.3 + uint8arrays: 3.1.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - ioredis + - uWebSockets.js + dev: false + + /@walletconnect/window-getters@1.0.1: + resolution: {integrity: sha512-vHp+HqzGxORPAN8gY03qnbTMnhqIwjeRJNOMOAzePRg4xVEEE2WvYsI9G2NMjOknA8hnuYbU3/hwLcKbjhc8+Q==} + dependencies: + tslib: 1.14.1 + dev: false + + /@walletconnect/window-metadata@1.0.1: + resolution: {integrity: sha512-9koTqyGrM2cqFRW517BPY/iEtUDx2r1+Pwwu5m7sJ7ka79wi3EyqhqcICk/yDmv6jAS1rjKgTKXlEhanYjijcA==} + dependencies: + '@walletconnect/window-getters': 1.0.1 + tslib: 1.14.1 + dev: false + + /acorn@8.11.3: + resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: false + + /ansi-colors@4.1.3: + resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} + engines: {node: '>=6'} + dev: false + + /ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} dev: false + /ansi-styles@3.2.1: + resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} + engines: {node: '>=4'} + dependencies: + color-convert: 1.9.3 + dev: false + /ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} @@ -1244,17 +1608,79 @@ packages: picomatch: 2.3.1 dev: false + /argparse@1.0.10: + resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} + dependencies: + sprintf-js: 1.0.3 + dev: false + + /array-buffer-byte-length@1.0.1: + resolution: {integrity: sha512-ahC5W1xgou+KTXix4sAO8Ki12Q+jf4i0+tmk3sC+zgcynshkHxzpXdImBehiUYKKKDwvfFiJl1tZt6ewscS1Mg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + is-array-buffer: 3.0.4 + dev: false + + /array-union@2.1.0: + resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} + engines: {node: '>=8'} + dev: false + + /array.prototype.flat@1.3.2: + resolution: {integrity: sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + es-shim-unscopables: 1.0.2 + dev: false + + /arraybuffer.prototype.slice@1.0.3: + resolution: {integrity: sha512-bMxMKAjg13EBSVscxTaYA4mRc5t1UAXa2kXiGTNfZ079HIWXEkKmkgFrh/nJqamaLSrXO5H4WFFkPEaLJWbs3A==} + engines: {node: '>= 0.4'} + dependencies: + array-buffer-byte-length: 1.0.1 + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + es-errors: 1.3.0 + get-intrinsic: 1.2.4 + is-array-buffer: 3.0.4 + is-shared-array-buffer: 1.0.3 + dev: false + + /arrify@1.0.1: + resolution: {integrity: sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==} + engines: {node: '>=0.10.0'} + dev: false + /atomic-sleep@1.0.0: resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} engines: {node: '>=8.0.0'} dev: false + /available-typed-arrays@1.0.7: + resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} + engines: {node: '>= 0.4'} + dependencies: + possible-typed-array-names: 1.0.0 + dev: false + /base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} dev: false - /binary-extensions@2.2.0: - resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} + /better-path-resolve@1.0.0: + resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} + engines: {node: '>=4'} + dependencies: + is-windows: 1.0.2 + dev: false + + /binary-extensions@2.3.0: + resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} dev: false @@ -1265,6 +1691,12 @@ packages: fill-range: 7.0.1 dev: false + /breakword@1.0.6: + resolution: {integrity: sha512-yjxDAYyK/pBvws9H4xKYpLDpYKEH6CzrBPAuXq3x18I+c/2MkVtT3qAr7Oloi6Dss9qNhPVueAAVU1CSeNDIXw==} + dependencies: + wcwidth: 1.0.1 + dev: false + /buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} dependencies: @@ -1272,11 +1704,52 @@ packages: ieee754: 1.2.1 dev: false + /call-bind@1.0.7: + resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==} + engines: {node: '>= 0.4'} + dependencies: + es-define-property: 1.0.0 + es-errors: 1.3.0 + function-bind: 1.1.2 + get-intrinsic: 1.2.4 + set-function-length: 1.2.2 + dev: false + + /camelcase-keys@6.2.2: + resolution: {integrity: sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==} + engines: {node: '>=8'} + dependencies: + camelcase: 5.3.1 + map-obj: 4.3.0 + quick-lru: 4.0.1 + dev: false + /camelcase@5.3.1: resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} engines: {node: '>=6'} dev: false + /chalk@2.4.2: + resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} + engines: {node: '>=4'} + dependencies: + ansi-styles: 3.2.1 + escape-string-regexp: 1.0.5 + supports-color: 5.5.0 + dev: false + + /chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + dev: false + + /chardet@0.7.0: + resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + dev: false + /chokidar@3.6.0: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} @@ -1292,6 +1765,11 @@ packages: fsevents: 2.3.3 dev: false + /ci-info@3.9.0: + resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} + engines: {node: '>=8'} + dev: false + /citty@0.1.6: resolution: {integrity: sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==} dependencies: @@ -1315,9 +1793,24 @@ packages: wrap-ansi: 6.2.0 dev: false - /cluster-key-slot@1.1.2: - resolution: {integrity: sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==} - engines: {node: '>=0.10.0'} + /cliui@8.0.1: + resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} + engines: {node: '>=12'} + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + dev: false + + /clone@1.0.4: + resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} + engines: {node: '>=0.8'} + dev: false + + /color-convert@1.9.3: + resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} + dependencies: + color-name: 1.1.3 dev: false /color-convert@2.0.1: @@ -1327,17 +1820,25 @@ packages: color-name: 1.1.4 dev: false + /color-name@1.1.3: + resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} + dev: false + /color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} dev: false + /confbox@0.1.7: + resolution: {integrity: sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==} + dev: false + /consola@3.2.3: resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==} engines: {node: ^14.18.0 || >=16.10.0} dev: false - /cookie-es@1.0.0: - resolution: {integrity: sha512-mWYvfOLrfEc996hlKcdABeIiPHUPC6DM2QYZdGGOvhOTbA3tjm2eBwqlJpoFdjC89NI4Qt6h0Pu06Mp+1Pj5OQ==} + /cookie-es@1.1.0: + resolution: {integrity: sha512-L2rLOcK0wzWSfSDA33YR+PUHDG10a8px7rUHKWbGLP4YfbsMed2KFUw5fczvDPbT98DDe3LEzviswl810apTEw==} dev: false /copy-anything@3.0.5: @@ -1347,6 +1848,14 @@ packages: is-what: 4.1.16 dev: true + /cross-spawn@5.1.0: + resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} + dependencies: + lru-cache: 4.1.5 + shebang-command: 1.2.0 + which: 1.3.1 + dev: false + /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -1368,6 +1877,55 @@ packages: /csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} + /csv-generate@3.4.3: + resolution: {integrity: sha512-w/T+rqR0vwvHqWs/1ZyMDWtHHSJaN06klRqJXBEpDJaM/+dZkso0OKh1VcuuYvK3XM53KysVNq8Ko/epCK8wOw==} + dev: false + + /csv-parse@4.16.3: + resolution: {integrity: sha512-cO1I/zmz4w2dcKHVvpCr7JVRu8/FymG5OEpmvsZYlccYolPBLoVGKUHgNoc4ZGkFeFlWGEDmMyBM+TTqRdW/wg==} + dev: false + + /csv-stringify@5.6.5: + resolution: {integrity: sha512-PjiQ659aQ+fUTQqSrd1XEDnOr52jh30RBurfzkscaE2tPaFsDH5wOAHJiw8XAHphRknCwMUE9KRayc4K/NbO8A==} + dev: false + + /csv@5.5.3: + resolution: {integrity: sha512-QTaY0XjjhTQOdguARF0lGKm5/mEq9PD9/VhZZegHDIBq2tQwgNpHc3dneD4mGo2iJs+fTKv5Bp0fZ+BRuY3Z0g==} + engines: {node: '>= 0.1.90'} + dependencies: + csv-generate: 3.4.3 + csv-parse: 4.16.3 + csv-stringify: 5.6.5 + stream-transform: 2.1.3 + dev: false + + /data-view-buffer@1.0.1: + resolution: {integrity: sha512-0lht7OugA5x3iJLOWFhWK/5ehONdprk0ISXqVFn/NFrDu+cuc8iADFrGQz5BnRK7LLU3JmkbXSxaqX+/mXYtUA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + is-data-view: 1.0.1 + dev: false + + /data-view-byte-length@1.0.1: + resolution: {integrity: sha512-4J7wRJD3ABAzr8wP+OcIcqq2dlUKp4DVflx++hs5h5ZKydWMI6/D/fAot+yh6g2tHh8fLFTvNOaVN357NvSrOQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + is-data-view: 1.0.1 + dev: false + + /data-view-byte-offset@1.0.0: + resolution: {integrity: sha512-t/Ygsytq+R995EJ5PZlD4Cu56sWa8InXySaViRzw9apusqsOO2bQP+SbYzAhR0pFKoB+43lYy8rWban9JSuXnA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + is-data-view: 1.0.1 + dev: false + /debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -1380,6 +1938,14 @@ packages: ms: 2.1.2 dev: false + /decamelize-keys@1.1.1: + resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} + engines: {node: '>=0.10.0'} + dependencies: + decamelize: 1.2.0 + map-obj: 1.0.1 + dev: false + /decamelize@1.2.0: resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==} engines: {node: '>=0.10.0'} @@ -1390,13 +1956,32 @@ packages: engines: {node: '>=0.10'} dev: false - /defu@6.1.4: - resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} + /defaults@1.0.4: + resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} + dependencies: + clone: 1.0.4 dev: false - /denque@2.1.0: - resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==} - engines: {node: '>=0.10'} + /define-data-property@1.1.4: + resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} + engines: {node: '>= 0.4'} + dependencies: + es-define-property: 1.0.0 + es-errors: 1.3.0 + gopd: 1.0.1 + dev: false + + /define-properties@1.2.1: + resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.4 + has-property-descriptors: 1.0.2 + object-keys: 1.1.1 + dev: false + + /defu@6.1.4: + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} dev: false /destr@2.0.3: @@ -1407,6 +1992,11 @@ packages: resolution: {integrity: sha512-53rsFbGdwMwlF7qvCt0ypLM5V5/Mbl0szB7GPN8y9NCcbknYOeVVXdrXEq+90IwAfrrzt6Hd+u2E2ntakICU8w==} dev: false + /detect-indent@6.1.0: + resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} + engines: {node: '>=8'} + dev: false + /detect-libc@1.0.3: resolution: {integrity: sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==} engines: {node: '>=0.10'} @@ -1417,8 +2007,15 @@ packages: resolution: {integrity: sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==} dev: false - /duplexify@4.1.2: - resolution: {integrity: sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw==} + /dir-glob@3.0.1: + resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} + engines: {node: '>=8'} + dependencies: + path-type: 4.0.0 + dev: false + + /duplexify@4.1.3: + resolution: {integrity: sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==} dependencies: end-of-stream: 1.4.4 inherits: 2.0.4 @@ -1440,37 +2037,162 @@ packages: once: 1.4.0 dev: false - /esbuild@0.19.12: - resolution: {integrity: sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==} + /enquirer@2.4.1: + resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} + engines: {node: '>=8.6'} + dependencies: + ansi-colors: 4.1.3 + strip-ansi: 6.0.1 + dev: false + + /error-ex@1.3.2: + resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} + dependencies: + is-arrayish: 0.2.1 + dev: false + + /es-abstract@1.23.3: + resolution: {integrity: sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==} + engines: {node: '>= 0.4'} + dependencies: + array-buffer-byte-length: 1.0.1 + arraybuffer.prototype.slice: 1.0.3 + available-typed-arrays: 1.0.7 + call-bind: 1.0.7 + data-view-buffer: 1.0.1 + data-view-byte-length: 1.0.1 + data-view-byte-offset: 1.0.0 + es-define-property: 1.0.0 + es-errors: 1.3.0 + es-object-atoms: 1.0.0 + es-set-tostringtag: 2.0.3 + es-to-primitive: 1.2.1 + function.prototype.name: 1.1.6 + get-intrinsic: 1.2.4 + get-symbol-description: 1.0.2 + globalthis: 1.0.4 + gopd: 1.0.1 + has-property-descriptors: 1.0.2 + has-proto: 1.0.3 + has-symbols: 1.0.3 + hasown: 2.0.2 + internal-slot: 1.0.7 + is-array-buffer: 3.0.4 + is-callable: 1.2.7 + is-data-view: 1.0.1 + is-negative-zero: 2.0.3 + is-regex: 1.1.4 + is-shared-array-buffer: 1.0.3 + is-string: 1.0.7 + is-typed-array: 1.1.13 + is-weakref: 1.0.2 + object-inspect: 1.13.1 + object-keys: 1.1.1 + object.assign: 4.1.5 + regexp.prototype.flags: 1.5.2 + safe-array-concat: 1.1.2 + safe-regex-test: 1.0.3 + string.prototype.trim: 1.2.9 + string.prototype.trimend: 1.0.8 + string.prototype.trimstart: 1.0.8 + typed-array-buffer: 1.0.2 + typed-array-byte-length: 1.0.1 + typed-array-byte-offset: 1.0.2 + typed-array-length: 1.0.6 + unbox-primitive: 1.0.2 + which-typed-array: 1.1.15 + dev: false + + /es-define-property@1.0.0: + resolution: {integrity: sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==} + engines: {node: '>= 0.4'} + dependencies: + get-intrinsic: 1.2.4 + dev: false + + /es-errors@1.3.0: + resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} + engines: {node: '>= 0.4'} + dev: false + + /es-object-atoms@1.0.0: + resolution: {integrity: sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==} + engines: {node: '>= 0.4'} + dependencies: + es-errors: 1.3.0 + dev: false + + /es-set-tostringtag@2.0.3: + resolution: {integrity: sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==} + engines: {node: '>= 0.4'} + dependencies: + get-intrinsic: 1.2.4 + has-tostringtag: 1.0.2 + hasown: 2.0.2 + dev: false + + /es-shim-unscopables@1.0.2: + resolution: {integrity: sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==} + dependencies: + hasown: 2.0.2 + dev: false + + /es-to-primitive@1.2.1: + resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} + engines: {node: '>= 0.4'} + dependencies: + is-callable: 1.2.7 + is-date-object: 1.0.5 + is-symbol: 1.0.4 + dev: false + + /esbuild@0.20.2: + resolution: {integrity: sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/aix-ppc64': 0.19.12 - '@esbuild/android-arm': 0.19.12 - '@esbuild/android-arm64': 0.19.12 - '@esbuild/android-x64': 0.19.12 - '@esbuild/darwin-arm64': 0.19.12 - '@esbuild/darwin-x64': 0.19.12 - '@esbuild/freebsd-arm64': 0.19.12 - '@esbuild/freebsd-x64': 0.19.12 - '@esbuild/linux-arm': 0.19.12 - '@esbuild/linux-arm64': 0.19.12 - '@esbuild/linux-ia32': 0.19.12 - '@esbuild/linux-loong64': 0.19.12 - '@esbuild/linux-mips64el': 0.19.12 - '@esbuild/linux-ppc64': 0.19.12 - '@esbuild/linux-riscv64': 0.19.12 - '@esbuild/linux-s390x': 0.19.12 - '@esbuild/linux-x64': 0.19.12 - '@esbuild/netbsd-x64': 0.19.12 - '@esbuild/openbsd-x64': 0.19.12 - '@esbuild/sunos-x64': 0.19.12 - '@esbuild/win32-arm64': 0.19.12 - '@esbuild/win32-ia32': 0.19.12 - '@esbuild/win32-x64': 0.19.12 + '@esbuild/aix-ppc64': 0.20.2 + '@esbuild/android-arm': 0.20.2 + '@esbuild/android-arm64': 0.20.2 + '@esbuild/android-x64': 0.20.2 + '@esbuild/darwin-arm64': 0.20.2 + '@esbuild/darwin-x64': 0.20.2 + '@esbuild/freebsd-arm64': 0.20.2 + '@esbuild/freebsd-x64': 0.20.2 + '@esbuild/linux-arm': 0.20.2 + '@esbuild/linux-arm64': 0.20.2 + '@esbuild/linux-ia32': 0.20.2 + '@esbuild/linux-loong64': 0.20.2 + '@esbuild/linux-mips64el': 0.20.2 + '@esbuild/linux-ppc64': 0.20.2 + '@esbuild/linux-riscv64': 0.20.2 + '@esbuild/linux-s390x': 0.20.2 + '@esbuild/linux-x64': 0.20.2 + '@esbuild/netbsd-x64': 0.20.2 + '@esbuild/openbsd-x64': 0.20.2 + '@esbuild/sunos-x64': 0.20.2 + '@esbuild/win32-arm64': 0.20.2 + '@esbuild/win32-ia32': 0.20.2 + '@esbuild/win32-x64': 0.20.2 dev: true + /escalade@3.1.2: + resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} + engines: {node: '>=6'} + dev: false + + /escape-string-regexp@1.0.5: + resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} + engines: {node: '>=0.8.0'} + dev: false + + /esprima@4.0.1: + resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} + engines: {node: '>=4'} + hasBin: true + dev: false + /events@3.3.0: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} @@ -1491,11 +2213,41 @@ packages: strip-final-newline: 3.0.0 dev: false - /fast-redact@3.3.0: - resolution: {integrity: sha512-6T5V1QK1u4oF+ATxs1lWUmlEk6P2T9HqJG3e2DnHOdVgZy2rFJBoEnrIedcTXlkAHU/zKC+7KETJ+KGGKwxgMQ==} + /extendable-error@0.1.7: + resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==} + dev: false + + /external-editor@3.1.0: + resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} + engines: {node: '>=4'} + dependencies: + chardet: 0.7.0 + iconv-lite: 0.4.24 + tmp: 0.0.33 + dev: false + + /fast-glob@3.3.2: + resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} + engines: {node: '>=8.6.0'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.5 + dev: false + + /fast-redact@3.5.0: + resolution: {integrity: sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==} engines: {node: '>=6'} dev: false + /fastq@1.17.1: + resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} + dependencies: + reusify: 1.0.4 + dev: false + /fill-range@7.0.1: resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} engines: {node: '>=8'} @@ -1516,6 +2268,45 @@ packages: path-exists: 4.0.0 dev: false + /find-up@5.0.0: + resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} + engines: {node: '>=10'} + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 + dev: false + + /find-yarn-workspace-root2@1.2.16: + resolution: {integrity: sha512-hr6hb1w8ePMpPVUK39S4RlwJzi+xPLuVuG8XlwXU3KD5Yn3qgBWVfy3AzNlDhWvE1EORCE65/Qm26rFQt3VLVA==} + dependencies: + micromatch: 4.0.5 + pkg-dir: 4.2.0 + dev: false + + /for-each@0.3.3: + resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} + dependencies: + is-callable: 1.2.7 + dev: false + + /fs-extra@7.0.1: + resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} + engines: {node: '>=6 <7 || >=8'} + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + dev: false + + /fs-extra@8.1.0: + resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} + engines: {node: '>=6 <7 || >=8'} + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + dev: false + /fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -1523,11 +2314,40 @@ packages: requiresBuild: true optional: true + /function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + dev: false + + /function.prototype.name@1.1.6: + resolution: {integrity: sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + functions-have-names: 1.2.3 + dev: false + + /functions-have-names@1.2.3: + resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} + dev: false + /get-caller-file@2.0.5: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} dev: false + /get-intrinsic@1.2.4: + resolution: {integrity: sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==} + engines: {node: '>= 0.4'} + dependencies: + es-errors: 1.3.0 + function-bind: 1.1.2 + has-proto: 1.0.3 + has-symbols: 1.0.3 + hasown: 2.0.2 + dev: false + /get-port-please@3.1.2: resolution: {integrity: sha512-Gxc29eLs1fbn6LQ4jSU4vXjlwyZhF5HsGuMAa7gqBP4Rw4yxxltyDUuF5MBclFzDTXO+ACchGQoeela4DSfzdQ==} dev: false @@ -1537,6 +2357,15 @@ packages: engines: {node: '>=16'} dev: false + /get-symbol-description@1.0.2: + resolution: {integrity: sha512-g0QYk1dZBxGwk+Ngc+ltRH2IBp2f7zBkBMBJZCDerh6EhlhSR6+9irMCuT/09zD6qkarHUSn529sK/yL4S27mg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + get-intrinsic: 1.2.4 + dev: false + /glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -1544,37 +2373,135 @@ packages: is-glob: 4.0.3 dev: false + /globalthis@1.0.4: + resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} + engines: {node: '>= 0.4'} + dependencies: + define-properties: 1.2.1 + gopd: 1.0.1 + dev: false + + /globby@11.1.0: + resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} + engines: {node: '>=10'} + dependencies: + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.3.2 + ignore: 5.3.1 + merge2: 1.4.1 + slash: 3.0.0 + dev: false + + /gopd@1.0.1: + resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + dependencies: + get-intrinsic: 1.2.4 + dev: false + + /graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + dev: false + + /grapheme-splitter@1.0.4: + resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} + dev: false + /h3@1.11.1: resolution: {integrity: sha512-AbaH6IDnZN6nmbnJOH72y3c5Wwh9P97soSVdGSBbcDACRdkC0FEWf25pzx4f/NuOCK6quHmW18yF2Wx+G4Zi1A==} dependencies: - cookie-es: 1.0.0 + cookie-es: 1.1.0 crossws: 0.2.4 defu: 6.1.4 destr: 2.0.3 - iron-webcrypto: 1.0.0 + iron-webcrypto: 1.1.1 ohash: 1.1.3 - radix3: 1.1.0 - ufo: 1.4.0 + radix3: 1.1.2 + ufo: 1.5.3 uncrypto: 0.1.3 unenv: 1.9.0 transitivePeerDependencies: - uWebSockets.js dev: false + /hard-rejection@2.1.0: + resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==} + engines: {node: '>=6'} + dev: false + + /has-bigints@1.0.2: + resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} + dev: false + + /has-flag@3.0.0: + resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} + engines: {node: '>=4'} + dev: false + + /has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + dev: false + + /has-property-descriptors@1.0.2: + resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} + dependencies: + es-define-property: 1.0.0 + dev: false + + /has-proto@1.0.3: + resolution: {integrity: sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==} + engines: {node: '>= 0.4'} + dev: false + + /has-symbols@1.0.3: + resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} + engines: {node: '>= 0.4'} + dev: false + + /has-tostringtag@1.0.2: + resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} + engines: {node: '>= 0.4'} + dependencies: + has-symbols: 1.0.3 + dev: false + + /hasown@2.0.2: + resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} + engines: {node: '>= 0.4'} + dependencies: + function-bind: 1.1.2 + dev: false + /hey-listen@1.0.8: resolution: {integrity: sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==} dev: false + /hosted-git-info@2.8.9: + resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} + dev: false + /http-shutdown@1.2.2: resolution: {integrity: sha512-S9wWkJ/VSY9/k4qcjG318bqJNruzE4HySUhFYknwmu6LBP97KLLfwNf+n4V1BHurvFNkSKLFnK/RsuUnRTf9Vw==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} dev: false + /human-id@1.0.2: + resolution: {integrity: sha512-UNopramDEhHJD+VR+ehk8rOslwSfByxPIZyJRfV739NDhN5LF1fa1MqnzKm2lGTQRjNrjK19Q5fhkgIfjlVUKw==} + dev: false + /human-signals@5.0.0: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} dev: false + /iconv-lite@0.4.24: + resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} + engines: {node: '>=0.10.0'} + dependencies: + safer-buffer: 2.1.2 + dev: false + /idb-keyval@6.2.1: resolution: {integrity: sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg==} dev: false @@ -1583,40 +2510,93 @@ packages: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: false + /ignore@5.3.1: + resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} + engines: {node: '>= 4'} + dev: false + /immer@9.0.21: resolution: {integrity: sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==} dev: false + /indent-string@4.0.0: + resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} + engines: {node: '>=8'} + dev: false + /inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} dev: false - /ioredis@5.3.2: - resolution: {integrity: sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA==} - engines: {node: '>=12.22.0'} + /internal-slot@1.0.7: + resolution: {integrity: sha512-NGnrKwXzSms2qUUih/ILZ5JBqNTSa1+ZmP6flaIp6KmSElgE9qdndzS3cqjrDovwFdmwsGsLdeFgB6suw+1e9g==} + engines: {node: '>= 0.4'} dependencies: - '@ioredis/commands': 1.2.0 - cluster-key-slot: 1.1.2 - debug: 4.3.4 - denque: 2.1.0 - lodash.defaults: 4.2.0 - lodash.isarguments: 3.1.0 - redis-errors: 1.2.0 - redis-parser: 3.0.0 - standard-as-callback: 2.1.0 - transitivePeerDependencies: - - supports-color + es-errors: 1.3.0 + hasown: 2.0.2 + side-channel: 1.0.6 + dev: false + + /iron-webcrypto@1.1.1: + resolution: {integrity: sha512-5xGwQUWHQSy039rFr+5q/zOmj7GP0Ypzvo34Ep+61bPIhaLduEDp/PvLGlU3awD2mzWUR0weN2vJ1mILydFPEg==} dev: false - /iron-webcrypto@1.0.0: - resolution: {integrity: sha512-anOK1Mktt8U1Xi7fCM3RELTuYbnFikQY5VtrDj7kPgpejV7d43tWKhzgioO0zpkazLEL/j/iayRqnJhrGfqUsg==} + /is-array-buffer@3.0.4: + resolution: {integrity: sha512-wcjaerHw0ydZwfhiKbXJWLDY8A7yV7KhjQOpb83hGgGfId/aQa4TOvwyzn2PuswW2gPCYEL/nEAiSVpdOj1lXw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + get-intrinsic: 1.2.4 + dev: false + + /is-arrayish@0.2.1: + resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} + dev: false + + /is-bigint@1.0.4: + resolution: {integrity: sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==} + dependencies: + has-bigints: 1.0.2 dev: false /is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} dependencies: - binary-extensions: 2.2.0 + binary-extensions: 2.3.0 + dev: false + + /is-boolean-object@1.1.2: + resolution: {integrity: sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + has-tostringtag: 1.0.2 + dev: false + + /is-callable@1.2.7: + resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} + engines: {node: '>= 0.4'} + dev: false + + /is-core-module@2.13.1: + resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} + dependencies: + hasown: 2.0.2 + dev: false + + /is-data-view@1.0.1: + resolution: {integrity: sha512-AHkaJrsUVW6wq6JS8y3JnM/GJF/9cf+k20+iDzlSaJrinEo5+7vRiteOSwBhHRiAyQATN1AmY4hwzxJKPmYf+w==} + engines: {node: '>= 0.4'} + dependencies: + is-typed-array: 1.1.13 + dev: false + + /is-date-object@1.0.5: + resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.2 dev: false /is-docker@3.0.0: @@ -1650,21 +2630,92 @@ packages: is-docker: 3.0.0 dev: false + /is-negative-zero@2.0.3: + resolution: {integrity: sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==} + engines: {node: '>= 0.4'} + dev: false + + /is-number-object@1.0.7: + resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.2 + dev: false + /is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} dev: false + /is-plain-obj@1.1.0: + resolution: {integrity: sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==} + engines: {node: '>=0.10.0'} + dev: false + + /is-regex@1.1.4: + resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + has-tostringtag: 1.0.2 + dev: false + + /is-shared-array-buffer@1.0.3: + resolution: {integrity: sha512-nA2hv5XIhLR3uVzDDfCIknerhx8XUKnstuOERPNNIinXG7v9u+ohXF67vxm4TPTEPU6lm61ZkwP3c9PCB97rhg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + dev: false + /is-stream@3.0.0: resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dev: false + /is-string@1.0.7: + resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.2 + dev: false + + /is-subdir@1.2.0: + resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==} + engines: {node: '>=4'} + dependencies: + better-path-resolve: 1.0.0 + dev: false + + /is-symbol@1.0.4: + resolution: {integrity: sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==} + engines: {node: '>= 0.4'} + dependencies: + has-symbols: 1.0.3 + dev: false + + /is-typed-array@1.1.13: + resolution: {integrity: sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==} + engines: {node: '>= 0.4'} + dependencies: + which-typed-array: 1.1.15 + dev: false + + /is-weakref@1.0.2: + resolution: {integrity: sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==} + dependencies: + call-bind: 1.0.7 + dev: false + /is-what@4.1.16: resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==} engines: {node: '>=12.13'} dev: true + /is-windows@1.0.2: + resolution: {integrity: sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==} + engines: {node: '>=0.10.0'} + dev: false + /is-wsl@3.1.0: resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==} engines: {node: '>=16'} @@ -1679,6 +2730,10 @@ packages: system-architecture: 0.1.0 dev: false + /isarray@2.0.5: + resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} + dev: false + /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: false @@ -1700,14 +2755,42 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - /jsonc-parser@3.2.1: - resolution: {integrity: sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==} + /js-yaml@3.14.1: + resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} + hasBin: true + dependencies: + argparse: 1.0.10 + esprima: 4.0.1 + dev: false + + /json-parse-even-better-errors@2.3.1: + resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} + dev: false + + /jsonfile@4.0.0: + resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + optionalDependencies: + graceful-fs: 4.2.11 dev: false /keyvaluestorage-interface@1.0.0: resolution: {integrity: sha512-8t6Q3TclQ4uZynJY9IGr2+SsIGwK9JHcO6ootkHCGA0CrQCRy+VkouYNO2xicET6b9al7QKzpebNow+gkpCL8g==} dev: false + /kind-of@6.0.3: + resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} + engines: {node: '>=0.10.0'} + dev: false + + /kleur@4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + dev: false + + /lines-and-columns@1.2.4: + resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} + dev: false + /listhen@1.7.2: resolution: {integrity: sha512-7/HamOm5YD9Wb7CFgAZkKgVPA96WwhcTQoqtm2VTZGVbVVn3IWKRBTgrU7cchA3Q8k9iCsG8Osoi9GX4JsGM9g==} hasBin: true @@ -1723,11 +2806,11 @@ packages: h3: 1.11.1 http-shutdown: 1.2.2 jiti: 1.21.0 - mlly: 1.6.1 + mlly: 1.7.0 node-forge: 1.3.1 pathe: 1.1.2 std-env: 3.7.0 - ufo: 1.4.0 + ufo: 1.5.3 untun: 0.1.3 uqr: 0.1.2 transitivePeerDependencies: @@ -1756,6 +2839,16 @@ packages: lit-html: 2.8.0 dev: false + /load-yaml-file@0.2.0: + resolution: {integrity: sha512-OfCBkGEw4nN6JLtgRidPX6QxjBQGQf72q3si2uvqyFEMbycSFFHwAZeXx6cJgFM9wmLrf9zBwCP3Ivqa+LLZPw==} + engines: {node: '>=6'} + dependencies: + graceful-fs: 4.2.11 + js-yaml: 3.14.1 + pify: 4.0.1 + strip-bom: 3.0.0 + dev: false + /locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -1763,33 +2856,75 @@ packages: p-locate: 4.1.0 dev: false - /lodash.defaults@4.2.0: - resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==} - dev: false - - /lodash.isarguments@3.1.0: - resolution: {integrity: sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==} + /locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + dependencies: + p-locate: 5.0.0 dev: false /lodash.isequal@4.5.0: resolution: {integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==} dev: false + /lodash.startcase@4.4.0: + resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} + dev: false + /loose-envify@1.4.0: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true dependencies: js-tokens: 4.0.0 - /lru-cache@10.2.0: - resolution: {integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==} + /lru-cache@10.2.2: + resolution: {integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==} engines: {node: 14 || >=16.14} dev: false + /lru-cache@4.1.5: + resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} + dependencies: + pseudomap: 1.0.2 + yallist: 2.1.2 + dev: false + + /map-obj@1.0.1: + resolution: {integrity: sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==} + engines: {node: '>=0.10.0'} + dev: false + + /map-obj@4.3.0: + resolution: {integrity: sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==} + engines: {node: '>=8'} + dev: false + + /meow@6.1.1: + resolution: {integrity: sha512-3YffViIt2QWgTy6Pale5QpopX/IvU3LPL03jOTqp6pGj3VjesdO/U8CuHMKpnQr4shCNCM5fd5XFFvIIl6JBHg==} + engines: {node: '>=8'} + dependencies: + '@types/minimist': 1.2.5 + camelcase-keys: 6.2.2 + decamelize-keys: 1.1.1 + hard-rejection: 2.1.0 + minimist-options: 4.1.0 + normalize-package-data: 2.5.0 + read-pkg-up: 7.0.1 + redent: 3.0.0 + trim-newlines: 3.0.1 + type-fest: 0.13.1 + yargs-parser: 18.1.3 + dev: false + /merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} dev: false + /merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + dev: false + /micromatch@4.0.5: resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} engines: {node: '>=8.6'} @@ -1809,13 +2944,32 @@ packages: engines: {node: '>=12'} dev: false - /mlly@1.6.1: - resolution: {integrity: sha512-vLgaHvaeunuOXHSmEbZ9izxPx3USsk8KCQ8iC+aTlp5sKRSoZvwhHh5L9VbKSaVC6sJDqbyohIS76E2VmHIPAA==} + /min-indent@1.0.1: + resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} + engines: {node: '>=4'} + dev: false + + /minimist-options@4.1.0: + resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==} + engines: {node: '>= 6'} + dependencies: + arrify: 1.0.1 + is-plain-obj: 1.1.0 + kind-of: 6.0.3 + dev: false + + /mixme@0.5.10: + resolution: {integrity: sha512-5H76ANWinB1H3twpJ6JY8uvAtpmFvHNArpilJAjXRKXSDDLPIMoZArw5SH0q9z+lLs8IrMw7Q2VWpWimFKFT1Q==} + engines: {node: '>= 8.0.0'} + dev: false + + /mlly@1.7.0: + resolution: {integrity: sha512-U9SDaXGEREBYQgfejV97coK0UL1r+qnF2SyO9A3qcI8MzKnsIFKHNVEkrDyNncQTKQQumsasmeq84eNMdBfsNQ==} dependencies: acorn: 8.11.3 pathe: 1.1.2 - pkg-types: 1.0.3 - ufo: 1.4.0 + pkg-types: 1.1.0 + ufo: 1.5.3 dev: false /motion@10.16.2: @@ -1853,8 +3007,8 @@ packages: engines: {node: ^16 || ^18 || >= 20} dev: false - /node-fetch-native@1.6.2: - resolution: {integrity: sha512-69mtXOFZ6hSkYiXAVB5SqaRvrbITC/NPyqv7yuu/qw0nmgPyYbIMYYNIDhNtwPrzk0ptrimrLz/hhjvm4w5Z+w==} + /node-fetch-native@1.6.4: + resolution: {integrity: sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==} dev: false /node-fetch@2.7.0: @@ -1874,6 +3028,15 @@ packages: engines: {node: '>= 6.13.0'} dev: false + /normalize-package-data@2.5.0: + resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} + dependencies: + hosted-git-info: 2.8.9 + resolve: 1.22.8 + semver: 5.7.2 + validate-npm-package-license: 3.0.4 + dev: false + /normalize-path@3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} @@ -1886,12 +3049,31 @@ packages: path-key: 4.0.0 dev: false - /ofetch@1.3.3: - resolution: {integrity: sha512-s1ZCMmQWXy4b5K/TW9i/DtiN8Ku+xCiHcjQ6/J/nDdssirrQNOoB165Zu8EqLMA2lln1JUth9a0aW9Ap2ctrUg==} + /object-inspect@1.13.1: + resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==} + dev: false + + /object-keys@1.1.1: + resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} + engines: {node: '>= 0.4'} + dev: false + + /object.assign@4.1.5: + resolution: {integrity: sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + has-symbols: 1.0.3 + object-keys: 1.1.1 + dev: false + + /ofetch@1.3.4: + resolution: {integrity: sha512-KLIET85ik3vhEfS+3fDlc/BAZiAp+43QEC/yCo5zkNoY2YaKvNkOaFr/6wCFgFH1kuYQM5pMNi0Tg8koiIemtw==} dependencies: destr: 2.0.3 - node-fetch-native: 1.6.2 - ufo: 1.4.0 + node-fetch-native: 1.6.4 + ufo: 1.5.3 dev: false /ohash@1.1.3: @@ -1915,6 +3097,22 @@ packages: mimic-fn: 4.0.0 dev: false + /os-tmpdir@1.0.2: + resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} + engines: {node: '>=0.10.0'} + dev: false + + /outdent@0.5.0: + resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} + dev: false + + /p-filter@2.1.0: + resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==} + engines: {node: '>=8'} + dependencies: + p-map: 2.1.0 + dev: false + /p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -1922,6 +3120,13 @@ packages: p-try: 2.2.0 dev: false + /p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + dependencies: + yocto-queue: 0.1.0 + dev: false + /p-locate@4.1.0: resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} engines: {node: '>=8'} @@ -1929,11 +3134,33 @@ packages: p-limit: 2.3.0 dev: false + /p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + dependencies: + p-limit: 3.1.0 + dev: false + + /p-map@2.1.0: + resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} + engines: {node: '>=6'} + dev: false + /p-try@2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} dev: false + /parse-json@5.2.0: + resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} + engines: {node: '>=8'} + dependencies: + '@babel/code-frame': 7.24.2 + error-ex: 1.3.2 + json-parse-even-better-errors: 2.3.1 + lines-and-columns: 1.2.4 + dev: false + /path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -1949,23 +3176,36 @@ packages: engines: {node: '>=12'} dev: false + /path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + dev: false + + /path-type@4.0.0: + resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} + engines: {node: '>=8'} + dev: false + /pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} dev: false /picocolors@1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} - dev: true /picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} dev: false + /pify@4.0.1: + resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} + engines: {node: '>=6'} + dev: false + /pino-abstract-transport@0.5.0: resolution: {integrity: sha512-+KAgmVeqXYbTtU2FScx1XS3kNyfZ5TrXY07V96QnUSFqo2gAqlvmaxH67Lj7SWazqsMabf+58ctdTcBgnOLUOQ==} dependencies: - duplexify: 4.1.2 + duplexify: 4.1.3 split2: 4.2.0 dev: false @@ -1978,7 +3218,7 @@ packages: hasBin: true dependencies: atomic-sleep: 1.0.0 - fast-redact: 3.3.0 + fast-redact: 3.5.0 on-exit-leak-free: 0.2.0 pino-abstract-transport: 0.5.0 pino-std-serializers: 4.0.0 @@ -1990,11 +3230,18 @@ packages: thread-stream: 0.15.2 dev: false - /pkg-types@1.0.3: - resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==} + /pkg-dir@4.2.0: + resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} + engines: {node: '>=8'} + dependencies: + find-up: 4.1.0 + dev: false + + /pkg-types@1.1.0: + resolution: {integrity: sha512-/RpmvKdxKf8uILTtoOhAgf30wYbP2Qw+L9p3Rvshx1JZVX+XQNZQFjlbmGHEGIm4CkVPlSn+NXmIM8+9oWQaSA==} dependencies: - jsonc-parser: 3.2.1 - mlly: 1.6.1 + confbox: 0.1.7 + mlly: 1.7.0 pathe: 1.1.2 dev: false @@ -2003,15 +3250,36 @@ packages: engines: {node: '>=10.13.0'} dev: false - /postcss@8.4.35: - resolution: {integrity: sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==} + /possible-typed-array-names@1.0.0: + resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} + engines: {node: '>= 0.4'} + dev: false + + /postcss@8.4.38: + resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==} engines: {node: ^10 || ^12 || >=14} dependencies: nanoid: 3.3.7 picocolors: 1.0.0 - source-map-js: 1.0.2 + source-map-js: 1.2.0 dev: true + /preferred-pm@3.1.3: + resolution: {integrity: sha512-MkXsENfftWSRpzCzImcp4FRsCc3y1opwB73CfCNWyzMqArju2CrlMHlqB7VexKiPEOjGMbttv1r9fSCn5S610w==} + engines: {node: '>=10'} + dependencies: + find-up: 5.0.0 + find-yarn-workspace-root2: 1.2.16 + path-exists: 4.0.0 + which-pm: 2.0.0 + dev: false + + /prettier@2.8.8: + resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} + engines: {node: '>=10.13.0'} + hasBin: true + dev: false + /prettier@3.2.5: resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} engines: {node: '>=14'} @@ -2031,6 +3299,10 @@ packages: resolution: {integrity: sha512-oyfc0Tx87Cpwva5ZXezSp5V9vht1c7dZBhvuV/y3ctkgMVUmiAGDVeeB0dKhGSyT0v1ZTEQYpe/RXlBVBNuCLA==} dev: false + /pseudomap@1.0.2: + resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==} + dev: false + /qrcode@1.5.3: resolution: {integrity: sha512-puyri6ApkEHYiVl4CFzo1tDkAZ+ATcnbJrJ6RiBM1Fhctdn/ix9MTE3hRph33omisEbC/2fcfemsseiKgBPKZg==} engines: {node: '>=10.13.0'} @@ -2052,29 +3324,67 @@ packages: strict-uri-encode: 2.0.0 dev: false + /queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + dev: false + /quick-format-unescaped@4.0.4: resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==} dev: false - /radix3@1.1.0: - resolution: {integrity: sha512-pNsHDxbGORSvuSScqNJ+3Km6QAVqk8CfsCBIEoDgpqLrkD2f3QM4I7d1ozJJ172OmIcoUcerZaNWqtLkRXTV3A==} + /quick-lru@4.0.1: + resolution: {integrity: sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==} + engines: {node: '>=8'} + dev: false + + /radix3@1.1.2: + resolution: {integrity: sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==} dev: false - /react-dom@18.2.0(react@18.2.0): - resolution: {integrity: sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==} + /react-dom@18.3.1(react@18.3.1): + resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==} peerDependencies: - react: ^18.2.0 + react: ^18.3.1 dependencies: loose-envify: 1.4.0 - react: 18.2.0 - scheduler: 0.23.0 + react: 18.3.1 + scheduler: 0.23.2 - /react@18.2.0: - resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==} + /react@18.3.1: + resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==} engines: {node: '>=0.10.0'} dependencies: loose-envify: 1.4.0 + /read-pkg-up@7.0.1: + resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} + engines: {node: '>=8'} + dependencies: + find-up: 4.1.0 + read-pkg: 5.2.0 + type-fest: 0.8.1 + dev: false + + /read-pkg@5.2.0: + resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} + engines: {node: '>=8'} + dependencies: + '@types/normalize-package-data': 2.4.4 + normalize-package-data: 2.5.0 + parse-json: 5.2.0 + type-fest: 0.6.0 + dev: false + + /read-yaml-file@1.1.0: + resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==} + engines: {node: '>=6'} + dependencies: + graceful-fs: 4.2.11 + js-yaml: 3.14.1 + pify: 4.0.1 + strip-bom: 3.0.0 + dev: false + /readable-stream@3.6.2: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} @@ -2096,20 +3406,30 @@ packages: engines: {node: '>= 12.13.0'} dev: false - /redis-errors@1.2.0: - resolution: {integrity: sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==} - engines: {node: '>=4'} + /redent@3.0.0: + resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} + engines: {node: '>=8'} + dependencies: + indent-string: 4.0.0 + strip-indent: 3.0.0 dev: false - /redis-parser@3.0.0: - resolution: {integrity: sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==} - engines: {node: '>=4'} + /regenerator-runtime@0.14.1: + resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} + dev: false + + /regexp.prototype.flags@1.5.2: + resolution: {integrity: sha512-NcDiDkTLuPR+++OCKB0nWafEmhg/Da8aUPLPMQbK+bxKKCm1/S5he+AqYa4PlMCVBalb4/yxIRub6qkEx5yJbw==} + engines: {node: '>= 0.4'} dependencies: - redis-errors: 1.2.0 + call-bind: 1.0.7 + define-properties: 1.2.1 + es-errors: 1.3.0 + set-function-name: 2.0.2 dev: false - /remove-accents@0.4.2: - resolution: {integrity: sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==} + /remove-accents@0.5.0: + resolution: {integrity: sha512-8g3/Otx1eJaVD12e31UbJj1YzdtVvzH85HV7t+9MJYk/u3XmkOUJ5Ys9wQrf9PCPK8+xn4ymzqYCiZl6QWKn+A==} dev: true /require-directory@2.1.1: @@ -2121,47 +3441,138 @@ packages: resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} dev: false - /rollup@4.12.0: - resolution: {integrity: sha512-wz66wn4t1OHIJw3+XU7mJJQV/2NAfw5OAk6G6Hoo3zcvz/XOfQ52Vgi+AN4Uxoxi0KBBwk2g8zPrTDA4btSB/Q==} + /resolve-from@5.0.0: + resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} + engines: {node: '>=8'} + dev: false + + /resolve@1.22.8: + resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} + hasBin: true + dependencies: + is-core-module: 2.13.1 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + dev: false + + /reusify@1.0.4: + resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + dev: false + + /rollup@4.17.2: + resolution: {integrity: sha512-/9ClTJPByC0U4zNLowV1tMBe8yMEAxewtR3cUNX5BoEpGH3dQEWpJLr6CLp0fPdYRF/fzVOgvDb1zXuakwF5kQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true dependencies: '@types/estree': 1.0.5 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.12.0 - '@rollup/rollup-android-arm64': 4.12.0 - '@rollup/rollup-darwin-arm64': 4.12.0 - '@rollup/rollup-darwin-x64': 4.12.0 - '@rollup/rollup-linux-arm-gnueabihf': 4.12.0 - '@rollup/rollup-linux-arm64-gnu': 4.12.0 - '@rollup/rollup-linux-arm64-musl': 4.12.0 - '@rollup/rollup-linux-riscv64-gnu': 4.12.0 - '@rollup/rollup-linux-x64-gnu': 4.12.0 - '@rollup/rollup-linux-x64-musl': 4.12.0 - '@rollup/rollup-win32-arm64-msvc': 4.12.0 - '@rollup/rollup-win32-ia32-msvc': 4.12.0 - '@rollup/rollup-win32-x64-msvc': 4.12.0 + '@rollup/rollup-android-arm-eabi': 4.17.2 + '@rollup/rollup-android-arm64': 4.17.2 + '@rollup/rollup-darwin-arm64': 4.17.2 + '@rollup/rollup-darwin-x64': 4.17.2 + '@rollup/rollup-linux-arm-gnueabihf': 4.17.2 + '@rollup/rollup-linux-arm-musleabihf': 4.17.2 + '@rollup/rollup-linux-arm64-gnu': 4.17.2 + '@rollup/rollup-linux-arm64-musl': 4.17.2 + '@rollup/rollup-linux-powerpc64le-gnu': 4.17.2 + '@rollup/rollup-linux-riscv64-gnu': 4.17.2 + '@rollup/rollup-linux-s390x-gnu': 4.17.2 + '@rollup/rollup-linux-x64-gnu': 4.17.2 + '@rollup/rollup-linux-x64-musl': 4.17.2 + '@rollup/rollup-win32-arm64-msvc': 4.17.2 + '@rollup/rollup-win32-ia32-msvc': 4.17.2 + '@rollup/rollup-win32-x64-msvc': 4.17.2 fsevents: 2.3.3 dev: true + /run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + dependencies: + queue-microtask: 1.2.3 + dev: false + + /safe-array-concat@1.1.2: + resolution: {integrity: sha512-vj6RsCsWBCf19jIeHEfkRMw8DPiBb+DMXklQ/1SGDHOMlHdPUkZXFQ2YdplS23zESTijAcurb1aSgJA3AgMu1Q==} + engines: {node: '>=0.4'} + dependencies: + call-bind: 1.0.7 + get-intrinsic: 1.2.4 + has-symbols: 1.0.3 + isarray: 2.0.5 + dev: false + /safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} dev: false + /safe-regex-test@1.0.3: + resolution: {integrity: sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + is-regex: 1.1.4 + dev: false + /safe-stable-stringify@2.4.3: resolution: {integrity: sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==} engines: {node: '>=10'} dev: false - /scheduler@0.23.0: - resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} + /safer-buffer@2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + dev: false + + /scheduler@0.23.2: + resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} dependencies: loose-envify: 1.4.0 + /semver@5.7.2: + resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} + hasBin: true + dev: false + + /semver@7.6.2: + resolution: {integrity: sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==} + engines: {node: '>=10'} + hasBin: true + dev: false + /set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} dev: false + /set-function-length@1.2.2: + resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + function-bind: 1.1.2 + get-intrinsic: 1.2.4 + gopd: 1.0.1 + has-property-descriptors: 1.0.2 + dev: false + + /set-function-name@2.0.2: + resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.2 + dev: false + + /shebang-command@1.2.0: + resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} + engines: {node: '>=0.10.0'} + dependencies: + shebang-regex: 1.0.0 + dev: false + /shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -2169,27 +3580,93 @@ packages: shebang-regex: 3.0.0 dev: false + /shebang-regex@1.0.0: + resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==} + engines: {node: '>=0.10.0'} + dev: false + /shebang-regex@3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} dev: false + /side-channel@1.0.6: + resolution: {integrity: sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + get-intrinsic: 1.2.4 + object-inspect: 1.13.1 + dev: false + + /signal-exit@3.0.7: + resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + dev: false + /signal-exit@4.1.0: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} dev: false + /slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + dev: false + + /smartwrap@2.0.2: + resolution: {integrity: sha512-vCsKNQxb7PnCNd2wY1WClWifAc2lwqsG8OaswpJkVJsvMGcnEntdTCDajZCkk93Ay1U3t/9puJmb525Rg5MZBA==} + engines: {node: '>=6'} + hasBin: true + dependencies: + array.prototype.flat: 1.3.2 + breakword: 1.0.6 + grapheme-splitter: 1.0.4 + strip-ansi: 6.0.1 + wcwidth: 1.0.1 + yargs: 15.4.1 + dev: false + /sonic-boom@2.8.0: resolution: {integrity: sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==} dependencies: atomic-sleep: 1.0.0 dev: false - /source-map-js@1.0.2: - resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} + /source-map-js@1.2.0: + resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} dev: true + /spawndamnit@2.0.0: + resolution: {integrity: sha512-j4JKEcncSjFlqIwU5L/rp2N5SIPsdxaRsIv678+TZxZ0SRDJTm8JrxJMjE/XuiEZNEir3S8l0Fa3Ke339WI4qA==} + dependencies: + cross-spawn: 5.1.0 + signal-exit: 3.0.7 + dev: false + + /spdx-correct@3.2.0: + resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} + dependencies: + spdx-expression-parse: 3.0.1 + spdx-license-ids: 3.0.17 + dev: false + + /spdx-exceptions@2.5.0: + resolution: {integrity: sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==} + dev: false + + /spdx-expression-parse@3.0.1: + resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==} + dependencies: + spdx-exceptions: 2.5.0 + spdx-license-ids: 3.0.17 + dev: false + + /spdx-license-ids@3.0.17: + resolution: {integrity: sha512-sh8PWc/ftMqAAdFiBu6Fy6JUOYjqDJBJvIhpfDMyHrr0Rbp5liZqd4TjtQ/RgfLjKFZb+LMx5hpml5qOWy0qvg==} + dev: false + /split-on-first@1.1.0: resolution: {integrity: sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==} engines: {node: '>=6'} @@ -2200,8 +3677,8 @@ packages: engines: {node: '>= 10.x'} dev: false - /standard-as-callback@2.1.0: - resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==} + /sprintf-js@1.0.3: + resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} dev: false /std-env@3.7.0: @@ -2212,6 +3689,12 @@ packages: resolution: {integrity: sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==} dev: false + /stream-transform@2.1.3: + resolution: {integrity: sha512-9GHUiM5hMiCi6Y03jD2ARC1ettBXkQBoQAe7nJsPknnI0ow10aXjTnew8QtYQmLjzn974BnmWEAJgCY6ZP1DeQ==} + dependencies: + mixme: 0.5.10 + dev: false + /strict-uri-encode@2.0.0: resolution: {integrity: sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==} engines: {node: '>=4'} @@ -2226,6 +3709,33 @@ packages: strip-ansi: 6.0.1 dev: false + /string.prototype.trim@1.2.9: + resolution: {integrity: sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + es-object-atoms: 1.0.0 + dev: false + + /string.prototype.trimend@1.0.8: + resolution: {integrity: sha512-p73uL5VCHCO2BZZ6krwwQE3kCzM7NKmis8S//xEC6fQonchbum4eP6kR4DLEjQFO3Wnj3Fuo8NM0kOSjVdHjZQ==} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-object-atoms: 1.0.0 + dev: false + + /string.prototype.trimstart@1.0.8: + resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-object-atoms: 1.0.0 + dev: false + /string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} dependencies: @@ -2239,11 +3749,23 @@ packages: ansi-regex: 5.0.1 dev: false + /strip-bom@3.0.0: + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} + engines: {node: '>=4'} + dev: false + /strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} dev: false + /strip-indent@3.0.0: + resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} + engines: {node: '>=8'} + dependencies: + min-indent: 1.0.1 + dev: false + /superjson@1.13.3: resolution: {integrity: sha512-mJiVjfd2vokfDxsQPOwJ/PtanO87LhpYY88ubI5dUB1Ab58Txbyje3+jpm+/83R/fevaq/107NNhtYBLuoTrFg==} engines: {node: '>=10'} @@ -2251,17 +3773,48 @@ packages: copy-anything: 3.0.5 dev: true + /supports-color@5.5.0: + resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} + engines: {node: '>=4'} + dependencies: + has-flag: 3.0.0 + dev: false + + /supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + dependencies: + has-flag: 4.0.0 + dev: false + + /supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + dev: false + /system-architecture@0.1.0: resolution: {integrity: sha512-ulAk51I9UVUyJgxlv9M6lFot2WP3e7t8Kz9+IS6D4rVba1tR9kON+Ey69f+1R4Q8cd45Lod6a4IcJIxnzGc/zA==} engines: {node: '>=18'} dev: false + /term-size@2.2.1: + resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==} + engines: {node: '>=8'} + dev: false + /thread-stream@0.15.2: resolution: {integrity: sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA==} dependencies: real-require: 0.1.0 dev: false + /tmp@0.0.33: + resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} + engines: {node: '>=0.6.0'} + dependencies: + os-tmpdir: 1.0.2 + dev: false + /to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -2273,6 +3826,11 @@ packages: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} dev: false + /trim-newlines@3.0.1: + resolution: {integrity: sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==} + engines: {node: '>=8'} + dev: false + /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: false @@ -2281,14 +3839,93 @@ packages: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} dev: false + /tty-table@4.2.3: + resolution: {integrity: sha512-Fs15mu0vGzCrj8fmJNP7Ynxt5J7praPXqFN0leZeZBXJwkMxv9cb2D454k1ltrtUSJbZ4yH4e0CynsHLxmUfFA==} + engines: {node: '>=8.0.0'} + hasBin: true + dependencies: + chalk: 4.1.2 + csv: 5.5.3 + kleur: 4.1.5 + smartwrap: 2.0.2 + strip-ansi: 6.0.1 + wcwidth: 1.0.1 + yargs: 17.7.2 + dev: false + + /type-fest@0.13.1: + resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==} + engines: {node: '>=10'} + dev: false + + /type-fest@0.6.0: + resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==} + engines: {node: '>=8'} + dev: false + + /type-fest@0.8.1: + resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==} + engines: {node: '>=8'} + dev: false + + /typed-array-buffer@1.0.2: + resolution: {integrity: sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + is-typed-array: 1.1.13 + dev: false + + /typed-array-byte-length@1.0.1: + resolution: {integrity: sha512-3iMJ9q0ao7WE9tWcaYKIptkNBuOIcZCCT0d4MRvuuH88fEoEH62IuQe0OtraD3ebQEoTRk8XCBoknUNc1Y67pw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + for-each: 0.3.3 + gopd: 1.0.1 + has-proto: 1.0.3 + is-typed-array: 1.1.13 + dev: false + + /typed-array-byte-offset@1.0.2: + resolution: {integrity: sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.7 + for-each: 0.3.3 + gopd: 1.0.1 + has-proto: 1.0.3 + is-typed-array: 1.1.13 + dev: false + + /typed-array-length@1.0.6: + resolution: {integrity: sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + for-each: 0.3.3 + gopd: 1.0.1 + has-proto: 1.0.3 + is-typed-array: 1.1.13 + possible-typed-array-names: 1.0.0 + dev: false + /typescript@4.9.5: resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} engines: {node: '>=4.2.0'} hasBin: true dev: true - /ufo@1.4.0: - resolution: {integrity: sha512-Hhy+BhRBleFjpJ2vchUNN40qgkh0366FWJGqVLYBHev0vpHTrXSA0ryT+74UiW6KWsldNurQMKGqCm1M2zBciQ==} + /ufo@1.5.3: + resolution: {integrity: sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==} + dev: false + + /uint8arrays@3.1.0: + resolution: {integrity: sha512-ei5rfKtoRO8OyOIor2Rz5fhzjThwIHJZ3uyDPnDHTXbP0aMQ1RN/6AI5B5d9dBxJOU+BvOAk7ZQ1xphsX8Lrog==} + dependencies: + multiformats: 9.9.0 dev: false /uint8arrays@3.1.1: @@ -2297,6 +3934,15 @@ packages: multiformats: 9.9.0 dev: false + /unbox-primitive@1.0.2: + resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} + dependencies: + call-bind: 1.0.7 + has-bigints: 1.0.2 + has-symbols: 1.0.3 + which-boxed-primitive: 1.0.2 + dev: false + /uncrypto@0.1.3: resolution: {integrity: sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==} dev: false @@ -2311,7 +3957,7 @@ packages: consola: 3.2.3 defu: 6.1.4 mime: 3.0.0 - node-fetch-native: 1.6.2 + node-fetch-native: 1.6.4 pathe: 1.1.2 dev: false @@ -2319,21 +3965,27 @@ packages: resolution: {integrity: sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==} dev: false - /unstorage@1.10.1(idb-keyval@6.2.1): - resolution: {integrity: sha512-rWQvLRfZNBpF+x8D3/gda5nUCQL2PgXy2jNG4U7/Rc9BGEv9+CAJd0YyGCROUBKs9v49Hg8huw3aih5Bf5TAVw==} + /universalify@0.1.2: + resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} + engines: {node: '>= 4.0.0'} + dev: false + + /unstorage@1.10.2(idb-keyval@6.2.1): + resolution: {integrity: sha512-cULBcwDqrS8UhlIysUJs2Dk0Mmt8h7B0E6mtR+relW9nZvsf/u4SkAYyNliPiPW7XtFNb5u3IUMkxGxFTTRTgQ==} peerDependencies: - '@azure/app-configuration': ^1.4.1 + '@azure/app-configuration': ^1.5.0 '@azure/cosmos': ^4.0.0 '@azure/data-tables': ^13.2.2 - '@azure/identity': ^3.3.2 - '@azure/keyvault-secrets': ^4.7.0 - '@azure/storage-blob': ^12.16.0 - '@capacitor/preferences': ^5.0.6 - '@netlify/blobs': ^6.2.0 - '@planetscale/database': ^1.11.0 - '@upstash/redis': ^1.23.4 - '@vercel/kv': ^0.2.3 + '@azure/identity': ^4.0.1 + '@azure/keyvault-secrets': ^4.8.0 + '@azure/storage-blob': ^12.17.0 + '@capacitor/preferences': ^5.0.7 + '@netlify/blobs': ^6.5.0 || ^7.0.0 + '@planetscale/database': ^1.16.0 + '@upstash/redis': ^1.28.4 + '@vercel/kv': ^1.0.1 idb-keyval: ^6.2.1 + ioredis: ^5.3.2 peerDependenciesMeta: '@azure/app-configuration': optional: true @@ -2359,21 +4011,21 @@ packages: optional: true idb-keyval: optional: true + ioredis: + optional: true dependencies: anymatch: 3.1.3 chokidar: 3.6.0 destr: 2.0.3 h3: 1.11.1 idb-keyval: 6.2.1 - ioredis: 5.3.2 listhen: 1.7.2 - lru-cache: 10.2.0 + lru-cache: 10.2.2 mri: 1.2.0 - node-fetch-native: 1.6.2 - ofetch: 1.3.3 - ufo: 1.4.0 + node-fetch-native: 1.6.4 + ofetch: 1.3.4 + ufo: 1.5.3 transitivePeerDependencies: - - supports-color - uWebSockets.js dev: false @@ -2390,27 +4042,42 @@ packages: resolution: {integrity: sha512-MJu7ypHq6QasgF5YRTjqscSzQp/W11zoUk6kvmlH+fmWEs63Y0Eib13hYFwAzagRJcVY8WVnlV+eBDUGMJ5IbA==} dev: false - /use-debounce@10.0.0(react@18.2.0): + /use-debounce@10.0.0(react@18.3.1): resolution: {integrity: sha512-XRjvlvCB46bah9IBXVnq/ACP2lxqXyZj0D9hj4K5OzNroMDpTEBg8Anuh1/UfRTRs7pLhQ+RiNxxwZu9+MVl1A==} engines: {node: '>= 16.0.0'} peerDependencies: react: '>=16.8.0' dependencies: - react: 18.2.0 + react: 18.3.1 dev: false - /use-sync-external-store@1.2.0(react@18.2.0): + /use-sync-external-store@1.2.0(react@18.3.1): resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==} peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 dependencies: - react: 18.2.0 + react: 18.3.1 + dev: false + + /use-sync-external-store@1.2.2(react@18.3.1): + resolution: {integrity: sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + dependencies: + react: 18.3.1 /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: false - /valtio@1.11.2(@types/react@18.2.58)(react@18.2.0): + /validate-npm-package-license@3.0.4: + resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} + dependencies: + spdx-correct: 3.2.0 + spdx-expression-parse: 3.0.1 + dev: false + + /valtio@1.11.2(@types/react@18.3.1)(react@18.3.1): resolution: {integrity: sha512-1XfIxnUXzyswPAPXo1P3Pdx2mq/pIqZICkWN60Hby0d9Iqb+MEIpqgYVlbflvHdrp2YR/q3jyKWRPJJ100yxaw==} engines: {node: '>=12.20.0'} peerDependencies: @@ -2422,14 +4089,14 @@ packages: react: optional: true dependencies: - '@types/react': 18.2.58 + '@types/react': 18.3.1 proxy-compare: 2.5.1 - react: 18.2.0 - use-sync-external-store: 1.2.0(react@18.2.0) + react: 18.3.1 + use-sync-external-store: 1.2.0(react@18.3.1) dev: false - /vite@5.1.4(@types/node@18.19.18): - resolution: {integrity: sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==} + /vite@5.2.11(@types/node@18.19.33): + resolution: {integrity: sha512-HndV31LWW05i1BLPMUCE1B9E9GFbOu1MbenhS58FuK6owSO5qHm7GiCotrNY1YE5rMeQSFBGmT5ZaLEjFizgiQ==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -2456,14 +4123,20 @@ packages: terser: optional: true dependencies: - '@types/node': 18.19.18 - esbuild: 0.19.12 - postcss: 8.4.35 - rollup: 4.12.0 + '@types/node': 18.19.33 + esbuild: 0.20.2 + postcss: 8.4.38 + rollup: 4.17.2 optionalDependencies: fsevents: 2.3.3 dev: true + /wcwidth@1.0.1: + resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + dependencies: + defaults: 1.0.4 + dev: false + /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: false @@ -2475,10 +4148,46 @@ packages: webidl-conversions: 3.0.1 dev: false + /which-boxed-primitive@1.0.2: + resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} + dependencies: + is-bigint: 1.0.4 + is-boolean-object: 1.1.2 + is-number-object: 1.0.7 + is-string: 1.0.7 + is-symbol: 1.0.4 + dev: false + /which-module@2.0.1: resolution: {integrity: sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==} dev: false + /which-pm@2.0.0: + resolution: {integrity: sha512-Lhs9Pmyph0p5n5Z3mVnN0yWcbQYUAD7rbQUiMsQxOJ3T57k7RFe35SUwWMf7dsbDZks1uOmw4AecB/JMDj3v/w==} + engines: {node: '>=8.15'} + dependencies: + load-yaml-file: 0.2.0 + path-exists: 4.0.0 + dev: false + + /which-typed-array@1.1.15: + resolution: {integrity: sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.7 + for-each: 0.3.3 + gopd: 1.0.1 + has-tostringtag: 1.0.2 + dev: false + + /which@1.3.1: + resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==} + hasBin: true + dependencies: + isexe: 2.0.0 + dev: false + /which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -2496,6 +4205,15 @@ packages: strip-ansi: 6.0.1 dev: false + /wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + dev: false + /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: false @@ -2513,8 +4231,8 @@ packages: optional: true dev: false - /ws@8.16.0: - resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==} + /ws@8.17.0: + resolution: {integrity: sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 @@ -2530,6 +4248,15 @@ packages: resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==} dev: false + /y18n@5.0.8: + resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} + engines: {node: '>=10'} + dev: false + + /yallist@2.1.2: + resolution: {integrity: sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==} + dev: false + /yargs-parser@18.1.3: resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==} engines: {node: '>=6'} @@ -2538,6 +4265,11 @@ packages: decamelize: 1.2.0 dev: false + /yargs-parser@21.1.1: + resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} + engines: {node: '>=12'} + dev: false + /yargs@15.4.1: resolution: {integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==} engines: {node: '>=8'} @@ -2555,12 +4287,30 @@ packages: yargs-parser: 18.1.3 dev: false + /yargs@17.7.2: + resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} + engines: {node: '>=12'} + dependencies: + cliui: 8.0.1 + escalade: 3.1.2 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 21.1.1 + dev: false + + /yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + dev: false + /zod@3.21.1: resolution: {integrity: sha512-+dTu2m6gmCbO9Ahm4ZBDapx2O6ZY9QSPXst2WXjcznPMwf2YNpn3RevLx4KkZp1OPW/ouFcoBtBzFz/LeY69oA==} dev: false - /zustand@4.5.1(@types/react@18.2.58)(immer@9.0.21)(react@18.2.0): - resolution: {integrity: sha512-XlauQmH64xXSC1qGYNv00ODaQ3B+tNPoy22jv2diYiP4eoDKr9LA+Bh5Bc3gplTrFdb6JVI+N4kc1DZ/tbtfPg==} + /zustand@4.5.2(@types/react@18.3.1)(immer@9.0.21)(react@18.3.1): + resolution: {integrity: sha512-2cN1tPkDVkwCy5ickKrI7vijSjPksFRfqS6237NzT0vqSsztTNnQdHw9mmN7uBdk3gceVXU0a+21jFzFzAc9+g==} engines: {node: '>=12.7.0'} peerDependencies: '@types/react': '>=16.8' @@ -2574,8 +4324,8 @@ packages: react: optional: true dependencies: - '@types/react': 18.2.58 + '@types/react': 18.3.1 immer: 9.0.21 - react: 18.2.0 - use-sync-external-store: 1.2.0(react@18.2.0) + react: 18.3.1 + use-sync-external-store: 1.2.0(react@18.3.1) dev: false