@pooflabs/web 0.0.81-rc5 → 0.0.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/auth/index.d.ts +10 -1
  2. package/dist/auth/providers/phantom-wallet-provider.d.ts +20 -21
  3. package/dist/global.d.ts +3 -1
  4. package/dist/{index-Fjyk5jYL.js → index-B2WGCssJ.js} +346 -490
  5. package/dist/index-B2WGCssJ.js.map +1 -0
  6. package/dist/{index-DB9nDInp.esm.js → index-CjHbp7Dq.esm.js} +3697 -562
  7. package/dist/index-CjHbp7Dq.esm.js.map +1 -0
  8. package/dist/{index-D_ta2S2c.js → index-DXPkkq81.js} +3698 -563
  9. package/dist/index-DXPkkq81.js.map +1 -0
  10. package/dist/{index-Bg_ApFIo.js → index-D_DiP8XQ.js} +3698 -563
  11. package/dist/index-D_DiP8XQ.js.map +1 -0
  12. package/dist/{index-CZhJBWap.esm.js → index-dcJIjFrs.esm.js} +3697 -562
  13. package/dist/index-dcJIjFrs.esm.js.map +1 -0
  14. package/dist/{index-Bkr4BRoP.esm.js → index-nt_HQVrk.esm.js} +344 -490
  15. package/dist/index-nt_HQVrk.esm.js.map +1 -0
  16. package/dist/{index.browser-iqs5DlRU.esm.js → index.browser-BNdFfyIg.esm.js} +1571 -1368
  17. package/dist/index.browser-BNdFfyIg.esm.js.map +1 -0
  18. package/dist/{index.browser-DHi7UhqF.js → index.browser-CT6PUv9G.js} +1571 -1368
  19. package/dist/index.browser-CT6PUv9G.js.map +1 -0
  20. package/dist/index.browser-Cy21yaX0.esm.js +1096 -0
  21. package/dist/index.browser-Cy21yaX0.esm.js.map +1 -0
  22. package/dist/index.browser-OvGNsMPu.esm.js +1002 -0
  23. package/dist/index.browser-OvGNsMPu.esm.js.map +1 -0
  24. package/dist/index.browser-ZD7Tz2bn.js +1099 -0
  25. package/dist/index.browser-ZD7Tz2bn.js.map +1 -0
  26. package/dist/index.browser-d0PlOXpF.js +105 -0
  27. package/dist/index.browser-d0PlOXpF.js.map +1 -0
  28. package/dist/index.browser-pE1s68e9.esm.js +102 -0
  29. package/dist/index.browser-pE1s68e9.esm.js.map +1 -0
  30. package/dist/index.browser-vuTr40so.js +1008 -0
  31. package/dist/index.browser-vuTr40so.js.map +1 -0
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.esm.js +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/{index.native-DYgJWWY4.esm.js → index.native-BqYr--vb.esm.js} +202 -178
  36. package/dist/index.native-BqYr--vb.esm.js.map +1 -0
  37. package/dist/{index.native-DJWuqJTZ.js → index.native-CyA-RdvW.js} +204 -178
  38. package/dist/index.native-CyA-RdvW.js.map +1 -0
  39. package/dist/index.native.esm.js +1 -1
  40. package/dist/index.native.js +1 -1
  41. package/dist/{phantom-wallet-provider-fofd8BMo.js → phantom-wallet-provider-DWCaMkyz.js} +147 -238
  42. package/dist/phantom-wallet-provider-DWCaMkyz.js.map +1 -0
  43. package/dist/{phantom-wallet-provider-DSFGWSOJ.esm.js → phantom-wallet-provider-K2V96G-G.esm.js} +147 -238
  44. package/dist/phantom-wallet-provider-K2V96G-G.esm.js.map +1 -0
  45. package/dist/{privy-wallet-provider-Csv34Kcc.js → privy-wallet-provider-BMg_S_d0.js} +4 -4
  46. package/dist/privy-wallet-provider-BMg_S_d0.js.map +1 -0
  47. package/dist/{privy-wallet-provider-TRToDe4Q.esm.js → privy-wallet-provider-DoX8q99w.esm.js} +4 -4
  48. package/dist/privy-wallet-provider-DoX8q99w.esm.js.map +1 -0
  49. package/dist/{solana-mobile-wallet-provider-L7nRuxhv.esm.js → solana-mobile-wallet-provider-Cmphb3oB.esm.js} +3 -82
  50. package/dist/solana-mobile-wallet-provider-Cmphb3oB.esm.js.map +1 -0
  51. package/dist/{solana-mobile-wallet-provider-Cp65LfNb.js → solana-mobile-wallet-provider-t22Ie8lY.js} +3 -82
  52. package/dist/solana-mobile-wallet-provider-t22Ie8lY.js.map +1 -0
  53. package/package.json +3 -3
  54. package/dist/index-Bg_ApFIo.js.map +0 -1
  55. package/dist/index-Bkr4BRoP.esm.js.map +0 -1
  56. package/dist/index-CZhJBWap.esm.js.map +0 -1
  57. package/dist/index-DB9nDInp.esm.js.map +0 -1
  58. package/dist/index-D_ta2S2c.js.map +0 -1
  59. package/dist/index-Fjyk5jYL.js.map +0 -1
  60. package/dist/index.browser-BTlliHCf.esm.js +0 -119
  61. package/dist/index.browser-BTlliHCf.esm.js.map +0 -1
  62. package/dist/index.browser-C-_FEr5M.esm.js +0 -1134
  63. package/dist/index.browser-C-_FEr5M.esm.js.map +0 -1
  64. package/dist/index.browser-DHi7UhqF.js.map +0 -1
  65. package/dist/index.browser-DRTQuf0J.js +0 -1253
  66. package/dist/index.browser-DRTQuf0J.js.map +0 -1
  67. package/dist/index.browser-Disp7Kcb.esm.js +0 -1250
  68. package/dist/index.browser-Disp7Kcb.esm.js.map +0 -1
  69. package/dist/index.browser-DjEZSiqI.js +0 -1137
  70. package/dist/index.browser-DjEZSiqI.js.map +0 -1
  71. package/dist/index.browser-DvTeEO2r.js +0 -122
  72. package/dist/index.browser-DvTeEO2r.js.map +0 -1
  73. package/dist/index.browser-iqs5DlRU.esm.js.map +0 -1
  74. package/dist/index.native-DJWuqJTZ.js.map +0 -1
  75. package/dist/index.native-DYgJWWY4.esm.js.map +0 -1
  76. package/dist/phantom-wallet-provider-DSFGWSOJ.esm.js.map +0 -1
  77. package/dist/phantom-wallet-provider-fofd8BMo.js.map +0 -1
  78. package/dist/privy-wallet-provider-Csv34Kcc.js.map +0 -1
  79. package/dist/privy-wallet-provider-TRToDe4Q.esm.js.map +0 -1
  80. package/dist/solana-mobile-wallet-provider-Cp65LfNb.js.map +0 -1
  81. package/dist/solana-mobile-wallet-provider-L7nRuxhv.esm.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { g as getDefaultExportFromCjs } from './index-Bkr4BRoP.esm.js';
2
- import { s as startRemoteScenario, t as transact } from './index.browser-C-_FEr5M.esm.js';
1
+ import { a as startScenario, S as SolanaMobileWalletAdapterError, b as SolanaMobileWalletAdapterErrorCode, s as startRemoteScenario } from './index.browser-OvGNsMPu.esm.js';
2
+ import { g as getDefaultExportFromCjs, a as base58 } from './index-nt_HQVrk.esm.js';
3
3
  import 'axios';
4
4
  import '@solana/web3.js';
5
5
  import '@coral-xyz/anchor';
@@ -20,6 +20,15 @@ const SolanaSignMessage = 'solana:signMessage';
20
20
  /** Name of the feature. */
21
21
  const SolanaSignTransaction = 'solana:signTransaction';
22
22
 
23
+ /** Name of the feature. */
24
+ const StandardConnect = 'standard:connect';
25
+
26
+ /** Name of the feature. */
27
+ const StandardDisconnect = 'standard:disconnect';
28
+
29
+ /** Name of the feature. */
30
+ const StandardEvents = 'standard:events';
31
+
23
32
  var browser = {};
24
33
 
25
34
  var canPromise;
@@ -3092,200 +3101,239 @@ function requireBrowser () {
3092
3101
  var browserExports = requireBrowser();
3093
3102
  var QRCode = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
3094
3103
 
3095
- /** Name of the feature. */
3096
- const StandardConnect = 'standard:connect';
3097
-
3098
- /** Name of the feature. */
3099
- const StandardDisconnect = 'standard:disconnect';
3100
-
3101
- /** Name of the feature. */
3102
- const StandardEvents = 'standard:events';
3103
-
3104
- var src;
3105
- var hasRequiredSrc;
3106
-
3107
- function requireSrc () {
3108
- if (hasRequiredSrc) return src;
3109
- hasRequiredSrc = 1;
3110
- // base-x encoding / decoding
3111
- // Copyright (c) 2018 base-x contributors
3112
- // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
3113
- // Distributed under the MIT software license, see the accompanying
3114
- // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
3115
- function base (ALPHABET) {
3116
- if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
3117
- var BASE_MAP = new Uint8Array(256);
3118
- for (var j = 0; j < BASE_MAP.length; j++) {
3119
- BASE_MAP[j] = 255;
3120
- }
3121
- for (var i = 0; i < ALPHABET.length; i++) {
3122
- var x = ALPHABET.charAt(i);
3123
- var xc = x.charCodeAt(0);
3124
- if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
3125
- BASE_MAP[xc] = i;
3126
- }
3127
- var BASE = ALPHABET.length;
3128
- var LEADER = ALPHABET.charAt(0);
3129
- var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
3130
- var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
3131
- function encode (source) {
3132
- if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
3133
- source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
3134
- } else if (Array.isArray(source)) {
3135
- source = Uint8Array.from(source);
3136
- }
3137
- if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
3138
- if (source.length === 0) { return '' }
3139
- // Skip & count leading zeroes.
3140
- var zeroes = 0;
3141
- var length = 0;
3142
- var pbegin = 0;
3143
- var pend = source.length;
3144
- while (pbegin !== pend && source[pbegin] === 0) {
3145
- pbegin++;
3146
- zeroes++;
3147
- }
3148
- // Allocate enough space in big-endian base58 representation.
3149
- var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
3150
- var b58 = new Uint8Array(size);
3151
- // Process the bytes.
3152
- while (pbegin !== pend) {
3153
- var carry = source[pbegin];
3154
- // Apply "b58 = b58 * 256 + ch".
3155
- var i = 0;
3156
- for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
3157
- carry += (256 * b58[it1]) >>> 0;
3158
- b58[it1] = (carry % BASE) >>> 0;
3159
- carry = (carry / BASE) >>> 0;
3160
- }
3161
- if (carry !== 0) { throw new Error('Non-zero carry') }
3162
- length = i;
3163
- pbegin++;
3164
- }
3165
- // Skip leading zeroes in base58 result.
3166
- var it2 = size - length;
3167
- while (it2 !== size && b58[it2] === 0) {
3168
- it2++;
3169
- }
3170
- // Translate the result into a string.
3171
- var str = LEADER.repeat(zeroes);
3172
- for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
3173
- return str
3174
- }
3175
- function decodeUnsafe (source) {
3176
- if (typeof source !== 'string') { throw new TypeError('Expected String') }
3177
- if (source.length === 0) { return new Uint8Array() }
3178
- var psz = 0;
3179
- // Skip and count leading '1's.
3180
- var zeroes = 0;
3181
- var length = 0;
3182
- while (source[psz] === LEADER) {
3183
- zeroes++;
3184
- psz++;
3185
- }
3186
- // Allocate enough space in big-endian base256 representation.
3187
- var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
3188
- var b256 = new Uint8Array(size);
3189
- // Process the characters.
3190
- while (source[psz]) {
3191
- // Find code of next character
3192
- var charCode = source.charCodeAt(psz);
3193
- // Base map can not be indexed using char code
3194
- if (charCode > 255) { return }
3195
- // Decode character
3196
- var carry = BASE_MAP[charCode];
3197
- // Invalid character
3198
- if (carry === 255) { return }
3199
- var i = 0;
3200
- for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
3201
- carry += (BASE * b256[it3]) >>> 0;
3202
- b256[it3] = (carry % 256) >>> 0;
3203
- carry = (carry / 256) >>> 0;
3204
- }
3205
- if (carry !== 0) { throw new Error('Non-zero carry') }
3206
- length = i;
3207
- psz++;
3208
- }
3209
- // Skip leading zeroes in b256.
3210
- var it4 = size - length;
3211
- while (it4 !== size && b256[it4] === 0) {
3212
- it4++;
3213
- }
3214
- var vch = new Uint8Array(zeroes + (size - it4));
3215
- var j = zeroes;
3216
- while (it4 !== size) {
3217
- vch[j++] = b256[it4++];
3218
- }
3219
- return vch
3220
- }
3221
- function decode (string) {
3222
- var buffer = decodeUnsafe(string);
3223
- if (buffer) { return buffer }
3224
- throw new Error('Non-base' + BASE + ' character')
3225
- }
3226
- return {
3227
- encode: encode,
3228
- decodeUnsafe: decodeUnsafe,
3229
- decode: decode
3230
- }
3231
- }
3232
- src = base;
3233
- return src;
3104
+ var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3105
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3106
+ 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");
3107
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3108
+ };
3109
+ var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3110
+ if (kind === "m") throw new TypeError("Private method is not writable");
3111
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3112
+ 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");
3113
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
3114
+ };
3115
+ var _RegisterWalletEvent_detail;
3116
+ /**
3117
+ * Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
3118
+ *
3119
+ * This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
3120
+ * ready to be registered.
3121
+ *
3122
+ * This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
3123
+ * the app that the app is ready to register the Wallet.
3124
+ *
3125
+ * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
3126
+ * as the app is ready whether the Wallet loads before or after the app.
3127
+ *
3128
+ * @param wallet Wallet to register.
3129
+ *
3130
+ * @group Wallet
3131
+ */
3132
+ function registerWallet(wallet) {
3133
+ const callback = ({ register }) => register(wallet);
3134
+ try {
3135
+ window.dispatchEvent(new RegisterWalletEvent(callback));
3136
+ }
3137
+ catch (error) {
3138
+ console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
3139
+ }
3140
+ try {
3141
+ window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
3142
+ }
3143
+ catch (error) {
3144
+ console.error('wallet-standard:app-ready event listener could not be added\n', error);
3145
+ }
3234
3146
  }
3147
+ class RegisterWalletEvent extends Event {
3148
+ get detail() {
3149
+ return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
3150
+ }
3151
+ get type() {
3152
+ return 'wallet-standard:register-wallet';
3153
+ }
3154
+ constructor(callback) {
3155
+ super('wallet-standard:register-wallet', {
3156
+ bubbles: false,
3157
+ cancelable: false,
3158
+ composed: false,
3159
+ });
3160
+ _RegisterWalletEvent_detail.set(this, void 0);
3161
+ __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
3162
+ }
3163
+ /** @deprecated */
3164
+ preventDefault() {
3165
+ throw new Error('preventDefault cannot be called');
3166
+ }
3167
+ /** @deprecated */
3168
+ stopImmediatePropagation() {
3169
+ throw new Error('stopImmediatePropagation cannot be called');
3170
+ }
3171
+ /** @deprecated */
3172
+ stopPropagation() {
3173
+ throw new Error('stopPropagation cannot be called');
3174
+ }
3175
+ }
3176
+ _RegisterWalletEvent_detail = new WeakMap();
3235
3177
 
3236
- var bs58;
3237
- var hasRequiredBs58;
3238
-
3239
- function requireBs58 () {
3240
- if (hasRequiredBs58) return bs58;
3241
- hasRequiredBs58 = 1;
3242
- const basex = requireSrc();
3243
- const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
3244
-
3245
- bs58 = basex(ALPHABET);
3246
- return bs58;
3178
+ //#region src/base64Utils.ts
3179
+ function fromUint8Array(byteArray) {
3180
+ return window.btoa(String.fromCharCode.call(null, ...byteArray));
3181
+ }
3182
+ function toUint8Array(base64EncodedByteArray) {
3183
+ return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
3184
+ }
3185
+ //#endregion
3186
+ //#region src/embedded-modal/loadingSpinner.ts
3187
+ const modalHtml$1 = `
3188
+ <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
3189
+ <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
3190
+ <div class="mobile-wallet-adapter-embedded-loading-container">
3191
+ <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
3192
+ </div>
3193
+ </div>
3194
+ `;
3195
+ const css$6 = `
3196
+ .mobile-wallet-adapter-embedded-loading-indicator {
3197
+ display: flex; /* Use flexbox to center content */
3198
+ justify-content: center; /* Center horizontally */
3199
+ align-items: start; /* Center vertically */
3200
+ position: fixed; /* Stay in place */
3201
+ z-index: 1; /* Sit on top */
3202
+ left: 0;
3203
+ top: 0;
3204
+ width: 100%; /* Full width */
3205
+ height: 100%; /* Full height */
3206
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
3207
+ overflow-y: auto; /* enable scrolling */
3247
3208
  }
3248
3209
 
3249
- var bs58Exports = requireBs58();
3250
- var base58 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
3210
+ .mobile-wallet-adapter-embedded-loading-container {
3211
+ display: flex;
3212
+ margin: auto;
3213
+ }
3251
3214
 
3252
- /******************************************************************************
3253
- Copyright (c) Microsoft Corporation.
3254
-
3255
- Permission to use, copy, modify, and/or distribute this software for any
3256
- purpose with or without fee is hereby granted.
3257
-
3258
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3259
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3260
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3261
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3262
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3263
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3264
- PERFORMANCE OF THIS SOFTWARE.
3265
- ***************************************************************************** */
3266
-
3267
- function __awaiter(thisArg, _arguments, P, generator) {
3268
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3269
- return new (P || (P = Promise))(function (resolve, reject) {
3270
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3271
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3272
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3273
- step((generator = generator.apply(thisArg, [])).next());
3274
- });
3275
- }
3276
-
3277
- function __classPrivateFieldGet$1(receiver, state, kind, f) {
3278
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3279
- 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");
3280
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3281
- }
3282
-
3283
- function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
3284
- if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3285
- return (state.set(receiver, value)), value;
3215
+ .mobile-wallet-adapter-embedded-loading-animation {
3216
+ position: relative;
3217
+ left: -9999px;
3218
+ width: 10px;
3219
+ height: 10px;
3220
+ border-radius: 5px;
3221
+ background-color: var(--spinner-color);
3222
+ color: var(--spinner-color);
3223
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3224
+ 9999px 0 0 0 var(--spinner-color),
3225
+ 10014px 0 0 0 var(--spinner-color);
3226
+ animation: dot-typing 1.5s infinite linear;
3286
3227
  }
3287
3228
 
3288
- var _EmbeddedModal_instances, _EmbeddedModal_root, _EmbeddedModal_eventListeners, _EmbeddedModal_listenersAttached, _EmbeddedModal_injectHTML, _EmbeddedModal_attachEventListeners, _EmbeddedModal_removeEventListeners, _EmbeddedModal_handleKeyDown;
3229
+ @keyframes dot-typing {
3230
+ 0% {
3231
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3232
+ 9999px 0 0 0 var(--spinner-color),
3233
+ 10014px 0 0 0 var(--spinner-color);
3234
+ }
3235
+ 16.667% {
3236
+ box-shadow: 9984px -10px 0 0 var(--spinner-color),
3237
+ 9999px 0 0 0 var(--spinner-color),
3238
+ 10014px 0 0 0 var(--spinner-color);
3239
+ }
3240
+ 33.333% {
3241
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3242
+ 9999px 0 0 0 var(--spinner-color),
3243
+ 10014px 0 0 0 var(--spinner-color);
3244
+ }
3245
+ 50% {
3246
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3247
+ 9999px -10px 0 0 var(--spinner-color),
3248
+ 10014px 0 0 0 var(--spinner-color);
3249
+ }
3250
+ 66.667% {
3251
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3252
+ 9999px 0 0 0 var(--spinner-color),
3253
+ 10014px 0 0 0 var(--spinner-color);
3254
+ }
3255
+ 83.333% {
3256
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3257
+ 9999px 0 0 0 var(--spinner-color),
3258
+ 10014px -10px 0 0 var(--spinner-color);
3259
+ }
3260
+ 100% {
3261
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3262
+ 9999px 0 0 0 var(--spinner-color),
3263
+ 10014px 0 0 0 var(--spinner-color);
3264
+ }
3265
+ }
3266
+ `;
3267
+ var EmbeddedLoadingSpinner = class {
3268
+ #root = null;
3269
+ #eventListeners = {};
3270
+ #listenersAttached = false;
3271
+ dom = null;
3272
+ constructor() {
3273
+ this.init = this.init.bind(this);
3274
+ this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3275
+ }
3276
+ async init() {
3277
+ console.log("Injecting modal");
3278
+ this.#injectHTML();
3279
+ }
3280
+ open = () => {
3281
+ console.debug("Modal open");
3282
+ this.#attachEventListeners();
3283
+ if (this.#root) this.#root.style.display = "flex";
3284
+ };
3285
+ close = (event = void 0) => {
3286
+ console.debug("Modal close");
3287
+ this.#removeEventListeners();
3288
+ if (this.#root) this.#root.style.display = "none";
3289
+ this.#eventListeners["close"]?.forEach((listener) => listener(event));
3290
+ };
3291
+ addEventListener(event, listener) {
3292
+ this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
3293
+ return () => this.removeEventListener(event, listener);
3294
+ }
3295
+ removeEventListener(event, listener) {
3296
+ this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
3297
+ }
3298
+ #injectHTML() {
3299
+ if (this.dom) return;
3300
+ this.#root = document.createElement("div");
3301
+ this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
3302
+ this.#root.innerHTML = modalHtml$1;
3303
+ this.#root.style.display = "none";
3304
+ const styles = document.createElement("style");
3305
+ styles.id = "mobile-wallet-adapter-embedded-modal-styles";
3306
+ styles.textContent = css$6;
3307
+ const host = document.createElement("div");
3308
+ this.dom = host.attachShadow({ mode: "closed" });
3309
+ host.style.setProperty("--spinner-color", "#FFFFFF");
3310
+ this.dom.appendChild(styles);
3311
+ this.dom.appendChild(this.#root);
3312
+ document.body.appendChild(host);
3313
+ }
3314
+ #attachEventListeners() {
3315
+ if (!this.#root || this.#listenersAttached) return;
3316
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
3317
+ this.close(event);
3318
+ }));
3319
+ window.addEventListener("load", this.close);
3320
+ document.addEventListener("keydown", this.#handleKeyDown);
3321
+ this.#listenersAttached = true;
3322
+ }
3323
+ #removeEventListeners() {
3324
+ if (!this.#listenersAttached) return;
3325
+ window.removeEventListener("load", this.close);
3326
+ document.removeEventListener("keydown", this.#handleKeyDown);
3327
+ if (!this.#root) return;
3328
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
3329
+ this.#listenersAttached = false;
3330
+ }
3331
+ #handleKeyDown = (event) => {
3332
+ if (event.key === "Escape") this.close(event);
3333
+ };
3334
+ };
3335
+ //#endregion
3336
+ //#region src/embedded-modal/modal.ts
3289
3337
  const modalHtml = `
3290
3338
  <div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
3291
3339
  <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
@@ -3301,13 +3349,13 @@ const modalHtml = `
3301
3349
  </div>
3302
3350
  </div>
3303
3351
  `;
3304
- const css$2 = `
3352
+ const css$5 = `
3305
3353
  .mobile-wallet-adapter-embedded-modal-container {
3306
3354
  display: flex; /* Use flexbox to center content */
3307
3355
  justify-content: center; /* Center horizontally */
3308
3356
  align-items: center; /* Center vertically */
3309
3357
  position: fixed; /* Stay in place */
3310
- z-index: 1; /* Sit on top */
3358
+ z-index: 2147483647; /* Sit on top */
3311
3359
  left: 0;
3312
3360
  top: 0;
3313
3361
  width: 100%; /* Full width */
@@ -3363,134 +3411,100 @@ const fonts = `
3363
3411
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
3364
3412
  <link href="https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
3365
3413
  `;
3366
- class EmbeddedModal {
3367
- constructor() {
3368
- _EmbeddedModal_instances.add(this);
3369
- _EmbeddedModal_root.set(this, null);
3370
- _EmbeddedModal_eventListeners.set(this, {});
3371
- _EmbeddedModal_listenersAttached.set(this, false);
3372
- this.dom = null;
3373
- this.open = () => {
3374
- console.debug('Modal open');
3375
- __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_attachEventListeners).call(this);
3376
- if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
3377
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'flex';
3378
- }
3379
- };
3380
- this.close = (event = undefined) => {
3381
- var _a;
3382
- console.debug('Modal close');
3383
- __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_removeEventListeners).call(this);
3384
- if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
3385
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
3386
- }
3387
- (_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")['close']) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener(event));
3388
- };
3389
- _EmbeddedModal_handleKeyDown.set(this, (event) => {
3390
- if (event.key === 'Escape')
3391
- this.close(event);
3392
- });
3393
- // Bind methods to ensure `this` context is correct
3394
- this.init = this.init.bind(this);
3395
- __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
3396
- }
3397
- init() {
3398
- return __awaiter(this, void 0, void 0, function* () {
3399
- console.log('Injecting modal');
3400
- __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_injectHTML).call(this);
3401
- });
3402
- }
3403
- addEventListener(event, listener) {
3404
- var _a;
3405
- ((_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event] = [listener]);
3406
- return () => this.removeEventListener(event, listener);
3407
- }
3408
- removeEventListener(event, listener) {
3409
- var _a;
3410
- __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
3411
- }
3412
- }
3413
- _EmbeddedModal_root = new WeakMap(), _EmbeddedModal_eventListeners = new WeakMap(), _EmbeddedModal_listenersAttached = new WeakMap(), _EmbeddedModal_handleKeyDown = new WeakMap(), _EmbeddedModal_instances = new WeakSet(), _EmbeddedModal_injectHTML = function _EmbeddedModal_injectHTML() {
3414
- // Check if the HTML has already been injected
3415
- if (document.getElementById('mobile-wallet-adapter-embedded-root-ui')) {
3416
- if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
3417
- __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
3418
- return;
3419
- }
3420
- // Create a container for the modal
3421
- __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.createElement('div'));
3422
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").id = 'mobile-wallet-adapter-embedded-root-ui';
3423
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").innerHTML = modalHtml;
3424
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
3425
- // Add modal content
3426
- const content = __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelector('.mobile-wallet-adapter-embedded-modal-content');
3427
- if (content)
3428
- content.innerHTML = this.contentHtml;
3429
- // Apply styles
3430
- const styles = document.createElement('style');
3431
- styles.id = 'mobile-wallet-adapter-embedded-modal-styles';
3432
- styles.textContent = css$2 + this.contentStyles;
3433
- // Create a shadow DOM to encapsulate the modal
3434
- const host = document.createElement('div');
3435
- host.innerHTML = fonts;
3436
- this.dom = host.attachShadow({ mode: 'closed' });
3437
- this.dom.appendChild(styles);
3438
- this.dom.appendChild(__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"));
3439
- // Append the shadow DOM host to the body
3440
- document.body.appendChild(host);
3441
- }, _EmbeddedModal_attachEventListeners = function _EmbeddedModal_attachEventListeners() {
3442
- if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f") || __classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
3443
- return;
3444
- const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
3445
- closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.addEventListener('click', this.close));
3446
- window.addEventListener('load', this.close);
3447
- document.addEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
3448
- __classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, true);
3449
- }, _EmbeddedModal_removeEventListeners = function _EmbeddedModal_removeEventListeners() {
3450
- if (!__classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
3451
- return;
3452
- window.removeEventListener('load', this.close);
3453
- document.removeEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
3454
- if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
3455
- return;
3456
- const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
3457
- closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.removeEventListener('click', this.close));
3458
- __classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, false);
3414
+ var EmbeddedModal = class {
3415
+ #root = null;
3416
+ #eventListeners = {};
3417
+ #listenersAttached = false;
3418
+ dom = null;
3419
+ constructor() {
3420
+ this.init = this.init.bind(this);
3421
+ this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3422
+ }
3423
+ async init() {
3424
+ console.log("Injecting modal");
3425
+ this.#injectHTML();
3426
+ }
3427
+ open = () => {
3428
+ console.debug("Modal open");
3429
+ this.#attachEventListeners();
3430
+ if (this.#root) this.#root.style.display = "flex";
3431
+ };
3432
+ close = (event = void 0) => {
3433
+ console.debug("Modal close");
3434
+ this.#removeEventListeners();
3435
+ if (this.#root) this.#root.style.display = "none";
3436
+ this.#eventListeners["close"]?.forEach((listener) => listener(event));
3437
+ };
3438
+ addEventListener(event, listener) {
3439
+ this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
3440
+ return () => this.removeEventListener(event, listener);
3441
+ }
3442
+ removeEventListener(event, listener) {
3443
+ this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
3444
+ }
3445
+ #injectHTML() {
3446
+ if (document.getElementById("mobile-wallet-adapter-embedded-root-ui")) {
3447
+ if (!this.#root) this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3448
+ return;
3449
+ }
3450
+ this.#root = document.createElement("div");
3451
+ this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
3452
+ this.#root.innerHTML = modalHtml;
3453
+ this.#root.style.display = "none";
3454
+ const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
3455
+ if (content) content.innerHTML = this.contentHtml;
3456
+ const styles = document.createElement("style");
3457
+ styles.id = "mobile-wallet-adapter-embedded-modal-styles";
3458
+ styles.textContent = css$5 + this.contentStyles;
3459
+ const host = document.createElement("div");
3460
+ host.innerHTML = fonts;
3461
+ this.dom = host.attachShadow({ mode: "closed" });
3462
+ this.dom.appendChild(styles);
3463
+ this.dom.appendChild(this.#root);
3464
+ document.body.appendChild(host);
3465
+ }
3466
+ #attachEventListeners() {
3467
+ if (!this.#root || this.#listenersAttached) return;
3468
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", this.close));
3469
+ window.addEventListener("load", this.close);
3470
+ document.addEventListener("keydown", this.#handleKeyDown);
3471
+ this.#listenersAttached = true;
3472
+ }
3473
+ #removeEventListeners() {
3474
+ if (!this.#listenersAttached) return;
3475
+ window.removeEventListener("load", this.close);
3476
+ document.removeEventListener("keydown", this.#handleKeyDown);
3477
+ if (!this.#root) return;
3478
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
3479
+ this.#listenersAttached = false;
3480
+ }
3481
+ #handleKeyDown = (event) => {
3482
+ if (event.key === "Escape") this.close(event);
3483
+ };
3484
+ };
3485
+ //#endregion
3486
+ //#region src/embedded-modal/remoteConnectionModal.ts
3487
+ var RemoteConnectionModal = class extends EmbeddedModal {
3488
+ contentStyles = css$4;
3489
+ contentHtml = QRCodeHtml;
3490
+ async initWithQR(qrCode) {
3491
+ super.init();
3492
+ this.populateQRCode(qrCode);
3493
+ }
3494
+ async populateQRCode(qrUrl) {
3495
+ const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
3496
+ if (qrcodeContainer) {
3497
+ const qrCodeElement = await QRCode.toCanvas(qrUrl, {
3498
+ width: 200,
3499
+ margin: 0
3500
+ });
3501
+ if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
3502
+ else qrcodeContainer.appendChild(qrCodeElement);
3503
+ const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
3504
+ if (qrPlaceholder) qrPlaceholder.style.display = "none";
3505
+ } else console.error("QRCode Container not found");
3506
+ }
3459
3507
  };
3460
-
3461
- class RemoteConnectionModal extends EmbeddedModal {
3462
- constructor() {
3463
- super(...arguments);
3464
- this.contentStyles = css$1;
3465
- this.contentHtml = QRCodeHtml;
3466
- }
3467
- initWithQR(qrCode) {
3468
- const _super = Object.create(null, {
3469
- init: { get: () => super.init }
3470
- });
3471
- return __awaiter(this, void 0, void 0, function* () {
3472
- _super.init.call(this);
3473
- this.populateQRCode(qrCode);
3474
- });
3475
- }
3476
- populateQRCode(qrUrl) {
3477
- var _a;
3478
- return __awaiter(this, void 0, void 0, function* () {
3479
- const qrcodeContainer = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-embedded-modal-qr-code-container');
3480
- if (qrcodeContainer) {
3481
- const qrCodeElement = yield QRCode.toCanvas(qrUrl, { width: 200, margin: 0 });
3482
- if (qrcodeContainer.firstElementChild !== null) {
3483
- qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
3484
- }
3485
- else
3486
- qrcodeContainer.appendChild(qrCodeElement);
3487
- }
3488
- else {
3489
- console.error('QRCode Container not found');
3490
- }
3491
- });
3492
- }
3493
- }
3494
3508
  const QRCodeHtml = `
3495
3509
  <div class="mobile-wallet-adapter-embedded-modal-qr-content">
3496
3510
  <div>
@@ -3506,7 +3520,9 @@ const QRCodeHtml = `
3506
3520
  Open your wallet and scan this code
3507
3521
  </h4>
3508
3522
  </div>
3509
- <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container"></div>
3523
+ <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
3524
+ <div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
3525
+ </div>
3510
3526
  </div>
3511
3527
  </div>
3512
3528
  <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
@@ -3533,7 +3549,7 @@ const QRCodeHtml = `
3533
3549
  </div>
3534
3550
  </div>
3535
3551
  `;
3536
- const css$1 = `
3552
+ const css$4 = `
3537
3553
  .mobile-wallet-adapter-embedded-modal-qr-content {
3538
3554
  display: flex;
3539
3555
  margin-top: 10px;
@@ -3577,6 +3593,16 @@ const css$1 = `
3577
3593
  margin-left: auto;
3578
3594
  }
3579
3595
 
3596
+ .mobile-wallet-adapter-embedded-modal-qr-placeholder {
3597
+ margin-left: auto;
3598
+ min-width: 200px;
3599
+ min-height: 200px;
3600
+ background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
3601
+ background-size: 200%;
3602
+ animation: placeholderAnimate 2.7s linear infinite;
3603
+ border-radius: 12px;
3604
+ }
3605
+
3580
3606
  .mobile-wallet-adapter-embedded-modal-divider {
3581
3607
  margin-top: 20px;
3582
3608
  padding-left: 10px;
@@ -3649,6 +3675,15 @@ const css$1 = `
3649
3675
  .mobile-wallet-adapter-embedded-modal-qr-code-container {
3650
3676
  margin: auto;
3651
3677
  }
3678
+ .mobile-wallet-adapter-embedded-modal-qr-placeholder {
3679
+ margin: auto;
3680
+ }
3681
+ }
3682
+
3683
+ /* QR Placeholder */
3684
+ @keyframes placeholderAnimate {
3685
+ 0% { background-position: 200% 0; }
3686
+ 100% { background-position: -200% 0; }
3652
3687
  }
3653
3688
 
3654
3689
  /* Spinner */
@@ -3729,962 +3764,1173 @@ const css$1 = `
3729
3764
  animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
3730
3765
  }
3731
3766
  `;
3732
-
3733
- const icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=';
3734
-
3735
- function fromUint8Array(byteArray) {
3736
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
3767
+ //#endregion
3768
+ //#region src/embedded-modal/localConnectionModal.ts
3769
+ var LocalConnectionModal = class extends EmbeddedModal {
3770
+ contentStyles = css$3;
3771
+ contentHtml = ErrorDialogHtml$3;
3772
+ initWithCallback(callback) {
3773
+ super.init();
3774
+ this.#prepareLaunchAction(callback);
3775
+ }
3776
+ #prepareLaunchAction(callback) {
3777
+ const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
3778
+ const listener = async () => {
3779
+ launchButton?.removeEventListener("click", listener);
3780
+ this.close();
3781
+ callback();
3782
+ };
3783
+ launchButton?.addEventListener("click", listener);
3784
+ }
3785
+ };
3786
+ const ErrorDialogHtml$3 = `
3787
+ <svg class="mobile-wallet-adapter-embedded-modal-launch-icon" width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
3788
+ <path d="M21.6 48C7.2 48 0 40.8 0 26.4V21.6C0 7.2 7.2 0 21.6 0H26.4C40.8 0 48 7.2 48 21.6V26.4C48 40.8 40.8 48 26.4 48H21.6Z" fill="#15994E"/>
3789
+ <mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3790
+ <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3791
+ </mask>
3792
+ <g mask="url(#mask0_189_522)">
3793
+ <mask id="mask1_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3794
+ <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3795
+ </mask>
3796
+ <g mask="url(#mask1_189_522)">
3797
+ <path d="M22.1092 26.1208L19.4498 23.4615C19.1736 23.1851 18.8253 23.0468 18.4048 23.0468C17.9846 23.0468 17.6363 23.1851 17.3598 23.4615C17.0836 23.7377 16.9468 24.0861 16.9495 24.5065C16.9522 24.9267 17.0916 25.275 17.3678 25.5512L21.0405 29.2238C21.3463 29.5276 21.7031 29.6795 22.1108 29.6795C22.5184 29.6795 22.8742 29.5276 23.1782 29.2238L30.5918 21.8098C30.8683 21.5336 31.0065 21.1867 31.0065 20.7692C31.0065 20.3514 30.8683 20.0044 30.5918 19.7282C30.3156 19.4517 29.9673 19.3135 29.5468 19.3135C29.1266 19.3135 28.7784 19.4517 28.5022 19.7282L22.1092 26.1208ZM23.9998 37.6042C22.113 37.6042 20.3425 37.2473 18.6885 36.5335C17.0343 35.8197 15.5954 34.8512 14.3718 33.6278C13.1485 32.4043 12.18 30.9654 11.4662 29.3112C10.7524 27.6572 10.3955 25.8867 10.3955 23.9998C10.3955 22.113 10.7524 20.3425 11.4662 18.6885C12.18 17.0343 13.1485 15.5954 14.3718 14.3718C15.5954 13.1485 17.0343 12.18 18.6885 11.4662C20.3425 10.7524 22.113 10.3955 23.9998 10.3955C25.8867 10.3955 27.6572 10.7524 29.3112 11.4662C30.9654 12.18 32.4043 13.1485 33.6278 14.3718C34.8512 15.5954 35.8197 17.0343 36.5335 18.6885C37.2473 20.3425 37.6042 22.113 37.6042 23.9998C37.6042 25.8867 37.2473 27.6572 36.5335 29.3112C35.8197 30.9654 34.8512 32.4043 33.6278 33.6278C32.4043 34.8512 30.9654 35.8197 29.3112 36.5335C27.6572 37.2473 25.8867 37.6042 23.9998 37.6042Z" fill="white"/>
3798
+ </g>
3799
+ </g>
3800
+ </svg>
3801
+ <div class="mobile-wallet-adapter-embedded-modal-title">Ready to connect!</div>
3802
+ <div>
3803
+ <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
3804
+ Connect Wallet
3805
+ </button>
3806
+ </div>
3807
+ `;
3808
+ const css$3 = `
3809
+ .mobile-wallet-adapter-embedded-modal-close {
3810
+ display: none;
3737
3811
  }
3738
- function toUint8Array(base64EncodedByteArray) {
3739
- return new Uint8Array(window
3740
- .atob(base64EncodedByteArray)
3741
- .split('')
3742
- .map((c) => c.charCodeAt(0)));
3812
+ .mobile-wallet-adapter-embedded-modal-content {
3813
+ text-align: center;
3814
+ min-width: 300px;
3743
3815
  }
3744
-
3745
- var _LocalSolanaMobileWalletAdapterWallet_instances, _LocalSolanaMobileWalletAdapterWallet_listeners, _LocalSolanaMobileWalletAdapterWallet_version, _LocalSolanaMobileWalletAdapterWallet_name, _LocalSolanaMobileWalletAdapterWallet_url, _LocalSolanaMobileWalletAdapterWallet_icon, _LocalSolanaMobileWalletAdapterWallet_appIdentity, _LocalSolanaMobileWalletAdapterWallet_authorization, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, _LocalSolanaMobileWalletAdapterWallet_connecting, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, _LocalSolanaMobileWalletAdapterWallet_chains, _LocalSolanaMobileWalletAdapterWallet_chainSelector, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, _LocalSolanaMobileWalletAdapterWallet_on, _LocalSolanaMobileWalletAdapterWallet_emit, _LocalSolanaMobileWalletAdapterWallet_off, _LocalSolanaMobileWalletAdapterWallet_connect, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, _LocalSolanaMobileWalletAdapterWallet_disconnect, _LocalSolanaMobileWalletAdapterWallet_transact, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, _LocalSolanaMobileWalletAdapterWallet_signTransaction, _LocalSolanaMobileWalletAdapterWallet_signMessage, _LocalSolanaMobileWalletAdapterWallet_signIn, _LocalSolanaMobileWalletAdapterWallet_performSignIn, _RemoteSolanaMobileWalletAdapterWallet_instances, _RemoteSolanaMobileWalletAdapterWallet_listeners, _RemoteSolanaMobileWalletAdapterWallet_version, _RemoteSolanaMobileWalletAdapterWallet_name, _RemoteSolanaMobileWalletAdapterWallet_url, _RemoteSolanaMobileWalletAdapterWallet_icon, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, _RemoteSolanaMobileWalletAdapterWallet_authorization, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, _RemoteSolanaMobileWalletAdapterWallet_connecting, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, _RemoteSolanaMobileWalletAdapterWallet_chains, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, _RemoteSolanaMobileWalletAdapterWallet_session, _RemoteSolanaMobileWalletAdapterWallet_on, _RemoteSolanaMobileWalletAdapterWallet_emit, _RemoteSolanaMobileWalletAdapterWallet_off, _RemoteSolanaMobileWalletAdapterWallet_connect, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, _RemoteSolanaMobileWalletAdapterWallet_disconnect, _RemoteSolanaMobileWalletAdapterWallet_transact, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, _RemoteSolanaMobileWalletAdapterWallet_signMessage, _RemoteSolanaMobileWalletAdapterWallet_signIn, _RemoteSolanaMobileWalletAdapterWallet_performSignIn;
3746
- const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
3747
- const SolanaMobileWalletAdapterRemoteWalletName = 'Remote Mobile Wallet Adapter';
3748
- const SIGNATURE_LENGTH_IN_BYTES = 64;
3749
- const DEFAULT_FEATURES = [SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage, SolanaSignIn];
3750
- class LocalSolanaMobileWalletAdapterWallet {
3751
- constructor(config) {
3752
- _LocalSolanaMobileWalletAdapterWallet_instances.add(this);
3753
- _LocalSolanaMobileWalletAdapterWallet_listeners.set(this, {});
3754
- _LocalSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
3755
- _LocalSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterWalletName);
3756
- _LocalSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
3757
- _LocalSolanaMobileWalletAdapterWallet_icon.set(this, icon);
3758
- _LocalSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
3759
- _LocalSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
3760
- _LocalSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
3761
- _LocalSolanaMobileWalletAdapterWallet_connecting.set(this, false);
3762
- /**
3763
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
3764
- * increment this and use it to make sure that `transact` calls from the previous
3765
- * 'generation' don't continue to do work and throw exceptions.
3766
- */
3767
- _LocalSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
3768
- _LocalSolanaMobileWalletAdapterWallet_chains.set(this, []);
3769
- _LocalSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
3770
- _LocalSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
3771
- _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
3772
- _LocalSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
3773
- var _a;
3774
- ((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event] = [listener]);
3775
- return () => __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
3776
- });
3777
- _LocalSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
3778
- if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
3779
- return { accounts: this.accounts };
3780
- }
3781
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
3782
- try {
3783
- if (silent) {
3784
- const cachedAuthorization = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3785
- if (cachedAuthorization) {
3786
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, cachedAuthorization.capabilities);
3787
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorization);
3788
- }
3789
- else {
3790
- return { accounts: this.accounts };
3791
- }
3792
- }
3793
- else {
3794
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
3795
- }
3796
- }
3797
- catch (e) {
3798
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3799
- }
3800
- finally {
3801
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3802
- }
3803
- return { accounts: this.accounts };
3804
- }));
3805
- _LocalSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
3806
- try {
3807
- const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3808
- if (cachedAuthorizationResult) {
3809
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3810
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
3811
- return cachedAuthorizationResult;
3812
- }
3813
- const selectedChain = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"));
3814
- return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3815
- const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3816
- wallet.getCapabilities(),
3817
- wallet.authorize({
3818
- chain: selectedChain,
3819
- identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3820
- sign_in_payload: signInPayload,
3821
- })
3822
- ]);
3823
- const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3824
- const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
3825
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3826
- Promise.all([
3827
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
3828
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3829
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3830
- ]);
3831
- return authorization;
3832
- }));
3833
- }
3834
- catch (e) {
3835
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3836
- }
3837
- }));
3838
- _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
3839
- var _a;
3840
- const didPublicKeysChange =
3841
- // Case 1: We started from having no authorization.
3842
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
3843
- // Case 2: The number of authorized accounts changed.
3844
- ((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
3845
- // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
3846
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
3847
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, authorization);
3848
- if (didPublicKeysChange) {
3849
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3850
- }
3851
- }));
3852
- _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
3853
- // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
3854
- const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
3855
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
3856
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
3857
- SolanaSignTransaction in this.features !== supportsSignTransaction;
3858
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, ((supportsSignAndSendTransaction || (!supportsSignAndSendTransaction && !supportsSignTransaction)) && {
3859
- [SolanaSignAndSendTransaction]: {
3860
- version: '1.0.0',
3861
- supportedTransactionVersions: ['legacy', 0],
3862
- signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
3863
- },
3864
- })), (supportsSignTransaction && {
3865
- [SolanaSignTransaction]: {
3866
- version: '1.0.0',
3867
- supportedTransactionVersions: ['legacy', 0],
3868
- signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
3869
- },
3870
- })));
3871
- if (didCapabilitiesChange) {
3872
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
3873
- }
3874
- }));
3875
- _LocalSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
3876
- var _b, _c;
3877
- try {
3878
- const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3879
- (_c = (_b = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
3880
- wallet.authorize({
3881
- auth_token: authToken,
3882
- identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3883
- chain: chain
3884
- })
3885
- ]);
3886
- const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3887
- const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
3888
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3889
- Promise.all([
3890
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3891
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3892
- ]);
3893
- }
3894
- catch (e) {
3895
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
3896
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3897
- }
3898
- }));
3899
- _LocalSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
3900
- var _d;
3901
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3902
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3903
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (_d = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _d++, _d));
3904
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, undefined);
3905
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3906
- }));
3907
- _LocalSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
3908
- var _e;
3909
- const walletUriBase = (_e = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _e === void 0 ? void 0 : _e.wallet_uri_base;
3910
- const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
3911
- const currentConnectionGeneration = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
3912
- try {
3913
- return yield transact(callback, config);
3914
- }
3915
- catch (e) {
3916
- if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
3917
- yield new Promise(() => { }); // Never resolve.
3918
- }
3919
- if (e instanceof Error &&
3920
- e.name === 'SolanaMobileWalletAdapterError' &&
3921
- e.code === 'ERROR_WALLET_NOT_FOUND') {
3922
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
3923
- }
3924
- throw e;
3925
- }
3926
- }));
3927
- _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
3928
- if (!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f"))
3929
- throw new Error('Wallet not connected');
3930
- return { authToken: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").chain };
3931
- });
3932
- _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
3933
- return accounts.map((account) => {
3934
- var _a, _b;
3935
- const publicKey = toUint8Array(account.address);
3936
- return {
3937
- address: base58.encode(publicKey),
3938
- publicKey,
3939
- label: account.label,
3940
- icon: account.icon,
3941
- chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"),
3942
- // TODO: get supported features from getCapabilities API
3943
- features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
3944
- };
3945
- });
3946
- });
3947
- _LocalSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
3948
- const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3949
- try {
3950
- const base64Transactions = transactions.map((tx) => { return fromUint8Array(tx); });
3951
- return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3952
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
3953
- const signedTransactions = (yield wallet.signTransactions({
3954
- payloads: base64Transactions,
3955
- })).signed_payloads.map(toUint8Array);
3956
- return signedTransactions;
3957
- }));
3958
- }
3959
- catch (e) {
3960
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3961
- }
3962
- }));
3963
- _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
3964
- const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3965
- try {
3966
- return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3967
- const [capabilities, _1] = yield Promise.all([
3968
- wallet.getCapabilities(),
3969
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
3970
- ]);
3971
- if (capabilities.supports_sign_and_send_transactions) {
3972
- const base64Transaction = fromUint8Array(transaction);
3973
- const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [base64Transaction] }))).signatures.map(toUint8Array);
3974
- return signatures[0];
3975
- }
3976
- else {
3977
- throw new Error('connected wallet does not support signAndSendTransaction');
3978
- }
3979
- }));
3980
- }
3981
- catch (e) {
3982
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3983
- }
3984
- }));
3985
- _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3986
- const outputs = [];
3987
- for (const input of inputs) {
3988
- const signature = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options);
3989
- outputs.push({ signature });
3990
- }
3991
- return outputs;
3992
- }));
3993
- _LocalSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3994
- return (yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
3995
- .map((signedTransaction) => {
3996
- return { signedTransaction };
3997
- });
3998
- }));
3999
- _LocalSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4000
- const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4001
- const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
4002
- const messages = inputs.map(({ message }) => fromUint8Array(message));
4003
- try {
4004
- return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4005
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4006
- const signedMessages = (yield wallet.signMessages({
4007
- addresses: addresses,
4008
- payloads: messages,
4009
- })).signed_payloads.map(toUint8Array);
4010
- return signedMessages.map((signedMessage) => {
4011
- return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
4012
- });
4013
- }));
4014
- }
4015
- catch (e) {
4016
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4017
- }
4018
- }));
4019
- _LocalSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4020
- const outputs = [];
4021
- if (inputs.length > 1) {
4022
- for (const input of inputs) {
4023
- outputs.push(yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
4024
- }
4025
- }
4026
- else {
4027
- return [yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
4028
- }
4029
- return outputs;
4030
- }));
4031
- _LocalSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
4032
- var _f, _g, _h;
4033
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
4034
- try {
4035
- const authorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_f = input === null || input === void 0 ? void 0 : input.domain) !== null && _f !== void 0 ? _f : window.location.host }));
4036
- if (!authorizationResult.sign_in_result) {
4037
- throw new Error("Sign in failed, no sign in result returned by wallet");
4038
- }
4039
- const signedInAddress = authorizationResult.sign_in_result.address;
4040
- const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
4041
- return {
4042
- account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
4043
- address: base58.encode(toUint8Array(signedInAddress))
4044
- }), { publicKey: toUint8Array(signedInAddress), chains: (_g = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _g !== void 0 ? _g : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"), features: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _h !== void 0 ? _h : authorizationResult.capabilities.features }),
4045
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4046
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
4047
- };
4048
- }
4049
- catch (e) {
4050
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4051
- }
4052
- finally {
4053
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
4054
- }
4055
- }));
4056
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
4057
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
4058
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, config.chains);
4059
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
4060
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
4061
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, {
4062
- // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
4063
- // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
4064
- // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
4065
- // assume both are supported here. The features will be updated based on the actual connected
4066
- // wallets capabilities during connection regardless, so this is safe.
4067
- [SolanaSignAndSendTransaction]: {
4068
- version: '1.0.0',
4069
- supportedTransactionVersions: ['legacy', 0],
4070
- signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4071
- },
4072
- [SolanaSignTransaction]: {
4073
- version: '1.0.0',
4074
- supportedTransactionVersions: ['legacy', 0],
4075
- signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4076
- },
4077
- });
4078
- }
4079
- get version() {
4080
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_version, "f");
4081
- }
4082
- get name() {
4083
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_name, "f");
4084
- }
4085
- get url() {
4086
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_url, "f");
4087
- }
4088
- get icon() {
4089
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_icon, "f");
4090
- }
4091
- get chains() {
4092
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f");
4093
- }
4094
- get features() {
4095
- return Object.assign({ [StandardConnect]: {
4096
- version: '1.0.0',
4097
- connect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connect, "f"),
4098
- }, [StandardDisconnect]: {
4099
- version: '1.0.0',
4100
- disconnect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f"),
4101
- }, [StandardEvents]: {
4102
- version: '1.0.0',
4103
- on: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_on, "f"),
4104
- }, [SolanaSignMessage]: {
4105
- version: '1.0.0',
4106
- signMessage: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signMessage, "f"),
4107
- }, [SolanaSignIn]: {
4108
- version: '1.0.0',
4109
- signIn: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signIn, "f"),
4110
- } }, __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
4111
- }
4112
- get accounts() {
4113
- var _a, _b;
4114
- return (_b = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
4115
- }
4116
- get connected() {
4117
- return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4118
- }
4119
- get isAuthorized() {
4120
- return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4121
- }
4122
- get currentAuthorization() {
4123
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4124
- }
4125
- get cachedAuthorizationResult() {
4126
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4127
- }
3816
+ .mobile-wallet-adapter-embedded-modal-launch-icon {
3817
+ margin-top: 24px;
4128
3818
  }
4129
- _LocalSolanaMobileWalletAdapterWallet_listeners = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_version = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_name = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_url = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_icon = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_appIdentity = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_authorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_authorizationCache = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connecting = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connectionGeneration = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_chains = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_chainSelector = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_optionalFeatures = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_on = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connect = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performAuthorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performReauthorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_disconnect = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_transact = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignTransactions = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signMessage = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signIn = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignIn = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_instances = new WeakSet(), _LocalSolanaMobileWalletAdapterWallet_emit = function _LocalSolanaMobileWalletAdapterWallet_emit(event, ...args) {
4130
- var _a;
4131
- // eslint-disable-next-line prefer-spread
4132
- (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
4133
- }, _LocalSolanaMobileWalletAdapterWallet_off = function _LocalSolanaMobileWalletAdapterWallet_off(event, listener) {
4134
- var _a;
4135
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
4136
- };
4137
- class RemoteSolanaMobileWalletAdapterWallet {
4138
- constructor(config) {
4139
- _RemoteSolanaMobileWalletAdapterWallet_instances.add(this);
4140
- _RemoteSolanaMobileWalletAdapterWallet_listeners.set(this, {});
4141
- _RemoteSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
4142
- _RemoteSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterRemoteWalletName);
4143
- _RemoteSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
4144
- _RemoteSolanaMobileWalletAdapterWallet_icon.set(this, icon);
4145
- _RemoteSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
4146
- _RemoteSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
4147
- _RemoteSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
4148
- _RemoteSolanaMobileWalletAdapterWallet_connecting.set(this, false);
4149
- /**
4150
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4151
- * increment this and use it to make sure that `transact` calls from the previous
4152
- * 'generation' don't continue to do work and throw exceptions.
4153
- */
4154
- _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
4155
- _RemoteSolanaMobileWalletAdapterWallet_chains.set(this, []);
4156
- _RemoteSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
4157
- _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
4158
- _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
4159
- _RemoteSolanaMobileWalletAdapterWallet_hostAuthority.set(this, void 0);
4160
- _RemoteSolanaMobileWalletAdapterWallet_session.set(this, void 0);
4161
- _RemoteSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
4162
- var _a;
4163
- ((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event] = [listener]);
4164
- return () => __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
4165
- });
4166
- _RemoteSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
4167
- if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
4168
- return { accounts: this.accounts };
4169
- }
4170
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
4171
- try {
4172
- yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
4173
- }
4174
- catch (e) {
4175
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4176
- }
4177
- finally {
4178
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4179
- }
4180
- return { accounts: this.accounts };
4181
- }));
4182
- _RemoteSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
4183
- try {
4184
- const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4185
- if (cachedAuthorizationResult) {
4186
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4187
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
4188
- return cachedAuthorizationResult;
4189
- }
4190
- if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f"))
4191
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined, "f");
4192
- const selectedChain = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"));
4193
- return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4194
- const [capabilities, mwaAuthorizationResult] = yield Promise.all([
4195
- wallet.getCapabilities(),
4196
- wallet.authorize({
4197
- chain: selectedChain,
4198
- identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
4199
- sign_in_payload: signInPayload,
4200
- })
4201
- ]);
4202
- const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
4203
- const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
4204
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4205
- Promise.all([
4206
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
4207
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorizationResult),
4208
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorizationResult),
4209
- ]);
4210
- return authorizationResult;
4211
- }));
4212
- }
4213
- catch (e) {
4214
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4215
- }
4216
- }));
4217
- _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
4218
- var _a;
4219
- const didPublicKeysChange =
4220
- // Case 1: We started from having no authorization.
4221
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
4222
- // Case 2: The number of authorized accounts changed.
4223
- ((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
4224
- // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
4225
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4226
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, authorization);
4227
- if (didPublicKeysChange) {
4228
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
4229
- }
4230
- }));
4231
- _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
4232
- // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
4233
- const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
4234
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions ||
4235
- capabilities.features.includes('solana:signAndSendTransaction');
4236
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
4237
- SolanaSignTransaction in this.features !== supportsSignTransaction;
4238
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, (supportsSignAndSendTransaction && {
4239
- [SolanaSignAndSendTransaction]: {
4240
- version: '1.0.0',
4241
- supportedTransactionVersions: capabilities.supported_transaction_versions,
4242
- signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4243
- },
4244
- })), (supportsSignTransaction && {
4245
- [SolanaSignTransaction]: {
4246
- version: '1.0.0',
4247
- supportedTransactionVersions: capabilities.supported_transaction_versions,
4248
- signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4249
- },
4250
- })));
4251
- if (didCapabilitiesChange) {
4252
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
4253
- }
4254
- }));
4255
- _RemoteSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
4256
- var _b, _c;
4257
- try {
4258
- const [capabilities, mwaAuthorizationResult] = yield Promise.all([
4259
- (_c = (_b = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
4260
- wallet.authorize({
4261
- auth_token: authToken,
4262
- identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
4263
- chain: chain
4264
- })
4265
- ]);
4266
- const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
4267
- const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
4268
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4269
- Promise.all([
4270
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
4271
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
4272
- ]);
4273
- }
4274
- catch (e) {
4275
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
4276
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4277
- }
4278
- }));
4279
- _RemoteSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
4280
- var _d;
4281
- var _e;
4282
- (_d = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) === null || _d === void 0 ? void 0 : _d.close();
4283
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4284
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4285
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (_e = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _e++, _e));
4286
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, undefined);
4287
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined);
4288
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
4289
- }));
4290
- _RemoteSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
4291
- var _f;
4292
- const walletUriBase = (_f = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _f === void 0 ? void 0 : _f.wallet_uri_base;
4293
- const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
4294
- const remoteConfig = Object.assign(Object.assign({}, baseConfig), { remoteHostAuthority: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, "f") });
4295
- const currentConnectionGeneration = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
4296
- const modal = new RemoteConnectionModal();
4297
- if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) {
4298
- return callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
4299
- }
4300
- try {
4301
- const { associationUrl, close, wallet } = yield startRemoteScenario(remoteConfig);
4302
- const removeCloseListener = modal.addEventListener('close', (event) => {
4303
- if (event)
4304
- close();
4305
- });
4306
- modal.initWithQR(associationUrl.toString());
4307
- modal.open();
4308
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, { close, wallet: yield wallet }, "f");
4309
- removeCloseListener();
4310
- modal.close();
4311
- return yield callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
4312
- }
4313
- catch (e) {
4314
- modal.close();
4315
- if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
4316
- yield new Promise(() => { }); // Never resolve.
4317
- }
4318
- if (e instanceof Error &&
4319
- e.name === 'SolanaMobileWalletAdapterError' &&
4320
- e.code === 'ERROR_WALLET_NOT_FOUND') {
4321
- yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
4322
- }
4323
- throw e;
4324
- }
4325
- }));
4326
- _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
4327
- if (!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f"))
4328
- throw new Error('Wallet not connected');
4329
- return { authToken: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").chain };
4330
- });
4331
- _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
4332
- return accounts.map((account) => {
4333
- var _a, _b;
4334
- const publicKey = toUint8Array(account.address);
4335
- return {
4336
- address: base58.encode(publicKey),
4337
- publicKey,
4338
- label: account.label,
4339
- icon: account.icon,
4340
- chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"),
4341
- // TODO: get supported features from getCapabilities API
4342
- features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
4343
- };
4344
- });
4345
- });
4346
- _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
4347
- const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4348
- try {
4349
- return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4350
- yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4351
- const signedTransactions = (yield wallet.signTransactions({
4352
- payloads: transactions.map(fromUint8Array),
4353
- })).signed_payloads.map(toUint8Array);
4354
- return signedTransactions;
4355
- }));
4356
- }
4357
- catch (e) {
4358
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4359
- }
4360
- }));
4361
- _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
4362
- const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4363
- try {
4364
- return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4365
- const [capabilities, _1] = yield Promise.all([
4366
- wallet.getCapabilities(),
4367
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
4368
- ]);
4369
- if (capabilities.supports_sign_and_send_transactions) {
4370
- const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [fromUint8Array(transaction)] }))).signatures.map(toUint8Array);
4371
- return signatures[0];
4372
- }
4373
- else {
4374
- throw new Error('connected wallet does not support signAndSendTransaction');
4375
- }
4376
- }));
4377
- }
4378
- catch (e) {
4379
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4380
- }
4381
- }));
4382
- _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4383
- const outputs = [];
4384
- for (const input of inputs) {
4385
- const signature = (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options));
4386
- outputs.push({ signature });
4387
- }
4388
- return outputs;
4389
- }));
4390
- _RemoteSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4391
- return (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
4392
- .map((signedTransaction) => {
4393
- return { signedTransaction };
4394
- });
4395
- }));
4396
- _RemoteSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4397
- const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4398
- const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
4399
- const messages = inputs.map(({ message }) => fromUint8Array(message));
4400
- try {
4401
- return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4402
- yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4403
- const signedMessages = (yield wallet.signMessages({
4404
- addresses: addresses,
4405
- payloads: messages,
4406
- })).signed_payloads.map(toUint8Array);
4407
- return signedMessages.map((signedMessage) => {
4408
- return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
4409
- });
4410
- }));
4411
- }
4412
- catch (e) {
4413
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4414
- }
4415
- }));
4416
- _RemoteSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4417
- const outputs = [];
4418
- if (inputs.length > 1) {
4419
- for (const input of inputs) {
4420
- outputs.push(yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
4421
- }
4422
- }
4423
- else {
4424
- return [yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
4425
- }
4426
- return outputs;
4427
- }));
4428
- _RemoteSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
4429
- var _g, _h, _j;
4430
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
4431
- try {
4432
- const authorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_g = input === null || input === void 0 ? void 0 : input.domain) !== null && _g !== void 0 ? _g : window.location.host }));
4433
- if (!authorizationResult.sign_in_result) {
4434
- throw new Error("Sign in failed, no sign in result returned by wallet");
4435
- }
4436
- const signedInAddress = authorizationResult.sign_in_result.address;
4437
- const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
4438
- return {
4439
- account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
4440
- address: base58.encode(toUint8Array(signedInAddress))
4441
- }), { publicKey: toUint8Array(signedInAddress), chains: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _h !== void 0 ? _h : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"), features: (_j = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _j !== void 0 ? _j : authorizationResult.capabilities.features }),
4442
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4443
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
4444
- };
4445
- }
4446
- catch (e) {
4447
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4448
- }
4449
- finally {
4450
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4451
- }
4452
- }));
4453
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
4454
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
4455
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, config.chains);
4456
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
4457
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, config.remoteHostAuthority);
4458
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
4459
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, {
4460
- // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
4461
- // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
4462
- // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
4463
- // assume both are supported here. The features will be updated based on the actual connected
4464
- // wallets capabilities during connection regardless, so this is safe.
4465
- [SolanaSignAndSendTransaction]: {
4466
- version: '1.0.0',
4467
- supportedTransactionVersions: ['legacy', 0],
4468
- signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4469
- },
4470
- [SolanaSignTransaction]: {
4471
- version: '1.0.0',
4472
- supportedTransactionVersions: ['legacy', 0],
4473
- signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4474
- },
4475
- });
4476
- }
4477
- get version() {
4478
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_version, "f");
4479
- }
4480
- get name() {
4481
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_name, "f");
4482
- }
4483
- get url() {
4484
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_url, "f");
4485
- }
4486
- get icon() {
4487
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_icon, "f");
4488
- }
4489
- get chains() {
4490
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f");
4491
- }
4492
- get features() {
4493
- return Object.assign({ [StandardConnect]: {
4494
- version: '1.0.0',
4495
- connect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connect, "f"),
4496
- }, [StandardDisconnect]: {
4497
- version: '1.0.0',
4498
- disconnect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f"),
4499
- }, [StandardEvents]: {
4500
- version: '1.0.0',
4501
- on: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_on, "f"),
4502
- }, [SolanaSignMessage]: {
4503
- version: '1.0.0',
4504
- signMessage: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signMessage, "f"),
4505
- }, [SolanaSignIn]: {
4506
- version: '1.0.0',
4507
- signIn: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signIn, "f"),
4508
- } }, __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
4509
- }
4510
- get accounts() {
4511
- var _a, _b;
4512
- return (_b = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
4513
- }
4514
- get connected() {
4515
- return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f") && !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4516
- }
4517
- get isAuthorized() {
4518
- return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4519
- }
4520
- get currentAuthorization() {
4521
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4522
- }
4523
- get cachedAuthorizationResult() {
4524
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4525
- }
3819
+ .mobile-wallet-adapter-embedded-modal-title {
3820
+ margin: 18px 100px 30px 100px;
3821
+ color: #000000;
3822
+ font-size: 2.75em;
3823
+ font-weight: 600;
4526
3824
  }
4527
- _RemoteSolanaMobileWalletAdapterWallet_listeners = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_version = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_name = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_url = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_icon = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_appIdentity = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_authorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_authorizationCache = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connecting = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_chains = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_chainSelector = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_hostAuthority = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_session = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_on = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connect = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performAuthorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performReauthorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_disconnect = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_transact = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signMessage = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signIn = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignIn = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_instances = new WeakSet(), _RemoteSolanaMobileWalletAdapterWallet_emit = function _RemoteSolanaMobileWalletAdapterWallet_emit(event, ...args) {
4528
- var _a;
4529
- // eslint-disable-next-line prefer-spread
4530
- (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
4531
- }, _RemoteSolanaMobileWalletAdapterWallet_off = function _RemoteSolanaMobileWalletAdapterWallet_off(event, listener) {
4532
- var _a;
4533
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
4534
- };
4535
-
4536
- var __classPrivateFieldSet = function (receiver, state, value, kind, f) {
4537
- if (kind === "m") throw new TypeError("Private method is not writable");
4538
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4539
- 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");
4540
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
4541
- };
4542
- var __classPrivateFieldGet = function (receiver, state, kind, f) {
4543
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4544
- 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");
4545
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4546
- };
4547
- var _RegisterWalletEvent_detail;
4548
- /**
4549
- * Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
4550
- *
4551
- * This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
4552
- * ready to be registered.
4553
- *
4554
- * This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
4555
- * the app that the app is ready to register the Wallet.
4556
- *
4557
- * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
4558
- * as the app is ready whether the Wallet loads before or after the app.
4559
- *
4560
- * @param wallet Wallet to register.
4561
- *
4562
- * @group Wallet
4563
- */
4564
- function registerWallet(wallet) {
4565
- const callback = ({ register }) => register(wallet);
4566
- try {
4567
- window.dispatchEvent(new RegisterWalletEvent(callback));
4568
- }
4569
- catch (error) {
4570
- console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
4571
- }
4572
- try {
4573
- window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
4574
- }
4575
- catch (error) {
4576
- console.error('wallet-standard:app-ready event listener could not be added\n', error);
4577
- }
3825
+ .mobile-wallet-adapter-embedded-modal-launch-action {
3826
+ display: block;
3827
+ width: 100%;
3828
+ height: 56px;
3829
+ font-size: 1.25em;
3830
+ background: #000000;
3831
+ color: #FFFFFF;
3832
+ border-radius: 18px;
4578
3833
  }
4579
- class RegisterWalletEvent extends Event {
4580
- constructor(callback) {
4581
- super('wallet-standard:register-wallet', {
4582
- bubbles: false,
4583
- cancelable: false,
4584
- composed: false,
4585
- });
4586
- _RegisterWalletEvent_detail.set(this, void 0);
4587
- __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
4588
- }
4589
- get detail() {
4590
- return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
3834
+ /* Smaller screens */
3835
+ @media all and (max-width: 600px) {
3836
+ .mobile-wallet-adapter-embedded-modal-title {
3837
+ font-size: 1.5em;
3838
+ margin-right: 12px;
3839
+ margin-left: 12px;
4591
3840
  }
4592
- get type() {
4593
- return 'wallet-standard:register-wallet';
3841
+ }
3842
+ `;
3843
+ //#endregion
3844
+ //#region src/embedded-modal/loopbackBlockedModal.ts
3845
+ var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
3846
+ contentStyles = css$2;
3847
+ get contentHtml() {
3848
+ const instructions = getIsPwaLaunchedAsApp() ? "Long press the app icon on your home screen to open site settings" : "Tap the lock or settings icon in the address bar to open site settings";
3849
+ return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
3850
+ }
3851
+ async init() {
3852
+ super.init();
3853
+ this.#prepareLaunchAction();
3854
+ }
3855
+ #prepareLaunchAction() {
3856
+ const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
3857
+ const listener = async (event) => {
3858
+ launchButton?.removeEventListener("click", listener);
3859
+ this.close(event);
3860
+ };
3861
+ launchButton?.addEventListener("click", listener);
3862
+ }
3863
+ };
3864
+ const ErrorDialogHtml$2 = `
3865
+ <div class="mobile-wallet-adapter-embedded-modal-header">
3866
+ Local Wallet Connection
3867
+ </div>
3868
+ <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
3869
+ <path d="M21.6 48C7.2 48 0 40.8 0 26.4V21.6C0 7.2 7.2 0 21.6 0H26.4C40.8 0 48 7.2 48 21.6V26.4C48 40.8 40.8 48 26.4 48H21.6Z" fill="#ED1515"/>
3870
+ <mask id="mask0_147_1364" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3871
+ <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3872
+ </mask>
3873
+ <g mask="url(#mask0_147_1364)">
3874
+ <path d="M20.1398 36.2705C19.7363 36.2705 19.3508 36.1945 18.9835 36.0425C18.6162 35.8907 18.2916 35.674 18.0098 35.3922L12.6072 29.9895C12.3254 29.7077 12.1086 29.3832 11.9568 29.0158C11.8048 28.6485 11.7288 28.2631 11.7288 27.8595V20.1395C11.7288 19.736 11.8048 19.3505 11.9568 18.9832C12.1086 18.6158 12.3254 18.2913 12.6072 18.0095L18.0098 12.6068C18.2916 12.3251 18.6162 12.1083 18.9835 11.9565C19.3508 11.8045 19.7363 11.7285 20.1398 11.7285H27.8598C28.2634 11.7285 28.6488 11.8045 29.0162 11.9565C29.3835 12.1083 29.708 12.3251 29.9898 12.6068L35.3925 18.0095C35.6743 18.2913 35.891 18.6158 36.0428 18.9832C36.1948 19.3505 36.2708 19.736 36.2708 20.1395V27.8595C36.2708 28.2631 36.1948 28.6485 36.0428 29.0158C35.891 29.3832 35.6743 29.7077 35.3925 29.9895L29.9898 35.3922C29.708 35.674 29.3835 35.8907 29.0162 36.0425C28.6488 36.1945 28.2634 36.2705 27.8598 36.2705H20.1398ZM20.1732 33.2372H27.8265L33.2375 27.8262V20.1728L27.8265 14.7618H20.1732L14.7622 20.1728V27.8262L20.1732 33.2372ZM23.9998 25.9538L26.7868 28.7408C27.0473 29.0013 27.3729 29.1302 27.7638 29.1275C28.1549 29.1248 28.4807 28.9933 28.7412 28.7328C29.0016 28.4724 29.1318 28.1466 29.1318 27.7555C29.1318 27.3646 29.0016 27.039 28.7412 26.7785L25.9542 23.9995L28.7412 21.2125C29.0016 20.9521 29.1318 20.6264 29.1318 20.2355C29.1318 19.8444 29.0016 19.5186 28.7412 19.2582C28.4807 18.9977 28.1549 18.8675 27.7638 18.8675C27.3729 18.8675 27.0473 18.9977 26.7868 19.2582L23.9998 22.0452L21.2128 19.2582C20.9524 18.9977 20.628 18.8675 20.2398 18.8675C19.8514 18.8675 19.5269 18.9977 19.2665 19.2582C19.006 19.5186 18.8758 19.8444 18.8758 20.2355C18.8758 20.6264 19.006 20.9521 19.2665 21.2125L22.0455 23.9995L19.2585 26.7865C18.998 27.047 18.8692 27.3713 18.8718 27.7595C18.8745 28.148 19.006 28.4724 19.2665 28.7328C19.5269 28.9933 19.8527 29.1235 20.2438 29.1235C20.6347 29.1235 20.9604 28.9933 21.2208 28.7328L23.9998 25.9538Z" fill="black"/>
3875
+ </g>
3876
+ </svg>
3877
+ <div class="mobile-wallet-adapter-embedded-modal-title">
3878
+ Your wallet connection is blocked
3879
+ </div>
3880
+ <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
3881
+ Visit site settings in the address bar and allow "Apps on Device".
3882
+ </div>
3883
+
3884
+ <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
3885
+ <div class="mobile-wallet-adapter-embedded-modal-footer">
3886
+ <div class="mobile-wallet-adapter-embedded-modal-details">
3887
+ <!-- Clickable header (label associated with the checkbox) -->
3888
+ <label for="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-header">
3889
+ <!-- Hidden checkbox to track state -->
3890
+ <input type="checkbox" id="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-input">
3891
+ <span class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-label">
3892
+ See details
3893
+ </span>
3894
+ <svg class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3895
+ <mask id="mask0_147_1382" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
3896
+ <rect width="24" height="24" fill="#D9D9D9"/>
3897
+ </mask>
3898
+ <g mask="url(#mask0_147_1382)">
3899
+ <path d="M11.9999 17.0811C11.8506 17.0811 11.7087 17.0563 11.5741 17.0067C11.4395 16.957 11.3162 16.8762 11.2042 16.7643L6.57924 12.1393C6.36801 11.9281 6.26656 11.667 6.27489 11.3561C6.28322 11.0453 6.39301 10.7842 6.60424 10.573C6.81547 10.3618 7.08069 10.2561 7.39989 10.2561C7.71909 10.2561 7.9843 10.3618 8.19554 10.573L11.9999 14.3773L15.8292 10.548C16.0405 10.3368 16.3015 10.2353 16.6124 10.2436C16.9233 10.252 17.1843 10.3618 17.3955 10.573C17.6068 10.7842 17.7124 11.0494 17.7124 11.3686C17.7124 11.6878 17.6068 11.9531 17.3955 12.1643L12.7955 16.7643C12.6836 16.8762 12.5603 16.957 12.4257 17.0067C12.2911 17.0563 12.1492 17.0811 11.9999 17.0811Z" fill="black"/>
3900
+ </g>
3901
+ </svg>
3902
+ </label>
3903
+
3904
+ <!-- Content to show/hide -->
3905
+ <ul class="mobile-wallet-adapter-embedded-modal-details-collapsible-content">
3906
+ <li>{{PERMISSION_INSTRUCTION_DETAIL}}</li>
3907
+ <li>Allow "Apps on Device"</li>
3908
+ </ul>
3909
+ </div>
3910
+ </div>
3911
+ <div>
3912
+ <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
3913
+ Got it
3914
+ </button>
3915
+ </div>
3916
+ `;
3917
+ const css$2 = `
3918
+ .mobile-wallet-adapter-embedded-modal-close {
3919
+ display: none;
3920
+ }
3921
+ .mobile-wallet-adapter-embedded-modal-content {
3922
+ text-align: center;
3923
+ }
3924
+ .mobile-wallet-adapter-embedded-modal-header {
3925
+ margin: 18px auto 30px auto;
3926
+ color: #7D9093;
3927
+ font-size: 1.0em;
3928
+ font-weight: 500;
3929
+ }
3930
+ .mobile-wallet-adapter-embedded-modal-title {
3931
+ margin: 18px 100px auto 100px;
3932
+ color: #000000;
3933
+ font-size: 2.75em;
3934
+ font-weight: 600;
3935
+ }
3936
+ .mobile-wallet-adapter-embedded-modal-subtitle {
3937
+ margin: 12px 60px 30px 60px;
3938
+ color: #7D9093;
3939
+ font-size: 1.25em;
3940
+ font-weight: 400;
3941
+ }
3942
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-header {
3943
+ display: flex;
3944
+ flex-direction: row;
3945
+ justify-content: space-between;
3946
+ margin: 10px auto 10px auto;
3947
+ color: #000000;
3948
+ font-size: 1.5em;
3949
+ font-weight: 600;
3950
+ cursor: pointer; /* Show pointer on hover */
3951
+ transition: background 0.2s ease; /* Smooth background change */
3952
+ }
3953
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
3954
+ transition: rotate 0.3s ease;
3955
+ }
3956
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-input {
3957
+ display: none; /* Hide the checkbox */
3958
+ }
3959
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
3960
+ margin: 0px auto 40px auto;
3961
+ max-height: 0px; /* Collapse content */
3962
+ overflow: hidden; /* Hide overflow when collapsed */
3963
+ transition: max-height 0.3s ease; /* Smooth transition */
3964
+ }
3965
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-content li {
3966
+ margin: 20px auto;
3967
+ color: #000000;
3968
+ font-size: 1.25em;
3969
+ font-weight: 400;
3970
+ text-align: left;
3971
+ }
3972
+ /* When checkbox is checked, show content */
3973
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) ~ .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
3974
+ max-height: 300px;
3975
+ }
3976
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) > .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
3977
+ rotate: 180deg;
3978
+ }
3979
+ .mobile-wallet-adapter-embedded-modal-launch-action {
3980
+ display: block;
3981
+ width: 100%;
3982
+ height: 56px;
3983
+ /*margin-top: 40px;*/
3984
+ font-size: 1.25em;
3985
+ /*line-height: 24px;*/
3986
+ /*letter-spacing: -1%;*/
3987
+ background: #000000;
3988
+ color: #FFFFFF;
3989
+ border-radius: 18px;
3990
+ }
3991
+ /* Smaller screens */
3992
+ @media all and (max-width: 600px) {
3993
+ .mobile-wallet-adapter-embedded-modal-title {
3994
+ font-size: 1.75em;
3995
+ margin-right: 12px;
3996
+ margin-left: 12px;
4594
3997
  }
4595
- /** @deprecated */
4596
- preventDefault() {
4597
- throw new Error('preventDefault cannot be called');
3998
+ .mobile-wallet-adapter-embedded-modal-subtitle {
3999
+ margin-right: 12px;
4000
+ margin-left: 12px;
4598
4001
  }
4599
- /** @deprecated */
4600
- stopImmediatePropagation() {
4601
- throw new Error('stopImmediatePropagation cannot be called');
4002
+ }
4003
+ `;
4004
+ //#endregion
4005
+ //#region src/embedded-modal/loopbackPermissionModal.ts
4006
+ var LoopbackPermissionModal = class extends EmbeddedModal {
4007
+ contentStyles = css$1;
4008
+ contentHtml = ErrorDialogHtml$1;
4009
+ async init() {
4010
+ super.init();
4011
+ this.#prepareLaunchAction();
4012
+ }
4013
+ #prepareLaunchAction() {
4014
+ const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
4015
+ const listener = async () => {
4016
+ launchButton?.removeEventListener("click", listener);
4017
+ try {
4018
+ await fetch("http://localhost");
4019
+ } catch {}
4020
+ this.close();
4021
+ };
4022
+ launchButton?.addEventListener("click", listener);
4023
+ }
4024
+ };
4025
+ const ErrorDialogHtml$1 = `
4026
+ <div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
4027
+ <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
4028
+ Tap "Allow" on the next screen
4029
+ </div>
4030
+ <svg class="mobile-wallet-adapter-embedded-modal-permission-prompt-mock" xmlns="http://www.w3.org/2000/svg" width="281" height="83" viewBox="0 0 281 83" fill="none">
4031
+ <rect width="281" height="83" rx="22" fill="#F0F3F5"/>
4032
+ <path d="M254.194 64L252.626 56.657H254.047L254.866 61.452L254.985 62.278H255.02L255.146 61.452L255.993 57.497H257.4L258.254 61.431L258.373 62.278H258.415L258.534 61.431L259.346 56.657H260.718L259.143 64H257.673L256.826 59.961L256.693 59.093H256.651L256.511 59.961L255.664 64H254.194Z" fill="black"/>
4033
+ <path d="M248.837 64.231C248.147 64.231 247.54 64.07 247.017 63.748C246.495 63.426 246.086 62.978 245.792 62.404C245.498 61.83 245.351 61.1673 245.351 60.416V60.241C245.351 59.4897 245.498 58.827 245.792 58.253C246.086 57.679 246.495 57.2333 247.017 56.916C247.54 56.594 248.147 56.433 248.837 56.433C249.528 56.433 250.135 56.594 250.657 56.916C251.18 57.2333 251.588 57.679 251.882 58.253C252.176 58.827 252.323 59.4897 252.323 60.241V60.416C252.323 61.1673 252.176 61.83 251.882 62.404C251.588 62.978 251.18 63.426 250.657 63.748C250.135 64.07 249.528 64.231 248.837 64.231ZM248.837 62.824C249.43 62.824 249.897 62.607 250.237 62.173C250.583 61.7343 250.755 61.1417 250.755 60.395V60.262C250.755 59.5107 250.583 58.918 250.237 58.484C249.897 58.05 249.43 57.833 248.837 57.833C248.249 57.833 247.783 58.05 247.437 58.484C247.092 58.918 246.919 59.5107 246.919 60.262V60.395C246.919 61.1417 247.092 61.7343 247.437 62.173C247.783 62.607 248.249 62.824 248.837 62.824Z" fill="black"/>
4034
+ <path d="M242.298 64.231C241.467 64.231 240.814 63.993 240.338 63.517C239.866 63.0364 239.631 62.3737 239.631 61.529V53.78H241.178V61.389C241.178 62.3317 241.591 62.803 242.417 62.803C242.65 62.803 242.865 62.7587 243.061 62.67C243.257 62.5814 243.464 62.4367 243.684 62.236L244.538 63.377C244.225 63.6664 243.884 63.881 243.516 64.021C243.152 64.161 242.746 64.231 242.298 64.231ZM237.51 55.061V53.78H240.611V55.061H237.51Z" fill="black"/>
4035
+ <path d="M234.463 64.231C233.633 64.231 232.979 63.993 232.503 63.517C232.032 63.0364 231.796 62.3737 231.796 61.529V53.78H233.343V61.389C233.343 62.3317 233.756 62.803 234.582 62.803C234.816 62.803 235.03 62.7587 235.226 62.67C235.422 62.5814 235.63 62.4367 235.849 62.236L236.703 63.377C236.391 63.6664 236.05 63.881 235.681 64.021C235.317 64.161 234.911 64.231 234.463 64.231ZM229.675 55.061V53.78H232.776V55.061H229.675Z" fill="black"/>
4036
+ <path d="M221.442 64L224.557 53.976H226.132L229.233 64H227.581L225.642 56.972L225.341 55.761H225.299L225.005 56.972L223.073 64H221.442ZM222.835 61.634L223.255 60.29H227.371L227.805 61.634H222.835Z" fill="black"/>
4037
+ <path d="M178.261 64L175.034 60.066V60.024L178.121 56.657H180.011L176.504 60.423V59.632L180.165 64H178.261ZM173.543 64V53.78H175.097V64H173.543Z" fill="#7D9093" fill-opacity="0.5"/>
4038
+ <path d="M169.306 64.224C168.588 64.224 167.958 64.0653 167.416 63.748C166.88 63.426 166.462 62.9803 166.163 62.411C165.865 61.837 165.715 61.1673 165.715 60.402V60.248C165.715 59.4873 165.862 58.8223 166.156 58.253C166.45 57.679 166.863 57.2333 167.395 56.916C167.927 56.594 168.546 56.433 169.25 56.433C169.978 56.433 170.59 56.6056 171.084 56.951C171.579 57.2917 171.955 57.777 172.211 58.407L170.874 58.995C170.72 58.6123 170.508 58.323 170.237 58.127C169.967 57.9263 169.633 57.826 169.236 57.826C168.63 57.826 168.149 58.0383 167.794 58.463C167.444 58.883 167.269 59.4616 167.269 60.199V60.465C167.269 61.1837 167.454 61.7577 167.822 62.187C168.196 62.6163 168.69 62.831 169.306 62.831C169.712 62.831 170.06 62.733 170.349 62.537C170.639 62.341 170.877 62.0423 171.063 61.641L172.379 62.285C172.188 62.6957 171.941 63.0457 171.637 63.335C171.334 63.6243 170.986 63.846 170.594 64C170.202 64.1493 169.773 64.224 169.306 64.224Z" fill="#7D9093" fill-opacity="0.5"/>
4039
+ <path d="M161.003 64.231C160.312 64.231 159.706 64.07 159.183 63.748C158.66 63.426 158.252 62.978 157.958 62.404C157.664 61.83 157.517 61.1673 157.517 60.416V60.241C157.517 59.4897 157.664 58.827 157.958 58.253C158.252 57.679 158.66 57.2333 159.183 56.916C159.706 56.594 160.312 56.433 161.003 56.433C161.694 56.433 162.3 56.594 162.823 56.916C163.346 57.2333 163.754 57.679 164.048 58.253C164.342 58.827 164.489 59.4897 164.489 60.241V60.416C164.489 61.1673 164.342 61.83 164.048 62.404C163.754 62.978 163.346 63.426 162.823 63.748C162.3 64.07 161.694 64.231 161.003 64.231ZM161.003 62.824C161.596 62.824 162.062 62.607 162.403 62.173C162.748 61.7343 162.921 61.1417 162.921 60.395V60.262C162.921 59.5107 162.748 58.918 162.403 58.484C162.062 58.05 161.596 57.833 161.003 57.833C160.415 57.833 159.948 58.05 159.603 58.484C159.258 58.918 159.085 59.5107 159.085 60.262V60.395C159.085 61.1417 159.258 61.7343 159.603 62.173C159.948 62.607 160.415 62.824 161.003 62.824Z" fill="#7D9093" fill-opacity="0.5"/>
4040
+ <path d="M154.463 64.231C153.633 64.231 152.979 63.993 152.503 63.517C152.032 63.0364 151.796 62.3737 151.796 61.529V53.78H153.343V61.389C153.343 62.3317 153.756 62.803 154.582 62.803C154.816 62.803 155.03 62.7587 155.226 62.67C155.422 62.5814 155.63 62.4367 155.849 62.236L156.703 63.377C156.391 63.6664 156.05 63.881 155.681 64.021C155.317 64.161 154.911 64.231 154.463 64.231ZM149.675 55.061V53.78H152.776V55.061H149.675Z" fill="#7D9093" fill-opacity="0.5"/>
4041
+ <path d="M142.24 64V53.976H145.544C146.421 53.976 147.112 54.1953 147.616 54.634C148.12 55.0726 148.372 55.6583 148.372 56.391V56.566C148.372 57.0886 148.246 57.5366 147.994 57.91C147.742 58.2833 147.38 58.5586 146.909 58.736V58.792C147.492 58.9226 147.947 59.2003 148.274 59.625C148.605 60.045 148.771 60.5606 148.771 61.172V61.361C148.771 61.893 148.645 62.3573 148.393 62.754C148.145 63.1506 147.795 63.4586 147.343 63.678C146.895 63.8926 146.365 64 145.754 64H142.24ZM143.794 62.656H145.572C146.085 62.656 146.482 62.5253 146.762 62.264C147.042 62.0026 147.182 61.6293 147.182 61.144V60.99C147.182 60.5046 147.037 60.1313 146.748 59.87C146.463 59.604 146.05 59.471 145.509 59.471H143.36V58.183H145.32C145.791 58.183 146.153 58.064 146.405 57.826C146.657 57.588 146.783 57.2496 146.783 56.811V56.685C146.783 56.2416 146.657 55.9033 146.405 55.67C146.157 55.4366 145.796 55.32 145.32 55.32H143.794V62.656Z" fill="#7D9093" fill-opacity="0.5"/>
4042
+ <rect x="18" y="17" width="246" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
4043
+ <rect x="18" y="33" width="82" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
4044
+ </svg>
4045
+ <div>
4046
+ <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4047
+ Continue to Allow
4048
+ </button>
4049
+ </div>
4050
+ `;
4051
+ const css$1 = `
4052
+ .mobile-wallet-adapter-embedded-modal-close {
4053
+ display: none;
4054
+ }
4055
+ .mobile-wallet-adapter-embedded-modal-content {
4056
+ text-align: center;
4057
+ }
4058
+ .mobile-wallet-adapter-embedded-modal-title {
4059
+ margin: 18px 100px auto 100px;
4060
+ color: #000000;
4061
+ font-size: 2.75em;
4062
+ font-weight: 600;
4063
+ }
4064
+ .mobile-wallet-adapter-embedded-modal-subtitle {
4065
+ margin: 20px 60px 40px 60px;
4066
+ color: #7D9093;
4067
+ font-size: 1.25em;
4068
+ font-weight: 400;
4069
+ }
4070
+ .mobile-wallet-adapter-embedded-modal-permission-prompt-mock {
4071
+ width: 90%;
4072
+ height: auto;
4073
+ margin: 0 auto 30px auto;
4074
+ display: block;
4075
+ }
4076
+ .mobile-wallet-adapter-embedded-modal-launch-action {
4077
+ display: block;
4078
+ width: 100%;
4079
+ height: 56px;
4080
+ font-size: 1.25em;
4081
+ background: #000000;
4082
+ color: #FFFFFF;
4083
+ border-radius: 18px;
4084
+ }
4085
+ /* Smaller screens */
4086
+ @media all and (max-width: 600px) {
4087
+ .mobile-wallet-adapter-embedded-modal-title {
4088
+ font-size: 1.5em;
4089
+ margin-right: 12px;
4090
+ margin-left: 12px;
4602
4091
  }
4603
- /** @deprecated */
4604
- stopPropagation() {
4605
- throw new Error('stopPropagation cannot be called');
4092
+ .mobile-wallet-adapter-embedded-modal-subtitle {
4093
+ margin-right: 12px;
4094
+ margin-left: 12px;
4606
4095
  }
4607
4096
  }
4608
- _RegisterWalletEvent_detail = new WeakMap();
4609
-
4097
+ `;
4098
+ //#endregion
4099
+ //#region src/getIsSupported.ts
4610
4100
  function getIsLocalAssociationSupported() {
4611
- return (typeof window !== 'undefined' &&
4612
- window.isSecureContext &&
4613
- typeof document !== 'undefined' &&
4614
- /android/i.test(navigator.userAgent));
4101
+ return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
4615
4102
  }
4616
4103
  function getIsRemoteAssociationSupported() {
4617
- return (typeof window !== 'undefined' &&
4618
- window.isSecureContext &&
4619
- typeof document !== 'undefined' &&
4620
- !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
4104
+ return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
4621
4105
  }
4622
- // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
4623
- // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
4624
4106
  function isWebView(userAgentString) {
4625
- return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
4107
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
4626
4108
  }
4627
-
4628
- function registerMwa(config) {
4629
- if (typeof window === 'undefined') {
4630
- console.warn(`MWA not registered: no window object`);
4631
- return;
4632
- }
4633
- if (!window.isSecureContext) {
4634
- console.warn(`MWA not registered: secure context required (https)`);
4635
- return;
4636
- }
4637
- // Local association technically is possible in a webview, but we prevent registration
4638
- // by default because it usually fails in the most common cases (e.g wallet browsers).
4639
- if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
4640
- registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
4641
- }
4642
- else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
4643
- registerWallet(new RemoteSolanaMobileWalletAdapterWallet(Object.assign(Object.assign({}, config), { remoteHostAuthority: config.remoteHostAuthority })));
4644
- }
4645
- else ;
4109
+ function isSolanaMobileWebShell(userAgentString) {
4110
+ return userAgentString.includes("Solana Mobile Web Shell");
4646
4111
  }
4647
-
4648
- const WALLET_NOT_FOUND_ERROR_MESSAGE = 'To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.';
4649
- const BROWSER_NOT_SUPPORTED_ERROR_MESSAGE = 'This browser appears to be incompatible with mobile wallet adapter. Open this page in a compatible mobile browser app and try again.';
4650
- class ErrorModal extends EmbeddedModal {
4651
- constructor() {
4652
- super(...arguments);
4653
- this.contentStyles = css;
4654
- this.contentHtml = ErrorDialogHtml;
4655
- }
4656
- initWithError(error) {
4657
- super.init();
4658
- this.populateError(error);
4659
- }
4660
- populateError(error) {
4661
- var _a, _b;
4662
- const errorMessageElement = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-error-message');
4663
- const actionBtn = (_b = this.dom) === null || _b === void 0 ? void 0 : _b.getElementById('mobile-wallet-adapter-error-action');
4664
- if (errorMessageElement) {
4665
- if (error.name === 'SolanaMobileWalletAdapterError') {
4666
- switch (error.code) {
4667
- case 'ERROR_WALLET_NOT_FOUND':
4668
- errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
4669
- if (actionBtn)
4670
- actionBtn.addEventListener('click', () => {
4671
- window.location.href = 'https://solanamobile.com/wallets';
4672
- });
4673
- return;
4674
- case 'ERROR_BROWSER_NOT_SUPPORTED':
4675
- errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
4676
- if (actionBtn)
4677
- actionBtn.style.display = 'none';
4678
- return;
4679
- }
4680
- }
4681
- errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
4682
- }
4683
- else {
4684
- console.log('Failed to locate error dialog element');
4685
- }
4686
- }
4112
+ function getIsPwaLaunchedAsApp() {
4113
+ const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
4114
+ if (typeof window == "undefined") return isAndroidTwa;
4115
+ const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
4116
+ const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
4117
+ const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
4118
+ return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
4119
+ }
4120
+ async function checkLocalNetworkAccessPermission() {
4121
+ if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
4122
+ try {
4123
+ const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
4124
+ if (lnaPermission.state === "granted") return;
4125
+ else if (lnaPermission.state === "denied") {
4126
+ const modal = new LoopbackPermissionBlockedModal();
4127
+ modal.init();
4128
+ modal.open();
4129
+ throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
4130
+ } else if (lnaPermission.state === "prompt") {
4131
+ const modal = new LoopbackPermissionModal();
4132
+ if (await new Promise((resolve, reject) => {
4133
+ modal.addEventListener("close", (event) => {
4134
+ if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
4135
+ });
4136
+ lnaPermission.onchange = () => {
4137
+ lnaPermission.onchange = null;
4138
+ resolve(lnaPermission.state);
4139
+ };
4140
+ modal.init();
4141
+ modal.open();
4142
+ }) === "granted") {
4143
+ const modal = new LocalConnectionModal();
4144
+ await new Promise((resolve, reject) => {
4145
+ modal.addEventListener("close", (event) => {
4146
+ if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
4147
+ });
4148
+ modal.initWithCallback(async () => {
4149
+ resolve(true);
4150
+ });
4151
+ modal.open();
4152
+ });
4153
+ return;
4154
+ } else return await checkLocalNetworkAccessPermission();
4155
+ }
4156
+ throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
4157
+ } catch (e) {
4158
+ if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
4159
+ if (e instanceof SolanaMobileWalletAdapterError) throw e;
4160
+ throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
4161
+ }
4162
+ }
4163
+ //#endregion
4164
+ //#region src/icon.ts
4165
+ const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
4166
+ //#endregion
4167
+ //#region src/wallet.ts
4168
+ const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
4169
+ const SolanaMobileWalletAdapterRemoteWalletName = "Remote Mobile Wallet Adapter";
4170
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
4171
+ const DEFAULT_FEATURES = [
4172
+ SolanaSignAndSendTransaction,
4173
+ SolanaSignTransaction,
4174
+ SolanaSignMessage,
4175
+ SolanaSignIn
4176
+ ];
4177
+ const WALLET_ASSOCIATION_TIMEOUT = 3e4;
4178
+ function getErrorMessage(error) {
4179
+ return error instanceof Error ? error.message : "Unknown error";
4180
+ }
4181
+ var LocalSolanaMobileWalletAdapterWallet = class {
4182
+ #listeners = {};
4183
+ #version = "1.0.0";
4184
+ #name = SolanaMobileWalletAdapterWalletName;
4185
+ #url = "https://solanamobile.com/wallets";
4186
+ #icon = icon;
4187
+ #appIdentity;
4188
+ #authorization;
4189
+ #authorizationCache;
4190
+ #connecting = false;
4191
+ /**
4192
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4193
+ * increment this and use it to make sure that `transact` calls from the previous
4194
+ * 'generation' don't continue to do work and throw exceptions.
4195
+ */
4196
+ #connectionGeneration = 0;
4197
+ #chains = [];
4198
+ #chainSelector;
4199
+ #optionalFeatures;
4200
+ #onWalletNotFound;
4201
+ get version() {
4202
+ return this.#version;
4203
+ }
4204
+ get name() {
4205
+ return this.#name;
4206
+ }
4207
+ get url() {
4208
+ return this.#url;
4209
+ }
4210
+ get icon() {
4211
+ return this.#icon;
4212
+ }
4213
+ get chains() {
4214
+ return this.#chains;
4215
+ }
4216
+ get features() {
4217
+ return {
4218
+ [StandardConnect]: {
4219
+ version: "1.0.0",
4220
+ connect: this.#connect
4221
+ },
4222
+ [StandardDisconnect]: {
4223
+ version: "1.0.0",
4224
+ disconnect: this.#disconnect
4225
+ },
4226
+ [StandardEvents]: {
4227
+ version: "1.0.0",
4228
+ on: this.#on
4229
+ },
4230
+ [SolanaSignMessage]: {
4231
+ version: "1.0.0",
4232
+ signMessage: this.#signMessage
4233
+ },
4234
+ [SolanaSignIn]: {
4235
+ version: "1.0.0",
4236
+ signIn: this.#signIn
4237
+ },
4238
+ ...this.#optionalFeatures
4239
+ };
4240
+ }
4241
+ get accounts() {
4242
+ return this.#authorization?.accounts ?? [];
4243
+ }
4244
+ constructor(config) {
4245
+ this.#authorizationCache = config.authorizationCache;
4246
+ this.#appIdentity = config.appIdentity;
4247
+ this.#chains = config.chains;
4248
+ this.#chainSelector = config.chainSelector;
4249
+ this.#onWalletNotFound = config.onWalletNotFound;
4250
+ this.#optionalFeatures = {
4251
+ [SolanaSignAndSendTransaction]: {
4252
+ version: "1.0.0",
4253
+ supportedTransactionVersions: ["legacy", 0],
4254
+ signAndSendTransaction: this.#signAndSendTransaction
4255
+ },
4256
+ [SolanaSignTransaction]: {
4257
+ version: "1.0.0",
4258
+ supportedTransactionVersions: ["legacy", 0],
4259
+ signTransaction: this.#signTransaction
4260
+ }
4261
+ };
4262
+ }
4263
+ get connected() {
4264
+ return !!this.#authorization;
4265
+ }
4266
+ get isAuthorized() {
4267
+ return !!this.#authorization;
4268
+ }
4269
+ get currentAuthorization() {
4270
+ return this.#authorization;
4271
+ }
4272
+ get cachedAuthorizationResult() {
4273
+ return this.#authorizationCache.get();
4274
+ }
4275
+ #on = (event, listener) => {
4276
+ this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
4277
+ return () => this.#off(event, listener);
4278
+ };
4279
+ #emit(event, ...args) {
4280
+ this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
4281
+ }
4282
+ #off(event, listener) {
4283
+ this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
4284
+ }
4285
+ #connect = async ({ silent } = {}) => {
4286
+ if (this.#connecting || this.connected) return { accounts: this.accounts };
4287
+ this.#connecting = true;
4288
+ try {
4289
+ if (silent) {
4290
+ const cachedAuthorization = await this.#authorizationCache.get();
4291
+ if (cachedAuthorization) {
4292
+ await this.#handleWalletCapabilitiesResult(cachedAuthorization.capabilities);
4293
+ await this.#handleAuthorizationResult(cachedAuthorization);
4294
+ } else return { accounts: this.accounts };
4295
+ } else await this.#performAuthorization();
4296
+ } catch (e) {
4297
+ throw new Error(getErrorMessage(e), { cause: e });
4298
+ } finally {
4299
+ this.#connecting = false;
4300
+ }
4301
+ return { accounts: this.accounts };
4302
+ };
4303
+ #performAuthorization = async (signInPayload) => {
4304
+ try {
4305
+ const cachedAuthorizationResult = await this.#authorizationCache.get();
4306
+ if (cachedAuthorizationResult) {
4307
+ this.#handleAuthorizationResult(cachedAuthorizationResult);
4308
+ return cachedAuthorizationResult;
4309
+ }
4310
+ const selectedChain = await this.#chainSelector.select(this.#chains);
4311
+ return await this.#transact(async (wallet) => {
4312
+ const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
4313
+ chain: selectedChain,
4314
+ identity: this.#appIdentity,
4315
+ sign_in_payload: signInPayload
4316
+ })]);
4317
+ const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4318
+ const authorization = {
4319
+ ...mwaAuthorizationResult,
4320
+ accounts,
4321
+ chain: selectedChain,
4322
+ capabilities
4323
+ };
4324
+ Promise.all([
4325
+ this.#handleWalletCapabilitiesResult(capabilities),
4326
+ this.#authorizationCache.set(authorization),
4327
+ this.#handleAuthorizationResult(authorization)
4328
+ ]);
4329
+ return authorization;
4330
+ });
4331
+ } catch (e) {
4332
+ throw new Error(getErrorMessage(e), { cause: e });
4333
+ }
4334
+ };
4335
+ #handleAuthorizationResult = async (authorization) => {
4336
+ const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4337
+ this.#authorization = authorization;
4338
+ if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
4339
+ };
4340
+ #handleWalletCapabilitiesResult = async (capabilities) => {
4341
+ const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
4342
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
4343
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
4344
+ this.#optionalFeatures = {
4345
+ ...(supportsSignAndSendTransaction || !supportsSignAndSendTransaction && !supportsSignTransaction) && { [SolanaSignAndSendTransaction]: {
4346
+ version: "1.0.0",
4347
+ supportedTransactionVersions: ["legacy", 0],
4348
+ signAndSendTransaction: this.#signAndSendTransaction
4349
+ } },
4350
+ ...supportsSignTransaction && { [SolanaSignTransaction]: {
4351
+ version: "1.0.0",
4352
+ supportedTransactionVersions: ["legacy", 0],
4353
+ signTransaction: this.#signTransaction
4354
+ } }
4355
+ };
4356
+ if (didCapabilitiesChange) this.#emit("change", { features: this.features });
4357
+ };
4358
+ #performReauthorization = async (wallet, authToken, chain) => {
4359
+ try {
4360
+ const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
4361
+ auth_token: authToken,
4362
+ identity: this.#appIdentity,
4363
+ chain
4364
+ })]);
4365
+ const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4366
+ const authorization = {
4367
+ ...mwaAuthorizationResult,
4368
+ accounts,
4369
+ chain,
4370
+ capabilities
4371
+ };
4372
+ Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
4373
+ } catch (e) {
4374
+ this.#disconnect();
4375
+ throw new Error(getErrorMessage(e), { cause: e });
4376
+ }
4377
+ };
4378
+ #disconnect = async () => {
4379
+ this.#authorizationCache.clear();
4380
+ this.#connecting = false;
4381
+ this.#connectionGeneration++;
4382
+ this.#authorization = void 0;
4383
+ this.#emit("change", { accounts: this.accounts });
4384
+ };
4385
+ #transact = async (callback) => {
4386
+ const walletUriBase = this.#authorization?.wallet_uri_base;
4387
+ const config = walletUriBase ? { baseUri: walletUriBase } : void 0;
4388
+ const currentConnectionGeneration = this.#connectionGeneration;
4389
+ const loadingSpinner = new EmbeddedLoadingSpinner();
4390
+ try {
4391
+ let associating = true;
4392
+ let timeout = void 0;
4393
+ const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
4394
+ loadingSpinner.init();
4395
+ const { wallet, close } = await startScenario(config);
4396
+ associating = false;
4397
+ loadingSpinner.addEventListener("close", (event) => {
4398
+ if (event) close();
4399
+ });
4400
+ loadingSpinner.open();
4401
+ const result = await callback(await wallet);
4402
+ loadingSpinner.close();
4403
+ close();
4404
+ return result;
4405
+ }), new Promise((_, reject) => {
4406
+ timeout = setTimeout(() => {
4407
+ if (associating) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
4408
+ }, WALLET_ASSOCIATION_TIMEOUT);
4409
+ })]);
4410
+ clearTimeout(timeout);
4411
+ return result;
4412
+ } catch (e) {
4413
+ loadingSpinner.close();
4414
+ if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
4415
+ if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
4416
+ throw e;
4417
+ }
4418
+ };
4419
+ #assertIsAuthorized = () => {
4420
+ if (!this.#authorization) throw new Error("Wallet not connected");
4421
+ return {
4422
+ authToken: this.#authorization.auth_token,
4423
+ chain: this.#authorization.chain
4424
+ };
4425
+ };
4426
+ #accountsToWalletStandardAccounts = (accounts) => {
4427
+ return accounts.map((account) => {
4428
+ const publicKey = toUint8Array(account.address);
4429
+ return {
4430
+ address: base58.encode(publicKey),
4431
+ publicKey,
4432
+ label: account.label,
4433
+ icon: account.icon,
4434
+ chains: account.chains ?? this.#chains,
4435
+ features: account.features ?? DEFAULT_FEATURES
4436
+ };
4437
+ });
4438
+ };
4439
+ #performSignTransactions = async (transactions) => {
4440
+ const { authToken, chain } = this.#assertIsAuthorized();
4441
+ try {
4442
+ const base64Transactions = transactions.map((tx) => {
4443
+ return fromUint8Array(tx);
4444
+ });
4445
+ return await this.#transact(async (wallet) => {
4446
+ await this.#performReauthorization(wallet, authToken, chain);
4447
+ return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(toUint8Array);
4448
+ });
4449
+ } catch (e) {
4450
+ throw new Error(getErrorMessage(e), { cause: e });
4451
+ }
4452
+ };
4453
+ #performSignAndSendTransaction = async (transaction, options) => {
4454
+ const { authToken, chain } = this.#assertIsAuthorized();
4455
+ try {
4456
+ return await this.#transact(async (wallet) => {
4457
+ const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
4458
+ if (capabilities.supports_sign_and_send_transactions) {
4459
+ const base64Transaction = fromUint8Array(transaction);
4460
+ return (await wallet.signAndSendTransactions({
4461
+ ...options,
4462
+ payloads: [base64Transaction]
4463
+ })).signatures.map(toUint8Array)[0];
4464
+ } else throw new Error("connected wallet does not support signAndSendTransaction");
4465
+ });
4466
+ } catch (e) {
4467
+ throw new Error(getErrorMessage(e), { cause: e });
4468
+ }
4469
+ };
4470
+ #signAndSendTransaction = async (...inputs) => {
4471
+ const outputs = [];
4472
+ for (const input of inputs) {
4473
+ const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
4474
+ outputs.push({ signature });
4475
+ }
4476
+ return outputs;
4477
+ };
4478
+ #signTransaction = async (...inputs) => {
4479
+ return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
4480
+ return { signedTransaction };
4481
+ });
4482
+ };
4483
+ #signMessage = async (...inputs) => {
4484
+ const { authToken, chain } = this.#assertIsAuthorized();
4485
+ const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
4486
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
4487
+ try {
4488
+ return await this.#transact(async (wallet) => {
4489
+ await this.#performReauthorization(wallet, authToken, chain);
4490
+ return (await wallet.signMessages({
4491
+ addresses,
4492
+ payloads: messages
4493
+ })).signed_payloads.map(toUint8Array).map((signedMessage) => {
4494
+ return {
4495
+ signedMessage,
4496
+ signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
4497
+ };
4498
+ });
4499
+ });
4500
+ } catch (e) {
4501
+ throw new Error(getErrorMessage(e), { cause: e });
4502
+ }
4503
+ };
4504
+ #signIn = async (...inputs) => {
4505
+ const outputs = [];
4506
+ if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
4507
+ else return [await this.#performSignIn(inputs[0])];
4508
+ return outputs;
4509
+ };
4510
+ #performSignIn = async (input) => {
4511
+ this.#connecting = true;
4512
+ try {
4513
+ const authorizationResult = await this.#performAuthorization({
4514
+ ...input,
4515
+ domain: input?.domain ?? window.location.host
4516
+ });
4517
+ if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
4518
+ const signedInAddress = authorizationResult.sign_in_result.address;
4519
+ const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
4520
+ return {
4521
+ account: {
4522
+ ...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
4523
+ publicKey: toUint8Array(signedInAddress),
4524
+ chains: signedInAccount?.chains ?? this.#chains,
4525
+ features: signedInAccount?.features ?? authorizationResult.capabilities.features
4526
+ },
4527
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4528
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
4529
+ };
4530
+ } catch (e) {
4531
+ throw new Error(getErrorMessage(e), { cause: e });
4532
+ } finally {
4533
+ this.#connecting = false;
4534
+ }
4535
+ };
4536
+ };
4537
+ var RemoteSolanaMobileWalletAdapterWallet = class {
4538
+ #listeners = {};
4539
+ #version = "1.0.0";
4540
+ #name = SolanaMobileWalletAdapterRemoteWalletName;
4541
+ #url = "https://solanamobile.com/wallets";
4542
+ #icon = icon;
4543
+ #appIdentity;
4544
+ #authorization;
4545
+ #authorizationCache;
4546
+ #connecting = false;
4547
+ /**
4548
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4549
+ * increment this and use it to make sure that `transact` calls from the previous
4550
+ * 'generation' don't continue to do work and throw exceptions.
4551
+ */
4552
+ #connectionGeneration = 0;
4553
+ #chains = [];
4554
+ #chainSelector;
4555
+ #optionalFeatures;
4556
+ #onWalletNotFound;
4557
+ #hostAuthority;
4558
+ #session;
4559
+ get version() {
4560
+ return this.#version;
4561
+ }
4562
+ get name() {
4563
+ return this.#name;
4564
+ }
4565
+ get url() {
4566
+ return this.#url;
4567
+ }
4568
+ get icon() {
4569
+ return this.#icon;
4570
+ }
4571
+ get chains() {
4572
+ return this.#chains;
4573
+ }
4574
+ get features() {
4575
+ return {
4576
+ [StandardConnect]: {
4577
+ version: "1.0.0",
4578
+ connect: this.#connect
4579
+ },
4580
+ [StandardDisconnect]: {
4581
+ version: "1.0.0",
4582
+ disconnect: this.#disconnect
4583
+ },
4584
+ [StandardEvents]: {
4585
+ version: "1.0.0",
4586
+ on: this.#on
4587
+ },
4588
+ [SolanaSignMessage]: {
4589
+ version: "1.0.0",
4590
+ signMessage: this.#signMessage
4591
+ },
4592
+ [SolanaSignIn]: {
4593
+ version: "1.0.0",
4594
+ signIn: this.#signIn
4595
+ },
4596
+ ...this.#optionalFeatures
4597
+ };
4598
+ }
4599
+ get accounts() {
4600
+ return this.#authorization?.accounts ?? [];
4601
+ }
4602
+ constructor(config) {
4603
+ this.#authorizationCache = config.authorizationCache;
4604
+ this.#appIdentity = config.appIdentity;
4605
+ this.#chains = config.chains;
4606
+ this.#chainSelector = config.chainSelector;
4607
+ this.#hostAuthority = config.remoteHostAuthority;
4608
+ this.#onWalletNotFound = config.onWalletNotFound;
4609
+ this.#optionalFeatures = {
4610
+ [SolanaSignAndSendTransaction]: {
4611
+ version: "1.0.0",
4612
+ supportedTransactionVersions: ["legacy", 0],
4613
+ signAndSendTransaction: this.#signAndSendTransaction
4614
+ },
4615
+ [SolanaSignTransaction]: {
4616
+ version: "1.0.0",
4617
+ supportedTransactionVersions: ["legacy", 0],
4618
+ signTransaction: this.#signTransaction
4619
+ }
4620
+ };
4621
+ }
4622
+ get connected() {
4623
+ return !!this.#session && !!this.#authorization;
4624
+ }
4625
+ get isAuthorized() {
4626
+ return !!this.#authorization;
4627
+ }
4628
+ get currentAuthorization() {
4629
+ return this.#authorization;
4630
+ }
4631
+ get cachedAuthorizationResult() {
4632
+ return this.#authorizationCache.get();
4633
+ }
4634
+ #on = (event, listener) => {
4635
+ this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
4636
+ return () => this.#off(event, listener);
4637
+ };
4638
+ #emit(event, ...args) {
4639
+ this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
4640
+ }
4641
+ #off(event, listener) {
4642
+ this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
4643
+ }
4644
+ #connect = async (_input = {}) => {
4645
+ if (this.#connecting || this.connected) return { accounts: this.accounts };
4646
+ this.#connecting = true;
4647
+ try {
4648
+ await this.#performAuthorization();
4649
+ } catch (e) {
4650
+ throw new Error(getErrorMessage(e), { cause: e });
4651
+ } finally {
4652
+ this.#connecting = false;
4653
+ }
4654
+ return { accounts: this.accounts };
4655
+ };
4656
+ #performAuthorization = async (signInPayload) => {
4657
+ try {
4658
+ const cachedAuthorizationResult = await this.#authorizationCache.get();
4659
+ if (cachedAuthorizationResult) {
4660
+ this.#handleAuthorizationResult(cachedAuthorizationResult);
4661
+ return cachedAuthorizationResult;
4662
+ }
4663
+ if (this.#session) this.#session = void 0;
4664
+ const selectedChain = await this.#chainSelector.select(this.#chains);
4665
+ return await this.#transact(async (wallet) => {
4666
+ const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
4667
+ chain: selectedChain,
4668
+ identity: this.#appIdentity,
4669
+ sign_in_payload: signInPayload
4670
+ })]);
4671
+ const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4672
+ const authorizationResult = {
4673
+ ...mwaAuthorizationResult,
4674
+ accounts,
4675
+ chain: selectedChain,
4676
+ capabilities
4677
+ };
4678
+ Promise.all([
4679
+ this.#handleWalletCapabilitiesResult(capabilities),
4680
+ this.#authorizationCache.set(authorizationResult),
4681
+ this.#handleAuthorizationResult(authorizationResult)
4682
+ ]);
4683
+ return authorizationResult;
4684
+ });
4685
+ } catch (e) {
4686
+ throw new Error(getErrorMessage(e), { cause: e });
4687
+ }
4688
+ };
4689
+ #handleAuthorizationResult = async (authorization) => {
4690
+ const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4691
+ this.#authorization = authorization;
4692
+ if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
4693
+ };
4694
+ #handleWalletCapabilitiesResult = async (capabilities) => {
4695
+ const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
4696
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions || capabilities.features.includes("solana:signAndSendTransaction");
4697
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
4698
+ this.#optionalFeatures = {
4699
+ ...supportsSignAndSendTransaction && { [SolanaSignAndSendTransaction]: {
4700
+ version: "1.0.0",
4701
+ supportedTransactionVersions: capabilities.supported_transaction_versions,
4702
+ signAndSendTransaction: this.#signAndSendTransaction
4703
+ } },
4704
+ ...supportsSignTransaction && { [SolanaSignTransaction]: {
4705
+ version: "1.0.0",
4706
+ supportedTransactionVersions: capabilities.supported_transaction_versions,
4707
+ signTransaction: this.#signTransaction
4708
+ } }
4709
+ };
4710
+ if (didCapabilitiesChange) this.#emit("change", { features: this.features });
4711
+ };
4712
+ #performReauthorization = async (wallet, authToken, chain) => {
4713
+ try {
4714
+ const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
4715
+ auth_token: authToken,
4716
+ identity: this.#appIdentity,
4717
+ chain
4718
+ })]);
4719
+ const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4720
+ const authorization = {
4721
+ ...mwaAuthorizationResult,
4722
+ accounts,
4723
+ chain,
4724
+ capabilities
4725
+ };
4726
+ Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
4727
+ } catch (e) {
4728
+ this.#disconnect();
4729
+ throw new Error(getErrorMessage(e), { cause: e });
4730
+ }
4731
+ };
4732
+ #disconnect = async () => {
4733
+ this.#session?.close();
4734
+ this.#authorizationCache.clear();
4735
+ this.#connecting = false;
4736
+ this.#connectionGeneration++;
4737
+ this.#authorization = void 0;
4738
+ this.#session = void 0;
4739
+ this.#emit("change", { accounts: this.accounts });
4740
+ };
4741
+ #transact = async (callback) => {
4742
+ const walletUriBase = this.#authorization?.wallet_uri_base;
4743
+ const remoteConfig = {
4744
+ ...walletUriBase ? { baseUri: walletUriBase } : void 0,
4745
+ remoteHostAuthority: this.#hostAuthority
4746
+ };
4747
+ const currentConnectionGeneration = this.#connectionGeneration;
4748
+ const modal = new RemoteConnectionModal();
4749
+ if (this.#session) return callback(this.#session.wallet);
4750
+ try {
4751
+ modal.init();
4752
+ modal.open();
4753
+ const { associationUrl, close, wallet } = await startRemoteScenario(remoteConfig);
4754
+ const removeCloseListener = modal.addEventListener("close", (event) => {
4755
+ if (event) close();
4756
+ });
4757
+ modal.populateQRCode(associationUrl.toString());
4758
+ this.#session = {
4759
+ close,
4760
+ wallet: await wallet
4761
+ };
4762
+ removeCloseListener();
4763
+ modal.close();
4764
+ return await callback(this.#session.wallet);
4765
+ } catch (e) {
4766
+ modal.close();
4767
+ if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
4768
+ if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
4769
+ throw e;
4770
+ }
4771
+ };
4772
+ #assertIsAuthorized = () => {
4773
+ if (!this.#authorization) throw new Error("Wallet not connected");
4774
+ return {
4775
+ authToken: this.#authorization.auth_token,
4776
+ chain: this.#authorization.chain
4777
+ };
4778
+ };
4779
+ #accountsToWalletStandardAccounts = (accounts) => {
4780
+ return accounts.map((account) => {
4781
+ const publicKey = toUint8Array(account.address);
4782
+ return {
4783
+ address: base58.encode(publicKey),
4784
+ publicKey,
4785
+ label: account.label,
4786
+ icon: account.icon,
4787
+ chains: account.chains ?? this.#chains,
4788
+ features: account.features ?? DEFAULT_FEATURES
4789
+ };
4790
+ });
4791
+ };
4792
+ #performSignTransactions = async (transactions) => {
4793
+ const { authToken, chain } = this.#assertIsAuthorized();
4794
+ try {
4795
+ return await this.#transact(async (wallet) => {
4796
+ await this.#performReauthorization(wallet, authToken, chain);
4797
+ return (await wallet.signTransactions({ payloads: transactions.map(fromUint8Array) })).signed_payloads.map(toUint8Array);
4798
+ });
4799
+ } catch (e) {
4800
+ throw new Error(getErrorMessage(e), { cause: e });
4801
+ }
4802
+ };
4803
+ #performSignAndSendTransaction = async (transaction, options) => {
4804
+ const { authToken, chain } = this.#assertIsAuthorized();
4805
+ try {
4806
+ return await this.#transact(async (wallet) => {
4807
+ const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
4808
+ if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
4809
+ ...options,
4810
+ payloads: [fromUint8Array(transaction)]
4811
+ })).signatures.map(toUint8Array)[0];
4812
+ else throw new Error("connected wallet does not support signAndSendTransaction");
4813
+ });
4814
+ } catch (e) {
4815
+ throw new Error(getErrorMessage(e), { cause: e });
4816
+ }
4817
+ };
4818
+ #signAndSendTransaction = async (...inputs) => {
4819
+ const outputs = [];
4820
+ for (const input of inputs) {
4821
+ const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
4822
+ outputs.push({ signature });
4823
+ }
4824
+ return outputs;
4825
+ };
4826
+ #signTransaction = async (...inputs) => {
4827
+ return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
4828
+ return { signedTransaction };
4829
+ });
4830
+ };
4831
+ #signMessage = async (...inputs) => {
4832
+ const { authToken, chain } = this.#assertIsAuthorized();
4833
+ const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
4834
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
4835
+ try {
4836
+ return await this.#transact(async (wallet) => {
4837
+ await this.#performReauthorization(wallet, authToken, chain);
4838
+ return (await wallet.signMessages({
4839
+ addresses,
4840
+ payloads: messages
4841
+ })).signed_payloads.map(toUint8Array).map((signedMessage) => {
4842
+ return {
4843
+ signedMessage,
4844
+ signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
4845
+ };
4846
+ });
4847
+ });
4848
+ } catch (e) {
4849
+ throw new Error(getErrorMessage(e), { cause: e });
4850
+ }
4851
+ };
4852
+ #signIn = async (...inputs) => {
4853
+ const outputs = [];
4854
+ if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
4855
+ else return [await this.#performSignIn(inputs[0])];
4856
+ return outputs;
4857
+ };
4858
+ #performSignIn = async (input) => {
4859
+ this.#connecting = true;
4860
+ try {
4861
+ const authorizationResult = await this.#performAuthorization({
4862
+ ...input,
4863
+ domain: input?.domain ?? window.location.host
4864
+ });
4865
+ if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
4866
+ const signedInAddress = authorizationResult.sign_in_result.address;
4867
+ const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
4868
+ return {
4869
+ account: {
4870
+ ...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
4871
+ publicKey: toUint8Array(signedInAddress),
4872
+ chains: signedInAccount?.chains ?? this.#chains,
4873
+ features: signedInAccount?.features ?? authorizationResult.capabilities.features
4874
+ },
4875
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4876
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
4877
+ };
4878
+ } catch (e) {
4879
+ throw new Error(getErrorMessage(e), { cause: e });
4880
+ } finally {
4881
+ this.#connecting = false;
4882
+ }
4883
+ };
4884
+ };
4885
+ //#endregion
4886
+ //#region src/initialize.ts
4887
+ function registerMwa(config) {
4888
+ if (typeof window === "undefined") {
4889
+ console.warn(`MWA not registered: no window object`);
4890
+ return;
4891
+ }
4892
+ if (!window.isSecureContext) {
4893
+ console.warn(`MWA not registered: secure context required (https)`);
4894
+ return;
4895
+ }
4896
+ const userAgent = navigator.userAgent;
4897
+ if (getIsLocalAssociationSupported() && (!isWebView(userAgent) || isSolanaMobileWebShell(userAgent))) registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
4898
+ else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== void 0) registerWallet(new RemoteSolanaMobileWalletAdapterWallet({
4899
+ ...config,
4900
+ remoteHostAuthority: config.remoteHostAuthority
4901
+ }));
4687
4902
  }
4903
+ //#endregion
4904
+ //#region src/embedded-modal/errorModal.ts
4905
+ const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
4906
+ const BROWSER_NOT_SUPPORTED_ERROR_MESSAGE = "This browser appears to be incompatible with mobile wallet adapter. Open this page in a compatible mobile browser app and try again.";
4907
+ var ErrorModal = class extends EmbeddedModal {
4908
+ contentStyles = css;
4909
+ contentHtml = ErrorDialogHtml;
4910
+ initWithError(error) {
4911
+ super.init();
4912
+ this.populateError(error);
4913
+ }
4914
+ populateError(error) {
4915
+ const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
4916
+ const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
4917
+ if (errorMessageElement) {
4918
+ if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
4919
+ case "ERROR_WALLET_NOT_FOUND":
4920
+ errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
4921
+ if (actionBtn) actionBtn.addEventListener("click", () => {
4922
+ window.location.href = "https://solanamobile.com/wallets";
4923
+ });
4924
+ return;
4925
+ case "ERROR_BROWSER_NOT_SUPPORTED":
4926
+ errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
4927
+ if (actionBtn) actionBtn.style.display = "none";
4928
+ return;
4929
+ }
4930
+ errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
4931
+ } else console.log("Failed to locate error dialog element");
4932
+ }
4933
+ };
4688
4934
  const ErrorDialogHtml = `
4689
4935
  <svg class="mobile-wallet-adapter-embedded-modal-error-icon" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#000000"><path d="M 280,-80 Q 197,-80 138.5,-138.5 80,-197 80,-280 80,-363 138.5,-421.5 197,-480 280,-480 q 83,0 141.5,58.5 58.5,58.5 58.5,141.5 0,83 -58.5,141.5 Q 363,-80 280,-80 Z M 824,-120 568,-376 Q 556,-389 542.5,-402.5 529,-416 516,-428 q 38,-24 61,-64 23,-40 23,-88 0,-75 -52.5,-127.5 Q 495,-760 420,-760 345,-760 292.5,-707.5 240,-655 240,-580 q 0,6 0.5,11.5 0.5,5.5 1.5,11.5 -18,2 -39.5,8 -21.5,6 -38.5,14 -2,-11 -3,-22 -1,-11 -1,-23 0,-109 75.5,-184.5 Q 311,-840 420,-840 q 109,0 184.5,75.5 75.5,75.5 75.5,184.5 0,43 -13.5,81.5 Q 653,-460 629,-428 l 251,252 z m -615,-61 71,-71 70,71 29,-28 -71,-71 71,-71 -28,-28 -71,71 -71,-71 -28,28 71,71 -71,71 z"/></svg>
4690
4936
  <div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
@@ -4744,123 +4990,80 @@ const css = `
4744
4990
  }
4745
4991
  }
4746
4992
  `;
4747
-
4748
- function defaultErrorModalWalletNotFoundHandler() {
4749
- return __awaiter(this, void 0, void 0, function* () {
4750
- if (typeof window !== 'undefined') {
4751
- const userAgent = window.navigator.userAgent.toLowerCase();
4752
- const errorDialog = new ErrorModal();
4753
- if (userAgent.includes('wv')) { // Android WebView
4754
- // MWA is not supported in this browser so we inform the user
4755
- // errorDialog.initWithError(
4756
- // new SolanaMobileWalletAdapterError(
4757
- // SolanaMobileWalletAdapterErrorCode.ERROR_BROWSER_NOT_SUPPORTED,
4758
- // ''
4759
- // )
4760
- // );
4761
- // TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
4762
- errorDialog.initWithError({
4763
- name: 'SolanaMobileWalletAdapterError',
4764
- code: 'ERROR_BROWSER_NOT_SUPPORTED',
4765
- message: ''
4766
- });
4767
- }
4768
- else { // Browser, user does not have a wallet installed.
4769
- // errorDialog.initWithError(
4770
- // new SolanaMobileWalletAdapterError(
4771
- // SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND,
4772
- // ''
4773
- // )
4774
- // );
4775
- // TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
4776
- errorDialog.initWithError({
4777
- name: 'SolanaMobileWalletAdapterError',
4778
- code: 'ERROR_WALLET_NOT_FOUND',
4779
- message: ''
4780
- });
4781
- }
4782
- errorDialog.open();
4783
- }
4784
- });
4993
+ //#endregion
4994
+ //#region src/createDefaultWalletNotFoundHandler.ts
4995
+ async function defaultErrorModalWalletNotFoundHandler() {
4996
+ if (typeof window !== "undefined") {
4997
+ const userAgent = window.navigator.userAgent.toLowerCase();
4998
+ const errorDialog = new ErrorModal();
4999
+ if (userAgent.includes("wv")) errorDialog.initWithError({
5000
+ name: "SolanaMobileWalletAdapterError",
5001
+ code: "ERROR_BROWSER_NOT_SUPPORTED",
5002
+ message: ""
5003
+ });
5004
+ else errorDialog.initWithError({
5005
+ name: "SolanaMobileWalletAdapterError",
5006
+ code: "ERROR_WALLET_NOT_FOUND",
5007
+ message: ""
5008
+ });
5009
+ errorDialog.open();
5010
+ }
4785
5011
  }
4786
5012
  function createDefaultWalletNotFoundHandler() {
4787
- return () => __awaiter(this, void 0, void 0, function* () { defaultErrorModalWalletNotFoundHandler(); });
5013
+ return async () => {
5014
+ defaultErrorModalWalletNotFoundHandler();
5015
+ };
4788
5016
  }
4789
-
4790
- const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
5017
+ //#endregion
5018
+ //#region src/createDefaultAuthorizationCache.ts
5019
+ const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
4791
5020
  function createDefaultAuthorizationCache() {
4792
- let storage;
4793
- try {
4794
- storage = window.localStorage;
4795
- // eslint-disable-next-line no-empty
4796
- }
4797
- catch (_a) { }
4798
- return {
4799
- clear() {
4800
- return __awaiter(this, void 0, void 0, function* () {
4801
- if (!storage) {
4802
- return;
4803
- }
4804
- try {
4805
- storage.removeItem(CACHE_KEY);
4806
- // eslint-disable-next-line no-empty
4807
- }
4808
- catch (_a) { }
4809
- });
4810
- },
4811
- get() {
4812
- return __awaiter(this, void 0, void 0, function* () {
4813
- if (!storage) {
4814
- return;
4815
- }
4816
- try {
4817
- const parsed = JSON.parse(storage.getItem(CACHE_KEY));
4818
- if (parsed && parsed.accounts) {
4819
- const parsedAccounts = parsed.accounts.map((account) => {
4820
- return Object.assign(Object.assign({}, account), { publicKey: 'publicKey' in account
4821
- ? new Uint8Array(Object.values(account.publicKey)) // Rebuild publicKey for WalletAccount
4822
- : base58.decode(account.address) });
4823
- });
4824
- return Object.assign(Object.assign({}, parsed), { accounts: parsedAccounts });
4825
- }
4826
- else
4827
- return parsed || undefined;
4828
- // eslint-disable-next-line no-empty
4829
- }
4830
- catch (_a) { }
4831
- });
4832
- },
4833
- set(authorization) {
4834
- return __awaiter(this, void 0, void 0, function* () {
4835
- if (!storage) {
4836
- return;
4837
- }
4838
- try {
4839
- storage.setItem(CACHE_KEY, JSON.stringify(authorization));
4840
- // eslint-disable-next-line no-empty
4841
- }
4842
- catch (_a) { }
4843
- });
4844
- },
4845
- };
5021
+ let storage;
5022
+ try {
5023
+ storage = window.localStorage;
5024
+ } catch {}
5025
+ return {
5026
+ async clear() {
5027
+ if (!storage) return;
5028
+ try {
5029
+ storage.removeItem(CACHE_KEY);
5030
+ } catch {}
5031
+ },
5032
+ async get() {
5033
+ if (!storage) return;
5034
+ try {
5035
+ const parsed = JSON.parse(storage.getItem(CACHE_KEY));
5036
+ if (parsed && parsed.accounts) {
5037
+ const parsedAccounts = parsed.accounts.map((account) => {
5038
+ return {
5039
+ ...account,
5040
+ publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : base58.decode(account.address)
5041
+ };
5042
+ });
5043
+ return {
5044
+ ...parsed,
5045
+ accounts: parsedAccounts
5046
+ };
5047
+ } else return parsed || void 0;
5048
+ } catch {}
5049
+ },
5050
+ async set(authorization) {
5051
+ if (!storage) return;
5052
+ try {
5053
+ storage.setItem(CACHE_KEY, JSON.stringify(authorization));
5054
+ } catch {}
5055
+ }
5056
+ };
4846
5057
  }
4847
-
5058
+ //#endregion
5059
+ //#region src/createDefaultChainSelector.ts
4848
5060
  function createDefaultChainSelector() {
4849
- return {
4850
- select(chains) {
4851
- return __awaiter(this, void 0, void 0, function* () {
4852
- if (chains.length === 1) {
4853
- return chains[0];
4854
- }
4855
- else if (chains.includes(SOLANA_MAINNET_CHAIN)) {
4856
- return SOLANA_MAINNET_CHAIN;
4857
- }
4858
- else
4859
- return chains[0];
4860
- });
4861
- },
4862
- };
5061
+ return { async select(chains) {
5062
+ if (chains.length === 1) return chains[0];
5063
+ else if (chains.includes(SOLANA_MAINNET_CHAIN)) return SOLANA_MAINNET_CHAIN;
5064
+ else return chains[0];
5065
+ } };
4863
5066
  }
4864
5067
 
4865
5068
  export { LocalSolanaMobileWalletAdapterWallet, RemoteSolanaMobileWalletAdapterWallet, SolanaMobileWalletAdapterRemoteWalletName, SolanaMobileWalletAdapterWalletName, createDefaultAuthorizationCache, createDefaultChainSelector, createDefaultWalletNotFoundHandler, defaultErrorModalWalletNotFoundHandler, registerMwa };
4866
- //# sourceMappingURL=index.browser-iqs5DlRU.esm.js.map
5069
+ //# sourceMappingURL=index.browser-BNdFfyIg.esm.js.map