kana-widget-v2
Version:
Kana Widget for cross-chain bridging and swap.
1,199 lines • 2.1 MB
JavaScript
import { jsx as _, Fragment as ri, jsxs as Se } from "react/jsx-runtime";
import { ConnectionProvider as t4, WalletProvider as r4, useWallet as Bf } from "@solana/wallet-adapter-react";
import { PhantomWalletAdapter as i4, SolflareWalletAdapter as n4, NightlyWalletAdapter as a4, CloverWalletAdapter as s4, Coin98WalletAdapter as o4, SolongWalletAdapter as f4, TorusWalletAdapter as l4 } from "@solana/wallet-adapter-wallets";
import * as Lr from "react";
import sr, { useMemo as kr, createContext as qi, forwardRef as Fn, useCallback as Ui, useState as Bt, useContext as Ai, useEffect as Ht, useRef as er, useLayoutEffect as c4, Fragment as Ca, isValidElement as u4, cloneElement as h4, createElement as d4, useReducer as l3, createRef as nh, useSyncExternalStore as c3, useImperativeHandle as p4 } from "react";
import { NetworkId as D, BridgeId as oi, Environment as m4, SwapAggregator as Ks, subscribeEvents as n0, eventId as a0 } from "@kanalabs/aggregator";
import { notification as v4, ConfigProvider as Wh, Tooltip as Bi, Tour as g4 } from "antd";
import { FewchaWallet as b4 } from "fewcha-plugin-wallet-adapter";
import { PontemWallet as w4 } from "@pontem/wallet-adapter-plugin";
import { RiseWallet as y4 } from "@rise-wallet/wallet-adapter";
import { MartianWallet as A4 } from "@martianwallet/aptos-wallet-adapter";
import { PetraWallet as x4 } from "petra-plugin-wallet-adapter";
import { BCS as _h, TxnBuilderTypes as u3, HexString as r2 } from "aptos";
import { Serializable as Gh, AccountAddress as Fr, Ed25519PublicKey as cn, SigningScheme as cr, MultiEd25519PublicKey as Yn, AnyPublicKey as Dn, MultiKey as Pa, Ed25519PrivateKey as ah, TransactionPayload as h3, Network as Wr, Serializer as Fa, Deserializer as ta, Hex as Oa, deserializeFromScriptArgument as M4, AccountAuthenticator as Pf, NetworkToChainId as sh, parseTypeTag as S4, TypeTag as oh, FixedBytes as k4, RawTransaction as d3, Ed25519Signature as ws, MultiEd25519Signature as Kh, AnySignature as If, AptosConfig as Rn, generateRawTransaction as p3, FeePayerRawTransaction as E4, generateTransactionPayload as uf, generateTransactionPayloadWithABI as C4, NetworkToNodeAPI as fh, Aptos as Gn, Secp256k1PublicKey as N4, Secp256k1Signature as B4, AccountAuthenticatorSingleKey as P4, SimpleTransaction as I4, AccountAuthenticatorEd25519 as D4, AnyPublicKeyVariant as R4, EphemeralKeyPair as Zh } from "@aptos-labs/ts-sdk";
import ja, { isAxiosError as i2, AxiosError as T4 } from "axios";
import { MizuWallet as L4 } from "@mizuwallet-sdk/aptos-wallet-adapter";
import { QueryClient as F4, QueryClientProvider as O4, useQuery as Ki } from "@tanstack/react-query";
import { ReactQueryDevtools as j4 } from "@tanstack/react-query-devtools";
import { initReactI18next as z4, I18nextProvider as U4 } from "react-i18next";
import { JsonRpcProvider as lh, Connection as n2, localnetConnection as J4, Ed25519Keypair as q4, RawSigner as H4 } from "@mysten/sui.js";
import { Connection as a2, PublicKey as s0, LAMPORTS_PER_SOL as s2 } from "@solana/web3.js";
import { ethers as rr } from "ethers";
import { HttpLink as V4, ApolloClient as W4, InMemoryCache as _4, gql as G4 } from "@apollo/client";
import { useConnect as K4, useDisconnect as Z4, useAccount as Df, useNetwork as m3, useSwitchNetwork as v3, useProvider as g3, useSigner as X4, configureChains as Y4, mainnet as Q4, createClient as $4, WagmiConfig as e5 } from "wagmi";
import { getProvider as li, fetchSigner as Rr } from "@wagmi/core";
import { create as Xh } from "zustand";
import { devtools as t5 } from "zustand/middleware";
import { immer as r5 } from "zustand/middleware/immer";
import { createPortal as i5 } from "react-dom";
import { useMediaQuery as n5 } from "react-responsive";
import { ClipLoader as a5, BeatLoader as b3 } from "react-spinners";
import fl from "react-select";
import { polygon as s5, bsc as o5, arbitrum as f5, avalanche as l5, zkSync as c5 } from "wagmi/chains";
import { publicProvider as u5 } from "wagmi/providers/public";
import { CoinbaseWalletConnector as h5 } from "wagmi/connectors/coinbaseWallet";
import { MetaMaskConnector as d5 } from "wagmi/connectors/metaMask";
import './index.css';const Ia = "data:image/svg+xml,%3csvg%20width='60'%20height='60'%20viewBox='0%200%2051%2050'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='25.682'%20cy='25'%20fill='%23000'%20r='25'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M14.39%2012.317c.209-.2.484-.317.768-.317h26.476c.483%200%20.725.584.383.926l-5.23%205.23c-.2.2-.475.317-.767.317H9.544a.542.542%200%200%201-.384-.926l5.23-5.23Zm0%2019.527c.2-.2.476-.317.768-.317h26.476c.483%200%20.725.584.383.926l-5.23%205.23c-.2.2-.475.317-.767.317H9.544a.542.542%200%200%201-.384-.926l5.23-5.23ZM36.02%2021.7c.292%200%20.567.117.767.317l5.23%205.23c.342.342.1.926-.384.926H15.158c-.292%200-.567-.117-.768-.317l-5.23-5.23a.542.542%200%200%201%20.384-.926H36.02Z'%20fill='url(%23a)'/%3e%3cdefs%3e%3clinearGradient%20id='a'%20x1='35.073'%20y1='6.771'%20x2='16.749'%20y2='41.868'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%2300FFA3'/%3e%3cstop%20offset='1'%20stop-color='%23DC1FFF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e", Ni = "data:image/svg+xml,%3csvg%20id='aptos-icon'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2074.67%2074.96'%20class='w-28'%3e%3ccircle%20cx='37.335'%20cy='37.48'%20r='37.335'%20fill='white'%3e%3c/circle%3e%3cpath%20d='M57.84,25.08H51.23a2.67,2.67,0,0,1-2-.91l-2.68-3a2.12,2.12,0,0,0-3.15,0l-2.3,2.6a4,4,0,0,1-3,1.34H2a37.24,37.24,0,0,0-2,9.25H34.13a2.21,2.21,0,0,0,1.59-.68l3.18-3.32a2.13,2.13,0,0,1,1.52-.64h.13a2.05,2.05,0,0,1,1.57.71l2.68,3a2.69,2.69,0,0,0,2,.91H74.67a36.79,36.79,0,0,0-2-9.25H57.84Z'%3e%3c/path%3e%3cpath%20d='M20.65,53.78a2.17,2.17,0,0,0,1.59-.68l3.18-3.31a2.1,2.1,0,0,1,1.52-.65h.13a2.12,2.12,0,0,1,1.58.71l2.68,3a2.7,2.7,0,0,0,2,.9H71.09a37.09,37.09,0,0,0,3.07-9.34H37.92a2.67,2.67,0,0,1-2-.91l-2.68-3a2.1,2.1,0,0,0-3.15,0l-2.3,2.59a4,4,0,0,1-3,1.34H.51a37.5,37.5,0,0,0,3.07,9.34Z'%3e%3c/path%3e%3cpath%20d='M47.44,15A2.23,2.23,0,0,0,49,14.29L52.21,11a2.09,2.09,0,0,1,1.52-.64h.13a2.09,2.09,0,0,1,1.57.7l2.68,3a2.67,2.67,0,0,0,2,.91H67.3A37.48,37.48,0,0,0,7.37,15Z'%3e%3c/path%3e%3cpath%20d='M33,63H23.2a2.7,2.7,0,0,1-2-.9l-2.68-3a2.1,2.1,0,0,0-3.15,0l-2.3,2.6a4,4,0,0,1-3,1.33H9.94a37.44,37.44,0,0,0,54.79,0Z'%3e%3c/path%3e%3c/svg%3e", Qn = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='60'%20height='60'%20fill='none'%20viewBox='0%200%2060%2060'%3e%3cpath%20cx='512'%20cy='512'%20r='512'%20fill='%238247E5'%20d='M60%2030A30%2030%200%200%201%2030%2060A30%2030%200%200%201%200%2030A30%2030%200%200%201%2060%2030z'/%3e%3cpath%20fill='%23fff'%20d='M39.93%2023.581c-0.72%20-0.419%20-1.655%20-0.419%20-2.446%200l-5.613%203.209%20-3.814%202.093%20-5.613%203.209c-0.72%200.419%20-1.655%200.419%20-2.447%200l-4.461%20-2.512c-0.72%20-0.419%20-1.223%20-1.186%20-1.223%20-2.023v-4.953c0%20-0.837%200.432%20-1.605%201.223%20-2.023l4.389%20-2.442c0.72%20-0.419%201.655%20-0.419%202.447%200l4.389%202.442c0.72%200.419%201.223%201.186%201.223%202.023v3.209l3.814%20-2.163v-3.209c0%20-0.837%20-0.432%20-1.605%20-1.223%20-2.023l-8.131%20-4.605c-0.72%20-0.419%20-1.655%20-0.419%20-2.447%200l-8.275%204.605c-0.792%200.419%20-1.223%201.186%20-1.223%202.023v9.279c0%200.837%200.432%201.605%201.223%202.023l8.275%204.605c0.72%200.419%201.655%200.419%202.447%200l5.613%20-3.14%203.814%20-2.163%205.613%20-3.14c0.72%20-0.419%201.655%20-0.419%202.446%200l4.389%202.442c0.72%200.419%201.223%201.186%201.223%202.023v4.953c0%200.837%20-0.432%201.605%20-1.223%202.023l-4.389%202.512c-0.72%200.419%20-1.655%200.419%20-2.446%200l-4.389%20-2.442c-0.72%20-0.419%20-1.223%20-1.186%20-1.223%20-2.023v-3.209l-3.814%202.163v3.209c0%200.837%200.432%201.605%201.223%202.023l8.275%204.605c0.72%200.419%201.655%200.419%202.446%200l8.275%20-4.605c0.72%20-0.419%201.223%20-1.186%201.223%20-2.023V30.279c0%20-0.837%20-0.432%20-1.605%20-1.223%20-2.023l-8.347%20-4.674Z'/%3e%3c/svg%3e", p5 = "https://api.mainnet-beta.solana.com";
D.solana, D.aptos, D.polygon;
var et = /* @__PURE__ */ ((t) => (t.Success = "success", t.Error = "error", t.Info = "info", t.Warning = "warning", t.Open = "open", t))(et || {});
const Rf = () => {
const [t, a] = v4.useNotification();
return { showNotification: (o, c) => {
const { message: i, description: d, duration: p } = c;
t[o]({
message: i,
description: d,
duration: p,
placement: "bottomRight"
});
}, contextHolder: a };
}, m5 = (t) => {
const { showNotification: a, contextHolder: f } = Rf(), o = kr(() => [
new i4(),
new n4(),
new a4(),
new s4(),
new o4(),
new f4(),
new l4()
], []);
return /* @__PURE__ */ _(ri, { children: /* @__PURE__ */ Se(
Wh,
{
theme: {
components: {
Notification: {
borderRadiusLG: 20,
colorText: "rgba(255, 255, 255, 0.88)",
colorTextHeading: "rgba(255, 255, 255, 0.88)",
colorIcon: "rgba(255, 255, 255, 0.45)",
colorBgElevated: "rgb(23, 24, 26)",
colorIconHover: "rgba(255, 255, 255, 0.88)"
}
}
},
children: [
f,
/* @__PURE__ */ _(t4, { endpoint: p5, children: /* @__PURE__ */ _(
r4,
{
wallets: o,
autoConnect: !0,
onError: (c) => {
if (c.toString() === "WalletSignTransactionError: User rejected the request." || c.toString() === "WalletSignTransactionError: Approval Denied" || c.toString() === "WalletSignTransactionError: Failed to sign transaction" || c.toString() === "WalletSignTransactionError: You canceled the transaction.")
throw new Error("User Rejected the request");
(c.toString() === "WalletConnectionError: User rejected the request." || c.name === "WalletConnectionError" || c.name === "WalletAccountError" || c.toString() === "WalletConnectionError: You canceled this request.") && a(et.Error, {
message: "User has rejected the connection"
});
},
children: t == null ? void 0 : t.children
}
) })
]
}
) });
};
var hr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Yh(t) {
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
function v5(t) {
if (t.__esModule) return t;
var a = t.default;
if (typeof a == "function") {
var f = function o() {
return this instanceof o ? Reflect.construct(a, arguments, this.constructor) : a.apply(this, arguments);
};
f.prototype = a.prototype;
} else f = {};
return Object.defineProperty(f, "__esModule", { value: !0 }), Object.keys(t).forEach(function(o) {
var c = Object.getOwnPropertyDescriptor(t, o);
Object.defineProperty(f, o, c.get ? c : {
enumerable: !0,
get: function() {
return t[o];
}
});
}), f;
}
var ll = { exports: {} }, o2;
function g5() {
return o2 || (o2 = 1, function(t) {
var a = Object.prototype.hasOwnProperty, f = "~";
function o() {
}
Object.create && (o.prototype = /* @__PURE__ */ Object.create(null), new o().__proto__ || (f = !1));
function c(g, w, m) {
this.fn = g, this.context = w, this.once = m || !1;
}
function i(g, w, m, x, M) {
if (typeof m != "function")
throw new TypeError("The listener must be a function");
var S = new c(m, x || g, M), k = f ? f + w : w;
return g._events[k] ? g._events[k].fn ? g._events[k] = [g._events[k], S] : g._events[k].push(S) : (g._events[k] = S, g._eventsCount++), g;
}
function d(g, w) {
--g._eventsCount === 0 ? g._events = new o() : delete g._events[w];
}
function p() {
this._events = new o(), this._eventsCount = 0;
}
p.prototype.eventNames = function() {
var w = [], m, x;
if (this._eventsCount === 0) return w;
for (x in m = this._events)
a.call(m, x) && w.push(f ? x.slice(1) : x);
return Object.getOwnPropertySymbols ? w.concat(Object.getOwnPropertySymbols(m)) : w;
}, p.prototype.listeners = function(w) {
var m = f ? f + w : w, x = this._events[m];
if (!x) return [];
if (x.fn) return [x.fn];
for (var M = 0, S = x.length, k = new Array(S); M < S; M++)
k[M] = x[M].fn;
return k;
}, p.prototype.listenerCount = function(w) {
var m = f ? f + w : w, x = this._events[m];
return x ? x.fn ? 1 : x.length : 0;
}, p.prototype.emit = function(w, m, x, M, S, k) {
var E = f ? f + w : w;
if (!this._events[E]) return !1;
var P = this._events[E], B = arguments.length, I, F;
if (P.fn) {
switch (P.once && this.removeListener(w, P.fn, void 0, !0), B) {
case 1:
return P.fn.call(P.context), !0;
case 2:
return P.fn.call(P.context, m), !0;
case 3:
return P.fn.call(P.context, m, x), !0;
case 4:
return P.fn.call(P.context, m, x, M), !0;
case 5:
return P.fn.call(P.context, m, x, M, S), !0;
case 6:
return P.fn.call(P.context, m, x, M, S, k), !0;
}
for (F = 1, I = new Array(B - 1); F < B; F++)
I[F - 1] = arguments[F];
P.fn.apply(P.context, I);
} else {
var U = P.length, ie;
for (F = 0; F < U; F++)
switch (P[F].once && this.removeListener(w, P[F].fn, void 0, !0), B) {
case 1:
P[F].fn.call(P[F].context);
break;
case 2:
P[F].fn.call(P[F].context, m);
break;
case 3:
P[F].fn.call(P[F].context, m, x);
break;
case 4:
P[F].fn.call(P[F].context, m, x, M);
break;
default:
if (!I) for (ie = 1, I = new Array(B - 1); ie < B; ie++)
I[ie - 1] = arguments[ie];
P[F].fn.apply(P[F].context, I);
}
}
return !0;
}, p.prototype.on = function(w, m, x) {
return i(this, w, m, x, !1);
}, p.prototype.once = function(w, m, x) {
return i(this, w, m, x, !0);
}, p.prototype.removeListener = function(w, m, x, M) {
var S = f ? f + w : w;
if (!this._events[S]) return this;
if (!m)
return d(this, S), this;
var k = this._events[S];
if (k.fn)
k.fn === m && (!M || k.once) && (!x || k.context === x) && d(this, S);
else {
for (var E = 0, P = [], B = k.length; E < B; E++)
(k[E].fn !== m || M && !k[E].once || x && k[E].context !== x) && P.push(k[E]);
P.length ? this._events[S] = P.length === 1 ? P[0] : P : d(this, S);
}
return this;
}, p.prototype.removeAllListeners = function(w) {
var m;
return w ? (m = f ? f + w : w, this._events[m] && d(this, m)) : (this._events = new o(), this._eventsCount = 0), this;
}, p.prototype.off = p.prototype.removeListener, p.prototype.addListener = p.prototype.on, p.prefixed = f, p.EventEmitter = p, t.exports = p;
}(ll)), ll.exports;
}
var b5 = g5();
const w3 = /* @__PURE__ */ Yh(b5);
var w5 = "aptos:signAndSubmitTransaction", y5 = "aptos:signMessage", A5 = "aptos:signTransaction", x5 = "aptos:connect", M5 = "aptos:disconnect", S5 = "aptos:account", k5 = "aptos:network", E5 = "aptos:onAccountChange", C5 = "aptos:onNetworkChange", y3 = class A3 extends Gh {
constructor({ address: a, publicKey: f, ansName: o }) {
super(), this.address = Fr.from(a), this.publicKey = f, this.ansName = o;
}
serialize(a) {
if (this.address.serialize(a), this.publicKey instanceof cn) a.serializeU32AsUleb128(cr.Ed25519);
else if (this.publicKey instanceof Yn) a.serializeU32AsUleb128(cr.MultiEd25519);
else if (this.publicKey instanceof Dn) a.serializeU32AsUleb128(cr.SingleKey);
else if (this.publicKey instanceof Pa) a.serializeU32AsUleb128(cr.MultiKey);
else throw new Error("Unsupported public key");
this.publicKey.serialize(a), a.serializeStr(this.ansName ?? "");
}
static deserialize(a) {
let f = Fr.deserialize(a), o = a.deserializeUleb128AsU32(), c;
switch (o) {
case cr.Ed25519:
c = cn.deserialize(a);
break;
case cr.MultiEd25519:
c = Yn.deserialize(a);
break;
case cr.SingleKey:
c = Dn.deserialize(a);
break;
case cr.MultiKey:
c = Pa.deserialize(a);
break;
default:
throw new Error(`Unknown variant index for WrappedPublicKey: ${o}`);
}
let i = a.deserializeStr() || void 0;
return new A3({ address: f, publicKey: c, ansName: i });
}
}, N5 = "aptos:devnet", B5 = "aptos:testnet", P5 = "aptos:localnet", I5 = "aptos:mainnet", x3 = [N5, B5, P5, I5], D5 = function(t, a, f, o) {
if (f === "a" && !o) throw new TypeError("Private accessor was defined without a getter");
if (typeof a == "function" ? t !== a || !o : !a.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return f === "m" ? o : f === "a" ? o.call(t) : o ? o.value : a.get(t);
}, R5 = function(t, a, f, o, c) {
if (o === "m") throw new TypeError("Private method is not writable");
if (o === "a" && !c) throw new TypeError("Private accessor was defined without a setter");
if (typeof a == "function" ? t !== a || !c : !a.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return o === "a" ? c.call(t, f) : c ? c.value = f : a.set(t, f), f;
}, j0;
let Zs;
const Tf = /* @__PURE__ */ new Set();
function T5(t) {
fo = void 0, Tf.add(t);
}
function L5(t) {
fo = void 0, Tf.delete(t);
}
const ps = {};
function M3() {
if (Zs || (Zs = Object.freeze({ register: f2, get: F5, on: O5 }), typeof window > "u"))
return Zs;
const t = Object.freeze({ register: f2 });
try {
window.addEventListener("wallet-standard:register-wallet", ({ detail: a }) => a(t));
} catch (a) {
console.error(`wallet-standard:register-wallet event listener could not be added
`, a);
}
try {
window.dispatchEvent(new j5(t));
} catch (a) {
console.error(`wallet-standard:app-ready event could not be dispatched
`, a);
}
return Zs;
}
function f2(...t) {
var a;
return t = t.filter((f) => !Tf.has(f)), t.length ? (t.forEach((f) => T5(f)), (a = ps.register) == null || a.forEach((f) => l2(() => f(...t))), function() {
var o;
t.forEach((c) => L5(c)), (o = ps.unregister) == null || o.forEach((c) => l2(() => c(...t)));
}) : () => {
};
}
let fo;
function F5() {
return fo || (fo = [...Tf]), fo;
}
function O5(t, a) {
var f;
return (f = ps[t]) != null && f.push(a) || (ps[t] = [a]), function() {
var c;
ps[t] = (c = ps[t]) == null ? void 0 : c.filter((i) => a !== i);
};
}
function l2(t) {
try {
t();
} catch (a) {
console.error(a);
}
}
class j5 extends Event {
get detail() {
return D5(this, j0, "f");
}
get type() {
return "wallet-standard:app-ready";
}
constructor(a) {
super("wallet-standard:app-ready", {
bubbles: !1,
cancelable: !1,
composed: !1
}), j0.set(this, void 0), R5(this, j0, a, "f");
}
/** @deprecated */
preventDefault() {
throw new Error("preventDefault cannot be called");
}
/** @deprecated */
stopImmediatePropagation() {
throw new Error("stopImmediatePropagation cannot be called");
}
/** @deprecated */
stopPropagation() {
throw new Error("stopPropagation cannot be called");
}
}
j0 = /* @__PURE__ */ new WeakMap();
function z5(t) {
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var S3 = { exports: {} }, qr = S3.exports = {}, rn, nn;
function ch() {
throw new Error("setTimeout has not been defined");
}
function uh() {
throw new Error("clearTimeout has not been defined");
}
(function() {
try {
typeof setTimeout == "function" ? rn = setTimeout : rn = ch;
} catch {
rn = ch;
}
try {
typeof clearTimeout == "function" ? nn = clearTimeout : nn = uh;
} catch {
nn = uh;
}
})();
function k3(t) {
if (rn === setTimeout)
return setTimeout(t, 0);
if ((rn === ch || !rn) && setTimeout)
return rn = setTimeout, setTimeout(t, 0);
try {
return rn(t, 0);
} catch {
try {
return rn.call(null, t, 0);
} catch {
return rn.call(this, t, 0);
}
}
}
function U5(t) {
if (nn === clearTimeout)
return clearTimeout(t);
if ((nn === uh || !nn) && clearTimeout)
return nn = clearTimeout, clearTimeout(t);
try {
return nn(t);
} catch {
try {
return nn.call(null, t);
} catch {
return nn.call(this, t);
}
}
}
var Cn = [], gs = !1, Sa, z0 = -1;
function J5() {
!gs || !Sa || (gs = !1, Sa.length ? Cn = Sa.concat(Cn) : z0 = -1, Cn.length && E3());
}
function E3() {
if (!gs) {
var t = k3(J5);
gs = !0;
for (var a = Cn.length; a; ) {
for (Sa = Cn, Cn = []; ++z0 < a; )
Sa && Sa[z0].run();
z0 = -1, a = Cn.length;
}
Sa = null, gs = !1, U5(t);
}
}
qr.nextTick = function(t) {
var a = new Array(arguments.length - 1);
if (arguments.length > 1)
for (var f = 1; f < arguments.length; f++)
a[f - 1] = arguments[f];
Cn.push(new C3(t, a)), Cn.length === 1 && !gs && k3(E3);
};
function C3(t, a) {
this.fun = t, this.array = a;
}
C3.prototype.run = function() {
this.fun.apply(null, this.array);
};
qr.title = "browser";
qr.browser = !0;
qr.env = {};
qr.argv = [];
qr.version = "";
qr.versions = {};
function On() {
}
qr.on = On;
qr.addListener = On;
qr.once = On;
qr.off = On;
qr.removeListener = On;
qr.removeAllListeners = On;
qr.emit = On;
qr.prependListener = On;
qr.prependOnceListener = On;
qr.listeners = function(t) {
return [];
};
qr.binding = function(t) {
throw new Error("process.binding is not supported");
};
qr.cwd = function() {
return "/";
};
qr.chdir = function(t) {
throw new Error("process.chdir is not supported");
};
qr.umask = function() {
return 0;
};
var q5 = S3.exports;
const Ut = /* @__PURE__ */ z5(q5);
var H5 = function(t, a, f, o) {
if (f === "a" && !o) throw new TypeError("Private accessor was defined without a getter");
if (typeof a == "function" ? t !== a || !o : !a.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return f === "m" ? o : f === "a" ? o.call(t) : o ? o.value : a.get(t);
}, V5 = function(t, a, f, o, c) {
if (o === "m") throw new TypeError("Private method is not writable");
if (o === "a" && !c) throw new TypeError("Private accessor was defined without a setter");
if (typeof a == "function" ? t !== a || !c : !a.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return o === "a" ? c.call(t, f) : c ? c.value = f : a.set(t, f), f;
}, U0;
function W5(t) {
const a = ({ register: f }) => f(t);
try {
window.dispatchEvent(new _5(a));
} catch (f) {
console.error(`wallet-standard:register-wallet event could not be dispatched
`, f);
}
try {
window.addEventListener("wallet-standard:app-ready", ({ detail: f }) => a(f));
} catch (f) {
console.error(`wallet-standard:app-ready event listener could not be added
`, f);
}
}
class _5 extends Event {
get detail() {
return H5(this, U0, "f");
}
get type() {
return "wallet-standard:register-wallet";
}
constructor(a) {
super("wallet-standard:register-wallet", {
bubbles: !1,
cancelable: !1,
composed: !1
}), U0.set(this, void 0), V5(this, U0, a, "f");
}
/** @deprecated */
preventDefault() {
throw new Error("preventDefault cannot be called");
}
/** @deprecated */
stopImmediatePropagation() {
throw new Error("stopImmediatePropagation cannot be called");
}
/** @deprecated */
stopPropagation() {
throw new Error("stopPropagation cannot be called");
}
}
U0 = /* @__PURE__ */ new WeakMap();
var ts = function(t, a, f, o) {
if (f === "a" && !o) throw new TypeError("Private accessor was defined without a getter");
if (typeof a == "function" ? t !== a || !o : !a.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return f === "m" ? o : f === "a" ? o.call(t) : o ? o.value : a.get(t);
}, rs = function(t, a, f, o, c) {
if (o === "m") throw new TypeError("Private method is not writable");
if (o === "a" && !c) throw new TypeError("Private accessor was defined without a setter");
if (typeof a == "function" ? t !== a || !c : !a.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return o === "a" ? c.call(t, f) : c ? c.value = f : a.set(t, f), f;
}, J0, q0, H0, V0, W0, _0;
class Qh {
/** Implementation of {@link "@wallet-standard/base".WalletAccount.address | WalletAccount::address} */
get address() {
return ts(this, J0, "f");
}
/** Implementation of {@link "@wallet-standard/base".WalletAccount.publicKey | WalletAccount::publicKey} */
get publicKey() {
return ts(this, q0, "f").slice();
}
/** Implementation of {@link "@wallet-standard/base".WalletAccount.chains | WalletAccount::chains} */
get chains() {
return ts(this, H0, "f").slice();
}
/** Implementation of {@link "@wallet-standard/base".WalletAccount.features | WalletAccount::features} */
get features() {
return ts(this, V0, "f").slice();
}
/** Implementation of {@link "@wallet-standard/base".WalletAccount.label | WalletAccount::label} */
get label() {
return ts(this, W0, "f");
}
/** Implementation of {@link "@wallet-standard/base".WalletAccount.icon | WalletAccount::icon} */
get icon() {
return ts(this, _0, "f");
}
/**
* Create and freeze a read-only account.
*
* @param account Account to copy properties from.
*/
constructor(a) {
J0.set(this, void 0), q0.set(this, void 0), H0.set(this, void 0), V0.set(this, void 0), W0.set(this, void 0), _0.set(this, void 0), new.target === Qh && Object.freeze(this), rs(this, J0, a.address, "f"), rs(this, q0, a.publicKey.slice(), "f"), rs(this, H0, a.chains.slice(), "f"), rs(this, V0, a.features.slice(), "f"), rs(this, W0, a.label, "f"), rs(this, _0, a.icon, "f");
}
}
J0 = /* @__PURE__ */ new WeakMap(), q0 = /* @__PURE__ */ new WeakMap(), H0 = /* @__PURE__ */ new WeakMap(), V0 = /* @__PURE__ */ new WeakMap(), W0 = /* @__PURE__ */ new WeakMap(), _0 = /* @__PURE__ */ new WeakMap();
var G5 = ["aptos:account", "aptos:connect", "aptos:disconnect", "aptos:network", "aptos:onAccountChange", "aptos:onNetworkChange", "aptos:signMessage", "aptos:signTransaction"];
function N3(t, a = []) {
return [...G5, ...a].every((f) => f in t.features);
}
function cl() {
let { get: t, on: a } = M3(), f = t(), o = [];
return f.map((c) => {
N3(c) && o.push(c);
}), { aptosWallets: o, on: a };
}
var ro = ((t) => (t[t.Unauthorized = 4100] = "Unauthorized", t[t.InternalError = -30001] = "InternalError", t))(ro || {}), c2 = Object.freeze({ 4100: { status: "Unauthorized", message: "The requested method and/or account has not been authorized by the user." }, [-30001]: { status: "Internal error", message: "Something went wrong within the wallet." } }), o0 = class B3 extends Error {
constructor(a, f) {
var o, c;
super(f ?? ((o = c2[a]) == null ? void 0 : o.message) ?? "Unknown error occurred"), this.code = a, this.status = ((c = c2[a]) == null ? void 0 : c.status) ?? "Unknown error", this.name = "AptosWalletError", Object.setPrototypeOf(this, B3.prototype);
}
}, Xr = ((t) => (t.APPROVED = "Approved", t.REJECTED = "Rejected", t))(Xr || {}), $h = {}, Lf = {};
Lf.byteLength = X5;
Lf.toByteArray = Q5;
Lf.fromByteArray = ty;
var on = [], ji = [], K5 = typeof Uint8Array < "u" ? Uint8Array : Array, ul = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (var is = 0, Z5 = ul.length; is < Z5; ++is)
on[is] = ul[is], ji[ul.charCodeAt(is)] = is;
ji[45] = 62;
ji[95] = 63;
function P3(t) {
var a = t.length;
if (a % 4 > 0)
throw new Error("Invalid string. Length must be a multiple of 4");
var f = t.indexOf("=");
f === -1 && (f = a);
var o = f === a ? 0 : 4 - f % 4;
return [f, o];
}
function X5(t) {
var a = P3(t), f = a[0], o = a[1];
return (f + o) * 3 / 4 - o;
}
function Y5(t, a, f) {
return (a + f) * 3 / 4 - f;
}
function Q5(t) {
var a, f = P3(t), o = f[0], c = f[1], i = new K5(Y5(t, o, c)), d = 0, p = c > 0 ? o - 4 : o, g;
for (g = 0; g < p; g += 4)
a = ji[t.charCodeAt(g)] << 18 | ji[t.charCodeAt(g + 1)] << 12 | ji[t.charCodeAt(g + 2)] << 6 | ji[t.charCodeAt(g + 3)], i[d++] = a >> 16 & 255, i[d++] = a >> 8 & 255, i[d++] = a & 255;
return c === 2 && (a = ji[t.charCodeAt(g)] << 2 | ji[t.charCodeAt(g + 1)] >> 4, i[d++] = a & 255), c === 1 && (a = ji[t.charCodeAt(g)] << 10 | ji[t.charCodeAt(g + 1)] << 4 | ji[t.charCodeAt(g + 2)] >> 2, i[d++] = a >> 8 & 255, i[d++] = a & 255), i;
}
function $5(t) {
return on[t >> 18 & 63] + on[t >> 12 & 63] + on[t >> 6 & 63] + on[t & 63];
}
function ey(t, a, f) {
for (var o, c = [], i = a; i < f; i += 3)
o = (t[i] << 16 & 16711680) + (t[i + 1] << 8 & 65280) + (t[i + 2] & 255), c.push($5(o));
return c.join("");
}
function ty(t) {
for (var a, f = t.length, o = f % 3, c = [], i = 16383, d = 0, p = f - o; d < p; d += i)
c.push(ey(t, d, d + i > p ? p : d + i));
return o === 1 ? (a = t[f - 1], c.push(
on[a >> 2] + on[a << 4 & 63] + "=="
)) : o === 2 && (a = (t[f - 2] << 8) + t[f - 1], c.push(
on[a >> 10] + on[a >> 4 & 63] + on[a << 2 & 63] + "="
)), c.join("");
}
var ed = {};
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
ed.read = function(t, a, f, o, c) {
var i, d, p = c * 8 - o - 1, g = (1 << p) - 1, w = g >> 1, m = -7, x = f ? c - 1 : 0, M = f ? -1 : 1, S = t[a + x];
for (x += M, i = S & (1 << -m) - 1, S >>= -m, m += p; m > 0; i = i * 256 + t[a + x], x += M, m -= 8)
;
for (d = i & (1 << -m) - 1, i >>= -m, m += o; m > 0; d = d * 256 + t[a + x], x += M, m -= 8)
;
if (i === 0)
i = 1 - w;
else {
if (i === g)
return d ? NaN : (S ? -1 : 1) * (1 / 0);
d = d + Math.pow(2, o), i = i - w;
}
return (S ? -1 : 1) * d * Math.pow(2, i - o);
};
ed.write = function(t, a, f, o, c, i) {
var d, p, g, w = i * 8 - c - 1, m = (1 << w) - 1, x = m >> 1, M = c === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, S = o ? 0 : i - 1, k = o ? 1 : -1, E = a < 0 || a === 0 && 1 / a < 0 ? 1 : 0;
for (a = Math.abs(a), isNaN(a) || a === 1 / 0 ? (p = isNaN(a) ? 1 : 0, d = m) : (d = Math.floor(Math.log(a) / Math.LN2), a * (g = Math.pow(2, -d)) < 1 && (d--, g *= 2), d + x >= 1 ? a += M / g : a += M * Math.pow(2, 1 - x), a * g >= 2 && (d++, g /= 2), d + x >= m ? (p = 0, d = m) : d + x >= 1 ? (p = (a * g - 1) * Math.pow(2, c), d = d + x) : (p = a * Math.pow(2, x - 1) * Math.pow(2, c), d = 0)); c >= 8; t[f + S] = p & 255, S += k, p /= 256, c -= 8)
;
for (d = d << c | p, w += c; w > 0; t[f + S] = d & 255, S += k, d /= 256, w -= 8)
;
t[f + S - k] |= E * 128;
};
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
(function(t) {
const a = Lf, f = ed, o = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
t.Buffer = m, t.SlowBuffer = ie, t.INSPECT_MAX_BYTES = 50;
const c = 2147483647;
t.kMaxLength = c;
const { Uint8Array: i, ArrayBuffer: d, SharedArrayBuffer: p } = globalThis;
m.TYPED_ARRAY_SUPPORT = g(), !m.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
);
function g() {
try {
const Y = new i(1), L = { foo: function() {
return 42;
} };
return Object.setPrototypeOf(L, i.prototype), Object.setPrototypeOf(Y, L), Y.foo() === 42;
} catch {
return !1;
}
}
Object.defineProperty(m.prototype, "parent", {
enumerable: !0,
get: function() {
if (m.isBuffer(this))
return this.buffer;
}
}), Object.defineProperty(m.prototype, "offset", {
enumerable: !0,
get: function() {
if (m.isBuffer(this))
return this.byteOffset;
}
});
function w(Y) {
if (Y > c)
throw new RangeError('The value "' + Y + '" is invalid for option "size"');
const L = new i(Y);
return Object.setPrototypeOf(L, m.prototype), L;
}
function m(Y, L, H) {
if (typeof Y == "number") {
if (typeof L == "string")
throw new TypeError(
'The "string" argument must be of type string. Received type number'
);
return k(Y);
}
return x(Y, L, H);
}
m.poolSize = 8192;
function x(Y, L, H) {
if (typeof Y == "string")
return E(Y, L);
if (d.isView(Y))
return B(Y);
if (Y == null)
throw new TypeError(
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof Y
);
if (_e(Y, d) || Y && _e(Y.buffer, d) || typeof p < "u" && (_e(Y, p) || Y && _e(Y.buffer, p)))
return I(Y, L, H);
if (typeof Y == "number")
throw new TypeError(
'The "value" argument must not be of type number. Received type number'
);
const oe = Y.valueOf && Y.valueOf();
if (oe != null && oe !== Y)
return m.from(oe, L, H);
const me = F(Y);
if (me) return me;
if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof Y[Symbol.toPrimitive] == "function")
return m.from(Y[Symbol.toPrimitive]("string"), L, H);
throw new TypeError(
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof Y
);
}
m.from = function(Y, L, H) {
return x(Y, L, H);
}, Object.setPrototypeOf(m.prototype, i.prototype), Object.setPrototypeOf(m, i);
function M(Y) {
if (typeof Y != "number")
throw new TypeError('"size" argument must be of type number');
if (Y < 0)
throw new RangeError('The value "' + Y + '" is invalid for option "size"');
}
function S(Y, L, H) {
return M(Y), Y <= 0 ? w(Y) : L !== void 0 ? typeof H == "string" ? w(Y).fill(L, H) : w(Y).fill(L) : w(Y);
}
m.alloc = function(Y, L, H) {
return S(Y, L, H);
};
function k(Y) {
return M(Y), w(Y < 0 ? 0 : U(Y) | 0);
}
m.allocUnsafe = function(Y) {
return k(Y);
}, m.allocUnsafeSlow = function(Y) {
return k(Y);
};
function E(Y, L) {
if ((typeof L != "string" || L === "") && (L = "utf8"), !m.isEncoding(L))
throw new TypeError("Unknown encoding: " + L);
const H = le(Y, L) | 0;
let oe = w(H);
const me = oe.write(Y, L);
return me !== H && (oe = oe.slice(0, me)), oe;
}
function P(Y) {
const L = Y.length < 0 ? 0 : U(Y.length) | 0, H = w(L);
for (let oe = 0; oe < L; oe += 1)
H[oe] = Y[oe] & 255;
return H;
}
function B(Y) {
if (_e(Y, i)) {
const L = new i(Y);
return I(L.buffer, L.byteOffset, L.byteLength);
}
return P(Y);
}
function I(Y, L, H) {
if (L < 0 || Y.byteLength < L)
throw new RangeError('"offset" is outside of buffer bounds');
if (Y.byteLength < L + (H || 0))
throw new RangeError('"length" is outside of buffer bounds');
let oe;
return L === void 0 && H === void 0 ? oe = new i(Y) : H === void 0 ? oe = new i(Y, L) : oe = new i(Y, L, H), Object.setPrototypeOf(oe, m.prototype), oe;
}
function F(Y) {
if (m.isBuffer(Y)) {
const L = U(Y.length) | 0, H = w(L);
return H.length === 0 || Y.copy(H, 0, 0, L), H;
}
if (Y.length !== void 0)
return typeof Y.length != "number" || Pt(Y.length) ? w(0) : P(Y);
if (Y.type === "Buffer" && Array.isArray(Y.data))
return P(Y.data);
}
function U(Y) {
if (Y >= c)
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + c.toString(16) + " bytes");
return Y | 0;
}
function ie(Y) {
return +Y != Y && (Y = 0), m.alloc(+Y);
}
m.isBuffer = function(L) {
return L != null && L._isBuffer === !0 && L !== m.prototype;
}, m.compare = function(L, H) {
if (_e(L, i) && (L = m.from(L, L.offset, L.byteLength)), _e(H, i) && (H = m.from(H, H.offset, H.byteLength)), !m.isBuffer(L) || !m.isBuffer(H))
throw new TypeError(
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
);
if (L === H) return 0;
let oe = L.length, me = H.length;
for (let Re = 0, xe = Math.min(oe, me); Re < xe; ++Re)
if (L[Re] !== H[Re]) {
oe = L[Re], me = H[Re];
break;
}
return oe < me ? -1 : me < oe ? 1 : 0;
}, m.isEncoding = function(L) {
switch (String(L).toLowerCase()) {
case "hex":
case "utf8":
case "utf-8":
case "ascii":
case "latin1":
case "binary":
case "base64":
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return !0;
default:
return !1;
}
}, m.concat = function(L, H) {
if (!Array.isArray(L))
throw new TypeError('"list" argument must be an Array of Buffers');
if (L.length === 0)
return m.alloc(0);
let oe;
if (H === void 0)
for (H = 0, oe = 0; oe < L.length; ++oe)
H += L[oe].length;
const me = m.allocUnsafe(H);
let Re = 0;
for (oe = 0; oe < L.length; ++oe) {
let xe = L[oe];
if (_e(xe, i))
Re + xe.length > me.length ? (m.isBuffer(xe) || (xe = m.from(xe)), xe.copy(me, Re)) : i.prototype.set.call(
me,
xe,
Re
);
else if (m.isBuffer(xe))
xe.copy(me, Re);
else
throw new TypeError('"list" argument must be an Array of Buffers');
Re += xe.length;
}
return me;
};
function le(Y, L) {
if (m.isBuffer(Y))
return Y.length;
if (d.isView(Y) || _e(Y, d))
return Y.byteLength;
if (typeof Y != "string")
throw new TypeError(
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof Y
);
const H = Y.length, oe = arguments.length > 2 && arguments[2] === !0;
if (!oe && H === 0) return 0;
let me = !1;
for (; ; )
switch (L) {
case "ascii":
case "latin1":
case "binary":
return H;
case "utf8":
case "utf-8":
return Ct(Y).length;
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return H * 2;
case "hex":
return H >>> 1;
case "base64":
return xt(Y).length;
default:
if (me)
return oe ? -1 : Ct(Y).length;
L = ("" + L).toLowerCase(), me = !0;
}
}
m.byteLength = le;
function he(Y, L, H) {
let oe = !1;
if ((L === void 0 || L < 0) && (L = 0), L > this.length || ((H === void 0 || H > this.length) && (H = this.length), H <= 0) || (H >>>= 0, L >>>= 0, H <= L))
return "";
for (Y || (Y = "utf8"); ; )
switch (Y) {
case "hex":
return C(this, L, H);
case "utf8":
case "utf-8":
return b(this, L, H);
case "ascii":
return r(this, L, H);
case "latin1":
case "binary":
return v(this, L, H);
case "base64":
return u(this, L, H);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return O(this, L, H);
default:
if (oe) throw new TypeError("Unknown encoding: " + Y);
Y = (Y + "").toLowerCase(), oe = !0;
}
}
m.prototype._isBuffer = !0;
function be(Y, L, H) {
const oe = Y[L];
Y[L] = Y[H], Y[H] = oe;
}
m.prototype.swap16 = function() {
const L = this.length;
if (L % 2 !== 0)
throw new RangeError("Buffer size must be a multiple of 16-bits");
for (let H = 0; H < L; H += 2)
be(this, H, H + 1);
return this;
}, m.prototype.swap32 = function() {
const L = this.length;
if (L % 4 !== 0)
throw new RangeError("Buffer size must be a multiple of 32-bits");
for (let H = 0; H < L; H += 4)
be(this, H, H + 3), be(this, H + 1, H + 2);
return this;
}, m.prototype.swap64 = function() {
const L = this.length;
if (L % 8 !== 0)
throw new RangeError("Buffer size must be a multiple of 64-bits");
for (let H = 0; H < L; H += 8)
be(this, H, H + 7), be(this, H + 1, H + 6), be(this, H + 2, H + 5), be(this, H + 3, H + 4);
return this;
}, m.prototype.toString = function() {
const L = this.length;
return L === 0 ? "" : arguments.length === 0 ? b(this, 0, L) : he.apply(this, arguments);
}, m.prototype.toLocaleString = m.prototype.toString, m.prototype.equals = function(L) {
if (!m.isBuffer(L)) throw new TypeError("Argument must be a Buffer");
return this === L ? !0 : m.compare(this, L) === 0;
}, m.prototype.inspect = function() {
let L = "";
const H = t.INSPECT_MAX_BYTES;
return L = this.toString("hex", 0, H).replace(/(.{2})/g, "$1 ").trim(), this.length > H && (L += " ... "), "<Buffer " + L + ">";
}, o && (m.prototype[o] = m.prototype.inspect), m.prototype.compare = function(L, H, oe, me, Re) {
if (_e(L, i) && (L = m.from(L, L.offset, L.byteLength)), !m.isBuffer(L))
throw new TypeError(
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof L
);
if (H === void 0 && (H = 0), oe === void 0 && (oe = L ? L.length : 0), me === void 0 && (me = 0), Re === void 0 && (Re = this.length), H < 0 || oe > L.length || me < 0 || Re > this.length)
throw new RangeError("out of range index");
if (me >= Re && H >= oe)
return 0;
if (me >= Re)
return -1;
if (H >= oe)
return 1;
if (H >>>= 0, oe >>>= 0, me >>>= 0, Re >>>= 0, this === L) return 0;
let xe = Re - me, Je = oe - H;
const kt = Math.min(xe, Je), ze = this.slice(me, Re), Le = L.slice(H, oe);
for (let tt = 0; tt < kt; ++tt)
if (ze[tt] !== Le[tt]) {
xe = ze[tt], Je = Le[tt];
break;
}
return xe < Je ? -1 : Je < xe ? 1 : 0;
};
function ae(Y, L, H, oe, me) {
if (Y.length === 0) return -1;
if (typeof H == "string" ? (oe = H, H = 0) : H > 2147483647 ? H = 2147483647 : H < -2147483648 && (H = -2147483648), H = +H, Pt(H) && (H = me ? 0 : Y.length - 1), H < 0 && (H = Y.length + H), H >= Y.length) {
if (me) return -1;
H = Y.length - 1;
} else if (H < 0)
if (me) H = 0;
else return -1;
if (typeof L == "string" && (L = m.from(L, oe)), m.isBuffer(L))
return L.length === 0 ? -1 : G(Y, L, H, oe, me);
if (typeof L == "number")
return L = L & 255, typeof i.prototype.indexOf == "function" ? me ? i.prototype.indexOf.call(Y, L, H) : i.prototype.lastIndexOf.call(Y, L, H) : G(Y, [L], H, oe, me);
throw new TypeError("val must be string, number or Buffer");
}
function G(Y, L, H, oe, me) {
let Re = 1, xe = Y.length, Je = L.length;
if (oe !== void 0 && (oe = String(oe).toLowerCase(), oe === "ucs2" || oe === "ucs-2" || oe === "utf16le" || oe === "utf-16le")) {
if (Y.length < 2 || L.length < 2)
return -1;
Re = 2, xe /= 2, Je /= 2, H /= 2;
}
function kt(Le, tt) {
return Re === 1 ? Le[tt] : Le.readUInt16BE(tt * Re);
}
let ze;
if (me) {
let Le = -1;
for (ze = H; ze < xe; ze++)
if (kt(Y, ze) === kt(L, Le === -1 ? 0 : ze - Le)) {
if (Le === -1 && (Le = ze), ze - Le + 1 === Je) return Le * Re;
} else
Le !== -1 && (ze -= ze - Le), Le = -1;
} else
for (H + Je > xe && (H = xe - Je), ze = H; ze >= 0; ze--) {
let Le = !0;
for (let tt = 0; tt < Je; tt++)
if (kt(Y, ze + tt) !== kt(L, tt)) {
Le = !1;
break;
}
if (Le) return ze;
}
return -1;
}
m.prototype.includes = function(L, H, oe) {
return this.indexOf(L, H, oe) !== -1;
}, m.prototype.indexOf = function(L, H, oe) {
return ae(this, L, H, oe, !0);
}, m.prototype.lastIndexOf = function(L, H, oe) {
return ae(this, L, H, oe, !1);
};
function y(Y, L, H, oe) {
H = Number(H) || 0;
const me = Y.length - H;
oe ? (oe = Number(oe), oe > me && (oe = me)) : oe = me;
const Re = L.length;
oe > Re / 2 && (oe = Re / 2);
let xe;
for (xe = 0; xe < oe; ++xe) {
const Je = parseInt(L.substr(xe * 2, 2), 16);
if (Pt(Je)) return xe;
Y[H + xe] = Je;
}
return xe;
}
function e(Y, L, H, oe) {
return we(Ct(L, Y.length - H), Y, H, oe);
}
function n(Y, L, H, oe) {
return we(Oe(L), Y, H, oe);
}
function s(Y, L, H, oe) {
return we(xt(L), Y, H, oe);
}
function l(Y, L, H, oe) {
return we(He(L, Y.length - H), Y, H, oe);
}
m.prototype.write = function(L, H, oe, me) {
if (H === void 0)
me = "utf8", oe = this.length, H = 0;
else if (oe === void 0 && typeof H == "string")
me = H, oe = this.length, H = 0;
else if (isFinite(H))
H = H >>> 0, isFinite(oe) ? (oe = oe >>> 0, me === void 0 && (me = "utf8")) : (me = oe, oe = void 0);
else
throw new Error(
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
);
const Re = this.length - H;
if ((oe === void 0 || oe > Re) && (oe = Re), L.length > 0 && (oe < 0 || H < 0) || H > this.length)
throw new RangeError("Attempt to write outside buffer bounds");
me || (me = "utf8");
let xe = !1;
for (; ; )
switch (me) {
case "hex":
return y(this, L, H, oe);
case "utf8":
case "utf-8":
return e(this, L, H, oe);
case "ascii":
case "latin1":
case "binary":
return n(this, L, H, oe);
case "base64":
return s(this, L, H, oe);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return l(this, L, H, oe);
default:
if (xe) throw new TypeError("Unknown encoding: " + me);
me = ("" + me).toLowerCase(), xe = !0;
}
}, m.prototype.toJSON = function() {
return {
type: "Buffer",
data: Array.prototype.slice.call(this._arr || this, 0)
};
};
function u(Y, L, H) {
return L === 0 && H === Y.length ? a.fromByteArray(Y) : a.fromByteArray(Y.slice(L, H));
}
function b(Y, L, H) {
H = Math.min(Y.length, H);
const oe = [];
let me = L;
for (; me < H; ) {
const Re = Y[me];
let xe = null, Je = Re > 239 ? 4 : Re > 223 ? 3 : Re > 191 ? 2 : 1;
if (me + Je <= H) {
let kt, ze, Le, tt;
switch (Je) {
case 1:
Re < 128 && (xe = Re);
break;
case 2:
kt = Y[me + 1], (kt & 192) === 128 && (tt = (Re & 31) << 6 | kt & 63, tt > 127 && (xe = tt));
break;
case 3:
kt = Y[me + 1], ze = Y[me + 2], (kt & 192) === 128 && (ze & 192) === 128 && (tt = (Re & 15) << 12 | (kt & 63) << 6 | ze & 63, tt > 2047 && (tt < 55296 || tt > 57343) && (xe = tt));
break;
case 4:
kt = Y[me + 1], ze = Y[me + 2], Le = Y[me + 3], (kt & 192) === 128 && (ze & 192) === 128 && (Le & 192) === 128 && (tt = (Re & 15) << 18 | (kt & 63) << 12 | (ze & 63) << 6 | Le & 63, tt > 65535 && tt < 1114112 && (xe = tt));
}
}
xe === null ? (xe = 65533, Je = 1) : xe > 65535 && (xe -= 65536, oe.push(xe >>> 10 & 1023 | 55296), xe = 56320 | xe & 1023), oe.push(xe), me += Je;
}
return h(oe);
}
const A = 4096;
function h(Y) {
const L = Y.length;
if (L <= A)
return String.fromCharCode.apply(String, Y);
let H = "", oe = 0;
for (; oe < L; )
H += String.fromCharCode.apply(
String,
Y.slice(oe, oe += A)
);
return H;
}
function r(Y, L, H) {
let oe = "";
H = Math.min(Y.length, H);
for (let me = L; me < H; ++me)
oe += String.fromCharCode(Y[me] & 127);
return oe;
}
function v(Y, L, H) {
let oe = "";
H = Math.min(Y.length, H);
for (let me = L; me < H; ++me)
oe += String.fromCharCode(Y[me]);
return oe;
}
function C(Y, L, H) {
const oe = Y.length;
(!L || L < 0) && (L = 0), (!H || H < 0 || H > oe) && (H = oe);
let me = "";
for (let Re = L; Re < H; ++Re)
me += Ue[Y[Re]];
return me;
}
function O(Y, L, H) {
const oe = Y.slice(L, H);
let me = "";
for (let Re = 0; Re < oe.length - 1; Re += 2)
me += String.fromCharCode(oe[Re] + oe[Re + 1] * 256);
return me;
}
m.prototype.slice = function(L, H) {
const oe = this.length;
L = ~~L, H = H === void 0 ? oe : ~~H, L < 0 ? (L += oe, L < 0 && (L = 0)) : L > oe && (L = oe), H < 0 ? (H += oe, H < 0 && (H = 0)) : H > oe && (H = oe), H < L && (H = L);
const me = this.subarray(L, H);
return Object.setPrototypeOf(me, m.prototype), me;
};
function se(Y, L, H) {
if (Y % 1 !== 0 || Y < 0) throw new RangeError("offset is not uint");
if (Y + L > H) throw new RangeError("Trying to access beyond buffer length");
}
m.prototype.readUintLE = m.prototype.readUIntLE = function(L, H, oe) {
L = L >>> 0, H = H >>> 0, oe || se(L, H, this.length);
let me = this[L], Re = 1, xe = 0;
for (; ++xe < H && (Re *= 256); )
me += this[L + xe] * Re;
return me;
}, m.prototype.readUintBE = m.prototype.readUIntBE = function(L, H, oe) {
L = L >>> 0, H = H >>> 0, oe || se(L, H, this.length);
let me = this[L + --H]