var __classPrivateFieldGet = function (receiver, state, kind, f) {
if (kind === "a" && !f) {
throw new TypeError("Private accessor was defined without a getter");
}
if (
typeof state === "function"
? receiver !== state || !f
: !state.has(receiver)
) {
throw new TypeError(
"Cannot read private member from an object whose class did not declare it",
);
}
return kind === "m"
? f
: kind === "a"
? f.call(receiver)
: f
? f.value
: state.get(receiver);
};
var __classPrivateFieldSet = function (receiver, state, value, kind, f) {
if (kind === "m") {
throw new TypeError("Private method is not writable");
}
if (kind === "a" && !f) {
throw new TypeError("Private accessor was defined without a setter");
}
if (
typeof state === "function"
? receiver !== state || !f
: !state.has(receiver)
) {
throw new TypeError(
"Cannot write private member to an object whose class did not declare it",
);
}
return kind === "a"
? f.call(receiver, value)
: f
? f.value = value
: state.set(receiver, value),
value;
};
var _RegisterWalletEvent_detail;
function registerWallet(wallet) {
const callback = ({ register }) => register(wallet);
try {
window.dispatchEvent(new RegisterWalletEvent(callback));
} catch (error) {
console.error(
"wallet-standard:register-wallet event could not be dispatched\n",
error,
);
}
try {
window.addEventListener(
"wallet-standard:app-ready",
({ detail: api }) => callback(api),
);
} catch (error) {
console.error(
"wallet-standard:app-ready event listener could not be added\n",
error,
);
}
}
var RegisterWalletEvent = class extends Event {
get detail() {
return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
}
get type() {
return "wallet-standard:register-wallet";
}
constructor(callback) {
super("wallet-standard:register-wallet", {
bubbles: false,
cancelable: false,
composed: false,
});
_RegisterWalletEvent_detail.set(this, void 0);
__classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
}
preventDefault() {
throw new Error("preventDefault cannot be called");
}
stopImmediatePropagation() {
throw new Error("stopImmediatePropagation cannot be called");
}
stopPropagation() {
throw new Error("stopPropagation cannot be called");
}
};
_RegisterWalletEvent_detail = new WeakMap();
function DEPRECATED_registerWallet(wallet) {
var _a;
registerWallet(wallet);
try {
((_a = window.navigator).wallets || (_a.wallets = [])).push((
{ register },
) => register(wallet));
} catch (error) {
console.error("window.navigator.wallets could not be pushed\n", error);
}
}
var __classPrivateFieldGet2 = function (receiver, state, kind, f) {
if (kind === "a" && !f) {
throw new TypeError("Private accessor was defined without a getter");
}
if (
typeof state === "function"
? receiver !== state || !f
: !state.has(receiver)
) {
throw new TypeError(
"Cannot read private member from an object whose class did not declare it",
);
}
return kind === "m"
? f
: kind === "a"
? f.call(receiver)
: f
? f.value
: state.get(receiver);
};
var __classPrivateFieldSet2 = function (receiver, state, value, kind, f) {
if (kind === "m") {
throw new TypeError("Private method is not writable");
}
if (kind === "a" && !f) {
throw new TypeError("Private accessor was defined without a setter");
}
if (
typeof state === "function"
? receiver !== state || !f
: !state.has(receiver)
) {
throw new TypeError(
"Cannot write private member to an object whose class did not declare it",
);
}
return kind === "a"
? f.call(receiver, value)
: f
? f.value = value
: state.set(receiver, value),
value;
};
var _ReadonlyWalletAccount_address;
var _ReadonlyWalletAccount_publicKey;
var _ReadonlyWalletAccount_chains;
var _ReadonlyWalletAccount_features;
var _ReadonlyWalletAccount_label;
var _ReadonlyWalletAccount_icon;
var ReadonlyWalletAccount = class _ReadonlyWalletAccount {
get address() {
return __classPrivateFieldGet2(this, _ReadonlyWalletAccount_address, "f");
}
get publicKey() {
return __classPrivateFieldGet2(this, _ReadonlyWalletAccount_publicKey, "f")
.slice();
}
get chains() {
return __classPrivateFieldGet2(this, _ReadonlyWalletAccount_chains, "f")
.slice();
}
get features() {
return __classPrivateFieldGet2(this, _ReadonlyWalletAccount_features, "f")
.slice();
}
get label() {
return __classPrivateFieldGet2(this, _ReadonlyWalletAccount_label, "f");
}
get icon() {
return __classPrivateFieldGet2(this, _ReadonlyWalletAccount_icon, "f");
}
constructor(account) {
_ReadonlyWalletAccount_address.set(this, void 0);
_ReadonlyWalletAccount_publicKey.set(this, void 0);
_ReadonlyWalletAccount_chains.set(this, void 0);
_ReadonlyWalletAccount_features.set(this, void 0);
_ReadonlyWalletAccount_label.set(this, void 0);
_ReadonlyWalletAccount_icon.set(this, void 0);
if (new.target === _ReadonlyWalletAccount) {
Object.freeze(this);
}
__classPrivateFieldSet2(
this,
_ReadonlyWalletAccount_address,
account.address,
"f",
);
__classPrivateFieldSet2(
this,
_ReadonlyWalletAccount_publicKey,
account.publicKey.slice(),
"f",
);
__classPrivateFieldSet2(
this,
_ReadonlyWalletAccount_chains,
account.chains.slice(),
"f",
);
__classPrivateFieldSet2(
this,
_ReadonlyWalletAccount_features,
account.features.slice(),
"f",
);
__classPrivateFieldSet2(
this,
_ReadonlyWalletAccount_label,
account.label,
"f",
);
__classPrivateFieldSet2(
this,
_ReadonlyWalletAccount_icon,
account.icon,
"f",
);
}
};
_ReadonlyWalletAccount_address = new WeakMap(),
_ReadonlyWalletAccount_publicKey = new WeakMap(),
_ReadonlyWalletAccount_chains = new WeakMap(),
_ReadonlyWalletAccount_features = new WeakMap(),
_ReadonlyWalletAccount_label = new WeakMap(),
_ReadonlyWalletAccount_icon = new WeakMap();
function arraysEqual(a, b) {
if (a === b) {
return true;
}
const length = a.length;
if (length !== b.length) {
return false;
}
for (let i = 0; i < length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
function bytesEqual(a, b) {
return arraysEqual(a, b);
}
function concatBytes(first, ...others) {
const length = others.reduce(
(length2, bytes2) => length2 + bytes2.length,
first.length,
);
const bytes = new Uint8Array(length);
bytes.set(first, 0);
for (const other of others) {
bytes.set(other, bytes.length);
}
return bytes;
}
function pick(source, ...keys) {
const picked = {};
for (const key of keys) {
picked[key] = source[key];
}
return picked;
}
function guard(callback) {
try {
callback();
} catch (error) {
console.error(error);
}
}
export {
arraysEqual,
bytesEqual,
concatBytes,
DEPRECATED_registerWallet,
guard,
pick,
ReadonlyWalletAccount,
registerWallet,
};